@@ -80,8 +80,9 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $parentContext = $this; |
| 82 | 82 | $parents = array($parentContext); |
| 83 | - while (($parentContext = $parentContext->parentContext) !== null) |
|
| 84 | - array_unshift($parents, $parentContext); |
|
| 83 | + while (($parentContext = $parentContext->parentContext) !== null) { |
|
| 84 | + array_unshift($parents, $parentContext); |
|
| 85 | + } |
|
| 85 | 86 | return $parents; |
| 86 | 87 | } |
| 87 | 88 | |
@@ -100,8 +101,9 @@ discard block |
||
| 100 | 101 | $values = array(); |
| 101 | 102 | foreach ($contextTree as $context) { |
| 102 | 103 | $value = $context->{$name}; |
| 103 | - if ($value !== null && (!$removeDuplicates || (!count($values) || $values[count($values) - 1] !== $value))) |
|
| 104 | - $values[] = $value; |
|
| 104 | + if ($value !== null && (!$removeDuplicates || (!count($values) || $values[count($values) - 1] !== $value))) { |
|
| 105 | + $values[] = $value; |
|
| 106 | + } |
|
| 105 | 107 | } |
| 106 | 108 | return $values; |
| 107 | 109 | } |
@@ -113,33 +115,39 @@ discard block |
||
| 113 | 115 | */ |
| 114 | 116 | public function set ($values = []) |
| 115 | 117 | { |
| 116 | - foreach ($values as $key => $value) |
|
| 117 | - $this->{$key} = $value; |
|
| 118 | + foreach ($values as $key => $value) { |
|
| 119 | + $this->{$key} = $value; |
|
| 120 | + } |
|
| 118 | 121 | return $this; |
| 119 | 122 | } |
| 120 | 123 | |
| 121 | 124 | public function __get ($name) |
| 122 | 125 | { |
| 123 | 126 | // First, check if the "actual" property exists |
| 124 | - if (property_exists($this, $name)) |
|
| 125 | - return $this->{$name}; |
|
| 127 | + if (property_exists($this, $name)) { |
|
| 128 | + return $this->{$name}; |
|
| 129 | + } |
|
| 126 | 130 | // Try to retrieve the property from the "values" array |
| 127 | - else if (array_key_exists($name, $this->values)) |
|
| 128 | - return $this->values[$name]; |
|
| 131 | + else if (array_key_exists($name, $this->values)) { |
|
| 132 | + return $this->values[$name]; |
|
| 133 | + } |
|
| 129 | 134 | // Try to retrieve the property from the parent context |
| 130 | - else if ($this->parentContext !== null && ($parentValue = $this->parentContext->{$name}) !== null) |
|
| 131 | - return $parentValue; |
|
| 135 | + else if ($this->parentContext !== null && ($parentValue = $this->parentContext->{$name}) !== null) { |
|
| 136 | + return $parentValue; |
|
| 137 | + } |
|
| 132 | 138 | // Try to retrieve the property from the "defaults" array |
| 133 | - else |
|
| 134 | - return array_key_exists($name, $this->defaults) ? $this->defaults[$name] : null; |
|
| 139 | + else { |
|
| 140 | + return array_key_exists($name, $this->defaults) ? $this->defaults[$name] : null; |
|
| 141 | + } |
|
| 135 | 142 | } |
| 136 | 143 | |
| 137 | 144 | public function __set ($name, $value) |
| 138 | 145 | { |
| 139 | - if (property_exists($this, $name)) |
|
| 140 | - $this->{$name} = $value; |
|
| 141 | - else |
|
| 142 | - $this->values[$name] = $value; |
|
| 146 | + if (property_exists($this, $name)) { |
|
| 147 | + $this->{$name} = $value; |
|
| 148 | + } else { |
|
| 149 | + $this->values[$name] = $value; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | /** |
@@ -151,14 +159,15 @@ discard block |
||
| 151 | 159 | do { |
| 152 | 160 | $reflectionClass = new \ReflectionClass($class); |
| 153 | 161 | $defaultProperties = $reflectionClass->getDefaultProperties(); |
| 154 | - foreach ($reflectionClass->getProperties() as $property) |
|
| 155 | - if ( |
|
| 162 | + foreach ($reflectionClass->getProperties() as $property) { |
|
| 163 | + if ( |
|
| 156 | 164 | !$property->isStatic() && |
| 157 | 165 | $property->isDefault() && |
| 158 | 166 | preg_match('/^_(.*)$/', $property->name, $matches) && |
| 159 | 167 | !$this->isDefaultSet($matches[1]) |
| 160 | 168 | ) |
| 161 | 169 | $this->setDefault($matches[1], $defaultProperties[$property->name]); |
| 170 | + } |
|
| 162 | 171 | } while ($class = get_parent_class($class)); |
| 163 | 172 | } |
| 164 | 173 | } |