Skip to content

Commit 35edfb6

Browse files
authored
Merge pull request #1582 from soyuka/merge-2.1
Merge 2.1
2 parents 0ed9a02 + 98c0db7 commit 35edfb6

File tree

61 files changed

+153
-144
lines changed

Some content is hidden

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

61 files changed

+153
-144
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"behat/symfony2-extension": "^2.1.1",
3434
"behatch/contexts": "dev-master",
3535
"doctrine/doctrine-bundle": "^1.6.3",
36-
"doctrine/orm": "^2.5.2",
36+
"doctrine/orm": ">=2.5.2 <2.6",
3737
"doctrine/annotations": "^1.2",
3838
"friendsofsymfony/user-bundle": "^2.0",
3939
"guzzlehttp/guzzle": "^6.0",

features/bootstrap/FeatureContext.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,6 @@ public function createPeopleWithPets()
800800
*/
801801
public function thereIsDummyDateObjectsWithDummyDate(int $nb)
802802
{
803-
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
804-
805803
for ($i = 1; $i <= $nb; ++$i) {
806804
$date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC'));
807805

features/bootstrap/SwaggerContext.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,13 @@
1717
use Behatch\Context\RestContext;
1818
use PHPUnit\Framework\Assert;
1919
use PHPUnit\Framework\ExpectationFailedException;
20-
use Symfony\Component\PropertyAccess\PropertyAccess;
2120

2221
final class SwaggerContext implements Context
2322
{
2423
/**
2524
* @var RestContext
2625
*/
2726
private $restContext;
28-
private $propertyAccessor;
29-
30-
public function __construct()
31-
{
32-
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
33-
}
3427

3528
/**
3629
* Gives access to the Behatch context.

src/Api/CachedIdentifiersExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getIdentifiersFromItem($item): array
7272
foreach ($keys as $propertyName) {
7373
$identifiers[$propertyName] = $this->propertyAccessor->getValue($item, $propertyName);
7474

75-
if (!is_object($identifiers[$propertyName])) {
75+
if (!\is_object($identifiers[$propertyName])) {
7676
continue;
7777
}
7878

src/Api/FilterLocatorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait FilterLocatorTrait
3535
*/
3636
private function setFilterLocator($filterLocator = null, bool $allowNull = false)
3737
{
38-
if ($filterLocator instanceof ContainerInterface || $filterLocator instanceof FilterCollection || null === $filterLocator && $allowNull) {
38+
if ($filterLocator instanceof ContainerInterface || $filterLocator instanceof FilterCollection || (null === $filterLocator && $allowNull)) {
3939
if ($filterLocator instanceof FilterCollection) {
4040
@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);
4141
}

src/Api/IdentifiersExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getIdentifiersFromItem($item): array
6969
continue;
7070
}
7171
$identifier = $identifiers[$propertyName] = $this->propertyAccessor->getValue($item, $propertyName);
72-
if (!is_object($identifier)) {
72+
if (!\is_object($identifier)) {
7373
continue;
7474
} elseif (method_exists($identifier, '__toString')) {
7575
$identifiers[$propertyName] = (string) $identifier;

src/Api/OperationTypeDeprecationHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class OperationTypeDeprecationHelper
3535
*/
3636
public static function getOperationType($operationType): string
3737
{
38-
if (is_bool($operationType)) {
38+
if (\is_bool($operationType)) {
3939
@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);
4040

4141
$operationType = $operationType ? OperationType::COLLECTION : OperationType::ITEM;

src/Api/ResourceClassResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(ResourceNameCollectionFactoryInterface $resourceName
3939
*/
4040
public function getResourceClass($value, string $resourceClass = null, bool $strict = false): string
4141
{
42-
if (is_object($value) && !$value instanceof \Traversable) {
42+
if (\is_object($value) && !$value instanceof \Traversable) {
4343
$typeToFind = $type = $this->getObjectClass($value);
4444
if (null === $resourceClass) {
4545
$resourceClass = $typeToFind;

src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function addTagsFor($value)
133133
return;
134134
}
135135

136-
if (!is_array($value) && !$value instanceof \Traversable) {
136+
if (!\is_array($value) && !$value instanceof \Traversable) {
137137
$this->addTagForItem($value);
138138

139139
return;

src/Bridge/Doctrine/EventListener/WriteListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
8181
private function getManager(string $resourceClass, $data)
8282
{
8383
$objectManager = $this->managerRegistry->getManagerForClass($resourceClass);
84-
if (null === $objectManager || !is_object($data)) {
84+
if (null === $objectManager || !\is_object($data)) {
8585
return null;
8686
}
8787

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
4949
$defaultOrder = $this->resourceMetadataFactory->create($resourceClass)->getAttribute('order');
5050
if (null !== $defaultOrder) {
5151
foreach ($defaultOrder as $field => $order) {
52-
if (is_int($field)) {
52+
if (\is_int($field)) {
5353
// Default direction
5454
$field = $order;
5555
$order = 'ASC';

src/Bridge/Doctrine/Orm/Filter/AbstractFilter.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ protected function getClassMetadata(string $resourceClass): ClassMetadata
100100
*/
101101
protected function isPropertyEnabled(string $property/*, string $resourceClass*/): bool
102102
{
103-
if (func_num_args() > 1) {
103+
if (\func_num_args() > 1) {
104104
$resourceClass = func_get_arg(1);
105105
} else {
106-
if (__CLASS__ !== get_class($this)) {
106+
if (__CLASS__ !== \get_class($this)) {
107107
$r = new \ReflectionMethod($this, __FUNCTION__);
108108
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
109109
@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);
@@ -151,10 +151,10 @@ protected function isPropertyMapped(string $property, string $resourceClass, boo
151151
*/
152152
protected function isPropertyNested(string $property/*, string $resourceClass*/): bool
153153
{
154-
if (func_num_args() > 1) {
155-
$resourceClass = func_get_arg(1);
154+
if (\func_num_args() > 1) {
155+
$resourceClass = (string) func_get_arg(1);
156156
} else {
157-
if (__CLASS__ !== get_class($this)) {
157+
if (__CLASS__ !== \get_class($this)) {
158158
$r = new \ReflectionMethod($this, __FUNCTION__);
159159
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
160160
@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);
@@ -224,10 +224,10 @@ protected function splitPropertyParts(string $property/*, string $resourceClass*
224224
{
225225
$parts = explode('.', $property);
226226

227-
if (func_num_args() > 1) {
227+
if (\func_num_args() > 1) {
228228
$resourceClass = func_get_arg(1);
229229
} else {
230-
if (__CLASS__ !== get_class($this)) {
230+
if (__CLASS__ !== \get_class($this)) {
231231
$r = new \ReflectionMethod($this, __FUNCTION__);
232232
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
233233
@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);
@@ -237,7 +237,7 @@ protected function splitPropertyParts(string $property/*, string $resourceClass*
237237

238238
if (!isset($resourceClass)) {
239239
return [
240-
'associations' => array_slice($parts, 0, -1),
240+
'associations' => \array_slice($parts, 0, -1),
241241
'field' => end($parts),
242242
];
243243
}
@@ -252,13 +252,13 @@ protected function splitPropertyParts(string $property/*, string $resourceClass*
252252
}
253253
}
254254

255-
if ($slice === count($parts)) {
255+
if ($slice === \count($parts)) {
256256
$slice -= 1;
257257
}
258258

259259
return [
260-
'associations' => array_slice($parts, 0, $slice),
261-
'field' => implode('.', array_slice($parts, $slice)),
260+
'associations' => \array_slice($parts, 0, $slice),
261+
'field' => implode('.', \array_slice($parts, $slice)),
262262
];
263263
}
264264

@@ -271,10 +271,10 @@ protected function splitPropertyParts(string $property/*, string $resourceClass*
271271
*/
272272
protected function extractProperties(Request $request/*, string $resourceClass*/): array
273273
{
274-
if (func_num_args() > 1) {
275-
$resourceClass = func_get_arg(1);
274+
if (\func_num_args() > 1) {
275+
$resourceClass = (string) func_get_arg(1);
276276
} else {
277-
if (__CLASS__ !== get_class($this)) {
277+
if (__CLASS__ !== \get_class($this)) {
278278
$r = new \ReflectionMethod($this, __FUNCTION__);
279279
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
280280
@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);
@@ -320,10 +320,10 @@ protected function extractProperties(Request $request/*, string $resourceClass*/
320320
*/
321321
protected function addJoinsForNestedProperty(string $property, string $rootAlias, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator/*, string $resourceClass*/): array
322322
{
323-
if (func_num_args() > 4) {
323+
if (\func_num_args() > 4) {
324324
$resourceClass = func_get_arg(4);
325325
} else {
326-
if (__CLASS__ !== get_class($this)) {
326+
if (__CLASS__ !== \get_class($this)) {
327327
$r = new \ReflectionMethod($this, __FUNCTION__);
328328
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
329329
@trigger_error(sprintf('Method %s() will have a fifth `$resourceClass` argument in version API Platform 3.0. Not defining it is deprecated since API Platform 2.1.', __FUNCTION__), E_USER_DEPRECATED);

src/Bridge/Doctrine/Orm/Filter/BooleanFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
7272
return;
7373
}
7474

75-
if (in_array($value, ['true', '1'], true)) {
75+
if (\in_array($value, ['true', '1'], true)) {
7676
$value = true;
77-
} elseif (in_array($value, ['false', '0'], true)) {
77+
} elseif (\in_array($value, ['false', '0'], true)) {
7878
$value = false;
7979
} else {
8080
$this->logger->notice('Invalid filter ignored', [

src/Bridge/Doctrine/Orm/Filter/DateFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function filterProperty(string $property, $values, QueryBuilder $query
7777
{
7878
// Expect $values to be an array having the period as keys and the date value as values
7979
if (
80-
!is_array($values) ||
80+
!\is_array($values) ||
8181
!$this->isPropertyEnabled($property, $resourceClass) ||
8282
!$this->isPropertyMapped($property, $resourceClass) ||
8383
!$this->isDateField($property, $resourceClass)
@@ -189,8 +189,8 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
189189
if (null === $nullManagement || self::EXCLUDE_NULL === $nullManagement) {
190190
$queryBuilder->andWhere($baseWhere);
191191
} elseif (
192-
(in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true) && self::INCLUDE_NULL_BEFORE === $nullManagement) ||
193-
(in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true) && self::INCLUDE_NULL_AFTER === $nullManagement)
192+
(\in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true) && self::INCLUDE_NULL_BEFORE === $nullManagement) ||
193+
(\in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true) && self::INCLUDE_NULL_AFTER === $nullManagement)
194194
) {
195195
$queryBuilder->andWhere($queryBuilder->expr()->orX(
196196
$baseWhere,

src/Bridge/Doctrine/Orm/Filter/ExistsFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
7575
return;
7676
}
7777

78-
if (in_array($value[self::QUERY_PARAMETER_KEY], ['true', '1', '', null], true)) {
78+
if (\in_array($value[self::QUERY_PARAMETER_KEY], ['true', '1', '', null], true)) {
7979
$value = true;
80-
} elseif (in_array($value[self::QUERY_PARAMETER_KEY], ['false', '0'], true)) {
80+
} elseif (\in_array($value[self::QUERY_PARAMETER_KEY], ['false', '0'], true)) {
8181
$value = false;
8282
} else {
8383
$this->logger->notice('Invalid filter ignored', [

src/Bridge/Doctrine/Orm/Filter/OrderFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(ManagerRegistry $managerRegistry, RequestStack $requ
5858
if (null !== $properties) {
5959
$properties = array_map(function ($propertyOptions) {
6060
// shorthand for default direction
61-
if (is_string($propertyOptions)) {
61+
if (\is_string($propertyOptions)) {
6262
$propertyOptions = [
6363
'default_direction' => $propertyOptions,
6464
];
@@ -115,7 +115,7 @@ protected function filterProperty(string $property, $direction, QueryBuilder $qu
115115
}
116116

117117
$direction = strtoupper($direction);
118-
if (!in_array($direction, ['ASC', 'DESC'], true)) {
118+
if (!\in_array($direction, ['ASC', 'DESC'], true)) {
119119
return;
120120
}
121121

@@ -151,6 +151,6 @@ protected function extractProperties(Request $request/*, string $resourceClass*/
151151
$properties = $request->query->get($this->orderParameterName);
152152
}
153153

154-
return is_array($properties) ? $properties : [];
154+
return \is_array($properties) ? $properties : [];
155155
}
156156
}

src/Bridge/Doctrine/Orm/Filter/RangeFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getDescription(string $resourceClass): array
6363
protected function filterProperty(string $property, $values, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
6464
{
6565
if (
66-
!is_array($values) ||
66+
!\is_array($values) ||
6767
!$this->isPropertyEnabled($property, $resourceClass) ||
6868
!$this->isPropertyMapped($property, $resourceClass)
6969
) {
@@ -107,7 +107,7 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
107107
case self::PARAMETER_BETWEEN:
108108
$rangeValue = explode('..', $value);
109109

110-
if (2 !== count($rangeValue)) {
110+
if (2 !== \count($rangeValue)) {
111111
$this->logger->notice('Invalid filter ignored', [
112112
'exception' => new InvalidArgumentException(sprintf('Invalid format for "[%s]", expected "<min>..<max>"', $operator)),
113113
]);

src/Bridge/Doctrine/Orm/Filter/SearchFilter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private function getType(string $doctrineType): string
158158
return 'float';
159159
}
160160

161-
if (defined(Type::class.'::DATE_IMMUTABLE')) {
161+
if (\defined(Type::class.'::DATE_IMMUTABLE')) {
162162
switch ($doctrineType) {
163163
case Type::DATE_IMMUTABLE:
164164
case Type::TIME_IMMUTABLE:
@@ -227,7 +227,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
227227
$caseSensitive = false;
228228
}
229229

230-
if (1 === count($values)) {
230+
if (1 === \count($values)) {
231231
$this->addWhereByStrategy($strategy, $queryBuilder, $queryNameGenerator, $alias, $field, $values[0], $caseSensitive);
232232

233233
return;
@@ -275,7 +275,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
275275
$associationField = $field;
276276
}
277277

278-
if (1 === count($values)) {
278+
if (1 === \count($values)) {
279279
$queryBuilder
280280
->andWhere(sprintf('%s.%s = :%s', $associationAlias, $associationField, $valueParameter))
281281
->setParameter($valueParameter, $values[0]);
@@ -388,7 +388,7 @@ protected function getIdFromValue(string $value)
388388
protected function normalizeValues(array $values): array
389389
{
390390
foreach ($values as $key => $value) {
391-
if (!is_int($key) || !is_string($value)) {
391+
if (!\is_int($key) || !\is_string($value)) {
392392
unset($values[$key]);
393393
}
394394
}

src/Bridge/Doctrine/Orm/Paginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public function getLastPage(): float
4444
*/
4545
public function getTotalItems(): float
4646
{
47-
return (float) ($this->totalItems ?? $this->totalItems = count($this->paginator));
47+
return (float) ($this->totalItems ?? $this->totalItems = \count($this->paginator));
4848
}
4949
}

src/Bridge/Doctrine/Orm/SubresourceDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getSubresource(string $resourceClass, array $identifiers, array
8585
$previousQueryBuilder = null;
8686
$previousAlias = null;
8787

88-
$num = count($context['identifiers']);
88+
$num = \count($context['identifiers']);
8989

9090
while ($num--) {
9191
list($identifier, $identifierResourceClass) = $context['identifiers'][$num];

src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function getBooleanOperationAttribute(string $resourceClass, array $opti
7575
$attribute = $resourceMetadata->getAttribute($attributeName);
7676
}
7777

78-
return is_bool($attribute) ? $attribute : $default;
78+
return \is_bool($attribute) ? $attribute : $default;
7979
}
8080

8181
/**
@@ -98,7 +98,7 @@ private function hasFetchEagerAssociation(EntityManager $em, ClassMetadataInfo $
9898

9999
$related = $em->getClassMetadata($mapping['targetEntity']);
100100

101-
if (in_array($related->name, $checked, true)) {
101+
if (\in_array($related->name, $checked, true)) {
102102
continue;
103103
}
104104

src/Bridge/Doctrine/Orm/Util/IdentifierManagerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private function normalizeIdentifiers($id, ObjectManager $manager, string $resou
4545
$isOrm = interface_exists(EntityManagerInterface::class) && $manager instanceof EntityManagerInterface;
4646
$platform = $isOrm ? $manager->getConnection()->getDatabasePlatform() : null;
4747

48-
if (count($doctrineIdentifierFields) > 1) {
48+
if (\count($doctrineIdentifierFields) > 1) {
4949
$identifiersMap = [];
5050

5151
// first transform identifiers to a proper key/value array

src/Bridge/NelmioApiDoc/Extractor/AnnotationsProvider/ApiPlatformProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private function getApiDoc(bool $collection, string $resourceClass, ResourceMeta
169169
*/
170170
private function getResourceHydraDoc(array $hydraApiDoc, string $prefixedShortName)
171171
{
172-
if (!isset($hydraApiDoc['hydra:supportedClass']) || !is_array($hydraApiDoc['hydra:supportedClass'])) {
172+
if (!isset($hydraApiDoc['hydra:supportedClass']) || !\is_array($hydraApiDoc['hydra:supportedClass'])) {
173173
return null;
174174
}
175175

@@ -192,7 +192,7 @@ private function getResourceHydraDoc(array $hydraApiDoc, string $prefixedShortNa
192192
*/
193193
private function getOperationHydraDoc(string $method, array $hydraDoc): array
194194
{
195-
if (!isset($hydraDoc['hydra:supportedOperation']) || !is_array($hydraDoc['hydra:supportedOperation'])) {
195+
if (!isset($hydraDoc['hydra:supportedOperation']) || !\is_array($hydraDoc['hydra:supportedOperation'])) {
196196
return [];
197197
}
198198

@@ -216,7 +216,7 @@ private function getOperationHydraDoc(string $method, array $hydraDoc): array
216216
*/
217217
private function getCollectionOperationHydraDoc(string $shortName, string $method, array $hydraEntrypointDoc): array
218218
{
219-
if (!isset($hydraEntrypointDoc['hydra:supportedProperty']) || !is_array($hydraEntrypointDoc['hydra:supportedProperty'])) {
219+
if (!isset($hydraEntrypointDoc['hydra:supportedProperty']) || !\is_array($hydraEntrypointDoc['hydra:supportedProperty'])) {
220220
return [];
221221
}
222222

0 commit comments

Comments
 (0)