From 5fe612c86091b70c0b75f0482ae8b4550502fc20 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 6 Apr 2024 17:54:55 +0200 Subject: [PATCH] cs fixer --- .github/workflows/static.yml | 48 +++++++++++++++++++ .gitignore | 3 +- .php-cs-fixer.dist.php | 19 ++++++++ .styleci.yml | 31 ------------ composer.json | 3 +- .../CmfRoutingExtension.php | 3 -- src/Doctrine/Orm/ContentRepository.php | 2 - src/Doctrine/Orm/RedirectRoute.php | 9 ---- src/Doctrine/Orm/Route.php | 3 -- src/Doctrine/Orm/RouteProvider.php | 15 ++---- src/Doctrine/Phpcr/ContentRepository.php | 6 --- src/Doctrine/Phpcr/PrefixCandidates.php | 7 +-- src/Doctrine/Phpcr/RedirectRoute.php | 34 ------------- src/Doctrine/Phpcr/Route.php | 28 ----------- src/Doctrine/Phpcr/RouteProvider.php | 4 +- src/Form/Type/RouteTypeType.php | 9 ---- src/Model/RedirectRoute.php | 28 ++--------- src/Model/Route.php | 17 ++----- src/Routing/DynamicRouter.php | 2 +- src/Routing/RedirectableRequestMatcher.php | 7 +-- .../RouteDefaultsTwigValidator.php | 2 +- .../Doctrine/Phpcr/RedirectRouteTest.php | 3 +- .../Doctrine/Phpcr/RouteProviderTest.php | 2 +- tests/Functional/Doctrine/Phpcr/RouteTest.php | 2 +- .../Functional/Routing/DynamicRouterTest.php | 2 +- .../RouteDefaultsTwigValidatorTest.php | 12 ++--- 26 files changed, 98 insertions(+), 203 deletions(-) create mode 100644 .github/workflows/static.yml create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .styleci.yml diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 00000000..4146017b --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,48 @@ +name: Static analysis + +on: + push: + branches: + - '[0-9]+.x' + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.x' + pull_request: + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: "curl,dom,json,xml,dom" + coverage: none + + - name: Checkout code + uses: actions/checkout@v4 + + # have to install phpstan ourselves here, the phpstan-ga fails at composer install with weird errors + # composer require --no-update jackalope/jackalope-doctrine-dbal jackalope/jackalope-jackrabbit phpstan/phpstan + - name: Install phpstan + run: | + + composer update + + - name: PHPStan + run: vendor/bin/phpstan analyze --no-progress + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --dry-run --diff diff --git a/.gitignore b/.gitignore index 6e7a8532..0b4c0b10 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ phpunit.xml composer.lock vendor tests/Fixtures/App/var/ -.phpunit.result.cache +.phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..a8e3ac3a --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,19 @@ +in(__DIR__.'/src') + ->in(__DIR__.'/tests') + ->exclude('tests/Fixtures/App/var/') + ->name('*.php') +; + +$config = new PhpCsFixer\Config(); + +return $config + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'single_line_throw' => false, + ]) + ->setFinder($finder) +; diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 793ac737..00000000 --- a/.styleci.yml +++ /dev/null @@ -1,31 +0,0 @@ -####################################################### -# DO NOT EDIT THIS FILE! # -# # -# It's auto-generated by symfony-cmf/dev-kit package. # -####################################################### - -############################################################################ -# This file is part of the Symfony CMF package. # -# # -# (c) Symfony CMF i # -# # -# For the full copyright and license information, please view the LICENSE # -# file that was distributed with this source code. # -############################################################################ - - -preset: symfony - -risky: true - -enabled: - - combine_consecutive_unsets - - no_php4_constructor - - no_useless_else - - ordered_use - - strict - - php_unit_construct - -disabled: - - single_line_class_definition - - single_line_throw diff --git a/composer.json b/composer.json index 1a07d8e1..94a8ad27 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-symfony": "^1.3", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.5.28", "matthiasnoback/symfony-dependency-injection-test": "^4.1.0 || ^5.1.0", "matthiasnoback/symfony-config-test": "^4.1.0 || ^5.1.0", "symfony/phpunit-bridge": "^7.0.3", @@ -52,6 +52,7 @@ "conflict": { "doctrine/common": "<3.1.1", "doctrine/persistence": "<1.3.0", + "doctrine/phpcr-odm": "<2.0", "symfony/doctrine-bridge": "<6.4.0", "symfony/security-core": "<6.4.0" }, diff --git a/src/DependencyInjection/CmfRoutingExtension.php b/src/DependencyInjection/CmfRoutingExtension.php index 5d015913..b03db9cb 100644 --- a/src/DependencyInjection/CmfRoutingExtension.php +++ b/src/DependencyInjection/CmfRoutingExtension.php @@ -27,9 +27,6 @@ */ final class CmfRoutingExtension extends Extension { - /** - * {@inheritdoc} - */ public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration(new Configuration(), $configs); diff --git a/src/Doctrine/Orm/ContentRepository.php b/src/Doctrine/Orm/ContentRepository.php index ef629000..ba0b02c1 100644 --- a/src/Doctrine/Orm/ContentRepository.php +++ b/src/Doctrine/Orm/ContentRepository.php @@ -37,8 +37,6 @@ protected function getModelAndId(string $identifier): array } /** - * {@inheritdoc} - * * @param string $id The ID contains both model name and id, separated by a colon */ public function findById(mixed $id): ?object diff --git a/src/Doctrine/Orm/RedirectRoute.php b/src/Doctrine/Orm/RedirectRoute.php index 3bb5f210..7c5b07b4 100644 --- a/src/Doctrine/Orm/RedirectRoute.php +++ b/src/Doctrine/Orm/RedirectRoute.php @@ -52,9 +52,6 @@ public function setParameters(array $parameters): void $this->serialisedParameters = json_encode($parameters, \JSON_THROW_ON_ERROR); } - /** - * {@inheritdoc} - */ public function getParameters(): array { if (!isset($this->serialisedParameters)) { @@ -65,9 +62,6 @@ public function getParameters(): array return \is_array($params) ? $params : []; } - /** - * {@inheritdoc} - */ public function getPath(): string { $pattern = parent::getPath(); @@ -78,9 +72,6 @@ public function getPath(): string return $pattern; } - /** - * {@inheritdoc} - */ protected function isBooleanOption(string $name): bool { return 'add_trailing_slash' === $name || parent::isBooleanOption($name); diff --git a/src/Doctrine/Orm/Route.php b/src/Doctrine/Orm/Route.php index eb1a4e75..eb93dc73 100644 --- a/src/Doctrine/Orm/Route.php +++ b/src/Doctrine/Orm/Route.php @@ -58,9 +58,6 @@ public function getPosition(): int return $this->position; } - /** - * {@inheritdoc} - */ public function getRouteKey(): string { return $this->getName(); diff --git a/src/Doctrine/Orm/RouteProvider.php b/src/Doctrine/Orm/RouteProvider.php index 27d17fe9..743970c8 100644 --- a/src/Doctrine/Orm/RouteProvider.php +++ b/src/Doctrine/Orm/RouteProvider.php @@ -41,9 +41,6 @@ public function __construct(ManagerRegistry $managerRegistry, CandidatesInterfac $this->candidatesStrategy = $candidatesStrategy; } - /** - * {@inheritdoc} - */ public function getRouteCollectionForRequest(Request $request): RouteCollection { $collection = new RouteCollection(); @@ -52,7 +49,7 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection if (0 === \count($candidates)) { return $collection; } - $routes = $this->getRouteRepository()->findByStaticPrefix($candidates, ['position' => 'ASC']); /** @phpstan-ignore-line */ + $routes = $this->getRouteRepository()->findByStaticPrefix($candidates, ['position' => 'ASC']); /* @phpstan-ignore-line */ /** @var Route $route */ foreach ($routes as $route) { $collection->add($route->getName(), $route); @@ -61,9 +58,6 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection return $collection; } - /** - * {@inheritdoc} - */ public function getRouteByName($name): SymfonyRoute { if (!$this->candidatesStrategy->isCandidate($name)) { @@ -78,9 +72,6 @@ public function getRouteByName($name): SymfonyRoute return $route; } - /** - * {@inheritdoc} - */ public function getRoutesByNames($names = null): array { if (null === $names) { @@ -90,7 +81,7 @@ public function getRoutesByNames($names = null): array try { return $this->getRouteRepository()->findBy([], null, $this->routeCollectionLimit ?: null); - } catch (TableNotFoundException $e) { + } catch (TableNotFoundException) { return []; } } @@ -100,7 +91,7 @@ public function getRoutesByNames($names = null): array // TODO: if we do findByName with multivalue, we need to filter with isCandidate afterwards try { $routes[] = $this->getRouteByName($name); - } catch (RouteNotFoundException $e) { + } catch (RouteNotFoundException) { // not found } } diff --git a/src/Doctrine/Phpcr/ContentRepository.php b/src/Doctrine/Phpcr/ContentRepository.php index 96f238a5..02a712c4 100644 --- a/src/Doctrine/Phpcr/ContentRepository.php +++ b/src/Doctrine/Phpcr/ContentRepository.php @@ -26,17 +26,11 @@ */ class ContentRepository extends DoctrineProvider implements ContentRepositoryInterface { - /** - * {@inheritdoc} - */ public function findById($id): ?object { return $this->getObjectManager()->find(null, $id); } - /** - * {@inheritdoc} - */ public function getContentId($content): ?string { if (!\is_object($content)) { diff --git a/src/Doctrine/Phpcr/PrefixCandidates.php b/src/Doctrine/Phpcr/PrefixCandidates.php index 7b17f1bc..afd9303d 100644 --- a/src/Doctrine/Phpcr/PrefixCandidates.php +++ b/src/Doctrine/Phpcr/PrefixCandidates.php @@ -47,7 +47,7 @@ final class PrefixCandidates extends Candidates * is using * @param int $limit Limit to candidates generated per prefix */ - public function __construct(array $prefixes, array $locales = [], ManagerRegistry $doctrine = null, int $limit = 20) + public function __construct(array $prefixes, array $locales = [], ?ManagerRegistry $doctrine = null, int $limit = 20) { parent::__construct($locales, $limit); $this->setPrefixes($prefixes); @@ -74,8 +74,6 @@ public function isCandidate($name): bool } /** - * {@inheritdoc} - * * @param QueryBuilder $queryBuilder */ public function restrictQuery($queryBuilder): void @@ -91,9 +89,6 @@ public function restrictQuery($queryBuilder): void } } - /** - * {@inheritdoc} - */ public function getCandidates(Request $request): array { $candidates = []; diff --git a/src/Doctrine/Phpcr/RedirectRoute.php b/src/Doctrine/Phpcr/RedirectRoute.php index 64f08d15..c9ec3d0b 100644 --- a/src/Doctrine/Phpcr/RedirectRoute.php +++ b/src/Doctrine/Phpcr/RedirectRoute.php @@ -69,36 +69,11 @@ public function setParentDocument($parent): static return $this; } - /** - * {@inheritdoc} - */ public function getParentDocument(): ?object { return $this->parent; } - /** - * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface - * @see setParentDocument - */ - public function setParent($parent) - { - @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use setParentDocument() instead.', \E_USER_DEPRECATED); - - return $this->setParentDocument($parent); - } - - /** - * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface - * @see getParentDocument - */ - public function getParent() - { - @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use getParentDocument() instead.', \E_USER_DEPRECATED); - - return $this->getParentDocument(); - } - /** * Rename a route by setting its new name. * @@ -160,9 +135,6 @@ public function getPrefix(): string return $this->idPrefix; } - /** - * {@inheritdoc} - */ public function setPrefix(string $prefix): static { $this->idPrefix = $prefix; @@ -206,9 +178,6 @@ public function generateStaticPrefix(string $id, string $idPrefix): string return $url; } - /** - * {@inheritdoc} - */ public function getPath(): string { $pattern = parent::getPath(); @@ -240,9 +209,6 @@ public function getRouteChildren(): array return $children; } - /** - * {@inheritdoc} - */ protected function isBooleanOption(string $name): bool { return 'add_trailing_slash' === $name || parent::isBooleanOption($name); diff --git a/src/Doctrine/Phpcr/Route.php b/src/Doctrine/Phpcr/Route.php index 5a50ffa1..d01256ab 100644 --- a/src/Doctrine/Phpcr/Route.php +++ b/src/Doctrine/Phpcr/Route.php @@ -89,28 +89,6 @@ public function getParentDocument(): object return $this->parent; } - /** - * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface - * @see setParentDocument - */ - public function setParent($parent) - { - @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use setParentDocument() instead.', \E_USER_DEPRECATED); - - return $this->setParentDocument($parent); - } - - /** - * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface - * @see getParentDocument - */ - public function getParent() - { - @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use getParentDocument() instead.', \E_USER_DEPRECATED); - - return $this->getParentDocument(); - } - /** * Rename a route by setting its new name. * @@ -172,9 +150,6 @@ public function getPrefix(): ?string return $this->idPrefix; } - /** - * {@inheritdoc} - */ public function setPrefix(string $prefix): static { $this->idPrefix = $prefix; @@ -264,9 +239,6 @@ public function getChildren(): Collection return $this->children; } - /** - * {@inheritdoc} - */ protected function isBooleanOption(string $name): bool { return 'add_trailing_slash' === $name || parent::isBooleanOption($name); diff --git a/src/Doctrine/Phpcr/RouteProvider.php b/src/Doctrine/Phpcr/RouteProvider.php index cf21c4ed..e19099f7 100644 --- a/src/Doctrine/Phpcr/RouteProvider.php +++ b/src/Doctrine/Phpcr/RouteProvider.php @@ -45,7 +45,7 @@ public function __construct( ManagerRegistry $managerRegistry, CandidatesInterface $candidatesStrategy, ?string $className = null, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($managerRegistry, $className); $this->candidatesStrategy = $candidatesStrategy; @@ -102,8 +102,6 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection } /** - * {@inheritdoc} - * * @param string $name The absolute path or uuid of the Route document */ public function getRouteByName(string $name): SymfonyRoute diff --git a/src/Form/Type/RouteTypeType.php b/src/Form/Type/RouteTypeType.php index 4ab01217..8cd09c8d 100644 --- a/src/Form/Type/RouteTypeType.php +++ b/src/Form/Type/RouteTypeType.php @@ -19,9 +19,6 @@ class RouteTypeType extends AbstractType { protected array $routeTypes = []; - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $choices = []; @@ -43,17 +40,11 @@ public function addRouteType(string $type): void $this->routeTypes[$type] = $type; } - /** - * {@inheritdoc} - */ public function getParent(): string { return ChoiceType::class; } - /** - * {@inheritdoc} - */ public function getBlockPrefix(): string { return 'cmf_routing_route_type'; diff --git a/src/Model/RedirectRoute.php b/src/Model/RedirectRoute.php index 41b1ab27..aa040106 100644 --- a/src/Model/RedirectRoute.php +++ b/src/Model/RedirectRoute.php @@ -11,13 +11,9 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Model; -use LogicException; use Symfony\Cmf\Component\Routing\RedirectRouteInterface; use Symfony\Component\Routing\Route as SymfonyRoute; -/** - * {@inheritdoc} - */ class RedirectRoute extends Route implements RedirectRouteInterface { /** @@ -47,16 +43,13 @@ class RedirectRoute extends Route implements RedirectRouteInterface * as route content for the redirection controller to have the redirect route * object as content. * - * @throws LogicException + * @throws \LogicException */ - public function setContent($document): static + public function setContent(object $document): static { - throw new LogicException('Do not set a content for the redirect route. It is its own content.'); + throw new \LogicException('Do not set a content for the redirect route. It is its own content.'); } - /** - * {@inheritdoc} - */ public function getContent(): static { return $this; @@ -71,9 +64,6 @@ public function setRouteTarget(?SymfonyRoute $document): void $this->routeTarget = $document; } - /** - * {@inheritdoc} - */ public function getRouteTarget(): ?SymfonyRoute { return $this->routeTarget; @@ -87,9 +77,6 @@ public function setRouteName(?string $routeName): void $this->routeName = $routeName; } - /** - * {@inheritdoc} - */ public function getRouteName(): ?string { return $this->routeName; @@ -104,9 +91,6 @@ public function setPermanent(bool $permanent): void $this->permanent = $permanent; } - /** - * {@inheritdoc} - */ public function isPermanent(): bool { return $this->permanent; @@ -123,9 +107,6 @@ public function setParameters(array $parameters): void $this->parameters = $parameters; } - /** - * {@inheritdoc} - */ public function getParameters(): array { return $this->parameters; @@ -139,9 +120,6 @@ public function setUri(?string $uri): void $this->uri = $uri; } - /** - * {@inheritdoc} - */ public function getUri(): ?string { return $this->uri; diff --git a/src/Model/Route.php b/src/Model/Route.php index cc7378f2..01bbffbe 100644 --- a/src/Model/Route.php +++ b/src/Model/Route.php @@ -25,10 +25,8 @@ class Route extends SymfonyRoute implements RouteObjectInterface { /** * Unique id of this route. - * - * @var string|int|null */ - protected $id; + protected string|int|null $id; /** * The referenced content object. @@ -37,7 +35,7 @@ class Route extends SymfonyRoute implements RouteObjectInterface /** * Part of the URL that does not have parameters and thus can be used to - * naivly guess candidate routes. + * naively guess candidate routes. * * Note that this field is not used by PHPCR-ODM */ @@ -76,12 +74,9 @@ public function __construct(array $options = []) } } - /** - * {@inheritdoc} - */ public function getRouteKey(): string { - return (string) $this->getId(); + return $this->getId(); } /** @@ -117,9 +112,6 @@ public function setContent(object $object): static return $this; } - /** - * {@inheritdoc} - */ public function getContent(): ?object { return $this->content; @@ -185,9 +177,6 @@ protected function isBooleanOption(string $name): bool return \in_array($name, ['add_format_pattern', 'add_locale_pattern']); } - /** - * {@inheritdoc} - */ public function getPath(): string { $pattern = ''; diff --git a/src/Routing/DynamicRouter.php b/src/Routing/DynamicRouter.php index 350654bf..88f19693 100644 --- a/src/Routing/DynamicRouter.php +++ b/src/Routing/DynamicRouter.php @@ -79,7 +79,7 @@ public function matchRequest(Request $request): array * * @return array the updated defaults to return for this match */ - protected function cleanDefaults(array $defaults, Request $request = null): array + protected function cleanDefaults(array $defaults, ?Request $request = null): array { if (null === $request) { $request = $this->getRequest(); diff --git a/src/Routing/RedirectableRequestMatcher.php b/src/Routing/RedirectableRequestMatcher.php index 6136d027..61c0256b 100644 --- a/src/Routing/RedirectableRequestMatcher.php +++ b/src/Routing/RedirectableRequestMatcher.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Routing; +use Symfony\Cmf\Bundle\RoutingBundle\Controller\RedirectController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Exception\ExceptionInterface; use Symfony\Component\Routing\Exception\ResourceNotFoundException; @@ -68,10 +69,10 @@ public function matchRequest(Request $request): array } } - private function redirect(string $path, string $route, string $scheme = null): array + private function redirect(string $path, string $route, ?string $scheme = null): array { return [ - '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', + '_controller' => RedirectController::class.'::urlRedirectAction', 'path' => $path, 'permanent' => true, 'scheme' => $scheme, @@ -82,7 +83,7 @@ private function redirect(string $path, string $route, string $scheme = null): a } /** - * Return a duplicated version of $request with the new $newpath as request_uri. + * Return a duplicated version of $request with the new $newPath as request_uri. */ private function rebuildRequest(Request $request, string $newPath): Request { diff --git a/src/Validator/Constraints/RouteDefaultsTwigValidator.php b/src/Validator/Constraints/RouteDefaultsTwigValidator.php index 04258dc9..f53e7e93 100644 --- a/src/Validator/Constraints/RouteDefaultsTwigValidator.php +++ b/src/Validator/Constraints/RouteDefaultsTwigValidator.php @@ -31,7 +31,7 @@ public function __construct(ControllerResolverInterface $controllerResolver, ?Lo $this->twig = $twig; } - public function validate($defaults, Constraint $constraint) + public function validate(mixed $defaults, Constraint $constraint): void { if (!$constraint instanceof RouteDefaults) { throw new \InvalidArgumentException(sprintf('Expected %s, got %s', RouteDefaults::class, get_class($constraint))); diff --git a/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php b/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php index 78892b97..c7247c0c 100644 --- a/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php +++ b/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php @@ -14,12 +14,11 @@ use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase; -use Symfony\Cmf\Component\Routing\RedirectRouteInterface; use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface; class RedirectRouteTest extends BaseTestCase { - const ROUTE_ROOT = '/test/redirectroute'; + public const ROUTE_ROOT = '/test/redirectroute'; public function setUp(): void { diff --git a/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php b/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php index 54931348..6c028463 100644 --- a/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php +++ b/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php @@ -21,7 +21,7 @@ class RouteProviderTest extends BaseTestCase { - const ROUTE_ROOT = '/test/routing'; + public const ROUTE_ROOT = '/test/routing'; /** @var RouteProvider */ private $repository; diff --git a/tests/Functional/Doctrine/Phpcr/RouteTest.php b/tests/Functional/Doctrine/Phpcr/RouteTest.php index db03ea08..8c98e191 100644 --- a/tests/Functional/Doctrine/Phpcr/RouteTest.php +++ b/tests/Functional/Doctrine/Phpcr/RouteTest.php @@ -16,7 +16,7 @@ class RouteTest extends BaseTestCase { - const ROUTE_ROOT = '/test/routing'; + public const ROUTE_ROOT = '/test/routing'; public function setUp(): void { diff --git a/tests/Functional/Routing/DynamicRouterTest.php b/tests/Functional/Routing/DynamicRouterTest.php index fd68b03b..14b17d8d 100644 --- a/tests/Functional/Routing/DynamicRouterTest.php +++ b/tests/Functional/Routing/DynamicRouterTest.php @@ -39,7 +39,7 @@ class DynamicRouterTest extends BaseTestCase protected $routeNamePrefix; - const ROUTE_ROOT = '/test/routing'; + public const ROUTE_ROOT = '/test/routing'; public function setUp(): void { diff --git a/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php b/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php index 4dd56316..3d0c8941 100644 --- a/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php +++ b/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php @@ -12,7 +12,6 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\Validator\Constraints; use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaults; use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaultsTwigValidator; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; @@ -24,19 +23,20 @@ class RouteDefaultsTwigValidatorTest extends ConstraintValidatorTestCase { protected MockObject&ControllerResolverInterface $controllerResolver; - private MockObject&LoaderInterface $engine; + private MockObject&LoaderInterface $loader; protected function setUp(): void { $this->controllerResolver = $this->createMock(ControllerResolverInterface::class); - $this->engine = $this->createMock(LoaderInterface::class); + $this->loader = $this->createMock(LoaderInterface::class); parent::setUp(); + $this->constraint = new RouteDefaults(); } protected function createValidator(): ConstraintValidatorInterface { - return new RouteDefaultsTwigValidator($this->controllerResolver, $this->engine); + return new RouteDefaultsTwigValidator($this->controllerResolver, $this->loader); } public function testNoTemplateViolationWithoutTwig(): void @@ -71,7 +71,7 @@ public function testControllerPathViolation(): void public function testCorrectTemplate(): void { - $this->engine + $this->loader ->method('exists') ->willReturn(true) ; @@ -84,7 +84,7 @@ public function testCorrectTemplate(): void public function testTemplateViolation(): void { $this - ->engine + ->loader ->method('exists') ->willReturn(false) ;