Suppressing missing function warning

In phpStorm 6, sometimes my php files use global variables and IDE gives warning.
To suppress warnings for that file I add this to the top of file:

/**
* @var $myVariable1 string
* @var $myVariable2 string
*/

But I have also this code:
if ( extension_loaded('thirdPartyExtension') ) { echo do_something(); }

Is it possible to write something inside comments and phpStorm won't give warning for "do_something()" function ?

0
3 comments

Hi there,

Is it possible to write something inside comments and phpStorm won't give warning for "do_something()" function ?

Create a stub for such function in PHP (proper function declaration with PHPDoc if available/required .. just empty body) and place it anywhere in your project (e.g. _ide_helper.php -- this file will be used by IDE only). This is how it's done for all known to PhpStorm functions/classes/extensions anyway (just Ctrl+Click on any standard class/function and see yourself).

0

In phpStorm 6, sometimes my php files use global variables and IDE gives warning.
To suppress warnings for that file I add this to the top of file:

/**
* @var $myVariable1 string
* @var $myVariable2 string
*/

If those variables are actually globals and code is yours ...  then try declaring them using global keyword -- should work across whole project with no need for additional comments elsewhere.

I mean this kind of things:

/** @var $myObject SomeClass */

global $myObject;

0

Thank you. This worked great.

0

Please sign in to leave a comment.