PHPStorm still can't tell which files are being included in tracing declarations

I copied this function from one file to another, just temporarily probably, and now when I Cmd+click on it in the original file, it doesn't go to that function in the file it includes, it shows both files to choose from, even though the second file isn't included in the first file.

This should make sense easily, but here's an explicit description in case you're confused:

callingFile1.php has function call dbQuery, defined in functions1.php

callingFile2.php has function call dbQuery, defined in that file (not in a separate included file), which was just pasted temporarily from functions1.php for testing and customization if necessary. (please don't assume everything's simple and easy in this repo)

PHPStorm not checking just included files for defined functions, and checking files that are never included anywhere in that file's include tree, has been an annoyance and time waster for at least months now.

When is this going to be fixed? It's really acting stupid. PHPStorm has been smarter in the past than previous editors, and I haven't this issue with Eclipse. Is it really not possible for this to work intelligently?

0
4 comments

When is this going to be fixed? It's really acting stupid. PHPStorm has been smarter in the past than previous editors, and I haven't this issue with Eclipse. Is it really not possible for this to work intelligently?

Right now, in the current circumstances, there's a little chance it's going to. Autoloading is the standard these days and has been the standard for roughly ten years now.

Here's the request that has been declined: https://youtrack.jetbrains.com/issue/WI-21527
And more of the same sentiment can be found here: https://youtrack.jetbrains.com/issue/WI-3962

0

I guess I'm not understanding why PHPStorm, in the absence of autoloading or the ability to tell if autoloading is done, simply won't even inspect the includes in the file calling the function... which in my case tells any developer looking at the file which file to check for the defined function. If they know it's defined in two different files, then it's easy to scroll up and look which one it's using; PHPStorm can make this much easier by just going to that file instead of showing both, correct?

PHPStorm's tracing should at the very least check this, no?

I'd think it would only show both options if it can't tell, but in my case it very simply can; if it found both, it can then check to see if the file already includes one of those results. That seems simple enough, no? It's a simple priority selection.

0

Eugene, WI-21527 is not the same example I'm talking about. Max's example is two files where one has the function defined and the other calls it without including the file, and PHPStorm doesn't show a validation warning.

My situation is where I have a file calling a function that's defined in two other different files, where only one file is included, but tracing the call shows both files as where that call is going.

While both examples indicate that PHPStorm is not checking file includes, it's still bizarre to me that it isn't; maybe you can explain what you mean by autoloading (since I've seen various different ways of implementing it, PSR-proper or not), and which implementation PHPStorm chooses to base its ignorance of included/required files on.

I can see that includes/loading could be ambiguous, undeterminable (due to wonky dynamic including or loading based on how a coder or framework does it), or too time-consuming for the index to make tracing feasible, but in our repos, the previous developers' duplicate definitions based on folder context (not something I do, by the way) is difficult to work with unless an editor can quickly take me to the definition. If I can see which one it's going to by looking at the top of the file or tracing a few includes or an easily-determinable autoload path, then I'd think PHPStorm could too, if not in most cases, but in many cases to make a check worth it.

No?

0

While both examples indicate that PHPStorm is not checking file includes

Yes, that is why I shared this specific link with you, the cause in the same no matter what the case is.

maybe you can explain what you mean by autoloading (since I've seen various different ways of implementing it, PSR-proper or not)

Whatever that is not requiring/including one file after another until the whole project is bound together. You can take a look at the Composer autoloading, for instance.

and which implementation PHPStorm chooses to base its ignorance of included/required files on.

PhpStorm considers two variables with the same name defined in the same namespace but in different files the same variable. Renaming such a variable would change the name for both of them. So we don't choose a single definition, we accumulate them, as we don't know in what way autoloading works in your case.

No?

Yes. But no. Your request is valid and reasonable, but at this moment, considering how people tend to structure their projects nowadays, our team decided that they are not going to put effort into implementing this rare scenario you described. Sorry.

0

Please sign in to leave a comment.