> For me personally it makes zero sense that having just removed strict typing
> we are introducing it back through back door, but if everybody likes it so
> be it.

It's strict typing to have a type-hint that can be matched by 4
different constructs (string function names, arrays, closures,
invokable classes)?  Basically anything that would succeed in
call_user_func would be allowed to pass...?  There's no "dynamic
typing" that I'm aware of that this would prevent.  Either it's
callable, or it's not.  No casting or silent type conversion is going
to change that.

So it's not making typing stricter at all.  All it does is allow you
to say "I want this parameter to be able to be directly called".
*What* form of call you give it doesn't matter one bit.  So in a
sense, it's like having a String type-hint that casts if it can, but
throws an error if it can't (Ex: an object without __toString).  This
will allow if there's a way to call it, and throw an error if not.

I'm all for this addition.  +1

On Tue, Jun 7, 2011 at 3:12 PM, Stas Malyshev <smalys...@sugarcrm.com> wrote:
> Hi!
>
>> https://wiki.php.net/rfc/callable
>
> It is good there's an RFC. However it seems to lack code examples. I
> understand it may be obvious to the proposers how it looks like, but it'd be
> nice to have the actual example there as it is done nearly everywhere else.
>
> The patch introduces new zval type IS_CALLABLE but zval functions weren't
> updated for it - IIRC at least dtor may end up being called on IS_CALLABLE
> value produced in the parser.
>
> Note also that this pseudo-type is called "callback" in all of our
> documentation, which means we have now documentation that says:
>
> bool array_walk ( array &$array , callback $funcname [, mixed $userdata ] )
>
> and type check that says "callable".
>
> Also, it is not clear what would happen if this type check is made against
> method which is not accessible (e.g. private out of scope). Would it say
> that the argument is invalid (which would be really confusing since it'd say
> something like "callable expected, array given" which it technically correct
> but doesn't explain why this array is not callable) or would allow it? If
> not, then zend_is_callable error information should be used and displayed.
> And the tests need to cover these cases, along with __call and __callStatic.
>
>
> For me personally it makes zero sense that having just removed strict typing
> we are introducing it back through back door, but if everybody likes it so
> be it.
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

Reply via email to