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

ini_get() analysis should be aware of whether an option exists or not #3063

Closed
dktapps opened this issue Mar 5, 2020 · 5 comments · Fixed by phpstan/phpstan-src#2362
Closed

Comments

@dktapps
Copy link
Contributor

dktapps commented Mar 5, 2020

Feature request

ini_get() returns false only when the directive specified does not exist.

substr() will never receive false in this code because the date.timezone ini directive always exists.
https://phpstan.org/r/6cdcdcb9-aa0c-4848-b727-4b2cf8e225e7

The above code should not report any errors.

@ondrejmirtes
Copy link
Member

Yeah, a simple dynamic return type extension would solve this.

@phpstan-bot
Copy link
Contributor

@dktapps PHPStan now reports different result with your code snippet:

@@ @@
-7: Parameter #1 $str of function substr expects string, string|false given.
+7: Parameter #1 $string of function substr expects string, string|false given.
Full report
Line Error
7 `Parameter #1 $string of function substr expects string, string

@phpstan-bot
Copy link
Contributor

@dktapps After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
- 7: Parameter #1 $str of function substr expects string, string|false given.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Full report
Line Error
-1 Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40Run PHPStan with --debug option and post the stack trace to:https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md

@ondrejmirtes
Copy link
Member

Implemented by phpstan/phpstan-src#2362

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants