Using the Drupal standard I am getting a false positive
$getMapOnlyLatestRevision = function ($tableName, $baseField, $idField, $preValidIds = []) use ($db): ?array {
if (empty($tableName) || empty($baseField) || empty($idField)) {
return NULL;
}
$ids = [];
$map = [];
if (empty($preValidIds)) {
$ids = $db->query("SELECT MAX($idField) FROM $tableName GROUP BY $baseField")->fetchCol();
}
else {
$ids = $db->query("SELECT MAX($idField) FROM $tableName WHERE $idField IN (:ids[]) GROUP BY $baseField", [
':ids[]' => $preValidIds,
])->fetchCol();
}
if (empty($ids)) {
return NULL;
}
$map = $db->query("SELECT * FROM $tableName WHERE $idField IN (:ids[])", [
':ids[]' => $ids,
])->fetchAllAssoc($idField);
return $map;
};
This results in a false positive error of: Non-namespaced classes/interfaces/traits should not be referenced with use statements
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | coder-3217297-fix.patch | 9.82 KB | apolitsin |
Issue fork coder-3217297
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 8.3.x
changes, plain diff MR !4
- 3217297-false-positive-in
changes, plain diff MR !3
Comments
Comment #2
chriscalip commentedComment #3
apolitsin commentedGot the same problem on any `use` code
Comment #4
apolitsin commentedProblem exists since `8.3.10`
tag `8.3.9 works fine`
https://git.drupalcode.org/project/coder/-/compare/8.3.9...8.3.10?from_p...
Here is the commit that breaks sniffer
https://git.drupalcode.org/project/coder/-/commit/7385c9df4a7c93aef8690c...
Comment #5
apolitsin commentedQuickFix:
Comment #7
apolitsin commentedComment #12
klausi@chriscalip thanks for reporting, I pushed a fix.
@APolitsin I could not reproduce any problem with your example code. Can you tray again with most recent Coder and PHPCS releases?