On 15/01/2015 15:31, Pavel Kouřil wrote:
On Thu, Jan 15, 2015 at 4:19 PM, Jordi Boggiano <j.boggi...@seld.be> wrote:

Right now, or with only weak hints, if a library decides to implement strict
typing, they'll skip the scalar hints and check types with something like
the assert lib [1]. A user calling it with random data would *always* get
exceptions. There is no way for the library to use scalar hints to play nice
with weak-typed callers as it would not be able to type check anymore in
that case.


Why would the libraries writers use the checks inside the method
instead of the typing, even in the case of the weak typing? I don't
see a single reason to do so, because if they ask for an "int" in the
method signature, they will get an int or the method won't get called
at all. See the example in the RFC with the "if (!is_int($i))".

I mean that if someone wants strict typing they won't want to use weak hints because that would coerce the data before they can verify it and ensure their code is strictly typed.

Therefore the best course of action is to have no hint + check manually, like they are doing now with such libs.

Cheers

--
Jordi Boggiano
@seldaek - http://nelm.io/jordi

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

Reply via email to