-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo][TypeInfo] Unable to validate doctrine/orm v2 PersistentCollection #60598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/**
* @phpstan-type Type1 int
* @phpstan-type Type2 array{var1: Type1, var2: Type3}
* @phpstan-type Type3 int
*/
|
cc @mtarld |
Pretty sure the issue I'm having is related to this too. I upgraded Symfony from 7.2 to 7.3 and I'm getting similar error from API Platform when it's doing something with entities that are reusing imported PHPStan types. https://github.com/simoheinonen/phpstan-bug/blob/master/src/Entity/FooInterface.php Full reproducer: simoheinonen/phpstan-bug#2 I was able to narrow it down to this: // src/Command/FooCommand.php
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\TypeInfo\TypeContext\TypeContextFactory;
#[AsCommand(name: 'foo')]
class FooCommand extends Command
{
public function __construct(
#[Autowire(service: 'type_info.type_context_factory')]
private TypeContextFactory $typeContextFactory,
)
{
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->typeContextFactory->createFromClassName(BarClass::class, BarClass::class);
return Command::SUCCESS;
}
}
/**
* @phpstan-type FooType string
*/
class FooClass
{
}
/**
* @phpstan-import-type FooType from FooClass
* @phpstan-type BarType array{
* barKey: FooType
* }
*/
class BarClass
{
}
|
This PR was merged into the 7.3 branch. Discussion ---------- [TypeInfo] Fix type alias resolving | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fixes #60598, fixes #60657 | License | MIT Take other type aliases into account when resolving type aliases, no matter the order they're defined. Commits ------- b778a80 [TypeInfo] Fix type alias resolving
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
7.3
Description
The TypeInfo component seems to be unable to parse a
Doctrine\ORM\PersistentCollection
object when using doctrine/orm v2. I am seeing the following exception thrown when attempting to validate an object with a PersistentCollection as a property:How to reproduce
Run the following commands to create a new project:
Update the ValidateCommand as follows:
Run the following:
bin/console app:validate
And see this error:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: