Skip to content

PHP parser interprets docblock return type like an array as a class #509

Closed
@hgraca

Description

@hgraca

Bug Report

Q A
BC Break no
Library Version 0.6.0
PHP version 7.4

Summary

It seems the php parser is using phpdocs and deciding that something like

/**
* @return array<int, string|int>
*/

is a class with FQCN My\Namespace\array<int, string|int> which
then ofc fails to create a FullyQualifiedClassName.

I've opened a PR.

Current behavior

/**
* @return array<int, string|int>
*/

is interpreted as FQCN My\Namespace\array<int, string|int>

How to reproduce

Make it parse a class with a method that returns and array and has a docblok detailing the array, ie

    /**
     * @return array<int, array<string|int, string|int|float>>
     */
    private function fetchInvoiceData(): array 
    {}

Expected behavior

we should ignore cases where

/**
* @return array<int, string|int>
*/

because the dependency is not a class, so we don't care about it.

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions