note 101896 added to language.oop5.typehinting
| From: | JeffLee at osu1 dot php dot net | Date: | Mon, 17 Jan 2011 00:43:00 +0000 |
| Subject: | note 101896 added to language.oop5.typehinting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175810@lists.php.net to get a copy of this message | ||
If you are have a namespaced interface that uses type-hinting, please make sure that your type-hints
are fully-qualified, *even* if the types are primitive.
NOTE: The following example uses regular slashes for namespaces rather than backslashes, because the
note system does not seem to render backslashes.
File A:
<?php
namespace NS1;
interface IFoo
{
public function DoSomething( /int $arg );
}
?>
File B:
<?php
namespace NS2;
class Foo implements /NS1/IFoo
{
public function DoSomething( /int $arg );
}
?>
Note that I had to use the "\" global namespace prefix on the "int" type hints.
Failure to do so will raise an incompatibility error.
This does not appear to be necessary for the "array" basic type, which strikes me as a
bug, or at least a flagrant inconsistency.
FYI, I'm using PHP 5.3.1.
----
Server IP: 208.69.120.55
Probable Submitter: 76.95.102.56
----
Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php
Edit -- https://master.php.net/note/edit/101896
Del: integrated -- https://master.php.net/note/delete/101896/integrated
Del: useless -- https://master.php.net/note/delete/101896/useless
Del: bad code -- https://master.php.net/note/delete/101896/bad+code
Del: spam -- https://master.php.net/note/delete/101896/spam
Del: non-english -- https://master.php.net/note/delete/101896/non-english
Del: in docs -- https://master.php.net/note/delete/101896/in+docs
Del: other reasons-- https://master.php.net/note/delete/101896
Reject -- https://master.php.net/note/reject/101896
Search -- https://master.php.net/manage/user-notes.php