[wp-trac] [WordPress Trac] #22251: Helper function to simplify checking for constants

WordPress Trac noreply at wordpress.org
Mon Oct 22 01:36:13 UTC 2012


#22251: Helper function to simplify checking for constants
-------------------------+------------------------------
 Reporter:  evansolomon  |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------

Comment (by nacin):

 If we are to do something like `wp_constant()` it woud probably be so
 constants are pluggable (for testing purposes). This patch conflates not
 defining a constant with defining it as something that evaluates to false.
 In core, we make that assumption often, but in a generic function, we may
 not be able to, which means we might be in a situation where we need
 multiple functions just to be able to test everything.

 We've reduces the use of the defined && constant pattern a few times
 before, notably with WP_DEBUG, which is automatically defined as false if
 it is not defined before the bootstrap begins to load.

 I think this is clever but I would like to see what some PHP frameworks
 use to work with constants (for the ones they don't avoid). It'd be nice
 to see what we can do to reduce the number of constants we have. Those 57
 instances have 30 unique constants among them.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22251#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list