sirbrillig / phpcs-variable-analysis

Find undefined and unused variables with the PHP Codesniffer static analysis tool.
Other
136 stars 14 forks source link

method call called 'enum' causes an "Cannot find enum start at position" error #292

Closed Levivb closed 1 year ago

Levivb commented 1 year ago

Hey,

Running the code sniffer over the following code causes an error

<?php

declare(strict_types=1);

namespace App\Auth;

final class Test
{
    public function __construct(private readonly SomcClass $someClass)
    {
    }

    public function createFor()
    {
        $this->someClass->enum('test');
    }
}

The error message: 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: Cannot find enum start at position 67

It seems the bug was introduced in https://github.com/sirbrillig/phpcs-variable-analysis/pull/289

It looks like 'enum' method calls are not handled correctly :)

sirbrillig commented 1 year ago

Thanks for noticing this! I figured I had missed something.

Levivb commented 1 year ago

Thanks for the insanely quick fix! 👍