hi Andrea,

On Sun, Jul 13, 2014 at 3:57 AM, Andrea Faulds <a...@ajf.me> wrote:
> Good evening,
>
> PHP’s type hinting system is rather incomplete as it does not support 
> scalars, only arrays, callables and objects. In 2012, Anthony Ferrara created 
> an RFC which proposed type hinting for scalar types (int, float, bool, string 
> and resource) with casting, with behaviour nearly the same as that of 
> zend_parse_parameters. Sadly, he later left PHP internals and withdrew his 
> RFCs.
>
> Since I am very much in favour of scalar type hints, I’ve updated the patch 
> to master and made some minor improvements, and I am re-opening the RFC with 
> the intent to try and get it into PHP 5.7. The patch is mostly there. It 
> needs some more tests and there are some edge cases I need to deal with, but 
> it otherwise works, and I expect I can finish fixing it up very soon.
>
> The RFC is here: https://wiki.php.net/rfc/scalar_type_hinting_with_cast
>
> A pull request is here: https://github.com/php/php-src/pull/717
>
> I’m hoping I can get this into PHP 5.7. I think scalar type hinting would be 
> a valuable addition to PHP’s existing type hinting system.

very nice work, thanks!

Some comments or wishes. I know these points have been discussed
already in the other threads but I still think it is worth posting
that here and (re) consider it.

To me argument types handling should match what we already do for
classes, strict handling. I asked many users at various conferences or
large companies using PHP and this is also what they wish. Indeed I am
not saying that all users wish that (who am I to say that? :) but I
feel like there is a large majority expecting this behavior.

The argument saying that it is not the PHP way is somehow incorrect
here, given that we already do that for classe. The type jungling
makes sense in implementations, as it always was but argument passing
and validation have been a source of pain since very long. I could
imagine one exception with the "numeric" type, which could accept
anything and got converted to integer/numeric values, like "1235ab" or
other weird things.


Cheers,
-- 
Pierre

@pierrejoye | http://www.libgd.org

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

Reply via email to