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

class with final doesn't mean dynamic property is prohibited #1238

Merged
merged 1 commit into from Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Type/ObjectType.php
Expand Up @@ -129,10 +129,6 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createYes();
}

if ($classReflection->isFinal()) {
return TrinaryLogic::createNo();
}

return TrinaryLogic::createMaybe();
}

Expand Down
Expand Up @@ -100,10 +100,6 @@ public function testImpossibleCheckTypeFunctionCall(): void
'Call to function property_exists() with $this(CheckTypeFunctionCall\FinalClassWithPropertyExists) and \'fooProperty\' will always evaluate to true.',
209,
],
[
'Call to function property_exists() with $this(CheckTypeFunctionCall\FinalClassWithPropertyExists) and \'barProperty\' will always evaluate to false.',
212,
],
[
'Call to function in_array() with arguments int, array{\'foo\', \'bar\'} and true will always evaluate to false.',
235,
Expand Down Expand Up @@ -273,10 +269,6 @@ public function testImpossibleCheckTypeFunctionCallWithoutAlwaysTrue(): void
'Call to function method_exists() with $this(CheckTypeFunctionCall\FinalClassWithMethodExists) and \'doBar\' will always evaluate to false.',
194,
],
[
'Call to function property_exists() with $this(CheckTypeFunctionCall\FinalClassWithPropertyExists) and \'barProperty\' will always evaluate to false.',
212,
],
[
'Call to function in_array() with arguments int, array{\'foo\', \'bar\'} and true will always evaluate to false.',
235,
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Type/Accessory/HasPropertyTypeTest.php
Expand Up @@ -47,7 +47,7 @@ public function dataIsSuperTypeOf(): array
[
new HasPropertyType('foo'),
new ObjectType(Closure::class),
TrinaryLogic::createNo(),
TrinaryLogic::createMaybe(),
],
[
new HasPropertyType('foo'),
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Type/ObjectTypeTest.php
Expand Up @@ -260,7 +260,7 @@ public function dataIsSuperTypeOf(): array
32 => [
new ObjectType(Closure::class),
new HasPropertyType('d'),
TrinaryLogic::createNo(),
TrinaryLogic::createMaybe(),
],
33 => [
new ObjectType(DateInterval::class),
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Type/TypeCombinatorTest.php
Expand Up @@ -2512,8 +2512,8 @@ public function dataIntersect(): iterable
new ObjectType(FinalClassWithPropertyExists::class),
new HasPropertyType('barProperty'),
],
NeverType::class,
'*NEVER*',
IntersectionType::class,
'CheckTypeFunctionCall\FinalClassWithPropertyExists&hasProperty(barProperty)',
],
[
[
Expand Down