beberlei / assert

Thin assertion library for use in libraries and business-model
Other
2.41k stars 188 forks source link

Resource and integerish #206

Closed manuxi closed 7 years ago

manuxi commented 7 years ago

Please try Assertion::integerish(fopen(FILE, 'r')); Works but should not.

rquadling commented 7 years ago

Well, PHP's type juggling of a resource to non zero...

php -r 'var_dump(fopen("./index.php","r"));' : resource(5) of type (stream) php -r 'var_dump((int)fopen("./index.php","r"));' : int(5)

So, the resource number is integer-ish ...

Interesting issue. I wonder how many people are asserting that resources are integer-ish and are happy with it.

rquadling commented 7 years ago

Thank you for the report. Fixed in https://github.com/beberlei/assert/releases/tag/v2.7.3

manuxi commented 7 years ago

Wow, that was fast ;) Thank you!