note 108178 added to language.oop5.interfaces
| From: | treii28 at gmail dot com | Date: | Wed, 04 Apr 2012 22:02:46 +0000 |
| Subject: | note 108178 added to language.oop5.interfaces | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186974@lists.php.net to get a copy of this message | ||
I just learned that you can cast a function using an abstract interface definition rather than
referring to a specific class that implements it. e.g.:
interface myInterface
{
public function someFunction();
}
class myClassA implements myInterface
{
public function someFunction() {
// does something
}
}
class myClassB
{
public function castFunction(myInterface $obj) {
// do something with object
}
}
This will be VERY useful for abstraction as I don't have to name specific implementations of an
interface, but can instead just use the interface to verify whatever object it is that is being
passed in still has expected functionality.
My question now is, is there any way you can cast using multiple interfaces?
----
Server IP: 69.147.83.197
Probable Submitter: 173.13.3.241
----
Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php
Edit -- https://master.php.net/note/edit/108178
Del: integrated -- https://master.php.net/note/delete/108178/integrated
Del: useless -- https://master.php.net/note/delete/108178/useless
Del: bad code -- https://master.php.net/note/delete/108178/bad+code
Del: spam -- https://master.php.net/note/delete/108178/spam
Del: non-english -- https://master.php.net/note/delete/108178/non-english
Del: in docs -- https://master.php.net/note/delete/108178/in+docs
Del: other reasons-- https://master.php.net/note/delete/108178
Reject -- https://master.php.net/note/reject/108178
Search -- https://master.php.net/manage/user-notes.php