Re: type hinting

From: Date: Sun, 06 Jan 2008 21:43:19 +0000
Subject: Re: type hinting
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to internals+get-34552@lists.php.net to get a copy of this message
Hello Johannes, then obviously pass by reference and base type hints are not compatible. Apart from that so far in PHP it does not matter whether a variable changes in base type. And we should not change this nature of PHP. marcus Sunday, January 6, 2008, 10:03:44 PM, you wrote: > Hi, > On Sun, 2008-01-06 at 21:24 +0100, Marcus Boerger wrote: >> That said I would only agree to type hints if we make them respect existing >> PHP conversion rules. > Which we can't really do. Think about Mikko's example: > $b = '5'; > function foo( int &$a ) > { > echo gettype( $a ); > } > foo( $b ); > echo gettype( $b ); > Casting there would, for sure, create problems. Doing no cast fails when > thinking about Kore's example: > $ php -r 'var_dump( ~"1", ~1 );' > string(1) "?" > int(-2) > Or: > $ php -r 'var_dump( "1" ^ "2", 1 ^ 2 );' > string(1) "" > int(3) > I can see why people want it, but it won't really fit into PHP's type > system imo. > And about the part being "optional": As long as you only use your own > code it's optional, sure. But as soon as you use a library or maintain > code written by others it isn't optional anymore - while that of course > is true for all design decisions made by the previous devs. > johannes Best regards, Marcus

« previous php.internals (#34552) next »