本文整理汇总了PHP中Nette\Utils\ObjectMixin::strictCall方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectMixin::strictCall方法的具体用法?PHP ObjectMixin::strictCall怎么用?PHP ObjectMixin::strictCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\ObjectMixin
的用法示例。
在下文中一共展示了ObjectMixin::strictCall方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
/**
* @return mixed
* @throws MemberAccessException
*/
public function __call($name, $args)
{
$class = get_class($this);
$isProp = ObjectMixin::hasProperty($class, $name);
if ($name === '') {
throw new MemberAccessException("Call to class '{$class}' method without name.");
} elseif ($isProp === 'event') {
// calling event handlers
if (is_array($this->{$name}) || $this->{$name} instanceof \Traversable) {
foreach ($this->{$name} as $handler) {
Callback::invokeArgs($handler, $args);
}
} elseif ($this->{$name} !== NULL) {
throw new UnexpectedValueException("Property {$class}::\${$name} must be array or NULL, " . gettype($this->{$name}) . ' given.');
}
} elseif ($isProp && $this->{$name} instanceof \Closure) {
// closure in property
trigger_error("Invoking closure in property via \$obj->{$name}() is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
return call_user_func_array($this->{$name}, $args);
} elseif (($methods =& ObjectMixin::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) {
// magic @methods
trigger_error("Magic methods such as {$class}::{$name}() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
list($op, $rp, $type) = $methods[$name];
if (count($args) !== ($op === 'get' ? 0 : 1)) {
throw new InvalidArgumentException("{$class}::{$name}() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.');
} elseif ($type && $args && !ObjectMixin::checkType($args[0], $type)) {
throw new InvalidArgumentException("Argument passed to {$class}::{$name}() must be {$type}, " . gettype($args[0]) . ' given.');
}
if ($op === 'get') {
return $rp->getValue($this);
} elseif ($op === 'set') {
$rp->setValue($this, $args[0]);
} elseif ($op === 'add') {
$val = $rp->getValue($this);
$val[] = $args[0];
$rp->setValue($this, $val);
}
return $this;
} elseif ($cb = ObjectMixin::getExtensionMethod($class, $name)) {
// extension methods
trigger_error("Extension methods such as {$class}::{$name}() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
return Callback::invoke($cb, $this, ...$args);
} else {
ObjectMixin::strictCall($class, $name);
}
}
示例2: __call
public function __call($name, $args)
{
if (method_exists(ClassType::class, $name)) {
trigger_error("getReflection()->{$name}() is deprecated, use Nette\\Reflection\\ClassType::from(\$presenter)->{$name}()", E_USER_DEPRECATED);
return call_user_func_array([new ClassType($this->getName()), $name], $args);
}
Nette\Utils\ObjectMixin::strictCall(get_class($this), $name);
}
示例3: __call
public function __call($name, $args)
{
if ($callback = Nette\Utils\ObjectMixin::getExtensionMethod(__CLASS__, $name)) {
return $callback($this, ...$args);
}
Nette\Utils\ObjectMixin::strictCall(__CLASS__, $name);
}