Commit eb4385d4 by Qiang Xue

improved error message of calling invalid scope method.

parent 8af989a8
......@@ -6,6 +6,7 @@
*/
namespace yii\db;
use yii\base\InvalidCallException;
/**
* ActiveQueryTrait implements the common methods and properties for active record query classes.
......@@ -42,6 +43,10 @@ trait ActiveQueryTrait
public function __call($name, $params)
{
if (method_exists($this->modelClass, $name)) {
$method = new \ReflectionMethod($this->modelClass, $name);
if (!$method->isStatic() || !$method->isPublic()) {
throw new InvalidCallException("The scope method \"{$this->modelClass}::$name()\" must be public and static.");
}
array_unshift($params, $this);
call_user_func_array([$this->modelClass, $name], $params);
return $this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment