Skip to content

Commit e0e4aa6

Browse files
Solve todo
1 parent 245f2c4 commit e0e4aa6

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/Reflection/Php/PhpClassReflectionExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ public function getNativeProperty(ClassReflection $classReflection, string $prop
218218
return $this->nativeProperties[$classReflection->getCacheKey()][$propertyName];
219219
}
220220

221-
// TODO: Find the difference between createInstanceProperty and createStaticProperty
222221
private function createProperty(
223222
ClassReflection $classReflection,
224223
string $propertyName,

src/Type/Accessory/HasPropertyType.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ public function accepts(Type $type, bool $strictTypes): AcceptsResult
7272

7373
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
7474
{
75-
// TODO
76-
return new IsSuperTypeOfResult($type->hasProperty($this->propertyName), []);
75+
return new IsSuperTypeOfResult(
76+
$type->hasInstanceProperty($this->propertyName)->or($type->hasStaticProperty($this->propertyName)),
77+
[],
78+
);
7779
}
7880

7981
public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult
@@ -88,8 +90,10 @@ public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult
8890
$limit = IsSuperTypeOfResult::createMaybe();
8991
}
9092

91-
// TODO
92-
return $limit->and(new IsSuperTypeOfResult($otherType->hasProperty($this->propertyName), []));
93+
return $limit->and(new IsSuperTypeOfResult(
94+
$otherType->hasInstanceProperty($this->propertyName)->or($otherType->hasStaticProperty($this->propertyName)),
95+
[],
96+
));
9397
}
9498

9599
public function isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsResult
@@ -117,7 +121,6 @@ public function hasProperty(string $propertyName): TrinaryLogic
117121
return TrinaryLogic::createMaybe();
118122
}
119123

120-
// TODO
121124
public function hasInstanceProperty(string $propertyName): TrinaryLogic
122125
{
123126
if ($this->propertyName === $propertyName) {
@@ -127,7 +130,6 @@ public function hasInstanceProperty(string $propertyName): TrinaryLogic
127130
return TrinaryLogic::createMaybe();
128131
}
129132

130-
// TODO
131133
public function hasStaticProperty(string $propertyName): TrinaryLogic
132134
{
133135
if ($this->propertyName === $propertyName) {

src/Type/ObjectShapeType.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
137137
);
138138
}
139139

140+
public function hasStaticProperty(string $propertyName): TrinaryLogic
141+
{
142+
return TrinaryLogic::createNo();
143+
}
144+
145+
public function getStaticProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
146+
{
147+
throw new ShouldNotHappenException();
148+
}
149+
150+
public function getUnresolvedStaticPropertyPrototype(string $propertyName, ClassMemberAccessAnswerer $scope): UnresolvedPropertyPrototypeReflection
151+
{
152+
throw new ShouldNotHappenException();
153+
}
154+
140155
public function accepts(Type $type, bool $strictTypes): AcceptsResult
141156
{
142157
if ($type instanceof CompoundType) {

0 commit comments

Comments
 (0)