coding-standard icon indicating copy to clipboard operation
coding-standard copied to clipboard

SlevomatCodingStandard.Variables.UnusedVariable false positive with compact

Open arxeiss opened this issue 1 month ago • 0 comments

Hi,

the sniff SlevomatCodingStandard.Variables.UnusedVariable is reporting all variables as unused, if they are used only in compact function.

Here variable $students is reported as unused. Strange is, it worked well for 8.20.0 and now after upgrade to 8.25.1 it reports those variables.

public function index(): View
    {
        $this->authorize('parentList', Student::class);
        $students = $this->studentService->getListForParent(Auth::user())->get();

        return \view('students.list', \compact('students'));
    }

arxeiss avatar Dec 03 '25 00:12 arxeiss