[TYPO3-core] RFC: is_array check extension manager

Ernesto Baschny [cron IT] ernst at cron-it.de
Wed Aug 15 11:35:53 CEST 2007


Hi,

I must agree with Franz here. is_array already does an implicit "isset",
so it is redundant to check for both. This is not documented anywhere
explicitly, but can be extracted from the is_array documentation fragment:

	"Returns TRUE if var is an array, FALSE otherwise."

If "var" is not even defined, it will also return FALSE (and NO warning,
as Franz already demonstrated).

I think it is always sufficient just to check the one item we are
wanting to loop. In this case:

if (is_array($conf['constraints']['conflicts'])) { ... }


Cheers,
Ernesto

Michael Stucki wrote: on 15.08.2007 08:51:
> No because he loops over $conf['constraints']['conflicts'].
> 
> $conf['constrains'] can be an array while still there might be no 
> $conf['constraints']['conflicts']! So checking this first using isset is the 
> only right thing to do.
> 
> Please double-check such tiny issues before writing to this list.
> 
> - michael
> 
> Franz Holzinger wrote on Wednesday 15 August 2007:
>> Hello Wolfgang,
>>
>> this is the wrong isset item I think:
>>
>> if (isset($conf['constraints']['conflicts']) &&
>> is_array($conf['constraints']['conflicts'])) {
>>
>> It should be like this:
>>
>> if (is_array($conf['constraints']) &&
>> is_array($conf['constraints']['conflicts'])) {
>>
>>>>> as this bugs me every now and then
>>>>> here's a patch that adds some is_array checks before
>>>>> foreach (should be common practice ;-))
>>  - Franz
>> _______________________________________________
>> TYPO3-team-core mailing list
>> TYPO3-team-core at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-core


More information about the TYPO3-team-core mailing list