mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix phpstan errors level 2
This commit is contained in:
parent
ed3e0f889e
commit
dcc285e976
@ -1,5 +1,5 @@
|
||||
parameters:
|
||||
level: 5
|
||||
level: 2
|
||||
paths:
|
||||
- src/
|
||||
- utils/
|
||||
|
@ -71,7 +71,7 @@ class ApiWrapper
|
||||
$data = \json_decode((string) $response->getBody());
|
||||
|
||||
// set the key with an expiry time
|
||||
$this->redis->setEx(
|
||||
$this->redis->setex(
|
||||
$cacheKey,
|
||||
$data->expires_in - 2,
|
||||
\serialize($data)
|
||||
|
@ -67,7 +67,7 @@ trait ProcessRequestTrait
|
||||
&& count($e->getResponse()->getHeader('Retry-After')) > 0) {
|
||||
if ($counter > 5) {
|
||||
$logger->error('too much 429 response', [
|
||||
'request' => Psr7\str($e->getRequest()),
|
||||
'request' => Psr7\get($e->getRequest()),
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
|
@ -22,8 +22,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class CSCrudReportController extends EntityPersonCRUDController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
protected function onBeforeRedirectAfterSubmission(string $action, $entity, FormInterface $form, Request $request): ?Response
|
||||
{
|
||||
$next = $request->request->get('submit', 'save-and-close');
|
||||
|
@ -102,7 +102,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
|
||||
};
|
||||
}
|
||||
|
||||
protected function getTemplateFor($action, $entity, Request $request)
|
||||
protected function getTemplateFor($action, $entity, Request $request): string
|
||||
{
|
||||
switch ($action) {
|
||||
case 'ps_situation_edit':
|
||||
@ -114,7 +114,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
|
||||
case 'dispositifs_view':
|
||||
return '@ChillJob/CSPerson/dispositifs_view.html.twig';
|
||||
default:
|
||||
parent::getTemplateFor($action, $entity, $request);
|
||||
return parent::getTemplateFor($action, $entity, $request);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class CSReportController extends AbstractController
|
||||
};
|
||||
$results[$key] = $this->managerRegistry->getManager()
|
||||
->getRepository($className)
|
||||
->findByPerson($person, $ordering);
|
||||
->findBy(['person' => $person], $ordering);
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
@ -544,7 +544,6 @@ class CSPerson
|
||||
/**
|
||||
* Get niveauMaitriseLangue.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getNiveauMaitriseLangue()
|
||||
{
|
||||
@ -562,7 +561,7 @@ class CSPerson
|
||||
return;
|
||||
}
|
||||
|
||||
if (\in_array('aucun', $this->getNiveauMaitriseLangue())) {
|
||||
if (\in_array('aucun', $this->getNiveauMaitriseLangue(), true)) {
|
||||
if (count($this->getNiveauMaitriseLangue()) > 1) {
|
||||
$context->buildViolation("Si \"Aucun\" est choisi dans la liste, il n'est "
|
||||
. "pas possible de cocher d'autres indications")
|
||||
|
@ -791,7 +791,7 @@ class Immersion implements \Stringable
|
||||
*/
|
||||
public function setNoteImmersion($note)
|
||||
{
|
||||
$this->noteImmersion = (string) $note;
|
||||
$this->noteImmersion = $note;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -156,7 +156,6 @@ class ProjetProfessionnel implements \Stringable
|
||||
/**
|
||||
* Set typeContrat.
|
||||
*
|
||||
* @param json|null $typeContrat
|
||||
*
|
||||
* @return ProjetProfessionnel
|
||||
*/
|
||||
@ -170,7 +169,6 @@ class ProjetProfessionnel implements \Stringable
|
||||
/**
|
||||
* Get typeContrat.
|
||||
*
|
||||
* @return json|null
|
||||
*/
|
||||
public function getTypeContrat()
|
||||
{
|
||||
@ -180,7 +178,6 @@ class ProjetProfessionnel implements \Stringable
|
||||
/**
|
||||
* Set typeContratNotes.
|
||||
*
|
||||
*
|
||||
* @return ProjetProfessionnel
|
||||
*/
|
||||
public function setTypeContratNotes(?string $typeContratNotes = null)
|
||||
@ -203,7 +200,6 @@ class ProjetProfessionnel implements \Stringable
|
||||
/**
|
||||
* Set volumeHoraire.
|
||||
*
|
||||
* @param json|null $volumeHoraire
|
||||
*
|
||||
* @return ProjetProfessionnel
|
||||
*/
|
||||
@ -217,7 +213,6 @@ class ProjetProfessionnel implements \Stringable
|
||||
/**
|
||||
* Get volumeHoraire.
|
||||
*
|
||||
* @return json|null
|
||||
*/
|
||||
public function getVolumeHoraire()
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ class Metier
|
||||
public function __construct()
|
||||
{
|
||||
$this->appellations = new ArrayCollection();
|
||||
$this->appellation = new ArrayCollection();
|
||||
// $this->appellation = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,8 +15,10 @@ use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
use Chill\MainBundle\Export\ListInterface;
|
||||
use Chill\PersonBundle\Export\Export\ListPerson;
|
||||
use Chill\JobBundle\Entity\CSPerson;
|
||||
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
@ -61,11 +63,12 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
TranslatorInterface $translator,
|
||||
ListPersonHelper $listPersonHelper,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
CustomFieldProvider $customFieldProvider
|
||||
CustomFieldProvider $customFieldProvider,
|
||||
ParameterBagInterface $parameterBag
|
||||
) {
|
||||
parent::__construct($em, $translator, $translatableStringHelper, $customFieldProvider);
|
||||
parent::__construct($customFieldProvider, $listPersonHelper, $em, $translatableStringHelper, $parameterBag);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,14 +203,8 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal
|
||||
{
|
||||
$csperson = self::CSPERSON;
|
||||
|
||||
/**
|
||||
* @var array $row each row exported
|
||||
*/
|
||||
$results = [];
|
||||
foreach ($rows as $row) {
|
||||
/**
|
||||
* @var string $key
|
||||
*/
|
||||
$res = [];
|
||||
foreach ($row as $key => $value) {
|
||||
switch ($key) {
|
||||
@ -359,7 +356,7 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal
|
||||
$rsm = new Query\ResultSetMapping();
|
||||
|
||||
foreach ($this->allFields() as $name => $type) {
|
||||
if ($data['fields'][$name]) {
|
||||
if (null !== $data['fields'][$name]) {
|
||||
$rsm->addScalarResult(strtolower($name), $name, $type);
|
||||
}
|
||||
}
|
||||
|
@ -191,12 +191,10 @@ class ListCV implements ListInterface, ExportElementValidatedInterface
|
||||
|
||||
/**
|
||||
* Return the required Role to execute the Export.
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function requiredRole(): string
|
||||
{
|
||||
return new Role(ExportsVoter::EXPORT);
|
||||
return ExportsVoter::EXPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +253,7 @@ class ListCV implements ListInterface, ExportElementValidatedInterface
|
||||
$rsm = new Query\ResultSetMapping();
|
||||
|
||||
foreach (self::FIELDS as $name => $type) {
|
||||
if ($data['fields'][$name]) {
|
||||
if (null !== $data['fields'][$name]) {
|
||||
$rsm->addScalarResult($name, $name, $type);
|
||||
}
|
||||
}
|
||||
@ -325,7 +323,7 @@ class ListCV implements ListInterface, ExportElementValidatedInterface
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -343,7 +341,7 @@ class ListCV implements ListInterface, ExportElementValidatedInterface
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -205,11 +205,10 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
/**
|
||||
* Return the required Role to execute the Export.
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function requiredRole(): string
|
||||
{
|
||||
return new Role(ExportsVoter::EXPORT);
|
||||
return ExportsVoter::EXPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,9 +289,6 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
{
|
||||
$freins = self::FREINS;
|
||||
|
||||
/**
|
||||
* @var array $row each row exported
|
||||
*/
|
||||
$results = [];
|
||||
foreach ($rows as $row) {
|
||||
/**
|
||||
@ -337,7 +333,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
* @param QueryBuilder|\Doctrine\ORM\NativeQuery $qb
|
||||
* @param mixed[] $data the data from the export's form (added by self::buildForm)
|
||||
*
|
||||
* @return mixed[]|\closure an array of results
|
||||
* @return mixed[]|\Closure an array of results
|
||||
*/
|
||||
public function getResult($qb, $data)
|
||||
{
|
||||
@ -351,7 +347,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
$rsm = new Query\ResultSetMapping();
|
||||
|
||||
foreach (self::FIELDS as $name => $type) {
|
||||
if ($data['fields'][$name]) {
|
||||
if (null !== $data['fields'][$name]) {
|
||||
$rsm->addScalarResult($name, $name, $type);
|
||||
}
|
||||
}
|
||||
@ -423,7 +419,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -441,7 +437,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -451,7 +447,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -211,11 +211,10 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
||||
/**
|
||||
* Return the required Role to execute the Export.
|
||||
*
|
||||
* @return Role
|
||||
*/
|
||||
public function requiredRole(): string
|
||||
{
|
||||
return new Role(ExportsVoter::EXPORT);
|
||||
return ExportsVoter::EXPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,10 +314,8 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
||||
{
|
||||
$projet_professionnel = self::PPROF;
|
||||
|
||||
/**
|
||||
* @var array $row each row exported
|
||||
*/
|
||||
$results = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
/**
|
||||
* @var string $key
|
||||
@ -388,7 +385,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
||||
$rsm = new Query\ResultSetMapping();
|
||||
|
||||
foreach (self::FIELDS as $name => $type) {
|
||||
if ($data['fields'][$name]) {
|
||||
if (null !== $data['fields'][$name]) {
|
||||
$rsm->addScalarResult($name, $name, $type);
|
||||
}
|
||||
}
|
||||
@ -460,7 +457,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -488,7 +485,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -498,7 +495,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
if (empty($value)) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\JobBundle\Form;
|
||||
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -19,7 +20,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType;
|
||||
|
||||
class CSPersonDispositifsType extends AbstractType
|
||||
{
|
||||
@ -90,7 +90,7 @@ class CSPersonDispositifsType extends AbstractType
|
||||
'label' => 'Code "Ma démarche FSE"',
|
||||
'required' => false,
|
||||
])
|
||||
->add('prescripteur', PickThirdPartyType::class, [
|
||||
->add('prescripteur', PickThirdpartyDynamicType::class, [
|
||||
'required' => false,
|
||||
'types' => ['prescripteur'],
|
||||
'label' => 'Prescripteur',
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\JobBundle\Form;
|
||||
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -19,7 +20,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
@ -148,7 +148,7 @@ class CSPersonPersonalSituationType extends AbstractType
|
||||
'choices' => \array_combine(CSPerson::HANDICAP_RECOMMANDATIONS, CSPerson::HANDICAP_RECOMMANDATIONS),
|
||||
'choice_label' => fn ($k) => 'handicap_recommandation.'.$k,
|
||||
])
|
||||
->add('handicapAccompagnement', PickThirdPartyType::class, [
|
||||
->add('handicapAccompagnement', PickThirdpartyDynamicType::class, [
|
||||
'center' => $options['center'],
|
||||
'types' => ['prescripteur'],
|
||||
'required' => false,
|
||||
|
@ -11,12 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\JobBundle\Form\ChoiceLoader;
|
||||
|
||||
use Chill\FranceTravailApiBundle\ApiHelper\PartenaireRomeAppellation;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||
use Chill\JobBundle\Entity\Rome\Appellation;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Chill\PoleEmploiApiBundle\ApiHelper\PartenaireRomeAppellation;
|
||||
use Chill\JobBundle\Entity\Rome\Metier;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
@ -72,25 +72,26 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface
|
||||
public function loadChoicesForValues($values, $value = null)
|
||||
{
|
||||
$choices = [];
|
||||
$code = '';
|
||||
|
||||
foreach ($values as $v) {
|
||||
if (empty($v)) {
|
||||
if (null === $v || '' === $v) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// start with "original-" ? then we load from api
|
||||
if (str_starts_with($v, 'original-')) {
|
||||
$code = \substr($v, \strlen('original-'));
|
||||
$appellation = $this->appellationRepository->findOneByCode($code);
|
||||
$appellation = $this->appellationRepository->findOneBy(['code' => $code]);
|
||||
} else {
|
||||
$id = $v;
|
||||
$appellation = $this->appellationRepository->find($id);
|
||||
}
|
||||
|
||||
if (null === $appellation) {
|
||||
if (null === $appellation && '' !== $code) {
|
||||
$def = $this->apiAppellation->getAppellation($code);
|
||||
$metier = $this->em->getRepository(Metier::class)
|
||||
->findOneByCode($def->metier->code)
|
||||
->findOneBy(['code' => $def->metier->code])
|
||||
;
|
||||
|
||||
if (null === $metier) {
|
||||
@ -108,7 +109,7 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface
|
||||
->setMetier($metier)
|
||||
;
|
||||
|
||||
if ($this->validator->validate($appellation) && $this->validator->validate($metier)) {
|
||||
if ([] === $this->validator->validate($appellation) && [] === $this->validator->validate($metier)) {
|
||||
$this->em->persist($appellation);
|
||||
}
|
||||
}
|
||||
@ -123,6 +124,8 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface
|
||||
|
||||
public function loadValuesForChoices(array $choices, $value = null)
|
||||
{
|
||||
$values = [];
|
||||
|
||||
foreach ($choices as $choice) {
|
||||
if (null === $choice) {
|
||||
$values[] = null;
|
||||
|
@ -11,13 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\JobBundle\Form;
|
||||
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Chill\MainBundle\Form\Type\DateIntervalType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@ -30,7 +30,7 @@ class ImmersionType extends AbstractType
|
||||
{
|
||||
if ('immersion' === $options['step']) {
|
||||
$builder
|
||||
->add('entreprise', PickThirdPartyType::class, [
|
||||
->add('entreprise', PickThirdpartyDynamicType::class, [
|
||||
'center' => $options['center'],
|
||||
'types' => ['entreprise'],
|
||||
'label' => "Identité de l'entreprise",
|
||||
|
@ -52,7 +52,7 @@ class CSConnectesVoter extends AbstractChillVoter implements ProvideRoleHierarch
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
if (!\in_array($attribute, self::ALL)) {
|
||||
if (!\in_array($attribute, self::ALL, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class ExportsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInt
|
||||
return false;
|
||||
}
|
||||
|
||||
$centers = $this->authorizationHelper->getReachableCenters($user, new Role($attribute));
|
||||
$centers = $this->authorizationHelper->getReachableCenters($user, $attribute);
|
||||
|
||||
if (null === $subject) {
|
||||
return count($centers) > 0;
|
||||
|
@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class EntityPersonCRUDController extends CRUDController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
public function __construct(protected readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* Override the base method to add a filtering step to a person.
|
||||
|
Loading…
x
Reference in New Issue
Block a user