[wp-trac] [WordPress Trac] #22234: Use access modifiers in classes, not the var keyword

WordPress Trac noreply at wordpress.org
Mon Oct 22 03:41:23 UTC 2012


#22234: Use access modifiers in classes, not the var keyword
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Future Release
Component:  General         |     Version:  1.5
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |
----------------------------+-----------------------------

Comment (by nacin):

 All new classes and properties (since 3.2) get proper visibility keywords.
 For existing properties, I have been following this guideline:

  * If the property is public, declare it as such. If the property is
 designed to be protected or private but cannot be, keep "var" rather than
 announcing that it is "public" and keep @access.

 I've begin to experiment with something else for wpdb: begin to set older
 properties as protected or private, but then providing a magic
 getter/setter to handle those values. That way, the functionality is the
 same, but A) the declarations and docs are accurate and B) we can throw
 deprecated property notices (but don't yet).

 The pattern wpdb uses might not be perfect for all classes, though, in
 that PHP's magic methods aren't uniformly used and therefore it might not
 be backwards compatible for all use cases. (We ran into some issues in
 hyperdb but got that fixed, and otherwise wpdb access is uncommon.)

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


More information about the wp-trac mailing list