Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function getName() on null in QueryBuilderInjectionRule.php:388 #4

Open
testdev4 opened this issue Nov 12, 2019 · 2 comments

Comments

@testdev4
Copy link

Any ideas? phpstan version is 0.11.19, latest DVWA and oroinc/phpstan-rules from master

~/Development/DVWA-master$ phpstan analyze --debug -l 7 -c /home/testdev4/Development/phpstan-rules/rules.neon -a /home/testdev4/Development/phpstan-rules/vendor/autoload.php *.php
/home/testdev4/Development/DVWA-master/about.php
PHP Fatal error: Uncaught Error: Call to a member function getName() on null in /home/testdev4/Development/phpstan-rules/src/Oro/Rules/Methods/QueryBuilderInjectionRule.php:388
Stack trace:
#0 /home/testdev4/Development/phpstan-rules/src/Oro/Rules/Methods/QueryBuilderInjectionRule.php(567): Oro\Rules\Methods\QueryBuilderInjectionRule->isUnsafeVariable(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\Scope))
#1 /home/testdev4/Development/phpstan-rules/src/Oro/Rules/Methods/QueryBuilderInjectionRule.php(490): Oro\Rules\Methods\QueryBuilderInjectionRule->isUnsafe(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\Scope))
#2 /home/testdev4/Development/phpstan-rules/src/Oro/Rules/Methods/QueryBuilderInjectionRule.php(572): Oro\Rules\Methods\QueryBuilderInjectionRule->isUnsafeArrayDimFetch(Object(PhpParser\Node\Expr\ArrayDimFetch), Object(PHPStan\Analyser\Scope))
#3 /home/testdev4/Development/phpstan-rules/src/Oro/Rules/Methods/QueryBuilderInjectionRule.php(372): Oro\Rules\Methods\QueryBuilderInjectionRule->isUns in /home/testdev4/Development/phpstan-rules/src/Oro/Rules/Methods/QueryBuilderInjectionRule.php on line 388

@testdev4
Copy link
Author

Steps to reproduce:

export PATH=$PATH:$HOME/.config/composer/vendor/bin
composer require phpstan/phpstan

cd ~/Development
git clone [email protected]:oroinc/phpstan-rules.git
cd ~/Development/phpstan-rules
composer install

git clone [email protected]:ethicalhack3r/DVWA.git
cd ~/Development/DVWA-master
composer install
phpstan analyze --debug -c ~/Development/phpstan-rules/rules.neon -a ~/Development/phpstan-rules/vendor/autoload.php .

@powli
Copy link

powli commented May 7, 2024

ℹ️ The error occurs as soon as you are analyzing a non-class context. The isUnsafeVariable method wrongly assumes to be in a class context, even if it is not, resulting in the error described above. This also occurs on Bundles install.php scripts, e.g. WebsiteBundle::install.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants