<?php
trait TraitName{
protected $name;
abstract protected function setName();
public function __construct(){
$this->setName();
}
public function getName(){
return $this->name;
}
}
class MyClass{
use TraitName{
TraitName::__construct as private __traitConstruct;
}
protected function setName(){
$this->name = __CLASS__;
}
public function __construct(){
$this->__traitConstruct();
}
}
$objMyClass = new MyClass();
echo $objMyClass->getName();