Пример #1
0
    public function get()
    {
       return  $this->_some;
    }
}

trait Call
{
    public function __call($method, $args)
    {
        $reflection = new ReflectionObject($this);
        foreach ($reflection->getProperties() as $property) {
            $transformedPropertyName = str_replace('_', '', $property->getName());
            $property->getName();
            current($args);
        }
    }
}

class A {
    use Hello, Call;

    protected $_name = '';
}

$a = new A();
$a->set('cal');
$a->get();
$a->setName('Jo');

Пример #2
0
trait Validators
{
    private function _isStringValidator($value)
    {
        return is_string($value);
    }
}

class A
{
    use Mapping, Validators;

    /**
     * @var string
     */
    protected $_name = '';

    /**
     * @var string
     */
    protected $_message = '';
}

$a = new A();
$a->setMessage('test');
var_dump($a->getMessage());
$a->setName('bill');
var_dump($a->getName());
$a->setName((string)123);