Skip to content

Modify the built-in @method extension to look at @throws in __call#1842

Merged
ondrejmirtes merged 5 commits intophpstan:1.9.xfrom
VincentLanglet:wipException
Oct 16, 2022
Merged

Modify the built-in @method extension to look at @throws in __call#1842
ondrejmirtes merged 5 commits intophpstan:1.9.xfrom
VincentLanglet:wipException

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

Comment on lines +69 to +71
$classReflection->hasNativeMethod('__call')
? $classReflection->getNativeMethod('__call')->getThrowType()
: null,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For static methods this should look at __callStatic instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed

Comment thread build/phpstan.neon Outdated
- 'PHPStan\Analyser\UndefinedVariableException'
- 'RuntimeException'
- 'Nette\Neon\Exception'
- 'Nette\MemberAccessException'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should no longer be necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed, done

private array $parameters,
private bool $isStatic,
private bool $isVariadic,
private ?Type $throwType = null,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does not need to be optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't know if i needed to be BC. Changed.

);
}

$isStatic = $methodTags[$methodName]->isStatic();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since you're extracting this into a variable, you should use this variable on line 70.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I forgot indeed, done

@ondrejmirtes ondrejmirtes changed the title Modify the built-in @method extension to look at @throws in __call. Modify the built-in @method extension to look at @throws in __call Oct 16, 2022
@ondrejmirtes ondrejmirtes merged commit ed1aff6 into phpstan:1.9.x Oct 16, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you.

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.

Looking for a way to improve @method and exceptions.

3 participants