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: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
- '7.2'
- '7.3'
- '7.4'
- 'rc'
include:
- php: '7.4'
coverage: true
Expand All @@ -170,7 +171,7 @@ jobs:
bash \
unzip \
- name: Cache mongodb PHP extension build
if: (!startsWith(matrix.php, '7.1'))
if: (!startsWith(matrix.php, '7.1') && !startsWith(matrix.php, 'rc'))
uses: actions/cache@v2
with:
path: /var/tmp/build/ext-mongodb-${{ env.EXT_MONGODB_VERSION }}
Expand All @@ -179,7 +180,7 @@ jobs:
ext-mongodb-${{ env.EXT_MONGODB_VERSION }}-php${{ matrix.php }}-
continue-on-error: true
- name: Install mongodb PHP extension
if: (!startsWith(matrix.php, '7.1'))
if: (!startsWith(matrix.php, '7.1') && !startsWith(matrix.php, 'rc'))
env:
BUILD_DIR: /var/tmp/build/ext-mongodb-${{ env.EXT_MONGODB_VERSION }}
SRC_DIR: /usr/src/php/ext/mongodb
Expand Down Expand Up @@ -230,11 +231,14 @@ jobs:
composer global require --prefer-dist --no-progress --no-suggest --ansi \
symfony/flex
- name: Remove Doctrine MongoDB ODM
if: startsWith(matrix.php, '7.1')
if: (startsWith(matrix.php, '7.1') || startsWith(matrix.php, 'rc'))
run: |
composer remove --dev --no-progress --no-update --ansi \
doctrine/mongodb-odm \
doctrine/mongodb-odm-bundle \
- name: Set Composer platform config
if: (startsWith(matrix.php, 'rc'))
run: composer config platform.php 7.4.99
- name: Update project dependencies
run: |
mkdir -p /tmp/api-platform/core/vendor
Expand Down Expand Up @@ -2348,7 +2352,7 @@ jobs:
with:
php-version: '7.4'
tools: pecl, composer, flex
extensions: intl, openssl, mbstring, pdo_sqlite
extensions: intl, openssl, mbstring, pdo_sqlite
coverage: none
ini-values: memory_limit=-1
- name: Cache Composer packages
Expand Down Expand Up @@ -2385,7 +2389,7 @@ jobs:
with:
php-version: '7.4'
tools: pecl, composer, flex
extensions: intl, openssl, mbstring, pdo_sqlite
extensions: intl, openssl, mbstring, pdo_sqlite
coverage: none
ini-values: memory_limit=-1
- name: Cache Composer packages
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"symfony/property-info": "^3.4 || ^4.0 || ^5.0",
"symfony/serializer": "^4.3 || ^5.0",
"symfony/web-link": "^4.1 || ^5.0",
"willdurand/negotiation": "^2.0.3"
"willdurand/negotiation": "^2.0.3 || 3.0.x-dev"
},
"require-dev": {
"behat/behat": "^3.1",
Expand All @@ -47,8 +47,8 @@
"jangregor/phpstan-prophecy": "^0.6",
"justinrainbow/json-schema": "^5.2.1",
"nelmio/api-doc-bundle": "^2.13.4",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0",
"phpdocumentor/type-resolver": "^0.3 || ^0.4",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0",
"phpdocumentor/type-resolver": "^0.3 || ^0.4 || ^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.4",
"phpstan/phpstan-doctrine": "^0.12.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private function getQueryBuilderWithNewAliases(QueryBuilder $queryBuilder, Query
$newAlias = $queryNameGenerator->generateJoinAlias($association);
$aliases[] = "{$joinPart->getAlias()}.";
$replacements[] = "$newAlias.";
$condition = str_replace($aliases, $replacements, $joinPart->getCondition());
$condition = str_replace($aliases, $replacements, $joinPart->getCondition() ?? '');
QueryBuilderHelper::addJoinOnce($queryBuilderClone, $queryNameGenerator, $alias, $association, $joinPart->getJoinType(), $joinPart->getConditionType(), $condition, $originAlias, $newAlias);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Hal/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
protected function getAttributes($object, $format = null, array $context): array
protected function getAttributes($object, $format = null, array $context = []): array
{
return $this->getComponents($object, $format, $context)['states'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApi/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
protected function getAttributes($object, $format = null, array $context): array
protected function getAttributes($object, $format = null, array $context = []): array
{
return $this->getComponents($object, $format, $context)['attributes'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/JsonSchema/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private function buildDefinitionName(string $className, string $format = 'json',
return $name;
}

private function getMetadata(string $className, string $type = Schema::TYPE_OUTPUT, ?string $operationType, ?string $operationName, ?array $serializerContext): ?array
private function getMetadata(string $className, string $type = Schema::TYPE_OUTPUT, ?string $operationType = null, ?string $operationName = null, ?array $serializerContext = null): ?array
{
if (!$this->isResourceClass($className)) {
return [
Expand Down Expand Up @@ -263,7 +263,7 @@ private function getMetadata(string $className, string $type = Schema::TYPE_OUTP
];
}

private function getSerializerContext(ResourceMetadata $resourceMetadata, string $type = Schema::TYPE_OUTPUT, ?string $operationType, ?string $operationName): array
private function getSerializerContext(ResourceMetadata $resourceMetadata, string $type = Schema::TYPE_OUTPUT, ?string $operationType = null, ?string $operationName = null): array
{
$attribute = Schema::TYPE_OUTPUT === $type ? 'normalization_context' : 'denormalization_context';

Expand Down
2 changes: 1 addition & 1 deletion src/Swagger/Serializer/DocumentationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ final class DocumentationNormalizer implements NormalizerInterface, CacheableSup
* @param mixed|null $jsonSchemaTypeFactory
* @param int[] $swaggerVersions
*/
public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, $jsonSchemaFactory = null, $jsonSchemaTypeFactory = null, OperationPathResolverInterface $operationPathResolver, UrlGeneratorInterface $urlGenerator = null, $filterLocator = null, NameConverterInterface $nameConverter = null, bool $oauthEnabled = false, string $oauthType = '', string $oauthFlow = '', string $oauthTokenUrl = '', string $oauthAuthorizationUrl = '', array $oauthScopes = [], array $apiKeys = [], SubresourceOperationFactoryInterface $subresourceOperationFactory = null, bool $paginationEnabled = true, string $paginationPageParameterName = 'page', bool $clientItemsPerPage = false, string $itemsPerPageParameterName = 'itemsPerPage', $formats = [], bool $paginationClientEnabled = false, string $paginationClientEnabledParameterName = 'pagination', array $defaultContext = [], array $swaggerVersions = [2, 3])
public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, $jsonSchemaFactory = null, $jsonSchemaTypeFactory = null, OperationPathResolverInterface $operationPathResolver = null, UrlGeneratorInterface $urlGenerator = null, $filterLocator = null, NameConverterInterface $nameConverter = null, bool $oauthEnabled = false, string $oauthType = '', string $oauthFlow = '', string $oauthTokenUrl = '', string $oauthAuthorizationUrl = '', array $oauthScopes = [], array $apiKeys = [], SubresourceOperationFactoryInterface $subresourceOperationFactory = null, bool $paginationEnabled = true, string $paginationPageParameterName = 'page', bool $clientItemsPerPage = false, string $itemsPerPageParameterName = 'itemsPerPage', $formats = [], bool $paginationClientEnabled = false, string $paginationClientEnabledParameterName = 'pagination', array $defaultContext = [], array $swaggerVersions = [2, 3])
{
if ($jsonSchemaTypeFactory instanceof OperationMethodResolverInterface) {
@trigger_error(sprintf('Passing an instance of %s to %s() is deprecated since version 2.5 and will be removed in 3.0.', OperationMethodResolverInterface::class, __METHOD__), E_USER_DEPRECATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Doctrine\ODM\MongoDB\Aggregation\Builder;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Count;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Facet;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Match;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Match as AggregationMatch;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Skip;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Iterator\Iterator;
Expand Down Expand Up @@ -467,7 +467,7 @@ private function mockAggregationBuilder($expectedOffset, $expectedLimit)
if ($expectedLimit > 0) {
$skipProphecy->limit($expectedLimit)->shouldBeCalled();
} else {
$matchProphecy = $this->prophesize(Match::class);
$matchProphecy = $this->prophesize(AggregationMatch::class);
$matchProphecy->field(Paginator::LIMIT_ZERO_MARKER_FIELD)->shouldBeCalled()->willReturn($matchProphecy);
$matchProphecy->equals(Paginator::LIMIT_ZERO_MARKER)->shouldBeCalled();
$skipProphecy->match()->shouldBeCalled()->willReturn($matchProphecy->reveal());
Expand Down
8 changes: 4 additions & 4 deletions tests/Bridge/Doctrine/MongoDbOdm/ItemDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Dummy;
use ApiPlatform\Core\Tests\ProphecyTrait;
use Doctrine\ODM\MongoDB\Aggregation\Builder;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Match;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Match as AggregationMatch;
use Doctrine\ODM\MongoDB\Iterator\Iterator;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
Expand All @@ -49,7 +49,7 @@ public function testGetItemSingleIdentifier()
{
$context = ['foo' => 'bar', 'fetch_data' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];

$matchProphecy = $this->prophesize(Match::class);
$matchProphecy = $this->prophesize(AggregationMatch::class);
$matchProphecy->field('id')->willReturn($matchProphecy)->shouldBeCalled();
$matchProphecy->equals(1)->shouldBeCalled();

Expand Down Expand Up @@ -78,7 +78,7 @@ public function testGetItemSingleIdentifier()

public function testGetItemDoubleIdentifier()
{
$matchProphecy = $this->prophesize(Match::class);
$matchProphecy = $this->prophesize(AggregationMatch::class);
$matchProphecy->field('ida')->willReturn($matchProphecy)->shouldBeCalled();
$matchProphecy->field('idb')->willReturn($matchProphecy)->shouldBeCalled();
$matchProphecy->equals(1)->shouldBeCalled();
Expand Down Expand Up @@ -135,7 +135,7 @@ public function testGetItemWrongCompositeIdentifier()

public function testAggregationResultExtension()
{
$matchProphecy = $this->prophesize(Match::class);
$matchProphecy = $this->prophesize(AggregationMatch::class);
$matchProphecy->field('id')->willReturn($matchProphecy)->shouldBeCalled();
$matchProphecy->equals(1)->shouldBeCalled();

Expand Down
24 changes: 12 additions & 12 deletions tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use ApiPlatform\Core\Tests\ProphecyTrait;
use Doctrine\ODM\MongoDB\Aggregation\Builder;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Lookup;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Match;
use Doctrine\ODM\MongoDB\Aggregation\Stage\Match as AggregationMatch;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Iterator\Iterator;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
Expand Down Expand Up @@ -122,7 +122,7 @@ public function testGetSubresource()
$dummyLookup->alias('relatedDummies')->shouldBeCalled();
$dummyAggregationBuilder->lookup('relatedDummies')->shouldBeCalled()->willReturn($dummyLookup->reveal());

$dummyMatch = $this->prophesize(Match::class);
$dummyMatch = $this->prophesize(AggregationMatch::class);
$dummyMatch->equals(1)->shouldBeCalled();
$dummyMatch->field('id')->shouldBeCalled()->willReturn($dummyMatch);
$dummyAggregationBuilder->match()->shouldBeCalled()->willReturn($dummyMatch->reveal());
Expand All @@ -133,7 +133,7 @@ public function testGetSubresource()

$managerProphecy->createAggregationBuilder(Dummy::class)->shouldBeCalled()->willReturn($dummyAggregationBuilder->reveal());

$match = $this->prophesize(Match::class);
$match = $this->prophesize(AggregationMatch::class);
$match->in([2])->shouldBeCalled();
$match->field('_id')->shouldBeCalled()->willReturn($match);
$aggregationBuilder->match()->shouldBeCalled()->willReturn($match);
Expand Down Expand Up @@ -167,7 +167,7 @@ public function testGetSubSubresourceItem()
$dummyLookup->alias('relatedDummies')->shouldBeCalled();
$dummyAggregationBuilder->lookup('relatedDummies')->shouldBeCalled()->willReturn($dummyLookup->reveal());

$dummyMatch = $this->prophesize(Match::class);
$dummyMatch = $this->prophesize(AggregationMatch::class);
$dummyMatch->equals(1)->shouldBeCalled();
$dummyMatch->field('id')->shouldBeCalled()->willReturn($dummyMatch);
$dummyAggregationBuilder->match()->shouldBeCalled()->willReturn($dummyMatch->reveal());
Expand All @@ -191,10 +191,10 @@ public function testGetSubSubresourceItem()
$rLookup->alias('thirdLevel')->shouldBeCalled();
$rAggregationBuilder->lookup('thirdLevel')->shouldBeCalled()->willReturn($rLookup->reveal());

$rMatch = $this->prophesize(Match::class);
$rMatch = $this->prophesize(AggregationMatch::class);
$rMatch->equals(1)->shouldBeCalled();
$rMatch->field('id')->shouldBeCalled()->willReturn($rMatch);
$previousRMatch = $this->prophesize(Match::class);
$previousRMatch = $this->prophesize(AggregationMatch::class);
$previousRMatch->in([2])->shouldBeCalled();
$previousRMatch->field('_id')->shouldBeCalled()->willReturn($previousRMatch);
$rAggregationBuilder->match()->shouldBeCalled()->willReturn($rMatch->reveal(), $previousRMatch->reveal());
Expand All @@ -216,7 +216,7 @@ public function testGetSubSubresourceItem()
// Origin manager (ThirdLevel)
$aggregationBuilder = $this->prophesize(Builder::class);

$match = $this->prophesize(Match::class);
$match = $this->prophesize(AggregationMatch::class);
$match->in([3])->shouldBeCalled();
$match->field('_id')->shouldBeCalled()->willReturn($match);
$aggregationBuilder->match()->shouldBeCalled()->willReturn($match);
Expand Down Expand Up @@ -265,10 +265,10 @@ public function testGetSubresourceOneToOneOwningRelation()
$aggregationBuilder->lookup('ownedDummy')->shouldBeCalled()->willReturn($lookup->reveal());
$managerProphecy->createAggregationBuilder(Dummy::class)->shouldBeCalled()->willReturn($aggregationBuilder->reveal());

$match = $this->prophesize(Match::class);
$match = $this->prophesize(AggregationMatch::class);
$match->equals(1)->shouldBeCalled();
$match->field('id')->shouldBeCalled()->willReturn($match);
$previousMatch = $this->prophesize(Match::class);
$previousMatch = $this->prophesize(AggregationMatch::class);
$previousMatch->in([3])->shouldBeCalled();
$previousMatch->field('_id')->shouldBeCalled()->willReturn($previousMatch);
$aggregationBuilder->match()->shouldBeCalled()->willReturn($match->reveal(), $previousMatch->reveal());
Expand Down Expand Up @@ -314,10 +314,10 @@ public function testAggregationResultExtension()
$aggregationBuilder->lookup('relatedDummies')->shouldBeCalled()->willReturn($lookup->reveal());
$managerProphecy->createAggregationBuilder(Dummy::class)->shouldBeCalled()->willReturn($aggregationBuilder->reveal());

$match = $this->prophesize(Match::class);
$match = $this->prophesize(AggregationMatch::class);
$match->equals(1)->shouldBeCalled();
$match->field('id')->shouldBeCalled()->willReturn($match);
$previousMatch = $this->prophesize(Match::class);
$previousMatch = $this->prophesize(AggregationMatch::class);
$previousMatch->in([3])->shouldBeCalled();
$previousMatch->field('_id')->shouldBeCalled()->willReturn($previousMatch);
$aggregationBuilder->match()->shouldBeCalled()->willReturn($match->reveal(), $previousMatch->reveal());
Expand Down Expand Up @@ -385,7 +385,7 @@ public function testGetSubresourceCollectionItem()

$rAggregationBuilder = $this->prophesize(Builder::class);

$rMatch = $this->prophesize(Match::class);
$rMatch = $this->prophesize(AggregationMatch::class);
$rMatch->equals(2)->shouldBeCalled();
$rMatch->field('id')->shouldBeCalled()->willReturn($rMatch);
$rAggregationBuilder->match()->shouldBeCalled()->willReturn($rMatch->reveal());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ public function testWithResourceWithTraceables()

$dataProvider = $dataCollector->getCollectionDataProviders();
foreach ($dataProvider['responses'] as $class => $response) {
$this->assertStringStartsWith('class@anonymous', $class);
$this->assertStringContainsString('@anonymous', $class);

$this->assertTrue($response);
}
$context = $dataProvider['context'];
Expand All @@ -189,7 +190,7 @@ public function testWithResourceWithTraceables()

$dataProvider = $dataCollector->getItemDataProviders();
foreach ($dataProvider['responses'] as $class => $response) {
$this->assertStringStartsWith('class@anonymous', $class);
$this->assertStringContainsString('@anonymous', $class);
$this->assertTrue($response);
}
$context = $dataProvider['context'];
Expand All @@ -198,7 +199,7 @@ public function testWithResourceWithTraceables()

$dataProvider = $dataCollector->getSubresourceDataProviders();
foreach ($dataProvider['responses'] as $class => $response) {
$this->assertStringStartsWith('class@anonymous', $class);
$this->assertStringContainsString('@anonymous', $class);
$this->assertTrue($response);
}
$context = $dataProvider['context'];
Expand All @@ -207,7 +208,7 @@ public function testWithResourceWithTraceables()

$dataPersister = $dataCollector->getDataPersisters();
foreach ($dataPersister['responses'] as $class => $response) {
$this->assertStringStartsWith('class@anonymous', $class);
$this->assertStringContainsString('@anonymous', $class);
$this->assertTrue($response);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function testPersist($persister, $expected)
$result = $dataPersister->getPersistersResponse();
$this->assertCount(\count($expected), $result);
$this->assertEmpty(array_filter($result, function ($key) {
if (\PHP_VERSION_ID >= 80000) {
return !str_starts_with($key, DataPersisterInterface::class.'@anonymous');
}

return 0 !== strpos($key, 'class@anonymous');
}, ARRAY_FILTER_USE_KEY));
$this->assertSame($expected, array_values($result));
Expand All @@ -46,6 +50,10 @@ public function testRemove($persister, $expected)
$result = $dataPersister->getPersistersResponse();
$this->assertCount(\count($expected), $result);
$this->assertEmpty(array_filter($result, function ($key) {
if (\PHP_VERSION_ID >= 80000) {
return !str_starts_with($key, DataPersisterInterface::class.'@anonymous');
}

return 0 !== strpos($key, 'class@anonymous');
}, ARRAY_FILTER_USE_KEY));
$this->assertSame($expected, array_values($result));
Expand Down
Loading