diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index c1a2e04..cc3525e 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -57,7 +57,11 @@ class Component extends Object } } } - throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name); + if (method_exists($this, 'set' . $name)) { + throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name); + } else { + throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name); + } } /** diff --git a/framework/yii/base/Object.php b/framework/yii/base/Object.php index 9f22aba..adbab9c 100644 --- a/framework/yii/base/Object.php +++ b/framework/yii/base/Object.php @@ -70,6 +70,8 @@ class Object implements Arrayable $getter = 'get' . $name; if (method_exists($this, $getter)) { return $this->$getter(); + } elseif (method_exists($this, 'set' . $name)) { + throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name); } else { throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name); }