Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author you
- */
- abstract class A
- {
- abstract public function a (); //this is a contract
- }
- /**
- * @author someone else
- */
- abstract class B extends A
- {
- abstract public function a ($t = false);
- }
- /**
- * @author someone else
- */
- class ConcreteA extends A
- {
- public function a()
- {
- //do something
- }
- }
- /**
- * @author someone else
- */
- class ConcreteB extends B
- {
- public function a($t = false)
- {
- //do something
- }
- }
- /**
- * For handling A's
- * @author you
- */
- class AHandler
- {
- public function doA(A $object)
- {
- $object->a();
- }
- }
- //someone elses code...
- $obj1 = new ConcreteB();
- $obj2 = new ConcreteA();
- //your code
- $handler = new AHandler();
- $handler->doA($obj2); //works fine
- $handler->doA($obj1); //typehint works fine, so probably something like "call to undefined method a"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement