[TYPO3-dev] behaviour of t3lib_div::testInt has been changed

JoH asenau info at cybercraft.de
Thu Sep 9 19:44:42 CEST 2010


>> Okay, you're right the function tells it tests intepretation as int,
>> not if it is an int :)
> 
> Before TYPO3 4.5 the function comment has been different:
> 
> * Tests if the input is an integer.
> 
> So I assume this change is wrong, because it changes the behaviour.

Well - the comment has been changed due to the fact that the function actually did NOT check if the input IS an integer.
It just converted the incoming value to an integer and then compared the result with the original value using strcmp.
So the incoming value could still have been a string, which is NOT an integer even though it looks like that - and which is the reason why is_int() wouldn't work in this case.

IMHO the comment AND the behaviour should be changed, so that
a) the function only recognizes values containing nothing else but integral numbers as "interpretable as integer"
b) the comment clearly states that behaviour

Just my 2 cents

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-dev mailing list