@@ -93,7 +93,7 @@ |
||
| 93 | 93 | * |
| 94 | 94 | * @param string $param |
| 95 | 95 | * |
| 96 | - * @return \mixed|null Returns parameter's value if exists, else parameter's name |
|
| 96 | + * @return null|string Returns parameter's value if exists, else parameter's name |
|
| 97 | 97 | */ |
| 98 | 98 | final protected function getValueFromParam(string $param) |
| 99 | 99 | { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | elseif (preg_match(self::$regEx['array'], $variable)) { |
| 112 | 112 | try { |
| 113 | 113 | $values[] = $this->getValueFromArray($variable); |
| 114 | - } catch(RuntimeException $e) { |
|
| 114 | + } catch (RuntimeException $e) { |
|
| 115 | 115 | if ($this->throwException) throw new GherkinParamException(); |
| 116 | 116 | if ($this->nullable) $values[] = null; |
| 117 | 117 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | else { |
| 121 | 121 | try { |
| 122 | 122 | $values[] = Fixtures::get($variable); |
| 123 | - } catch(RuntimeException $e) { |
|
| 123 | + } catch (RuntimeException $e) { |
|
| 124 | 124 | if ($this->throwException) throw new GherkinParamException(); |
| 125 | 125 | if ($this->nullable) $values[] = null; |
| 126 | 126 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | // due to the default behavior when `search` and `replace` arrays size mismatch |
| 136 | 136 | $param = $this->mapParametersToValues($matches, $values, $param); |
| 137 | 137 | |
| 138 | - } catch(GherkinParamException $e) { |
|
| 138 | + } catch (GherkinParamException $e) { |
|
| 139 | 139 | // only active if throwException setting is true |
| 140 | 140 | throw new ExtensionException( |
| 141 | 141 | $this, |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | final private function mapParametersToValues(array $matches, array $values, string $param) |
| 162 | 162 | { |
| 163 | 163 | //TODO: move count() into separate variable [performance] |
| 164 | - for ($i=0; $i<count($matches); $i++) { |
|
| 164 | + for ($i = 0; $i < count($matches); $i++) { |
|
| 165 | 165 | $search = $matches[$i]; |
| 166 | 166 | if (isset($values[$i])) { |
| 167 | 167 | $replacement = $values[$i]; |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | $prop = new ReflectionProperty(get_class($arg), 'table'); |
| 270 | 270 | $prop->setAccessible(true); |
| 271 | 271 | $table = $prop->getValue($arg); |
| 272 | - foreach($table as $i => $row) { |
|
| 272 | + foreach ($table as $i => $row) { |
|
| 273 | 273 | foreach ($row as $j => $cell) { |
| 274 | 274 | $val = $this->getValueFromParam($cell); |
| 275 | 275 | $table[$i][$j] = $val ? $val : null; // issue TableNode does not support `null` values in table |
@@ -112,8 +112,12 @@ discard block |
||
| 112 | 112 | try { |
| 113 | 113 | $values[] = $this->getValueFromArray($variable); |
| 114 | 114 | } catch(RuntimeException $e) { |
| 115 | - if ($this->throwException) throw new GherkinParamException(); |
|
| 116 | - if ($this->nullable) $values[] = null; |
|
| 115 | + if ($this->throwException) { |
|
| 116 | + throw new GherkinParamException(); |
|
| 117 | + } |
|
| 118 | + if ($this->nullable) { |
|
| 119 | + $values[] = null; |
|
| 120 | + } |
|
| 117 | 121 | } |
| 118 | 122 | } |
| 119 | 123 | // normal case |
@@ -121,13 +125,19 @@ discard block |
||
| 121 | 125 | try { |
| 122 | 126 | $values[] = Fixtures::get($variable); |
| 123 | 127 | } catch(RuntimeException $e) { |
| 124 | - if ($this->throwException) throw new GherkinParamException(); |
|
| 125 | - if ($this->nullable) $values[] = null; |
|
| 128 | + if ($this->throwException) { |
|
| 129 | + throw new GherkinParamException(); |
|
| 130 | + } |
|
| 131 | + if ($this->nullable) { |
|
| 132 | + $values[] = null; |
|
| 133 | + } |
|
| 126 | 134 | } |
| 127 | 135 | } |
| 128 | 136 | // if machting value return is not found (null) |
| 129 | 137 | if (is_null(end($values))) { |
| 130 | - if ($this->throwException) throw new GherkinParamException(); |
|
| 138 | + if ($this->throwException) { |
|
| 139 | + throw new GherkinParamException(); |
|
| 140 | + } |
|
| 131 | 141 | } |
| 132 | 142 | } |
| 133 | 143 | |
@@ -167,15 +177,23 @@ discard block |
||
| 167 | 177 | $replacement = $values[$i]; |
| 168 | 178 | if (\is_array($replacement)) { |
| 169 | 179 | // case of replacement is an array (case of config param), ie param does not exists |
| 170 | - if ($this->throwException) throw new GherkinParamException(); |
|
| 171 | - if ($this->nullable) $param = null; |
|
| 180 | + if ($this->throwException) { |
|
| 181 | + throw new GherkinParamException(); |
|
| 182 | + } |
|
| 183 | + if ($this->nullable) { |
|
| 184 | + $param = null; |
|
| 185 | + } |
|
| 172 | 186 | break; |
| 173 | 187 | } |
| 174 | 188 | //TODO: replace str_replace by strtr (performance) |
| 175 | 189 | $param = \str_replace($search, $replacement, $param); |
| 176 | 190 | } else { |
| 177 | - if ($this->throwException) throw new GherkinParamException(); |
|
| 178 | - if ($this->nullable) $param = null; |
|
| 191 | + if ($this->throwException) { |
|
| 192 | + throw new GherkinParamException(); |
|
| 193 | + } |
|
| 194 | + if ($this->nullable) { |
|
| 195 | + $param = null; |
|
| 196 | + } |
|
| 179 | 197 | } |
| 180 | 198 | } |
| 181 | 199 | return $param; |