note 101897 added to language.oop5.typehinting
| From: | jeffomatic at gmail dot com | Date: | Mon, 17 Jan 2011 00:43:20 +0000 |
| Subject: | note 101897 added to language.oop5.typehinting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175811@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/101897
Del: integrated -- https://master.php.net/note/delete/101897/integrated
Del: useless -- https://master.php.net/note/delete/101897/useless
Del: bad code -- https://master.php.net/note/delete/101897/bad+code
Del: spam -- https://master.php.net/note/delete/101897/spam
Del: non-english -- https://master.php.net/note/delete/101897/non-english
Del: in docs -- https://master.php.net/note/delete/101897/in+docs
Del: other reasons-- https://master.php.net/note/delete/101897
Reject -- https://master.php.net/note/reject/101897
Search -- https://master.php.net/manage/user-notes.php