Reduce thrown E_NOTICEs
Every time PHP tries to access an index of an array, which is not set, or a variable that is not defined PHP generated an E_NOTICE and uses NULL as resulting value.
This is bad because of three major reasons:
1. Bugs resulting from an invalid evaluation of the value are very hard to find.
2. You can not trust the type of the variable so you have to check it anywhere you use it.
3. Not checking keys is considered bad code.
And a lot of other (major and minor) reasons to check the key/variable before accessing it, including tiny performance improvements as a positive side effect.
Always check if the variable/key exists before accessing it.
If the value is not existent use the expected default value (e.g.: empty string, zero, null..)
How to work on this:¶
Edit UnitTests.xml in core/Build and set
stopOnFailure="true" as <phpunit> tag attributes.
Go to \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::initializeBasicErrorReporting and set
Run all unit tests. PHPUnit will halt on the first error.
Create a child issue on this ticket that combines some changes into logic units.
There shouldn't be more than 20 changes per patch to keep them simple and increase velocity. Smaller patches are getting approved and merged faster.
[TASK] Remove the first few E_NOTICEs occuring in the unit tests
PHP throws E_NOTICE when not existing array keys are accessed.
The received value will become null.
This patch aims to reduce the number of generated notices,
to increase readability and reliability of the changed methods.
Reviewed-by: Markus Klein <firstname.lastname@example.org>
Tested-by: Markus Klein <email@example.com>
Reviewed-by: Benni Mack <firstname.lastname@example.org>
Tested-by: Benni Mack <email@example.com>
[TASK] Provide correct data for DatabaseLanguageRowsTest
The dummy data provided in DatabaseLanguageRowsTest
leads to some E_NOTICEs.
This patch aims to provide the minimal correct set of dummy
data needed to run the affected tests without any E_NOTICE
Reviewed-by: Wouter Wolters <firstname.lastname@example.org>
Tested-by: Wouter Wolters <email@example.com>
Reviewed-by: Morton Jonuschat <firstname.lastname@example.org>
Tested-by: Morton Jonuschat <email@example.com>
[TASK] E_NOTICE reduction
Reduce number of E_NOTICE thrown by TYPO3
Reviewed-by: Jan Helke <firstname.lastname@example.org>
Tested-by: Jan Helke <email@example.com>
Tested-by: TYPO3com <firstname.lastname@example.org>
Reviewed-by: Christian Kuhn <email@example.com>
Tested-by: Christian Kuhn <firstname.lastname@example.org>