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

Classname in instanceof cannot be null #2769

Draft
wants to merge 3 commits into
base: 1.10.x
Choose a base branch
from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Nov 23, 2023


public function sayMixed(mixed $class): void
{
var_dump(new stdClass instanceof $class);
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 sure whether we want the rule error on mixed

@@ -36,6 +36,18 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
if (!$node->class instanceof Node\Name) {
Copy link
Contributor Author

@staabm staabm Nov 23, 2023

Choose a reason for hiding this comment

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

maybe this needs to be BleedingEdge only? reworked into a level 8 rule instead

@ondrejmirtes
Copy link
Member

There are many other invalid things that can't be in instanceof: https://3v4l.org/6h0tt

This can't just be a level 8 rule. Stuff like this needs to be reported sooner: https://phpstan.org/r/caf262f8-6927-4288-8ce0-09da00a1dd1d

mixed should be reported on level 9.

To help with that you need to use RuleLevelHelper.

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.

2 participants