for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Analogue\ORM;
/**
* This trait assumes that the MagicGetters trait is used as well.
*/
trait MagicSetters
{
* Dynamically set attributes on the entity.
*
* @param string $key
* @param mixed $value
* @return void
public function __set($key, $value)
$this->attributes[$key] = $value;
attributes
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Unset an attribute on the entity.
public function __unset($key)
unset($this->attributes[$key]);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: