diff --git a/psalm.xml b/psalm.xml index 3e4e3d0..30258a7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ */ protected $defaultByValueStrategy = AllowRemoveByValue::class; - /** @var string */ + /** @var class-string */ protected $defaultByReferenceStrategy = AllowRemoveByReference::class; /** @var Inflector */ @@ -79,7 +78,7 @@ public function __construct(ObjectManager $objectManager, $byValue = true, ?Infl } /** - * @return string + * @return class-string */ public function getDefaultByValueStrategy() { @@ -87,7 +86,7 @@ public function getDefaultByValueStrategy() } /** - * @param string $defaultByValueStrategy + * @param class-string $defaultByValueStrategy * * @return $this */ @@ -99,7 +98,7 @@ public function setDefaultByValueStrategy($defaultByValueStrategy) } /** - * @return string + * @return class-string */ public function getDefaultByReferenceStrategy() { @@ -107,7 +106,7 @@ public function getDefaultByReferenceStrategy() } /** - * @param string $defaultByReferenceStrategy + * @param class-string $defaultByReferenceStrategy * * @return $this */ @@ -351,6 +350,7 @@ protected function hydrateByValue(array $data, $object) if ($metadata->hasAssociation($field)) { $target = $metadata->getAssociationTargetClass($field); + assert($target !== null); if ($metadata->isSingleValuedAssociation($field)) { if (! is_callable([$object, $setter])) { @@ -420,6 +420,7 @@ protected function hydrateByReference(array $data, $object) if ($metadata->hasAssociation($field)) { $target = $metadata->getAssociationTargetClass($field); + assert($target !== null); if ($metadata->isSingleValuedAssociation($field)) { $value = $this->toOne($target, $this->hydrateValue($field, $value, $data)); @@ -482,8 +483,8 @@ protected function tryConvertArrayToObject($data, $object) * and a target instance will be initialized and then hydrated. The hydrated * target will be returned. * - * @param string $target - * @param mixed $value + * @param class-string $target + * @param mixed $value * * @return object|null */ @@ -511,16 +512,16 @@ protected function toOne($target, $value) * strategies that inherit from AbstractCollectionStrategy class, and that add or remove elements but without * changing the collection of the object * - * @param object $object - * @param mixed $collectionName - * @param string $target - * @param mixed $values + * @param object $object + * @param mixed $collectionName + * @param class-string $target + * @param mixed $values * * @throws InvalidArgumentException */ protected function toMany($object, $collectionName, $target, $values) { - $metadata = $this->objectManager->getClassMetadata(ltrim($target, '\\')); + $metadata = $this->objectManager->getClassMetadata($target); $identifier = $metadata->getIdentifier(); if (! is_array($values) && ! $values instanceof Traversable) { @@ -608,8 +609,8 @@ static function ($item) { * * @link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#doctrine-mapping-types * - * @param mixed $value - * @param string $typeOfField + * @param mixed $value + * @param ?string $typeOfField * * @return mixed|null */