Skip to content

Commit bdc429c

Browse files
staabmondrejmirtes
authored andcommitted
Narrow types
1 parent e565885 commit bdc429c

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

src/Rules/ClassNameNodePair.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
final class ClassNameNodePair
88
{
99

10+
/**
11+
* @param non-empty-string $className
12+
*/
1013
public function __construct(private string $className, private Node $node)
1114
{
1215
}
1316

17+
/**
18+
* @return non-empty-string
19+
*/
1420
public function getClassName(): string
1521
{
1622
return $this->className;

src/Rules/FunctionDefinitionCheck.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ private function getParameterNode(
704704
}
705705

706706
/**
707-
* @return string[]
707+
* @return non-empty-string[]
708708
*/
709709
private function getParameterReferencedClasses(ParameterReflection $parameter): array
710710
{
@@ -732,7 +732,7 @@ private function getParameterReferencedClasses(ParameterReflection $parameter):
732732
}
733733

734734
/**
735-
* @return string[]
735+
* @return non-empty-string[]
736736
*/
737737
private function getReturnTypeReferencedClasses(ParametersAcceptor $parametersAcceptor): array
738738
{

src/Type/ObjectType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
444444

445445
public function getReferencedClasses(): array
446446
{
447+
if ($this->className === '') {
448+
return [];
449+
}
450+
447451
return [$this->className];
448452
}
449453

src/Type/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface Type
2828
{
2929

3030
/**
31-
* @return list<string>
31+
* @return list<non-empty-string>
3232
*/
3333
public function getReferencedClasses(): array;
3434

0 commit comments

Comments
 (0)