<?php
class ObjetoSimples {
var $nome;
var $cargo;
var $turno;
public static function construtor($nome, $cargo, $turno) {
$obj = new ObjetoSimples();
$obj->nome = $nome;
$obj->cargo = $cargo;
$obj->turno = $turno;
return $obj;
}
}
class ObjetoComposto {
public static function construtor($nome, $setor, $nome2, $cargo, $turno) {
$obj = new ObjetoComposto();
$obj->nome = $nome;
$obj->setor = $setor;
$obj->equipe = new ObjetoSimples();
$obj->equipe->nome = $nome2;
$obj->equipe->cargo = $cargo;
$obj->equipe->turno = $turno;
return $obj;
}
public static function construtor2($nome, $setor, $obj2) {
$obj = new ObjetoComposto();
$obj->nome = $nome;
$obj->setor = $setor;
$obj->equipe = $obj2;
return $obj;
}
var $nome;
var $setor;
var $equipe;
}
$obj = new ObjetoSimples();
$obj->nome = "joao";
$obj->cargo = "gerente";
$obj->turno = "noite";
$obj2 = new ObjetoComposto();
$obj2->nome = "maria";
$obj2->setor = "fabrica";
$obj2->equipe = $obj;
$obj3 = ObjetoComposto::construtor("maria", "fabrica", "joao", "gerente", "noite");
$obj4 = ObjetoComposto::construtor2("maria", "fabrica", ObjetoSimples::construtor("joao", "gerente", "noite"));
PD9waHAKY2xhc3MgT2JqZXRvU2ltcGxlcyB7CiAgIHZhciAkbm9tZTsKICAgdmFyICRjYXJnbzsKICAgdmFyICR0dXJubzsKICAgcHVibGljIHN0YXRpYyBmdW5jdGlvbiBjb25zdHJ1dG9yKCRub21lLCAkY2FyZ28sICR0dXJubykgewoJICAgCSRvYmogPSBuZXcgT2JqZXRvU2ltcGxlcygpOwogICAgCSRvYmotPm5vbWUgPSAkbm9tZTsKICAgICAJJG9iai0+Y2FyZ28gPSAkY2FyZ287CiAgICAJJG9iai0+dHVybm8gPSAkdHVybm87CiAgICAJcmV0dXJuICRvYmo7CiAgIH0KfQoKY2xhc3MgT2JqZXRvQ29tcG9zdG8gewogICAgcHVibGljIHN0YXRpYyBmdW5jdGlvbiBjb25zdHJ1dG9yKCRub21lLCAkc2V0b3IsICRub21lMiwg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