[wp-trac] [WordPress Trac] #35058: PHP Fatal when map_deep tries to work on an object that has a property by reference

WordPress Trac noreply at wordpress.org
Sun Dec 13 20:49:59 UTC 2015


#35058: PHP Fatal when map_deep tries to work on an object that has a property by
reference
--------------------------+------------------------------
 Reporter:  jeff@…        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Formatting    |     Version:  4.4
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by jeff@…):

 This is my adjusted function...


 {{{
 /**
  * Maps a function to all non-iterable elements of an array or an object.
  *
  * This is similar to `array_walk_recursive()` but acts upon objects too.
  *
  * @since 4.4.0
  *
  * @param mixed    $value    The array, object, or scalar.
  * @param callable $callback The function to map onto $value.
  * @return The value with the callback applied to all non-arrays and non-
 objects inside it.
  */
 function map_deep( $value, $callback ) {
         if ( is_array( $value ) || is_object( $value ) ) {
                 foreach ( $value as $index => $item ) {
                         $value[$index] = map_deep( $item, $callback );
                 }
                 return $value;
         } else {
                 return call_user_func( $callback, $value );
         }
 }

 }}}

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


More information about the wp-trac mailing list