The phpstan job reports three nullCoalesce.unnecessary errors on 4.x. The rule fires where the left operand of ?? can never be undefined, which makes coalescing it to a literal NULL a no-op:

  • domain/src/Form/DomainForm.php:111: $id = $domain->id() ?? NULL;
  • domain/src/Hook/DomainThemeHooks.php:50: $string = $config->get('css_classes') ?? NULL;
  • domain_config_ui/tests/src/Kernel/DomainConfigEditContextTest.php:157: $override_factory->getStorage('example_com')->read('system.site')['slogan'] ?? NULL

No module change caused this. The previous 4.x pipeline passed phpstan on the same code, and the job installs the latest phpstan, so the finding comes from a phpstan release. The job is allow_failure, so the pipeline as a whole stays green.

Proposed resolution

Delete the ?? NULL on those three lines. Note that the rule is about undefined-ness, not nullability: a method call is always set, whereas a possibly undefined array offset is not. The module has eight other ?? NULL occurrences, all of them guarding possibly undefined offsets, and none of those are flagged, so this should not be applied mechanically.

The 3.x branch carries the same three expressions, so it needs the same fix.

Issue fork domain-3613847

Command icon 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:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

  • mably committed 2bd32e76 on 3.0.x
    task: #3613847 Fix phpstan: Coalesce operator ?? is unnecessary because...

  • mably committed c5c53f7d on 2.0.x
    task: #3613847 Fix phpstan: Coalesce operator ?? is unnecessary because...

  • mably committed 43682980 on 3.x
    task: #3613847 Fix phpstan: Coalesce operator ?? is unnecessary because...

  • mably committed 01fd37b7 on 4.x
    task: #3613847 Fix phpstan: Coalesce operator ?? is unnecessary because...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.