fix phpstan issues

This commit is contained in:
Julien Fastré 2023-04-28 22:55:01 +02:00
parent 9027cbd196
commit c35994203d
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
10 changed files with 24 additions and 43 deletions

View File

@ -113,7 +113,6 @@ class ListActivityHelper
'usersIds' => self::MSG_KEY . 'users ids',
'thirdPartiesIds' => self::MSG_KEY . 'third parties ids',
'personsIds' => self::MSG_KEY . 'persons ids',
default => throw new LogicException('key not supported'),
};
}

View File

@ -162,9 +162,6 @@ class CustomFieldController extends AbstractController
/**
* Creates a form to create a CustomField entity.
*
* @param CustomField $entity The entity
* @param string
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(CustomField $entity, mixed $type)

View File

@ -15,6 +15,7 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option;
use Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
use Chill\FamilyMembersBundle\Templating\Twig;
use Chill\MainBundle\Form\Type\Select2ChoiceType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use LogicException;
@ -22,6 +23,7 @@ use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Templating\EngineInterface;
use function get_class;
use function gettype;
use function is_object;
@ -30,8 +32,11 @@ class CustomFieldLongChoice extends AbstractCustomField
{
public const KEY = 'key';
public function __construct(private OptionRepository $optionRepository, private TranslatableStringHelper $translatableStringHelper, private TwigEngine $templating)
{
public function __construct(
private OptionRepository $optionRepository,
private TranslatableStringHelper $translatableStringHelper,
private EngineInterface $templating,
) {
}
public function buildForm(FormBuilderInterface $builder, CustomField $customField)

View File

@ -258,7 +258,9 @@ class ApiController extends AbstractCRUDController
}
match ($request->getMethod()) {
/* @phpstan-ignore-next-line */
Request::METHOD_DELETE => $entity->{'remove' . ucfirst($property)}($postedData),
/* @phpstan-ignore-next-line */
Request::METHOD_POST => $entity->{'add' . ucfirst($property)}($postedData),
default => throw new BadRequestHttpException('this method is not supported'),
};

View File

@ -209,9 +209,9 @@ class AuthorizationHelper implements AuthorizationHelperInterface
throw new UnexpectedValueException(
sprintf(
'The entity given is not an instance of %s, %s given',
'The entity given is not an instance of %s or an array of centers, %s given',
Center::class,
$center::class
gettype($center)
)
);
}

View File

@ -23,25 +23,15 @@ class PasswordRecoverEvent extends Event
public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token';
/**
* @var bool
*/
protected $safelyGenerated;
/**
* @var User
*/
protected $user;
/**
* @param type $token
* @param User $user
* @param type $ip
* @param bool $safelyGenerated true if generated safely (from console command, etc.)
*/
public function __construct(protected $token = null, ?User $user = null, protected $ip = null, bool $safelyGenerated = false)
public function __construct(
private ?string $token = null,
private ?User $user = null,
private $ip = null,
private bool $safelyGenerated = false,
)
{
$this->user = $user;
$this->safelyGenerated = $safelyGenerated;
}
public function getIp()

View File

@ -87,7 +87,6 @@ class RollingDateConverter implements RollingDateConverterInterface
4, 5, 6 => '04',
7, 8, 9 => '07',
10, 11, 12 => '10',
default => throw new LogicException('this month is not valid: ' . $date->format('n')),
};
return DateTimeImmutable::createFromFormat(

View File

@ -30,11 +30,6 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
protected array $lazyLoadedPersons = [];
/**
* PersonChoiceLoader constructor.
*
* @param EntityRepository $personRepository
*/
public function __construct(
protected PersonRepository $personRepository,
?array $centers = null

View File

@ -211,6 +211,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
return $result;
}
}
throw new \LogicException("should not happens");
}
/**

View File

@ -11,6 +11,8 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Security\Authorization;
use Chill\PersonBundle\Entity\Person;
use Chill\TaskBundle\Entity\AbstractTask;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@ -18,26 +20,16 @@ class AuthorizationEvent extends Event
{
public const VOTE = 'chill_task.vote';
/**
* @var TokenInterface
*/
protected $token;
/**
* @var bool
*/
protected $vote;
/**
* @param string $attribute
* @param \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Entity\AbstractTask|null $subject
*/
public function __construct(
protected \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Security\Authorization\Chill\TaskBundle\Entity\AbstractTask|null $subject,
protected $attribute,
TokenInterface $token
private Person|AbstractTask|null $subject,
private string $attribute,
private TokenInterface $token
) {
$this->token = $token;
}
public function getAttribute()