Commit 9a4d7ff1 by Carsten Brandt

Exception message when getting write-only property

parent 7fa81949
...@@ -57,7 +57,11 @@ class Component extends Object ...@@ -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);
}
} }
/** /**
......
...@@ -70,6 +70,8 @@ class Object implements Arrayable ...@@ -70,6 +70,8 @@ class Object implements Arrayable
$getter = 'get' . $name; $getter = 'get' . $name;
if (method_exists($this, $getter)) { if (method_exists($this, $getter)) {
return $this->$getter(); return $this->$getter();
} elseif (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
} else { } else {
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name); throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
} }
......
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