Project

General

Profile

Actions

Task #98519

closed

Uninitialized properties in DebuggerUtility

Added by Mario Lubenka over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
Start date:
2022-10-04
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
extbase, debug, debugger, php
Complexity:
easy
Sprint Focus:

Description

DebuggerUtility:var_dump is commonly used to debug PHP classes.
In the latest PHP versions it is recommended to use typed properties in PHP classes.
Hardening PHP classes via typed properties ensures type safety at runtime.

class MyClass {
  protected array $myArray;
  protected \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe;

  __constructor(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe) {
    $this->tsfe = $tsfe;
  }
};

Typed properties have to states: initialized and uninitialized. All typed properties are uninitialized until a value is assigned.
That's usually the case in constructors, but it may also happen at runtime.

Objects with uninitialized typed properties throw an exception when passed into DebuggerUtility::var_dump:

$test = new class {
  protected \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe;
};
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($test);

Expected behaviour

As the DebuggerUtility is intended for development purposes, uninitialized variables should not break the website.
Instead, a label "uninitialized" should be attached to the property so the developer can do the intended debugging but still knows about uninitialized variables.


Files

error.png (82.2 KB) error.png Mario Lubenka, 2022-10-04 11:50
suggested_fix.png (15.4 KB) suggested_fix.png Mario Lubenka, 2022-10-04 11:53
Actions #1

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75981

Actions #2

Updated by Gerrit Code Review over 1 year ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75981

Actions #3

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75981

Actions #4

Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75981

Actions #5

Updated by Gerrit Code Review over 1 year ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75981

Actions #6

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76053

Actions #7

Updated by Mario Lubenka over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF