> So the question is only whether "+0" or "-0" (or "+0", etc.) should be
> accepted as integers by FILTER_VALIDATE_INT. I think they should,
> because
> we also accept non-canonical inputs such as "+5", i.e., we always
> accept a
> sign. It's true that 0 is neither positive or negative, but I don't
> think
> "accepts a leading sign, except if it's 0" is a good option. It's an
> unnecessary special case.

I was misguided by two statements, I'm sorry.

The 1st: In my opinion FILTER_VALIDATE_INT must work like var_dump(-0); (BR 
#54096)
The 2nd: "Treat "+0" and "-0" as valid integers just like var_dump() does." 
(https://github.com/php/php-src/pull/248)

Both statements are wrong, since the purpose of the filter extension is to 
validate strings. I found this information in BR #52884 (see last comment). 
Maybe it should be added to the docs? It's nonsense to say, that 
FILTER_VALIDATE_INT must work like var_dump() since they are both serving 
different purposes.

With this information I agree on your opinion.

var_dump(filter_var('-0',FILTER_VALIDATE_INT)); // int(0) instead of the prior 
bool(false)
var_dump('-0'); // string(2) "-0"
var_dump(is_int('-0')); // bool(false)


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to