Skip to content

Commit

Permalink
feature #53160 [PropertyInfo] Deprecate PropertyInfo Type (mtarld)
Browse files Browse the repository at this point in the history
This PR was merged into the 7.1 branch.

Discussion
----------

[PropertyInfo] Deprecate PropertyInfo Type

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes
| Issues        |
| License       | MIT

This PR is a follow-up of symfony/symfony#52510.

As the TypeInfo's `Type` aims to represent types in the Symfony ecosystem, the PropertyInfo's `Type` needs to be deprecated in favor of the first one.

Commits
-------

d32e81c816 [PropertyInfo] Deprecate PropertyInfo Type
  • Loading branch information
fabpot committed Apr 5, 2024
2 parents 601ff99 + 03c2c66 commit 5a3570d
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Tests/Functional/PropertyInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,38 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;

use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\PropertyInfo\Type as LegacyType;
use Symfony\Component\TypeInfo\Type;

class PropertyInfoTest extends AbstractWebTestCase
{
public function testPhpDocPriority()
{
static::bootKernel(['test_case' => 'Serializer']);

$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))], static::getContainer()->get('property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes'));
$propertyInfo = static::getContainer()->get('property_info');

if (!method_exists($propertyInfo, 'getType')) {
$this->markTestSkipped();
}

$this->assertEquals(Type::list(Type::int()), $propertyInfo->getType(Dummy::class, 'codes'));
}

/**
* @group legacy
*/
public function testPhpDocPriorityLegacy()
{
static::bootKernel(['test_case' => 'Serializer']);

$propertyInfo = static::getContainer()->get('property_info');

if (!method_exists($propertyInfo, 'getTypes')) {
$this->markTestSkipped();
}

$this->assertEquals([new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('int'))], $propertyInfo->getTypes(Dummy::class, 'codes'));
}
}

Expand Down

0 comments on commit 5a3570d

Please sign in to comment.