@@ -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( |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | final public function renameField($renamings) |
| 50 | 50 | { |
| 51 | 51 | if (is_callable($renamings)) { |
| 52 | - $this->setField( call_user_func($renamings, $this->field) ); |
|
| 52 | + $this->setField(call_user_func($renamings, $this->field)); |
|
| 53 | 53 | } |
| 54 | 54 | elseif (is_array($renamings)) { |
| 55 | 55 | if (isset($renamings[$this->field])) { |
| 56 | - $this->setField( $renamings[$this->field] ); |
|
| 56 | + $this->setField($renamings[$this->field]); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | else { |
| 60 | 60 | throw new \InvalidArgumentException( |
| 61 | 61 | "\$renamings MUST be a callable or an associative array " |
| 62 | - ."instead of: " . var_export($renamings, true) |
|
| 62 | + ."instead of: ".var_export($renamings, true) |
|
| 63 | 63 | ); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -50,13 +50,11 @@ |
||
| 50 | 50 | { |
| 51 | 51 | if (is_callable($renamings)) { |
| 52 | 52 | $this->setField( call_user_func($renamings, $this->field) ); |
| 53 | - } |
|
| 54 | - elseif (is_array($renamings)) { |
|
| 53 | + } elseif (is_array($renamings)) { |
|
| 55 | 54 | if (isset($renamings[$this->field])) { |
| 56 | 55 | $this->setField( $renamings[$this->field] ); |
| 57 | 56 | } |
| 58 | - } |
|
| 59 | - else { |
|
| 57 | + } else { |
|
| 60 | 58 | throw new \InvalidArgumentException( |
| 61 | 59 | "\$renamings MUST be a callable or an associative array " |
| 62 | 60 | ."instead of: " . var_export($renamings, true) |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function findSymbolicOperator($english_operator) |
| 35 | 35 | { |
| 36 | - $association = array_flip( self::$ruleAliases ); |
|
| 37 | - if (isset($association[ $english_operator ])) { |
|
| 38 | - return $association[ $english_operator ]; |
|
| 36 | + $association = array_flip(self::$ruleAliases); |
|
| 37 | + if (isset($association[$english_operator])) { |
|
| 38 | + return $association[$english_operator]; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $english_operator; |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | public static function findEnglishOperator($symbolic_operator) |
| 47 | 47 | { |
| 48 | 48 | $association = self::$ruleAliases; |
| 49 | - if (isset($association[ $symbolic_operator ])) { |
|
| 50 | - return $association[ $symbolic_operator ]; |
|
| 49 | + if (isset($association[$symbolic_operator])) { |
|
| 50 | + return $association[$symbolic_operator]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | return $symbolic_operator; |
@@ -65,16 +65,16 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return $this |
| 67 | 67 | */ |
| 68 | - public static function generateSimpleRule($field, $type, $values, array $options=[]) |
|
| 68 | + public static function generateSimpleRule($field, $type, $values, array $options = []) |
|
| 69 | 69 | { |
| 70 | - $cache_key = hash('md4', serialize( func_get_args()) ); |
|
| 70 | + $cache_key = hash('md4', serialize(func_get_args())); |
|
| 71 | 71 | if (isset(self::$static_cache['rules_generation'][$cache_key])) { |
| 72 | 72 | return self::$static_cache['rules_generation'][$cache_key]->copy(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $ruleClass = self::getRuleClass($type); |
| 76 | 76 | |
| 77 | - return self::$static_cache['rules_generation'][$cache_key] = new $ruleClass( $field, $values, $options ); |
|
| 77 | + return self::$static_cache['rules_generation'][$cache_key] = new $ruleClass($field, $values, $options); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | . str_replace('_', '', ucwords($english_rule_operator, '_')) |
| 92 | 92 | . 'Rule'; |
| 93 | 93 | |
| 94 | - if (!class_exists( $rule_class)) { |
|
| 94 | + if (!class_exists($rule_class)) { |
|
| 95 | 95 | throw new \InvalidArgumentException( |
| 96 | 96 | "The class '$rule_class' corresponding to the operator " |
| 97 | 97 | ."'$rule_operator' / '$english_rule_operator' cannot be found." |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return $this |
| 122 | 122 | */ |
| 123 | - final public function dump($exit=false, array $options=[]) |
|
| 123 | + final public function dump($exit = false, array $options = []) |
|
| 124 | 124 | { |
| 125 | 125 | $default_options = [ |
| 126 | 126 | 'callstack_depth' => 2, |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | // 'show_instance' => false, |
| 129 | 129 | ]; |
| 130 | 130 | foreach ($default_options as $default_option => &$default_value) { |
| 131 | - if (!isset($options[ $default_option ])) { |
|
| 132 | - $options[ $default_option ] = $default_value; |
|
| 131 | + if (!isset($options[$default_option])) { |
|
| 132 | + $options[$default_option] = $default_value; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | extract($options); |
| 136 | 136 | |
| 137 | 137 | $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $callstack_depth); |
| 138 | - $caller = $bt[ $callstack_depth - 2 ]; |
|
| 138 | + $caller = $bt[$callstack_depth - 2]; |
|
| 139 | 139 | |
| 140 | - echo "\n" . $caller['file'] . ':' . $caller['line'] . "\n"; |
|
| 140 | + echo "\n".$caller['file'].':'.$caller['line']."\n"; |
|
| 141 | 141 | if ($mode == 'string') { |
| 142 | - if ( ! isset($options['indent_unit'])) { |
|
| 142 | + if (!isset($options['indent_unit'])) { |
|
| 143 | 143 | $options['indent_unit'] = " "; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | elseif ($mode == 'xdebug') { |
| 160 | - if ( ! function_exists('xdebug_is_enabled')) { |
|
| 160 | + if (!function_exists('xdebug_is_enabled')) { |
|
| 161 | 161 | throw new \RuntimeException("Xdebug is not installed"); |
| 162 | 162 | } |
| 163 | - if ( ! xdebug_is_enabled()) { |
|
| 163 | + if (!xdebug_is_enabled()) { |
|
| 164 | 164 | throw new \RuntimeException("Xdebug is disabled"); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | else { |
| 181 | 181 | throw new \InvalidArgumentException( |
| 182 | 182 | "'mode' option must belong to ['string', 'export', 'dump'] " |
| 183 | - ."instead of " . var_export($mode, true) |
|
| 183 | + ."instead of ".var_export($mode, true) |
|
| 184 | 184 | ); |
| 185 | 185 | } |
| 186 | 186 | echo "\n\n"; |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // return hash('crc32b', serialize( $this->toArray() )); |
| 265 | - return hash('md4', serialize( $this->toArray(['semantic' => true]) )) // faster but longer |
|
| 265 | + return hash('md4', serialize($this->toArray(['semantic' => true]))) // faster but longer |
|
| 266 | 266 | .'-' |
| 267 | - .hash('md4', serialize( $this->options )) |
|
| 267 | + .hash('md4', serialize($this->options)) |
|
| 268 | 268 | ; |
| 269 | 269 | } |
| 270 | 270 | |
@@ -144,8 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | echo ($this->toString($options)); |
| 147 | - } |
|
| 148 | - elseif ($mode == 'dump') { |
|
| 147 | + } elseif ($mode == 'dump') { |
|
| 149 | 148 | if ($xdebug_enabled = ini_get('xdebug.overload_var_dump')) { |
| 150 | 149 | ini_set('xdebug.overload_var_dump', 0); |
| 151 | 150 | } |
@@ -155,8 +154,7 @@ discard block |
||
| 155 | 154 | if ($xdebug_enabled) { |
| 156 | 155 | ini_set('xdebug.overload_var_dump', 1); |
| 157 | 156 | } |
| 158 | - } |
|
| 159 | - elseif ($mode == 'xdebug') { |
|
| 157 | + } elseif ($mode == 'xdebug') { |
|
| 160 | 158 | if ( ! function_exists('xdebug_is_enabled')) { |
| 161 | 159 | throw new \RuntimeException("Xdebug is not installed"); |
| 162 | 160 | } |
@@ -173,11 +171,9 @@ discard block |
||
| 173 | 171 | if ($xdebug_enabled) { |
| 174 | 172 | ini_set('xdebug.overload_var_dump', 0); |
| 175 | 173 | } |
| 176 | - } |
|
| 177 | - elseif ($mode == 'export') { |
|
| 174 | + } elseif ($mode == 'export') { |
|
| 178 | 175 | var_export($this->toArray($options)); |
| 179 | - } |
|
| 180 | - else { |
|
| 176 | + } else { |
|
| 181 | 177 | throw new \InvalidArgumentException( |
| 182 | 178 | "'mode' option must belong to ['string', 'export', 'dump'] " |
| 183 | 179 | ."instead of " . var_export($mode, true) |
@@ -288,21 +284,18 @@ discard block |
||
| 288 | 284 | $this |
| 289 | 285 | ]) |
| 290 | 286 | ]); |
| 291 | - } |
|
| 292 | - elseif ($this instanceof AndRule) { |
|
| 287 | + } elseif ($this instanceof AndRule) { |
|
| 293 | 288 | $ruleTree = new OrRule([ |
| 294 | 289 | $this |
| 295 | 290 | ]); |
| 296 | - } |
|
| 297 | - elseif ($this instanceof OrRule) { |
|
| 291 | + } elseif ($this instanceof OrRule) { |
|
| 298 | 292 | foreach ($this->operands as $i => $operand) { |
| 299 | 293 | if (!$operand instanceof AndRule) { |
| 300 | 294 | $this->operands[$i] = new AndRule([$operand]); |
| 301 | 295 | } |
| 302 | 296 | } |
| 303 | 297 | $ruleTree = $this; |
| 304 | - } |
|
| 305 | - else { |
|
| 298 | + } else { |
|
| 306 | 299 | throw new \LogicException( |
| 307 | 300 | "Unhandled type of simplified rules provided for conversion: " |
| 308 | 301 | .$this |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param string $field The field to apply the rule on. |
| 19 | 19 | * @param array $value The value the field can equal to. |
| 20 | 20 | */ |
| 21 | - public function __construct( $field, $value, array $options=[] ) |
|
| 21 | + public function __construct($field, $value, array $options = []) |
|
| 22 | 22 | { |
| 23 | 23 | $this->field = $field; |
| 24 | 24 | $this->value = $value; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | */ |
| 32 | - public function isNormalizationAllowed(array $contextual_options=[]) |
|
| 32 | + public function isNormalizationAllowed(array $contextual_options = []) |
|
| 33 | 33 | { |
| 34 | 34 | $operand = $this->getOperandAt(0); |
| 35 | 35 | |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @return array |
| 60 | 60 | */ |
| 61 | - public function toArray(array $options=[]) |
|
| 61 | + public function toArray(array $options = []) |
|
| 62 | 62 | { |
| 63 | 63 | $default_options = [ |
| 64 | 64 | 'show_instance' => false, |
| 65 | 65 | ]; |
| 66 | 66 | foreach ($default_options as $default_option => &$default_value) { |
| 67 | - if (!isset($options[ $default_option ])) { |
|
| 68 | - $options[ $default_option ] = $default_value; |
|
| 67 | + if (!isset($options[$default_option])) { |
|
| 68 | + $options[$default_option] = $default_value; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | */ |
| 92 | - public function toString(array $options=[]) |
|
| 92 | + public function toString(array $options = []) |
|
| 93 | 93 | { |
| 94 | 94 | if (!empty($this->cache['string'])) { |
| 95 | 95 | return $this->cache['string']; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - public function hasSolution(array $simplification_options=[]) |
|
| 111 | + public function hasSolution(array $simplification_options = []) |
|
| 112 | 112 | { |
| 113 | 113 | return true; |
| 114 | 114 | } |
@@ -81,8 +81,7 @@ |
||
| 81 | 81 | |
| 82 | 82 | if (!$options['show_instance']) { |
| 83 | 83 | return $this->cache['array'] = $array; |
| 84 | - } |
|
| 85 | - else { |
|
| 84 | + } else { |
|
| 86 | 85 | return $array; |
| 87 | 86 | } |
| 88 | 87 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | const remove_negations = 'remove_negations'; |
| 21 | 21 | const rootify_disjunctions = 'rootify_disjunctions'; |
| 22 | 22 | const unify_atomic_operands = 'unify_atomic_operands'; |
| 23 | - const remove_invalid_branches = 'remove_invalid_branches'; // simplified after this step |
|
| 23 | + const remove_invalid_branches = 'remove_invalid_branches'; // simplified after this step |
|
| 24 | 24 | |
| 25 | 25 | const simplified = self::remove_invalid_branches; |
| 26 | 26 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | */ |
| 46 | - public function __construct( array $operands=[] ) |
|
| 46 | + public function __construct(array $operands = []) |
|
| 47 | 47 | { |
| 48 | - $this->setOperands( $operands ); |
|
| 48 | + $this->setOperands($operands); |
|
| 49 | 49 | $this->flushCache(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return $this |
| 66 | 66 | */ |
| 67 | - public function addOperand( AbstractRule $new_operand ) |
|
| 67 | + public function addOperand(AbstractRule $new_operand) |
|
| 68 | 68 | { |
| 69 | - if (!isset($this->operands[ $id = $new_operand->getSemanticId() ])) { |
|
| 70 | - $this->operands[ $id ] = $new_operand; |
|
| 69 | + if (!isset($this->operands[$id = $new_operand->getSemanticId()])) { |
|
| 70 | + $this->operands[$id] = $new_operand; |
|
| 71 | 71 | |
| 72 | 72 | if ($this->current_simplification_step) { |
| 73 | 73 | $this->current_simplification_step = null; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function getOperands() |
| 86 | 86 | { |
| 87 | - return array_values( $this->operands ); |
|
| 87 | + return array_values($this->operands); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param array $simplification_options |
| 129 | 129 | * @param bool $force |
| 130 | 130 | */ |
| 131 | - public function moveSimplificationStepForward($step_to_go_to, array $simplification_options, $force=false) |
|
| 131 | + public function moveSimplificationStepForward($step_to_go_to, array $simplification_options, $force = false) |
|
| 132 | 132 | { |
| 133 | 133 | if (!in_array($step_to_go_to, self::simplification_steps)) { |
| 134 | 134 | throw new \InvalidArgumentException( |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | if (!$force && $this->current_simplification_step !== null) { |
| 141 | 141 | $steps_indices = array_flip(self::simplification_steps); |
| 142 | 142 | |
| 143 | - $current_index = $steps_indices[ $this->current_simplification_step ]; |
|
| 144 | - $target_index = $steps_indices[ $step_to_go_to ]; |
|
| 143 | + $current_index = $steps_indices[$this->current_simplification_step]; |
|
| 144 | + $target_index = $steps_indices[$step_to_go_to]; |
|
| 145 | 145 | |
| 146 | - if ( $current_index >= $target_index ) { |
|
| 146 | + if ($current_index >= $target_index) { |
|
| 147 | 147 | // allow recall of previous step without going back |
| 148 | 148 | return; |
| 149 | 149 | } |
| 150 | - elseif ( $current_index < $target_index - 1 ) { |
|
| 150 | + elseif ($current_index < $target_index - 1) { |
|
| 151 | 151 | throw new \LogicException( |
| 152 | - "$step_to_go_to MUST be fullfilled after " . self::simplification_steps[$target_index - 1] |
|
| 153 | - . " instead of the current step: " . $this->current_simplification_step |
|
| 154 | - ."\nfor: " . $this |
|
| 152 | + "$step_to_go_to MUST be fullfilled after ".self::simplification_steps[$target_index - 1] |
|
| 153 | + . " instead of the current step: ".$this->current_simplification_step |
|
| 154 | + ."\nfor: ".$this |
|
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $steps_indices = array_flip(self::simplification_steps); |
| 182 | 182 | |
| 183 | - $current_index = $steps_indices[ $this->current_simplification_step ]; |
|
| 184 | - $step_index = $steps_indices[ $step ]; |
|
| 183 | + $current_index = $steps_indices[$this->current_simplification_step]; |
|
| 184 | + $step_index = $steps_indices[$step]; |
|
| 185 | 185 | |
| 186 | 186 | return $current_index >= $step_index; |
| 187 | 187 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | if ($operands[$i] instanceof AbstractOperationRule) { |
| 210 | - $operands[$i]->removeNegations( $contextual_options ); |
|
| 210 | + $operands[$i]->removeNegations($contextual_options); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -227,11 +227,11 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @return $this; |
| 229 | 229 | */ |
| 230 | - public function cleanOperations($simplification_options, $recurse=true) |
|
| 230 | + public function cleanOperations($simplification_options, $recurse = true) |
|
| 231 | 231 | { |
| 232 | 232 | if ($recurse) { |
| 233 | 233 | foreach ($this->operands as $i => $operand) { |
| 234 | - if ( $operand instanceof AbstractOperationRule |
|
| 234 | + if ($operand instanceof AbstractOperationRule |
|
| 235 | 235 | && !$operand instanceof InRule |
| 236 | 236 | && !$operand instanceof NotEqualRule |
| 237 | 237 | && !$operand instanceof NotInRule |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | public function unifyAtomicOperands($simplification_strategy_step = false, array $contextual_options) |
| 306 | 306 | { |
| 307 | 307 | if ($simplification_strategy_step) { |
| 308 | - $this->moveSimplificationStepForward( self::unify_atomic_operands, $contextual_options ); |
|
| 308 | + $this->moveSimplificationStepForward(self::unify_atomic_operands, $contextual_options); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // $this->dump(true); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | catch (\Exception $e) { |
| 342 | 342 | VisibilityViolator::setHiddenProperty( |
| 343 | 343 | $e, 'message', |
| 344 | - $e->getMessage() . "\n" . var_export($operandsByOperator, true) |
|
| 344 | + $e->getMessage()."\n".var_export($operandsByOperator, true) |
|
| 345 | 345 | ); |
| 346 | 346 | |
| 347 | 347 | throw $e; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - return $this->setOperandsOrReplaceByOperation( $unifiedOperands, $contextual_options ); |
|
| 352 | + return $this->setOperandsOrReplaceByOperation($unifiedOperands, $contextual_options); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | private static $simplification_cache = []; |
@@ -365,10 +365,10 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @return AbstractRule the simplified rule |
| 367 | 367 | */ |
| 368 | - final public function simplify($options=[]) |
|
| 368 | + final public function simplify($options = []) |
|
| 369 | 369 | { |
| 370 | - $step_to_stop_before = !empty($options['stop_before']) ? $options['stop_before'] : null; |
|
| 371 | - $step_to_stop_after = !empty($options['stop_after']) ? $options['stop_after'] : null; |
|
| 370 | + $step_to_stop_before = !empty($options['stop_before']) ? $options['stop_before'] : null; |
|
| 371 | + $step_to_stop_after = !empty($options['stop_after']) ? $options['stop_after'] : null; |
|
| 372 | 372 | $force_logical_core = !empty($options['force_logical_core']) ? $options['force_logical_core'] : false; |
| 373 | 373 | |
| 374 | 374 | if ($step_to_stop_before && !in_array($step_to_stop_before, self::simplification_steps)) { |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | // $instance->dump(true); |
| 407 | 407 | |
| 408 | - if ($step_to_stop_after == self::remove_negations || |
|
| 409 | - $step_to_stop_before == self::rootify_disjunctions ) { |
|
| 408 | + if ($step_to_stop_after == self::remove_negations || |
|
| 409 | + $step_to_stop_before == self::rootify_disjunctions) { |
|
| 410 | 410 | return $instance; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | // $instance->dump(true); |
| 419 | 419 | |
| 420 | - if ($step_to_stop_after == self::rootify_disjunctions || |
|
| 421 | - $step_to_stop_before == self::unify_atomic_operands ) { |
|
| 420 | + if ($step_to_stop_after == self::rootify_disjunctions || |
|
| 421 | + $step_to_stop_before == self::unify_atomic_operands) { |
|
| 422 | 422 | return $instance; |
| 423 | 423 | } |
| 424 | 424 | |
@@ -428,8 +428,8 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | // $instance->dump(true); |
| 430 | 430 | |
| 431 | - if ($step_to_stop_after == self::unify_atomic_operands || |
|
| 432 | - $step_to_stop_before == self::remove_invalid_branches ) { |
|
| 431 | + if ($step_to_stop_after == self::unify_atomic_operands || |
|
| 432 | + $step_to_stop_before == self::remove_invalid_branches) { |
|
| 433 | 433 | return $instance; |
| 434 | 434 | } |
| 435 | 435 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | // last non recursive clean |
| 447 | 447 | // TODO kind of monad|become|cese |
| 448 | 448 | //@see https://github.com/jclaveau/php-logical-filter/issues/20 |
| 449 | - if ($instance instanceof AndRule || $instance instanceof OrRule ) { |
|
| 449 | + if ($instance instanceof AndRule || $instance instanceof OrRule) { |
|
| 450 | 450 | if (!$instance->getOperands()) { |
| 451 | 451 | return $instance; |
| 452 | 452 | } |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | $cache_keys[] = $instance->getSemanticId().'-'.$options_id; |
| 488 | 488 | foreach ($cache_keys as $cache_key) { |
| 489 | - self::$simplification_cache[ $cache_key ] = $instance; |
|
| 489 | + self::$simplification_cache[$cache_key] = $instance; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | return $instance->copy(); |
@@ -509,15 +509,15 @@ discard block |
||
| 509 | 509 | // For FilteredValue and FilteredKey |
| 510 | 510 | $field = (string) $field; |
| 511 | 511 | |
| 512 | - if (!isset($operandsByFields[ $field ])) { |
|
| 513 | - $operandsByFields[ $field ] = []; |
|
| 512 | + if (!isset($operandsByFields[$field])) { |
|
| 513 | + $operandsByFields[$field] = []; |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if (!isset($operandsByFields[ $field ][ $operand::operator ])) { |
|
| 517 | - $operandsByFields[ $field ][ $operand::operator ] = []; |
|
| 516 | + if (!isset($operandsByFields[$field][$operand::operator])) { |
|
| 517 | + $operandsByFields[$field][$operand::operator] = []; |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - $operandsByFields[ $field ][ $operand::operator ][] = $operand; |
|
| 520 | + $operandsByFields[$field][$operand::operator][] = $operand; |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | return $operandsByFields; |
@@ -540,15 +540,15 @@ discard block |
||
| 540 | 540 | // For FilteredValue and FilteredKey |
| 541 | 541 | $field = (string) $field; |
| 542 | 542 | |
| 543 | - if (!isset($operandsByFields[ $field ])) { |
|
| 544 | - $operandsByFields[ $field ] = []; |
|
| 543 | + if (!isset($operandsByFields[$field])) { |
|
| 544 | + $operandsByFields[$field] = []; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - if (!isset($operandsByFields[ $field ][ $operand::operator ])) { |
|
| 548 | - $operandsByFields[ $field ][ $operand::operator ] = []; |
|
| 547 | + if (!isset($operandsByFields[$field][$operand::operator])) { |
|
| 548 | + $operandsByFields[$field][$operand::operator] = []; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $operandsByFields[ $field ][ $operand::operator ][] = $operand; |
|
| 551 | + $operandsByFields[$field][$operand::operator][] = $operand; |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | return $operandsByFields; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | * |
| 587 | 587 | * @return AbstractRule|null The operand if it exists or null |
| 588 | 588 | */ |
| 589 | - protected function getOperandAt($index=0) |
|
| 589 | + protected function getOperandAt($index = 0) |
|
| 590 | 590 | { |
| 591 | 591 | $operands = array_values($this->operands); |
| 592 | 592 | if (isset($operands[$index])) { |
@@ -111,8 +111,7 @@ discard block |
||
| 111 | 111 | foreach ($this->operands as $operand) { |
| 112 | 112 | if (method_exists($operand, 'renameField')) { |
| 113 | 113 | $operand->renameField($renamings); |
| 114 | - } |
|
| 115 | - else { |
|
| 114 | + } else { |
|
| 116 | 115 | $operand->renameFields($renamings); |
| 117 | 116 | } |
| 118 | 117 | } |
@@ -146,8 +145,7 @@ discard block |
||
| 146 | 145 | if ( $current_index >= $target_index ) { |
| 147 | 146 | // allow recall of previous step without going back |
| 148 | 147 | return; |
| 149 | - } |
|
| 150 | - elseif ( $current_index < $target_index - 1 ) { |
|
| 148 | + } elseif ( $current_index < $target_index - 1 ) { |
|
| 151 | 149 | throw new \LogicException( |
| 152 | 150 | "$step_to_go_to MUST be fullfilled after " . self::simplification_steps[$target_index - 1] |
| 153 | 151 | . " instead of the current step: " . $this->current_simplification_step |
@@ -279,8 +277,7 @@ discard block |
||
| 279 | 277 | |
| 280 | 278 | if ($operand instanceof InRule && !$operand->isNormalizationAllowed($simplification_options)) { |
| 281 | 279 | $count = count($operand->getPossibilities()); |
| 282 | - } |
|
| 283 | - else { |
|
| 280 | + } else { |
|
| 284 | 281 | $count = count($operand->getOperands()); |
| 285 | 282 | } |
| 286 | 283 | |
@@ -337,8 +334,7 @@ discard block |
||
| 337 | 334 | foreach ($operandsByOperator as $operator => $operands) { |
| 338 | 335 | try { |
| 339 | 336 | $unifiedOperands = array_merge($unifiedOperands, $operands); |
| 340 | - } |
|
| 341 | - catch (\Exception $e) { |
|
| 337 | + } catch (\Exception $e) { |
|
| 342 | 338 | VisibilityViolator::setHiddenProperty( |
| 343 | 339 | $e, 'message', |
| 344 | 340 | $e->getMessage() . "\n" . var_export($operandsByOperator, true) |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | * @param string $field The field to apply the rule on. |
| 17 | 17 | * @param array $value The value the field can below to. |
| 18 | 18 | */ |
| 19 | - public function __construct( $field, $maximum ) |
|
| 19 | + public function __construct($field, $maximum) |
|
| 20 | 20 | { |
| 21 | - if ( !is_scalar($maximum) |
|
| 21 | + if (!is_scalar($maximum) |
|
| 22 | 22 | && !$maximum instanceof \DateTimeInterface |
| 23 | 23 | && null !== $maximum |
| 24 | 24 | ) { |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return bool |
| 40 | 40 | */ |
| 41 | - public function hasSolution(array $contextual_options=[]) |
|
| 41 | + public function hasSolution(array $contextual_options = []) |
|
| 42 | 42 | { |
| 43 | 43 | // if minimum is null, the rule is equivalent to true |
| 44 | - if (is_numeric( $this->maximum )) { |
|
| 45 | - if (is_nan( $this->maximum )) { |
|
| 44 | + if (is_numeric($this->maximum)) { |
|
| 45 | + if (is_nan($this->maximum)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (is_infinite( $this->maximum ) && $this->maximum < 0) { |
|
| 49 | + if (is_infinite($this->maximum) && $this->maximum < 0) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return array |
| 23 | 23 | */ |
| 24 | - public function toArray(array $options=[]) |
|
| 24 | + public function toArray(array $options = []) |
|
| 25 | 25 | { |
| 26 | 26 | $default_options = [ |
| 27 | 27 | 'show_instance' => false, |
| 28 | 28 | ]; |
| 29 | 29 | foreach ($default_options as $default_option => &$default_value) { |
| 30 | - if (!isset($options[ $default_option ])) { |
|
| 31 | - $options[ $default_option ] = $default_value; |
|
| 30 | + if (!isset($options[$default_option])) { |
|
| 31 | + $options[$default_option] = $default_value; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | */ |
| 58 | - public function toString(array $options=[]) |
|
| 58 | + public function toString(array $options = []) |
|
| 59 | 59 | { |
| 60 | 60 | if (!empty($this->cache['string'])) { |
| 61 | 61 | return $this->cache['string']; |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | if (!$options['show_instance']) { |
| 49 | 49 | return $this->cache['array'] = $array; |
| 50 | - } |
|
| 51 | - else { |
|
| 50 | + } else { |
|
| 52 | 51 | return $array; |
| 53 | 52 | } |
| 54 | 53 | } |
@@ -70,11 +69,9 @@ discard block |
||
| 70 | 69 | |
| 71 | 70 | if ($field instanceof FilteredValue || $field instanceof FilteredKey) { |
| 72 | 71 | $field = "$field"; |
| 73 | - } |
|
| 74 | - elseif ($field instanceof \Closure) { |
|
| 72 | + } elseif ($field instanceof \Closure) { |
|
| 75 | 73 | throw new \Exception("Closures dump not implemented"); |
| 76 | - } |
|
| 77 | - else { |
|
| 74 | + } else { |
|
| 78 | 75 | $field = "'$field'"; |
| 79 | 76 | } |
| 80 | 77 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | return $this; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $this->moveSimplificationStepForward( self::rootify_disjunctions, $simplification_options ); |
|
| 28 | + $this->moveSimplificationStepForward(self::rootify_disjunctions, $simplification_options); |
|
| 29 | 29 | |
| 30 | 30 | $upLiftedOperands = []; |
| 31 | 31 | foreach ($this->getOperands() as $operand) { |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | foreach ($upLiftedOperands as $i => $operand) { |
| 58 | 58 | if ($operand instanceof NotRule) { |
| 59 | - if ( ($operand instanceof NotEqualRule || $operand instanceof NotInRule) |
|
| 60 | - && ! $operand->isNormalizationAllowed($simplification_options) |
|
| 59 | + if (($operand instanceof NotEqualRule || $operand instanceof NotInRule) |
|
| 60 | + && !$operand->isNormalizationAllowed($simplification_options) |
|
| 61 | 61 | ) { |
| 62 | 62 | foreach ($upLiftedOr->getOperands() as $upLifdtedOperand) { |
| 63 | - $upLifdtedOperand->addOperand( $operand->copy() ); |
|
| 63 | + $upLifdtedOperand->addOperand($operand->copy()); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | else { |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | foreach ($operand->getOperands() as $subOperand) { |
| 83 | 83 | foreach ($upLiftedOr->getOperands() as $upLiftedOrSubOperand) { |
| 84 | 84 | $newUpLiftedOrSubOperand = $upLiftedOrSubOperand->copy(); |
| 85 | - $newUpLiftedOrSubOperand->addOperand( $subOperand->copy() ); |
|
| 85 | + $newUpLiftedOrSubOperand->addOperand($subOperand->copy()); |
|
| 86 | 86 | if ($newUpLiftedOrSubOperand->simplify($simplification_options)->hasSolution($simplification_options)) { |
| 87 | - $newUpLiftedOr->addOperand( $newUpLiftedOrSubOperand ); |
|
| 87 | + $newUpLiftedOr->addOperand($newUpLiftedOrSubOperand); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $upLifdtedOperand->addOperand( $operand->copy() ); |
|
| 104 | + $upLifdtedOperand->addOperand($operand->copy()); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @todo same as OrRule |
| 118 | 118 | */ |
| 119 | - public function toArray(array $options=[]) |
|
| 119 | + public function toArray(array $options = []) |
|
| 120 | 120 | { |
| 121 | 121 | $default_options = [ |
| 122 | 122 | 'show_instance' => false, |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | 'semantic' => false, |
| 125 | 125 | ]; |
| 126 | 126 | foreach ($default_options as $default_option => &$default_value) { |
| 127 | - if (!isset($options[ $default_option ])) { |
|
| 128 | - $options[ $default_option ] = $default_value; |
|
| 127 | + if (!isset($options[$default_option])) { |
|
| 128 | + $options[$default_option] = $default_value; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | */ |
| 167 | - public function toString(array $options=[]) |
|
| 167 | + public function toString(array $options = []) |
|
| 168 | 168 | { |
| 169 | 169 | $operator = self::operator; |
| 170 | 170 | if (!$this->operands) { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | foreach ($this->operands as $operand) { |
| 180 | 180 | $out .= implode("\n", array_map(function($line) use (&$indent_unit) { |
| 181 | 181 | return $indent_unit.$line; |
| 182 | - }, explode("\n", $operand->toString($options)) )) . ",$line_break"; |
|
| 182 | + }, explode("\n", $operand->toString($options)))).",$line_break"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $out .= ']'; |
@@ -193,17 +193,17 @@ discard block |
||
| 193 | 193 | public function removeSameOperationOperands() |
| 194 | 194 | { |
| 195 | 195 | foreach ($this->operands as $i => $operand) { |
| 196 | - if ( ! is_a($operand, AndRule::class)) { |
|
| 196 | + if (!is_a($operand, AndRule::class)) { |
|
| 197 | 197 | continue; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( ! $operands = $operand->getOperands()) { |
|
| 200 | + if (!$operands = $operand->getOperands()) { |
|
| 201 | 201 | continue; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Id AND is an operand on AND they can be merge (and the same with OR) |
| 205 | 205 | foreach ($operands as $sub_operand) { |
| 206 | - $this->addOperand( $sub_operand->copy() ); |
|
| 206 | + $this->addOperand($sub_operand->copy()); |
|
| 207 | 207 | } |
| 208 | 208 | unset($this->operands[$i]); |
| 209 | 209 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | foreach ($this->operands as $i => $operand) { |
| 232 | 232 | // if ($operand instanceof AndRule || $operand instanceof OrRule ) { |
| 233 | - if ( in_array( get_class($operand), [AndRule::class, OrRule::class]) ) { |
|
| 233 | + if (in_array(get_class($operand), [AndRule::class, OrRule::class])) { |
|
| 234 | 234 | $this->operands[$i] = $operand->removeInvalidBranches($simplification_options); |
| 235 | 235 | if (!$this->operands[$i]->hasSolution()) { |
| 236 | 236 | $this->operands = []; |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | // $this->dump(true); |
| 245 | 245 | |
| 246 | 246 | foreach ($operandsByFields as $field => $operandsByOperator) { |
| 247 | - if (!empty($operandsByOperator[ EqualRule::operator ])) { |
|
| 248 | - foreach ($operandsByOperator[ EqualRule::operator ] as $equalRule) { |
|
| 247 | + if (!empty($operandsByOperator[EqualRule::operator])) { |
|
| 248 | + foreach ($operandsByOperator[EqualRule::operator] as $equalRule) { |
|
| 249 | 249 | // Multiple equal rules without the same value is invalid |
| 250 | 250 | if (isset($previousEqualRule) && $previousEqualRule->getValue() != $equalRule->getValue()) { |
| 251 | 251 | $this->operands = []; |
@@ -255,55 +255,55 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | unset($previousEqualRule); |
| 257 | 257 | |
| 258 | - $equalRule = reset($operandsByOperator[ EqualRule::operator ]); |
|
| 258 | + $equalRule = reset($operandsByOperator[EqualRule::operator]); |
|
| 259 | 259 | |
| 260 | - if ( !empty($operandsByOperator[ BelowRule::operator ]) |
|
| 260 | + if (!empty($operandsByOperator[BelowRule::operator]) |
|
| 261 | 261 | && $equalRule->getValue() === null |
| 262 | 262 | ) { |
| 263 | 263 | $this->operands = []; |
| 264 | 264 | return $this; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ( !empty($operandsByOperator[ BelowRule::operator ]) |
|
| 268 | - && $equalRule->getValue() >= reset($operandsByOperator[ BelowRule::operator ])->getMaximum() |
|
| 267 | + if (!empty($operandsByOperator[BelowRule::operator]) |
|
| 268 | + && $equalRule->getValue() >= reset($operandsByOperator[BelowRule::operator])->getMaximum() |
|
| 269 | 269 | ) { |
| 270 | 270 | $this->operands = []; |
| 271 | 271 | return $this; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( !empty($operandsByOperator[ AboveRule::operator ]) |
|
| 274 | + if (!empty($operandsByOperator[AboveRule::operator]) |
|
| 275 | 275 | && $equalRule->getValue() === null |
| 276 | 276 | ) { |
| 277 | 277 | $this->operands = []; |
| 278 | 278 | return $this; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( !empty($operandsByOperator[ AboveRule::operator ]) |
|
| 282 | - && $equalRule->getValue() <= reset($operandsByOperator[ AboveRule::operator ])->getMinimum() |
|
| 281 | + if (!empty($operandsByOperator[AboveRule::operator]) |
|
| 282 | + && $equalRule->getValue() <= reset($operandsByOperator[AboveRule::operator])->getMinimum() |
|
| 283 | 283 | ) { |
| 284 | 284 | $this->operands = []; |
| 285 | 285 | return $this; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( !empty($operandsByOperator[ NotEqualRule::operator ]) |
|
| 289 | - && $equalRule->getValue() == reset($operandsByOperator[ NotEqualRule::operator ])->getValue() |
|
| 288 | + if (!empty($operandsByOperator[NotEqualRule::operator]) |
|
| 289 | + && $equalRule->getValue() == reset($operandsByOperator[NotEqualRule::operator])->getValue() |
|
| 290 | 290 | ) { |
| 291 | 291 | $this->operands = []; |
| 292 | 292 | return $this; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if ( !empty($operandsByOperator[ NotEqualRule::operator ]) |
|
| 295 | + if (!empty($operandsByOperator[NotEqualRule::operator]) |
|
| 296 | 296 | && $equalRule->getValue() === null |
| 297 | - && reset($operandsByOperator[ NotEqualRule::operator ])->getValue() === null |
|
| 297 | + && reset($operandsByOperator[NotEqualRule::operator])->getValue() === null |
|
| 298 | 298 | ) { |
| 299 | 299 | $this->operands = []; |
| 300 | 300 | return $this; |
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | - elseif ( !empty($operandsByOperator[ BelowRule::operator ]) |
|
| 304 | - && !empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 305 | - $aboveRule = reset($operandsByOperator[ AboveRule::operator ]); |
|
| 306 | - $belowRule = reset($operandsByOperator[ BelowRule::operator ]); |
|
| 303 | + elseif (!empty($operandsByOperator[BelowRule::operator]) |
|
| 304 | + && !empty($operandsByOperator[AboveRule::operator])) { |
|
| 305 | + $aboveRule = reset($operandsByOperator[AboveRule::operator]); |
|
| 306 | + $belowRule = reset($operandsByOperator[BelowRule::operator]); |
|
| 307 | 307 | |
| 308 | 308 | if ($belowRule->getMaximum() <= $aboveRule->getMinimum()) { |
| 309 | 309 | $this->operands = []; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * |
| 324 | 324 | * @return bool If the AndRule can have a solution or not |
| 325 | 325 | */ |
| 326 | - public function hasSolution(array $contextual_options=[]) |
|
| 326 | + public function hasSolution(array $contextual_options = []) |
|
| 327 | 327 | { |
| 328 | 328 | if (!$this->simplicationStepReached(self::simplified)) { |
| 329 | 329 | throw new \LogicException( |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | try { |
| 358 | 358 | if ($operator == AboveRule::operator) { |
| 359 | - usort($operands, function( AboveRule $a, AboveRule $b ) { |
|
| 359 | + usort($operands, function(AboveRule $a, AboveRule $b) { |
|
| 360 | 360 | if ($a->getMinimum() === null) { |
| 361 | 361 | return 1; |
| 362 | 362 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $operands = [reset($operands)]; |
| 375 | 375 | } |
| 376 | 376 | elseif ($operator == BelowRule::operator) { |
| 377 | - usort($operands, function( BelowRule $a, BelowRule $b ) { |
|
| 377 | + usort($operands, function(BelowRule $a, BelowRule $b) { |
|
| 378 | 378 | if ($a->getMaximum() === null) { |
| 379 | 379 | return 1; |
| 380 | 380 | } |
@@ -420,10 +420,10 @@ discard block |
||
| 420 | 420 | continue; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $first_in->setPossibilities( array_intersect( |
|
| 423 | + $first_in->setPossibilities(array_intersect( |
|
| 424 | 424 | $first_in->getPossibilities(), |
| 425 | 425 | $next_in->getPossibilities() |
| 426 | - ) ); |
|
| 426 | + )); |
|
| 427 | 427 | |
| 428 | 428 | unset($operands[$i]); |
| 429 | 429 | } |
@@ -441,17 +441,17 @@ discard block |
||
| 441 | 441 | continue; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - $first_not_in->setPossibilities( array_merge( |
|
| 444 | + $first_not_in->setPossibilities(array_merge( |
|
| 445 | 445 | $first_not_in->getPossibilities(), |
| 446 | 446 | $next_not_in->getPossibilities() |
| 447 | - ) ); |
|
| 447 | + )); |
|
| 448 | 448 | |
| 449 | 449 | unset($operands[$i]); |
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | catch (\Exception $e) { |
| 454 | - VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage() . "\n" . var_export([ |
|
| 454 | + VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage()."\n".var_export([ |
|
| 455 | 455 | 'operands' => $operands, |
| 456 | 456 | // 'this' => $this, |
| 457 | 457 | ], true) |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | throw $e; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $operandsByFields[ $field ][ $operator ] = $operands; |
|
| 464 | + $operandsByFields[$field][$operator] = $operands; |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -484,14 +484,14 @@ discard block |
||
| 484 | 484 | ] |
| 485 | 485 | as $unifyable_operator |
| 486 | 486 | ) { |
| 487 | - if (!empty($operandsByOperator[ $unifyable_operator ])) { |
|
| 488 | - if (count($operandsByOperator[ $unifyable_operator ]) != 1) { |
|
| 487 | + if (!empty($operandsByOperator[$unifyable_operator])) { |
|
| 488 | + if (count($operandsByOperator[$unifyable_operator]) != 1) { |
|
| 489 | 489 | throw new \LogicException( |
| 490 | - __METHOD__ . " MUST be called after unifyAtomicOperands() " |
|
| 490 | + __METHOD__." MUST be called after unifyAtomicOperands() " |
|
| 491 | 491 | ."to have only one '$unifyable_operator' predicate istead of:\n" |
| 492 | - ."[\n".implode( ",\n", array_map(function ($rule) { |
|
| 492 | + ."[\n".implode(",\n", array_map(function($rule) { |
|
| 493 | 493 | return $rule->toString(); |
| 494 | - }, $operandsByOperator[ $unifyable_operator ]) |
|
| 494 | + }, $operandsByOperator[$unifyable_operator]) |
|
| 495 | 495 | )."\n]" |
| 496 | 496 | ); |
| 497 | 497 | } |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | // If tyhere is no more operands for a given field it means there |
| 503 | 503 | // is no possible solutions for it so all the current and_case |
| 504 | 504 | // is invalidated. |
| 505 | - if (! $operandsByOperator) { |
|
| 505 | + if (!$operandsByOperator) { |
|
| 506 | 506 | return []; |
| 507 | 507 | } |
| 508 | 508 | } |
@@ -517,73 +517,73 @@ discard block |
||
| 517 | 517 | protected static function simplifyDifferentOperandsForField($field, array $operandsByOperator) |
| 518 | 518 | { |
| 519 | 519 | // EqualRule comparisons |
| 520 | - if (!empty($operandsByOperator[ EqualRule::operator ])) { |
|
| 521 | - $equalRule = reset( $operandsByOperator[ EqualRule::operator ] ); |
|
| 520 | + if (!empty($operandsByOperator[EqualRule::operator])) { |
|
| 521 | + $equalRule = reset($operandsByOperator[EqualRule::operator]); |
|
| 522 | 522 | |
| 523 | - if (!empty($operandsByOperator[ NotEqualRule::operator ])) { |
|
| 524 | - foreach ($operandsByOperator[ NotEqualRule::operator ] as $i => $not_equal_rule) { |
|
| 523 | + if (!empty($operandsByOperator[NotEqualRule::operator])) { |
|
| 524 | + foreach ($operandsByOperator[NotEqualRule::operator] as $i => $not_equal_rule) { |
|
| 525 | 525 | if ($equalRule->getValue() !== null) { |
| 526 | 526 | if ($not_equal_rule->getValue() === null) { // means if exists <=> equals something |
| 527 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 527 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 528 | 528 | } |
| 529 | 529 | elseif ($not_equal_rule->getValue() != $equalRule->getValue()) { |
| 530 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 530 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | - elseif ($equalRule->getValue() === null ) { |
|
| 533 | + elseif ($equalRule->getValue() === null) { |
|
| 534 | 534 | if ($not_equal_rule->getValue() !== null) { |
| 535 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 535 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 536 | 536 | } |
| 537 | 537 | // else we let the "equal null" and the "not equal null" for the romeInvalidBranches step |
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - if (!empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 543 | - $aboveRule = reset($operandsByOperator[ AboveRule::operator ]); |
|
| 542 | + if (!empty($operandsByOperator[AboveRule::operator])) { |
|
| 543 | + $aboveRule = reset($operandsByOperator[AboveRule::operator]); |
|
| 544 | 544 | if ($equalRule->getValue() !== null && $aboveRule->getMinimum() < $equalRule->getValue()) { |
| 545 | - unset($operandsByOperator[ AboveRule::operator ]); |
|
| 545 | + unset($operandsByOperator[AboveRule::operator]); |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - if (!empty($operandsByOperator[ BelowRule::operator ])) { |
|
| 550 | - $belowRule = reset($operandsByOperator[ BelowRule::operator ]); |
|
| 549 | + if (!empty($operandsByOperator[BelowRule::operator])) { |
|
| 550 | + $belowRule = reset($operandsByOperator[BelowRule::operator]); |
|
| 551 | 551 | if ($equalRule->getValue() !== null && $belowRule->getMaximum() > $equalRule->getValue()) { |
| 552 | - unset($operandsByOperator[ BelowRule::operator ]); |
|
| 552 | + unset($operandsByOperator[BelowRule::operator]); |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - if (!empty($operandsByOperator[ InRule::operator ])) { |
|
| 557 | - $possibilities = reset($operandsByOperator[ InRule::operator ])->getPossibilities(); |
|
| 556 | + if (!empty($operandsByOperator[InRule::operator])) { |
|
| 557 | + $possibilities = reset($operandsByOperator[InRule::operator])->getPossibilities(); |
|
| 558 | 558 | |
| 559 | 559 | if (in_array($equalRule->getValue(), $possibilities)) { |
| 560 | - unset($operandsByOperator[ InRule::operator ]); |
|
| 560 | + unset($operandsByOperator[InRule::operator]); |
|
| 561 | 561 | } |
| 562 | 562 | else { |
| 563 | 563 | // We flush possibilities of the InRule |
| 564 | 564 | // TODO Replace it by a FalseRule |
| 565 | - $operandsByOperator[ InRule::operator ][0]->setPossibilities([]); |
|
| 565 | + $operandsByOperator[InRule::operator][0]->setPossibilities([]); |
|
| 566 | 566 | // and also remove the equal rule to shorten the reste of the simplification process |
| 567 | - unset($operandsByOperator[ EqualRule::operator ]); |
|
| 567 | + unset($operandsByOperator[EqualRule::operator]); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if (!empty($operandsByOperator[ NotInRule::operator ])) { |
|
| 572 | - $notInRule = reset($operandsByOperator[ NotInRule::operator ]); |
|
| 571 | + if (!empty($operandsByOperator[NotInRule::operator])) { |
|
| 572 | + $notInRule = reset($operandsByOperator[NotInRule::operator]); |
|
| 573 | 573 | if (in_array($equalRule->getValue(), $notInRule->getPossibilities())) { |
| 574 | 574 | // ['field', '=', 4] && ['field', '!in', [4]...] <=> false |
| 575 | 575 | return []; |
| 576 | 576 | } |
| 577 | 577 | else { |
| 578 | - unset($operandsByOperator[ NotInRule::operator ]); |
|
| 578 | + unset($operandsByOperator[NotInRule::operator]); |
|
| 579 | 579 | } |
| 580 | 580 | // $notInRule->dump(true); |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - if (!empty($operandsByOperator[ BelowOrEqualRule::operator ])) { |
|
| 584 | - $belowOrEqualRule = reset($operandsByOperator[ BelowOrEqualRule::operator ]); |
|
| 583 | + if (!empty($operandsByOperator[BelowOrEqualRule::operator])) { |
|
| 584 | + $belowOrEqualRule = reset($operandsByOperator[BelowOrEqualRule::operator]); |
|
| 585 | 585 | if ($equalRule->getValue() <= $belowOrEqualRule->getMaximum()) { |
| 586 | - unset($operandsByOperator[ BelowOrEqualRule::operator ]); |
|
| 586 | + unset($operandsByOperator[BelowOrEqualRule::operator]); |
|
| 587 | 587 | } |
| 588 | 588 | else { |
| 589 | 589 | // ['field', '=', 4] && ['field', '<=', [3]...] <=> false |
@@ -591,10 +591,10 @@ discard block |
||
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - if (!empty($operandsByOperator[ AboveOrEqualRule::operator ])) { |
|
| 595 | - $aboveOrEqualRule = reset($operandsByOperator[ AboveOrEqualRule::operator ]); |
|
| 594 | + if (!empty($operandsByOperator[AboveOrEqualRule::operator])) { |
|
| 595 | + $aboveOrEqualRule = reset($operandsByOperator[AboveOrEqualRule::operator]); |
|
| 596 | 596 | if ($equalRule->getValue() >= $aboveOrEqualRule->getMinimum()) { |
| 597 | - unset($operandsByOperator[ AboveOrEqualRule::operator ]); |
|
| 597 | + unset($operandsByOperator[AboveOrEqualRule::operator]); |
|
| 598 | 598 | } |
| 599 | 599 | else { |
| 600 | 600 | // ['field', '=', 4] && ['field', '<=', [3]...] <=> false |
@@ -604,54 +604,54 @@ discard block |
||
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // NotEqualRule null comparisons |
| 607 | - if (!empty($operandsByOperator[ NotEqualRule::operator ])) { |
|
| 608 | - if (!empty($operandsByOperator[ NotEqualRule::operator ])) { |
|
| 609 | - foreach ($operandsByOperator[ NotEqualRule::operator ] as $i => $notEqualRule) { |
|
| 607 | + if (!empty($operandsByOperator[NotEqualRule::operator])) { |
|
| 608 | + if (!empty($operandsByOperator[NotEqualRule::operator])) { |
|
| 609 | + foreach ($operandsByOperator[NotEqualRule::operator] as $i => $notEqualRule) { |
|
| 610 | 610 | if ($notEqualRule->getValue() === null) { |
| 611 | - if (!empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 612 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 611 | + if (!empty($operandsByOperator[AboveRule::operator])) { |
|
| 612 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - if (!empty($operandsByOperator[ BelowRule::operator ])) { |
|
| 616 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 615 | + if (!empty($operandsByOperator[BelowRule::operator])) { |
|
| 616 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - if (!empty($operandsByOperator[ EqualRule::operator ])) { |
|
| 620 | - if (reset($operandsByOperator[ EqualRule::operator ])->getValue() !== null) { |
|
| 621 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 619 | + if (!empty($operandsByOperator[EqualRule::operator])) { |
|
| 620 | + if (reset($operandsByOperator[EqualRule::operator])->getValue() !== null) { |
|
| 621 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | else { |
| 626 | - if (!empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 627 | - if ($operandsByOperator[ AboveRule::operator ][0]->getMinimum() >= $notEqualRule->getValue()) { |
|
| 628 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 626 | + if (!empty($operandsByOperator[AboveRule::operator])) { |
|
| 627 | + if ($operandsByOperator[AboveRule::operator][0]->getMinimum() >= $notEqualRule->getValue()) { |
|
| 628 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - if (!empty($operandsByOperator[ BelowRule::operator ])) { |
|
| 633 | - if ($operandsByOperator[ BelowRule::operator ][0]->getMaximum() <= $notEqualRule->getValue()) { |
|
| 634 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 632 | + if (!empty($operandsByOperator[BelowRule::operator])) { |
|
| 633 | + if ($operandsByOperator[BelowRule::operator][0]->getMaximum() <= $notEqualRule->getValue()) { |
|
| 634 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - if (!empty($operandsByOperator[ NotInRule::operator ])) { |
|
| 640 | - $notInRule = reset($operandsByOperator[ NotInRule::operator ]); |
|
| 639 | + if (!empty($operandsByOperator[NotInRule::operator])) { |
|
| 640 | + $notInRule = reset($operandsByOperator[NotInRule::operator]); |
|
| 641 | 641 | if (!in_array($notEqualRule->getValue(), $notInRule->getPossibilities())) { |
| 642 | 642 | // TODO Replace it by a FalseRule |
| 643 | - $operandsByOperator[ NotInRule::operator ][0]->setPossibilities( |
|
| 643 | + $operandsByOperator[NotInRule::operator][0]->setPossibilities( |
|
| 644 | 644 | array_merge($notInRule->getPossibilities(), [$notEqualRule->getValue()]) |
| 645 | 645 | ); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
|
| 648 | + unset($operandsByOperator[NotEqualRule::operator][$i]); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | - if (!empty($operandsByOperator[ InRule::operator ])) { |
|
| 652 | - $inRule = reset($operandsByOperator[ InRule::operator ]); |
|
| 651 | + if (!empty($operandsByOperator[InRule::operator])) { |
|
| 652 | + $inRule = reset($operandsByOperator[InRule::operator]); |
|
| 653 | 653 | |
| 654 | - $operandsByOperator[ InRule::operator ][0]->setPossibilities( |
|
| 654 | + $operandsByOperator[InRule::operator][0]->setPossibilities( |
|
| 655 | 655 | array_diff($inRule->getPossibilities(), [$notEqualRule->getValue()]) |
| 656 | 656 | ); |
| 657 | 657 | } |
@@ -661,61 +661,61 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | // Comparison between InRules and NotInRules |
| 663 | 663 | // This is an optimization to avoid NotIn explosion |
| 664 | - if (!empty($operandsByOperator[ InRule::operator ])) { |
|
| 665 | - $inRule = $operandsByOperator[ InRule::operator ][0]; |
|
| 664 | + if (!empty($operandsByOperator[InRule::operator])) { |
|
| 665 | + $inRule = $operandsByOperator[InRule::operator][0]; |
|
| 666 | 666 | |
| 667 | - if (!empty($operandsByOperator[ NotInRule::operator ])) { |
|
| 668 | - $notInRule = reset($operandsByOperator[ NotInRule::operator ]); |
|
| 669 | - $operandsByOperator[ InRule::operator ][0]->setPossibilities( |
|
| 670 | - array_diff( $inRule->getPossibilities(), $notInRule->getPossibilities()) |
|
| 667 | + if (!empty($operandsByOperator[NotInRule::operator])) { |
|
| 668 | + $notInRule = reset($operandsByOperator[NotInRule::operator]); |
|
| 669 | + $operandsByOperator[InRule::operator][0]->setPossibilities( |
|
| 670 | + array_diff($inRule->getPossibilities(), $notInRule->getPossibilities()) |
|
| 671 | 671 | ); |
| 672 | - unset($operandsByOperator[ NotInRule::operator ]); |
|
| 672 | + unset($operandsByOperator[NotInRule::operator]); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - if (!empty($operandsByOperator[ BelowRule::operator ])) { |
|
| 676 | - $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getMaximum(); |
|
| 675 | + if (!empty($operandsByOperator[BelowRule::operator])) { |
|
| 676 | + $upper_limit = reset($operandsByOperator[BelowRule::operator])->getMaximum(); |
|
| 677 | 677 | |
| 678 | - $operandsByOperator[ InRule::operator ][0]->setPossibilities( |
|
| 679 | - array_filter( $inRule->getPossibilities(), function ($possibility) use ($upper_limit) { |
|
| 678 | + $operandsByOperator[InRule::operator][0]->setPossibilities( |
|
| 679 | + array_filter($inRule->getPossibilities(), function($possibility) use ($upper_limit) { |
|
| 680 | 680 | return $possibility < $upper_limit; |
| 681 | 681 | } ) |
| 682 | 682 | ); |
| 683 | 683 | |
| 684 | - unset($operandsByOperator[ BelowRule::operator ]); |
|
| 684 | + unset($operandsByOperator[BelowRule::operator]); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if (!empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 688 | - $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getMinimum(); |
|
| 687 | + if (!empty($operandsByOperator[AboveRule::operator])) { |
|
| 688 | + $lower_limit = reset($operandsByOperator[AboveRule::operator])->getMinimum(); |
|
| 689 | 689 | |
| 690 | - $operandsByOperator[ InRule::operator ][0]->setPossibilities( |
|
| 691 | - array_filter( $inRule->getPossibilities(), function ($possibility) use ($lower_limit) { |
|
| 690 | + $operandsByOperator[InRule::operator][0]->setPossibilities( |
|
| 691 | + array_filter($inRule->getPossibilities(), function($possibility) use ($lower_limit) { |
|
| 692 | 692 | return $possibility > $lower_limit; |
| 693 | 693 | } ) |
| 694 | 694 | ); |
| 695 | 695 | |
| 696 | - unset($operandsByOperator[ AboveRule::operator ]); |
|
| 696 | + unset($operandsByOperator[AboveRule::operator]); |
|
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | // Comparison between NotInRules and > or < |
| 701 | - if (!empty($operandsByOperator[ NotInRule::operator ])) { |
|
| 702 | - $notInRule = $operandsByOperator[ NotInRule::operator ][0]; |
|
| 701 | + if (!empty($operandsByOperator[NotInRule::operator])) { |
|
| 702 | + $notInRule = $operandsByOperator[NotInRule::operator][0]; |
|
| 703 | 703 | |
| 704 | - if (!empty($operandsByOperator[ BelowRule::operator ])) { |
|
| 705 | - $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getUpperLimit(); |
|
| 704 | + if (!empty($operandsByOperator[BelowRule::operator])) { |
|
| 705 | + $upper_limit = reset($operandsByOperator[BelowRule::operator])->getUpperLimit(); |
|
| 706 | 706 | |
| 707 | - $operandsByOperator[ NotInRule::operator ][0]->setPossibilities( |
|
| 708 | - array_filter( $notInRule->getPossibilities(), function ($possibility) use ($upper_limit) { |
|
| 707 | + $operandsByOperator[NotInRule::operator][0]->setPossibilities( |
|
| 708 | + array_filter($notInRule->getPossibilities(), function($possibility) use ($upper_limit) { |
|
| 709 | 709 | return $possibility < $upper_limit; |
| 710 | 710 | } ) |
| 711 | 711 | ); |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - if (!empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 715 | - $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getMinimum(); |
|
| 714 | + if (!empty($operandsByOperator[AboveRule::operator])) { |
|
| 715 | + $lower_limit = reset($operandsByOperator[AboveRule::operator])->getMinimum(); |
|
| 716 | 716 | |
| 717 | - $operandsByOperator[ NotInRule::operator ][0]->setPossibilities( |
|
| 718 | - array_filter( $notInRule->getPossibilities(), function ($possibility) use ($lower_limit) { |
|
| 717 | + $operandsByOperator[NotInRule::operator][0]->setPossibilities( |
|
| 718 | + array_filter($notInRule->getPossibilities(), function($possibility) use ($lower_limit) { |
|
| 719 | 719 | return $possibility > $lower_limit; |
| 720 | 720 | } ) |
| 721 | 721 | ); |
@@ -723,25 +723,25 @@ discard block |
||
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | // Comparison between <= and > or < |
| 726 | - if (!empty($operandsByOperator[ BelowOrEqualRule::operator ])) { |
|
| 727 | - $belowOrEqualRule = $operandsByOperator[ BelowOrEqualRule::operator ][0]; |
|
| 726 | + if (!empty($operandsByOperator[BelowOrEqualRule::operator])) { |
|
| 727 | + $belowOrEqualRule = $operandsByOperator[BelowOrEqualRule::operator][0]; |
|
| 728 | 728 | |
| 729 | - if (!empty($operandsByOperator[ BelowRule::operator ])) { |
|
| 730 | - $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getUpperLimit(); |
|
| 729 | + if (!empty($operandsByOperator[BelowRule::operator])) { |
|
| 730 | + $upper_limit = reset($operandsByOperator[BelowRule::operator])->getUpperLimit(); |
|
| 731 | 731 | |
| 732 | 732 | if ($belowOrEqualRule->getMaximum() >= $upper_limit) { |
| 733 | 733 | // [field < 3] && [field <= 3] |
| 734 | 734 | // [field < 3] && [field <= 4] |
| 735 | - unset($operandsByOperator[ BelowOrEqualRule::operator ][0]); |
|
| 735 | + unset($operandsByOperator[BelowOrEqualRule::operator][0]); |
|
| 736 | 736 | } |
| 737 | 737 | else { |
| 738 | 738 | // [field < 3] && [field <= 2] |
| 739 | - unset($operandsByOperator[ BelowRule::operator ][0]); |
|
| 739 | + unset($operandsByOperator[BelowRule::operator][0]); |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if (!empty($operandsByOperator[ AboveRule::operator ])) { |
|
| 744 | - $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getLowerLimit(); |
|
| 743 | + if (!empty($operandsByOperator[AboveRule::operator])) { |
|
| 744 | + $lower_limit = reset($operandsByOperator[AboveRule::operator])->getLowerLimit(); |
|
| 745 | 745 | |
| 746 | 746 | if ($belowOrEqualRule->getMaximum() <= $lower_limit) { |
| 747 | 747 | // [field > 3] && [field <= 2] <=> false |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if (!empty($operandsByOperator[ AboveOrEqualRule::operator ])) { |
|
| 753 | - $minimum = reset($operandsByOperator[ AboveOrEqualRule::operator ])->getMinimum(); |
|
| 752 | + if (!empty($operandsByOperator[AboveOrEqualRule::operator])) { |
|
| 753 | + $minimum = reset($operandsByOperator[AboveOrEqualRule::operator])->getMinimum(); |
|
| 754 | 754 | |
| 755 | 755 | if ($belowOrEqualRule->getMaximum() < $minimum) { |
| 756 | 756 | // [field <= 3] && [field >= 4] <=> false |
@@ -758,11 +758,11 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | elseif ($belowOrEqualRule->getMaximum() == $minimum) { |
| 760 | 760 | // [field <= 3] && [field >= 3] <=> [field = 3] |
| 761 | - unset($operandsByOperator[ BelowOrEqualRule::operator ]); |
|
| 762 | - unset($operandsByOperator[ AboveOrEqualRule::operator ]); |
|
| 763 | - $operandsByOperator[ EqualRule::operator ][] = new EqualRule($field, $minimum); |
|
| 761 | + unset($operandsByOperator[BelowOrEqualRule::operator]); |
|
| 762 | + unset($operandsByOperator[AboveOrEqualRule::operator]); |
|
| 763 | + $operandsByOperator[EqualRule::operator][] = new EqualRule($field, $minimum); |
|
| 764 | 764 | |
| 765 | - if (count($operandsByOperator[ EqualRule::operator ]) > 1) { |
|
| 765 | + if (count($operandsByOperator[EqualRule::operator]) > 1) { |
|
| 766 | 766 | $operandsByOperator = self::simplifyDifferentOperandsForField($field, $operandsByOperator); |
| 767 | 767 | } |
| 768 | 768 | } |
@@ -781,10 +781,10 @@ discard block |
||
| 781 | 781 | public function setOperandsOrReplaceByOperation($new_operands) |
| 782 | 782 | { |
| 783 | 783 | try { |
| 784 | - return $this->setOperands( $new_operands ); |
|
| 784 | + return $this->setOperands($new_operands); |
|
| 785 | 785 | } |
| 786 | 786 | catch (\LogicException $e) { |
| 787 | - return new AndRule( $new_operands ); |
|
| 787 | + return new AndRule($new_operands); |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | |
@@ -62,15 +62,13 @@ discard block |
||
| 62 | 62 | foreach ($upLiftedOr->getOperands() as $upLifdtedOperand) { |
| 63 | 63 | $upLifdtedOperand->addOperand( $operand->copy() ); |
| 64 | 64 | } |
| 65 | - } |
|
| 66 | - else { |
|
| 65 | + } else { |
|
| 67 | 66 | throw new \LogicException( |
| 68 | 67 | "Rootifying disjunctions MUST be done after negations removal instead of '".$operand."' \n" |
| 69 | 68 | .$operand |
| 70 | 69 | ); |
| 71 | 70 | } |
| 72 | - } |
|
| 73 | - elseif ($operand instanceof OrRule && $operand->isNormalizationAllowed($simplification_options)) { |
|
| 71 | + } elseif ($operand instanceof OrRule && $operand->isNormalizationAllowed($simplification_options)) { |
|
| 74 | 72 | |
| 75 | 73 | // If an operand is an Or, me transform the current |
| 76 | 74 | // (A' || A") && (B') <=> (A' && B') || (A" && B'); |
@@ -90,8 +88,7 @@ discard block |
||
| 90 | 88 | } |
| 91 | 89 | |
| 92 | 90 | $upLiftedOr = $newUpLiftedOr; |
| 93 | - } |
|
| 94 | - else { |
|
| 91 | + } else { |
|
| 95 | 92 | // append the operand to all the operands of the $upLiftedOr |
| 96 | 93 | foreach ($upLiftedOr->getOperands() as $upLifdtedOperand) { |
| 97 | 94 | if (!$upLifdtedOperand instanceof AndRule) { |
@@ -147,16 +144,14 @@ discard block |
||
| 147 | 144 | [self::operator], |
| 148 | 145 | $operands_semantic_ids |
| 149 | 146 | ); |
| 150 | - } |
|
| 151 | - else { |
|
| 147 | + } else { |
|
| 152 | 148 | foreach ($operands as $operand) { |
| 153 | 149 | $operands_as_array[] = $operand->toArray($options); |
| 154 | 150 | } |
| 155 | 151 | |
| 156 | 152 | if (!$options['show_instance']) { |
| 157 | 153 | return $this->cache['array'] = $operands_as_array; |
| 158 | - } |
|
| 159 | - else { |
|
| 154 | + } else { |
|
| 160 | 155 | return $operands_as_array; |
| 161 | 156 | } |
| 162 | 157 | } |
@@ -299,8 +294,7 @@ discard block |
||
| 299 | 294 | $this->operands = []; |
| 300 | 295 | return $this; |
| 301 | 296 | } |
| 302 | - } |
|
| 303 | - elseif ( !empty($operandsByOperator[ BelowRule::operator ]) |
|
| 297 | + } elseif ( !empty($operandsByOperator[ BelowRule::operator ]) |
|
| 304 | 298 | && !empty($operandsByOperator[ AboveRule::operator ])) { |
| 305 | 299 | $aboveRule = reset($operandsByOperator[ AboveRule::operator ]); |
| 306 | 300 | $belowRule = reset($operandsByOperator[ BelowRule::operator ]); |
@@ -372,8 +366,7 @@ discard block |
||
| 372 | 366 | return 1; |
| 373 | 367 | }); |
| 374 | 368 | $operands = [reset($operands)]; |
| 375 | - } |
|
| 376 | - elseif ($operator == BelowRule::operator) { |
|
| 369 | + } elseif ($operator == BelowRule::operator) { |
|
| 377 | 370 | usort($operands, function( BelowRule $a, BelowRule $b ) { |
| 378 | 371 | if ($a->getMaximum() === null) { |
| 379 | 372 | return 1; |
@@ -390,8 +383,7 @@ discard block |
||
| 390 | 383 | return 1; |
| 391 | 384 | }); |
| 392 | 385 | $operands = [reset($operands)]; |
| 393 | - } |
|
| 394 | - elseif ($operator == EqualRule::operator) { |
|
| 386 | + } elseif ($operator == EqualRule::operator) { |
|
| 395 | 387 | // TODO add an option for the support strict comparison |
| 396 | 388 | foreach ($operands as $i => $operand) { |
| 397 | 389 | if (!isset($previous_operand)) { |
@@ -402,8 +394,7 @@ discard block |
||
| 402 | 394 | if ($previous_operand == $operand) { |
| 403 | 395 | unset($operands[$i]); |
| 404 | 396 | continue; |
| 405 | - } |
|
| 406 | - else { |
|
| 397 | + } else { |
|
| 407 | 398 | // Same field expected to be two differents |
| 408 | 399 | // values at the same time has no sens so |
| 409 | 400 | // we remove all the operands of the current |
@@ -411,8 +402,7 @@ discard block |
||
| 411 | 402 | return []; |
| 412 | 403 | } |
| 413 | 404 | } |
| 414 | - } |
|
| 415 | - elseif ($operator == InRule::operator) { |
|
| 405 | + } elseif ($operator == InRule::operator) { |
|
| 416 | 406 | $first_in = reset($operands); |
| 417 | 407 | |
| 418 | 408 | foreach ($operands as $i => $next_in) { |
@@ -432,8 +422,7 @@ discard block |
||
| 432 | 422 | if (!$first_in->getPossibilities()) { |
| 433 | 423 | return []; |
| 434 | 424 | } |
| 435 | - } |
|
| 436 | - elseif ($operator == NotInRule::operator) { |
|
| 425 | + } elseif ($operator == NotInRule::operator) { |
|
| 437 | 426 | $first_not_in = reset($operands); |
| 438 | 427 | |
| 439 | 428 | foreach ($operands as $i => $next_not_in) { |
@@ -449,8 +438,7 @@ discard block |
||
| 449 | 438 | unset($operands[$i]); |
| 450 | 439 | } |
| 451 | 440 | } |
| 452 | - } |
|
| 453 | - catch (\Exception $e) { |
|
| 441 | + } catch (\Exception $e) { |
|
| 454 | 442 | VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage() . "\n" . var_export([ |
| 455 | 443 | 'operands' => $operands, |
| 456 | 444 | // 'this' => $this, |
@@ -525,12 +513,10 @@ discard block |
||
| 525 | 513 | if ($equalRule->getValue() !== null) { |
| 526 | 514 | if ($not_equal_rule->getValue() === null) { // means if exists <=> equals something |
| 527 | 515 | unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
| 528 | - } |
|
| 529 | - elseif ($not_equal_rule->getValue() != $equalRule->getValue()) { |
|
| 516 | + } elseif ($not_equal_rule->getValue() != $equalRule->getValue()) { |
|
| 530 | 517 | unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
| 531 | 518 | } |
| 532 | - } |
|
| 533 | - elseif ($equalRule->getValue() === null ) { |
|
| 519 | + } elseif ($equalRule->getValue() === null ) { |
|
| 534 | 520 | if ($not_equal_rule->getValue() !== null) { |
| 535 | 521 | unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
| 536 | 522 | } |
@@ -558,8 +544,7 @@ discard block |
||
| 558 | 544 | |
| 559 | 545 | if (in_array($equalRule->getValue(), $possibilities)) { |
| 560 | 546 | unset($operandsByOperator[ InRule::operator ]); |
| 561 | - } |
|
| 562 | - else { |
|
| 547 | + } else { |
|
| 563 | 548 | // We flush possibilities of the InRule |
| 564 | 549 | // TODO Replace it by a FalseRule |
| 565 | 550 | $operandsByOperator[ InRule::operator ][0]->setPossibilities([]); |
@@ -573,8 +558,7 @@ discard block |
||
| 573 | 558 | if (in_array($equalRule->getValue(), $notInRule->getPossibilities())) { |
| 574 | 559 | // ['field', '=', 4] && ['field', '!in', [4]...] <=> false |
| 575 | 560 | return []; |
| 576 | - } |
|
| 577 | - else { |
|
| 561 | + } else { |
|
| 578 | 562 | unset($operandsByOperator[ NotInRule::operator ]); |
| 579 | 563 | } |
| 580 | 564 | // $notInRule->dump(true); |
@@ -584,8 +568,7 @@ discard block |
||
| 584 | 568 | $belowOrEqualRule = reset($operandsByOperator[ BelowOrEqualRule::operator ]); |
| 585 | 569 | if ($equalRule->getValue() <= $belowOrEqualRule->getMaximum()) { |
| 586 | 570 | unset($operandsByOperator[ BelowOrEqualRule::operator ]); |
| 587 | - } |
|
| 588 | - else { |
|
| 571 | + } else { |
|
| 589 | 572 | // ['field', '=', 4] && ['field', '<=', [3]...] <=> false |
| 590 | 573 | return []; |
| 591 | 574 | } |
@@ -595,8 +578,7 @@ discard block |
||
| 595 | 578 | $aboveOrEqualRule = reset($operandsByOperator[ AboveOrEqualRule::operator ]); |
| 596 | 579 | if ($equalRule->getValue() >= $aboveOrEqualRule->getMinimum()) { |
| 597 | 580 | unset($operandsByOperator[ AboveOrEqualRule::operator ]); |
| 598 | - } |
|
| 599 | - else { |
|
| 581 | + } else { |
|
| 600 | 582 | // ['field', '=', 4] && ['field', '<=', [3]...] <=> false |
| 601 | 583 | return []; |
| 602 | 584 | } |
@@ -621,8 +603,7 @@ discard block |
||
| 621 | 603 | unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
| 622 | 604 | } |
| 623 | 605 | } |
| 624 | - } |
|
| 625 | - else { |
|
| 606 | + } else { |
|
| 626 | 607 | if (!empty($operandsByOperator[ AboveRule::operator ])) { |
| 627 | 608 | if ($operandsByOperator[ AboveRule::operator ][0]->getMinimum() >= $notEqualRule->getValue()) { |
| 628 | 609 | unset($operandsByOperator[ NotEqualRule::operator ][$i]); |
@@ -733,8 +714,7 @@ discard block |
||
| 733 | 714 | // [field < 3] && [field <= 3] |
| 734 | 715 | // [field < 3] && [field <= 4] |
| 735 | 716 | unset($operandsByOperator[ BelowOrEqualRule::operator ][0]); |
| 736 | - } |
|
| 737 | - else { |
|
| 717 | + } else { |
|
| 738 | 718 | // [field < 3] && [field <= 2] |
| 739 | 719 | unset($operandsByOperator[ BelowRule::operator ][0]); |
| 740 | 720 | } |
@@ -755,8 +735,7 @@ discard block |
||
| 755 | 735 | if ($belowOrEqualRule->getMaximum() < $minimum) { |
| 756 | 736 | // [field <= 3] && [field >= 4] <=> false |
| 757 | 737 | return []; |
| 758 | - } |
|
| 759 | - elseif ($belowOrEqualRule->getMaximum() == $minimum) { |
|
| 738 | + } elseif ($belowOrEqualRule->getMaximum() == $minimum) { |
|
| 760 | 739 | // [field <= 3] && [field >= 3] <=> [field = 3] |
| 761 | 740 | unset($operandsByOperator[ BelowOrEqualRule::operator ]); |
| 762 | 741 | unset($operandsByOperator[ AboveOrEqualRule::operator ]); |
@@ -782,8 +761,7 @@ discard block |
||
| 782 | 761 | { |
| 783 | 762 | try { |
| 784 | 763 | return $this->setOperands( $new_operands ); |
| 785 | - } |
|
| 786 | - catch (\LogicException $e) { |
|
| 764 | + } catch (\LogicException $e) { |
|
| 787 | 765 | return new AndRule( $new_operands ); |
| 788 | 766 | } |
| 789 | 767 | } |
@@ -19,17 +19,17 @@ discard block |
||
| 19 | 19 | public function removeSameOperationOperands(array $simplification_options) |
| 20 | 20 | { |
| 21 | 21 | foreach ($this->operands as $i => &$operand) { |
| 22 | - if ( ! is_a($operand, OrRule::class)) { |
|
| 22 | + if (!is_a($operand, OrRule::class)) { |
|
| 23 | 23 | continue; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - if ( !$operand->isNormalizationAllowed($simplification_options) ) { |
|
| 26 | + if (!$operand->isNormalizationAllowed($simplification_options)) { |
|
| 27 | 27 | continue; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // Id AND is an operand on AND they can be merge (and the same with OR) |
| 31 | 31 | foreach ($operand->getOperands() as $sub_operand) { |
| 32 | - $this->addOperand( $sub_operand->copy() ); |
|
| 32 | + $this->addOperand($sub_operand->copy()); |
|
| 33 | 33 | } |
| 34 | 34 | unset($this->operands[$i]); |
| 35 | 35 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | return $this->copy(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $this->moveSimplificationStepForward( self::rootify_disjunctions, $simplification_options ); |
|
| 56 | + $this->moveSimplificationStepForward(self::rootify_disjunctions, $simplification_options); |
|
| 57 | 57 | |
| 58 | 58 | $upLiftedOperands = []; |
| 59 | 59 | foreach ($this->getOperands() as $operand) { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - public function toArray(array $options=[]) |
|
| 83 | + public function toArray(array $options = []) |
|
| 84 | 84 | { |
| 85 | 85 | $default_options = [ |
| 86 | 86 | 'show_instance' => false, |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | 'semantic' => false, |
| 89 | 89 | ]; |
| 90 | 90 | foreach ($default_options as $default_option => &$default_value) { |
| 91 | - if (!isset($options[ $default_option ])) { |
|
| 92 | - $options[ $default_option ] = $default_value; |
|
| 91 | + if (!isset($options[$default_option])) { |
|
| 92 | + $options[$default_option] = $default_value; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | */ |
| 131 | - public function toString(array $options=[]) |
|
| 131 | + public function toString(array $options = []) |
|
| 132 | 132 | { |
| 133 | 133 | $operator = self::operator; |
| 134 | 134 | if (!$this->operands) { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | foreach ($this->operands as $operand) { |
| 144 | 144 | $out .= implode("\n", array_map(function($line) use (&$indent_unit) { |
| 145 | 145 | return $indent_unit.$line; |
| 146 | - }, explode("\n", $operand->toString($options)) )) . ",$line_break"; |
|
| 146 | + }, explode("\n", $operand->toString($options)))).",$line_break"; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $out .= ']'; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | try { |
| 166 | 166 | if ($operator == AboveRule::operator) { |
| 167 | - usort($operands, function( AboveRule $a, AboveRule $b ) { |
|
| 167 | + usort($operands, function(AboveRule $a, AboveRule $b) { |
|
| 168 | 168 | if ($a->getMinimum() === null) { |
| 169 | 169 | return 1; |
| 170 | 170 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $operands = [reset($operands)]; |
| 183 | 183 | } |
| 184 | 184 | elseif ($operator == BelowRule::operator) { |
| 185 | - usort($operands, function( BelowRule $a, BelowRule $b ) { |
|
| 185 | + usort($operands, function(BelowRule $a, BelowRule $b) { |
|
| 186 | 186 | if ($a->getMaximum() === null) { |
| 187 | 187 | return 1; |
| 188 | 188 | } |
@@ -207,17 +207,17 @@ discard block |
||
| 207 | 207 | continue; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $first_in->setPossibilities( array_merge( |
|
| 210 | + $first_in->setPossibilities(array_merge( |
|
| 211 | 211 | $first_in->getPossibilities(), |
| 212 | 212 | $next_in->getPossibilities() |
| 213 | - ) ); |
|
| 213 | + )); |
|
| 214 | 214 | |
| 215 | 215 | unset($operands[$i]); |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | catch (\Exception $e) { |
| 220 | - VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage() . "\n" . var_export([ |
|
| 220 | + VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage()."\n".var_export([ |
|
| 221 | 221 | 'operands' => $operands, |
| 222 | 222 | ], true) |
| 223 | 223 | ); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | throw $e; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - $operandsByFields[ $field ][ $operator ] = $operands; |
|
| 229 | + $operandsByFields[$field][$operator] = $operands; |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return bool If the rule can have a solution or not |
| 273 | 273 | */ |
| 274 | - public function hasSolution(array $simplification_options=[]) |
|
| 274 | + public function hasSolution(array $simplification_options = []) |
|
| 275 | 275 | { |
| 276 | 276 | if (!$this->isNormalizationAllowed($simplification_options)) { |
| 277 | 277 | return true; |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | public function setOperandsOrReplaceByOperation($new_operands) |
| 299 | 299 | { |
| 300 | 300 | try { |
| 301 | - return $this->setOperands( $new_operands ); |
|
| 301 | + return $this->setOperands($new_operands); |
|
| 302 | 302 | } |
| 303 | 303 | catch (\LogicException $e) { |
| 304 | - return new OrRule( $new_operands ); |
|
| 304 | + return new OrRule($new_operands); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
@@ -66,8 +66,7 @@ discard block |
||
| 66 | 66 | foreach ($operand->getOperands() as $subOperand) { |
| 67 | 67 | $upLiftedOperands[] = $subOperand; |
| 68 | 68 | } |
| 69 | - } |
|
| 70 | - else { |
|
| 69 | + } else { |
|
| 71 | 70 | $upLiftedOperands[] = $operand; |
| 72 | 71 | } |
| 73 | 72 | } |
@@ -111,16 +110,14 @@ discard block |
||
| 111 | 110 | [self::operator], |
| 112 | 111 | $operands_semantic_ids |
| 113 | 112 | ); |
| 114 | - } |
|
| 115 | - else { |
|
| 113 | + } else { |
|
| 116 | 114 | foreach ($operands as $operand) { |
| 117 | 115 | $operands_as_array[] = $operand->toArray($options); |
| 118 | 116 | } |
| 119 | 117 | |
| 120 | 118 | if (!$options['show_instance']) { |
| 121 | 119 | return $this->cache['array'] = $operands_as_array; |
| 122 | - } |
|
| 123 | - else { |
|
| 120 | + } else { |
|
| 124 | 121 | return $operands_as_array; |
| 125 | 122 | } |
| 126 | 123 | } |
@@ -180,8 +177,7 @@ discard block |
||
| 180 | 177 | return 1; |
| 181 | 178 | }); |
| 182 | 179 | $operands = [reset($operands)]; |
| 183 | - } |
|
| 184 | - elseif ($operator == BelowRule::operator) { |
|
| 180 | + } elseif ($operator == BelowRule::operator) { |
|
| 185 | 181 | usort($operands, function( BelowRule $a, BelowRule $b ) { |
| 186 | 182 | if ($a->getMaximum() === null) { |
| 187 | 183 | return 1; |
@@ -198,8 +194,7 @@ discard block |
||
| 198 | 194 | return 1; |
| 199 | 195 | }); |
| 200 | 196 | $operands = [reset($operands)]; |
| 201 | - } |
|
| 202 | - elseif ($operator == InRule::operator) { |
|
| 197 | + } elseif ($operator == InRule::operator) { |
|
| 203 | 198 | $first_in = reset($operands); |
| 204 | 199 | |
| 205 | 200 | foreach ($operands as $i => $next_in) { |
@@ -215,8 +210,7 @@ discard block |
||
| 215 | 210 | unset($operands[$i]); |
| 216 | 211 | } |
| 217 | 212 | } |
| 218 | - } |
|
| 219 | - catch (\Exception $e) { |
|
| 213 | + } catch (\Exception $e) { |
|
| 220 | 214 | VisibilityViolator::setHiddenProperty($e, 'message', $e->getMessage() . "\n" . var_export([ |
| 221 | 215 | 'operands' => $operands, |
| 222 | 216 | ], true) |
@@ -254,8 +248,7 @@ discard block |
||
| 254 | 248 | unset($this->operands[$i]); |
| 255 | 249 | continue; |
| 256 | 250 | } |
| 257 | - } |
|
| 258 | - else { |
|
| 251 | + } else { |
|
| 259 | 252 | if (!$this->operands[$i]->hasSolution()) { |
| 260 | 253 | unset($this->operands[$i]); |
| 261 | 254 | } |
@@ -299,8 +292,7 @@ discard block |
||
| 299 | 292 | { |
| 300 | 293 | try { |
| 301 | 294 | return $this->setOperands( $new_operands ); |
| 302 | - } |
|
| 303 | - catch (\LogicException $e) { |
|
| 295 | + } catch (\LogicException $e) { |
|
| 304 | 296 | return new OrRule( $new_operands ); |
| 305 | 297 | } |
| 306 | 298 | } |
@@ -21,8 +21,7 @@ |
||
| 21 | 21 | // So if the two limits are equal we only consider the equality |
| 22 | 22 | $this->addOperand( new EqualRule($field, $limits[0]) ); |
| 23 | 23 | $this->addOperand( new EqualRule($field, $limits[0]) ); |
| 24 | - } |
|
| 25 | - else { |
|
| 24 | + } else { |
|
| 26 | 25 | $this->addOperand( new AboveOrEqualRule($field, $limits[0]) ); |
| 27 | 26 | $this->addOperand( new BelowRule($field, $limits[1]) ); |
| 28 | 27 | } |