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
61 changes: 52 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ jobs:
continue-on-error: true

phpunit-components:
name: PHPUnit ${{ matrix.component }} (PHP ${{ matrix.php.version }} ${{ matrix.php.coverage && 'coverage' || '' }}${{ matrix.php.deprecations && 'no deprecations' || '' }})
name: PHPUnit ${{ matrix.component }} (PHP ${{ matrix.php.version }} ${{ matrix.php.coverage && 'coverage' || '' }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand All @@ -274,8 +274,6 @@ jobs:
- version: '8.3'
- version: '8.4'
coverage: true
- version: '8.4'
deprecations: true
component:
- api-platform/doctrine-common
- api-platform/doctrine-orm
Expand Down Expand Up @@ -309,18 +307,13 @@ jobs:
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
composer global link . --permanent
- name: Allow unstable project dependencies
if: matrix.php.deprecations == true
run: |
cd $(composer ${{matrix.component}} --cwd)
composer config minimum-stability dev
- name: Run ${{ matrix.component }} install
run: |
composer ${{matrix.component}} update
- name: Run ${{ matrix.component }} tests
run: |
mkdir -p /tmp/build/logs/phpunit
composer ${{matrix.component}} test --log-junit "/tmp/build/logs/phpunit/junit.xml" ${{ matrix.php.coverage && '--coverage-clover /tmp/build/logs/phpunit/clover.xml' || '' }} ${{ matrix.php.deprecations && '--fail-on-deprecation --display-deprecations' || '' }}
composer ${{matrix.component}} test --log-junit "/tmp/build/logs/phpunit/junit.xml" ${{ matrix.php.coverage && '--coverage-clover /tmp/build/logs/phpunit/clover.xml' || '' }}
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -347,6 +340,56 @@ jobs:
php-coveralls --coverage_clover=/tmp/build/logs/phpunit/clover.xml
continue-on-error: true

phpunit-components-fail-deprecation:
name: PHPUnit no deprecations ${{ matrix.component }} (PHP ${{ matrix.php.version }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
php:
- version: '8.4'
component:
- api-platform/doctrine-common
- api-platform/doctrine-orm
- api-platform/doctrine-odm
- api-platform/metadata
- api-platform/hydra
- api-platform/json-api
- api-platform/json-schema
- api-platform/elasticsearch
- api-platform/openapi
- api-platform/graphql
- api-platform/http-cache
- api-platform/ramsey-uuid
- api-platform/serializer
- api-platform/state
- api-platform/symfony
- api-platform/validator
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php.version }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
ini-values: memory_limit=-1
- name: Linking
run: |
composer global require soyuka/pmu
composer global config allow-plugins.soyuka/pmu true --no-interaction
composer global link . --permanent
- name: Run ${{ matrix.component }} install
run: |
composer ${{matrix.component}} update
- name: Run ${{ matrix.component }} tests
run: |
mkdir -p /tmp/build/logs/phpunit
cd $(composer ${{matrix.component}} --cwd)
./vendor/bin/phpunit --fail-on-deprecation --display-deprecations --log-junit "/tmp/build/logs/phpunit/junit.xml"

behat:
name: Behat (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"symfony/property-info": "^6.4 || ^7.1",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/translation-contracts": "^3.3",
"symfony/type-info": "^7.3-dev",
"symfony/type-info": "v7.3.0-BETA1",
"symfony/web-link": "^6.4 || ^7.0",
"willdurand/negotiation": "^3.1"
},
Expand Down Expand Up @@ -211,10 +211,6 @@
},
"type": "library",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{"type": "vcs", "url": "https://github.com/soyuka/phpunit"}
]
}
4 changes: 0 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ parameters:
paths:
- tests/Fixtures/TestBundle/Document/
- src/Metadata/Tests/Fixtures/ApiResource/
-
message: '#Parameter \#1 \$constraint of method#'
paths:
- tests/Symfony/Validator/Metadata/Property/Restriction/
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy<(\\?[a-zA-Z0-9_]+)+>::\$[a-zA-Z0-9_]+#'
# https://github.com/phpstan/phpstan-symfony/issues/76
-
Expand Down
6 changes: 1 addition & 5 deletions src/Doctrine/Common/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"doctrine/orm": "^2.17 || ^3.0",
"phpspec/prophecy-phpunit": "^2.2",
"phpunit/phpunit": "11.5.x-dev",
"symfony/type-info": "^7.3-dev"
"symfony/type-info": "v7.3.0-BETA1"
},
"conflict": {
"doctrine/persistence": "<1.3"
Expand Down Expand Up @@ -76,10 +76,6 @@
"test": "./vendor/bin/phpunit"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{
"type": "vcs",
"url": "https://github.com/soyuka/phpunit"
Expand Down
14 changes: 8 additions & 6 deletions src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Types\Type as MongoDbType;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Symfony\Component\PropertyInfo\Type as LegacyType;
use Symfony\Component\TypeInfo\Type;
Expand Down Expand Up @@ -83,7 +84,7 @@
);
}

#[\PHPUnit\Framework\Attributes\Group('legacy')]
#[IgnoreDeprecations]

Check warning on line 87 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L87

Added line #L87 was not covered by tests
#[\PHPUnit\Framework\Attributes\DataProvider('legacyTypesProvider')]
public function testExtractLegacy(string $property, ?array $type = null): void
{
Expand All @@ -96,7 +97,7 @@
$this->assertEquals($type, $this->createExtractor()->getType(DoctrineDummy::class, $property));
}

#[\PHPUnit\Framework\Attributes\Group('legacy')]
#[IgnoreDeprecations]

Check warning on line 100 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L100

Added line #L100 was not covered by tests
public function testExtractWithEmbedOneLegacy(): void
{
$expectedTypes = [
Expand All @@ -123,7 +124,7 @@
);
}

#[\PHPUnit\Framework\Attributes\Group('legacy')]
#[IgnoreDeprecations]

Check warning on line 127 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L127

Added line #L127 was not covered by tests
public function testExtractWithEmbedManyLegacy(): void
{
$expectedTypes = [
Expand Down Expand Up @@ -153,7 +154,7 @@
);
}

#[\PHPUnit\Framework\Attributes\Group('legacy')]
#[IgnoreDeprecations]

Check warning on line 157 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L157

Added line #L157 was not covered by tests
public function testExtractEnumLegacy(): void
{
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString'));
Expand All @@ -168,6 +169,7 @@
$this->assertNull($this->createExtractor()->getType(DoctrineEnum::class, 'enumCustom'));
}

#[IgnoreDeprecations]

Check warning on line 172 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L172

Added line #L172 was not covered by tests
public static function legacyTypesProvider(): array
{
return [
Expand Down Expand Up @@ -258,7 +260,7 @@
$this->assertNull($this->createExtractor()->getProperties('Not\Exist'));
}

#[\PHPUnit\Framework\Attributes\Group('legacy')]
#[IgnoreDeprecations]

Check warning on line 263 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L263

Added line #L263 was not covered by tests
public function testGetTypesCatchExceptionLegacy(): void
{
$this->assertNull($this->createExtractor()->getTypes('Not\Exist', 'baz'));
Expand All @@ -278,7 +280,7 @@
$this->assertNull($extractor->isReadable(DoctrineGeneratedValue::class, 'foo'));
}

#[\PHPUnit\Framework\Attributes\Group('legacy')]
#[IgnoreDeprecations]

Check warning on line 283 in src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php#L283

Added line #L283 was not covered by tests
public function testGetTypesWithEmbedManyOmittingTargetDocumentLegacy(): void
{
$actualTypes = $this->createExtractor()->getTypes(
Expand Down
6 changes: 1 addition & 5 deletions src/Doctrine/Odm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"api-platform/state": "^4.1",
"doctrine/mongodb-odm": "^2.10",
"symfony/property-info": "^6.4 || ^7.1",
"symfony/type-info": "^7.3-dev"
"symfony/type-info": "v7.3.0-BETA1"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.11",
Expand Down Expand Up @@ -76,10 +76,6 @@
"test": "./vendor/bin/phpunit"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{
"type": "vcs",
"url": "https://github.com/soyuka/phpunit"
Expand Down
6 changes: 1 addition & 5 deletions src/Doctrine/Orm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/property-access": "^6.4 || ^7.0",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/type-info": "^7.3-dev",
"symfony/type-info": "v7.3.0-BETA1",
"symfony/uid": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0"
Expand Down Expand Up @@ -76,10 +76,6 @@
"test": "./vendor/bin/phpunit"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{
"type": "vcs",
"url": "https://github.com/soyuka/phpunit"
Expand Down
4 changes: 0 additions & 4 deletions src/Documentation/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
"phpunit/phpunit": "11.5.x-dev"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{
"type": "vcs",
"url": "https://github.com/soyuka/phpunit"
Expand Down
2 changes: 2 additions & 0 deletions src/Elasticsearch/Tests/Extension/SortExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Metadata\ResourceClassResolverInterface;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
Expand Down Expand Up @@ -53,6 +54,7 @@
self::assertEquals(['sort' => [['name' => ['order' => 'asc']], ['bar' => ['order' => 'desc']]]], $sortExtension->applyToCollection([], Foo::class, (new GetCollection())->withOrder(['name', 'bar' => 'desc'])));
}

#[IgnoreDeprecations]

Check warning on line 57 in src/Elasticsearch/Tests/Extension/SortExtensionTest.php

View check run for this annotation

Codecov / codecov/patch

src/Elasticsearch/Tests/Extension/SortExtensionTest.php#L57

Added line #L57 was not covered by tests
public function testApplyToCollectionWithNestedProperty(): void
{
$fooType = Type::list(Type::object(Foo::class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use ApiPlatform\Elasticsearch\Metadata\Resource\Factory\ElasticsearchProviderResourceMetadataCollectionFactory;
use ApiPlatform\Elasticsearch\Tests\Fixtures\Foo;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
use ApiPlatform\Metadata\Tests\Fixtures\Metadata\Get;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

Expand Down
6 changes: 1 addition & 5 deletions src/Elasticsearch/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"symfony/property-access": "^6.4 || ^7.0",
"symfony/property-info": "^6.4 || ^7.1",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/type-info": "^7.3-dev",
"symfony/type-info": "v7.3.0-BETA1",
"symfony/uid": "^6.4 || ^7.0"
},
"require-dev": {
Expand Down Expand Up @@ -76,10 +76,6 @@
"test": "./vendor/bin/phpunit"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{
"type": "vcs",
"url": "https://github.com/soyuka/phpunit"
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQl/Tests/Type/TypeConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
use GraphQL\Type\Definition\EnumType;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type as GraphQLType;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Symfony\Component\PropertyInfo\Type as LegacyType;
use Symfony\Component\TypeInfo\Type;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;

/**
* @author Alan Poulain <contact@alanpoulain.eu>
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQl/Type/FieldsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type\CollectionType;
use Symfony\Component\TypeInfo\TypeIdentifier;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\TypeInfo\TypeIdentifier;

/**
* Builds the GraphQL fields.
Expand Down
6 changes: 1 addition & 5 deletions src/GraphQl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"api-platform/serializer": "^4.1",
"symfony/property-info": "^6.4 || ^7.1",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/type-info": "^7.2",
"symfony/type-info": "v7.3.0-BETA1",
"webonyx/graphql-php": "^15.0",
"willdurand/negotiation": "^3.1"
},
Expand Down Expand Up @@ -80,10 +80,6 @@
"test": "./vendor/bin/phpunit"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/symfony/type-info"
},
{
"type": "vcs",
"url": "https://github.com/soyuka/phpunit"
Expand Down
15 changes: 3 additions & 12 deletions src/Hal/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ApiPlatform\Metadata\ResourceClassResolverInterface;
use ApiPlatform\Metadata\UrlGeneratorInterface;
use ApiPlatform\Metadata\Util\ClassInfoTrait;
use ApiPlatform\Metadata\Util\TypeHelper;
use ApiPlatform\Serializer\AbstractItemNormalizer;
use ApiPlatform\Serializer\CacheKeyTrait;
use ApiPlatform\Serializer\ContextTrait;
Expand All @@ -39,7 +40,6 @@
use Symfony\Component\TypeInfo\Type\CollectionType;
use Symfony\Component\TypeInfo\Type\CompositeTypeInterface;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\TypeInfo\Type\WrappingTypeInterface;

/**
* Converts between objects and array including HAL metadata.
Expand Down Expand Up @@ -212,17 +212,8 @@ private function getComponents(object $object, ?string $format, array $context):
$isOne = $className && $this->resourceClassResolver->isResourceClass($className);
}
} elseif ($type instanceof Type) {
$typeIsCollection = function (Type $type) use (&$typeIsCollection, &$valueType): bool {
return match (true) {
$type instanceof CollectionType => null !== $valueType = $type->getCollectionValueType(),
$type instanceof WrappingTypeInterface => $type->wrappedTypeIsSatisfiedBy($typeIsCollection),
$type instanceof CompositeTypeInterface => $type->composedTypesAreSatisfiedBy($typeIsCollection),
default => false,
};
};

if ($type->isSatisfiedBy($typeIsCollection)) {
$isMany = $valueType->isSatisfiedBy($typeIsResourceClass);
if ($type->isSatisfiedBy(fn ($t) => $t instanceof CollectionType)) {
$isMany = TypeHelper::getCollectionValueType($type)?->isSatisfiedBy($typeIsResourceClass);
} else {
$isOne = $type->isSatisfiedBy($typeIsResourceClass);
}
Expand Down
Loading
Loading