Skip to content

Commit caf9dc8

Browse files
landurefabpot
authored andcommitted
[TypeInfo] simplify identifier comparison in isIdentifiedBy method
Improve `isIdentifiedBy` method performance by replacing unnecessary `TypeIdentifier` backed enum instantiation by an identity test between a string identifier and its value. Closes symfony#61720 Signed-off-by: Pierre-Yves Landuré <[email protected]>
1 parent 84c65cb commit caf9dc8

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/Symfony/Component/TypeInfo/Type/BuiltinType.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ public function getTypeIdentifier(): TypeIdentifier
4141
public function isIdentifiedBy(TypeIdentifier|string ...$identifiers): bool
4242
{
4343
foreach ($identifiers as $identifier) {
44-
if (\is_string($identifier)) {
45-
try {
46-
$identifier = TypeIdentifier::from($identifier);
47-
} catch (\ValueError) {
48-
continue;
49-
}
50-
}
51-
52-
if ($identifier === $this->typeIdentifier) {
44+
if ($identifier === $this->typeIdentifier || $identifier === $this->typeIdentifier->value) {
5345
return true;
5446
}
5547
}

0 commit comments

Comments
 (0)