global $object = undefined method warning
I've run into a slight issue with wordpress plugins, where I use the global database object ($wpdb) for queries.
it works fine, but PHPStorm highlights all methods (e.g. $wpdb->get_var() ) as undefined and also does not offer code completion for the methods or properties.
jumping to the declaration of $wpdb (cmd-b), points to the wrong location: a file (/wp-admin/includes/schema.php) where $wpdb is included as global, but not where the object is created or the class is defined (/wp-includes/wp-db.php).
is there something I can do to fix this behavior, or is this an issue for the tracker?
any help appreciated.
请先登录再写评论。
just in case anyone else stumbles across this thread,
adding the following to the plugin file, does the job:
now the inspections and code completion work as beautiful as ever.
Nonono, you should use next phpdoc instead:
thats far better.
thank you very much.