[wp-trac] [WordPress Trac] #32139: Add PHPDoc for all global $wp_query in /wp-includes/query.php

WordPress Trac noreply at wordpress.org
Mon Apr 27 17:11:23 UTC 2015


#32139: Add PHPDoc for all global $wp_query in /wp-includes/query.php
------------------------------------+------------------------------
 Reporter:  MikeSchinkel            |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Query                   |     Version:  trunk
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  docs
------------------------------------+------------------------------

Comment (by MikeSchinkel):

 Replying to [comment:4 jdgrimes]:

 So I modified core and added a file `/wp-includes/phpdoc/globals.php`.
 Then just after the call to `wp_initial_constants()` in `/wp-settings.php`
 I added the following code:

 {{{
 set_include_path( get_include_path() . ':' . ABSPATH . WPINC . '/phpdoc'
 );
 require( ABSPATH . WPINC . '/phpdoc/globals.php' );
 }}}

 In `/phpdoc/globals.php` I added the following:

 {{{
 <?php
 /**
  * @var WP_Query $wp_query
  */
 }}}

 I then ran PhpStorm to the line after the `require( ABSPATH . WPINC .
 '/phpdoc/globals.php' );` in the debugger and navigated to `/wp-
 includes/query.php` but PhpStorm did not recognize the type of `$wp_query`
 in that file.

 Did I do something wrong?  Asked another way, what patch can we (you & I)
 propose that will allow PhpStorm to recognize well-known global variables
 in WordPress?

 ''(BTW, doing it with the PHP path seems like just a hack for PhpStorm;
 documenting every location at the source seems more like the correct thing
 to do since it is not just for PhpStorm, no?)''

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


More information about the wp-trac mailing list