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

NULL and null as a property default value are treated differently when overriding a parent property #3063

Merged
merged 1 commit into from
May 12, 2024

Conversation

staabm
Copy link
Contributor

@staabm staabm commented May 12, 2024

closes phpstan/phpstan#10987

I looked thru the codebase but could not see any other occurence with the same problem

@@ -39,7 +39,7 @@ public function processNode(Node $node, Scope $scope): array
$propertyReflection = $classReflection->getNativeProperty($node->getName());
$propertyType = $propertyReflection->getWritableType();
if ($propertyReflection->getNativeType() instanceof MixedType) {
if ($default instanceof Node\Expr\ConstFetch && (string) $default->name === 'null') {
if ($default instanceof Node\Expr\ConstFetch && $default->name->toLowerString() === 'null') {
Copy link
Contributor Author

@staabm staabm May 12, 2024

Choose a reason for hiding this comment

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

btw: the origin reporter mentioned he expected 2 errors instead. since we already have this special case for native mixed I went with 0 errors for consistency.

@ondrejmirtes ondrejmirtes merged commit d5a4746 into phpstan:1.11.x May 12, 2024
445 of 446 checks passed
@ondrejmirtes
Copy link
Member

Awesome, thank you!

@staabm staabm deleted the bug10987 branch May 12, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants