Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Oct 31, 2025

fixes "~140 offset might not exist" errors

@staabm staabm changed the title Create PHPParser.stub Create PhpParserExpr.stub Oct 31, 2025
$parameters = null;
$singleParametersAcceptor = null;
if (count($parametersAcceptors) === 1) {
if (!array_is_list($args)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing a runtime check, to not change the phpdoc on a @api class

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this is worse because suddenly you're throwing an exception for a valid input advertised by the signature.

If it's not a list, let's make it a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea.

It might even be worth creating a new rule which errors in my wrong code example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to express the logic you'd want...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error on conditions which always lead to unchecked exceptions, when the conditions narrows a parameter type.

But you are right, maybe too specific

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd merge this if you call array_values here instead 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not at the computer until now. fix incoming ;).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also outside the entire time 😂

@staabm staabm marked this pull request as ready for review October 31, 2025 10:12
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 8c871fc into phpstan:2.1.x Oct 31, 2025
535 of 550 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the parser-stub branch October 31, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants