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

WordPress Trac noreply at wordpress.org
Mon Oct 22 05:25:47 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 MikeSchinkel):

 Replying to [comment:12 rmccue]:
 > I completely agree, but I think if they're going to be uppercase, then
 they need to be only settable once so that they act like constants. That's
 why my personal preference would be to use lowercased properties just as
 normal properties.

 This approach could not support that ''and'' also offer the fast access to
 the properties.  I guess it could be extended to have ''"read-only
 constants"'' by storing those in an internal array and thus always using
 the magic methods for access but the tradeoffs would obviously be slower
 access. That might be okay for constants not used often.

 But even so, I've only seen immutable constants causing trouble vs.
 helping ''(such as for testing)''; in contrast I haven't seen any real
 issues with `get_option()` values being mutable.

 > That was for if they could only be set in `wp-config.php`, where I can
 see problems with using includes in the config causing the complicated
 setter stuff to fail.

 I ''think'' this approach bypasses those issues. Maybe, maybe not?

 > I personally would prefer eliminating the constants and constant-like
 behaviour (immutability) in favour of simply using properties (also
 renaming some such as `$wp->db['host'] = 'localhost'` etc.).

 Agreed. Obviously. :)

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


More information about the wp-trac mailing list