False positive PHPCompatibility.Keywords.ForbiddenNames.asFound on import statement of a class named Enum with an alias
etremblay opened this issue · comments
Eric Durand-Tremblay commented
Bug Description
Report an invalid as
keyword in import of a class named "Enum" with an alias.
Given the following reproduction Scenario
The issue happens when running this command:
./vendor/bin/phpcs --standard=PHPCompatibility file.php
... over a file containing this code:
<?php
namespace Events;
use Elao\Enum\Bridge\Symfony\Validator\Constraint\Enum as AssertEnum;
I'd expect the following behaviour
No error
Instead this happened
-----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
5 | ERROR | Function name, class name, namespace name or constant name can not be reserved keyword 'as' (since version all)
-----------------------------------------------------------------------------------------------------------------------------
Environment
Environment | Answer |
---|---|
PHP version | 8.1.14 |
PHP_CodeSniffer version | 3.7.1 |
PHPCompatibility version | dev-master#2fb82334bbefe513e2522ea585cd5ba32bb4d763 |
Install type | Composer project local |
Additional Context (optional)
The problem is only in the develop branch
Tested Against develop
branch?
- I have verified the issue still exists in the
develop
branch of PHPCompatibility.
Juliette commented
@etremblay Thank you for reporting this. I'm on a break at the moment, but will look into it once I'm back in the office. I've milestoned the issue for the 10.0.0 release to ensure it will be fixed before we release.
Juliette commented
Oh, sod it. Turns out to be an easy fix. PR #1475 should fix this. Testing appreciated.
Eric Durand-Tremblay commented
Awesome, thanks for the quick response ... and fix !