Fix issues reported by PHPStan.

This commit is contained in:
Pol Dellaiera 2021-11-09 15:17:24 +01:00
parent 48ea67968e
commit 2eb30d2ae8
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
7 changed files with 124 additions and 137 deletions

View File

@ -1,8 +1,10 @@
<?php <?php
namespace Chill\DocStoreBundle\Repository; declare(strict_types=1);
use App\Entity\AccompanyingCourseDocument; namespace Chill\DocStoreBundle\EntityRepository;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;

View File

@ -1,18 +1,15 @@
<?php <?php
/*
*/ declare(strict_types=1);
namespace Chill\MainBundle\DependencyInjection\CompilerPass; namespace Chill\MainBundle\DependencyInjection\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Chill\MainBundle\Form\PermissionsGroupType; use Chill\MainBundle\Form\PermissionsGroupType;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
use LogicException;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class ACLFlagsCompilerPass implements CompilerPassInterface class ACLFlagsCompilerPass implements CompilerPassInterface
{ {
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
@ -29,7 +26,7 @@ class ACLFlagsCompilerPass implements CompilerPassInterface
$permissionGroupType->addMethodCall('addFlagProvider', [ $reference ]); $permissionGroupType->addMethodCall('addFlagProvider', [ $reference ]);
break; break;
default: default:
throw new \LogicalException(sprintf( throw new LogicException(sprintf(
"This tag 'scope' is not implemented: %s, on service with id %s", $tag['scope'], $id) "This tag 'scope' is not implemented: %s, on service with id %s", $tag['scope'], $id)
); );
} }

View File

@ -124,11 +124,12 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
* @param string $containerWidgetConfigParameterName the key under which we can use the widget configuration * @param string $containerWidgetConfigParameterName the key under which we can use the widget configuration
* @throws \LogicException * @throws \LogicException
* @throws \UnexpectedValueException if the given extension does not implement HasWidgetExtensionInterface * @throws \UnexpectedValueException if the given extension does not implement HasWidgetExtensionInterface
* @throws \InvalidConfigurationException if there are errors in the config
*/ */
public function doProcess(ContainerBuilder $container, $extension, public function doProcess(
$containerWidgetConfigParameterName) ContainerBuilder $container,
{ $extension,
$containerWidgetConfigParameterName
) {
if (!$container->hasDefinition(self::WIDGET_MANAGER)) { if (!$container->hasDefinition(self::WIDGET_MANAGER)) {
throw new \LogicException("the service ".self::WIDGET_MANAGER." should". throw new \LogicException("the service ".self::WIDGET_MANAGER." should".
" be present. It is required by ".self::class); " be present. It is required by ".self::class);
@ -171,7 +172,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
// check that the widget is allowed at this place // check that the widget is allowed at this place
if (!$this->isPlaceAllowedForWidget($place, $alias, $container)) { if (!$this->isPlaceAllowedForWidget($place, $alias, $container)) {
throw new \InvalidConfigurationException(sprintf( throw new InvalidConfigurationException(sprintf(
"The widget with alias %s is not allowed at place %s", "The widget with alias %s is not allowed at place %s",
$alias, $alias,
$place $place

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Repository; namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;

View File

@ -205,7 +205,7 @@ class DateRangeCovering
{ {
if (!$this->computed) { if (!$this->computed) {
throw new \LogicException(sprintf("You cannot call the method %s before ". throw new \LogicException(sprintf("You cannot call the method %s before ".
"'process'", __METHOD)); "'process'", __METHOD__));
} }
return count($this->intersections) > 0; return count($this->intersections) > 0;
@ -215,7 +215,7 @@ class DateRangeCovering
{ {
if (!$this->computed) { if (!$this->computed) {
throw new \LogicException(sprintf("You cannot call the method %s before ". throw new \LogicException(sprintf("You cannot call the method %s before ".
"'process'", __METHOD)); "'process'", __METHOD__));
} }
return $this->intersections; return $this->intersections;

View File

@ -1,20 +1,7 @@
<?php <?php
/*
* Copyright (C) 2016-2019 Champs-Libres <info@champs-libres.coop> declare(strict_types=1);
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\PersonBundle\CRUD\Controller; namespace Chill\PersonBundle\CRUD\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\CRUD\Controller\CRUDController;
@ -23,11 +10,8 @@ use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use BadMethodCallException;
/**
* Controller for entities attached as one-to-on to a person
*
*/
class OneToOneEntityPersonCRUDController extends CRUDController class OneToOneEntityPersonCRUDController extends CRUDController
{ {
protected function getTemplateFor($action, $entity, Request $request) protected function getTemplateFor($action, $entity, Request $request)
@ -83,7 +67,7 @@ class OneToOneEntityPersonCRUDController extends CRUDController
protected function generateRedirectOnCreateRoute($action, Request $request, $entity) protected function generateRedirectOnCreateRoute($action, Request $request, $entity)
{ {
throw new BadMethodCallException("not implemtented yet"); throw new BadMethodCallException('Not implemented yet.');
} }
} }

View File

@ -1,8 +1,10 @@
<?php <?php
declare(strict_types=1);
namespace Chill\PersonBundle\Repository\Household; namespace Chill\PersonBundle\Repository\Household;
use Chill\PersonBundle\Entity\Household\HouseholdMembers; use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
@ -12,6 +14,6 @@ final class HouseholdMembersRepository
public function __construct(EntityManagerInterface $entityManager) public function __construct(EntityManagerInterface $entityManager)
{ {
$this->repository = $entityManager->getRepository(HouseholdMembers::class); $this->repository = $entityManager->getRepository(HouseholdMember::class);
} }
} }