|
|
@@ -199,7 +199,8 @@ trait EntityTrait {
|
|
|
* @return \Cake\Datasource\EntityInterface this object
|
|
|
*/
|
|
|
public function set($property, $value = null, $options = []) {
|
|
|
- if (is_string($property)) {
|
|
|
+ $isString = is_string($property);
|
|
|
+ if ($isString && $property !== '') {
|
|
|
$guard = false;
|
|
|
$property = [$property => $value];
|
|
|
} else {
|
|
|
@@ -207,6 +208,9 @@ trait EntityTrait {
|
|
|
$options = (array)$value;
|
|
|
}
|
|
|
|
|
|
+ if (!is_array($property)) {
|
|
|
+ throw new \InvalidArgumentException('Cannot set an empty property');
|
|
|
+ }
|
|
|
$options += ['setter' => true, 'guard' => $guard];
|
|
|
|
|
|
foreach ($property as $p => $value) {
|
|
|
@@ -235,10 +239,15 @@ trait EntityTrait {
|
|
|
*
|
|
|
* @param string $property the name of the property to retrieve
|
|
|
* @return mixed
|
|
|
+ * @throws \InvalidArgumentException if an empty property name is passed
|
|
|
*/
|
|
|
public function &get($property) {
|
|
|
- $method = 'get' . Inflector::camelize($property);
|
|
|
+ if (!strlen((string)$property)) {
|
|
|
+ throw new \InvalidArgumentException('Cannot get an empty property');
|
|
|
+ }
|
|
|
+
|
|
|
$value = null;
|
|
|
+ $method = 'get' . Inflector::camelize($property);
|
|
|
|
|
|
if (isset($this->_properties[$property])) {
|
|
|
$value =& $this->_properties[$property];
|