How to reference (but not include) external files to not get "undefined function" warnings by PHPStorm?

Hi guys,

a.php gets executed which includes functions.php and b.php.  b.php contains function references which functions are defined in functions.php, but does not include functions.php directly.  PHPStorms highlights the "undefined" functions in b.php.  I don't wanna explicitly include functions.php from b.php.  How can I make PHPStorm figure out to use the functions defined in functions.php?

Thanks in advance,
Laci

0
4 comments

Hi there,

If those are functions, then PhpStorm should pick them up as long as they part of the project (no need for explicit include/require statements -- just to be placed anywhere in a project). For example, this will work just fine (for PhpStorm when resolving function names):

PROJECT_ROOT/a.php

<?php
$a = some_function('hello');
echo $a;


PROJECT_ROOT/includes/functions.php

<?php
function some_function ($text)
{
    return '<[[' . $text . ']]>';
}


Since your description is very simplified, I cannot give you definite answer what you need to do.

Are you including some 3rd party library or what? If so -- then maybe include it into a project as External Library (Settings | PHP | Include paths) -- same kind of idea as PHP's own include_path settings.

If it's something else -- then please provide more details -- real example would be good.

0
Avatar
Permanently deleted user

Thanks for your quick reply!

Since then I created a simple project just like your example and there were no undefined messages displayed by PHPStorm, indeed.

Despite of this my own project still displayed these warnings.  At this point I copied my whole project into another directory and opened the copied project with PHPStorm.  Magic, everything worked!

I consider this issue resolved, althought chances are there is some bug lurking in the background.

Laci

0

In this case please try File | Invalidate Caches next time.

0
Avatar
Permanently deleted user

Will do.

Thanks for the excellent support!

0

Please sign in to leave a comment.