oop - PHP protected java style -
i have functionality need shared few classes manage common aspect of software. in java, have theses classes in same package , common functionality in protected method in helper class.
in php, protected method mean can use in sub-classes current solution make method protected , have classes needing method extend helper class. problem current solution fact can't inherit multiple classes lets need helper classes, im ...
so, is there way have method visibility comparable java protected in php? if not, cleaner way solve problem?
it sounds looking use traits.
http://php.net/manual/en/language.oop5.traits.php
this let define shared protected method , provide classes require it. recommend implementing interface can specify method provided trait has there.
php lets extend 1 abstract class can implement multiple interfaces.
Comments
Post a Comment