phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

[FIX] dynamic variable undefined inside `isset`

Open ga-devfront opened this issue 6 months ago • 6 comments

Fix https://github.com/phpstan/phpstan/issues/13353 This is the fix for the issue above. If you see any changes to make, please let me know; this is my first contribution to the project.

ga-devfront avatar Aug 07 '25 06:08 ga-devfront

Please look at this problem more thoroughly. There's IssetCheck (

https://github.com/phpstan/phpstan-src/blob/5a3990227e64a66b058a96753887e4aa7d411b92/src/Rules/IssetCheck.php#L45

) used by several rules where only Variable with string name property is being handled, but the code might find some improvements to the logic useful.

It was my first idea to fix the problem in the IssetCheck, however, the error being returned actually comes from DefinedVariableRule. Being new to the project, I don't yet understand how it all works. However, if you could tell me a little more about what you'd like to see added, there's no problem; I'm open to any suggestions. I've added the tests as requested.

ga-devfront avatar Sep 01 '25 15:09 ga-devfront

IssetCheck is used by IssetRule and others. Look at IssetRuleTest what it detects.

You should be able to produce some tests with $$ to see what's currently wrong about the behaviour.

ondrejmirtes avatar Sep 02 '25 05:09 ondrejmirtes

IssetCheck is used by IssetRule and others. Look at IssetRuleTest what it detects.

You should be able to produce some tests with $$ to see what's currently wrong about the behaviour.

As you can see, I added the tests in IssetRuleTest.php, but nothing is thrown. Maybe I missed something, feel free to let me know.

ga-devfront avatar Sep 02 '25 07:09 ga-devfront

The branch has conflict @ga-devfront ; are you interested in rebasing/finishing the PR ?

VincentLanglet avatar Oct 19 '25 10:10 VincentLanglet

The branch has conflict @ga-devfront ; are you interested in rebasing/finishing the PR ?

Rebase done. But don't know what to do more for finishing it.

ga-devfront avatar Oct 20 '25 07:10 ga-devfront

@ondrejmirtes up please :heart:

ga-devfront avatar Nov 17 '25 10:11 ga-devfront