#38128 [Opn->WFx]: Add scalar-type hinting

From: Date: Tue, 18 Jul 2006 06:45:17 +0000
Subject: #38128 [Opn->WFx]: Add scalar-type hinting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-99557@lists.php.net to get a copy of this message
 ID:               38128
 Updated by:       helly@php.net
 Reported By:      obluda dot x at seznam dot cz
-Status:           Open
+Status:           Wont fix
 Bug Type:         Feature/Change Request
-Operating System: all
+Operating System: *
-PHP Version:      5CVS-2006-07-18 (CVS)
+PHP Version:      *
 New Comment:

Ressource and Object typehinting are the only types we probably add in
some future. But we discussed and disagreed to the others already.
There is no need and it actually would contradict the php way where all
variables are casted as needed.


Previous Comments:
------------------------------------------------------------------------

[2006-07-18 05:55:28] obluda dot x at seznam dot cz

Description:
------------
Currently, only object and array arguments of a function can be hinted.
However, if you can't hint non-class/non-array argument, you have to
leave argument unhinted, which allows passing of class/array besides of
scalar types.

I propose adding new type-hinting keyword 'scalar', which matches
complement to currently possible hints. Think also about 'resource'
hint.

Reproduce code:
---------------
<?php
        function show ( scalar $string ) {
                echo $string;
        }
        show("hello\n");
        show(new stdClass());
?>

Expected result:
----------------
hello
Error...



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38128&edit=1


Thread (2 messages)

« previous php.bugs (#99557) next »