Skip to content

Commit 6c0f366

Browse files
authored
Make sure we do not use dynamic properties (#679)
* Make sure we do not use dynamic properties * Bugfix * Bugfix
1 parent 9587868 commit 6c0f366

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

Model/AddressBuilder.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ final class AddressBuilder
7979
*/
8080
private $timezone;
8181

82+
/**
83+
* A storage for extra parameters.
84+
*
85+
* @var array
86+
*/
87+
private $data = [];
88+
8289
/**
8390
* @param string $providedBy
8491
*/
@@ -277,34 +284,38 @@ public function setTimezone($timezone)
277284
}
278285

279286
/**
280-
* @param $name
281-
* @param $value
287+
* @param string $name
288+
* @param mixed $value
282289
*
283290
* @return $this
284291
*/
285-
public function setValue($name, $value)
292+
public function setValue(string $name, $value)
286293
{
287-
$this->$name = $value;
294+
$this->data[$name] = $value;
288295

289296
return $this;
290297
}
291298

292299
/**
293-
* @param $name
294-
* @param null $default
300+
* @param string $name
301+
* @param mixed|null $default
295302
*/
296-
public function getValue($name, $default = null)
303+
public function getValue(string $name, $default = null)
297304
{
298-
return $this->$name ?? $default;
305+
if ($this->hasValue($name)) {
306+
return $this->data[$name];
307+
}
308+
309+
return $default;
299310
}
300311

301312
/**
302-
* @param $name
313+
* @param string $name
303314
*
304315
* @return bool
305316
*/
306-
public function hasValue($name)
317+
public function hasValue(string $name): bool
307318
{
308-
return property_exists($this, $name);
319+
return array_key_exists($name, $this->data);
309320
}
310321
}

0 commit comments

Comments
 (0)