diff --git a/framework/yii/base/Model.php b/framework/yii/base/Model.php index 9a3e08d..e9fc032 100644 --- a/framework/yii/base/Model.php +++ b/framework/yii/base/Model.php @@ -186,9 +186,8 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess */ public function formName() { - $class = get_class($this); - $pos = strrpos($class, '\\'); - return $pos === false ? $class : substr($class, $pos + 1); + $reflector = new \ReflectionClass($this); + return $reflector->getShortName(); } /** diff --git a/framework/yii/db/ActiveRecord.php b/framework/yii/db/ActiveRecord.php index 234c79b..37944ff 100644 --- a/framework/yii/db/ActiveRecord.php +++ b/framework/yii/db/ActiveRecord.php @@ -1390,12 +1390,11 @@ class ActiveRecord extends Model protected function getNamespacedClass($class) { if (strpos($class, '\\') === false) { - $primaryClass = get_class($this); - if (($pos = strrpos($primaryClass, '\\')) !== false) { - return substr($primaryClass, 0, $pos + 1) . $class; - } + $reflector = new \ReflectionClass($this); + return $reflector->getNamespaceName() . '\\' . $class; + } else { + return $class; } - return $class; } /**