[wp-trac] [WordPress Trac] #20683: WP_Dependencies' constructor should accept a string/array value for $deps rather than converting a string to an empty array

WordPress Trac wp-trac at lists.automattic.com
Tue May 15 20:12:39 UTC 2012


#20683: WP_Dependencies' constructor should accept a string/array value for $deps
rather than converting a string to an empty array
-------------------------+-----------------------------
 Reporter:  vhauri       |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 Currently, WP_Dependencies' constructor takes any $deps value that's not
 an array and converts it to an empty array. I propose bringing the
 constructor's behavior more in line with standard WP function paramater
 behavior by accepting a string as a single dependency. Essentially this
 involves adding an is_string() check on $deps before checking if it's not
 an array, and creating an array with a single element in the case that it
 is a string.


 {{{
 if ( !is_array($this->deps) )
   $this->deps = array();
 }}}

 becomes

 {{{
 if ( is_string( $this->deps ) )
   $this->deps = (array) $this->deps;
 elseif ( !is_array( $this->deps ) )
   $this->deps = array();
 }}}

 See the attached diff for a proposed patch.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20683>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list