Skip to content

Commit a5f35d3

Browse files
committed
Merge branch '2.5'
* 2.5: docs: better formatting in changelog Prepare release 2.5.10 (#3970) fix: only display hydra:next when the item total is strictly greater than the number of items per page (#3967)
2 parents 5000965 + 1a81156 commit a5f35d3

File tree

101 files changed

+163
-159
lines changed

Some content is hidden

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

101 files changed

+163
-159
lines changed

.php_cs.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ $finder = PhpCsFixer\Finder::create()
1717
'tests/Fixtures/app/var',
1818
])
1919
->notPath('src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php')
20+
->notPath('src/Annotation/ApiFilter.php') // temporary
21+
->notPath('src/Annotation/ApiProperty.php') // temporary
22+
->notPath('src/Annotation/ApiResource.php') // temporary
23+
->notPath('src/Annotation/ApiSubresource.php') // temporary
2024
->notPath('tests/Fixtures/TestBundle/Entity/DummyPhp8.php') // temporary
2125
->append([
2226
'tests/Fixtures/app/console',

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
* Validator: Query filters and parameters are validated (#1723)
6060
* `ExceptionInterface` now extends `\Throwable` (#3217)
6161

62+
## 2.5.10
63+
64+
* Hydra: only display `hydra:next` when the item total is strictly greater than the number of items per page (#3967)
65+
6266
## 2.5.9
6367

6468
* Fix a warning when preloading the `AbstractPaginator` class (#3827)

src/Annotation/ApiFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @Annotation
2525
* @Target({"PROPERTY", "CLASS"})
2626
*/
27-
#[\Attribute(\Attribute::TARGET_PROPERTY|\Attribute::TARGET_CLASS|\Attribute::IS_REPEATABLE)]
27+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
2828
final class ApiFilter
2929
{
3030
/**

src/Annotation/ApiProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @Attribute("swaggerContext", type="array")
3434
* )
3535
*/
36-
#[\Attribute(\Attribute::TARGET_PROPERTY|\Attribute::TARGET_METHOD|\Attribute::TARGET_PARAMETER)]
36+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_PARAMETER)]
3737
final class ApiProperty
3838
{
3939
use AttributesHydratorTrait;

src/Annotation/ApiSubresource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @Annotation
2222
* @Target({"METHOD", "PROPERTY"})
2323
*/
24-
#[\Attribute(\Attribute::TARGET_PROPERTY|\Attribute::TARGET_METHOD)]
24+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD)]
2525
final class ApiSubresource
2626
{
2727
/**

src/Annotation/AttributesHydratorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function hydrateAttributes(array $values): void
7272
foreach (self::$deprecatedAttributes as $deprecatedAttribute => $options) {
7373
if (\array_key_exists($deprecatedAttribute, $values)) {
7474
$values[$options[0]] = $values[$deprecatedAttribute];
75-
@trigger_error(sprintf('Attribute "%s" is deprecated in annotation since API Platform %s, prefer using "%s" attribute instead', $deprecatedAttribute, $options[1], $options[0]), E_USER_DEPRECATED);
75+
@trigger_error(sprintf('Attribute "%s" is deprecated in annotation since API Platform %s, prefer using "%s" attribute instead', $deprecatedAttribute, $options[1], $options[0]), \E_USER_DEPRECATED);
7676
unset($values[$deprecatedAttribute]);
7777
}
7878
}

src/Api/CachedIdentifiersExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(CacheItemPoolInterface $cacheItemPool, IdentifiersEx
4444
$this->resourceClassResolver = $resourceClassResolver;
4545

4646
if (null === $this->resourceClassResolver) {
47-
@trigger_error(sprintf('Not injecting %s in the CachedIdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), E_USER_DEPRECATED);
47+
@trigger_error(sprintf('Not injecting %s in the CachedIdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), \E_USER_DEPRECATED);
4848
}
4949
}
5050

src/Api/FilterCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class FilterCollection extends \ArrayObject
2626
{
2727
public function __construct($input = [], $flags = 0, $iterator_class = 'ArrayIterator')
2828
{
29-
@trigger_error(sprintf('The %s class is deprecated since version 2.1 and will be removed in 3.0. Provide an implementation of %s instead.', self::class, ContainerInterface::class), E_USER_DEPRECATED);
29+
@trigger_error(sprintf('The %s class is deprecated since version 2.1 and will be removed in 3.0. Provide an implementation of %s instead.', self::class, ContainerInterface::class), \E_USER_DEPRECATED);
3030

3131
parent::__construct($input, $flags, $iterator_class);
3232
}

src/Api/FilterLocatorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private function setFilterLocator($filterLocator, bool $allowNull = false): void
3636
{
3737
if ($filterLocator instanceof ContainerInterface || $filterLocator instanceof FilterCollection || (null === $filterLocator && $allowNull)) {
3838
if ($filterLocator instanceof FilterCollection) {
39-
@trigger_error(sprintf('The %s class is deprecated since version 2.1 and will be removed in 3.0. Provide an implementation of %s instead.', FilterCollection::class, ContainerInterface::class), E_USER_DEPRECATED);
39+
@trigger_error(sprintf('The %s class is deprecated since version 2.1 and will be removed in 3.0. Provide an implementation of %s instead.', FilterCollection::class, ContainerInterface::class), \E_USER_DEPRECATED);
4040
}
4141

4242
$this->filterLocator = $filterLocator;

src/Api/FormatsProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class FormatsProvider implements FormatsProviderInterface, OperationAwareF
3030

3131
public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, array $configuredFormats)
3232
{
33-
@trigger_error(sprintf('The "%s" class is deprecated since API Platform 2.5, use the "formats" attribute instead.', __CLASS__), E_USER_DEPRECATED);
33+
@trigger_error(sprintf('The "%s" class is deprecated since API Platform 2.5, use the "formats" attribute instead.', __CLASS__), \E_USER_DEPRECATED);
3434

3535
$this->resourceMetadataFactory = $resourceMetadataFactory;
3636
$this->configuredFormats = $configuredFormats;

src/Api/IdentifiersExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName
4141
$this->resourceClassResolver = $resourceClassResolver;
4242

4343
if (null === $this->resourceClassResolver) {
44-
@trigger_error(sprintf('Not injecting %s in the IdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), E_USER_DEPRECATED);
44+
@trigger_error(sprintf('Not injecting %s in the IdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), \E_USER_DEPRECATED);
4545
}
4646
}
4747

src/Api/OperationTypeDeprecationHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class OperationTypeDeprecationHelper
3434
public static function getOperationType($operationType): string
3535
{
3636
if (\is_bool($operationType)) {
37-
@trigger_error('Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3', E_USER_DEPRECATED);
37+
@trigger_error('Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3', \E_USER_DEPRECATED);
3838

3939
$operationType = $operationType ? OperationType::COLLECTION : OperationType::ITEM;
4040
}

src/Bridge/Doctrine/Common/Filter/ExistsFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function normalizeValue($value, string $property): ?bool
7575
if (\is_array($value) && isset($value[self::QUERY_PARAMETER_KEY])) {
7676
@trigger_error(
7777
sprintf('The ExistsFilter syntax "%s[exists]=true/false" is deprecated since 2.5. Use the syntax "%s[%s]=true/false" instead.', $property, $this->existsParameterName, $property),
78-
E_USER_DEPRECATED
78+
\E_USER_DEPRECATED
7979
);
8080
$value = $value[self::QUERY_PARAMETER_KEY];
8181
}

src/Bridge/Doctrine/Common/Filter/SearchFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected function normalizeValues(array $values, string $property): ?array
160160
protected function hasValidValues(array $values, $type = null): bool
161161
{
162162
foreach ($values as $key => $value) {
163-
if (\in_array($type, (array) self::DOCTRINE_INTEGER_TYPE, true) && null !== $value && false === filter_var($value, FILTER_VALIDATE_INT)) {
163+
if (null !== $value && \in_array($type, (array) self::DOCTRINE_INTEGER_TYPE, true) && false === filter_var($value, \FILTER_VALIDATE_INT)) {
164164
return false;
165165
}
166166
}

src/Bridge/Doctrine/Common/PropertyHelperTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function isPropertyNested(string $property/*, string $resourceClass*/)
5555
if (__CLASS__ !== static::class) {
5656
$r = new \ReflectionMethod($this, __FUNCTION__);
5757
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
58-
@trigger_error(sprintf('Method %s() will have a second `$resourceClass` argument in version API Platform 3.0. Not defining it is deprecated since API Platform 2.1.', __FUNCTION__), E_USER_DEPRECATED);
58+
@trigger_error(sprintf('Method %s() will have a second `$resourceClass` argument in version API Platform 3.0. Not defining it is deprecated since API Platform 2.1.', __FUNCTION__), \E_USER_DEPRECATED);
5959
}
6060
}
6161
$resourceClass = null;
@@ -94,7 +94,7 @@ protected function splitPropertyParts(string $property/*, string $resourceClass*
9494
} elseif (__CLASS__ !== static::class) {
9595
$r = new \ReflectionMethod($this, __FUNCTION__);
9696
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
97-
@trigger_error(sprintf('Method %s() will have a second `$resourceClass` argument in version API Platform 3.0. Not defining it is deprecated since API Platform 2.1.', __FUNCTION__), E_USER_DEPRECATED);
97+
@trigger_error(sprintf('Method %s() will have a second `$resourceClass` argument in version API Platform 3.0. Not defining it is deprecated since API Platform 2.1.', __FUNCTION__), \E_USER_DEPRECATED);
9898
}
9999
}
100100

src/Bridge/Doctrine/EventListener/PublishMercureUpdatesListener.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
*/
4242
final class PublishMercureUpdatesListener
4343
{
44+
use DispatchTrait;
45+
use ResourceClassInfoTrait;
4446
private const ALLOWED_KEYS = [
4547
'topics' => true,
4648
'data' => true,
@@ -51,9 +53,6 @@ final class PublishMercureUpdatesListener
5153
'normalization_context' => true,
5254
];
5355

54-
use DispatchTrait;
55-
use ResourceClassInfoTrait;
56-
5756
private $iriConverter;
5857
private $serializer;
5958
private $publisher;
@@ -182,7 +181,7 @@ private function storeObjectToPublish($object, string $property): void
182181
throw new \InvalidArgumentException('Targets do not exist anymore since Mercure 0.10. Mark the update as private instead or downgrade the Mercure Component to version 0.3');
183182
}
184183

185-
@trigger_error('Targets do not exist anymore since Mercure 0.10. Mark the update as private instead.', E_USER_DEPRECATED);
184+
@trigger_error('Targets do not exist anymore since Mercure 0.10. Mark the update as private instead.', \E_USER_DEPRECATED);
186185
break;
187186
}
188187

src/Bridge/Doctrine/EventListener/WriteListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class WriteListener
3131

3232
public function __construct(ManagerRegistry $managerRegistry)
3333
{
34-
@trigger_error(sprintf('The %s class is deprecated since version 2.2 and will be removed in 3.0. Use the %s class instead.', __CLASS__, BaseWriteListener::class), E_USER_DEPRECATED);
34+
@trigger_error(sprintf('The %s class is deprecated since version 2.2 and will be removed in 3.0. Use the %s class instead.', __CLASS__, BaseWriteListener::class), \E_USER_DEPRECATED);
3535

3636
$this->managerRegistry = $managerRegistry;
3737
}

src/Bridge/Doctrine/MongoDbOdm/SubresourceDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function buildAggregation(array $identifiers, array $context, array $exe
127127
$identifierResourceClass = $context['identifiers'][$identifier][0];
128128
$previousAssociationProperty = $contextIdentifiers[$remainingIdentifiers] ?? $context['property'];
129129
} else {
130-
@trigger_error('Identifiers should match the convention introduced in ADR 0001-resource-identifiers, this behavior will be removed in 3.0.', E_USER_DEPRECATED);
130+
@trigger_error('Identifiers should match the convention introduced in ADR 0001-resource-identifiers, this behavior will be removed in 3.0.', \E_USER_DEPRECATED);
131131
[$identifier, $identifierResourceClass] = $context['identifiers'][$remainingIdentifiers - 1];
132132
$previousAssociationProperty = $context['identifiers'][$remainingIdentifiers][0] ?? $context['property'];
133133
}

src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ final class EagerLoadingExtension implements ContextAwareQueryCollectionExtensio
5555
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, int $maxJoins = 30, bool $forceEager = true, RequestStack $requestStack = null, SerializerContextBuilderInterface $serializerContextBuilder = null, bool $fetchPartial = false, ClassMetadataFactoryInterface $classMetadataFactory = null)
5656
{
5757
if (null !== $this->requestStack) {
58-
@trigger_error(sprintf('Passing an instance of "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the data provider\'s context instead.', RequestStack::class), E_USER_DEPRECATED);
58+
@trigger_error(sprintf('Passing an instance of "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the data provider\'s context instead.', RequestStack::class), \E_USER_DEPRECATED);
5959
}
6060
if (null !== $this->serializerContextBuilder) {
61-
@trigger_error(sprintf('Passing an instance of "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the data provider\'s context instead.', SerializerContextBuilderInterface::class), E_USER_DEPRECATED);
61+
@trigger_error(sprintf('Passing an instance of "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the data provider\'s context instead.', SerializerContextBuilderInterface::class), \E_USER_DEPRECATED);
6262
}
6363

6464
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
@@ -178,7 +178,7 @@ private function joinRelations(QueryBuilder $queryBuilder, QueryNameGeneratorInt
178178
(null === $fetchEager = $propertyMetadata->getAttribute('fetch_eager')) &&
179179
(null !== $fetchEager = $propertyMetadata->getAttribute('fetchEager'))
180180
) {
181-
@trigger_error('The "fetchEager" attribute is deprecated since 2.3. Please use "fetch_eager" instead.', E_USER_DEPRECATED);
181+
@trigger_error('The "fetchEager" attribute is deprecated since 2.3. Please use "fetch_eager" instead.', \E_USER_DEPRECATED);
182182
}
183183

184184
if (false === $fetchEager) {

src/Bridge/Doctrine/Orm/Extension/PaginationExtension.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ final class PaginationExtension implements ContextAwareQueryResultCollectionExte
6868
public function __construct(ManagerRegistry $managerRegistry, /* ResourceMetadataFactoryInterface */ $resourceMetadataFactory, /* Pagination */ $pagination)
6969
{
7070
if ($resourceMetadataFactory instanceof RequestStack && $pagination instanceof ResourceMetadataFactoryInterface) {
71-
@trigger_error(sprintf('Passing an instance of "%s" as second argument of "%s" is deprecated since API Platform 2.4 and will not be possible anymore in API Platform 3. Pass an instance of "%s" instead.', RequestStack::class, self::class, ResourceMetadataFactoryInterface::class), E_USER_DEPRECATED);
72-
@trigger_error(sprintf('Passing an instance of "%s" as third argument of "%s" is deprecated since API Platform 2.4 and will not be possible anymore in API Platform 3. Pass an instance of "%s" instead.', ResourceMetadataFactoryInterface::class, self::class, Pagination::class), E_USER_DEPRECATED);
71+
@trigger_error(sprintf('Passing an instance of "%s" as second argument of "%s" is deprecated since API Platform 2.4 and will not be possible anymore in API Platform 3. Pass an instance of "%s" instead.', RequestStack::class, self::class, ResourceMetadataFactoryInterface::class), \E_USER_DEPRECATED);
72+
@trigger_error(sprintf('Passing an instance of "%s" as third argument of "%s" is deprecated since API Platform 2.4 and will not be possible anymore in API Platform 3. Pass an instance of "%s" instead.', ResourceMetadataFactoryInterface::class, self::class, Pagination::class), \E_USER_DEPRECATED);
7373

7474
$this->requestStack = $resourceMetadataFactory;
7575
$resourceMetadataFactory = $pagination;
@@ -92,7 +92,7 @@ public function __construct(ManagerRegistry $managerRegistry, /* ResourceMetadat
9292

9393
foreach ($legacyPaginationArgs as $pos => $arg) {
9494
if (\array_key_exists($pos, $args)) {
95-
@trigger_error(sprintf('Passing "$%s" arguments is deprecated since API Platform 2.4 and will not be possible anymore in API Platform 3. Pass an instance of "%s" as third argument instead.', implode('", "$', array_column($legacyPaginationArgs, 'arg_name')), Paginator::class), E_USER_DEPRECATED);
95+
@trigger_error(sprintf('Passing "$%s" arguments is deprecated since API Platform 2.4 and will not be possible anymore in API Platform 3. Pass an instance of "%s" as third argument instead.', implode('", "$', array_column($legacyPaginationArgs, 'arg_name')), Paginator::class), \E_USER_DEPRECATED);
9696

9797
if (!((null === $arg['default'] && null === $args[$pos]) || \call_user_func("is_{$arg['type']}", $args[$pos]))) {
9898
throw new InvalidArgumentException(sprintf('The "$%s" argument is expected to be a %s%s.', $arg['arg_name'], $arg['type'], null === $arg['default'] ? ' or null' : ''));
@@ -224,7 +224,7 @@ private function getPagination(QueryBuilder $queryBuilder, string $resourceClass
224224
$maxItemsPerPage = $resourceMetadata->getCollectionOperationAttribute($operationName, 'maximum_items_per_page', null, true);
225225

226226
if (null !== $maxItemsPerPage) {
227-
@trigger_error('The "maximum_items_per_page" option has been deprecated since API Platform 2.5 in favor of "pagination_maximum_items_per_page" and will be removed in API Platform 3.', E_USER_DEPRECATED);
227+
@trigger_error('The "maximum_items_per_page" option has been deprecated since API Platform 2.5 in favor of "pagination_maximum_items_per_page" and will be removed in API Platform 3.', \E_USER_DEPRECATED);
228228
}
229229

230230
$maxItemsPerPage = $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_maximum_items_per_page', $maxItemsPerPage ?? $this->maximumItemPerPage, true);
@@ -274,7 +274,7 @@ private function isPartialPaginationEnabled(Request $request = null, ResourceMet
274274
}
275275

276276
if ($clientEnabled && $request) {
277-
$enabled = filter_var($this->getPaginationParameter($request, $this->partialParameterName, $enabled), FILTER_VALIDATE_BOOLEAN);
277+
$enabled = filter_var($this->getPaginationParameter($request, $this->partialParameterName, $enabled), \FILTER_VALIDATE_BOOLEAN);
278278
}
279279

280280
return $enabled;
@@ -286,7 +286,7 @@ private function isPaginationEnabled(Request $request, ResourceMetadata $resourc
286286
$clientEnabled = $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_client_enabled', $this->clientEnabled, true);
287287

288288
if ($clientEnabled) {
289-
$enabled = filter_var($this->getPaginationParameter($request, $this->enabledParameterName, $enabled), FILTER_VALIDATE_BOOLEAN);
289+
$enabled = filter_var($this->getPaginationParameter($request, $this->enabledParameterName, $enabled), \FILTER_VALIDATE_BOOLEAN);
290290
}
291291

292292
return $enabled;

0 commit comments

Comments
 (0)