Php type hinting to object properties existance -
how can hint, argument receive must have several public properties?
like:
interface iperson { public $surname; public $name; } class { public function foo(iperson $p) { return $p->surname . ' ' . $p->name; } }
but since interfaces can't point variables (why?), behavior above possible in php?
may there in new php releases(5.5-7.0
)?
i think main issue php
type system, no has property
concept?
define getters in interface:
interface iperson { public function getsurname(); public function getname(); } class { public function foo(iperson $p) { return $p->getsurname() . ' ' . $p->getname(); } }
Comments
Post a Comment