Skip to content

PHPCS hangs processing some nested arrow functions inside a function call #3324

Closed
@drupol

Description

@drupol

Describe the bug
Hello,

I'm using PHP CS in a project and I'm doing experimentation in a local branch.

While testing some stuff, I run from time to time PHP CS with the PSR12 standard.

However, for some reason, it hangs on a file. I streamlined the file to the strict minimum for this issue:

Code sample

<?php

declare(strict_types=1);

namespace Foo;

final class Bar
{
    public function __invoke(): Closure
    {
        return
            static function (callable ...$callbacks): Closure {
                $test = A::of()
                    (B::thunk()(true))
                    (
                        ...C::map()
                        (static fn (callable $callback): callable => static fn ($value, $key, Iterator $iterator): bool => $callback($value, $key, $iterator) === $value)
                        ($callbacks)
                    );

                return $test;
            };
    }
}

To reproduce

./vendor/bin/phpcs --standard=PSR12 --extensions=php --report=full --ignore=/.github/,/.idea/,/build/,/benchmarks/,/node_modules/,/resource/,/spec/,/tests/,/var/,/vendor/ testFile.php

Expected behavior

I expect to have a report.

Versions (please complete the following information):

  • OS: Linux
  • PHP: 7.4.16
  • PHPCS: 3.6 and dev-master
  • Standard: PSR12

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