note 59028 deleted from language.oop5.typehinting by bjori
| From: | bjori@php.net | Date: | Fri, 14 Apr 2006 14:55:11 +0000 |
| Subject: | note 59028 deleted from language.oop5.typehinting by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108080@lists.php.net to get a copy of this message | ||
Note Submitter: mg at memedia dot de
----
NOTE:
Doesn't work with strings!
--
SOURCE:
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
--
OUTPUT:
Tasty::mustBeArray
Tasty::testType
string
Fatal error: Argument 1 passed to Tasty::mustBeString() must be an object of class String