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

"Optional parameter declared before required parameter" with NULL default is not reported in PHP 8.1 #6668

Closed
luxemate opened this issue Feb 18, 2022 · 2 comments · Fixed by phpstan/phpstan-src#2963

Comments

@luxemate
Copy link

luxemate commented Feb 18, 2022

Bug report

In PHP 8.1 this code throws a deprecation warning: https://3v4l.org/ZV6On

Whereas PHPStan ignores the optional parameter if it has a NULL default.

Code snippet that reproduces the problem

With string default there's an error: https://phpstan.org/r/3b7755fa-3d5f-4c4f-a908-1fab2e418da3
With NULL default there's no error: https://phpstan.org/r/66ee3543-d33b-445b-ba59-8ef61fb76c98

Expected output

Deprecated: Optional parameter $arg2 declared before required parameter $arg3 is implicitly treated as a required parameter

@ondrejmirtes
Copy link
Member

Implemented phpstan/phpstan-src#2963

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 Apr 17, 2024
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.

2 participants