Skip to content

Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure #2120

@LastRide

Description

@LastRide

Hi.

I have next code:

<?php

class Foo
{
    private $foo;

    public function __construct($bar)
    {
        $this->foo = \is_array($bar)
            ? \array_map(
                function () {
                    return null;
                },
                $bar
            ) : $bar;
    }

    public function build(array $bar): array
    {
        return $bar;
    }
}

src/Files/File::getTokens() for ":" symbol in string public function build(array $bar): array returns "T_INLINE_ELSE" instead of "T_COLON" type.

If I change my code to:

<?php

class Foo
{
    private $foo;

    public function __construct($bar)
    {
        $this->foo = \is_array($bar)
            ? $bar
            : \array_map(
                function () {
                    return null;
                },
                $bar
            );
    }

    public function build(array $bar): array
    {
        return $bar;
    }
}

":" symbol would correctly parsed with "T_COLON" type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions