[BUGFIX] Prefer to throw in IdentifierFunctionLine
There is a subtle difference between a PHP error and a dedicated thrown exception: When an object knows it should return something, but can't, because it has not been set up correctly, then the implementation is responsible of throwing a "i'm incomplete" exception: This is not an error in the class, but a wrong set up usage, and this should throw, and should not error out with a return type mismatch error. The patch changes two getters of TS parser related IdentifierFunctionLine to obey this difference and now throws in case it "has been set up incompletely". In this case, an IdentifierFunctionLine is only "complete" after at least an identifier token stream and a function name token has been set: After being fully set up, these two properties must have a value. The object knows this and the two getters now throw an exception instead of failing with a type error. Resolves: #103977 Related: #97816 Releases: main, 12.4 Change-Id: I772d774fbaae3c2ec7ff4c9abc6ef4964254259d Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84496 Tested-by:core-ci <typo3@b13.com> Reviewed-by:
Christian Kuhn <lolli@schwarzbu.ch> Tested-by:
Christian Kuhn <lolli@schwarzbu.ch>
Showing
- typo3/sysext/core/Classes/TypoScript/Tokenizer/Line/IdentifierFunctionLine.php 11 additions, 5 deletions...sses/TypoScript/Tokenizer/Line/IdentifierFunctionLine.php
- typo3/sysext/core/Tests/Unit/TypoScript/Tokenizer/Line/IdentifierFunctionLineTest.php 16 additions, 0 deletions.../TypoScript/Tokenizer/Line/IdentifierFunctionLineTest.php
Please register or sign in to comment