Const variables, show path

Hello, can you help me please, how to let PHPSTorm known a path to files when using variables, constants ?
For example i set:
require_once $SERVER['DOCUMENT_ROOT']."/_const/base.php;
and this works, but PHPStorm highlights word '_const' like, Path '_const' not found. But how can i fix this ? 

2 comments

Hi there,

It's not possible -- currently PhpStorm cannot not evaluate what $_SERVER['DOCUMENT_ROOT'] is (such info is only available during runtime) -- http://youtrack.jetbrains.com/issue/WI-3321

Your only solution right now is to either disable this inspection completely (it does not do much anyway) -- Settings | Inspections | PHP | General | Unresolved Include
.. or just suppress it for that line only:

  • Alt+Enter while cursor standing on problematic place
  • Arrow right
  • Suppress for statement

screen01.png

Final result would be:

/** @noinspection PhpIncludeInspection */
require_once $_SERVER['DOCUMENT_ROOT']."/_const/base.php;


P.S.
BTW -- I assume you have typo there as it should be $_SERVER instead of  $SERVER

0

Okay, i got it. Thank you ;)
Yeap, sorry, my mistake - not "$SERVER", but $_SERVER .

0

Please sign in to leave a comment.