WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #45374, comment 5


Ignore:
Timestamp:
12/06/2018 07:33:34 AM (2 years ago)
Author:
websupporter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #45374, comment 5

    initial v1  
    1919        // Somehow the &$this does not work.
    2020        apply_filters_ref_array('testFilter', ['test', &$this]);
    21         apply_filters_ref_array('testFilter', array('Test', &$this));
     21        apply_filters_ref_array('testFilter', array('Test', $this));
    2222       
    2323        // It seems to be limited to filter.
     
    2727(new Test())->run();
    2828
     29$object = new Test();
     30apply_filters_ref_array('testFilter', ['test', $object]);
    2931/**
    30  * These do not throw.
     32 * This does not throw.
    3133 */
    32 $object = new Test();
    33 apply_filters_ref_array('posts_clauses2', ['test', $object]);
    34 apply_filters_ref_array('posts_clauses2', ['test', &$object]);
     34apply_filters_ref_array('testFilter', ['test', &$object]);
    3535}}}
    3636
     
    4444
    4545As you can see, here `$this` is not referenced, although I do ''not'' change the `$args`. Also noteworthy, in this example I can change `$args[0]` without having another problem (except for the PHP 7.1.25).
     46
     47''Edit: I edited my code example for clarification, but it didn't change my outcomes.''