[wp-trac] [WordPress Trac] #40332: Is passing arguments by reference in Walker_Nav_Menu methods needed?

WordPress Trac noreply at wordpress.org
Thu Jun 15 14:14:20 UTC 2017


#40332: Is passing arguments by reference in Walker_Nav_Menu methods needed?
---------------------------+--------------------------
 Reporter:  dingo_bastard  |       Owner:
     Type:  enhancement    |      Status:  closed
 Priority:  normal         |   Milestone:
Component:  Menus          |     Version:  4.7.3
 Severity:  normal         |  Resolution:  invalid
 Keywords:                 |     Focuses:  performance
---------------------------+--------------------------
Changes (by welcher):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 @dingo_bastard thanks for the ticket! The pass by reference operator
 allows the function to modify the passed variable without returning it.

 See the example below.
 {{{
 class Reference_Test {
         public function pass_by_reference( &$output ) {
                 $output .= ' : Passed By Reference';
         }

         public function no_reference( $output  ) {
                 $output .= ' : No Reference';
         }
 }

 $output = 'Start';
 $test   = new Reference_Test();

 $test->pass_by_reference( $output );
 $test->no_reference( $output );

 echo $output; // Output is "Start : Passed By Reference"

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40332#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list