[TYPO3-core] RFC #15020: Enhancement of t3lib_div::testInt

Steffen Kamper info at sk-typo3.de
Wed Jul 7 10:21:38 CEST 2010


Hi,

Dmitry Dulepov schrieb:
> Hi!
> 
> Michiel Roos [netcreators] wrote:
>> Problem:
>> t3lib_div::testInt can be optimized by making use of the PHP version of
>> testInt called: is_int.
> 
> I think there is an issue here. Here is the description of is_int from the
> PHP manual:
> 
> ==============
> Finds whether the type of the given variable is integer.
> Note: To test if a variable is a number or a numeric string (such as form
> input, which is always a string), you must use is_numeric().
> ==============
> 
> I just checked: is_int('5') gives false, while t3lib_div::testInt('5')
> gives true. The idea of the later is to see if the argument can be
> ~interpreted~ as integer while the former checks if it ~is~ integer. The
> difference is important.
> 
> -1 to the patch because it breaks the behavior. Sorry.
> 

it seems that t3lib_div::testInt was written for strings mainly.
The name of the function is misleading here.
What's about
return (intval($var) == $var);
?

vg Steffen


More information about the TYPO3-team-core mailing list