Hi!

> The answer - which is definitely a matter of opinion - is that allowing 
> any string reduces the usefulness of the type hint.

IMO, having consistent rules is much more, orders of magnitude more
important than serving any particular use case. We will always have use
cases in which any particular check would not be enough. We should not
sacrifice the simplicity of the language to try and capture every one of
them.

> In fact, I'd find the behaviour more obvious if it were written 
> some_func((bool)$foo & BIT_FLAG) - it makes clear that some_func is not 
> itself aware of the flag, that's just the caller's way of making the 
> decision. That the type hint encouraged that would therefore seem like a 
> Good Thing.

What you want is strict typing then. And if() working the same way -
after all, if function can be unaware of the flag, if() is definitely
unaware of it. So you'll always have to write if(($foo & BIT_FLAG) !=
0). Some would say it's an improvement. I am not among them. If you want
to enforce code style, we already have tools for that, but I don't think
this particular one should be in the language.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/

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

Reply via email to