Skip to content

Commit 91c738d

Browse files
committed
[Chore] Bump PHPStan & Rector versions
1 parent 3057e53 commit 91c738d

File tree

73 files changed

+1056
-572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1056
-572
lines changed

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565
"pamil/phpspec-skip-example-extension": "^4.2",
6666
"phpspec/phpspec": "^7.5",
6767
"phpspec/prophecy-phpunit": "^2.2",
68-
"phpstan/phpstan": "^1.12",
69-
"phpstan/phpstan-phpunit": "^1.4",
70-
"phpstan/phpstan-webmozart-assert": "^1.2",
68+
"phpstan/phpstan": "^2.0",
69+
"phpstan/phpstan-phpunit": "^2.0",
70+
"phpstan/phpstan-webmozart-assert": "^2.0",
7171
"phpunit/phpunit": "^10.0",
72-
"rector/rector": "^0.18.2",
72+
"rector/rector": "^2.0",
7373
"sylius-labs/coding-standard": "^4.4",
7474
"sylius/grid-bundle": "^1.13",
7575
"symfony/console": "^6.4 || ^7.1",
@@ -137,7 +137,8 @@
137137
"analyse": [
138138
"@composer validate --strict",
139139
"vendor/bin/ecs check",
140-
"vendor/bin/phpstan analyse --ansi --memory-limit=256M -c phpstan.neon -l max src"
140+
"vendor/bin/phpstan analyse --ansi --memory-limit=256M -c phpstan.neon -l max src",
141+
"vendor/bin/rector process --dry-run"
141142
],
142143
"fix": [
143144
"vendor/bin/ecs check --fix"

phpstan-baseline.neon

Lines changed: 853 additions & 0 deletions
Large diffs are not rendered by default.

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ includes:
33
- vendor/phpstan/phpstan-phpunit/extension.neon
44

55
- vendor/phpstan/phpstan-phpunit/rules.neon
6+
- phpstan-baseline.neon
67

78
parameters:
89
reportUnmatchedIgnoredErrors: false

rector.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
declare(strict_types=1);
44

5-
use Rector\Core\Configuration\Option;
6-
use Rector\Php74\Rector\Property\TypedPropertyRector;
7-
use Rector\Set\ValueObject\SetList;
8-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
9-
10-
return static function (ContainerConfigurator $containerConfigurator): void
11-
{
12-
$parameters = $containerConfigurator->parameters();
13-
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
14-
$parameters->set(Option::IMPORT_SHORT_CLASSES, false);
15-
16-
$services = $containerConfigurator->services();
17-
$services->set(TypedPropertyRector::class);
18-
};
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/src'
10+
])
11+
->withSkipPath('src/Bundle/spec')
12+
->withSkipPath('src/Component/legacy/spec')
13+
->withSkipPath('src/Component/spec')
14+
->withPhpSets(php80: true)
15+
;

src/Bundle/AbstractResourceBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function getModelNamespace(): ?string
9494
/**
9595
* Return mapping compiler pass class depending on driver.
9696
*
97-
*
97+
* @return string[]
9898
*
9999
* @throws UnknownDriverException
100100
*/

src/Bundle/Controller/ControllerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected function json($data, int $status = 200, array $headers = [], array $co
146146
protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse
147147
{
148148
$response = new BinaryFileResponse($file);
149-
$response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName);
149+
$response->setContentDisposition($disposition, $fileName ?? $response->getFile()->getFilename());
150150

151151
return $response;
152152
}

src/Bundle/Controller/EventDispatcher.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919

2020
final class EventDispatcher implements EventDispatcherInterface
2121
{
22-
private SymfonyEventDispatcherInterface $eventDispatcher;
23-
24-
public function __construct(SymfonyEventDispatcherInterface $eventDispatcher)
22+
public function __construct(private SymfonyEventDispatcherInterface $eventDispatcher)
2523
{
26-
$this->eventDispatcher = $eventDispatcher;
2724
}
2825

2926
public function dispatch(

src/Bundle/Controller/FlashHelper.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ final class FlashHelper implements FlashHelperInterface
2727
/** @var RequestStack|SessionInterface */
2828
private $requestStack;
2929

30-
private TranslatorInterface $translator;
31-
32-
private string $defaultLocale;
33-
3430
/**
3531
* @param RequestStack|SessionInterface $requestStack
3632
*/
37-
public function __construct(/* RequestStack */ $requestStack, TranslatorInterface $translator, string $defaultLocale)
33+
public function __construct(/* RequestStack */ $requestStack, private TranslatorInterface $translator, private string $defaultLocale)
3834
{
3935
/** @phpstan-ignore-next-line */
4036
if (!$requestStack instanceof SessionInterface && !$requestStack instanceof RequestStack) {
@@ -53,8 +49,6 @@ public function __construct(/* RequestStack */ $requestStack, TranslatorInterfac
5349
}
5450

5551
$this->requestStack = $requestStack;
56-
$this->translator = $translator;
57-
$this->defaultLocale = $defaultLocale;
5852
}
5953

6054
public function addSuccessFlash(

src/Bundle/Controller/ParametersParser.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@
2121

2222
final class ParametersParser implements ParametersParserInterface
2323
{
24-
private ContainerInterface $container;
25-
26-
private ExpressionLanguage $expression;
27-
28-
public function __construct(ContainerInterface $container, ExpressionLanguage $expression)
24+
public function __construct(private ContainerInterface $container, private ExpressionLanguage $expression)
2925
{
30-
$this->container = $container;
31-
$this->expression = $expression;
3226
}
3327

3428
public function parseRequestValues(array $parameters, Request $request): array
@@ -61,15 +55,15 @@ private function parseRequestValue($parameter, Request $request)
6155
return $parameter;
6256
}
6357

64-
if (0 === strpos($parameter, '$')) {
58+
if (str_starts_with($parameter, '$')) {
6559
return RequestParameterProvider::provide($request, substr($parameter, 1));
6660
}
6761

68-
if (0 === strpos($parameter, 'expr:')) {
62+
if (str_starts_with($parameter, 'expr:')) {
6963
return $this->parseRequestValueExpression(substr($parameter, 5), $request);
7064
}
7165

72-
if (0 === strpos($parameter, '!!')) {
66+
if (str_starts_with($parameter, '!!')) {
7367
return $this->parseRequestValueTypecast($parameter, $request);
7468
}
7569

src/Bundle/Controller/RedirectHandler.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222

2323
final class RedirectHandler implements RedirectHandlerInterface
2424
{
25-
private RouterInterface $router;
26-
27-
public function __construct(RouterInterface $router)
25+
public function __construct(private RouterInterface $router)
2826
{
29-
$this->router = $router;
3027
}
3128

3229
public function redirectToResource(RequestConfiguration $configuration, ResourceInterface $resource): Response
@@ -37,7 +34,7 @@ public function redirectToResource(RequestConfiguration $configuration, Resource
3734
(string) $configuration->getRedirectRoute(ResourceActions::SHOW),
3835
$configuration->getRedirectParameters($resource),
3936
);
40-
} catch (RouteNotFoundException $exception) {
37+
} catch (RouteNotFoundException) {
4138
return $this->redirectToRoute(
4239
$configuration,
4340
(string) $configuration->getRedirectRoute(ResourceActions::INDEX),

0 commit comments

Comments
 (0)