Use null coalesce operator instead of ternary operator

Created on 17 February 2023, almost 2 years ago

Problem/Motivation

We can use the convert coalesce operator instead of the ternary operator is there is NULL or empty.

FILE: /var/www/html/web/modules/custom/ief_table_view_mode/ief_table_view_mode.module
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
 100 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/ief_table_view_mode/src/Form/EntityInlineTableViewModeForm.php
-----------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
 62 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------

Steps to reproduce

Run the below command,
phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml ief_table_view_mode

Proposed resolution

Before:

return isset($this->handlers['route_provider'][$entity_type_id]) ? $this->handlers['route_provider'][$entity_type_id] : [];

After:

return $this->handlers['route_provider'][$entity_type_id] ?? [];

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

2.0

Component

Miscellaneous

Created by

🇮🇳India arunkumark Coimbatore

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

Comments & Activities

Production build 0.71.5 2024