@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | * |
| 536 | 536 | * This helpes to ease the result of simplify() |
| 537 | 537 | * |
| 538 | - * @return OrRule |
|
| 538 | + * @return LogicalFilter |
|
| 539 | 539 | */ |
| 540 | 540 | public function addMinimalCase() |
| 541 | 541 | { |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * |
| 591 | 591 | * @param $debug Provides a source oriented dump. |
| 592 | 592 | * |
| 593 | - * @return array A description of the rules. |
|
| 593 | + * @return string A description of the rules. |
|
| 594 | 594 | */ |
| 595 | 595 | public function toString(array $options=[]) |
| 596 | 596 | { |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | * @param array|callable Associative array of renamings or callable |
| 669 | 669 | * that would rename the fields. |
| 670 | 670 | * |
| 671 | - * @return string $this |
|
| 671 | + * @return LogicalFilter $this |
|
| 672 | 672 | */ |
| 673 | 673 | public function removeRules($filter) |
| 674 | 674 | { |
@@ -711,8 +711,8 @@ discard block |
||
| 711 | 711 | * @param array|callable Associative array of renamings or callable |
| 712 | 712 | * that would rename the fields. |
| 713 | 713 | * |
| 714 | - * @return array The rules matching the filter |
|
| 715 | - * @return array $options debug | leaves_only | clean_empty_branches |
|
| 714 | + * @return LogicalFilter The rules matching the filter |
|
| 715 | + * @return LogicalFilter $options debug | leaves_only | clean_empty_branches |
|
| 716 | 716 | * |
| 717 | 717 | * |
| 718 | 718 | * @todo Merge with rules |
@@ -823,6 +823,7 @@ discard block |
||
| 823 | 823 | * @param array|LogicalFilter |
| 824 | 824 | * @param array|callable Associative array of renamings or callable |
| 825 | 825 | * that would rename the fields. |
| 826 | + * @param \Closure $options |
|
| 826 | 827 | * |
| 827 | 828 | * @return array The rules matching the filter |
| 828 | 829 | */ |
@@ -1009,7 +1010,6 @@ discard block |
||
| 1009 | 1010 | } |
| 1010 | 1011 | |
| 1011 | 1012 | /** |
| 1012 | - * @param bool $exit=false |
|
| 1013 | 1013 | * @param array $options + callstack_depth=2 The level of the caller to dump |
| 1014 | 1014 | * + mode='string' in 'export' | 'dump' | 'string' |
| 1015 | 1015 | * |
@@ -1104,10 +1104,9 @@ discard block |
||
| 1104 | 1104 | * Applies the current instance to a value (and its index optionnally). |
| 1105 | 1105 | * |
| 1106 | 1106 | * @param mixed $value_to_check |
| 1107 | - * @param scalar $index |
|
| 1108 | 1107 | * @param Filterer|callable|null $filterer |
| 1109 | 1108 | * |
| 1110 | - * @return AbstractRule|false|true + False if the filter doesn't validates |
|
| 1109 | + * @return boolean + False if the filter doesn't validates |
|
| 1111 | 1110 | * + Null if the target has no sens (operation filtered by field for example) |
| 1112 | 1111 | * + A rule tree containing the first matching case if there is one. |
| 1113 | 1112 | */ |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @see self::addRules |
| 53 | 53 | */ |
| 54 | - public function __construct($rules=[], Filterer $default_filterer=null, array $options=[]) |
|
| 54 | + public function __construct($rules = [], Filterer $default_filterer = null, array $options = []) |
|
| 55 | 55 | { |
| 56 | 56 | if ($rules instanceof AbstractRule) { |
| 57 | 57 | $rules = $rules->copy(); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | if ($rules) { |
| 75 | - $this->and_( $rules ); |
|
| 75 | + $this->and_($rules); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function getDefaultFilterer() |
| 82 | 82 | { |
| 83 | - if (! $this->default_filterer) { |
|
| 83 | + if ( ! $this->default_filterer) { |
|
| 84 | 84 | $this->default_filterer = new PhpFilterer(); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if ( 3 == count($rules_description) |
|
| 164 | + if (3 == count($rules_description) |
|
| 165 | 165 | && is_string($rules_description[0]) |
| 166 | 166 | && is_string($rules_description[1]) |
| 167 | 167 | ) { |
@@ -177,30 +177,30 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | elseif (count($rules_description) == count(array_filter($rules_description, function($arg) { |
| 179 | 179 | return $arg instanceof LogicalFilter; |
| 180 | - })) ) { |
|
| 180 | + }))) { |
|
| 181 | 181 | // Already instanciated rules |
| 182 | 182 | foreach ($rules_description as $i => $filter) { |
| 183 | 183 | $rules = $filter->getRules(); |
| 184 | 184 | if (null !== $rules) { |
| 185 | - $this->addRule( $rules, $operation); |
|
| 185 | + $this->addRule($rules, $operation); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | elseif (count($rules_description) == count(array_filter($rules_description, function($arg) { |
| 190 | 190 | return $arg instanceof AbstractRule; |
| 191 | - })) ) { |
|
| 191 | + }))) { |
|
| 192 | 192 | // Already instanciated rules |
| 193 | 193 | foreach ($rules_description as $i => $new_rule) { |
| 194 | - $this->addRule( $new_rule, $operation); |
|
| 194 | + $this->addRule($new_rule, $operation); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | elseif (1 == count($rules_description) && is_array($rules_description[0])) { |
| 198 | 198 | if (count($rules_description[0]) == count(array_filter($rules_description[0], function($arg) { |
| 199 | 199 | return $arg instanceof AbstractRule; |
| 200 | - })) ) { |
|
| 200 | + }))) { |
|
| 201 | 201 | // Case of $filter->or_([AbstractRule, AbstractRule, AbstractRule, ...]) |
| 202 | 202 | foreach ($rules_description[0] as $i => $new_rule) { |
| 203 | - $this->addRule( $new_rule, $operation ); |
|
| 203 | + $this->addRule($new_rule, $operation); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | else { |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | * |
| 233 | 233 | * @return $this |
| 234 | 234 | */ |
| 235 | - protected function addRule( AbstractRule $rule, $operation=AndRule::operator ) |
|
| 235 | + protected function addRule(AbstractRule $rule, $operation = AndRule::operator) |
|
| 236 | 236 | { |
| 237 | - if ($this->rules && in_array( get_class($this->rules), [AndRule::class, OrRule::class]) |
|
| 238 | - && ! $this->rules->getOperands() ) { |
|
| 237 | + if ($this->rules && in_array(get_class($this->rules), [AndRule::class, OrRule::class]) |
|
| 238 | + && ! $this->rules->getOperands()) { |
|
| 239 | 239 | throw new \LogicException( |
| 240 | 240 | "You are trying to add rules to a LogicalFilter which had " |
| 241 | 241 | ."only contradictory rules that have already been simplified: " |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | array $rules_composition, |
| 285 | 285 | AbstractOperationRule $recursion_position |
| 286 | 286 | ) { |
| 287 | - if ( ! array_filter($rules_composition, function ($rule_composition_part) { |
|
| 287 | + if ( ! array_filter($rules_composition, function($rule_composition_part) { |
|
| 288 | 288 | return is_string($rule_composition_part); |
| 289 | 289 | })) { |
| 290 | 290 | // at least one operator is required for operation rules |
@@ -293,13 +293,13 @@ discard block |
||
| 293 | 293 | .var_export($rules_composition, true) |
| 294 | 294 | ); |
| 295 | 295 | } |
| 296 | - elseif ( 3 == count($rules_composition) |
|
| 297 | - && ! in_array( AndRule::operator, $rules_composition, true ) |
|
| 298 | - && ! in_array( OrRule::operator, $rules_composition, true ) |
|
| 299 | - && ! in_array( NotRule::operator, $rules_composition, true ) |
|
| 300 | - && ! in_array( AbstractRule::findSymbolicOperator( AndRule::operator ), $rules_composition, true ) |
|
| 301 | - && ! in_array( AbstractRule::findSymbolicOperator( OrRule::operator ), $rules_composition, true ) |
|
| 302 | - && ! in_array( AbstractRule::findSymbolicOperator( NotRule::operator ), $rules_composition, true ) |
|
| 296 | + elseif (3 == count($rules_composition) |
|
| 297 | + && ! in_array(AndRule::operator, $rules_composition, true) |
|
| 298 | + && ! in_array(OrRule::operator, $rules_composition, true) |
|
| 299 | + && ! in_array(NotRule::operator, $rules_composition, true) |
|
| 300 | + && ! in_array(AbstractRule::findSymbolicOperator(AndRule::operator), $rules_composition, true) |
|
| 301 | + && ! in_array(AbstractRule::findSymbolicOperator(OrRule::operator), $rules_composition, true) |
|
| 302 | + && ! in_array(AbstractRule::findSymbolicOperator(NotRule::operator), $rules_composition, true) |
|
| 303 | 303 | ) { |
| 304 | 304 | // atomic or composit rules |
| 305 | 305 | $operand_left = $rules_composition[0]; |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | $rule = AbstractRule::generateSimpleRule( |
| 310 | 310 | $operand_left, $operation, $operand_right, $this->getOptions() |
| 311 | 311 | ); |
| 312 | - $recursion_position->addOperand( $rule ); |
|
| 312 | + $recursion_position->addOperand($rule); |
|
| 313 | 313 | } |
| 314 | 314 | else { |
| 315 | 315 | // operations |
| 316 | - if ( NotRule::operator == $rules_composition[0] |
|
| 317 | - || $rules_composition[0] == AbstractRule::findSymbolicOperator( NotRule::operator ) ) { |
|
| 316 | + if (NotRule::operator == $rules_composition[0] |
|
| 317 | + || $rules_composition[0] == AbstractRule::findSymbolicOperator(NotRule::operator)) { |
|
| 318 | 318 | $rule = new NotRule(); |
| 319 | 319 | } |
| 320 | - elseif (in_array( AndRule::operator, $rules_composition ) |
|
| 321 | - || in_array( AbstractRule::findSymbolicOperator( AndRule::operator ), $rules_composition )) { |
|
| 320 | + elseif (in_array(AndRule::operator, $rules_composition) |
|
| 321 | + || in_array(AbstractRule::findSymbolicOperator(AndRule::operator), $rules_composition)) { |
|
| 322 | 322 | $rule = new AndRule(); |
| 323 | 323 | } |
| 324 | - elseif (in_array( OrRule::operator, $rules_composition ) |
|
| 325 | - || in_array( AbstractRule::findSymbolicOperator( OrRule::operator ), $rules_composition ) ) { |
|
| 324 | + elseif (in_array(OrRule::operator, $rules_composition) |
|
| 325 | + || in_array(AbstractRule::findSymbolicOperator(OrRule::operator), $rules_composition)) { |
|
| 326 | 326 | $rule = new OrRule(); |
| 327 | 327 | } |
| 328 | 328 | else { |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | $operands_descriptions = array_filter( |
| 338 | 338 | $rules_composition, |
| 339 | - function ($operand) use ($operator) { |
|
| 340 | - return ! in_array($operand, [$operator, AbstractRule::findSymbolicOperator( $operator )]); |
|
| 339 | + function($operand) use ($operator) { |
|
| 340 | + return ! in_array($operand, [$operator, AbstractRule::findSymbolicOperator($operator)]); |
|
| 341 | 341 | } |
| 342 | 342 | ); |
| 343 | 343 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | foreach ($operands_descriptions as $i => $operands_description) { |
| 354 | 354 | if (false === $operands_description) { |
| 355 | - $operands_descriptions[ $i ] = ['and']; // FalseRule hack |
|
| 355 | + $operands_descriptions[$i] = ['and']; // FalseRule hack |
|
| 356 | 356 | } |
| 357 | 357 | elseif (null === $operands_description || true === $operands_description) { |
| 358 | 358 | $operands_description = ['and']; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | ); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - unset($operands_descriptions[ $i ]); |
|
| 366 | + unset($operands_descriptions[$i]); |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | throw new \InvalidArgumentException( |
| 382 | 382 | "Mixing different operations in the same rule level not implemented: \n[" |
| 383 | 383 | . implode(', ', $remaining_operations)."]\n" |
| 384 | - . 'in ' . var_export($rules_composition, true) |
|
| 384 | + . 'in '.var_export($rules_composition, true) |
|
| 385 | 385 | ); |
| 386 | 386 | } |
| 387 | 387 | |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - $recursion_position->addOperand( $rule ); |
|
| 410 | + $recursion_position->addOperand($rule); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | return $this; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | public function and_() |
| 438 | 438 | { |
| 439 | - $this->addRules( AndRule::operator, func_get_args()); |
|
| 439 | + $this->addRules(AndRule::operator, func_get_args()); |
|
| 440 | 440 | return $this; |
| 441 | 441 | } |
| 442 | 442 | |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | public function or_() |
| 466 | 466 | { |
| 467 | - $this->addRules( OrRule::operator, func_get_args()); |
|
| 467 | + $this->addRules(OrRule::operator, func_get_args()); |
|
| 468 | 468 | return $this; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -511,12 +511,12 @@ discard block |
||
| 511 | 511 | * @param array $options stop_after | stop_before | |
| 512 | 512 | * @return $this |
| 513 | 513 | */ |
| 514 | - public function simplify($options=[]) |
|
| 514 | + public function simplify($options = []) |
|
| 515 | 515 | { |
| 516 | 516 | if ($this->rules) { |
| 517 | 517 | // AndRule added to make all Operation methods available |
| 518 | 518 | $this->rules = (new AndRule([$this->rules])) |
| 519 | - ->simplify( $options ) |
|
| 519 | + ->simplify($options) |
|
| 520 | 520 | // ->dump(true, false) |
| 521 | 521 | ; |
| 522 | 522 | } |
@@ -559,9 +559,9 @@ discard block |
||
| 559 | 559 | * |
| 560 | 560 | * @return bool |
| 561 | 561 | */ |
| 562 | - public function hasSolution($save_simplification=true) |
|
| 562 | + public function hasSolution($save_simplification = true) |
|
| 563 | 563 | { |
| 564 | - if (! $this->rules) { |
|
| 564 | + if ( ! $this->rules) { |
|
| 565 | 565 | return true; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * |
| 581 | 581 | * @return array A description of the rules. |
| 582 | 582 | */ |
| 583 | - public function toArray(array $options=[]) |
|
| 583 | + public function toArray(array $options = []) |
|
| 584 | 584 | { |
| 585 | 585 | return $this->rules ? $this->rules->toArray($options) : $this->rules; |
| 586 | 586 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @return array A description of the rules. |
| 594 | 594 | */ |
| 595 | - public function toString(array $options=[]) |
|
| 595 | + public function toString(array $options = []) |
|
| 596 | 596 | { |
| 597 | 597 | return $this->rules ? $this->rules->toString($options) : $this->rules; |
| 598 | 598 | } |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | * @param mixed $row |
| 631 | 631 | * @return bool |
| 632 | 632 | */ |
| 633 | - public function __invoke($row, $key=null) |
|
| 633 | + public function __invoke($row, $key = null) |
|
| 634 | 634 | { |
| 635 | 635 | return $this->validates($row, $key); |
| 636 | 636 | } |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | [ |
| 681 | 681 | Filterer::on_row_matches => function($rule, $key, &$rows, $matching_case) use (&$cache_flush_required) { |
| 682 | 682 | // $rule->dump(); |
| 683 | - unset( $rows[$key] ); |
|
| 684 | - if ( ! $rows ) { |
|
| 683 | + unset($rows[$key]); |
|
| 684 | + if ( ! $rows) { |
|
| 685 | 685 | throw new \Exception( |
| 686 | 686 | "Removing the only rule $rule from the filter $this " |
| 687 | 687 | ."produces a case which has no possible solution due to missing " |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * |
| 718 | 718 | * @todo Merge with rules |
| 719 | 719 | */ |
| 720 | - public function keepLeafRulesMatching($filter=[], array $options=[]) |
|
| 720 | + public function keepLeafRulesMatching($filter = [], array $options = []) |
|
| 721 | 721 | { |
| 722 | 722 | $clean_empty_branches = ! isset($options['clean_empty_branches']) || $options['clean_empty_branches']; |
| 723 | 723 | |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | // ->dump() |
| 726 | 726 | ; |
| 727 | 727 | |
| 728 | - $options[ Filterer::leaves_only ] = true; |
|
| 728 | + $options[Filterer::leaves_only] = true; |
|
| 729 | 729 | |
| 730 | 730 | $this->rules = (new RuleFilterer)->apply($filter, $this->rules, $options); |
| 731 | 731 | // $this->rules->dump(true); |
@@ -765,13 +765,13 @@ discard block |
||
| 765 | 765 | * |
| 766 | 766 | * @todo Merge with rules |
| 767 | 767 | */ |
| 768 | - public function listLeafRulesMatching($filter=[]) |
|
| 768 | + public function listLeafRulesMatching($filter = []) |
|
| 769 | 769 | { |
| 770 | 770 | $filter = (new LogicalFilter($filter, new RuleFilterer)) |
| 771 | 771 | // ->dump() |
| 772 | 772 | ; |
| 773 | 773 | |
| 774 | - if (! $this->rules) { |
|
| 774 | + if ( ! $this->rules) { |
|
| 775 | 775 | return []; |
| 776 | 776 | } |
| 777 | 777 | |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $key, |
| 786 | 786 | array $siblings |
| 787 | 787 | ) use (&$out) { |
| 788 | - if ( ! $matching_rule instanceof AndRule |
|
| 788 | + if ( ! $matching_rule instanceof AndRule |
|
| 789 | 789 | && ! $matching_rule instanceof OrRule |
| 790 | 790 | && ! $matching_rule instanceof NotRule |
| 791 | 791 | ) { |
@@ -826,13 +826,13 @@ discard block |
||
| 826 | 826 | * |
| 827 | 827 | * @return array The rules matching the filter |
| 828 | 828 | */ |
| 829 | - public function onEachRule($filter=[], $options) |
|
| 829 | + public function onEachRule($filter = [], $options) |
|
| 830 | 830 | { |
| 831 | 831 | $filter = (new LogicalFilter($filter, new RuleFilterer)) |
| 832 | 832 | // ->dump() |
| 833 | 833 | ; |
| 834 | 834 | |
| 835 | - if (! $this->rules) { |
|
| 835 | + if ( ! $this->rules) { |
|
| 836 | 836 | return []; |
| 837 | 837 | } |
| 838 | 838 | |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | { |
| 866 | 866 | $this->simplify()->addMinimalCase(); |
| 867 | 867 | |
| 868 | - if (! $this->rules) { |
|
| 868 | + if ( ! $this->rules) { |
|
| 869 | 869 | return $this; |
| 870 | 870 | } |
| 871 | 871 | |
@@ -891,11 +891,11 @@ discard block |
||
| 891 | 891 | * |
| 892 | 892 | * @return array The bounds of the range and a nullable property for each field |
| 893 | 893 | */ |
| 894 | - public function getRanges($ruleFilter=null) |
|
| 894 | + public function getRanges($ruleFilter = null) |
|
| 895 | 895 | { |
| 896 | 896 | $ranges = []; |
| 897 | 897 | |
| 898 | - $this->onEachCase(function (AndRule $and_rule) use (&$ranges, $ruleFilter) { |
|
| 898 | + $this->onEachCase(function(AndRule $and_rule) use (&$ranges, $ruleFilter) { |
|
| 899 | 899 | (new self($and_rule))->onEachRule( |
| 900 | 900 | ['and', |
| 901 | 901 | $ruleFilter, |
@@ -904,12 +904,12 @@ discard block |
||
| 904 | 904 | '><', '><=', '=><=', '=><', |
| 905 | 905 | ]], |
| 906 | 906 | ], |
| 907 | - function ($rule) use (&$ranges) { |
|
| 907 | + function($rule) use (&$ranges) { |
|
| 908 | 908 | |
| 909 | 909 | $field = $rule->getField(); |
| 910 | 910 | |
| 911 | - $range = isset($ranges[ $field ]) |
|
| 912 | - ? $ranges[ $field ] |
|
| 911 | + $range = isset($ranges[$field]) |
|
| 912 | + ? $ranges[$field] |
|
| 913 | 913 | : ['min' => [], 'max' => [], 'nullable' => false]; |
| 914 | 914 | |
| 915 | 915 | if ($rule::operator == '=') { |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | ); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - $ranges[ $field ] = $range; |
|
| 940 | + $ranges[$field] = $range; |
|
| 941 | 941 | } |
| 942 | 942 | ); |
| 943 | 943 | }); |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | * |
| 992 | 992 | * @return LogicalFilter |
| 993 | 993 | */ |
| 994 | - public function saveAs( &$variable) |
|
| 994 | + public function saveAs(&$variable) |
|
| 995 | 995 | { |
| 996 | 996 | return $variable = $this; |
| 997 | 997 | } |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | * |
| 1003 | 1003 | * @return LogicalFilter |
| 1004 | 1004 | */ |
| 1005 | - public function saveCopyAs( &$copied_variable) |
|
| 1005 | + public function saveCopyAs(&$copied_variable) |
|
| 1006 | 1006 | { |
| 1007 | 1007 | $copied_variable = $this->copy(); |
| 1008 | 1008 | return $this; |
@@ -1015,15 +1015,15 @@ discard block |
||
| 1015 | 1015 | * |
| 1016 | 1016 | * @return $this |
| 1017 | 1017 | */ |
| 1018 | - public function dump($exit=false, array $options=[]) |
|
| 1018 | + public function dump($exit = false, array $options = []) |
|
| 1019 | 1019 | { |
| 1020 | 1020 | $default_options = [ |
| 1021 | 1021 | 'callstack_depth' => 3, |
| 1022 | 1022 | 'mode' => 'string', |
| 1023 | 1023 | ]; |
| 1024 | 1024 | foreach ($default_options as $default_option => &$default_value) { |
| 1025 | - if ( ! isset($options[ $default_option ])) { |
|
| 1026 | - $options[ $default_option ] = $default_value; |
|
| 1025 | + if ( ! isset($options[$default_option])) { |
|
| 1026 | + $options[$default_option] = $default_value; |
|
| 1027 | 1027 | } |
| 1028 | 1028 | } |
| 1029 | 1029 | extract($options); |
@@ -1034,24 +1034,24 @@ discard block |
||
| 1034 | 1034 | else { |
| 1035 | 1035 | // TODO dump a TrueRule |
| 1036 | 1036 | $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $callstack_depth); |
| 1037 | - $caller = $bt[ $callstack_depth - 2 ]; |
|
| 1037 | + $caller = $bt[$callstack_depth - 2]; |
|
| 1038 | 1038 | |
| 1039 | 1039 | // get line and file from the previous level of the caller |
| 1040 | 1040 | // TODO go deeper if this case exist? |
| 1041 | - if (! isset($caller['file'])) { |
|
| 1042 | - $caller['file'] = $bt[ $callstack_depth - 3 ]['file']; |
|
| 1041 | + if ( ! isset($caller['file'])) { |
|
| 1042 | + $caller['file'] = $bt[$callstack_depth - 3]['file']; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | - if (! isset($caller['line'])) { |
|
| 1046 | - $caller['line'] = $bt[ $callstack_depth - 3 ]['line']; |
|
| 1045 | + if ( ! isset($caller['line'])) { |
|
| 1046 | + $caller['line'] = $bt[$callstack_depth - 3]['line']; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | try { |
| 1050 | - echo "\n" . $caller['file'] . ':' . $caller['line'] . "\n"; |
|
| 1050 | + echo "\n".$caller['file'].':'.$caller['line']."\n"; |
|
| 1051 | 1051 | var_export($this->toArray($options)); |
| 1052 | 1052 | } |
| 1053 | 1053 | catch (\Exception $e) { |
| 1054 | - echo "\nError while dumping: " . $e->getMessage() . "\n"; |
|
| 1054 | + echo "\nError while dumping: ".$e->getMessage()."\n"; |
|
| 1055 | 1055 | var_export($caller); |
| 1056 | 1056 | echo "\n\n"; |
| 1057 | 1057 | var_export($bt); |
@@ -1076,15 +1076,15 @@ discard block |
||
| 1076 | 1076 | * |
| 1077 | 1077 | * @return mixed The filtered data |
| 1078 | 1078 | */ |
| 1079 | - public function applyOn($data_to_filter, $action_on_matches=null, $filterer=null) |
|
| 1079 | + public function applyOn($data_to_filter, $action_on_matches = null, $filterer = null) |
|
| 1080 | 1080 | { |
| 1081 | - if (! $filterer) { |
|
| 1081 | + if ( ! $filterer) { |
|
| 1082 | 1082 | $filterer = $this->getDefaultFilterer(); |
| 1083 | 1083 | } |
| 1084 | 1084 | elseif (is_callable($filterer)) { |
| 1085 | 1085 | $filterer = new CustomizableFilterer($filterer); |
| 1086 | 1086 | } |
| 1087 | - elseif (! $filterer instanceof Filterer) { |
|
| 1087 | + elseif ( ! $filterer instanceof Filterer) { |
|
| 1088 | 1088 | throw new \InvalidArgumentException( |
| 1089 | 1089 | "The given \$filterer must be null or a callable or a instance " |
| 1090 | 1090 | ."of Filterer instead of: ".var_export($filterer, true) |
@@ -1092,8 +1092,8 @@ discard block |
||
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | if ($data_to_filter instanceof LogicalFilter) { |
| 1095 | - $filtered_rules = $filterer->apply( $this, $data_to_filter->getRules() ); |
|
| 1096 | - return $data_to_filter->flushRules()->addRule( $filtered_rules ); |
|
| 1095 | + $filtered_rules = $filterer->apply($this, $data_to_filter->getRules()); |
|
| 1096 | + return $data_to_filter->flushRules()->addRule($filtered_rules); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | else { |
| 1099 | 1099 | return $filterer->apply($this, $data_to_filter); |
@@ -1111,15 +1111,15 @@ discard block |
||
| 1111 | 1111 | * + Null if the target has no sens (operation filtered by field for example) |
| 1112 | 1112 | * + A rule tree containing the first matching case if there is one. |
| 1113 | 1113 | */ |
| 1114 | - public function validates($value_to_check, $key_to_check=null, $filterer=null) |
|
| 1114 | + public function validates($value_to_check, $key_to_check = null, $filterer = null) |
|
| 1115 | 1115 | { |
| 1116 | - if (! $filterer) { |
|
| 1116 | + if ( ! $filterer) { |
|
| 1117 | 1117 | $filterer = $this->getDefaultFilterer(); |
| 1118 | 1118 | } |
| 1119 | 1119 | elseif (is_callable($filterer)) { |
| 1120 | 1120 | $filterer = new CustomizableFilterer($filterer); |
| 1121 | 1121 | } |
| 1122 | - elseif (! $filterer instanceof Filterer) { |
|
| 1122 | + elseif ( ! $filterer instanceof Filterer) { |
|
| 1123 | 1123 | throw new \InvalidArgumentException( |
| 1124 | 1124 | "The given \$filterer must be null or a callable or a instance " |
| 1125 | 1125 | ."of Filterer instead of: ".var_export($filterer, true) |