Enforce null coalescing operator ?? instead of a ternary operator through phpcs

Created on 8 May 2024, 5 months ago
Updated 23 May 2024, 5 months ago

Problem/Motivation

#3074131: Use null coalescing operator ?? instead of a ternary operator with an isset() condition landed, so we should enforce this. The change to null coallescing operator was already done in core a while back in #3222251: [November 8, 2021] Replace all isset constructs with the null coalescing operator . But now we need to enable SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator.

Steps to reproduce

Add SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator to phpcs.xml.dist and run codestle.

Proposed resolution

Add SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator to phpcs.xml.dist

Remaining tasks

Add SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator to phpcs.xml.dist
Fix possible violations

User interface changes

n.a.

API changes

n.a.

Data model changes

n.a.

Release notes snippet

Using null coalescing operator ?? instead of a ternary operator is now enforced in core.

📌 Task
Status

Fixed

Version

10.3

Component
Other 

Last updated about 11 hours ago

Created by

🇳🇱Netherlands bbrala Netherlands

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024