Task #98519
closedUninitialized properties in DebuggerUtility
100%
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