8000 [symfony/property-info] Can't handle Collection annotations · Issue #57634 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[symfony/property-info] Can't handle Collection annotations #57634
Closed
@bumburoom

Description

@bumburoom

Symfony version(s) affected

6.4.9

Description

The property reader symfony/property-info/Util/PhpStanTypeHelper.php doesn't recognized the type of a collection property and try to access an not existing array key at line 169.

return [new Type($subTypes[0]->getBuiltinType(), true, $subTypes[0]->getClassName(), $subTypes[0]->isCollection(), $subTypes[0]->getCollectionKeyTypes(), $subTypes[0]->getCollectionValueTypes())];

How to reproduce

The property with annotation like that can be successful extracted

/** @var ?Permission[] $permissions*/
public ?array $permissions = null;

The following annotation can not be extracted and cause a PHP warning "Undefined array key 0"
/** @var ?Collection<int, Permission> $permissions*/
public ?Collection $permissions = null;

Possible Solution

No response

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

      0