Few questions regarding functionality...
Hey guys, coming from notepad++, PhpStorm is utterly amazing, however I'm trying to figure out if I'm doing something wrong of if PhpStorm just doesn't work this way. The two biggest questions I have at the moment are:
I believe I read on this forum that PhpStorm's Inspect Code doesn't "read"/"parse" (I am using a local php server setup and PhpStorm sees it) include/require files and/or variables? As an example, I have two files: index.php, core.php. Inside index.php it calls core.php via require_once 'core.php'. If I Inspect Code on index.php it says $variable is undefined. Well yes, it is, in index.php however it's defined inside of a while loop in core.php. Is that expected behavior to show it as undefined, just this in this example (inside a while loop) or will it always say it's undefined since it's not actually defined in index.php?
In the same type of example, how does "Unused local variable" work? I try another test and remove any calls to $variable in either file (although $variable IS still defined inside of the while loop) and Inspect Code doesn't show $variable as unused?
Thanks for any clarification.
Please sign in to leave a comment.
> If I Inspect Code on index.php it says $variable is undefined.
This is usually due to incorrectly set "require_once" paths.
IDE doesn't "run" the code and unable to know the value of variables, but if the variable is in a code - IDE should be able to navigate to it's usages/definitions.
> although $variable IS still defined inside of the while loop
This most likely causes inspection to count $variable as used. Can't say for sure without inspecting the file/project unfortunately.
What is the proper way to include/require files?
As to your second response:
while ($the_materialsCubicYards = $stmt->fetch()) {$directCostCubicYards[$the_materialsCubicYards['name']] = $the_materialsCubicYards;
}
As the test, the absolute only place $directCostCubicYards is used is in this file. Would it or would it not be considered an unused variable?