diff --git a/src/Hydrator/AbstractHydrator.php b/src/Hydrator/AbstractHydrator.php index 8b7f432..8e362bd 100644 --- a/src/Hydrator/AbstractHydrator.php +++ b/src/Hydrator/AbstractHydrator.php @@ -160,7 +160,7 @@ public function getNamingStrategy() */ public function extractValue($property, $value, ExtractionContext $context = null) { - // Optimization: avoid a method call, please do not change + // Optimization: avoid a method call by inlining, please do not change if (isset($this->strategies[$property]) || isset($this->strategies['*'])) { return $this->getStrategy($property)->extract($value, $context); } @@ -178,7 +178,7 @@ public function extractValue($property, $value, ExtractionContext $context = nul */ public function hydrateValue($property, $value, HydrationContext $context = null) { - // Optimization: avoid a method call, please do not change + // Optimization: avoid a method call by inlining, please do not change if (isset($this->strategies[$property]) || isset($this->strategies['*'])) { return $this->getStrategy($property)->hydrate($value, $context); } diff --git a/src/Hydrator/ArraySerializableHydrator.php b/src/Hydrator/ArraySerializableHydrator.php index f17b41d..333c5bc 100644 --- a/src/Hydrator/ArraySerializableHydrator.php +++ b/src/Hydrator/ArraySerializableHydrator.php @@ -63,15 +63,19 @@ public function hydrate(array $data, $object) if (is_callable([$object, 'exchangeArray'])) { $object->exchangeArray($replacement); - } elseif (is_callable([$object, 'populate'])) { + + return $object; + } + + if (is_callable([$object, 'populate'])) { $object->populate($replacement); - } else { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided object to implement exchangeArray() or populate()', - __METHOD__ - )); + + return $object; } - return $object; + throw new Exception\BadMethodCallException(sprintf( + '%s expects the provided object to implement exchangeArray() or populate()', + __METHOD__ + )); } }