Skip to content

Commit

Permalink
Applied review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Feb 26, 2025
1 parent dc56230 commit 2ecc398
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
*/
final class ClassNameResourceNameCollectionFactory implements ResourceNameCollectionFactoryInterface
{
/**
* @var array<string>
*/
/** @var array<string> */
private array $resources = [];

public function create(): ResourceNameCollection
Expand All @@ -27,7 +25,7 @@ public function create(): ResourceNameCollection
}

/**
* @param array<string> $newResources
* @param array<int, string> $newResources
*/
public function addResources(array $newResources): void
{
Expand Down
1 change: 0 additions & 1 deletion src/bundle/ApiPlatform/OpenApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ private function insertExampleFilesContent(OpenApi $openApi): void
}

$responses = $operation->getResponses();

if ($responses === null) {
continue;
}
Expand Down
5 changes: 1 addition & 4 deletions src/bundle/ApiPlatform/SchemasCollectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
*/
final class SchemasCollectionFactory implements SchemasCollectionFactoryInterface
{
/**
* @var array<SchemasProviderInterface>
*/
/** @var array<SchemasProviderInterface> */
private array $providers = [];

public function create(): SchemasCollection
{
$schemas = [];

foreach ($this->providers as $provider) {
$schemas = array_merge($schemas, $provider->getSchemas());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\Rest\DependencyInjection\Compiler;

use Ibexa\Bundle\Rest\ApiPlatform\ClassNameResourceNameCollectionFactory;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class ClassNameResourceNamePass implements CompilerPassInterface
final readonly class ClassNameResourceNamePass implements CompilerPassInterface
{
public const API_PLATFORM_RESOURCE_SERVICE_TAG = 'ibexa.api_platform.resource';
public const string API_PLATFORM_RESOURCE_SERVICE_TAG = 'ibexa.api_platform.resource';

public function process(ContainerBuilder $container): void
{
Expand All @@ -28,7 +29,7 @@ public function process(ContainerBuilder $container): void
$taggedServiceDefinition = $container->getDefinition($id);
$definition->addMethodCall(
'addResources',
[[$taggedServiceDefinition->getClass()]]
[[$taggedServiceDefinition->getClass()]],
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\Rest\DependencyInjection\Compiler;

Expand All @@ -12,9 +13,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class SchemaProviderPass implements CompilerPassInterface
final readonly class SchemaProviderPass implements CompilerPassInterface
{
public const API_PLATFORM_SCHEMA_PROVIDER_SERVICE_TAG = 'ibexa.api_platform.schemas_provider';
public const string API_PLATFORM_SCHEMA_PROVIDER_SERVICE_TAG = 'ibexa.api_platform.schemas_provider';

public function process(ContainerBuilder $container): void
{
Expand All @@ -28,7 +29,7 @@ public function process(ContainerBuilder $container): void
foreach ($taggedServiceIds as $serviceId => $attributes) {
$definition->addMethodCall(
'addProvider',
[new Reference($serviceId)]
[new Reference($serviceId)],
);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/bundle/Resources/config/api_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
index_1: '@ibexa.api_platform.ibexa_openapi.factory'

ibexa.api_platform.ibexa_openapi.factory:
class: 'Ibexa\Bundle\Rest\ApiPlatform\OpenApiFactory'
class: Ibexa\Bundle\Rest\ApiPlatform\OpenApiFactory
decorates: ibexa.api_platform.openapi.factory
arguments:
- '@.inner'
Expand All @@ -30,7 +30,6 @@ services:

Ibexa\Bundle\Rest\ApiPlatform\ClassNameResourceNameCollectionFactory: ~


# Collecting schemas

Ibexa\Bundle\Rest\ApiPlatform\SchemasCollectionFactory: ~
Expand Down
7 changes: 4 additions & 3 deletions src/lib/ApiPlatform/SchemasCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

namespace Ibexa\Rest\ApiPlatform;

final class SchemasCollection implements \IteratorAggregate, \Countable
final readonly class SchemasCollection implements \IteratorAggregate, \Countable
{
/**
* @param array<string, mixed> $schemas
*/
public function __construct(private readonly array $schemas = [])
{
public function __construct(
private array $schemas = [],
) {
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ApiPlatform/SchemasProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Yaml\Yaml;

final class SchemasProvider implements SchemasProviderInterface
final readonly class SchemasProvider implements SchemasProviderInterface
{
/**
* @param array<string> $files
*/
public function __construct(
private readonly KernelInterface $kernel,
private readonly array $files,
private KernelInterface $kernel,
private array $files,
) {
}

Expand Down

0 comments on commit 2ecc398

Please sign in to comment.