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()documentedint|bool/ "FALSE if none" but returns NULL, and a domain id is a machine name.DomainStorageInterface::sort()documentedboolbut is auasortcomparator returning int.DomainAliasInterface::getDomainId()documentedintbut returns the parent domain's machine name.DomainStorage::loadDefaultDomain()andDomainAliasStorage::loadByPattern()narrow their result with aninstanceofinstead of a count.DomainAccessPermissionsTest::$domainsandDomainContentTestBase::$domainsdocumentedDomainInterfacefor an array property, which alone accounted for 19 of the 52.- Four lazily initialised properties are documented as nullable.
DomainAccessEntityHooksappends to the field item list withappendItem()rather than[].DeleteForm::buildForm()throws its redirect as anEnforcedResponseExceptioninstead of returning a response from a build handler.DomainAliasFormandDomainSourceActionBaseassert 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.