Skip to content

Commit af0c980

Browse files
Try
1 parent 8f4e3bc commit af0c980

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ parameters:
14641464
-
14651465
rawMessage: 'Doing instanceof PHPStan\Type\ObjectShapeType is error-prone and deprecated. Use Type::isObject() and Type::hasProperty() instead.'
14661466
identifier: phpstanApi.instanceofType
1467-
count: 3
1467+
count: 2
14681468
path: src/Type/ObjectShapeType.php
14691469

14701470
-

src/Type/ObjectShapeType.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,14 @@ public function getUnresolvedPropertyPrototype(string $propertyName, ClassMember
113113

114114
public function hasInstanceProperty(string $propertyName): TrinaryLogic
115115
{
116-
if (!array_key_exists($propertyName, $this->properties)) {
117-
return TrinaryLogic::createNo();
118-
}
119-
120-
if (in_array($propertyName, $this->optionalProperties, true)) {
121-
return TrinaryLogic::createMaybe();
116+
if (
117+
array_key_exists($propertyName, $this->properties)
118+
&& in_array($propertyName, $this->optionalProperties, true)
119+
) {
120+
return TrinaryLogic::createYes();
122121
}
123122

124-
return TrinaryLogic::createYes();
123+
return TrinaryLogic::createMaybe();
125124
}
126125

127126
public function getInstanceProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
@@ -297,10 +296,6 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
297296
foreach ($this->properties as $propertyName => $propertyType) {
298297
$hasProperty = new IsSuperTypeOfResult($type->hasInstanceProperty((string) $propertyName), []);
299298
if ($hasProperty->no()) {
300-
if ($type instanceof self) {
301-
$result = $result->and(IsSuperTypeOfResult::createMaybe());
302-
continue;
303-
}
304299
if (in_array($propertyName, $this->optionalProperties, true)) {
305300
continue;
306301
}

0 commit comments

Comments
 (0)