當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectMixin::strictCall方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:nette,項目名稱:utils,代碼行數:50,代碼來源:SmartObject.php

示例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);
 }
開發者ID:hrach,項目名稱:nette-application,代碼行數:8,代碼來源:ComponentReflection.php

示例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);
 }
開發者ID:nette,項目名稱:finder,代碼行數:7,代碼來源:Finder.php


注:本文中的Nette\Utils\ObjectMixin::strictCall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。