Skip to content

Commit ba9f089

Browse files
Simplify PhpFileParser::getExtraTypes() logic (#25)
The first time the method is called, a string is built up with `|`-separated extra types, then split based on `|`s, the resulting array is filtered to exclude non-empty strings, and that array is finally passed to `PhpFileCleaner::setTypeConfig()`. Given that the array only has at most a single entry, just set the array directly.
1 parent 73dd304 commit ba9f089

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/PhpFileParser.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,12 @@ private static function getExtraTypes(): string
125125

126126
if (null === $extraTypes) {
127127
$extraTypes = '';
128+
$extraTypesArray = [];
128129
if (PHP_VERSION_ID >= 80100 || (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>='))) {
129130
$extraTypes .= '|enum';
131+
$extraTypesArray = ['enum'];
130132
}
131133

132-
$extraTypesArray = array_filter(explode('|', $extraTypes), function (string $type): bool {
133-
return $type !== '';
134-
});
135134
PhpFileCleaner::setTypeConfig(array_merge(['class', 'interface', 'trait'], $extraTypesArray));
136135
}
137136

0 commit comments

Comments
 (0)