Bug #23893
closedAdd type hints for function parameters in tslib_content
0%
Description
Functions in tslib_content do not have type hints for array or object parameters.
Problem: if you pass a string instead of an array PHP will try to index this string instead of using parts of the array. This will lead to errors about trying to use a string offset.
If a type hint is used there will be a clear error that the wrong type was used.
This was discussed with Joey Hasenau who has taken care of the restructuring of the stdWrap functions in tslib_content.
(issue imported from #M16194)
Updated by Ernesto Baschny almost 14 years ago
Has been discussed for some other methods already in the core list, and adding type hinting is nice but breaks compatibility, because this is the API we used to have. Most common problem is:
$conf meant to be an array()
But extensions passing "NULL" to it. This is not compatible with type hinting "array" and will generate a fatal error.
So that cleanup can only be done by deprecating all methods and introducing new ones, or simply ignoring this backwards compatibility problem, which I would like to postpone to 4.6. :)
Updated by Jigal van Hemert almost 14 years ago
function test (array $arg = NULL) {
allows NULL, unset variables and array to be passed as argument. Other types trigger an exception.
You need to test for NULL and set $arg to an empty array and you're backwards compatible with NULL values.
At least passing a string will not cause erratic behaviour because PHP will otherwise trying to index strings.
Updated by Jo Hasenau almost 14 years ago
Seems to be the same problem as #24462
Updated by Chris topher about 13 years ago
- Target version changed from 4.6.0 to 4.6.1
Updated by Chris topher almost 13 years ago
- Target version changed from 4.6.1 to 4.6.2
Updated by Benni Mack almost 10 years ago
- Status changed from New to Needs Feedback
- Is Regression set to No
Is this one still valid?
Updated by Alexander Opitz over 9 years ago
- Status changed from Needs Feedback to Closed
No feedback within the last 90 days => closing this issue.
If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.