Issue #3616760: Raise phpstan analysis from level 2 to 3 (3.x backport)

Backport of the 4.x change to 3.x, on top of #3616747 so an ignore that stops matching is reported.

Level 3 reports 52 errors on 3.x, the same count 4.x had, and the same split.

34 module defects, fixed

  • DomainStorageInterface::loadDefaultId() documented int|bool / "FALSE if none" but returns NULL, and a domain id is a machine name.
  • DomainStorageInterface::sort() documented bool but is a uasort comparator returning int.
  • DomainAliasInterface::getDomainId() documented int but returns the parent domain's machine name.
  • DomainStorage::loadDefaultDomain() and DomainAliasStorage::loadByPattern() narrow their result with an instanceof instead of a count.
  • DomainAccessPermissionsTest::$domains and DomainContentTestBase::$domains documented DomainInterface for an array property, which alone accounted for 19 of the 52.
  • Four lazily initialised properties are documented as nullable.
  • DomainAccessEntityHooks appends to the field item list with appendItem() rather than [].
  • DeleteForm::buildForm() throws its redirect as an EnforcedResponseException instead of returning a response from a build handler.
  • DomainAliasForm and DomainSourceActionBase assert the concrete handler and entity type they need.

18 upstream typing bugs, baselined

KernelTestBase::$container, BrowserTestBase::$loggedInUser, StorableConfigBase::$schemaWrapper and LanguageConfigFactoryOverrideInterface::getOverride() all document a type core's own code does not honour. Nothing in the module can fix them, so they go in phpstan-baseline.neon -- byte for byte the file 4.x carries. The $container entries are message regexes rather than raw messages so they keep matching if core makes the property nullable.

phpstan is [OK] No errors at level 3 against Drupal 11.4.4, the version the current lane installs, with every baseline entry matching.

Merge request reports

Loading