@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | - * @return array |
|
| 84 | + * @return AbstractRule[] |
|
| 85 | 85 | */ |
| 86 | 86 | public function getOperands() |
| 87 | 87 | { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param array|callable $renamings Associative array of renamings or callable |
| 118 | 118 | * that would rename the fields. |
| 119 | 119 | * |
| 120 | - * @return boolean Whether or not the operation changed semantically |
|
| 120 | + * @return AbstractOperationRule Whether or not the operation changed semantically |
|
| 121 | 121 | */ |
| 122 | 122 | public function renameFields_andReturnIsChanged($renamings) |
| 123 | 123 | { |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * @param string $field The field to apply the rule on. |
| 25 | 25 | * @param mixed $possibilities The values the field can belong to. |
| 26 | 26 | */ |
| 27 | - public function __construct($field, $possibilities, array $options=[]) |
|
| 27 | + public function __construct($field, $possibilities, array $options = []) |
|
| 28 | 28 | { |
| 29 | - if (! empty($options)) { |
|
| 29 | + if ( ! empty($options)) { |
|
| 30 | 30 | $this->setOptions($options); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | $this->field = $field; |
| 34 | - $this->addPossibilities( $possibilities ); |
|
| 34 | + $this->addPossibilities($possibilities); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function addPossibilities($possibilities) |
| 51 | 51 | { |
| 52 | - if ( is_object($possibilities) |
|
| 52 | + if (is_object($possibilities) |
|
| 53 | 53 | && $possibilities instanceof \IteratorAggregate |
| 54 | 54 | && method_exists($possibilities, 'toArray') |
| 55 | 55 | ) { |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | $id = hash('crc32b', serialize($possibility)); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( ! isset($this->native_possibilities[ $id ])) { |
|
| 75 | - $this->native_possibilities[ $id ] = $possibility; |
|
| 74 | + if ( ! isset($this->native_possibilities[$id])) { |
|
| 75 | + $this->native_possibilities[$id] = $possibility; |
|
| 76 | 76 | $require_cache_flush = true; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return InRule $this |
| 91 | 91 | */ |
| 92 | - public function addOperand( AbstractRule $operand ) |
|
| 92 | + public function addOperand(AbstractRule $operand) |
|
| 93 | 93 | { |
| 94 | 94 | $this->addPossibilities([$operand->getValue()]); |
| 95 | 95 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | return $operand; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( ! ($operand instanceof EqualRule && $operand->getField() == $this->field) ) { |
|
| 134 | + if ( ! ($operand instanceof EqualRule && $operand->getField() == $this->field)) { |
|
| 135 | 135 | throw new \InvalidArgumentException( |
| 136 | 136 | "Trying to set an invalid operand of an InRule: " |
| 137 | 137 | .var_export($operand, true) |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @return array |
| 173 | 173 | */ |
| 174 | - public function toArray(array $options=[]) |
|
| 174 | + public function toArray(array $options = []) |
|
| 175 | 175 | { |
| 176 | 176 | $default_options = [ |
| 177 | 177 | 'show_instance' => false, |
| 178 | 178 | ]; |
| 179 | 179 | foreach ($default_options as $default_option => &$default_value) { |
| 180 | - if ( ! isset($options[ $default_option ])) { |
|
| 181 | - $options[ $default_option ] = $default_value; |
|
| 180 | + if ( ! isset($options[$default_option])) { |
|
| 181 | + $options[$default_option] = $default_value; |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | */ |
| 207 | - public function toString(array $options=[]) |
|
| 207 | + public function toString(array $options = []) |
|
| 208 | 208 | { |
| 209 | 209 | if (isset($this->cache['string'])) { |
| 210 | 210 | return $this->cache['string']; |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $operator = self::operator; |
| 214 | 214 | |
| 215 | - $stringified_possibilities = '[' . implode(', ', array_map(function($possibility) { |
|
| 215 | + $stringified_possibilities = '['.implode(', ', array_map(function($possibility) { |
|
| 216 | 216 | return var_export($possibility, true); |
| 217 | - }, $this->getPossibilities()) ) .']'; |
|
| 217 | + }, $this->getPossibilities())).']'; |
|
| 218 | 218 | |
| 219 | 219 | return $this->cache['string'] = "['{$this->getField()}', '$operator', $stringified_possibilities]"; |
| 220 | 220 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | /** |
| 234 | 234 | * @return bool If the InRule can have a solution or not |
| 235 | 235 | */ |
| 236 | - public function hasSolution(array $contextual_options=[]) |
|
| 236 | + public function hasSolution(array $contextual_options = []) |
|
| 237 | 237 | { |
| 238 | 238 | return ! empty($this->getPossibilities()); |
| 239 | 239 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @return string $field |
| 25 | 25 | */ |
| 26 | - final public function setField( $field ) |
|
| 26 | + final public function setField($field) |
|
| 27 | 27 | { |
| 28 | 28 | if ( ! is_scalar($field)) { |
| 29 | 29 | throw new \InvalidArgumentEXception( |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | $old_field = $this->field; |
| 68 | 68 | |
| 69 | 69 | if (is_callable($renamings)) { |
| 70 | - $this->setField( call_user_func($renamings, $this->field) ); |
|
| 70 | + $this->setField(call_user_func($renamings, $this->field)); |
|
| 71 | 71 | } |
| 72 | 72 | elseif (is_array($renamings)) { |
| 73 | 73 | if (isset($renamings[$this->field])) { |
| 74 | - $this->setField( $renamings[$this->field] ); |
|
| 74 | + $this->setField($renamings[$this->field]); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | else { |
| 78 | 78 | throw new \InvalidArgumentException( |
| 79 | 79 | "\$renamings MUST be a callable or an associative array " |
| 80 | - ."instead of: " . var_export($renamings, true) |
|
| 80 | + ."instead of: ".var_export($renamings, true) |
|
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | 83 | |