Reputation: 3580
In my PhpStorm project, I have the following 3 files:
sub.php:
<?php
function do_something() {
// do something
}
?>
sub_debug.php:
<?php
function do_something() {
// do something with debugging
}
?>
main.php:
<?php
include 'sub.php';
do_something();
?>
So in my main.php, I usually include sub.php
, and only switch to sub_debug.php
if I need to do some debugging. So at any one time, I only include one of those two PHP files, and only one do_something()
function is in scope.
However, when I CTRL-click on the do_something()
call in main.php
in PhpStorm, it still informs me that there are multiple implementations and prompt me to select one.
Is it possible to configure PhpStorm to only link to include
-d codes and not all PHP files in the project?
Upvotes: 1
Views: 268
Reputation: 165148
PhpStorm does not take include
/require
statements into consideration when dealing with definitions -- it assumes (for convenience and performance reasons) that all global entities (like functions/classes etc) are always accessible (e.g. classes can be auto loaded .. or necessary file with functions is included/required in another place).
Think about this case: in your main.php
you include another file (e.g. include 'another.php';
) and in that another.php
file you call do_something();
.
Considering that another.php
does not have any include/require statements -- how IDE should know for sure which do_something();
to go here?
With the current approach it provides the same user experience in both cases.
In any case: https://youtrack.jetbrains.com/issue/WI-4095 seems related to your request.
Consider watching this and related tickets (str/vote/comment) to get notified on any progress.
Upvotes: 3