-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For the record, I'm all for it. Optionality means flexibility. If one
doesn't want to use it, he doesn't have to.

Can you send a patch against 5.3 in CVS?

Have you thought about type hinting for return values?

thanks,
- - Markus

Sam Barrow wrote:
> A few weeks ago I wrote a message on this list about my patch for scalar
> type hinting. I've been using it for about a month now in a large scale
> application im developing with no problems. It allows type hinting for
> the following types: int, float, string, bool (boolean), num (int or
> float), scalar (int, float, string, or bool), object, and resource.
> 
> All of these types have been very useful. Num has been useful for any
> mathematical functions, scalar has been the most useful, mostly for
> echoing values and interacting with the database (as a database cant
> store arrays or objects).
> 
> The type hinting is all 100% optional and has caused no problems for me
> at all, I use it in most function but some functions I'll use it for one
> parameter and not the other, or none at all with no problems.
> 
> What is the general opinion on this? Examples below:
> 
> <?php
> 
> function multiply(num $a, num b) {
>       return $a * $b ;
> }
> 
> multiply(5, 1) ; // works
> 
> multiply(3.7, 8.2) // works
> 
> multiply("foo", 5) ; // Catchable fatal error: Argument 1 passed to
> multiply() must be a number, string given
> 
> function displayStuff(scalar $stuff) {
>       echo $stuff ;
> }
> 
> displayStuff('Hello!') ; // works
> 
> displayStuff(123) ; // works
> 
> displayStuff(array('a' => 'b')) ; // Catchable fatal error: Argument 1
> passed to displayStuff() must be a scalar, array given
> 
> ?>
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHXv8e1nS0RcInK9ARApVaAJ9vwTTVdH+HNENA64wfaPbkyCyG9gCgrMuy
CD2xQpN43p0dlgPIiYm2Ckg=
=ZOm7
-----END PGP SIGNATURE-----

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

Reply via email to