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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Gerrit Code Review over 2 years 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
Updated by Mario Lubenka over 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset daaffe231c582f33b1f045722882493e5f3e9be7.