Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. interface SomeObjectInterface
  2. {
  3.     public function create(): ?SomeObject;
  4.     public function action();
  5. }
  6.  
  7. class SomeObject implements SomeObjectInterface
  8. {
  9.     ...
  10. }
  11.  
  12. $object = new SomeObject;
  13. //Тут что-то пошло не так и вместо объекта вернулся null.
  14. $initializedObject = $object->create();
  15. //Fatal error: Uncaught Error: Call to a member function action() on null
  16. $initializedObject->action();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement