3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Object { // protected $hasMany; protected $theSignificativeProperties = ['nome', 'login']; public function getHasMany() { return $this->hasMany; } public function getSignificativeProperties() { return $this->theSignificativeProperties; } } class Aluno extends Object { private $nome; private $login; protected $hasMany = ['post', 'disciplina']; protected $theSignificativeProperties = ['nome', 'login']; /*public function getHasMany() { return $this->hasMany; }*/ /*public function getSignificativeProperties() { return $this->theSignificativeProperties; }*/ } class Post extends Object { // } class Disciplina extends Object { protected $hasMany = ['aluno']; } class EntityManager { // } class RelationalEntityManager extends EntityManager { public function find() { // echo 'Usando o RelationalEntityManager.'; } } class BaseController { protected $objectService; public function __construct() { $this->objectService = new BaseObjectService(new RelationalEntityManager()); } public function view() { $args = func_get_args(); $this->objectService->view($args); } } class AlunoController extends BaseController { } class BaseObjectService { private $em; public function __construct(EntityManager $entityManager) { $this->em = $entityManager; } public function view($args) { // echo 'Argumentos: '; print_r($args); echo 'Classe em questão: '; echo get_class($this); print_r(); $this->em->find(); } } echo 'Aluno: ' . class_exists('Aluno') . '<br>'; echo 'Teste: '; var_dump(class_exists('Teste')) . '\n'; $a = new Aluno(); print_r ( $a->getSignificativeProperties() ); $alunoController = new AlunoController(); $alunoController->view('marcelo', 'boi', 1);

preferences:
47.07 ms | 402 KiB | 5 Q