Skip to content

annotate tool breaks when virtual fields have generics defined in return type #424

@LordSimal

Description

@LordSimal

I am just trying to add the IDE Helper and annotations to the https://github.com/cakephp/plugins.cakephp.org repo but got a wrong property decleration when generating properties.

I have e.g. this virtual field

    /**
     * @return array<int, array<\Tags\Model\Entity\Tag>>
     * @see \App\Model\Entity\Package::$cake_php_tag_groups
     */
    protected function _getCakePhpTagGroups(): array
    {
        return $this->groupVersionTags($this->cake_php_tags, 'CakePHP');
    }

    /**
     * @return array<int, array<\Tags\Model\Entity\Tag>>
     * @see \App\Model\Entity\Package::$php_tag_groups
     */
    protected function _getPhpTagGroups(): array
    {
        return $this->groupVersionTags($this->php_tags, 'PHP');
    }

which generates this property

 * @property array<\Tags\Model\Entity\Tag> $cake_php_tags
 * @property array<int, $cake_php_tag_groups     // <==============
 * @property array<\Tags\Model\Entity\Tag> $php_tags
 * @property array<int, $php_tag_groups      // <==============
 * @property array<\Tags\Model\Entity\Tagged> $tagged
 * @property array<\Tags\Model\Entity\Tag> $tags
 * @property \Tags\Model\Entity\Tagged $_joinData

I do have these config options set

    'IdeHelper' => [
        'tableBehaviors' => true,
        'arrayAsGenerics' => true,
        'objectAsGenerics' => true,
        'assocsAsGenerics' => true,
    ],

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions