Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[TypeInfo] TypeContextFactory::collectUses returns values with ; #60906

Open
@eXsio

Description

@eXsio

Symfony version(s) affected

7.3.0

Description

I'm trying to upgrade from Symfony 6.4 to 7.3, but the Serializer is failing to recognize nested Types. Upon deeper inspection it turned out that the TypeContextFactory::collectUses is gathering values with ;.

Im running on WSL with PHP 8.4.8. I've cloned the Property Info Component and uppon running

 php vendor/bin/phpunit --filter testCollectUses Tests/TypeContext/TypeContextFactoryTest.php

I'm getting the following failure:

1) Symfony\Component\TypeInfo\Tests\TypeContext\TypeContextFactoryTest::testCollectUses
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 [
-    'Type' => 'Symfony\Component\TypeInfo\Type',
-    'DateTimeInterface' => '\DateTimeInterface',
-    'DateTime' => '\DateTimeImmutable',
+    'Type;' => 'Symfony\Component\TypeInfo\Type;',
+    'DateTimeInterface;' => '\DateTimeInterface;',
+    'DateTime;' => '\DateTimeImmutable',
 ]

/home/exsio/dev/type-info/Tests/TypeContext/TypeContextFactoryTest.php:83

FAILURES!
Tests: 1, Assertions: 2, Failures: 1, PHPUnit Deprecations: 1.

This is a complete migration blocker for me.

How to reproduce

  1. Install PHP 8.4.8
  2. Run php vendor/bin/phpunit --filter testCollectUses Tests/TypeContext/TypeContextFactoryTest.php

This may be failing only on WSL, not sure about native distro.

Possible Solution

Modify TypeContextFactory on line 139 and replace

$uses[$alias] = $use[0];

with

$uses[str_replace(";","", $alias)] = str_replace(";","", $use[0]);

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions