Project

General

Profile

Actions

Task #98091

closed

[T3DD22] Cleanup: Refactor and simplify array access

Added by Tizian Schmidlin over 2 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Code Cleanup
Target version:
-
Start date:
2022-08-05
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
Sprint Focus:

Description

The core is littered with "useless" statements, checking if a variable that maybe is not initialized is an array, like this:

if (is_array($var['key']) && is_array($var['key']['subKey']) {
    foreach ($var['key']['subKey'] as $v) {
        // ...
    }
}

This can, if the source of the variable is trustworthy, be simpified:

foreach ($var['key']['subKey'] ?? [] as $v) {
    // ...
}
Trustworthy sources might be:
  • signed functions or methods
  • methods that are not properly signed, but internally enforce the advocated return type
  • typoscript arrays with a dot-index (e.g. $conf['includeCss.']
Untrustworthy sources might be:
  • content based values
  • potentially faulty extension configurations
  • values from flexform fields
  • anything that might not come from a core extension
Actions

Also available in: Atom PDF