Skip to content

Commit edf0856

Browse files
authored
Reduce memory consumption of collectors (#141)
1 parent ef82114 commit edf0856

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Collector/ImplementedInterfaceCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function getNodeType(): string
1818

1919
/**
2020
* @param Class_ $node
21-
* @return string[]|null
21+
* @return non-empty-array<string>|null
2222
*/
2323
public function processNode(Node $node, Scope $scope): ?array
2424
{
@@ -33,6 +33,10 @@ public function processNode(Node $node, Scope $scope): ?array
3333
$implementedInterfaceNames[] = $implement->toString();
3434
}
3535

36+
if ($implementedInterfaceNames === []) {
37+
return null;
38+
}
39+
3640
return $implementedInterfaceNames;
3741
}
3842
}

src/Collector/InterfaceOfAbstractClassCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function getNodeType(): string
1818

1919
/**
2020
* @param Class_ $node
21-
* @return string[]|null
21+
* @return non-empty-array<string>|null
2222
*/
2323
public function processNode(Node $node, Scope $scope): ?array
2424
{
@@ -32,6 +32,10 @@ public function processNode(Node $node, Scope $scope): ?array
3232
$interfaceNames[] = $implement->toString();
3333
}
3434

35+
if ($interfaceNames === []) {
36+
return null;
37+
}
38+
3539
return $interfaceNames;
3640
}
3741
}

0 commit comments

Comments
 (0)