Skip to content

Commit 3a23345

Browse files
committed
use isset in hot path
1 parent e0d22e2 commit 3a23345

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/Guesser/MappedGuesser.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ public function __construct(private array $map)
2424
public function guess(ObjectType $type): Normalizer|null
2525
{
2626
$className = $type->getClassName();
27-
if (! array_key_exists($className, $this->map)) {
27+
28+
if (!isset($this->map[$className])) {
2829
return null;
2930
}
3031

31-
$normalizerType = $this->map[$className];
32-
33-
return new $normalizerType();
32+
return new $this->map[$className]();
3433
}
3534
}

src/MetadataHydrator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function extract(object $object, array $context = []): mixed
111111
*/
112112
public function metadata(string $class): ClassMetadata
113113
{
114-
if (array_key_exists($class, $this->classMetadata)) {
114+
if (isset($this->classMetadata[$class])) {
115115
return $this->classMetadata[$class];
116116
}
117117

src/Middleware/TransformMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function extract(ClassMetadata $metadata, object $object, array $context,
9898
{
9999
$objectId = spl_object_id($object);
100100

101-
if (array_key_exists($objectId, $this->callStack)) {
101+
if (isset($this->callStack[$objectId])) {
102102
$references = array_values($this->callStack);
103103
$references[] = $object::class;
104104

0 commit comments

Comments
 (0)