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

WordPress Trac noreply at wordpress.org
Sat Apr 1 16:38:31 UTC 2017


#40332: Is passing arguments by reference in Walker_Nav_Menu methods needed?
---------------------------+-----------------------------
 Reporter:  dingo_bastard  |      Owner:
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Menus          |    Version:  4.7.3
 Severity:  normal         |   Keywords:
  Focuses:  performance    |
---------------------------+-----------------------------
 From what I've read, since PHP 5 objects are automatically passed by
 reference, and in the `Walker_Nav_Menu` class we have methods that have
 arguments that are passed by reference like

 {{{#!php
 public function start_lvl( &$output, $depth = 0, $args = array() ) {
         if ( isset( $args->item_spacing ) && 'discard' ===
 $args->item_spacing ) {
                 $t = '';
                 $n = '';
         } else {
                 $t = "\t";
                 $n = "\n";
         }
         $indent = str_repeat( $t, $depth );
         $output .= "{$n}{$indent}<ul class=\"sub-menu\">{$n}";
 }
 }}}

 So my question is: is this necessary? Especially given the fact that
 wordpress.org recommends the users to install it on
 [[https://wordpress.org/about/requirements/|PHP7 or greater]].
 Is this because of backwards compatibility or?

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


More information about the wp-trac mailing list