[TYPO3-core] RFC #0016467 Missing array check in tt_content

Ernesto Baschny [cron IT] ernst at cron-it.de
Fri Nov 19 11:09:10 CET 2010


Jigal van Hemert schrieb am 19.11.2010 09:39:

> On 18-11-2010 15:27, Bjoern Pedersen wrote:
>> Problem: a count check is not sufficent to check for an array.
>> Solution:
>> add is_array check
> 
> Since the method is defined as
> 
> public function stdWrap($content = '', $conf = array()) {
> 
> wouldn't it be better to force $conf as an array:
> 
> public function stdWrap($content = '', array $conf = array()) {
> 
> Or will too much code collapse which calls stdWrap with other types of
> variables? The advantage is that we don't have to perform "expensive"
> checks for this kind of situation.
> Opinions of core devs and RMs on this?

This is not recommended since it breaks more than it helps.

This has been discussed before for some other method with the same
problem (I don't recall which one..), and it was at the end of *much*
debate decided to keep the API from breaking and handle the checking
inside the function.

One might say "the calling party should know, the API is documented as
expecting an array() and its their fault if it breaks when passing other
stuff". In that other case the extension that broke was pretty heavily
used, which is why this signature was reverted again (it passed an
uninitialized variable as a parameter, which is considered "NULL" and
which is not not compatible with the signature "array").

The "de-facto-API" is more or less what our TYPO3 PHP classes allows us
and what is used "in the field".

PHP itself for example also added lots of strict checking to parameters
in 5.3, but these are handled as "Warnings". We should do it similarly
and handle that with "deprecationLog()".

Cheers,
Ernesto


More information about the TYPO3-team-core mailing list