On 09/03/2017 17:37, Fleshgrinder wrote:
On 3/9/2017 3:18 AM, Stanislav Malyshev wrote:
I don't think it's right approach. is_* functions check the current type
of the value, not whether it can be converted to another type. If we
need ones that express the latter, we should have different functions.
Also, as already noted, having __toString doesn't mean it returns
something useful.
This is not true at all:
1. is_dir
2. is_executable
3. is_file
4. is_finite
5. is_infinite
6. is_link
7. is_nan
8. is_readable
9. is_resource (checks the resource's type too)
10. is_uploaded_file
11. is_writable
I think a good example is "is_callable", which evaluates not the *type*
of the value, but the *possible behaviour*. You could think of
Closure::fromCallable($foo) as "cast $foo to Closure", in which case
is_callable($foo) is "can $foo be cast to Closure?" (at least, in it's
default behaviour).
This is then much more similar to defining is_stringable($foo) to return
true for everything that can be cast to string.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php