|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-11-24 13:26 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 07:00:01 2025 UTC |
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