Fixed phpstan analysis issues and bad code that showed up with phpstan 2.0

This commit is contained in:
Jan Böhmer 2024-12-28 22:31:04 +01:00
parent a273acbecd
commit 946032a101
42 changed files with 98 additions and 85 deletions

View file

@ -69,6 +69,15 @@ class StructuralElementDenormalizer implements DenormalizerInterface, Denormaliz
&& in_array('import', $context['groups'] ?? [], true);
}
/**
* @template T of AbstractStructuralDBElement
* @param $data
* @phpstan-param class-string<T> $type
* @param string|null $format
* @param array $context
* @return AbstractStructuralDBElement|null
* @phpstan-return T|null
*/
public function denormalize($data, string $type, string $format = null, array $context = []): ?AbstractStructuralDBElement
{
//Do not use API Platform's denormalizer
@ -85,7 +94,7 @@ class StructuralElementDenormalizer implements DenormalizerInterface, Denormaliz
$deserialized_entity = $this->denormalizer->denormalize($data, $type, $format, $context);
//Check if we already have the entity in the database (via path)
/** @var StructuralDBElementRepository $repo */
/** @var StructuralDBElementRepository<T> $repo */
$repo = $this->entityManager->getRepository($type);
$path = $deserialized_entity->getFullPath(AbstractStructuralDBElement::PATH_DELIMITER_ARROW);