sa: Fix all issues related to PHP versions and static-analysis.

This commit is contained in:
Pol Dellaiera 2021-12-21 11:58:58 +01:00
parent b3823161af
commit b743475761
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
25 changed files with 79 additions and 81 deletions

View File

@ -417,15 +417,6 @@ parameters:
count: 1
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php
-
message:
"""
#^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\:
since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$#
"""
count: 3
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php
-
message:
"""
@ -435,15 +426,6 @@ parameters:
count: 1
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php
-
message:
"""
#^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\:
since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$#
"""
count: 1
path: src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php
-
message:
"""

View File

@ -15,10 +15,11 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use function array_keys;
use function is_array;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
class DocGenEncoder implements \Symfony\Component\Serializer\Encoder\EncoderInterface
class DocGenEncoder implements EncoderInterface
{
public function encode($data, string $format, array $context = [])
public function encode($data, $format, array $context = [])
{
if (!$this->isAssociative($data)) {
throw new UnexpectedValueException('Only associative arrays are allowed; lists are not allowed');
@ -30,7 +31,7 @@ class DocGenEncoder implements \Symfony\Component\Serializer\Encoder\EncoderInte
return $result;
}
public function supportsEncoding(string $format)
public function supportsEncoding($format)
{
return 'docgen' === $format;
}

View File

@ -29,7 +29,7 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
*
* @return array|ArrayObject|bool|float|int|string|void|null
*/
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, $format = null, array $context = [])
{
$data = [];
@ -44,7 +44,7 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
return $data;
}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = [])
{
if ('docgen' !== $format) {
return false;

View File

@ -55,7 +55,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
$this->translatableStringHelper = $translatableStringHelper;
}
public function normalize($object, ?string $format = null, array $context = [])
public function normalize($object, $format = null, array $context = [])
{
$classMetadataKey = $object ?? $context['docgen:expects'] ?? null;
@ -96,7 +96,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
return $this->normalizeObject($object, $format, $context, $expectedGroups, $metadata, $attributes);
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
return 'docgen' === $format && (is_object($data) || null === $data);
}

View File

@ -49,7 +49,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
/**
* @param Address $address
*/
public function normalize($address, ?string $format = null, array $context = [])
public function normalize($address, $format = null, array $context = [])
{
if ($address instanceof Address) {
$text = $address->isNoAddress() ? '' : $address->getStreet() . ', ' . $address->getStreetNumber();
@ -118,7 +118,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
throw new UnexpectedValueException();
}
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
if ('json' === $format) {
return $data instanceof Address;

View File

@ -29,7 +29,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
$this->repository = $repository;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
if (false === array_key_exists('type', $data)) {
throw new InvalidArgumentException('missing "type" key in data');
@ -52,7 +52,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
return $center;
}
public function normalize($center, ?string $format = null, array $context = [])
public function normalize($center, $format = null, array $context = [])
{
/** @var Center $center */
return [
@ -62,12 +62,12 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
];
}
public function supportsDenormalization($data, string $type, ?string $format = null)
public function supportsDenormalization($data, $type, $format = null)
{
return Center::class === $type;
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
return $data instanceof Center && 'json' === $format;
}

View File

@ -23,7 +23,7 @@ class CollectionNormalizer implements NormalizerAwareInterface, NormalizerInterf
/**
* @param Collection $collection
*/
public function normalize($collection, ?string $format = null, array $context = [])
public function normalize($collection, $format = null, array $context = [])
{
$paginator = $collection->getPaginator();
@ -40,7 +40,7 @@ class CollectionNormalizer implements NormalizerAwareInterface, NormalizerInterf
];
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
return $data instanceof Collection;
}

View File

@ -36,7 +36,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
$this->parameterBag = $parameterBag;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
if (null === $data) {
return null;
@ -54,7 +54,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
throw new UnexpectedValueException();
}
public function normalize($date, ?string $format = null, array $context = [])
public function normalize($date, $format = null, array $context = [])
{
/** @var DateTimeInterface $date */
switch ($format) {
@ -91,7 +91,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
}
}
public function supportsDenormalization($data, string $type, ?string $format = null): bool
public function supportsDenormalization($data, $type, $format = null): bool
{
return DateTimeInterface::class === $type
|| DateTime::class === $type
@ -99,7 +99,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
|| (is_array($data) && array_key_exists('datetime', $data));
}
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
if ('json' === $format) {
return $data instanceof DateTimeInterface;

View File

@ -38,7 +38,7 @@ class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterfa
*/
public const TYPE = '@multi';
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
foreach ($context[self::ALLOWED_TYPES] as $localType) {
if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) {
@ -54,7 +54,7 @@ class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterfa
'ALLOWED_TYPES: %s', implode(', ', $context[self::ALLOWED_TYPES])));
}
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = [])
public function supportsDenormalization($data, $type, $format = null, array $context = [])
{
if (self::TYPE !== $type) {
return false;

View File

@ -33,7 +33,7 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
$this->serializerMetadataFactory = $serializerMetadataFactory;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
if (array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
return $context[AbstractNormalizer::OBJECT_TO_POPULATE];
@ -43,7 +43,7 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
->find($data['id']);
}
public function supportsDenormalization($data, string $type, ?string $format = null)
public function supportsDenormalization($data, $type, $format = null)
{
if (false === is_array($data)) {
return false;

View File

@ -20,7 +20,7 @@ use function is_array;
class PointNormalizer implements DenormalizerInterface
{
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
if (!is_array($data)) {
throw new InvalidArgumentException('point data is not an array. It should be an array of 2 coordinates.');
@ -33,7 +33,7 @@ class PointNormalizer implements DenormalizerInterface
return Point::fromLonLat($data[0], $data[1]);
}
public function supportsDenormalization($data, string $type, ?string $format = null): bool
public function supportsDenormalization($data, $type, $format = null): bool
{
return Point::class === $type;
}

View File

@ -40,7 +40,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
$this->userRender = $userRender;
}
public function normalize($user, ?string $format = null, array $context = [])
public function normalize($user, $format = null, array $context = [])
{
/** @var User $user */
$userJobContext = array_merge(
@ -77,7 +77,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
];
}
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
if ($data instanceof User && ('json' === $format || 'docgen' === $format)) {
return true;

View File

@ -19,6 +19,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use function array_key_exists;
@ -37,6 +38,7 @@ class AccompanyingCourseCommentController extends AbstractController
$newComment->setAccompanyingPeriod($accompanyingCourse);
$form = $this->createCommentForm($newComment, 'new');
$editForm = null;
if ($request->query->has('edit')) {
foreach ($accompanyingCourse->getComments() as $comment) {
@ -53,12 +55,16 @@ class AccompanyingCourseCommentController extends AbstractController
}
}
if (null === $editForm) {
throw new NotFoundHttpException('Unable to find an edit form.');
}
if ($request->getMethod() === Request::METHOD_POST) {
if (array_key_exists('edit', $request->request->all()[$editForm->getName()])) {
$currentForm = $editForm->handleRequest($request);
if (array_key_exists('edit', $request->request->all()[$editForm->getName()])) {
$isEditingNew = false;
} else {
$currentForm = $form->handleRequest($request);
$isEditingNew = true;
}
@ -79,7 +85,7 @@ class AccompanyingCourseCommentController extends AbstractController
return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [
'accompanyingCourse' => $accompanyingCourse,
'form' => $form->createView(),
'edit_form' => isset($editForm) ? $editForm->createView() : null,
'edit_form' => $editForm !== null ? $editForm->createView() : null,
'commentEditId' => $commentEditId ?? null,
]);
}

View File

@ -94,7 +94,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
/**
* @param AccompanyingPeriod|null $period
*/
public function normalize($period, ?string $format = null, array $context = [])
public function normalize($period, $format = null, array $context = [])
{
if ($period instanceof AccompanyingPeriod) {
$scopes = $this->scopeResolverDispatcher->isConcerned($period) ? $this->scopeResolverDispatcher->resolveScope($period) : [];
@ -147,7 +147,9 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'hasRequestor' => $period->getRequestor() !== null,
'requestorKind' => $period->getRequestorKind(),
];
} elseif (null === $period) {
}
if (null === $period) {
return array_merge(
(new NormalizeNullValueHelper($this->normalizer, 'type', 'accompanying_period'))
->normalize(self::PERIOD_NULL, $format, $context),
@ -163,10 +165,10 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
);
}
throw new InvalidArgumentException('this neither an accompanying period or null');
throw new InvalidArgumentException('This neither an accompanying period or null.');
}
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
if ('docgen' !== $format) {
return false;

View File

@ -19,9 +19,12 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
*/
final class AccompanyingPeriodOriginNormalizer implements NormalizerInterface
{
public function normalize($origin, ?string $format = null, array $context = [])
/**
* @param Origin $origin
*/
public function normalize($origin, $format = null, array $context = [])
{
/** @var Origin $origin */
return [
'type' => 'origin',
'id' => $origin->getId(),
@ -30,7 +33,7 @@ final class AccompanyingPeriodOriginNormalizer implements NormalizerInterface
];
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
return $data instanceof Origin;
}

View File

@ -17,11 +17,13 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class AccompanyingPeriodParticipationNormalizer implements NormalizerAwareInterface, NormalizerInterface
{
protected ?NormalizerInterface $normalizer = null;
private ?NormalizerInterface $normalizer = null;
public function normalize($participation, ?string $format = null, array $context = [])
/**
* @param AccompanyingPeriodParticipation $participation
*/
public function normalize($participation, $format = null, array $context = [])
{
/** @var AccompanyingPeriodParticipation $participation */
return [
'id' => $participation->getId(),
'startDate' => $this->normalizer->normalize($participation->getStartDate(), $format),
@ -35,8 +37,9 @@ class AccompanyingPeriodParticipationNormalizer implements NormalizerAwareInterf
$this->normalizer = $normalizer;
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
// @TODO Fix this.
return false;
return $data instanceof AccompanyingPeriodParticipation;

View File

@ -38,7 +38,7 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface
$this->repository = $repository;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
$resource = $this->extractObjectToPopulate($type, $context);
@ -87,7 +87,7 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface
return $resource;
}
public function supportsDenormalization($data, string $type, ?string $format = null)
public function supportsDenormalization($data, $type, $format = null)
{
return Resource::class === $type;
}

View File

@ -51,7 +51,7 @@ class AccompanyingPeriodWorkDenormalizer implements ContextAwareDenormalizerInte
$this->em = $em;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
$work = $this->denormalizer->denormalize($data, $type, $format, array_merge(
$context,
@ -65,7 +65,7 @@ class AccompanyingPeriodWorkDenormalizer implements ContextAwareDenormalizerInte
return $work;
}
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return AccompanyingPeriodWork::class === $type
&& self::class !== ($context['skip'] ?? null)

View File

@ -35,7 +35,7 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
$this->factory = $factory;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
// some test about schema first...
$this->performChecks($data);
@ -50,7 +50,7 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
return $this->denormalizeMove($data, $type, $format, $context);
}
public function supportsDenormalization($data, string $type, ?string $format = null)
public function supportsDenormalization($data, $type, $format = null)
{
return MembersEditor::class === $type;
}

View File

@ -57,7 +57,7 @@ class PersonDocGenNormalizer implements
$this->translatableStringHelper = $translatableStringHelper;
}
public function normalize($person, ?string $format = null, array $context = [])
public function normalize($person, $format = null, array $context = [])
{
/** @var Person $person */
$dateContext = $context;
@ -132,7 +132,7 @@ class PersonDocGenNormalizer implements
return $data;
}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = [])
{
if ('docgen' !== $format) {
return false;

View File

@ -59,7 +59,7 @@ class PersonJsonNormalizer implements
$this->centerResolverManager = $centerResolverManager;
}
public function denormalize($data, string $type, ?string $format = null, array $context = [])
public function denormalize($data, $type, $format = null, array $context = [])
{
$person = $this->extractObjectToPopulate($type, $context);
@ -140,12 +140,13 @@ class PersonJsonNormalizer implements
return $person;
}
public function normalize($person, ?string $format = null, array $context = [])
/**
* @param Person $person
*/
public function normalize($person, $format = null, array $context = [])
{
/** @var Household $household */
$household = $person->getCurrentHousehold();
/** @var Person $person */
return [
'type' => 'person',
'id' => $person->getId(),
@ -164,12 +165,12 @@ class PersonJsonNormalizer implements
];
}
public function supportsDenormalization($data, string $type, ?string $format = null)
public function supportsDenormalization($data, $type, $format = null)
{
return Person::class === $type && 'person' === ($data['type'] ?? null);
}
public function supportsNormalization($data, ?string $format = null): bool
public function supportsNormalization($data, $format = null): bool
{
return $data instanceof Person && 'json' === $format;
}

View File

@ -32,7 +32,7 @@ class RelationshipDocGenNormalizer implements ContextAwareNormalizerInterface, N
/**
* @param Relationship $relation
*/
public function normalize($relation, ?string $format = null, array $context = [])
public function normalize($relation, $format = null, array $context = [])
{
$counterpart = $context['docgen:relationship:counterpart'] ?? null;
$contextPerson = array_merge($context, [
@ -78,7 +78,7 @@ class RelationshipDocGenNormalizer implements ContextAwareNormalizerInterface, N
];
}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = [])
{
if ('docgen' !== $format) {
return false;

View File

@ -28,7 +28,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
$this->render = $render;
}
public function normalize($socialAction, ?string $format = null, array $context = [])
public function normalize($socialAction, $format = null, array $context = [])
{
switch ($format) {
case 'json':
@ -58,7 +58,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
}
}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = [])
{
if ($data instanceof SocialAction && 'json' === $format) {
return true;

View File

@ -28,7 +28,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz
$this->render = $render;
}
public function normalize($socialIssue, ?string $format = null, array $context = [])
public function normalize($socialIssue, $format = null, array $context = [])
{
/** @var SocialIssue $socialIssue */
switch ($format) {
@ -57,7 +57,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz
}
}
public function supportsNormalization($data, ?string $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = [])
{
if ($data instanceof SocialIssue && 'json' === $format) {
return true;

View File

@ -31,7 +31,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
/**
* @param ThirdParty $thirdParty
*/
public function normalize($thirdParty, ?string $format = null, array $context = [])
public function normalize($thirdParty, $format = null, array $context = [])
{
return [
'type' => 'thirdparty',
@ -49,7 +49,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
];
}
public function supportsNormalization($data, ?string $format = null)
public function supportsNormalization($data, $format = null)
{
return $data instanceof ThirdParty && 'json' === $format;
}