ID:               35363
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mg at memedia dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Various
 PHP Version:      5CVS-2005-11-24 (snap)
 New Comment:

No bug here.
Only arrays and classes can be used for typehinting.


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

[2005-11-24 12:50:36] mg at memedia dot de

Description:
------------
See above. Maybe there are als osome other variable types that doesn't
work. Actually I only see that Classes and Arrays work.

Anyway, llive could be easier if I wouldn't need to tell every function
to check for incoming variable types ;)

Reproduce code:
---------------
class Tasty {
    function mustBeArray(Array $test) {
        echo "Tasty::mustBeArray\n";
        return true;
    }
    function mustBeString(String $str) {
        print("Tasty::mustBeString\n");    
    }
    function testType($type){
        print("Tasty::testType\n");
        print(gettype($type)."\n");
    }
}
$t = new Tasty();
$t->mustBeArray(Array(1,2));
$t->testType((String)'test'); 
$t->mustBeString((String)'test'); // doesn't work


Expected result:
----------------
OUTPUT:

Tasty::mustBeArray
Tasty::testType
string
Tasey::mustBeString

Actual result:
--------------
OUTPUT:

Tasty::mustBeArray
Tasty::testType
string
Fatal error: Argument 1 passed to Tasty::mustBeString() must be an
object of class String


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


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

Reply via email to