[wp-trac] [WordPress Trac] #37699: Death to Globals Episode #1: A Registry, A Pattern

WordPress Trac noreply at wordpress.org
Thu Sep 1 21:36:13 UTC 2016


#37699: Death to Globals Episode #1: A Registry, A Pattern
----------------------------+------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  4.7
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------

Comment (by MikeSchinkel):

 Replying to [comment:70 JamesDiGioia]:
 > FWIW, given that PHPStorm has built-in support for WordPress, there's a
 decent chance they would support the WordPress container OOTB if this
 landed.

 I am just as concerned about the fact that this pattern if included in
 WordPress will be copied ad infinitum by plugin developers and few it any
 of these plugins will get the benefit of built-in support in PhpStorm.

 > I'm not really sure the lack of IDE support should be a blocker here.

 Not a blocker, just a request to not create the issue to begin with.

 > Additionally, if you're concerned about hitting as broad a group of
 developers as possible, IDE concerns aren't that high a priority, given
 that groups 1-3 probably aren't using PHPStorm anyway.

 There is a saying ''"Make common cases easy and uncommon cases
 possible."''  Using `WP::get()` this would make those uncommon cases
 mostly not possible ''(without a lot of extra work that most people won't
 know how to do.)''.

 What I am suggesting really is as simple as this:

  If we know the name of the global variables we want to refactor -- which
 we do in all cases -- then let us create named actual methods to access
 and update them.

 BTW, we could use `WP::__callStatic()` instead of WP::get()` and then
 document all these global-state methods using PHPDoc; that would be
 another valid approach. But would be less performant.

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


More information about the wp-trac mailing list