From 2ddfd564017ce7a56a2f6d8989bf1ef2276ebd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Feb 2024 19:12:14 +0100 Subject: [PATCH] fix phpstan and rector errors, fix path for rector rules --- .../Controller/CustomFieldController.php | 2 +- .../CRUD/Controller/AbstractCRUDController.php | 4 +--- .../ChillMainBundle/Tests/Export/SortExportElementTest.php | 2 +- .../Controller/AccompanyingCourseCommentController.php | 2 +- src/Bundle/ChillPersonBundle/Entity/Person.php | 6 +++--- .../ByStepAggregatorTest.php | 2 +- .../ByStepFilterTest.php | 2 +- ...ndleAddFormDefaultDataOnExportFilterAggregatorRector.php | 6 +++--- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php index 2bb381d8b..85b5d9261 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php @@ -14,7 +14,7 @@ namespace Chill\CustomFieldsBundle\Controller; use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; use Chill\CustomFieldsBundle\Form\CustomFieldType; -use Symfony\Bridge\Doctrine\ManagerRegistry; +use Doctrine\Persistence\ManagerRegistry; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php index 882187fad..ea5e55a69 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php @@ -39,8 +39,6 @@ abstract class AbstractCRUDController extends AbstractController */ protected array $crudConfig = []; - public function __construct(private readonly ManagerRegistry $managerRegistry) {} - /** * get the role given from the config. */ @@ -183,7 +181,7 @@ abstract class AbstractCRUDController extends AbstractController $expectedVersion = $request->query->getInt('entity_version'); try { - $manager = $this->managerRegistry->getManagerForClass($this->getEntityClass()); + $manager = $this->getManagerRegistry()->getManagerForClass($this->getEntityClass()); if ($manager instanceof EntityManagerInterface) { $manager->lock($e, LockMode::OPTIMISTIC, $expectedVersion); diff --git a/src/Bundle/ChillMainBundle/Tests/Export/SortExportElementTest.php b/src/Bundle/ChillMainBundle/Tests/Export/SortExportElementTest.php index cd820bb1c..02cf0a90f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/SortExportElementTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/SortExportElementTest.php @@ -102,7 +102,7 @@ class SortExportElementTest extends KernelTestCase private function makeTranslator(): TranslatorInterface { return new class () implements TranslatorInterface { - public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null) + public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null) { return $id; } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index cbead99f4..d4a78fc18 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -16,8 +16,8 @@ use Chill\PersonBundle\Form\AccompanyingCourseCommentType; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\ManagerRegistry; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; -use Symfony\Bridge\Doctrine\ManagerRegistry; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 6f56d82ec..d337d5d7f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -503,7 +503,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * The person's spoken languages. * - * @var Collection + * @var Collection * * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\Language") * @@ -1788,9 +1788,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI } /** - * @param (\Doctrine\Common\Collections\Collection&\iterable<\Chill\MainBundle\Entity\Language>) $spokenLanguages + * @param (\Doctrine\Common\Collections\Collection) $spokenLanguages */ - public function setSpokenLanguages(mixed $spokenLanguages): self + public function setSpokenLanguages(Collection $spokenLanguages): self { $this->spokenLanguages = $spokenLanguages; diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByStepAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByStepAggregatorTest.php index 4e15b5286..6b75f6634 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByStepAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByStepAggregatorTest.php @@ -27,7 +27,7 @@ class ByStepAggregatorTest extends AbstractAggregatorTest public function getAggregator() { $translator = new class () implements TranslatorInterface { - public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null) + public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null) { return $id; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php index 77ff35ad6..18415ac89 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php @@ -28,7 +28,7 @@ class ByStepFilterTest extends AbstractFilterTest public function getFilter() { $translator = new class () implements TranslatorInterface { - public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null) + public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null) { return $id; } diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index b2efd260a..81279823b 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -17,14 +17,14 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\ListInterface; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\ClassAnalyzer; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends AbstractRector +final readonly class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends AbstractRector { public function __construct( - private readonly ClassAnalyzer $classAnalyzer, + private ClassAnalyzer $classAnalyzer, ) {} public function getRuleDefinition(): RuleDefinition