Skip to content

Commit ab474b6

Browse files
authored
Merge 2.5 onto master
Merge 2.5 onto master
2 parents 347a095 + a5bd1b7 commit ab474b6

File tree

24 files changed

+123
-98
lines changed

24 files changed

+123
-98
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
restore-keys: ${{ runner.os }}-composer-
128128
- name: Enable code coverage
129129
if: matrix.coverage
130-
run: echo '::set-env name=COVERAGE::1'
130+
run: echo "COVERAGE=1" >> $GITHUB_ENV
131131
- name: Remove Doctrine MongoDB ODM
132132
if: (startsWith(matrix.php, '7.1') || startsWith(matrix.php, 'rc'))
133133
run: |
@@ -222,7 +222,7 @@ jobs:
222222
restore-keys: ${{ runner.os }}-composer-
223223
- name: Enable code coverage
224224
if: matrix.coverage
225-
run: echo '::set-env name=COVERAGE::1'
225+
run: echo "COVERAGE=1" >> $GITHUB_ENV
226226
- name: Remove Doctrine MongoDB ODM
227227
if: startsWith(matrix.php, '7.1')
228228
run: |

composer.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"require-dev": {
3030
"behat/behat": "^3.1",
3131
"behat/mink": "^1.7",
32-
"behatch/contexts": "dev-api-platform",
32+
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
33+
"friends-of-behat/mink-extension": "^2.2",
34+
"friends-of-behat/symfony-extension": "^2.1",
35+
"soyuka/contexts": "^3.3.1",
3336
"doctrine/annotations": "^1.7",
3437
"doctrine/common": "^2.11 || ^3.0",
3538
"doctrine/data-fixtures": "^1.2.2",
@@ -38,9 +41,6 @@
3841
"doctrine/mongodb-odm-bundle": "^4.0",
3942
"doctrine/orm": "^2.6.4 || ^3.0",
4043
"elasticsearch/elasticsearch": "^6.0 || ^7.0",
41-
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
42-
"friends-of-behat/mink-extension": "^2.2",
43-
"friends-of-behat/symfony-extension": "^2.1",
4444
"guzzlehttp/guzzle": "^6.0 || ^7.0",
4545
"jangregor/phpstan-prophecy": "^0.8",
4646
"justinrainbow/json-schema": "^5.2.1",
@@ -116,12 +116,6 @@
116116
"ApiPlatform\\Core\\Tests\\": "tests/"
117117
}
118118
},
119-
"repositories": [
120-
{
121-
"type": "vcs",
122-
"url": "https://github.com/dunglas/contexts"
123-
}
124-
],
125119
"config": {
126120
"preferred-install": {
127121
"*": "dist"

phpstan.neon.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ parameters:
9797
-
9898
message: '#Service "test" is not registered in the container\.#'
9999
path: tests/GraphQl/Type/TypesContainerTest.php
100-
# https://github.com/phpstan/phpstan/issues/2999
101-
-
102-
message: '#ArrayObject<string, bool\|string> does not accept array<string, mixed>\.#'
103-
path: src/JsonSchema/SchemaFactory.php
104100
-
105101
message: '#Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo::\$fieldMappings \(array.*\)>\) does not accept array\(.*\)\.#'
106102
path: tests/Bridge/Doctrine/Orm/Metadata/Property/DoctrineOrmPropertyMetadataFactoryTest.php

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class OrderFilter extends AbstractFilter implements OrderFilterInterface
4343
public function __construct(ManagerRegistry $managerRegistry, string $orderParameterName = 'order', LoggerInterface $logger = null, array $properties = null, NameConverterInterface $nameConverter = null)
4444
{
4545
if (null !== $properties) {
46-
$properties = array_map(function ($propertyOptions) {
46+
$properties = array_map(static function ($propertyOptions) {
4747
// shorthand for default direction
4848
if (\is_string($propertyOptions)) {
4949
$propertyOptions = [

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,24 @@ private function addEqualityMatchStrategy(string $strategy, string $field, $valu
166166
{
167167
$type = $metadata->getTypeOfField($field);
168168

169+
if (MongoDbType::STRING !== $type) {
170+
return MongoDbType::getType($type)->convertToDatabaseValue($value);
171+
}
172+
173+
$quotedValue = preg_quote($value);
174+
169175
switch ($strategy) {
170-
case MongoDbType::STRING !== $type:
171-
return MongoDbType::getType($type)->convertToDatabaseValue($value);
172176
case null:
173177
case self::STRATEGY_EXACT:
174-
return $caseSensitive ? $value : new Regex("^$value$", 'i');
178+
return $caseSensitive ? $value : new Regex("^$quotedValue$", 'i');
175179
case self::STRATEGY_PARTIAL:
176-
return new Regex($value, $caseSensitive ? '' : 'i');
180+
return new Regex($quotedValue, $caseSensitive ? '' : 'i');
177181
case self::STRATEGY_START:
178-
return new Regex("^$value", $caseSensitive ? '' : 'i');
182+
return new Regex("^$quotedValue", $caseSensitive ? '' : 'i');
179183
case self::STRATEGY_END:
180-
return new Regex("$value$", $caseSensitive ? '' : 'i');
184+
return new Regex("$quotedValue$", $caseSensitive ? '' : 'i');
181185
case self::STRATEGY_WORD_START:
182-
return new Regex("(^$value.*|.*\s$value.*)", $caseSensitive ? '' : 'i');
186+
return new Regex("(^$quotedValue.*|.*\s$quotedValue.*)", $caseSensitive ? '' : 'i');
183187
default:
184188
throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy));
185189
}

src/Bridge/Doctrine/MongoDbOdm/SubresourceDataProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ private function buildAggregation(array $identifiers, array $context, array $exe
164164
$aggregation = $this->buildAggregation($identifiers, $context, $executeOptions, $aggregation, --$remainingIdentifiers, $topAggregationBuilder);
165165

166166
$results = $aggregation->execute($executeOptions)->toArray();
167-
$in = array_reduce($results, function ($in, $result) use ($previousAssociationProperty) {
168-
return $in + array_map(function ($result) {
167+
$in = array_reduce($results, static function ($in, $result) use ($previousAssociationProperty) {
168+
return $in + array_map(static function ($result) {
169169
return $result['_id'];
170170
}, $result[$previousAssociationProperty] ?? []);
171171
}, []);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class OrderFilter extends AbstractContextAwareFilter implements OrderFilterInter
4444
public function __construct(ManagerRegistry $managerRegistry, ?RequestStack $requestStack = null, string $orderParameterName = 'order', LoggerInterface $logger = null, array $properties = null, NameConverterInterface $nameConverter = null)
4545
{
4646
if (null !== $properties) {
47-
$properties = array_map(function ($propertyOptions) {
47+
$properties = array_map(static function ($propertyOptions) {
4848
// shorthand for default direction
4949
if (\is_string($propertyOptions)) {
5050
$propertyOptions = [

src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private function addSwaggerSection(ArrayNodeDefinition $rootNode): void
318318
})
319319
->end()
320320
->validate()
321-
->ifTrue(function ($v) use ($defaultVersions) {
321+
->ifTrue(static function ($v) use ($defaultVersions) {
322322
return $v !== array_intersect($v, $defaultVersions);
323323
})
324324
->thenInvalid(sprintf('Only the versions %s are supported. Got %s.', implode(' and ', $defaultVersions), '%s'))
@@ -388,7 +388,7 @@ private function addHttpCacheSection(ArrayNodeDefinition $rootNode): void
388388
->variableNode('request_options')
389389
->defaultValue([])
390390
->validate()
391-
->ifTrue(function ($v) { return false === \is_array($v); })
391+
->ifTrue(static function ($v) { return false === \is_array($v); })
392392
->thenInvalid('The request_options parameter must be an array.')
393393
->end()
394394
->info('To pass options to the client charged with the request.')
@@ -486,7 +486,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
486486
->useAttributeAsKey('exception_class')
487487
->beforeNormalization()
488488
->ifArray()
489-
->then(function (array $exceptionToStatus) {
489+
->then(static function (array $exceptionToStatus) {
490490
foreach ($exceptionToStatus as &$httpStatusCode) {
491491
if (\is_int($httpStatusCode)) {
492492
continue;
@@ -505,7 +505,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
505505
->prototype('integer')->end()
506506
->validate()
507507
->ifArray()
508-
->then(function (array $exceptionToStatus) {
508+
->then(static function (array $exceptionToStatus) {
509509
foreach ($exceptionToStatus as $httpStatusCode) {
510510
if ($httpStatusCode < 100 || $httpStatusCode >= 600) {
511511
throw new InvalidConfigurationException(sprintf('The HTTP status code "%s" is not valid.', $httpStatusCode));
@@ -530,7 +530,7 @@ private function addFormatSection(ArrayNodeDefinition $rootNode, string $key, ar
530530
->useAttributeAsKey('format')
531531
->beforeNormalization()
532532
->ifArray()
533-
->then(function ($v) {
533+
->then(static function ($v) {
534534
foreach ($v as $format => $value) {
535535
if (isset($value['mime_types'])) {
536536
continue;

src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use ApiPlatform\Core\JsonSchema\SchemaFactoryInterface;
2121
use PHPUnit\Framework\ExpectationFailedException;
2222
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
23+
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
2324
use Symfony\Contracts\HttpClient\ResponseInterface;
2425

2526
/**
@@ -111,14 +112,14 @@ public static function assertMatchesJsonSchema($jsonSchema, ?int $checkMode = nu
111112

112113
public static function assertMatchesResourceCollectionJsonSchema(string $resourceClass, ?string $operationName = null, string $format = 'jsonld'): void
113114
{
114-
$schema = self::getSchemaFactory()->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, OperationType::COLLECTION, $operationName);
115+
$schema = self::getSchemaFactory()->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, OperationType::COLLECTION, $operationName, null, [AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false]);
115116

116117
static::assertMatchesJsonSchema($schema->getArrayCopy());
117118
}
118119

119120
public static function assertMatchesResourceItemJsonSchema(string $resourceClass, ?string $operationName = null, string $format = 'jsonld'): void
120121
{
121-
$schema = self::getSchemaFactory()->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, OperationType::ITEM, $operationName);
122+
$schema = self::getSchemaFactory()->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, OperationType::ITEM, $operationName, null, [AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false]);
122123

123124
static::assertMatchesJsonSchema($schema->getArrayCopy());
124125
}

src/GraphQl/Type/FieldsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private function getFilterArgs(array $args, ?string $resourceClass, ?ResourceMet
395395
if (\array_key_exists($key, $parsed) && \is_array($parsed[$key])) {
396396
$parsed = [$key => ''];
397397
}
398-
array_walk_recursive($parsed, function (&$value) use ($graphqlFilterType) {
398+
array_walk_recursive($parsed, static function (&$value) use ($graphqlFilterType) {
399399
$value = $graphqlFilterType;
400400
});
401401
$args = $this->mergeFilterArgs($args, $parsed, $resourceMetadata, $key);

0 commit comments

Comments
 (0)