mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
sa: Fix all issues related to PHP versions and static-analysis.
This commit is contained in:
@@ -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) {
|
||||
$currentForm = $editForm->handleRequest($request);
|
||||
|
||||
if (array_key_exists('edit', $request->request->all()[$editForm->getName()])) {
|
||||
$currentForm = $editForm->handleRequest($request);
|
||||
$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,
|
||||
]);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user