Skip to content

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

Merged
ondrejmirtes merged 1 commit intophpstan:1.11.xfrom
staabm:bug10987
May 12, 2024
Merged

NULL and null as a property default value are treated differently when overriding a parent property#3063
ondrejmirtes merged 1 commit intophpstan:1.11.xfrom
staabm:bug10987

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

$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
@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

Development

Successfully merging this pull request may close these issues.

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

2 participants