Skip to content

Commit

Permalink
Merge 3.4 (#6507)
Browse files Browse the repository at this point in the history
* tests: remove output suffix after reverting

* cs: remove unnecessary comments (#6408)

* fix(elasticsearch): change normalize return type to compatible with other normalizers (#6493)

* style: various cs fixes (#6504)

* cs: fixes

* chore: phpstan fixes

* style: cs fixes

---------

Co-authored-by: Takashi Kanemoto <[email protected]>
Co-authored-by: Koen Pasman <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent 3f48c6f commit 7e5e0aa
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/Elasticsearch/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function supportsDenormalization(mixed $data, string $type, ?string $form
/**
* {@inheritdoc}
*/
public function normalize(mixed $object, ?string $format = null, array $context = []): array
public function normalize(mixed $object, ?string $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null
{
return $this->decorated->normalize($object, $format, $context);
}
Expand Down
8 changes: 0 additions & 8 deletions src/Hydra/Tests/JsonSchema/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public function testHasRootDefinitionKeyBuildSchema(): void
$definitions = $resultSchema->getDefinitions();
$rootDefinitionKey = $resultSchema->getRootDefinitionKey();

// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]['properties']));
$properties = $resultSchema['definitions'][$rootDefinitionKey]['properties'];
$this->assertArrayHasKey('@context', $properties);
Expand Down Expand Up @@ -124,9 +122,7 @@ public function testSchemaTypeBuildSchema(): void
$definitionName = 'Dummy.jsonld';

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
// @noRector
$this->assertTrue(isset($resultSchema['properties']['hydra:member']));
$this->assertArrayHasKey('hydra:totalItems', $resultSchema['properties']);
$this->assertArrayHasKey('hydra:view', $resultSchema['properties']);
Expand All @@ -139,9 +135,7 @@ public function testSchemaTypeBuildSchema(): void
$resultSchema = $this->schemaFactory->buildSchema(Dummy::class, 'jsonld', Schema::TYPE_OUTPUT, null, null, null, true);

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
// @noRector
$this->assertTrue(isset($resultSchema['properties']['hydra:member']));
$this->assertArrayHasKey('hydra:totalItems', $resultSchema['properties']);
$this->assertArrayHasKey('hydra:view', $resultSchema['properties']);
Expand All @@ -157,9 +151,7 @@ public function testHasHydraViewNavigationBuildSchema(): void
$resultSchema = $this->schemaFactory->buildSchema(Dummy::class, 'jsonld', Schema::TYPE_OUTPUT, new GetCollection());

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
// @noRector
$this->assertTrue(isset($resultSchema['properties']['hydra:view']));
$this->assertArrayHasKey('properties', $resultSchema['properties']['hydra:view']);
$this->assertArrayHasKey('hydra:first', $resultSchema['properties']['hydra:view']['properties']);
Expand Down
4 changes: 0 additions & 4 deletions src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ public function testHasRootDefinitionKeyBuildSchema(): void
$definitions = $resultSchema->getDefinitions();
$rootDefinitionKey = $resultSchema->getRootDefinitionKey();

// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]['properties']));
$properties = $resultSchema['definitions'][$rootDefinitionKey]['properties'];
$this->assertArrayHasKey('data', $properties);
Expand Down Expand Up @@ -132,7 +130,6 @@ public function testSchemaTypeBuildSchema(): void
$definitionName = 'Dummy.jsonapi';

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
$this->assertArrayHasKey('links', $resultSchema['properties']);
$this->assertArrayHasKey('self', $resultSchema['properties']['links']['properties']);
Expand Down Expand Up @@ -160,7 +157,6 @@ public function testSchemaTypeBuildSchema(): void
$resultSchema = $this->schemaFactory->buildSchema(Dummy::class, 'jsonapi', Schema::TYPE_OUTPUT, forceCollection: true);

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
$this->assertArrayHasKey('links', $resultSchema['properties']);
$this->assertArrayHasKey('self', $resultSchema['properties']['links']['properties']);
Expand Down
1 change: 0 additions & 1 deletion src/JsonSchema/Command/JsonSchemaGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
*/
final class JsonSchemaGenerateCommand extends Command
{
// @noRector \Rector\Php81\Rector\Property\ReadOnlyPropertyRector
private array $formats;

public function __construct(private readonly SchemaFactoryInterface $schemaFactory, array $formats)
Expand Down
4 changes: 0 additions & 4 deletions src/JsonSchema/Tests/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public function testBuildSchemaForNonResourceClass(): void
$definitions = $resultSchema->getDefinitions();

$this->assertSame((new \ReflectionClass(NotAResource::class))->getShortName(), $rootDefinitionKey);
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
$this->assertArrayHasKey('type', $definitions[$rootDefinitionKey]);
$this->assertSame('object', $definitions[$rootDefinitionKey]['type']);
Expand Down Expand Up @@ -166,7 +165,6 @@ public function testBuildSchemaForNonResourceClassWithUnionIntersectTypes(): voi
$definitions = $resultSchema->getDefinitions();

$this->assertSame((new \ReflectionClass(NotAResourceWithUnionIntersectTypes::class))->getShortName(), $rootDefinitionKey);
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
$this->assertArrayHasKey('type', $definitions[$rootDefinitionKey]);
$this->assertSame('object', $definitions[$rootDefinitionKey]['type']);
Expand Down Expand Up @@ -249,7 +247,6 @@ public function testBuildSchemaWithSerializerGroups(): void
$definitions = $resultSchema->getDefinitions();

$this->assertSame((new \ReflectionClass(OverriddenOperationDummy::class))->getShortName().'-'.$serializerGroup, $rootDefinitionKey);
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
$this->assertArrayHasKey('type', $definitions[$rootDefinitionKey]);
$this->assertSame('object', $definitions[$rootDefinitionKey]['type']);
Expand Down Expand Up @@ -307,7 +304,6 @@ public function testBuildSchemaForAssociativeArray(): void
$definitions = $resultSchema->getDefinitions();

$this->assertSame((new \ReflectionClass(NotAResource::class))->getShortName(), $rootDefinitionKey);
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
$this->assertArrayHasKey('properties', $definitions[$rootDefinitionKey]);
$this->assertArrayHasKey('foo', $definitions[$rootDefinitionKey]['properties']);
Expand Down
2 changes: 0 additions & 2 deletions src/JsonSchema/Tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ public function testDefinitions(string $version, array $baseDefinitions): void
if (Schema::VERSION_OPENAPI === $version) {
$this->assertArrayHasKey('schemas', $schema['components']);
} else {
// @noRector
$this->assertTrue(isset($schema['definitions']));
}

$definitions = $schema->getDefinitions();
// @noRector
$this->assertTrue(isset($definitions['foo']));

$this->assertArrayNotHasKey('definitions', $schema->getArrayCopy(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class: AttributeResource::class,
priority: 4,
status: 301,
provider: AttributeResourceProvider::class,
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
processor: [AttributeResourceProcessor::class, 'process']
),
'_api_/dummy/{dummyId}/attribute_resources/{identifier}{._format}_patch' => new Patch(
Expand All @@ -106,14 +105,12 @@ class: AttributeResource::class,
priority: 5,
status: 301,
provider: AttributeResourceProvider::class,
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
processor: [AttributeResourceProcessor::class, 'process']
),
],
inputFormats: ['json' => ['application/merge-patch+json']],
status: 301,
provider: AttributeResourceProvider::class,
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
processor: [AttributeResourceProcessor::class, 'process']
),
]),
Expand Down
1 change: 0 additions & 1 deletion src/Serializer/AbstractCollectionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ abstract class AbstractCollectionNormalizer implements NormalizerInterface, Norm
/**
* This constant must be overridden in the child class.
*/
// @noRector \Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector
public const FORMAT = 'to-override';

public function __construct(protected ResourceClassResolverInterface $resourceClassResolver, protected string $pageParameterName, protected ?ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory = null)
Expand Down
1 change: 0 additions & 1 deletion src/Serializer/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
final class JsonEncoder implements EncoderInterface, DecoderInterface
{
// @noRector \Rector\Php81\Rector\Property\ReadOnlyPropertyRector
public function __construct(private readonly string $format, private ?BaseJsonEncoder $jsonEncoder = null)
{
if (null !== $this->jsonEncoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ public function process(ContainerBuilder $container): void
$clientDefinition = $container->getDefinition('api_platform.elasticsearch.client');

if (!$clientConfiguration) {
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
$clientDefinition->setFactory([$builderName, 'build']);
} else {
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
$clientDefinition->setFactory([$builderName, 'fromConfig']);
$clientDefinition->setArguments([$clientConfiguration]);
}
Expand Down
7 changes: 2 additions & 5 deletions tests/Behat/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,8 @@
*/
final class DoctrineContext implements Context
{
// @noRector \Rector\Php81\Rector\Property\ReadOnlyPropertyRector
private ObjectManager $manager;
// @noRector \Rector\Php81\Rector\Property\ReadOnlyPropertyRector
private ?SchemaTool $schemaTool;
// @noRector \Rector\Php81\Rector\Property\ReadOnlyPropertyRector
private ?SchemaManager $schemaManager;

/**
Expand Down Expand Up @@ -1470,7 +1467,7 @@ public function thereArePrograms(int $nb): void
->count()->getQuery()->execute();
}

for ($i = $count + 1; $i <= $nb; ++$i) {
for ($i = (int) $count + 1; $i <= $nb; ++$i) {
$program = $this->isOrm() ? new Program() : new ProgramDocument();
$program->name = "Lorem ipsum $i";
$program->date = new \DateTimeImmutable(\sprintf('2015-03-0%dT10:00:00+00:00', $i));
Expand Down Expand Up @@ -1518,7 +1515,7 @@ public function thereAreComments(int $nb): void
->count()->getQuery()->execute();
}

for ($i = $count + 1; $i <= $nb; ++$i) {
for ($i = (int) $count + 1; $i <= $nb; ++$i) {
$comment = $this->isOrm() ? new Comment() : new CommentDocument();
$comment->comment = "Lorem ipsum dolor sit amet $i";
$comment->date = new \DateTimeImmutable(\sprintf('2015-03-0%dT10:00:00+00:00', $i));
Expand Down
1 change: 0 additions & 1 deletion tests/Fixtures/TestBundle/Entity/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Content implements \JsonSerializable
#[ORM\OrderBy(['id' => 'ASC'])]
private Collection|iterable $fields;
#[ORM\Column(type: 'string')]
// @noRector \Rector\Php81\Rector\Property\ReadOnlyPropertyRector
private string $status = ContentStatus::DRAFT;

public function __construct()
Expand Down
4 changes: 0 additions & 4 deletions tests/Hal/JsonSchema/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public function testHasRootDefinitionKeyBuildSchema(): void
$definitions = $resultSchema->getDefinitions();
$rootDefinitionKey = $resultSchema->getRootDefinitionKey();

// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]));
// @noRector
$this->assertTrue(isset($definitions[$rootDefinitionKey]['properties']));
$properties = $resultSchema['definitions'][$rootDefinitionKey]['properties'];
$this->assertArrayHasKey('_links', $properties);
Expand Down Expand Up @@ -117,7 +115,6 @@ public function testSchemaTypeBuildSchema(): void
$definitionName = 'Dummy.jsonhal';

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
$this->assertArrayHasKey('_embedded', $resultSchema['properties']);
$this->assertArrayHasKey('totalItems', $resultSchema['properties']);
Expand All @@ -129,7 +126,6 @@ public function testSchemaTypeBuildSchema(): void
$resultSchema = $this->schemaFactory->buildSchema(Dummy::class, 'jsonhal', Schema::TYPE_OUTPUT, null, null, null, true);

$this->assertNull($resultSchema->getRootDefinitionKey());
// @noRector
$this->assertTrue(isset($resultSchema['properties']));
$this->assertArrayHasKey('_embedded', $resultSchema['properties']);
$this->assertArrayHasKey('totalItems', $resultSchema['properties']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function testProcess(): void
}

$clientDefinitionProphecy = $this->prophesize(Definition::class);
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
$clientDefinitionProphecy->setFactory([$clientBuilder, 'fromConfig'])->willReturn($clientDefinitionProphecy->reveal())->shouldBeCalled();
$clientDefinitionProphecy->setArguments(
Argument::allOf(
Expand All @@ -79,7 +78,6 @@ public function testProcessWithoutConfiguration(): void
$clientBuilder = class_exists(\Elasticsearch\ClientBuilder::class) ? \Elasticsearch\ClientBuilder::class : \Elastic\Elasticsearch\ClientBuilder::class;

$clientDefinitionProphecy = $this->prophesize(Definition::class);
// @noRector \Rector\Php81\Rector\Array_\FirstClassCallableRector
$clientDefinitionProphecy->setFactory([$clientBuilder, 'build'])->willReturn($clientDefinitionProphecy->reveal())->shouldBeCalled();

$containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);
Expand Down

0 comments on commit 7e5e0aa

Please sign in to comment.