apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -17,17 +17,13 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use function array_key_exists;
use function count;
use function is_array;
class DoctrineExistingEntityNormalizer implements DenormalizerInterface
{
public function __construct(private readonly EntityManagerInterface $em, private readonly ClassMetadataFactoryInterface $serializerMetadataFactory) {}
public function denormalize($data, $type, $format = null, array $context = [])
{
if (array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
if (\array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
return $context[AbstractNormalizer::OBJECT_TO_POPULATE];
}
@@ -37,11 +33,11 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
public function supportsDenormalization($data, $type, $format = null)
{
if (false === is_array($data)) {
if (false === \is_array($data)) {
return false;
}
if (false === array_key_exists('id', $data)) {
if (false === \array_key_exists('id', $data)) {
return false;
}
@@ -60,13 +56,13 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
// check that only 2 keys
// that the second key is property
// and that the type match the class for given type property
return count($data) === 2
&& array_key_exists($typeProperty, $data)
return 2 === \count($data)
&& \array_key_exists($typeProperty, $data)
&& $classDiscriminator->getClassForType($data[$typeProperty]) === $type;
}
}
// we do not have any class discriminator. Check that the id is the only one key
return count($data) === 1;
return 1 === \count($data);
}
}