Skip to content

Commit 1bd5c20

Browse files
vincentchalamonalanpoulain
authored andcommitted
chore: apply rector to migrate tests to PHP 8.1
1 parent 4fc07cd commit 1bd5c20

File tree

383 files changed

+1524
-2019
lines changed

Some content is hidden

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

383 files changed

+1524
-2019
lines changed

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"require-dev": {
3636
"behat/behat": "^3.1",
3737
"behat/mink": "^1.9@dev",
38+
"behatch/contexts": "dev-patch-1",
3839
"doctrine/cache": "^1.11 || ^2.1",
3940
"doctrine/common": "^2.11 || ^3.0",
4041
"doctrine/data-fixtures": "^1.2.2",
@@ -60,7 +61,7 @@
6061
"psr/log": "^1.0 || ^2.0 || ^3.0",
6162
"ramsey/uuid": "^3.7 || ^4.0",
6263
"ramsey/uuid-doctrine": "^1.4",
63-
"behatch/contexts": "dev-patch-1",
64+
"rector/rector": "^0.13.9",
6465
"soyuka/stubs-mongodb": "^1.0",
6566
"symfony/asset": "^6.1",
6667
"symfony/browser-kit": "^6.1",
@@ -142,6 +143,9 @@
142143
"extra": {
143144
"branch-alias": {
144145
"dev-main": "3.0.x-dev"
146+
},
147+
"symfony": {
148+
"require": "^6.1"
145149
}
146150
}
147151
}

rector.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
]);
4141

4242
// PHPUnit
43-
// $rectorConfig->sets([
44-
// PHPUnitSetList::PHPUNIT_91,
45-
// PHPUnitSetList::PHPUNIT_CODE_QUALITY,
46-
// PHPUnitSetList::PHPUNIT_EXCEPTION,
47-
// PHPUnitSetList::REMOVE_MOCKS,
48-
// PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
49-
// PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
50-
// ]);
43+
$rectorConfig->sets([
44+
PHPUnitSetList::PHPUNIT_91,
45+
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
46+
PHPUnitSetList::PHPUNIT_EXCEPTION,
47+
PHPUnitSetList::REMOVE_MOCKS,
48+
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
49+
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
50+
]);
5151
};

src/GraphQl/Action/EntrypointAction.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class EntrypointAction
3535
{
3636
private int|bool $debug;
3737

38-
public function __construct(private readonly SchemaBuilderInterface $schemaBuilder, private readonly ExecutorInterface $executor, private readonly GraphiQlAction $graphiQlAction, private readonly GraphQlPlaygroundAction $graphQlPlaygroundAction, private readonly NormalizerInterface $normalizer, private readonly ErrorHandlerInterface $errorHandler, bool $debug = false, private readonly bool $graphiqlEnabled = false, private readonly bool $graphQlPlaygroundEnabled = false, private $defaultIde = false)
38+
public function __construct(private readonly SchemaBuilderInterface $schemaBuilder, private readonly ExecutorInterface $executor, private readonly GraphiQlAction $graphiQlAction, private readonly GraphQlPlaygroundAction $graphQlPlaygroundAction, private readonly NormalizerInterface $normalizer, private readonly ErrorHandlerInterface $errorHandler, bool $debug = false, private readonly bool $graphiqlEnabled = false, private readonly bool $graphQlPlaygroundEnabled = false, private readonly ?string $defaultIde = null)
3939
{
4040
if (class_exists(Debug::class)) {
4141
$this->debug = $debug ? Debug::INCLUDE_DEBUG_MESSAGE | Debug::INCLUDE_TRACE : false;
@@ -111,7 +111,7 @@ private function parseRequest(Request $request): array
111111
*/
112112
private function parseData(?string $query, ?string $operationName, array $variables, string $jsonContent): array
113113
{
114-
if (!\is_array($data = json_decode($jsonContent, true, 512, \JSON_THROW_ON_ERROR))) {
114+
if (!\is_array($data = json_decode($jsonContent, true, 512, \JSON_ERROR_NONE))) {
115115
throw new BadRequestHttpException('GraphQL data is not valid JSON.');
116116
}
117117

@@ -142,7 +142,7 @@ private function parseMultipartRequest(?string $query, ?string $operationName, a
142142
[$query, $operationName, $variables] = $this->parseData($query, $operationName, $variables, $operations);
143143

144144
/** @var string $map */
145-
if (!\is_array($decodedMap = json_decode($map, true, 512, \JSON_THROW_ON_ERROR))) {
145+
if (!\is_array($decodedMap = json_decode($map, true, 512, \JSON_ERROR_NONE))) {
146146
throw new BadRequestHttpException('GraphQL multipart request map is not valid JSON.');
147147
}
148148

@@ -192,7 +192,7 @@ private function applyMapToVariables(array $map, array $variables, array $files)
192192
*/
193193
private function decodeVariables(string $variables): array
194194
{
195-
if (!\is_array($decoded = json_decode($variables, true, 512, \JSON_THROW_ON_ERROR))) {
195+
if (!\is_array($decoded = json_decode($variables, true, 512, \JSON_ERROR_NONE))) {
196196
throw new BadRequestHttpException('GraphQL variables are not valid JSON.');
197197
}
198198

src/Symfony/Bundle/Resources/config/symfony/events.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
<argument>api_platform.action.exception</argument>
7070
<argument type="service" id="logger" on-invalid="null" />
7171
<argument>false</argument>
72-
<argument type="service" id="exception_listener" on-invalid="null" />
7372

7473
<tag name="kernel.event_listener" event="kernel.exception" method="onKernelException" priority="-96" />
7574
<tag name="monolog.logger" channel="request" />

src/Symfony/EventListener/ExceptionListener.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Psr\Log\LoggerInterface;
1818
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
1919
use Symfony\Component\HttpKernel\EventListener\ErrorListener;
20-
use Symfony\Component\HttpKernel\EventListener\ExceptionListener as LegacyExceptionListener;
2120

2221
/**
2322
* Handles requests errors.
@@ -27,11 +26,11 @@
2726
*/
2827
final class ExceptionListener
2928
{
30-
private readonly ErrorListener $exceptionListener;
29+
private readonly ErrorListener $errorListener;
3130

32-
public function __construct($controller, LoggerInterface $logger = null, $debug = false, ErrorListener $errorListener = null)
31+
public function __construct(string|object|array|null $controller, LoggerInterface $logger = null, bool $debug = false)
3332
{
34-
$this->exceptionListener = $errorListener ? new ErrorListener($controller, $logger, $debug) : new LegacyExceptionListener($controller, $logger, $debug); // @phpstan-ignore-line
33+
$this->errorListener = new ErrorListener($controller, $logger, $debug);
3534
}
3635

3736
public function onKernelException(ExceptionEvent $event): void
@@ -45,6 +44,6 @@ public function onKernelException(ExceptionEvent $event): void
4544
return;
4645
}
4746

48-
$this->exceptionListener->onKernelException($event);
47+
$this->errorListener->onKernelException($event);
4948
}
5049
}

src/Symfony/Maker/Resources/skeleton/StateProcessor.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class <?php echo $class_name; ?> implements ProcessorInterface
1010
{
11-
public function process($data, Operation $operation, array $uriVariables = [], array $context = [])
11+
public function process($data, Operation $operation, array $uriVariables = [], array $context = []): void
1212
{
1313
// Handle the state
1414
}

tests/Action/PlaceholderActionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class PlaceholderActionTest extends TestCase
2323
{
24-
public function testAction()
24+
public function testAction(): void
2525
{
2626
$action = new PlaceholderAction();
2727

tests/Api/CompositeIdentifierParserTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CompositeIdentifierParserTest extends TestCase
2121
/**
2222
* @dataProvider variousIdentifiers
2323
*/
24-
public function testNormalizeCompositeCorrectly(array $identifiers)
24+
public function testNormalizeCompositeCorrectly(array $identifiers): void
2525
{
2626
foreach ($identifiers as $string => $expected) {
2727
$this->assertEquals(CompositeIdentifierParser::parse($string), $expected);
@@ -45,10 +45,10 @@ public function variousIdentifiers(): array
4545
/**
4646
* @dataProvider compositeIdentifiers
4747
*/
48-
public function testStringify(array $identifiers)
48+
public function testStringify(array $identifiers): void
4949
{
5050
foreach ($identifiers as $string => $arr) {
51-
$this->assertEquals(CompositeIdentifierParser::stringify($arr), $string);
51+
$this->assertSame(CompositeIdentifierParser::stringify($arr), $string);
5252
}
5353
}
5454

tests/Api/IdentifiersExtractorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class IdentifiersExtractorTest extends TestCase
3333
{
3434
use ProphecyTrait;
3535

36-
public function testGetIdentifiersFromItem()
36+
public function testGetIdentifiersFromItem(): void
3737
{
3838
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
3939
$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
@@ -60,7 +60,7 @@ public function testGetIdentifiersFromItem()
6060
$this->assertEquals([], $identifiersExtractor->getIdentifiersFromItem($item, $operation->reveal()));
6161
}
6262

63-
public function testGetIdentifiersFromItemWithId()
63+
public function testGetIdentifiersFromItemWithId(): void
6464
{
6565
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
6666
$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);

tests/Api/QueryParameterValidator/QueryParameterValidatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function setUp(): void
4848
/**
4949
* unsafe method should not use filter validations.
5050
*/
51-
public function testOnKernelRequestWithUnsafeMethod()
51+
public function testOnKernelRequestWithUnsafeMethod(): void
5252
{
5353
$request = [];
5454

@@ -60,7 +60,7 @@ public function testOnKernelRequestWithUnsafeMethod()
6060
/**
6161
* If the tested filter is non-existent, then nothing should append.
6262
*/
63-
public function testOnKernelRequestWithWrongFilter()
63+
public function testOnKernelRequestWithWrongFilter(): void
6464
{
6565
$request = [];
6666

@@ -73,7 +73,7 @@ public function testOnKernelRequestWithWrongFilter()
7373
/**
7474
* if the required parameter is not set, throw an FilterValidationException.
7575
*/
76-
public function testOnKernelRequestWithRequiredFilterNotSet()
76+
public function testOnKernelRequestWithRequiredFilterNotSet(): void
7777
{
7878
$request = [];
7979

@@ -103,7 +103,7 @@ public function testOnKernelRequestWithRequiredFilterNotSet()
103103
/**
104104
* if the required parameter is set, no exception should be throwned.
105105
*/
106-
public function testOnKernelRequestWithRequiredFilter()
106+
public function testOnKernelRequestWithRequiredFilter(): void
107107
{
108108
$request = ['required' => 'foo'];
109109

0 commit comments

Comments
 (0)