On Thu May 27 11:22 AM, David Soria Parra wrote:
> On 2010-05-27, Zeev Suraski <z...@zend.com> wrote:
> +1 from me for this. I think two solutions is not the right way and we 
> +should
> try to make the type system consistent for the user. Therefore +1 for 
> auto-converting.

I still feel the debate of the "right way" is still open, say I have the
following class:
 
class Tax {
    /**
     * Apply a tax rate or {...@link getRatesApply() tax rates} to a given
amount and get the total tax.
     *
     * @param string|float        $amount
     * @param string|float|array  $rates      Tax rate or an array of tax
rates
     * @param int                 $precision  Rounding precision
     *
     * @return string
     */
        static function apply($amount, $rates, $precision = 2) {}
}

Strict typing would allow:

static function apply($amount, $rates, int $precision = 2) {}

Type hinting would allow:

static function apply(string $amount, $rates, int $precision = 2) {}

This is far from consistent to the user, the syntax is identical to *strict
typing* in many (if not all) dynamic programming languages. 
I would much prefer to see a 'type hint' where magical conversion happens
as:

static function apply((string) $amount, $rates, (int) $precision = 2) {}






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

Reply via email to