Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions lib/class-method-call-reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,37 @@ public function isStatic() {
*/
protected function _getClassMapping() {

// Keys are receiver expressions as printed by the pretty printer, so
// global variables keep their `$` sigil.
// List of global use generated using following command:
// ack "global \\\$[^;]+;" --no-filename | tr -d '\t' | sort | uniq | sed "s/global //g" | sed "s/, /,/g" | tr , '\n' | sed "s/;//g" | sort | uniq | sed "s/\\\$//g" | sed "s/[^ ][^ ]*/'&' => ''/g"
// ack "global \\\$[^;]+;" --no-filename | tr -d '\t' | sort | uniq | sed "s/global //g" | sed "s/, /,/g" | tr , '\n' | sed "s/;//g" | sort | uniq | sed "s/[^ ][^ ]*/'&' => ''/g"
// There is probably an easier way, there are currently no globals that are classes starting with an underscore
$wp_globals = array(
'authordata' => 'WP_User',
'custom_background' => 'Custom_Background',
'custom_image_header' => 'Custom_Image_Header',
'phpmailer' => 'PHPMailer',
'post' => 'WP_Post',
'userdata' => 'WP_User', // This can also be stdClass, but you can't call methods on an stdClass
'wp' => 'WP',
'wp_admin_bar' => 'WP_Admin_Bar',
'wp_customize' => 'WP_Customize_Manager',
'wp_embed' => 'WP_Embed',
'wp_filesystem' => 'WP_Filesystem',
'wp_hasher' => 'PasswordHash', // This can be overridden by plugins, for core assume this is ours
'wp_json' => 'Services_JSON',
'wp_list_table' => 'WP_List_Table', // This one differs because there are a lot of different List Tables, assume they all only overwrite existing functions on WP_List_Table
'wp_locale' => 'WP_Locale',
'wp_object_cache' => 'WP_Object_Cache',
'wp_query' => 'WP_Query',
'wp_rewrite' => 'WP_Rewrite',
'wp_roles' => 'WP_Roles',
'wp_scripts' => 'WP_Scripts',
'wp_styles' => 'WP_Styles',
'wp_the_query' => 'WP_Query',
'wp_widget_factory' => 'WP_Widget_Factory',
'wp_xmlrpc_server' => 'wp_xmlrpc_server', // This can be overridden by plugins, for core assume this is ours
'wpdb' => 'wpdb',
'$authordata' => 'WP_User',
'$custom_background' => 'Custom_Background',
'$custom_image_header' => 'Custom_Image_Header',
'$phpmailer' => 'PHPMailer',
'$post' => 'WP_Post',
'$userdata' => 'WP_User', // This can also be stdClass, but you can't call methods on an stdClass
'$wp' => 'WP',
'$wp_admin_bar' => 'WP_Admin_Bar',
'$wp_customize' => 'WP_Customize_Manager',
'$wp_embed' => 'WP_Embed',
'$wp_filesystem' => 'WP_Filesystem',
'$wp_hasher' => 'PasswordHash', // This can be overridden by plugins, for core assume this is ours
'$wp_json' => 'Services_JSON',
'$wp_list_table' => 'WP_List_Table', // This one differs because there are a lot of different List Tables, assume they all only overwrite existing functions on WP_List_Table
'$wp_locale' => 'WP_Locale',
'$wp_object_cache' => 'WP_Object_Cache',
'$wp_query' => 'WP_Query',
'$wp_rewrite' => 'WP_Rewrite',
'$wp_roles' => 'WP_Roles',
'$wp_scripts' => 'WP_Scripts',
'$wp_styles' => 'WP_Styles',
'$wp_the_query' => 'WP_Query',
'$wp_widget_factory' => 'WP_Widget_Factory',
'$wp_xmlrpc_server' => 'wp_xmlrpc_server', // This can be overridden by plugins, for core assume this is ours
'$wpdb' => 'wpdb',
);

$wp_functions = array(
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/export/uses/methods.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ class My_Class extends Parent_Class {
parent::do_parental_stuff();
}
}

$wp_the_query->get( 'paged' );
12 changes: 11 additions & 1 deletion tests/phpunit/tests/export/uses/methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,17 @@ public function test_instance_methods() {
'name' => 'update',
'line' => 5,
'end_line' => 5,
'class' => '$wpdb',
'class' => 'wpdb',
'static' => false,
)
);

$this->assertFileUsesMethod(
array(
'name' => 'get',
'line' => 23,
'end_line' => 23,
'class' => 'WP_Query',
'static' => false,
)
);
Expand Down