Skip to content

Commit

Permalink
class with final doesn't mean dynamic property is prohibited
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyan authored and ondrejmirtes committed Apr 22, 2022
1 parent fb83f47 commit e9b4a9b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
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

0 comments on commit e9b4a9b

Please sign in to comment.