本文整理汇总了PHP中Object::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::__set方法的具体用法?PHP Object::__set怎么用?PHP Object::__set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::__set方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test___set01
public function test___set01()
{
$item = new Object();
$value = 'bar';
$item->__set('foo', $value);
$this->assertEquals($value, $item->__get('foo'));
}
示例2: lcfirst
function __set($name, $value)
{
$prop = lcfirst($name);
if (in_array($prop, self::$Allowed)) {
return $this->SetProperty($prop, $value);
}
return parent::__set($name, $value);
}
示例3: __set
public function __set($key, $value)
{
if (isset($this->_setters[$key])) {
$this->{$this->_setters[$key]}($value);
} else {
parent::__set($key, $value);
}
}
示例4: __set
public function __set($name, $value)
{
if (!isset($this->{$name})) {
$this->other[$name] = $value;
return $value;
}
return parent::__set($name, $value);
}
示例5: __set
/**
* Shorthand to set the value of an inaccessible property.
*
* @param string $name the name of the property.
* @param mixed $value The value of the property
*/
public function __set($name, $value)
{
try {
$property = $this->reflector->getProperty($name);
$property->setAccessible(true);
$property->setValue($this->object, $value);
} catch (ReflectionException $e) {
return $this->object->__set($name, $value);
}
}
示例6: __set
public function __set($key, $value)
{
if ($key == 'row') {
$value = (int) $value;
foreach ($this->cells as $column => $cell) {
$this->cells[$column]->row = $value;
}
}
parent::__set($key, $value);
}
示例7: foreach
/**
* Allow adding properties in the "construct" fase.
*
* @param string|array $property
* @param mixed $value
*/
function __set($property, $value = null)
{
if (is_array($property)) {
$state = $this->_state;
$this->_state = 'construct';
foreach ($property as $name => $value) {
$this->{$name} = $value;
}
$this->_state = $state;
return;
}
if ($this->_state === 'construct') {
$this->{$property} = $value;
} else {
parent::__set($property, $value);
}
}
示例8: __set
/**
* Sets user data value.
* @param string property name
* @param mixed property value
* @return void
*/
public function __set($key, $value)
{
if ($key === 'name' || $key === 'roles') {
parent::__set($key, $value);
} else {
$this->data[$key] = $value;
}
}