From 92a6fed52166b6edaed8ba2c4b0be112ebec561a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 25 Feb 2022 09:48:33 +0100 Subject: [PATCH] phpstan fixes --- phpstan-deprecations.neon | 27 ------------------- .../Controller/AbstractElementController.php | 9 +++---- .../Controller/ElementController.php | 4 +-- .../Migrations/Version20180522080432.php | 4 +-- .../Migrations/Version20181219145631.php | 4 +-- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/phpstan-deprecations.neon b/phpstan-deprecations.neon index 1e80ab775..2de8b8bc8 100644 --- a/phpstan-deprecations.neon +++ b/phpstan-deprecations.neon @@ -222,33 +222,6 @@ parameters: count: 1 path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php - - - message: - """ - #^Class Chill\\\\AMLI\\\\BudgetBundle\\\\Controller\\\\AbstractElementController extends deprecated class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\Controller\\: - since Symfony 4\\.2, use "Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController" instead\\.$# - """ - count: 1 - path: src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php - - - - message: - """ - #^Class Chill\\\\AMLI\\\\BudgetBundle\\\\Controller\\\\ElementController extends deprecated class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\Controller\\: - since Symfony 4\\.2, use "Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController" instead\\.$# - """ - count: 1 - path: src/Bundle/ChillBudgetBundle/Controller/ElementController.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: 1 - path: src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php - - message: """ diff --git a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php index d7bfc80c5..519dc1605 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php @@ -16,8 +16,7 @@ use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter; use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Form; use Symfony\Component\HttpFoundation\Request; @@ -26,7 +25,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; use function get_class; -abstract class AbstractElementController extends Controller +abstract class AbstractElementController extends AbstractController { protected LoggerInterface $chillMainLogger; @@ -117,7 +116,7 @@ abstract class AbstractElementController extends Controller $indexPage = 'chill_budget_elements_household_index'; } - $entity = null !== $element->getPerson() ?: $element->getHousehold(); + $entity = null !== $element->getPerson() ? $element->getPerson() : $element->getHousehold(); $form = $this->createForm($this->getType(), $element); $form->add('submit', SubmitType::class); @@ -150,7 +149,7 @@ abstract class AbstractElementController extends Controller protected function _new($entity, Request $request, $template, $flashMessageOnSuccess) { /** @var AbstractElement $element */ - $element = new AbstractElement(); + $element = $this->createNewElement(); if ($entity instanceof Person) { $element->setPerson($entity); diff --git a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php index 9f6f14faa..afe16a066 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php @@ -21,13 +21,13 @@ use DateTime; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Contracts\Translation\TranslatorInterface; use function array_merge; use function count; -class ElementController extends Controller +class ElementController extends AbstractController { protected CalculatorManager $calculator; diff --git a/src/Bundle/ChillBudgetBundle/Migrations/Version20180522080432.php b/src/Bundle/ChillBudgetBundle/Migrations/Version20180522080432.php index 3a8d350b7..022d53354 100644 --- a/src/Bundle/ChillBudgetBundle/Migrations/Version20180522080432.php +++ b/src/Bundle/ChillBudgetBundle/Migrations/Version20180522080432.php @@ -21,7 +21,7 @@ final class Version20180522080432 extends AbstractMigration { public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + // $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SCHEMA chill_budget CASCADE'); } @@ -33,7 +33,7 @@ final class Version20180522080432 extends AbstractMigration public function up(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + // $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SCHEMA chill_budget'); $this->addSql('DROP SEQUENCE report_id_seq CASCADE'); diff --git a/src/Bundle/ChillBudgetBundle/Migrations/Version20181219145631.php b/src/Bundle/ChillBudgetBundle/Migrations/Version20181219145631.php index 059d7f2c1..1de24772c 100644 --- a/src/Bundle/ChillBudgetBundle/Migrations/Version20181219145631.php +++ b/src/Bundle/ChillBudgetBundle/Migrations/Version20181219145631.php @@ -21,14 +21,14 @@ final class Version20181219145631 extends AbstractMigration { public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + // $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_budget.charge ALTER help SET NOT NULL'); } public function up(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + // $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_budget.charge ALTER help DROP NOT NULL'); }