Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
UPGRADE FROM 2.0-BETA10 to 2.0-BETA13
=====================================

### Core

* The `Rollerworks\Component\Search\Extension\Core\DataTransformer\IntegerToStringTransformer`
deprecated usage of accepting a `null` value for `$roundingMode`, use `IntegerToStringTransformer::ROUND_DOWN` instead.

* The `Rollerworks\Component\Search\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer`
deprecated usage of accepting a `null` value for `$grouping` and `$roundingMode`
use `NumberToLocalizedStringTransformer::ROUND_DOWN` for `$roundingMode` and `false` for `$grouping` instead.

UPGRADE FROM 2.0-BETA9 to 2.0-BETA10
===================================
====================================

### Api-Platform

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
],
"homepage": "https://rollerworks.github.io/",
"require": {
"php": ">=8.1",
"php": "^8.1",
"nesbot/carbon": "^2.38 || ^3.0",
"psr/container": "^1.1 || ^2.0",
"symfony/intl": "^6.4 || ^7.4 || ^8.0",
"symfony/options-resolver": "^6.4 || ^7.4 || ^8.0",
"symfony/property-access": "^6.4 || ^7.4 || ^8.0",
"symfony/string": "^6.4 || ^7.4 || ^8.0",
"symfony/translation-contracts": "^3.4"
"symfony/translation-contracts": "^3.4",
"symfony/polyfill-php84": "^1.33"
},
"require-dev": {
"api-platform/core": "^4.2",
Expand Down
11 changes: 4 additions & 7 deletions lib/ApiPlatform/Doctrine/Orm/Extension/SearchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@
*/
final class SearchExtension implements QueryCollectionExtensionInterface
{
private RequestStack $requestStack;
private DoctrineOrmFactory $ormFactory;

public function __construct(RequestStack $requestStack, DoctrineOrmFactory $ormFactory)
{
$this->requestStack = $requestStack;
$this->ormFactory = $ormFactory;
public function __construct(
private readonly RequestStack $requestStack,
private readonly DoctrineOrmFactory $ormFactory,
) {
}

public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
Expand Down
25 changes: 11 additions & 14 deletions lib/ApiPlatform/Elasticsearch/Extension/SearchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@
*/
class SearchExtension implements QueryCollectionExtensionInterface
{
private $requestStack;
private $registry;
private $elasticsearchFactory;
private $client;
private $identifierNames = [];

public function __construct(RequestStack $requestStack, ManagerRegistry $registry, ElasticsearchFactory $elasticsearchFactory, Client $client)
{
$this->requestStack = $requestStack;
$this->registry = $registry;
$this->elasticsearchFactory = $elasticsearchFactory;
$this->client = $client;
/** @var array<string, string[]> */
private array $identifierNames = [];

public function __construct(
private readonly RequestStack $requestStack,
private readonly ManagerRegistry $registry,
private readonly ElasticsearchFactory $elasticsearchFactory,
private readonly Client $client,
) {
}

public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
Expand Down Expand Up @@ -132,9 +129,9 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator

// NOTE: written like this so we only check if we have a normalizer once
if ($normalizer !== null) {
$callable = static fn (Document $document) => \call_user_func($normalizer, $document->getId());
$callable = static fn (Document $document) => $normalizer($document->getId());
} else {
$callable = static fn (Document $document) => $document->getId();
$callable = static fn (Document $document): ?string => $document->getId();
}
$ids = array_map($callable, $response->getDocuments());

Expand Down
20 changes: 7 additions & 13 deletions lib/ApiPlatform/EventListener/SearchConditionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,13 @@
*/
final class SearchConditionListener
{
private $searchFactory;
private $inputProcessorLoader;
private ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory;
private $eventDispatcher;
private $cache;

public function __construct(SearchFactory $searchFactory, InputProcessorLoader $inputProcessorLoader, ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, EventDispatcherInterface $eventDispatcher, ?CacheInterface $cache = null)
{
$this->searchFactory = $searchFactory;
$this->inputProcessorLoader = $inputProcessorLoader;
$this->resourceMetadataCollectionFactory = $resourceMetadataFactory;
$this->eventDispatcher = $eventDispatcher;
$this->cache = $cache;
public function __construct(
private readonly SearchFactory $searchFactory,
private readonly InputProcessorLoader $inputProcessorLoader,
private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ?CacheInterface $cache = null,
) {
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/ApiPlatform/Exception/InvalidConditionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class InvalidConditionException extends RuntimeException implements ProblemExcep
private int $status = 422;

/** @var ConditionErrorMessage[] */
private array $errors;
private readonly array $errors;

#[Groups(['jsonld', 'json', 'jsonapi'])]
#[ApiProperty(writable: false, initializable: false)]
private string $detail;
private readonly string $detail;

public function __construct(ErrorList $error, int $code = 0, ?\Throwable $previous = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
*/
final class DefaultConfigurationMetadataFactory implements ResourceMetadataCollectionFactoryInterface
{
public function __construct(private readonly ResourceMetadataCollectionFactoryInterface $decorated)
{
public function __construct(
private readonly ResourceMetadataCollectionFactoryInterface $decorated,
) {
}

public function create(string $resourceClass): ResourceMetadataCollection
Expand Down
14 changes: 5 additions & 9 deletions lib/ApiPlatform/SearchConditionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ final class SearchConditionEvent extends Event
*/
public const SEARCH_CONDITION_EVENT = 'rollerworks_search.process.primary_condition';

private $searchCondition;
private $resourceClass;
private $request;

public function __construct(?SearchCondition $searchCondition, string $resourceClass, Request $request)
{
$this->searchCondition = $searchCondition;
$this->resourceClass = $resourceClass;
$this->request = $request;
public function __construct(
private readonly ?SearchCondition $searchCondition,
private readonly string $resourceClass,
private readonly Request $request,
) {
}

public function getSearchCondition(): ?SearchCondition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function normalize(mixed $data, ?string $format = null, array $context =

public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return ($format === 'json' || $format === 'jsonproblem' || $format === 'jsonld') && $data instanceof ConditionErrorMessage;
return \in_array($format, ['json', 'jsonproblem', 'jsonld'], true) && $data instanceof ConditionErrorMessage;
}

public function getSupportedTypes(?string $format): array
{
if ($format === 'json' || $format === 'jsonproblem' || $format === 'jsonld') {
if (\in_array($format, ['json', 'jsonproblem', 'jsonld'], true)) {
return [
ConditionErrorMessage::class => true,
];
Expand Down
14 changes: 7 additions & 7 deletions lib/ApiPlatform/Serializer/InvalidSearchConditionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
*/
final class InvalidSearchConditionNormalizer implements NormalizerInterface
{
private $serializePayloadFields;
private $nameConverter;

public function __construct(?array $serializePayloadFields = null, ?NameConverterInterface $nameConverter = null)
{
$this->nameConverter = $nameConverter;
$this->serializePayloadFields = $serializePayloadFields;
/**
* @param string[]|null $serializePayloadFields
*/
public function __construct(
private readonly ?array $serializePayloadFields = null,
private readonly ?NameConverterInterface $nameConverter = null,
) {
}

/**
Expand Down Expand Up @@ -97,7 +97,7 @@

if ($this->serializePayloadFields && $constraint && $constraint->payload) {
// If some fields are whitelisted, only them are added
$payloadFields = $this->serializePayloadFields === null ? $constraint->payload : array_intersect_key($constraint->payload, array_flip($this->serializePayloadFields));

Check failure on line 100 in lib/ApiPlatform/Serializer/InvalidSearchConditionNormalizer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Strict comparison using === between non-empty-array and null will always evaluate to false.
$payloadFields && $violationData['payload'] = $payloadFields;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ApiPlatform\Doctrine\Orm\Util\QueryNameGenerator;
use ApiPlatform\Metadata\Get;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Func;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\Mapping\ClassMetadata;
Expand Down Expand Up @@ -51,7 +52,7 @@ public function apply_to_collection_with_valid_condition(): void
$elasticaResponse = $this->createResponse($ids);
$searchCondition = $this->createCondition();

$queryFunctionProphecy = $this->prophesize(Expr\Func::class);
$queryFunctionProphecy = $this->prophesize(Func::class);
$queryFunction = $queryFunctionProphecy->reveal();

$queryExpressionProphecy = $this->prophesize(Expr::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ private function createProcessorLoader(InputProcessor $inputProcessor, string $n
return new InputProcessorLoader(
new ClosureContainer(
[
$name => static fn () => $inputProcessor,
$name => static fn (): InputProcessor => $inputProcessor,
]
),
[$name => $name]
Expand Down
Loading
Loading