Problem/Motivation
phpcs --standard=Drupal modules/user/src/EventSubscriber/AccessDeniedSubscriber.php
FILE: ...core/modules/user/src/EventSubscriber/AccessDeniedSubscriber.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
----------------------------------------------------------------------
3 | ERROR | [x] Namespaced classes, interfaces and traits should
| | not begin with a file doc comment
13 | WARNING | [x] Unused use statement
46 | ERROR | [ ] Expected type hint "UrlGeneratorInterface"; found
| | "URLGeneratorInterface" for $url_generator
This is because the use statement is:
use Drupal\Core\Routing\UrlGeneratorInterface;
and the code is:
public function __construct(AccountInterface $account, URLGeneratorInterface $url_generator) {
The problem is UrlGeneratorInterface vs URLGeneratorInterface. So either the fix here is wrong - it is removes the use statement - or the sniff is wrong. I think the sniff is wrong because PHP is not case sensitive.
Proposed resolution
tbd
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #2
alexpottComment #3
klausiOk, so this sniff should not be case sensitive. We should also create a sniff that makes sure that class names are spelled out the exact same way as in the use statement.
Comment #4
alexpottThat's not quite right - the use statement can be in the wrong case too :(
Comment #5
klausiYeah, I mean Drupal should invent a coding standard that the casing has to be the same in the use statement and the statement referencing the class.
Comment #7
klausiCommitted a fix.