Skip to content

Commit aa06ba3

Browse files
committed
Add missing type notations
1 parent 9a99d64 commit aa06ba3

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

phive.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
33
<phar name="phpunit" version="^8.4" installed="8.4.3" location="./tools/phpunit" copy="true"/>
4-
<phar name="psalm" version="^3.7.2" installed="3.7.2" location="./tools/psalm" copy="true"/>
4+
<phar name="psalm" version="^3.7.2" installed="3.9.3" location="./tools/psalm" copy="true"/>
55
</phive>

src/Types/ContextFactory.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ final class ContextFactory
6464
public function createFromReflector(Reflector $reflector) : Context
6565
{
6666
if ($reflector instanceof ReflectionClass) {
67+
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
68+
/** @var ReflectionClass<object> $reflector */
69+
6770
return $this->createFromReflectionClass($reflector);
6871
}
6972

@@ -89,33 +92,45 @@ public function createFromReflector(Reflector $reflector) : Context
8992
private function createFromReflectionParameter(ReflectionParameter $parameter) : Context
9093
{
9194
$class = $parameter->getDeclaringClass();
92-
if ($class) {
93-
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
94-
/** @var ReflectionClass<object> $class */
95-
96-
return $this->createFromReflectionClass($class);
95+
if (!$class) {
96+
throw new InvalidArgumentException('Unable to get class of ' . $parameter->getName());
9797
}
9898

99-
throw new InvalidArgumentException('Unable to get class of ' . $parameter->getName());
99+
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
100+
/** @var ReflectionClass<object> $class */
101+
102+
return $this->createFromReflectionClass($class);
100103
}
101104

102105
private function createFromReflectionMethod(ReflectionMethod $method) : Context
103106
{
104-
return $this->createFromReflectionClass($method->getDeclaringClass());
107+
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
108+
/** @var ReflectionClass<object> $class */
109+
$class = $method->getDeclaringClass();
110+
111+
return $this->createFromReflectionClass($class);
105112
}
106113

107114
private function createFromReflectionProperty(ReflectionProperty $property) : Context
108115
{
109-
return $this->createFromReflectionClass($property->getDeclaringClass());
116+
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
117+
/** @var ReflectionClass<object> $class */
118+
$class = $property->getDeclaringClass();
119+
120+
return $this->createFromReflectionClass($class);
110121
}
111122

112123
private function createFromReflectionClassConstant(ReflectionClassConstant $constant) : Context
113124
{
114-
return $this->createFromReflectionClass($constant->getDeclaringClass());
125+
//phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable
126+
/** @var ReflectionClass<object> $class */
127+
$class = $constant->getDeclaringClass();
128+
129+
return $this->createFromReflectionClass($class);
115130
}
116131

117132
/**
118-
* @phpstan-param ReflectionClass<object> $class
133+
* @param ReflectionClass<object> $class
119134
*/
120135
private function createFromReflectionClass(ReflectionClass $class) : Context
121136
{

0 commit comments

Comments
 (0)