Skip to content

Commit 517ce57

Browse files
authored
Merge pull request #24 from Icinga/fix/closure-properties-for-mutators
Properties: Resolve closures before any mutation
2 parents f6c97d8 + 3e0617e commit 517ce57

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Properties.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,15 @@ public function setProperties(array $properties)
6868
*/
6969
protected function getProperty($key)
7070
{
71+
if (isset($this->properties[$key]) && $this->properties[$key] instanceof Closure) {
72+
$this->setProperty($key, $this->properties[$key]($this));
73+
}
74+
7175
if ($this->accessorsAndMutatorsEnabled) {
7276
$this->mutateProperty($key);
7377
}
7478

7579
if (array_key_exists($key, $this->properties)) {
76-
if ($this->properties[$key] instanceof Closure) {
77-
$value = $this->properties[$key]($this);
78-
$this->setProperty($key, $value);
79-
return $value;
80-
}
81-
8280
return $this->properties[$key];
8381
}
8482

0 commit comments

Comments
 (0)