fix: resolve pre-existing phpstan and phpcs CI failures
Problem
The 4.1.x branch has pre-existing phpstan and phpcs failures that block CI on all MRs.
Changes
- Php.php: Add the
DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariablephpcs:ignore alongside the existingVariableAnalysisone — both sniffs flag the same eval-scope variable. - CustomFormatters deriver: Cast
base_plugin_definitionto array before offset access. - CustomFormattersTestBase: Loosen
$adminUser's docblock toAccountInterface(wasUser|false) and drop the now-dead!== FALSEguard arounddrupalLogin(). - FormatterSettingAccessControlTest: Loosen
$adminUser/$regularUserfrom nativeAccountInterface-typed properties to untyped-with-docblock, same reasoning as above. - Test files: No
\assert()/instanceofnarrowing ondrupalCreateUser()/createUser()return values — Drupal core's current stable ($CORE_STABLE, 11.4.x) typesUserCreationTrait::createUser()as returning bareUserInterface, notUserInterface|false, so such a check is dead code phpstan flags asinstanceof.alwaysTrue. - phpstan.neon: Ignore
entityStorageDirectInjectioninFormatterListBuilder(required byConfigEntityListBuilder's parent constructor), scoped with a leading-wildcard path so it matches regardless of which directory phpstan is run from. - phpstan.neon: Targeted ignores for deprecated
node_access_rebuild()and_contextual_links_to_id()(no replacement available yet in Drupal 11).
Why separate MR?
These issues are unrelated to any feature work. Splitting them out unblocks CI for all future MRs.
Edited by Stuart Clark