@@ -214,7 +214,7 @@ |
||
214 | 214 | */ |
215 | 215 | private static function convert_int_to_char_for_ctype($int) |
216 | 216 | { |
217 | - if (! is_int($int)) { |
|
217 | + if (!is_int($int)) { |
|
218 | 218 | return $int; |
219 | 219 | } |
220 | 220 |
@@ -28,13 +28,13 @@ |
||
28 | 28 | |
29 | 29 | public function __construct(OptionsResolver $optionsResolver) |
30 | 30 | { |
31 | - $this->get = Closure::bind(function ($property, $option, $message) { |
|
31 | + $this->get = Closure::bind(function($property, $option, $message) { |
|
32 | 32 | /** @var OptionsResolver $this */ |
33 | 33 | if (!$this->isDefined($option)) { |
34 | 34 | throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option)); |
35 | 35 | } |
36 | 36 | |
37 | - if (! array_key_exists($option, $this->{$property})) { |
|
37 | + if (!array_key_exists($option, $this->{$property})) { |
|
38 | 38 | throw new NoConfigurationException($message); |
39 | 39 | } |
40 | 40 |
@@ -28,7 +28,8 @@ |
||
28 | 28 | |
29 | 29 | public function __construct(OptionsResolver $optionsResolver) |
30 | 30 | { |
31 | - $this->get = Closure::bind(function ($property, $option, $message) { |
|
31 | + $this->get = Closure::bind(function ($property, $option, $message) |
|
32 | + { |
|
32 | 33 | /** @var OptionsResolver $this */ |
33 | 34 | if (!$this->isDefined($option)) { |
34 | 35 | throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option)); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function isMissing($option) |
340 | 340 | { |
341 | - return isset($this->required[$option]) && ! array_key_exists($option, $this->defaults); |
|
341 | + return isset($this->required[$option]) && !array_key_exists($option, $this->defaults); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | throw new UndefinedOptionsException(sprintf('The option "%s" does not exist, defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); |
441 | 441 | } |
442 | 442 | |
443 | - if (! is_string($deprecationMessage) && !$deprecationMessage instanceof Closure) { |
|
443 | + if (!is_string($deprecationMessage) && !$deprecationMessage instanceof Closure) { |
|
444 | 444 | throw new InvalidArgumentException(sprintf('Invalid type for deprecation message argument, expected string or \Closure, but got "%s".', gettype($deprecationMessage))); |
445 | 445 | } |
446 | 446 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); |
579 | 579 | } |
580 | 580 | |
581 | - if (! is_array($allowedValues)) { |
|
581 | + if (!is_array($allowedValues)) { |
|
582 | 582 | $allowedValues = [$allowedValues]; |
583 | 583 | } |
584 | 584 | |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | // Check whether the option is set at all |
826 | - if (!isset($this->defaults[$option]) && ! array_key_exists($option, $this->defaults)) { |
|
826 | + if (!isset($this->defaults[$option]) && !array_key_exists($option, $this->defaults)) { |
|
827 | 827 | if (!isset($this->defined[$option])) { |
828 | 828 | throw new NoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); |
829 | 829 | } |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling)))); |
841 | 841 | } |
842 | 842 | |
843 | - if (! is_array($value)) { |
|
843 | + if (!is_array($value)) { |
|
844 | 844 | throw new InvalidOptionsException(sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $option, $this->formatValue($value), $this->formatTypeOf($value))); |
845 | 845 | } |
846 | 846 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | |
960 | 960 | $this->calling[$option] = true; |
961 | 961 | try { |
962 | - if (! is_string($deprecationMessage = $deprecationMessage($this, $value))) { |
|
962 | + if (!is_string($deprecationMessage = $deprecationMessage($this, $value))) { |
|
963 | 963 | throw new InvalidOptionsException(sprintf('Invalid type for deprecation message, expected string but got "%s", return an empty string to ignore.', gettype($deprecationMessage))); |
964 | 964 | } |
965 | 965 | } finally { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $resolver = new OptionsResolver(); |
67 | 67 | $closures = []; |
68 | - $resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {}); |
|
68 | + $resolver->setDefault($option = 'foo', $closures[] = function(Options $options) {}); |
|
69 | 69 | |
70 | 70 | $debug = new OptionsResolverIntrospector($resolver); |
71 | 71 | $this->assertSame($closures, $debug->getLazyClosures($option)); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $resolver = new OptionsResolver(); |
172 | 172 | $resolver->setDefined($option = 'foo'); |
173 | - $resolver->setNormalizer($option = 'foo', $normalizer = function () {}); |
|
173 | + $resolver->setNormalizer($option = 'foo', $normalizer = function() {}); |
|
174 | 174 | |
175 | 175 | $debug = new OptionsResolverIntrospector($resolver); |
176 | 176 | $this->assertSame($normalizer, $debug->getNormalizer($option)); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | { |
216 | 216 | $resolver = new OptionsResolver(); |
217 | 217 | $resolver->setDefined('foo'); |
218 | - $resolver->setDeprecated('foo', $closure = function (Options $options, $value) {}); |
|
218 | + $resolver->setDeprecated('foo', $closure = function(Options $options, $value) {}); |
|
219 | 219 | |
220 | 220 | $debug = new OptionsResolverIntrospector($resolver); |
221 | 221 | $this->assertSame($closure, $debug->getDeprecationMessage('foo')); |
@@ -65,7 +65,9 @@ discard block |
||
65 | 65 | { |
66 | 66 | $resolver = new OptionsResolver(); |
67 | 67 | $closures = []; |
68 | - $resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {}); |
|
68 | + $resolver->setDefault($option = 'foo', $closures[] = function (Options $options) |
|
69 | + { |
|
70 | +}); |
|
69 | 71 | |
70 | 72 | $debug = new OptionsResolverIntrospector($resolver); |
71 | 73 | $this->assertSame($closures, $debug->getLazyClosures($option)); |
@@ -170,7 +172,9 @@ discard block |
||
170 | 172 | { |
171 | 173 | $resolver = new OptionsResolver(); |
172 | 174 | $resolver->setDefined($option = 'foo'); |
173 | - $resolver->setNormalizer($option = 'foo', $normalizer = function () {}); |
|
175 | + $resolver->setNormalizer($option = 'foo', $normalizer = function () |
|
176 | + { |
|
177 | +}); |
|
174 | 178 | |
175 | 179 | $debug = new OptionsResolverIntrospector($resolver); |
176 | 180 | $this->assertSame($normalizer, $debug->getNormalizer($option)); |
@@ -215,7 +219,9 @@ discard block |
||
215 | 219 | { |
216 | 220 | $resolver = new OptionsResolver(); |
217 | 221 | $resolver->setDefined('foo'); |
218 | - $resolver->setDeprecated('foo', $closure = function (Options $options, $value) {}); |
|
222 | + $resolver->setDeprecated('foo', $closure = function (Options $options, $value) |
|
223 | + { |
|
224 | +}); |
|
219 | 225 | |
220 | 226 | $debug = new OptionsResolverIntrospector($resolver); |
221 | 227 | $this->assertSame($closure, $debug->getDeprecationMessage('foo')); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function testResolveFailsFromLazyOption() |
68 | 68 | { |
69 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
69 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
70 | 70 | $options->resolve([]); |
71 | 71 | }); |
72 | 72 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function testFailIfSetDefaultFromLazyOption() |
96 | 96 | { |
97 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
97 | + $this->resolver->setDefault('lazy', function(Options $options) { |
|
98 | 98 | $options->setDefault('default', 42); |
99 | 99 | }); |
100 | 100 | |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | |
118 | 118 | public function testSetLazyReturnsThis() |
119 | 119 | { |
120 | - $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function (Options $options) {})); |
|
120 | + $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function(Options $options) {})); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | public function testSetLazyClosure() |
124 | 124 | { |
125 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
125 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
126 | 126 | return 'lazy'; |
127 | 127 | }); |
128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | public function testClosureWithoutTypeHintNotInvoked() |
133 | 133 | { |
134 | - $closure = function ($options) { |
|
134 | + $closure = function($options) { |
|
135 | 135 | Assert::fail('Should not be called'); |
136 | 136 | }; |
137 | 137 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | public function testClosureWithoutParametersNotInvoked() |
144 | 144 | { |
145 | - $closure = function () { |
|
145 | + $closure = function() { |
|
146 | 146 | Assert::fail('Should not be called'); |
147 | 147 | }; |
148 | 148 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $this->resolver->setDefault('foo', 'bar'); |
158 | 158 | |
159 | 159 | // defined by subclass |
160 | - $this->resolver->setDefault('foo', function (Options $options, $previousValue) { |
|
160 | + $this->resolver->setDefault('foo', function(Options $options, $previousValue) { |
|
161 | 161 | Assert::assertEquals('bar', $previousValue); |
162 | 162 | |
163 | 163 | return 'lazy'; |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | public function testAccessPreviousLazyDefaultValue() |
170 | 170 | { |
171 | 171 | // defined by superclass |
172 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
172 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
173 | 173 | return 'bar'; |
174 | 174 | }); |
175 | 175 | |
176 | 176 | // defined by subclass |
177 | - $this->resolver->setDefault('foo', function (Options $options, $previousValue) { |
|
177 | + $this->resolver->setDefault('foo', function(Options $options, $previousValue) { |
|
178 | 178 | Assert::assertEquals('bar', $previousValue); |
179 | 179 | |
180 | 180 | return 'lazy'; |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() |
187 | 187 | { |
188 | 188 | // defined by superclass |
189 | - $this->resolver->setDefault('foo', function () { |
|
189 | + $this->resolver->setDefault('foo', function() { |
|
190 | 190 | Assert::fail('Should not be called'); |
191 | 191 | }); |
192 | 192 | |
193 | 193 | // defined by subclass, no $previousValue argument defined! |
194 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
194 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
195 | 195 | return 'lazy'; |
196 | 196 | }); |
197 | 197 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | public function testOverwrittenLazyOptionNotEvaluated() |
202 | 202 | { |
203 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
203 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
204 | 204 | Assert::fail('Should not be called'); |
205 | 205 | }); |
206 | 206 | |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | { |
214 | 214 | $calls = 0; |
215 | 215 | |
216 | - $this->resolver->setDefault('lazy1', function (Options $options) use (&$calls) { |
|
216 | + $this->resolver->setDefault('lazy1', function(Options $options) use (&$calls) { |
|
217 | 217 | Assert::assertSame(1, ++$calls); |
218 | 218 | |
219 | 219 | $options['lazy2']; |
220 | 220 | }); |
221 | 221 | |
222 | - $this->resolver->setDefault('lazy2', function (Options $options) use (&$calls) { |
|
222 | + $this->resolver->setDefault('lazy2', function(Options $options) use (&$calls) { |
|
223 | 223 | Assert::assertSame(2, ++$calls); |
224 | 224 | }); |
225 | 225 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function testFailIfSetRequiredFromLazyOption() |
240 | 240 | { |
241 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
241 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
242 | 242 | $options->setRequired('bar'); |
243 | 243 | }); |
244 | 244 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function testFailIfSetDefinedFromLazyOption() |
368 | 368 | { |
369 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
369 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
370 | 370 | $options->setDefined('bar'); |
371 | 371 | }); |
372 | 372 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | public function testLazyOptionsAreDefined() |
414 | 414 | { |
415 | 415 | $this->assertFalse($this->resolver->isDefined('foo')); |
416 | - $this->resolver->setDefault('foo', function (Options $options) {}); |
|
416 | + $this->resolver->setDefault('foo', function(Options $options) {}); |
|
417 | 417 | $this->assertTrue($this->resolver->isDefined('foo')); |
418 | 418 | } |
419 | 419 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | { |
466 | 466 | $this->resolver |
467 | 467 | ->setDefault('bar', 'baz') |
468 | - ->setDefault('foo', function (Options $options) { |
|
468 | + ->setDefault('foo', function(Options $options) { |
|
469 | 469 | $options->setDeprecated('bar'); |
470 | 470 | }) |
471 | 471 | ->resolve() |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | { |
501 | 501 | $this->resolver |
502 | 502 | ->setDefined('foo') |
503 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
503 | + ->setDeprecated('foo', function(Options $options, $value) { |
|
504 | 504 | return false; |
505 | 505 | }) |
506 | 506 | ; |
@@ -515,10 +515,10 @@ discard block |
||
515 | 515 | { |
516 | 516 | $this->resolver |
517 | 517 | ->setDefined(['foo', 'bar']) |
518 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
518 | + ->setDeprecated('foo', function(Options $options, $value) { |
|
519 | 519 | $options['bar']; |
520 | 520 | }) |
521 | - ->setDeprecated('bar', function (Options $options, $value) { |
|
521 | + ->setDeprecated('bar', function(Options $options, $value) { |
|
522 | 522 | $options['foo']; |
523 | 523 | }) |
524 | 524 | ; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | { |
551 | 551 | $count = 0; |
552 | 552 | error_clear_last(); |
553 | - set_error_handler(function () use (&$count) { |
|
553 | + set_error_handler(function() use (&$count) { |
|
554 | 554 | ++$count; |
555 | 555 | |
556 | 556 | return false; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | public function provideDeprecationData() |
574 | 574 | { |
575 | 575 | yield 'It deprecates an option with default message' => [ |
576 | - function (OptionsResolver $resolver) { |
|
576 | + function(OptionsResolver $resolver) { |
|
577 | 577 | $resolver |
578 | 578 | ->setDefined(['foo', 'bar']) |
579 | 579 | ->setDeprecated('foo') |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | ]; |
589 | 589 | |
590 | 590 | yield 'It deprecates an option with custom message' => [ |
591 | - function (OptionsResolver $resolver) { |
|
591 | + function(OptionsResolver $resolver) { |
|
592 | 592 | $resolver |
593 | 593 | ->setDefined('foo') |
594 | - ->setDefault('bar', function (Options $options) { |
|
594 | + ->setDefault('bar', function(Options $options) { |
|
595 | 595 | return $options['foo']; |
596 | 596 | }) |
597 | 597 | ->setDeprecated('foo', 'The option "foo" is deprecated, use "bar" option instead.') |
@@ -606,14 +606,14 @@ discard block |
||
606 | 606 | ]; |
607 | 607 | |
608 | 608 | yield 'It deprecates an option evaluated in another definition' => [ |
609 | - function (OptionsResolver $resolver) { |
|
609 | + function(OptionsResolver $resolver) { |
|
610 | 610 | // defined by superclass |
611 | 611 | $resolver |
612 | 612 | ->setDefault('foo', null) |
613 | 613 | ->setDeprecated('foo') |
614 | 614 | ; |
615 | 615 | // defined by subclass |
616 | - $resolver->setDefault('bar', function (Options $options) { |
|
616 | + $resolver->setDefault('bar', function(Options $options) { |
|
617 | 617 | return $options['foo']; // It triggers a deprecation |
618 | 618 | }); |
619 | 619 | }, |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | ]; |
627 | 627 | |
628 | 628 | yield 'It deprecates allowed type and value' => [ |
629 | - function (OptionsResolver $resolver) { |
|
629 | + function(OptionsResolver $resolver) { |
|
630 | 630 | $resolver |
631 | 631 | ->setDefault('foo', null) |
632 | 632 | ->setAllowedTypes('foo', ['null', 'string', stdClass::class]) |
633 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
633 | + ->setDeprecated('foo', function(Options $options, $value) { |
|
634 | 634 | if ($value instanceof stdClass) { |
635 | 635 | return sprintf('Passing an instance of "%s" to option "foo" is deprecated, pass its FQCN instead.', stdClass::class); |
636 | 636 | } |
@@ -648,12 +648,12 @@ discard block |
||
648 | 648 | ]; |
649 | 649 | |
650 | 650 | yield 'It triggers a deprecation based on the value only if option is provided by the user' => [ |
651 | - function (OptionsResolver $resolver) { |
|
651 | + function(OptionsResolver $resolver) { |
|
652 | 652 | $resolver |
653 | 653 | ->setDefined('foo') |
654 | 654 | ->setAllowedTypes('foo', ['null', 'bool']) |
655 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
656 | - if (! is_bool($value)) { |
|
655 | + ->setDeprecated('foo', function(Options $options, $value) { |
|
656 | + if (!is_bool($value)) { |
|
657 | 657 | return 'Passing a value different than true or false is deprecated.'; |
658 | 658 | } |
659 | 659 | |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | }) |
662 | 662 | ->setDefault('baz', null) |
663 | 663 | ->setAllowedTypes('baz', ['null', 'int']) |
664 | - ->setDeprecated('baz', function (Options $options, $value) { |
|
665 | - if (! is_int($value)) { |
|
664 | + ->setDeprecated('baz', function(Options $options, $value) { |
|
665 | + if (!is_int($value)) { |
|
666 | 666 | return 'Not passing an integer is deprecated.'; |
667 | 667 | } |
668 | 668 | |
669 | 669 | return ''; |
670 | 670 | }) |
671 | - ->setDefault('bar', function (Options $options) { |
|
671 | + ->setDefault('bar', function(Options $options) { |
|
672 | 672 | $options['baz']; // It does not triggers a deprecation |
673 | 673 | |
674 | 674 | return $options['foo']; // It does not triggers a deprecation |
@@ -684,10 +684,10 @@ discard block |
||
684 | 684 | ]; |
685 | 685 | |
686 | 686 | yield 'It ignores a deprecation if closure returns an empty string' => [ |
687 | - function (OptionsResolver $resolver) { |
|
687 | + function(OptionsResolver $resolver) { |
|
688 | 688 | $resolver |
689 | 689 | ->setDefault('foo', null) |
690 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
690 | + ->setDeprecated('foo', function(Options $options, $value) { |
|
691 | 691 | return ''; |
692 | 692 | }) |
693 | 693 | ; |
@@ -698,11 +698,11 @@ discard block |
||
698 | 698 | ]; |
699 | 699 | |
700 | 700 | yield 'It deprecates value depending on other option value' => [ |
701 | - function (OptionsResolver $resolver) { |
|
701 | + function(OptionsResolver $resolver) { |
|
702 | 702 | $resolver |
703 | 703 | ->setDefault('widget', null) |
704 | 704 | ->setDefault('date_format', null) |
705 | - ->setDeprecated('date_format', function (Options $options, $dateFormat) { |
|
705 | + ->setDeprecated('date_format', function(Options $options, $dateFormat) { |
|
706 | 706 | if (null !== $dateFormat && 'single_text' === $options['widget']) { |
707 | 707 | return 'Using the "date_format" option when the "widget" option is set to "single_text" is deprecated.'; |
708 | 708 | } |
@@ -720,16 +720,16 @@ discard block |
||
720 | 720 | ]; |
721 | 721 | |
722 | 722 | yield 'It triggers a deprecation for each evaluation' => [ |
723 | - function (OptionsResolver $resolver) { |
|
723 | + function(OptionsResolver $resolver) { |
|
724 | 724 | $resolver |
725 | 725 | // defined by superclass |
726 | 726 | ->setDefined('foo') |
727 | 727 | ->setDeprecated('foo') |
728 | 728 | // defined by subclass |
729 | - ->setDefault('bar', function (Options $options) { |
|
729 | + ->setDefault('bar', function(Options $options) { |
|
730 | 730 | return $options['foo']; // It triggers a deprecation |
731 | 731 | }) |
732 | - ->setNormalizer('bar', function (Options $options, $value) { |
|
732 | + ->setNormalizer('bar', function(Options $options, $value) { |
|
733 | 733 | $options['foo']; // It triggers a deprecation |
734 | 734 | $options['foo']; // It triggers a deprecation |
735 | 735 | |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | ]; |
747 | 747 | |
748 | 748 | yield 'It ignores a deprecation if no option is provided by the user' => [ |
749 | - function (OptionsResolver $resolver) { |
|
749 | + function(OptionsResolver $resolver) { |
|
750 | 750 | $resolver |
751 | 751 | ->setDefined('foo') |
752 | 752 | ->setDefault('bar', null) |
@@ -760,14 +760,14 @@ discard block |
||
760 | 760 | ]; |
761 | 761 | |
762 | 762 | yield 'It explicitly ignores a depreciation' => [ |
763 | - function (OptionsResolver $resolver) { |
|
763 | + function(OptionsResolver $resolver) { |
|
764 | 764 | $resolver |
765 | - ->setDefault('baz', function (Options $options) { |
|
765 | + ->setDefault('baz', function(Options $options) { |
|
766 | 766 | return $options->offsetGet('foo', false); |
767 | 767 | }) |
768 | 768 | ->setDefault('foo', null) |
769 | 769 | ->setDeprecated('foo') |
770 | - ->setDefault('bar', function (Options $options) { |
|
770 | + ->setDefault('bar', function(Options $options) { |
|
771 | 771 | return $options->offsetGet('foo', false); |
772 | 772 | }) |
773 | 773 | ; |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | */ |
801 | 801 | public function testFailIfSetAllowedTypesFromLazyOption() |
802 | 802 | { |
803 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
803 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
804 | 804 | $options->setAllowedTypes('bar', 'string'); |
805 | 805 | }); |
806 | 806 | |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | */ |
976 | 976 | public function testFailIfAddAllowedTypesFromLazyOption() |
977 | 977 | { |
978 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
978 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
979 | 979 | $options->addAllowedTypes('bar', 'string'); |
980 | 980 | }); |
981 | 981 | |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | public function testFailIfSetAllowedValuesFromLazyOption() |
1059 | 1059 | { |
1060 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1060 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1061 | 1061 | $options->setAllowedValues('bar', 'baz'); |
1062 | 1062 | }); |
1063 | 1063 | |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | public function testResolveFailsIfClosureReturnsFalse() |
1141 | 1141 | { |
1142 | 1142 | $this->resolver->setDefault('foo', 42); |
1143 | - $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { |
|
1143 | + $this->resolver->setAllowedValues('foo', function($value) use (&$passedValue) { |
|
1144 | 1144 | $passedValue = $value; |
1145 | 1145 | |
1146 | 1146 | return false; |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | public function testResolveSucceedsIfClosureReturnsTrue() |
1159 | 1159 | { |
1160 | 1160 | $this->resolver->setDefault('foo', 'bar'); |
1161 | - $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { |
|
1161 | + $this->resolver->setAllowedValues('foo', function($value) use (&$passedValue) { |
|
1162 | 1162 | $passedValue = $value; |
1163 | 1163 | |
1164 | 1164 | return true; |
@@ -1175,9 +1175,9 @@ discard block |
||
1175 | 1175 | { |
1176 | 1176 | $this->resolver->setDefault('foo', 42); |
1177 | 1177 | $this->resolver->setAllowedValues('foo', [ |
1178 | - function () { return false; }, |
|
1179 | - function () { return false; }, |
|
1180 | - function () { return false; }, |
|
1178 | + function() { return false; }, |
|
1179 | + function() { return false; }, |
|
1180 | + function() { return false; }, |
|
1181 | 1181 | ]); |
1182 | 1182 | |
1183 | 1183 | $this->resolver->resolve(); |
@@ -1187,9 +1187,9 @@ discard block |
||
1187 | 1187 | { |
1188 | 1188 | $this->resolver->setDefault('foo', 'bar'); |
1189 | 1189 | $this->resolver->setAllowedValues('foo', [ |
1190 | - function () { return false; }, |
|
1191 | - function () { return true; }, |
|
1192 | - function () { return false; }, |
|
1190 | + function() { return false; }, |
|
1191 | + function() { return true; }, |
|
1192 | + function() { return false; }, |
|
1193 | 1193 | ]); |
1194 | 1194 | |
1195 | 1195 | $this->assertEquals(['foo' => 'bar'], $this->resolver->resolve()); |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | public function testFailIfAddAllowedValuesFromLazyOption() |
1210 | 1210 | { |
1211 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1211 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1212 | 1212 | $options->addAllowedValues('bar', 'baz'); |
1213 | 1213 | }); |
1214 | 1214 | |
@@ -1287,8 +1287,8 @@ discard block |
||
1287 | 1287 | public function testResolveFailsIfAllAddedClosuresReturnFalse() |
1288 | 1288 | { |
1289 | 1289 | $this->resolver->setDefault('foo', 42); |
1290 | - $this->resolver->setAllowedValues('foo', function () { return false; }); |
|
1291 | - $this->resolver->addAllowedValues('foo', function () { return false; }); |
|
1290 | + $this->resolver->setAllowedValues('foo', function() { return false; }); |
|
1291 | + $this->resolver->addAllowedValues('foo', function() { return false; }); |
|
1292 | 1292 | |
1293 | 1293 | $this->resolver->resolve(); |
1294 | 1294 | } |
@@ -1296,8 +1296,8 @@ discard block |
||
1296 | 1296 | public function testResolveSucceedsIfAnyAddedClosureReturnsTrue() |
1297 | 1297 | { |
1298 | 1298 | $this->resolver->setDefault('foo', 'bar'); |
1299 | - $this->resolver->setAllowedValues('foo', function () { return false; }); |
|
1300 | - $this->resolver->addAllowedValues('foo', function () { return true; }); |
|
1299 | + $this->resolver->setAllowedValues('foo', function() { return false; }); |
|
1300 | + $this->resolver->addAllowedValues('foo', function() { return true; }); |
|
1301 | 1301 | |
1302 | 1302 | $this->assertEquals(['foo' => 'bar'], $this->resolver->resolve()); |
1303 | 1303 | } |
@@ -1305,8 +1305,8 @@ discard block |
||
1305 | 1305 | public function testResolveSucceedsIfAnyAddedClosureReturnsTrue2() |
1306 | 1306 | { |
1307 | 1307 | $this->resolver->setDefault('foo', 'bar'); |
1308 | - $this->resolver->setAllowedValues('foo', function () { return true; }); |
|
1309 | - $this->resolver->addAllowedValues('foo', function () { return false; }); |
|
1308 | + $this->resolver->setAllowedValues('foo', function() { return true; }); |
|
1309 | + $this->resolver->addAllowedValues('foo', function() { return false; }); |
|
1310 | 1310 | |
1311 | 1311 | $this->assertEquals(['foo' => 'bar'], $this->resolver->resolve()); |
1312 | 1312 | } |
@@ -1314,13 +1314,13 @@ discard block |
||
1314 | 1314 | public function testSetNormalizerReturnsThis() |
1315 | 1315 | { |
1316 | 1316 | $this->resolver->setDefault('foo', 'bar'); |
1317 | - $this->assertSame($this->resolver, $this->resolver->setNormalizer('foo', function () {})); |
|
1317 | + $this->assertSame($this->resolver, $this->resolver->setNormalizer('foo', function() {})); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | public function testSetNormalizerClosure() |
1321 | 1321 | { |
1322 | 1322 | $this->resolver->setDefault('foo', 'bar'); |
1323 | - $this->resolver->setNormalizer('foo', function () { |
|
1323 | + $this->resolver->setNormalizer('foo', function() { |
|
1324 | 1324 | return 'normalized'; |
1325 | 1325 | }); |
1326 | 1326 | |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | */ |
1333 | 1333 | public function testSetNormalizerFailsIfUnknownOption() |
1334 | 1334 | { |
1335 | - $this->resolver->setNormalizer('foo', function () {}); |
|
1335 | + $this->resolver->setNormalizer('foo', function() {}); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
@@ -1340,8 +1340,8 @@ discard block |
||
1340 | 1340 | */ |
1341 | 1341 | public function testFailIfSetNormalizerFromLazyOption() |
1342 | 1342 | { |
1343 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1344 | - $options->setNormalizer('foo', function () {}); |
|
1343 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1344 | + $options->setNormalizer('foo', function() {}); |
|
1345 | 1345 | }); |
1346 | 1346 | |
1347 | 1347 | $this->resolver->setDefault('bar', 'baz'); |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | { |
1354 | 1354 | $this->resolver->setDefault('foo', 'bar'); |
1355 | 1355 | |
1356 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1356 | + $this->resolver->setNormalizer('foo', function(Options $options, $value) { |
|
1357 | 1357 | return 'normalized['.$value.']'; |
1358 | 1358 | }); |
1359 | 1359 | |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | { |
1365 | 1365 | $this->resolver->setDefault('foo', 'bar'); |
1366 | 1366 | |
1367 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1367 | + $this->resolver->setNormalizer('foo', function(Options $options, $value) { |
|
1368 | 1368 | return 'normalized['.$value.']'; |
1369 | 1369 | }); |
1370 | 1370 | |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | |
1383 | 1383 | $this->resolver->setAllowedTypes('foo', 'int'); |
1384 | 1384 | |
1385 | - $this->resolver->setNormalizer('foo', function () { |
|
1385 | + $this->resolver->setNormalizer('foo', function() { |
|
1386 | 1386 | Assert::fail('Should not be called.'); |
1387 | 1387 | }); |
1388 | 1388 | |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | |
1399 | 1399 | $this->resolver->setAllowedValues('foo', 'baz'); |
1400 | 1400 | |
1401 | - $this->resolver->setNormalizer('foo', function () { |
|
1401 | + $this->resolver->setNormalizer('foo', function() { |
|
1402 | 1402 | Assert::fail('Should not be called.'); |
1403 | 1403 | }); |
1404 | 1404 | |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | $this->resolver->setDefault('default', 'bar'); |
1411 | 1411 | $this->resolver->setDefault('norm', 'baz'); |
1412 | 1412 | |
1413 | - $this->resolver->setNormalizer('norm', function (Options $options) { |
|
1413 | + $this->resolver->setNormalizer('norm', function(Options $options) { |
|
1414 | 1414 | /* @var TestCase $test */ |
1415 | 1415 | Assert::assertSame('bar', $options['default']); |
1416 | 1416 | |
@@ -1425,12 +1425,12 @@ discard block |
||
1425 | 1425 | |
1426 | 1426 | public function testNormalizerCanAccessLazyOptions() |
1427 | 1427 | { |
1428 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1428 | + $this->resolver->setDefault('lazy', function(Options $options) { |
|
1429 | 1429 | return 'bar'; |
1430 | 1430 | }); |
1431 | 1431 | $this->resolver->setDefault('norm', 'baz'); |
1432 | 1432 | |
1433 | - $this->resolver->setNormalizer('norm', function (Options $options) { |
|
1433 | + $this->resolver->setNormalizer('norm', function(Options $options) { |
|
1434 | 1434 | /* @var TestCase $test */ |
1435 | 1435 | Assert::assertEquals('bar', $options['lazy']); |
1436 | 1436 | |
@@ -1451,11 +1451,11 @@ discard block |
||
1451 | 1451 | $this->resolver->setDefault('norm1', 'bar'); |
1452 | 1452 | $this->resolver->setDefault('norm2', 'baz'); |
1453 | 1453 | |
1454 | - $this->resolver->setNormalizer('norm1', function (Options $options) { |
|
1454 | + $this->resolver->setNormalizer('norm1', function(Options $options) { |
|
1455 | 1455 | $options['norm2']; |
1456 | 1456 | }); |
1457 | 1457 | |
1458 | - $this->resolver->setNormalizer('norm2', function (Options $options) { |
|
1458 | + $this->resolver->setNormalizer('norm2', function(Options $options) { |
|
1459 | 1459 | $options['norm1']; |
1460 | 1460 | }); |
1461 | 1461 | |
@@ -1467,13 +1467,13 @@ discard block |
||
1467 | 1467 | */ |
1468 | 1468 | public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption() |
1469 | 1469 | { |
1470 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1470 | + $this->resolver->setDefault('lazy', function(Options $options) { |
|
1471 | 1471 | $options['norm']; |
1472 | 1472 | }); |
1473 | 1473 | |
1474 | 1474 | $this->resolver->setDefault('norm', 'baz'); |
1475 | 1475 | |
1476 | - $this->resolver->setNormalizer('norm', function (Options $options) { |
|
1476 | + $this->resolver->setNormalizer('norm', function(Options $options) { |
|
1477 | 1477 | $options['lazy']; |
1478 | 1478 | }); |
1479 | 1479 | |
@@ -1486,7 +1486,7 @@ discard block |
||
1486 | 1486 | |
1487 | 1487 | $this->resolver->setDefaults(['catcher' => null, 'thrower' => null]); |
1488 | 1488 | |
1489 | - $this->resolver->setNormalizer('catcher', function (Options $options) { |
|
1489 | + $this->resolver->setNormalizer('catcher', function(Options $options) { |
|
1490 | 1490 | try { |
1491 | 1491 | return $options['thrower']; |
1492 | 1492 | } catch (Exception $e) { |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | } |
1495 | 1495 | }); |
1496 | 1496 | |
1497 | - $this->resolver->setNormalizer('thrower', function () use (&$throw) { |
|
1497 | + $this->resolver->setNormalizer('thrower', function() use (&$throw) { |
|
1498 | 1498 | if ($throw) { |
1499 | 1499 | $throw = false; |
1500 | 1500 | throw new UnexpectedValueException('throwing'); |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | { |
1511 | 1511 | $throw = true; |
1512 | 1512 | |
1513 | - $this->resolver->setDefault('catcher', function (Options $options) { |
|
1513 | + $this->resolver->setDefault('catcher', function(Options $options) { |
|
1514 | 1514 | try { |
1515 | 1515 | return $options['thrower']; |
1516 | 1516 | } catch (Exception $e) { |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | } |
1519 | 1519 | }); |
1520 | 1520 | |
1521 | - $this->resolver->setDefault('thrower', function (Options $options) use (&$throw) { |
|
1521 | + $this->resolver->setDefault('thrower', function(Options $options) use (&$throw) { |
|
1522 | 1522 | if ($throw) { |
1523 | 1523 | $throw = false; |
1524 | 1524 | throw new UnexpectedValueException('throwing'); |
@@ -1537,12 +1537,12 @@ discard block |
||
1537 | 1537 | $this->resolver->setDefault('norm1', 'bar'); |
1538 | 1538 | $this->resolver->setDefault('norm2', 'baz'); |
1539 | 1539 | |
1540 | - $this->resolver->setNormalizer('norm1', function ($options) use (&$calls) { |
|
1540 | + $this->resolver->setNormalizer('norm1', function($options) use (&$calls) { |
|
1541 | 1541 | Assert::assertSame(1, ++$calls); |
1542 | 1542 | |
1543 | 1543 | $options['norm2']; |
1544 | 1544 | }); |
1545 | - $this->resolver->setNormalizer('norm2', function () use (&$calls) { |
|
1545 | + $this->resolver->setNormalizer('norm2', function() use (&$calls) { |
|
1546 | 1546 | Assert::assertSame(2, ++$calls); |
1547 | 1547 | }); |
1548 | 1548 | |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | { |
1556 | 1556 | $this->resolver->setDefined('norm'); |
1557 | 1557 | |
1558 | - $this->resolver->setNormalizer('norm', function () { |
|
1558 | + $this->resolver->setNormalizer('norm', function() { |
|
1559 | 1559 | Assert::fail('Should not be called.'); |
1560 | 1560 | }); |
1561 | 1561 | |
@@ -1589,7 +1589,7 @@ discard block |
||
1589 | 1589 | */ |
1590 | 1590 | public function testFailIfSetDefaultsFromLazyOption() |
1591 | 1591 | { |
1592 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1592 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1593 | 1593 | $options->setDefaults(['two' => '2']); |
1594 | 1594 | }); |
1595 | 1595 | |
@@ -1625,7 +1625,7 @@ discard block |
||
1625 | 1625 | |
1626 | 1626 | public function testRemoveLazyOption() |
1627 | 1627 | { |
1628 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1628 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1629 | 1629 | return 'lazy'; |
1630 | 1630 | }); |
1631 | 1631 | $this->resolver->remove('foo'); |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | public function testRemoveNormalizer() |
1637 | 1637 | { |
1638 | 1638 | $this->resolver->setDefault('foo', 'bar'); |
1639 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1639 | + $this->resolver->setNormalizer('foo', function(Options $options, $value) { |
|
1640 | 1640 | return 'normalized'; |
1641 | 1641 | }); |
1642 | 1642 | $this->resolver->remove('foo'); |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | */ |
1671 | 1671 | public function testFailIfRemoveFromLazyOption() |
1672 | 1672 | { |
1673 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1673 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1674 | 1674 | $options->remove('bar'); |
1675 | 1675 | }); |
1676 | 1676 | |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | |
1702 | 1702 | public function testClearLazyOption() |
1703 | 1703 | { |
1704 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1704 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1705 | 1705 | return 'lazy'; |
1706 | 1706 | }); |
1707 | 1707 | $this->resolver->clear(); |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | public function testClearNormalizer() |
1713 | 1713 | { |
1714 | 1714 | $this->resolver->setDefault('foo', 'bar'); |
1715 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1715 | + $this->resolver->setNormalizer('foo', function(Options $options, $value) { |
|
1716 | 1716 | return 'normalized'; |
1717 | 1717 | }); |
1718 | 1718 | $this->resolver->clear(); |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | */ |
1747 | 1747 | public function testFailIfClearFromLazyption() |
1748 | 1748 | { |
1749 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1749 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
1750 | 1750 | $options->clear(); |
1751 | 1751 | }); |
1752 | 1752 | |
@@ -1758,11 +1758,11 @@ discard block |
||
1758 | 1758 | public function testClearOptionAndNormalizer() |
1759 | 1759 | { |
1760 | 1760 | $this->resolver->setDefault('foo1', 'bar'); |
1761 | - $this->resolver->setNormalizer('foo1', function (Options $options) { |
|
1761 | + $this->resolver->setNormalizer('foo1', function(Options $options) { |
|
1762 | 1762 | return ''; |
1763 | 1763 | }); |
1764 | 1764 | $this->resolver->setDefault('foo2', 'bar'); |
1765 | - $this->resolver->setNormalizer('foo2', function (Options $options) { |
|
1765 | + $this->resolver->setNormalizer('foo2', function(Options $options) { |
|
1766 | 1766 | return ''; |
1767 | 1767 | }); |
1768 | 1768 | |
@@ -1776,11 +1776,11 @@ discard block |
||
1776 | 1776 | $this->resolver->setDefault('default2', 1); |
1777 | 1777 | $this->resolver->setRequired('required'); |
1778 | 1778 | $this->resolver->setDefined('defined'); |
1779 | - $this->resolver->setDefault('lazy1', function (Options $options) { |
|
1779 | + $this->resolver->setDefault('lazy1', function(Options $options) { |
|
1780 | 1780 | return 'lazy'; |
1781 | 1781 | }); |
1782 | 1782 | |
1783 | - $this->resolver->setDefault('lazy2', function (Options $options) { |
|
1783 | + $this->resolver->setDefault('lazy2', function(Options $options) { |
|
1784 | 1784 | Assert::assertArrayHasKey('default1', $options); |
1785 | 1785 | Assert::assertArrayHasKey('default2', $options); |
1786 | 1786 | Assert::assertArrayHasKey('required', $options); |
@@ -1846,7 +1846,7 @@ discard block |
||
1846 | 1846 | { |
1847 | 1847 | $this->resolver->setDefault('foo', 'bar'); |
1848 | 1848 | |
1849 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1849 | + $this->resolver->setDefault('lazy', function(Options $options) { |
|
1850 | 1850 | $options['undefined']; |
1851 | 1851 | }); |
1852 | 1852 | |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | { |
1862 | 1862 | $this->resolver->setDefined('defined'); |
1863 | 1863 | |
1864 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1864 | + $this->resolver->setDefault('lazy', function(Options $options) { |
|
1865 | 1865 | $options['defined']; |
1866 | 1866 | }); |
1867 | 1867 | |
@@ -1873,11 +1873,11 @@ discard block |
||
1873 | 1873 | */ |
1874 | 1874 | public function testFailIfCyclicDependency() |
1875 | 1875 | { |
1876 | - $this->resolver->setDefault('lazy1', function (Options $options) { |
|
1876 | + $this->resolver->setDefault('lazy1', function(Options $options) { |
|
1877 | 1877 | $options['lazy2']; |
1878 | 1878 | }); |
1879 | 1879 | |
1880 | - $this->resolver->setDefault('lazy2', function (Options $options) { |
|
1880 | + $this->resolver->setDefault('lazy2', function(Options $options) { |
|
1881 | 1881 | $options['lazy1']; |
1882 | 1882 | }); |
1883 | 1883 | |
@@ -1889,9 +1889,9 @@ discard block |
||
1889 | 1889 | $this->resolver->setDefault('default', 0); |
1890 | 1890 | $this->resolver->setRequired('required'); |
1891 | 1891 | $this->resolver->setDefined('defined'); |
1892 | - $this->resolver->setDefault('lazy1', function () {}); |
|
1892 | + $this->resolver->setDefault('lazy1', function() {}); |
|
1893 | 1893 | |
1894 | - $this->resolver->setDefault('lazy2', function (Options $options) { |
|
1894 | + $this->resolver->setDefault('lazy2', function(Options $options) { |
|
1895 | 1895 | Assert::assertCount(4, $options); |
1896 | 1896 | }); |
1897 | 1897 | |
@@ -1910,7 +1910,7 @@ discard block |
||
1910 | 1910 | $this->resolver->setDefault('foo', 0); |
1911 | 1911 | $this->resolver->setRequired('bar'); |
1912 | 1912 | $this->resolver->setDefined('bar'); |
1913 | - $this->resolver->setDefault('lazy1', function () {}); |
|
1913 | + $this->resolver->setDefault('lazy1', function() {}); |
|
1914 | 1914 | |
1915 | 1915 | count($this->resolver); |
1916 | 1916 | } |
@@ -2065,7 +2065,7 @@ discard block |
||
2065 | 2065 | public function testIsNestedOption() |
2066 | 2066 | { |
2067 | 2067 | $this->resolver->setDefaults([ |
2068 | - 'database' => function (OptionsResolver $resolver) { |
|
2068 | + 'database' => function(OptionsResolver $resolver) { |
|
2069 | 2069 | $resolver->setDefined(['host', 'port']); |
2070 | 2070 | }, |
2071 | 2071 | ]); |
@@ -2080,7 +2080,7 @@ discard block |
||
2080 | 2080 | { |
2081 | 2081 | $this->resolver->setDefaults([ |
2082 | 2082 | 'name' => 'default', |
2083 | - 'database' => function (OptionsResolver $resolver) { |
|
2083 | + 'database' => function(OptionsResolver $resolver) { |
|
2084 | 2084 | $resolver->setDefined(['host', 'port']); |
2085 | 2085 | }, |
2086 | 2086 | ]); |
@@ -2097,7 +2097,7 @@ discard block |
||
2097 | 2097 | { |
2098 | 2098 | $this->resolver->setDefaults([ |
2099 | 2099 | 'name' => 'default', |
2100 | - 'database' => function (OptionsResolver $resolver) { |
|
2100 | + 'database' => function(OptionsResolver $resolver) { |
|
2101 | 2101 | $resolver->setRequired('host'); |
2102 | 2102 | }, |
2103 | 2103 | ]); |
@@ -2114,7 +2114,7 @@ discard block |
||
2114 | 2114 | { |
2115 | 2115 | $this->resolver->setDefaults([ |
2116 | 2116 | 'name' => 'default', |
2117 | - 'database' => function (OptionsResolver $resolver) { |
|
2117 | + 'database' => function(OptionsResolver $resolver) { |
|
2118 | 2118 | $resolver |
2119 | 2119 | ->setDefined('logging') |
2120 | 2120 | ->setAllowedTypes('logging', 'bool'); |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | { |
2134 | 2134 | $this->resolver->setDefaults([ |
2135 | 2135 | 'name' => 'default', |
2136 | - 'database' => function (OptionsResolver $resolver) { |
|
2136 | + 'database' => function(OptionsResolver $resolver) { |
|
2137 | 2137 | $resolver->setDefined('host'); |
2138 | 2138 | }, |
2139 | 2139 | ]); |
@@ -2146,7 +2146,7 @@ discard block |
||
2146 | 2146 | { |
2147 | 2147 | $this->resolver->setDefaults([ |
2148 | 2148 | 'name' => 'default', |
2149 | - 'database' => function (OptionsResolver $resolver) { |
|
2149 | + 'database' => function(OptionsResolver $resolver) { |
|
2150 | 2150 | $resolver->setDefined(['host', 'port']); |
2151 | 2151 | }, |
2152 | 2152 | ]); |
@@ -2162,7 +2162,7 @@ discard block |
||
2162 | 2162 | { |
2163 | 2163 | $this->resolver->setDefaults([ |
2164 | 2164 | 'name' => 'default', |
2165 | - 'database' => function (OptionsResolver $resolver) { |
|
2165 | + 'database' => function(OptionsResolver $resolver) { |
|
2166 | 2166 | $resolver->setDefaults([ |
2167 | 2167 | 'host' => 'localhost', |
2168 | 2168 | 'port' => 3306, |
@@ -2184,12 +2184,12 @@ discard block |
||
2184 | 2184 | { |
2185 | 2185 | $this->resolver->setDefaults([ |
2186 | 2186 | 'name' => 'default', |
2187 | - 'database' => function (OptionsResolver $resolver) { |
|
2187 | + 'database' => function(OptionsResolver $resolver) { |
|
2188 | 2188 | $resolver |
2189 | 2189 | ->setRequired(['dbname', 'host']) |
2190 | 2190 | ->setDefaults([ |
2191 | 2191 | 'port' => 3306, |
2192 | - 'replicas' => function (OptionsResolver $resolver) { |
|
2192 | + 'replicas' => function(OptionsResolver $resolver) { |
|
2193 | 2193 | $resolver->setDefaults([ |
2194 | 2194 | 'host' => 'replica1', |
2195 | 2195 | 'port' => 3306, |
@@ -2222,10 +2222,10 @@ discard block |
||
2222 | 2222 | public function testResolveLazyOptionUsingNestedOption() |
2223 | 2223 | { |
2224 | 2224 | $this->resolver->setDefaults([ |
2225 | - 'version' => function (Options $options) { |
|
2225 | + 'version' => function(Options $options) { |
|
2226 | 2226 | return $options['database']['server_version']; |
2227 | 2227 | }, |
2228 | - 'database' => function (OptionsResolver $resolver) { |
|
2228 | + 'database' => function(OptionsResolver $resolver) { |
|
2229 | 2229 | $resolver->setDefault('server_version', '3.15'); |
2230 | 2230 | }, |
2231 | 2231 | ]); |
@@ -2241,7 +2241,7 @@ discard block |
||
2241 | 2241 | { |
2242 | 2242 | $this->resolver |
2243 | 2243 | ->setDefaults([ |
2244 | - 'database' => function (OptionsResolver $resolver) { |
|
2244 | + 'database' => function(OptionsResolver $resolver) { |
|
2245 | 2245 | $resolver->setDefaults([ |
2246 | 2246 | 'port' => 3306, |
2247 | 2247 | 'host' => 'localhost', |
@@ -2249,7 +2249,7 @@ discard block |
||
2249 | 2249 | ]); |
2250 | 2250 | }, |
2251 | 2251 | ]) |
2252 | - ->setNormalizer('database', function (Options $options, $value) { |
|
2252 | + ->setNormalizer('database', function(Options $options, $value) { |
|
2253 | 2253 | ksort($value); |
2254 | 2254 | |
2255 | 2255 | return $value; |
@@ -2266,11 +2266,11 @@ discard block |
||
2266 | 2266 | public function testOverwrittenNestedOptionNotEvaluatedIfLazyDefault() |
2267 | 2267 | { |
2268 | 2268 | // defined by superclass |
2269 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2269 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2270 | 2270 | Assert::fail('Should not be called'); |
2271 | 2271 | }); |
2272 | 2272 | // defined by subclass |
2273 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
2273 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
2274 | 2274 | return 'lazy'; |
2275 | 2275 | }); |
2276 | 2276 | $this->assertSame(['foo' => 'lazy'], $this->resolver->resolve()); |
@@ -2279,7 +2279,7 @@ discard block |
||
2279 | 2279 | public function testOverwrittenNestedOptionNotEvaluatedIfScalarDefault() |
2280 | 2280 | { |
2281 | 2281 | // defined by superclass |
2282 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2282 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2283 | 2283 | Assert::fail('Should not be called'); |
2284 | 2284 | }); |
2285 | 2285 | // defined by subclass |
@@ -2290,11 +2290,11 @@ discard block |
||
2290 | 2290 | public function testOverwrittenLazyOptionNotEvaluatedIfNestedOption() |
2291 | 2291 | { |
2292 | 2292 | // defined by superclass |
2293 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
2293 | + $this->resolver->setDefault('foo', function(Options $options) { |
|
2294 | 2294 | Assert::fail('Should not be called'); |
2295 | 2295 | }); |
2296 | 2296 | // defined by subclass |
2297 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2297 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2298 | 2298 | $resolver->setDefault('bar', 'baz'); |
2299 | 2299 | }); |
2300 | 2300 | $this->assertSame(['foo' => ['bar' => 'baz']], $this->resolver->resolve()); |
@@ -2303,15 +2303,15 @@ discard block |
||
2303 | 2303 | public function testResolveAllNestedOptionDefinitions() |
2304 | 2304 | { |
2305 | 2305 | // defined by superclass |
2306 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2306 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2307 | 2307 | $resolver->setRequired('bar'); |
2308 | 2308 | }); |
2309 | 2309 | // defined by subclass |
2310 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2310 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2311 | 2311 | $resolver->setDefault('bar', 'baz'); |
2312 | 2312 | }); |
2313 | 2313 | // defined by subclass |
2314 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2314 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2315 | 2315 | $resolver->setDefault('ping', 'pong'); |
2316 | 2316 | }); |
2317 | 2317 | $this->assertSame(['foo' => ['ping' => 'pong', 'bar' => 'baz']], $this->resolver->resolve()); |
@@ -2320,11 +2320,11 @@ discard block |
||
2320 | 2320 | public function testNormalizeNestedValue() |
2321 | 2321 | { |
2322 | 2322 | // defined by superclass |
2323 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2323 | + $this->resolver->setDefault('foo', function(OptionsResolver $resolver) { |
|
2324 | 2324 | $resolver->setDefault('bar', null); |
2325 | 2325 | }); |
2326 | 2326 | // defined by subclass |
2327 | - $this->resolver->setNormalizer('foo', function (Options $options, $resolvedValue) { |
|
2327 | + $this->resolver->setNormalizer('foo', function(Options $options, $resolvedValue) { |
|
2328 | 2328 | if (null === $resolvedValue['bar']) { |
2329 | 2329 | $resolvedValue['bar'] = 'baz'; |
2330 | 2330 | } |
@@ -2339,7 +2339,7 @@ discard block |
||
2339 | 2339 | */ |
2340 | 2340 | public function testFailsIfCyclicDependencyBetweenSameNestedOption() |
2341 | 2341 | { |
2342 | - $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { |
|
2342 | + $this->resolver->setDefault('database', function(OptionsResolver $resolver, Options $parent) { |
|
2343 | 2343 | $resolver->setDefault('replicas', $parent['database']); |
2344 | 2344 | }); |
2345 | 2345 | $this->resolver->resolve(); |
@@ -2351,10 +2351,10 @@ discard block |
||
2351 | 2351 | public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption() |
2352 | 2352 | { |
2353 | 2353 | $this->resolver->setDefaults([ |
2354 | - 'version' => function (Options $options) { |
|
2354 | + 'version' => function(Options $options) { |
|
2355 | 2355 | return $options['database']['server_version']; |
2356 | 2356 | }, |
2357 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2357 | + 'database' => function(OptionsResolver $resolver, Options $parent) { |
|
2358 | 2358 | $resolver->setDefault('server_version', $parent['version']); |
2359 | 2359 | }, |
2360 | 2360 | ]); |
@@ -2368,10 +2368,10 @@ discard block |
||
2368 | 2368 | { |
2369 | 2369 | $this->resolver |
2370 | 2370 | ->setDefault('name', 'default') |
2371 | - ->setDefault('database', function (OptionsResolver $resolver, Options $parent) { |
|
2371 | + ->setDefault('database', function(OptionsResolver $resolver, Options $parent) { |
|
2372 | 2372 | $resolver->setDefault('host', $parent['name']); |
2373 | 2373 | }) |
2374 | - ->setNormalizer('name', function (Options $options, $value) { |
|
2374 | + ->setNormalizer('name', function(Options $options, $value) { |
|
2375 | 2375 | $options['database']; |
2376 | 2376 | }); |
2377 | 2377 | $this->resolver->resolve(); |
@@ -2382,10 +2382,10 @@ discard block |
||
2382 | 2382 | */ |
2383 | 2383 | public function testFailsIfCyclicDependencyBetweenNestedOptions() |
2384 | 2384 | { |
2385 | - $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { |
|
2385 | + $this->resolver->setDefault('database', function(OptionsResolver $resolver, Options $parent) { |
|
2386 | 2386 | $resolver->setDefault('host', $parent['replica']['host']); |
2387 | 2387 | }); |
2388 | - $this->resolver->setDefault('replica', function (OptionsResolver $resolver, Options $parent) { |
|
2388 | + $this->resolver->setDefault('replica', function(OptionsResolver $resolver, Options $parent) { |
|
2389 | 2389 | $resolver->setDefault('host', $parent['database']['host']); |
2390 | 2390 | }); |
2391 | 2391 | $this->resolver->resolve(); |
@@ -2395,7 +2395,7 @@ discard block |
||
2395 | 2395 | { |
2396 | 2396 | $this->resolver->setDefaults([ |
2397 | 2397 | 'version' => 3.15, |
2398 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2398 | + 'database' => function(OptionsResolver $resolver, Options $parent) { |
|
2399 | 2399 | $resolver->setDefault('server_version', $parent['version']); |
2400 | 2400 | }, |
2401 | 2401 | ]); |
@@ -2404,7 +2404,7 @@ discard block |
||
2404 | 2404 | |
2405 | 2405 | public function testNestedClosureWithoutTypeHintNotInvoked() |
2406 | 2406 | { |
2407 | - $closure = function ($resolver) { |
|
2407 | + $closure = function($resolver) { |
|
2408 | 2408 | Assert::fail('Should not be called'); |
2409 | 2409 | }; |
2410 | 2410 | $this->resolver->setDefault('foo', $closure); |
@@ -2413,7 +2413,7 @@ discard block |
||
2413 | 2413 | |
2414 | 2414 | public function testNestedClosureWithoutTypeHint2ndArgumentNotInvoked() |
2415 | 2415 | { |
2416 | - $closure = function (OptionsResolver $resolver, $parent) { |
|
2416 | + $closure = function(OptionsResolver $resolver, $parent) { |
|
2417 | 2417 | Assert::fail('Should not be called'); |
2418 | 2418 | }; |
2419 | 2419 | $this->resolver->setDefault('foo', $closure); |
@@ -2424,13 +2424,13 @@ discard block |
||
2424 | 2424 | { |
2425 | 2425 | $this->resolver->setDefaults([ |
2426 | 2426 | 'ip' => null, |
2427 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2427 | + 'database' => function(OptionsResolver $resolver, Options $parent) { |
|
2428 | 2428 | $resolver->setDefault('host', $parent['ip']); |
2429 | - $resolver->setDefault('primary_replica', function (OptionsResolver $resolver, Options $parent) { |
|
2429 | + $resolver->setDefault('primary_replica', function(OptionsResolver $resolver, Options $parent) { |
|
2430 | 2430 | $resolver->setDefault('host', $parent['host']); |
2431 | 2431 | }); |
2432 | 2432 | }, |
2433 | - 'secondary_replica' => function (Options $options) { |
|
2433 | + 'secondary_replica' => function(Options $options) { |
|
2434 | 2434 | return $options['database']['primary_replica']['host']; |
2435 | 2435 | }, |
2436 | 2436 | ]); |
@@ -2450,13 +2450,13 @@ discard block |
||
2450 | 2450 | { |
2451 | 2451 | $this->resolver->setDefaults([ |
2452 | 2452 | 'debug' => true, |
2453 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2453 | + 'database' => function(OptionsResolver $resolver, Options $parent) { |
|
2454 | 2454 | $resolver |
2455 | 2455 | ->setDefined('logging') |
2456 | - ->setDefault('profiling', function (Options $options) use ($parent) { |
|
2456 | + ->setDefault('profiling', function(Options $options) use ($parent) { |
|
2457 | 2457 | return $parent['debug']; |
2458 | 2458 | }) |
2459 | - ->setNormalizer('logging', function (Options $options, $value) use ($parent) { |
|
2459 | + ->setNormalizer('logging', function(Options $options, $value) use ($parent) { |
|
2460 | 2460 | return false === $parent['debug'] ? true : $value; |
2461 | 2461 | }); |
2462 | 2462 | }, |
@@ -66,7 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function testResolveFailsFromLazyOption() |
68 | 68 | { |
69 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
69 | + $this->resolver->setDefault('foo', function (Options $options) |
|
70 | + { |
|
70 | 71 | $options->resolve([]); |
71 | 72 | }); |
72 | 73 | |
@@ -94,7 +95,8 @@ discard block |
||
94 | 95 | */ |
95 | 96 | public function testFailIfSetDefaultFromLazyOption() |
96 | 97 | { |
97 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
98 | + $this->resolver->setDefault('lazy', function (Options $options) |
|
99 | + { |
|
98 | 100 | $options->setDefault('default', 42); |
99 | 101 | }); |
100 | 102 | |
@@ -117,12 +119,15 @@ discard block |
||
117 | 119 | |
118 | 120 | public function testSetLazyReturnsThis() |
119 | 121 | { |
120 | - $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function (Options $options) {})); |
|
122 | + $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function (Options $options) |
|
123 | + { |
|
124 | +})); |
|
121 | 125 | } |
122 | 126 | |
123 | 127 | public function testSetLazyClosure() |
124 | 128 | { |
125 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
129 | + $this->resolver->setDefault('foo', function (Options $options) |
|
130 | + { |
|
126 | 131 | return 'lazy'; |
127 | 132 | }); |
128 | 133 | |
@@ -131,7 +136,8 @@ discard block |
||
131 | 136 | |
132 | 137 | public function testClosureWithoutTypeHintNotInvoked() |
133 | 138 | { |
134 | - $closure = function ($options) { |
|
139 | + $closure = function ($options) |
|
140 | + { |
|
135 | 141 | Assert::fail('Should not be called'); |
136 | 142 | }; |
137 | 143 | |
@@ -142,7 +148,8 @@ discard block |
||
142 | 148 | |
143 | 149 | public function testClosureWithoutParametersNotInvoked() |
144 | 150 | { |
145 | - $closure = function () { |
|
151 | + $closure = function () |
|
152 | + { |
|
146 | 153 | Assert::fail('Should not be called'); |
147 | 154 | }; |
148 | 155 | |
@@ -157,7 +164,8 @@ discard block |
||
157 | 164 | $this->resolver->setDefault('foo', 'bar'); |
158 | 165 | |
159 | 166 | // defined by subclass |
160 | - $this->resolver->setDefault('foo', function (Options $options, $previousValue) { |
|
167 | + $this->resolver->setDefault('foo', function (Options $options, $previousValue) |
|
168 | + { |
|
161 | 169 | Assert::assertEquals('bar', $previousValue); |
162 | 170 | |
163 | 171 | return 'lazy'; |
@@ -169,12 +177,14 @@ discard block |
||
169 | 177 | public function testAccessPreviousLazyDefaultValue() |
170 | 178 | { |
171 | 179 | // defined by superclass |
172 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
180 | + $this->resolver->setDefault('foo', function (Options $options) |
|
181 | + { |
|
173 | 182 | return 'bar'; |
174 | 183 | }); |
175 | 184 | |
176 | 185 | // defined by subclass |
177 | - $this->resolver->setDefault('foo', function (Options $options, $previousValue) { |
|
186 | + $this->resolver->setDefault('foo', function (Options $options, $previousValue) |
|
187 | + { |
|
178 | 188 | Assert::assertEquals('bar', $previousValue); |
179 | 189 | |
180 | 190 | return 'lazy'; |
@@ -186,12 +196,14 @@ discard block |
||
186 | 196 | public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() |
187 | 197 | { |
188 | 198 | // defined by superclass |
189 | - $this->resolver->setDefault('foo', function () { |
|
199 | + $this->resolver->setDefault('foo', function () |
|
200 | + { |
|
190 | 201 | Assert::fail('Should not be called'); |
191 | 202 | }); |
192 | 203 | |
193 | 204 | // defined by subclass, no $previousValue argument defined! |
194 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
205 | + $this->resolver->setDefault('foo', function (Options $options) |
|
206 | + { |
|
195 | 207 | return 'lazy'; |
196 | 208 | }); |
197 | 209 | |
@@ -200,7 +212,8 @@ discard block |
||
200 | 212 | |
201 | 213 | public function testOverwrittenLazyOptionNotEvaluated() |
202 | 214 | { |
203 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
215 | + $this->resolver->setDefault('foo', function (Options $options) |
|
216 | + { |
|
204 | 217 | Assert::fail('Should not be called'); |
205 | 218 | }); |
206 | 219 | |
@@ -213,13 +226,15 @@ discard block |
||
213 | 226 | { |
214 | 227 | $calls = 0; |
215 | 228 | |
216 | - $this->resolver->setDefault('lazy1', function (Options $options) use (&$calls) { |
|
229 | + $this->resolver->setDefault('lazy1', function (Options $options) use (&$calls) |
|
230 | + { |
|
217 | 231 | Assert::assertSame(1, ++$calls); |
218 | 232 | |
219 | 233 | $options['lazy2']; |
220 | 234 | }); |
221 | 235 | |
222 | - $this->resolver->setDefault('lazy2', function (Options $options) use (&$calls) { |
|
236 | + $this->resolver->setDefault('lazy2', function (Options $options) use (&$calls) |
|
237 | + { |
|
223 | 238 | Assert::assertSame(2, ++$calls); |
224 | 239 | }); |
225 | 240 | |
@@ -238,7 +253,8 @@ discard block |
||
238 | 253 | */ |
239 | 254 | public function testFailIfSetRequiredFromLazyOption() |
240 | 255 | { |
241 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
256 | + $this->resolver->setDefault('foo', function (Options $options) |
|
257 | + { |
|
242 | 258 | $options->setRequired('bar'); |
243 | 259 | }); |
244 | 260 | |
@@ -366,7 +382,8 @@ discard block |
||
366 | 382 | */ |
367 | 383 | public function testFailIfSetDefinedFromLazyOption() |
368 | 384 | { |
369 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
385 | + $this->resolver->setDefault('foo', function (Options $options) |
|
386 | + { |
|
370 | 387 | $options->setDefined('bar'); |
371 | 388 | }); |
372 | 389 | |
@@ -413,7 +430,9 @@ discard block |
||
413 | 430 | public function testLazyOptionsAreDefined() |
414 | 431 | { |
415 | 432 | $this->assertFalse($this->resolver->isDefined('foo')); |
416 | - $this->resolver->setDefault('foo', function (Options $options) {}); |
|
433 | + $this->resolver->setDefault('foo', function (Options $options) |
|
434 | + { |
|
435 | +}); |
|
417 | 436 | $this->assertTrue($this->resolver->isDefined('foo')); |
418 | 437 | } |
419 | 438 | |
@@ -465,7 +484,8 @@ discard block |
||
465 | 484 | { |
466 | 485 | $this->resolver |
467 | 486 | ->setDefault('bar', 'baz') |
468 | - ->setDefault('foo', function (Options $options) { |
|
487 | + ->setDefault('foo', function (Options $options) |
|
488 | + { |
|
469 | 489 | $options->setDeprecated('bar'); |
470 | 490 | }) |
471 | 491 | ->resolve() |
@@ -500,7 +520,8 @@ discard block |
||
500 | 520 | { |
501 | 521 | $this->resolver |
502 | 522 | ->setDefined('foo') |
503 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
523 | + ->setDeprecated('foo', function (Options $options, $value) |
|
524 | + { |
|
504 | 525 | return false; |
505 | 526 | }) |
506 | 527 | ; |
@@ -515,10 +536,12 @@ discard block |
||
515 | 536 | { |
516 | 537 | $this->resolver |
517 | 538 | ->setDefined(['foo', 'bar']) |
518 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
539 | + ->setDeprecated('foo', function (Options $options, $value) |
|
540 | + { |
|
519 | 541 | $options['bar']; |
520 | 542 | }) |
521 | - ->setDeprecated('bar', function (Options $options, $value) { |
|
543 | + ->setDeprecated('bar', function (Options $options, $value) |
|
544 | + { |
|
522 | 545 | $options['foo']; |
523 | 546 | }) |
524 | 547 | ; |
@@ -550,7 +573,8 @@ discard block |
||
550 | 573 | { |
551 | 574 | $count = 0; |
552 | 575 | error_clear_last(); |
553 | - set_error_handler(function () use (&$count) { |
|
576 | + set_error_handler(function () use (&$count) |
|
577 | + { |
|
554 | 578 | ++$count; |
555 | 579 | |
556 | 580 | return false; |
@@ -573,7 +597,8 @@ discard block |
||
573 | 597 | public function provideDeprecationData() |
574 | 598 | { |
575 | 599 | yield 'It deprecates an option with default message' => [ |
576 | - function (OptionsResolver $resolver) { |
|
600 | + function (OptionsResolver $resolver) |
|
601 | + { |
|
577 | 602 | $resolver |
578 | 603 | ->setDefined(['foo', 'bar']) |
579 | 604 | ->setDeprecated('foo') |
@@ -588,10 +613,12 @@ discard block |
||
588 | 613 | ]; |
589 | 614 | |
590 | 615 | yield 'It deprecates an option with custom message' => [ |
591 | - function (OptionsResolver $resolver) { |
|
616 | + function (OptionsResolver $resolver) |
|
617 | + { |
|
592 | 618 | $resolver |
593 | 619 | ->setDefined('foo') |
594 | - ->setDefault('bar', function (Options $options) { |
|
620 | + ->setDefault('bar', function (Options $options) |
|
621 | + { |
|
595 | 622 | return $options['foo']; |
596 | 623 | }) |
597 | 624 | ->setDeprecated('foo', 'The option "foo" is deprecated, use "bar" option instead.') |
@@ -606,14 +633,16 @@ discard block |
||
606 | 633 | ]; |
607 | 634 | |
608 | 635 | yield 'It deprecates an option evaluated in another definition' => [ |
609 | - function (OptionsResolver $resolver) { |
|
636 | + function (OptionsResolver $resolver) |
|
637 | + { |
|
610 | 638 | // defined by superclass |
611 | 639 | $resolver |
612 | 640 | ->setDefault('foo', null) |
613 | 641 | ->setDeprecated('foo') |
614 | 642 | ; |
615 | 643 | // defined by subclass |
616 | - $resolver->setDefault('bar', function (Options $options) { |
|
644 | + $resolver->setDefault('bar', function (Options $options) |
|
645 | + { |
|
617 | 646 | return $options['foo']; // It triggers a deprecation |
618 | 647 | }); |
619 | 648 | }, |
@@ -626,11 +655,13 @@ discard block |
||
626 | 655 | ]; |
627 | 656 | |
628 | 657 | yield 'It deprecates allowed type and value' => [ |
629 | - function (OptionsResolver $resolver) { |
|
658 | + function (OptionsResolver $resolver) |
|
659 | + { |
|
630 | 660 | $resolver |
631 | 661 | ->setDefault('foo', null) |
632 | 662 | ->setAllowedTypes('foo', ['null', 'string', stdClass::class]) |
633 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
663 | + ->setDeprecated('foo', function (Options $options, $value) |
|
664 | + { |
|
634 | 665 | if ($value instanceof stdClass) { |
635 | 666 | return sprintf('Passing an instance of "%s" to option "foo" is deprecated, pass its FQCN instead.', stdClass::class); |
636 | 667 | } |
@@ -648,11 +679,13 @@ discard block |
||
648 | 679 | ]; |
649 | 680 | |
650 | 681 | yield 'It triggers a deprecation based on the value only if option is provided by the user' => [ |
651 | - function (OptionsResolver $resolver) { |
|
682 | + function (OptionsResolver $resolver) |
|
683 | + { |
|
652 | 684 | $resolver |
653 | 685 | ->setDefined('foo') |
654 | 686 | ->setAllowedTypes('foo', ['null', 'bool']) |
655 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
687 | + ->setDeprecated('foo', function (Options $options, $value) |
|
688 | + { |
|
656 | 689 | if (! is_bool($value)) { |
657 | 690 | return 'Passing a value different than true or false is deprecated.'; |
658 | 691 | } |
@@ -661,14 +694,16 @@ discard block |
||
661 | 694 | }) |
662 | 695 | ->setDefault('baz', null) |
663 | 696 | ->setAllowedTypes('baz', ['null', 'int']) |
664 | - ->setDeprecated('baz', function (Options $options, $value) { |
|
697 | + ->setDeprecated('baz', function (Options $options, $value) |
|
698 | + { |
|
665 | 699 | if (! is_int($value)) { |
666 | 700 | return 'Not passing an integer is deprecated.'; |
667 | 701 | } |
668 | 702 | |
669 | 703 | return ''; |
670 | 704 | }) |
671 | - ->setDefault('bar', function (Options $options) { |
|
705 | + ->setDefault('bar', function (Options $options) |
|
706 | + { |
|
672 | 707 | $options['baz']; // It does not triggers a deprecation |
673 | 708 | |
674 | 709 | return $options['foo']; // It does not triggers a deprecation |
@@ -684,10 +719,12 @@ discard block |
||
684 | 719 | ]; |
685 | 720 | |
686 | 721 | yield 'It ignores a deprecation if closure returns an empty string' => [ |
687 | - function (OptionsResolver $resolver) { |
|
722 | + function (OptionsResolver $resolver) |
|
723 | + { |
|
688 | 724 | $resolver |
689 | 725 | ->setDefault('foo', null) |
690 | - ->setDeprecated('foo', function (Options $options, $value) { |
|
726 | + ->setDeprecated('foo', function (Options $options, $value) |
|
727 | + { |
|
691 | 728 | return ''; |
692 | 729 | }) |
693 | 730 | ; |
@@ -698,11 +735,13 @@ discard block |
||
698 | 735 | ]; |
699 | 736 | |
700 | 737 | yield 'It deprecates value depending on other option value' => [ |
701 | - function (OptionsResolver $resolver) { |
|
738 | + function (OptionsResolver $resolver) |
|
739 | + { |
|
702 | 740 | $resolver |
703 | 741 | ->setDefault('widget', null) |
704 | 742 | ->setDefault('date_format', null) |
705 | - ->setDeprecated('date_format', function (Options $options, $dateFormat) { |
|
743 | + ->setDeprecated('date_format', function (Options $options, $dateFormat) |
|
744 | + { |
|
706 | 745 | if (null !== $dateFormat && 'single_text' === $options['widget']) { |
707 | 746 | return 'Using the "date_format" option when the "widget" option is set to "single_text" is deprecated.'; |
708 | 747 | } |
@@ -720,16 +759,19 @@ discard block |
||
720 | 759 | ]; |
721 | 760 | |
722 | 761 | yield 'It triggers a deprecation for each evaluation' => [ |
723 | - function (OptionsResolver $resolver) { |
|
762 | + function (OptionsResolver $resolver) |
|
763 | + { |
|
724 | 764 | $resolver |
725 | 765 | // defined by superclass |
726 | 766 | ->setDefined('foo') |
727 | 767 | ->setDeprecated('foo') |
728 | 768 | // defined by subclass |
729 | - ->setDefault('bar', function (Options $options) { |
|
769 | + ->setDefault('bar', function (Options $options) |
|
770 | + { |
|
730 | 771 | return $options['foo']; // It triggers a deprecation |
731 | 772 | }) |
732 | - ->setNormalizer('bar', function (Options $options, $value) { |
|
773 | + ->setNormalizer('bar', function (Options $options, $value) |
|
774 | + { |
|
733 | 775 | $options['foo']; // It triggers a deprecation |
734 | 776 | $options['foo']; // It triggers a deprecation |
735 | 777 | |
@@ -746,7 +788,8 @@ discard block |
||
746 | 788 | ]; |
747 | 789 | |
748 | 790 | yield 'It ignores a deprecation if no option is provided by the user' => [ |
749 | - function (OptionsResolver $resolver) { |
|
791 | + function (OptionsResolver $resolver) |
|
792 | + { |
|
750 | 793 | $resolver |
751 | 794 | ->setDefined('foo') |
752 | 795 | ->setDefault('bar', null) |
@@ -760,14 +803,17 @@ discard block |
||
760 | 803 | ]; |
761 | 804 | |
762 | 805 | yield 'It explicitly ignores a depreciation' => [ |
763 | - function (OptionsResolver $resolver) { |
|
806 | + function (OptionsResolver $resolver) |
|
807 | + { |
|
764 | 808 | $resolver |
765 | - ->setDefault('baz', function (Options $options) { |
|
809 | + ->setDefault('baz', function (Options $options) |
|
810 | + { |
|
766 | 811 | return $options->offsetGet('foo', false); |
767 | 812 | }) |
768 | 813 | ->setDefault('foo', null) |
769 | 814 | ->setDeprecated('foo') |
770 | - ->setDefault('bar', function (Options $options) { |
|
815 | + ->setDefault('bar', function (Options $options) |
|
816 | + { |
|
771 | 817 | return $options->offsetGet('foo', false); |
772 | 818 | }) |
773 | 819 | ; |
@@ -800,7 +846,8 @@ discard block |
||
800 | 846 | */ |
801 | 847 | public function testFailIfSetAllowedTypesFromLazyOption() |
802 | 848 | { |
803 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
849 | + $this->resolver->setDefault('foo', function (Options $options) |
|
850 | + { |
|
804 | 851 | $options->setAllowedTypes('bar', 'string'); |
805 | 852 | }); |
806 | 853 | |
@@ -975,7 +1022,8 @@ discard block |
||
975 | 1022 | */ |
976 | 1023 | public function testFailIfAddAllowedTypesFromLazyOption() |
977 | 1024 | { |
978 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1025 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1026 | + { |
|
979 | 1027 | $options->addAllowedTypes('bar', 'string'); |
980 | 1028 | }); |
981 | 1029 | |
@@ -1057,7 +1105,8 @@ discard block |
||
1057 | 1105 | */ |
1058 | 1106 | public function testFailIfSetAllowedValuesFromLazyOption() |
1059 | 1107 | { |
1060 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1108 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1109 | + { |
|
1061 | 1110 | $options->setAllowedValues('bar', 'baz'); |
1062 | 1111 | }); |
1063 | 1112 | |
@@ -1140,7 +1189,8 @@ discard block |
||
1140 | 1189 | public function testResolveFailsIfClosureReturnsFalse() |
1141 | 1190 | { |
1142 | 1191 | $this->resolver->setDefault('foo', 42); |
1143 | - $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { |
|
1192 | + $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) |
|
1193 | + { |
|
1144 | 1194 | $passedValue = $value; |
1145 | 1195 | |
1146 | 1196 | return false; |
@@ -1158,7 +1208,8 @@ discard block |
||
1158 | 1208 | public function testResolveSucceedsIfClosureReturnsTrue() |
1159 | 1209 | { |
1160 | 1210 | $this->resolver->setDefault('foo', 'bar'); |
1161 | - $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { |
|
1211 | + $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) |
|
1212 | + { |
|
1162 | 1213 | $passedValue = $value; |
1163 | 1214 | |
1164 | 1215 | return true; |
@@ -1175,9 +1226,15 @@ discard block |
||
1175 | 1226 | { |
1176 | 1227 | $this->resolver->setDefault('foo', 42); |
1177 | 1228 | $this->resolver->setAllowedValues('foo', [ |
1178 | - function () { return false; }, |
|
1179 | - function () { return false; }, |
|
1180 | - function () { return false; }, |
|
1229 | + function () |
|
1230 | + { |
|
1231 | +return false; }, |
|
1232 | + function () |
|
1233 | + { |
|
1234 | +return false; }, |
|
1235 | + function () |
|
1236 | + { |
|
1237 | +return false; }, |
|
1181 | 1238 | ]); |
1182 | 1239 | |
1183 | 1240 | $this->resolver->resolve(); |
@@ -1187,9 +1244,15 @@ discard block |
||
1187 | 1244 | { |
1188 | 1245 | $this->resolver->setDefault('foo', 'bar'); |
1189 | 1246 | $this->resolver->setAllowedValues('foo', [ |
1190 | - function () { return false; }, |
|
1191 | - function () { return true; }, |
|
1192 | - function () { return false; }, |
|
1247 | + function () |
|
1248 | + { |
|
1249 | +return false; }, |
|
1250 | + function () |
|
1251 | + { |
|
1252 | +return true; }, |
|
1253 | + function () |
|
1254 | + { |
|
1255 | +return false; }, |
|
1193 | 1256 | ]); |
1194 | 1257 | |
1195 | 1258 | $this->assertEquals(['foo' => 'bar'], $this->resolver->resolve()); |
@@ -1208,7 +1271,8 @@ discard block |
||
1208 | 1271 | */ |
1209 | 1272 | public function testFailIfAddAllowedValuesFromLazyOption() |
1210 | 1273 | { |
1211 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1274 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1275 | + { |
|
1212 | 1276 | $options->addAllowedValues('bar', 'baz'); |
1213 | 1277 | }); |
1214 | 1278 | |
@@ -1287,8 +1351,12 @@ discard block |
||
1287 | 1351 | public function testResolveFailsIfAllAddedClosuresReturnFalse() |
1288 | 1352 | { |
1289 | 1353 | $this->resolver->setDefault('foo', 42); |
1290 | - $this->resolver->setAllowedValues('foo', function () { return false; }); |
|
1291 | - $this->resolver->addAllowedValues('foo', function () { return false; }); |
|
1354 | + $this->resolver->setAllowedValues('foo', function () |
|
1355 | + { |
|
1356 | +return false; }); |
|
1357 | + $this->resolver->addAllowedValues('foo', function () |
|
1358 | + { |
|
1359 | +return false; }); |
|
1292 | 1360 | |
1293 | 1361 | $this->resolver->resolve(); |
1294 | 1362 | } |
@@ -1296,8 +1364,12 @@ discard block |
||
1296 | 1364 | public function testResolveSucceedsIfAnyAddedClosureReturnsTrue() |
1297 | 1365 | { |
1298 | 1366 | $this->resolver->setDefault('foo', 'bar'); |
1299 | - $this->resolver->setAllowedValues('foo', function () { return false; }); |
|
1300 | - $this->resolver->addAllowedValues('foo', function () { return true; }); |
|
1367 | + $this->resolver->setAllowedValues('foo', function () |
|
1368 | + { |
|
1369 | +return false; }); |
|
1370 | + $this->resolver->addAllowedValues('foo', function () |
|
1371 | + { |
|
1372 | +return true; }); |
|
1301 | 1373 | |
1302 | 1374 | $this->assertEquals(['foo' => 'bar'], $this->resolver->resolve()); |
1303 | 1375 | } |
@@ -1305,8 +1377,12 @@ discard block |
||
1305 | 1377 | public function testResolveSucceedsIfAnyAddedClosureReturnsTrue2() |
1306 | 1378 | { |
1307 | 1379 | $this->resolver->setDefault('foo', 'bar'); |
1308 | - $this->resolver->setAllowedValues('foo', function () { return true; }); |
|
1309 | - $this->resolver->addAllowedValues('foo', function () { return false; }); |
|
1380 | + $this->resolver->setAllowedValues('foo', function () |
|
1381 | + { |
|
1382 | +return true; }); |
|
1383 | + $this->resolver->addAllowedValues('foo', function () |
|
1384 | + { |
|
1385 | +return false; }); |
|
1310 | 1386 | |
1311 | 1387 | $this->assertEquals(['foo' => 'bar'], $this->resolver->resolve()); |
1312 | 1388 | } |
@@ -1314,13 +1390,16 @@ discard block |
||
1314 | 1390 | public function testSetNormalizerReturnsThis() |
1315 | 1391 | { |
1316 | 1392 | $this->resolver->setDefault('foo', 'bar'); |
1317 | - $this->assertSame($this->resolver, $this->resolver->setNormalizer('foo', function () {})); |
|
1393 | + $this->assertSame($this->resolver, $this->resolver->setNormalizer('foo', function () |
|
1394 | + { |
|
1395 | +})); |
|
1318 | 1396 | } |
1319 | 1397 | |
1320 | 1398 | public function testSetNormalizerClosure() |
1321 | 1399 | { |
1322 | 1400 | $this->resolver->setDefault('foo', 'bar'); |
1323 | - $this->resolver->setNormalizer('foo', function () { |
|
1401 | + $this->resolver->setNormalizer('foo', function () |
|
1402 | + { |
|
1324 | 1403 | return 'normalized'; |
1325 | 1404 | }); |
1326 | 1405 | |
@@ -1332,7 +1411,9 @@ discard block |
||
1332 | 1411 | */ |
1333 | 1412 | public function testSetNormalizerFailsIfUnknownOption() |
1334 | 1413 | { |
1335 | - $this->resolver->setNormalizer('foo', function () {}); |
|
1414 | + $this->resolver->setNormalizer('foo', function () |
|
1415 | + { |
|
1416 | +}); |
|
1336 | 1417 | } |
1337 | 1418 | |
1338 | 1419 | /** |
@@ -1340,8 +1421,11 @@ discard block |
||
1340 | 1421 | */ |
1341 | 1422 | public function testFailIfSetNormalizerFromLazyOption() |
1342 | 1423 | { |
1343 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1344 | - $options->setNormalizer('foo', function () {}); |
|
1424 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1425 | + { |
|
1426 | + $options->setNormalizer('foo', function () |
|
1427 | + { |
|
1428 | +}); |
|
1345 | 1429 | }); |
1346 | 1430 | |
1347 | 1431 | $this->resolver->setDefault('bar', 'baz'); |
@@ -1353,7 +1437,8 @@ discard block |
||
1353 | 1437 | { |
1354 | 1438 | $this->resolver->setDefault('foo', 'bar'); |
1355 | 1439 | |
1356 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1440 | + $this->resolver->setNormalizer('foo', function (Options $options, $value) |
|
1441 | + { |
|
1357 | 1442 | return 'normalized['.$value.']'; |
1358 | 1443 | }); |
1359 | 1444 | |
@@ -1364,7 +1449,8 @@ discard block |
||
1364 | 1449 | { |
1365 | 1450 | $this->resolver->setDefault('foo', 'bar'); |
1366 | 1451 | |
1367 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1452 | + $this->resolver->setNormalizer('foo', function (Options $options, $value) |
|
1453 | + { |
|
1368 | 1454 | return 'normalized['.$value.']'; |
1369 | 1455 | }); |
1370 | 1456 | |
@@ -1382,7 +1468,8 @@ discard block |
||
1382 | 1468 | |
1383 | 1469 | $this->resolver->setAllowedTypes('foo', 'int'); |
1384 | 1470 | |
1385 | - $this->resolver->setNormalizer('foo', function () { |
|
1471 | + $this->resolver->setNormalizer('foo', function () |
|
1472 | + { |
|
1386 | 1473 | Assert::fail('Should not be called.'); |
1387 | 1474 | }); |
1388 | 1475 | |
@@ -1398,7 +1485,8 @@ discard block |
||
1398 | 1485 | |
1399 | 1486 | $this->resolver->setAllowedValues('foo', 'baz'); |
1400 | 1487 | |
1401 | - $this->resolver->setNormalizer('foo', function () { |
|
1488 | + $this->resolver->setNormalizer('foo', function () |
|
1489 | + { |
|
1402 | 1490 | Assert::fail('Should not be called.'); |
1403 | 1491 | }); |
1404 | 1492 | |
@@ -1410,7 +1498,8 @@ discard block |
||
1410 | 1498 | $this->resolver->setDefault('default', 'bar'); |
1411 | 1499 | $this->resolver->setDefault('norm', 'baz'); |
1412 | 1500 | |
1413 | - $this->resolver->setNormalizer('norm', function (Options $options) { |
|
1501 | + $this->resolver->setNormalizer('norm', function (Options $options) |
|
1502 | + { |
|
1414 | 1503 | /* @var TestCase $test */ |
1415 | 1504 | Assert::assertSame('bar', $options['default']); |
1416 | 1505 | |
@@ -1425,12 +1514,14 @@ discard block |
||
1425 | 1514 | |
1426 | 1515 | public function testNormalizerCanAccessLazyOptions() |
1427 | 1516 | { |
1428 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1517 | + $this->resolver->setDefault('lazy', function (Options $options) |
|
1518 | + { |
|
1429 | 1519 | return 'bar'; |
1430 | 1520 | }); |
1431 | 1521 | $this->resolver->setDefault('norm', 'baz'); |
1432 | 1522 | |
1433 | - $this->resolver->setNormalizer('norm', function (Options $options) { |
|
1523 | + $this->resolver->setNormalizer('norm', function (Options $options) |
|
1524 | + { |
|
1434 | 1525 | /* @var TestCase $test */ |
1435 | 1526 | Assert::assertEquals('bar', $options['lazy']); |
1436 | 1527 | |
@@ -1451,11 +1542,13 @@ discard block |
||
1451 | 1542 | $this->resolver->setDefault('norm1', 'bar'); |
1452 | 1543 | $this->resolver->setDefault('norm2', 'baz'); |
1453 | 1544 | |
1454 | - $this->resolver->setNormalizer('norm1', function (Options $options) { |
|
1545 | + $this->resolver->setNormalizer('norm1', function (Options $options) |
|
1546 | + { |
|
1455 | 1547 | $options['norm2']; |
1456 | 1548 | }); |
1457 | 1549 | |
1458 | - $this->resolver->setNormalizer('norm2', function (Options $options) { |
|
1550 | + $this->resolver->setNormalizer('norm2', function (Options $options) |
|
1551 | + { |
|
1459 | 1552 | $options['norm1']; |
1460 | 1553 | }); |
1461 | 1554 | |
@@ -1467,13 +1560,15 @@ discard block |
||
1467 | 1560 | */ |
1468 | 1561 | public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption() |
1469 | 1562 | { |
1470 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1563 | + $this->resolver->setDefault('lazy', function (Options $options) |
|
1564 | + { |
|
1471 | 1565 | $options['norm']; |
1472 | 1566 | }); |
1473 | 1567 | |
1474 | 1568 | $this->resolver->setDefault('norm', 'baz'); |
1475 | 1569 | |
1476 | - $this->resolver->setNormalizer('norm', function (Options $options) { |
|
1570 | + $this->resolver->setNormalizer('norm', function (Options $options) |
|
1571 | + { |
|
1477 | 1572 | $options['lazy']; |
1478 | 1573 | }); |
1479 | 1574 | |
@@ -1486,7 +1581,8 @@ discard block |
||
1486 | 1581 | |
1487 | 1582 | $this->resolver->setDefaults(['catcher' => null, 'thrower' => null]); |
1488 | 1583 | |
1489 | - $this->resolver->setNormalizer('catcher', function (Options $options) { |
|
1584 | + $this->resolver->setNormalizer('catcher', function (Options $options) |
|
1585 | + { |
|
1490 | 1586 | try { |
1491 | 1587 | return $options['thrower']; |
1492 | 1588 | } catch (Exception $e) { |
@@ -1494,7 +1590,8 @@ discard block |
||
1494 | 1590 | } |
1495 | 1591 | }); |
1496 | 1592 | |
1497 | - $this->resolver->setNormalizer('thrower', function () use (&$throw) { |
|
1593 | + $this->resolver->setNormalizer('thrower', function () use (&$throw) |
|
1594 | + { |
|
1498 | 1595 | if ($throw) { |
1499 | 1596 | $throw = false; |
1500 | 1597 | throw new UnexpectedValueException('throwing'); |
@@ -1510,7 +1607,8 @@ discard block |
||
1510 | 1607 | { |
1511 | 1608 | $throw = true; |
1512 | 1609 | |
1513 | - $this->resolver->setDefault('catcher', function (Options $options) { |
|
1610 | + $this->resolver->setDefault('catcher', function (Options $options) |
|
1611 | + { |
|
1514 | 1612 | try { |
1515 | 1613 | return $options['thrower']; |
1516 | 1614 | } catch (Exception $e) { |
@@ -1518,7 +1616,8 @@ discard block |
||
1518 | 1616 | } |
1519 | 1617 | }); |
1520 | 1618 | |
1521 | - $this->resolver->setDefault('thrower', function (Options $options) use (&$throw) { |
|
1619 | + $this->resolver->setDefault('thrower', function (Options $options) use (&$throw) |
|
1620 | + { |
|
1522 | 1621 | if ($throw) { |
1523 | 1622 | $throw = false; |
1524 | 1623 | throw new UnexpectedValueException('throwing'); |
@@ -1537,12 +1636,14 @@ discard block |
||
1537 | 1636 | $this->resolver->setDefault('norm1', 'bar'); |
1538 | 1637 | $this->resolver->setDefault('norm2', 'baz'); |
1539 | 1638 | |
1540 | - $this->resolver->setNormalizer('norm1', function ($options) use (&$calls) { |
|
1639 | + $this->resolver->setNormalizer('norm1', function ($options) use (&$calls) |
|
1640 | + { |
|
1541 | 1641 | Assert::assertSame(1, ++$calls); |
1542 | 1642 | |
1543 | 1643 | $options['norm2']; |
1544 | 1644 | }); |
1545 | - $this->resolver->setNormalizer('norm2', function () use (&$calls) { |
|
1645 | + $this->resolver->setNormalizer('norm2', function () use (&$calls) |
|
1646 | + { |
|
1546 | 1647 | Assert::assertSame(2, ++$calls); |
1547 | 1648 | }); |
1548 | 1649 | |
@@ -1555,7 +1656,8 @@ discard block |
||
1555 | 1656 | { |
1556 | 1657 | $this->resolver->setDefined('norm'); |
1557 | 1658 | |
1558 | - $this->resolver->setNormalizer('norm', function () { |
|
1659 | + $this->resolver->setNormalizer('norm', function () |
|
1660 | + { |
|
1559 | 1661 | Assert::fail('Should not be called.'); |
1560 | 1662 | }); |
1561 | 1663 | |
@@ -1589,7 +1691,8 @@ discard block |
||
1589 | 1691 | */ |
1590 | 1692 | public function testFailIfSetDefaultsFromLazyOption() |
1591 | 1693 | { |
1592 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1694 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1695 | + { |
|
1593 | 1696 | $options->setDefaults(['two' => '2']); |
1594 | 1697 | }); |
1595 | 1698 | |
@@ -1625,7 +1728,8 @@ discard block |
||
1625 | 1728 | |
1626 | 1729 | public function testRemoveLazyOption() |
1627 | 1730 | { |
1628 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1731 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1732 | + { |
|
1629 | 1733 | return 'lazy'; |
1630 | 1734 | }); |
1631 | 1735 | $this->resolver->remove('foo'); |
@@ -1636,7 +1740,8 @@ discard block |
||
1636 | 1740 | public function testRemoveNormalizer() |
1637 | 1741 | { |
1638 | 1742 | $this->resolver->setDefault('foo', 'bar'); |
1639 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1743 | + $this->resolver->setNormalizer('foo', function (Options $options, $value) |
|
1744 | + { |
|
1640 | 1745 | return 'normalized'; |
1641 | 1746 | }); |
1642 | 1747 | $this->resolver->remove('foo'); |
@@ -1670,7 +1775,8 @@ discard block |
||
1670 | 1775 | */ |
1671 | 1776 | public function testFailIfRemoveFromLazyOption() |
1672 | 1777 | { |
1673 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1778 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1779 | + { |
|
1674 | 1780 | $options->remove('bar'); |
1675 | 1781 | }); |
1676 | 1782 | |
@@ -1701,7 +1807,8 @@ discard block |
||
1701 | 1807 | |
1702 | 1808 | public function testClearLazyOption() |
1703 | 1809 | { |
1704 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1810 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1811 | + { |
|
1705 | 1812 | return 'lazy'; |
1706 | 1813 | }); |
1707 | 1814 | $this->resolver->clear(); |
@@ -1712,7 +1819,8 @@ discard block |
||
1712 | 1819 | public function testClearNormalizer() |
1713 | 1820 | { |
1714 | 1821 | $this->resolver->setDefault('foo', 'bar'); |
1715 | - $this->resolver->setNormalizer('foo', function (Options $options, $value) { |
|
1822 | + $this->resolver->setNormalizer('foo', function (Options $options, $value) |
|
1823 | + { |
|
1716 | 1824 | return 'normalized'; |
1717 | 1825 | }); |
1718 | 1826 | $this->resolver->clear(); |
@@ -1746,7 +1854,8 @@ discard block |
||
1746 | 1854 | */ |
1747 | 1855 | public function testFailIfClearFromLazyption() |
1748 | 1856 | { |
1749 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
1857 | + $this->resolver->setDefault('foo', function (Options $options) |
|
1858 | + { |
|
1750 | 1859 | $options->clear(); |
1751 | 1860 | }); |
1752 | 1861 | |
@@ -1758,11 +1867,13 @@ discard block |
||
1758 | 1867 | public function testClearOptionAndNormalizer() |
1759 | 1868 | { |
1760 | 1869 | $this->resolver->setDefault('foo1', 'bar'); |
1761 | - $this->resolver->setNormalizer('foo1', function (Options $options) { |
|
1870 | + $this->resolver->setNormalizer('foo1', function (Options $options) |
|
1871 | + { |
|
1762 | 1872 | return ''; |
1763 | 1873 | }); |
1764 | 1874 | $this->resolver->setDefault('foo2', 'bar'); |
1765 | - $this->resolver->setNormalizer('foo2', function (Options $options) { |
|
1875 | + $this->resolver->setNormalizer('foo2', function (Options $options) |
|
1876 | + { |
|
1766 | 1877 | return ''; |
1767 | 1878 | }); |
1768 | 1879 | |
@@ -1776,11 +1887,13 @@ discard block |
||
1776 | 1887 | $this->resolver->setDefault('default2', 1); |
1777 | 1888 | $this->resolver->setRequired('required'); |
1778 | 1889 | $this->resolver->setDefined('defined'); |
1779 | - $this->resolver->setDefault('lazy1', function (Options $options) { |
|
1890 | + $this->resolver->setDefault('lazy1', function (Options $options) |
|
1891 | + { |
|
1780 | 1892 | return 'lazy'; |
1781 | 1893 | }); |
1782 | 1894 | |
1783 | - $this->resolver->setDefault('lazy2', function (Options $options) { |
|
1895 | + $this->resolver->setDefault('lazy2', function (Options $options) |
|
1896 | + { |
|
1784 | 1897 | Assert::assertArrayHasKey('default1', $options); |
1785 | 1898 | Assert::assertArrayHasKey('default2', $options); |
1786 | 1899 | Assert::assertArrayHasKey('required', $options); |
@@ -1846,7 +1959,8 @@ discard block |
||
1846 | 1959 | { |
1847 | 1960 | $this->resolver->setDefault('foo', 'bar'); |
1848 | 1961 | |
1849 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1962 | + $this->resolver->setDefault('lazy', function (Options $options) |
|
1963 | + { |
|
1850 | 1964 | $options['undefined']; |
1851 | 1965 | }); |
1852 | 1966 | |
@@ -1861,7 +1975,8 @@ discard block |
||
1861 | 1975 | { |
1862 | 1976 | $this->resolver->setDefined('defined'); |
1863 | 1977 | |
1864 | - $this->resolver->setDefault('lazy', function (Options $options) { |
|
1978 | + $this->resolver->setDefault('lazy', function (Options $options) |
|
1979 | + { |
|
1865 | 1980 | $options['defined']; |
1866 | 1981 | }); |
1867 | 1982 | |
@@ -1873,11 +1988,13 @@ discard block |
||
1873 | 1988 | */ |
1874 | 1989 | public function testFailIfCyclicDependency() |
1875 | 1990 | { |
1876 | - $this->resolver->setDefault('lazy1', function (Options $options) { |
|
1991 | + $this->resolver->setDefault('lazy1', function (Options $options) |
|
1992 | + { |
|
1877 | 1993 | $options['lazy2']; |
1878 | 1994 | }); |
1879 | 1995 | |
1880 | - $this->resolver->setDefault('lazy2', function (Options $options) { |
|
1996 | + $this->resolver->setDefault('lazy2', function (Options $options) |
|
1997 | + { |
|
1881 | 1998 | $options['lazy1']; |
1882 | 1999 | }); |
1883 | 2000 | |
@@ -1889,9 +2006,12 @@ discard block |
||
1889 | 2006 | $this->resolver->setDefault('default', 0); |
1890 | 2007 | $this->resolver->setRequired('required'); |
1891 | 2008 | $this->resolver->setDefined('defined'); |
1892 | - $this->resolver->setDefault('lazy1', function () {}); |
|
2009 | + $this->resolver->setDefault('lazy1', function () |
|
2010 | + { |
|
2011 | +}); |
|
1893 | 2012 | |
1894 | - $this->resolver->setDefault('lazy2', function (Options $options) { |
|
2013 | + $this->resolver->setDefault('lazy2', function (Options $options) |
|
2014 | + { |
|
1895 | 2015 | Assert::assertCount(4, $options); |
1896 | 2016 | }); |
1897 | 2017 | |
@@ -1910,7 +2030,9 @@ discard block |
||
1910 | 2030 | $this->resolver->setDefault('foo', 0); |
1911 | 2031 | $this->resolver->setRequired('bar'); |
1912 | 2032 | $this->resolver->setDefined('bar'); |
1913 | - $this->resolver->setDefault('lazy1', function () {}); |
|
2033 | + $this->resolver->setDefault('lazy1', function () |
|
2034 | + { |
|
2035 | +}); |
|
1914 | 2036 | |
1915 | 2037 | count($this->resolver); |
1916 | 2038 | } |
@@ -2065,7 +2187,8 @@ discard block |
||
2065 | 2187 | public function testIsNestedOption() |
2066 | 2188 | { |
2067 | 2189 | $this->resolver->setDefaults([ |
2068 | - 'database' => function (OptionsResolver $resolver) { |
|
2190 | + 'database' => function (OptionsResolver $resolver) |
|
2191 | + { |
|
2069 | 2192 | $resolver->setDefined(['host', 'port']); |
2070 | 2193 | }, |
2071 | 2194 | ]); |
@@ -2080,7 +2203,8 @@ discard block |
||
2080 | 2203 | { |
2081 | 2204 | $this->resolver->setDefaults([ |
2082 | 2205 | 'name' => 'default', |
2083 | - 'database' => function (OptionsResolver $resolver) { |
|
2206 | + 'database' => function (OptionsResolver $resolver) |
|
2207 | + { |
|
2084 | 2208 | $resolver->setDefined(['host', 'port']); |
2085 | 2209 | }, |
2086 | 2210 | ]); |
@@ -2097,7 +2221,8 @@ discard block |
||
2097 | 2221 | { |
2098 | 2222 | $this->resolver->setDefaults([ |
2099 | 2223 | 'name' => 'default', |
2100 | - 'database' => function (OptionsResolver $resolver) { |
|
2224 | + 'database' => function (OptionsResolver $resolver) |
|
2225 | + { |
|
2101 | 2226 | $resolver->setRequired('host'); |
2102 | 2227 | }, |
2103 | 2228 | ]); |
@@ -2114,7 +2239,8 @@ discard block |
||
2114 | 2239 | { |
2115 | 2240 | $this->resolver->setDefaults([ |
2116 | 2241 | 'name' => 'default', |
2117 | - 'database' => function (OptionsResolver $resolver) { |
|
2242 | + 'database' => function (OptionsResolver $resolver) |
|
2243 | + { |
|
2118 | 2244 | $resolver |
2119 | 2245 | ->setDefined('logging') |
2120 | 2246 | ->setAllowedTypes('logging', 'bool'); |
@@ -2133,7 +2259,8 @@ discard block |
||
2133 | 2259 | { |
2134 | 2260 | $this->resolver->setDefaults([ |
2135 | 2261 | 'name' => 'default', |
2136 | - 'database' => function (OptionsResolver $resolver) { |
|
2262 | + 'database' => function (OptionsResolver $resolver) |
|
2263 | + { |
|
2137 | 2264 | $resolver->setDefined('host'); |
2138 | 2265 | }, |
2139 | 2266 | ]); |
@@ -2146,7 +2273,8 @@ discard block |
||
2146 | 2273 | { |
2147 | 2274 | $this->resolver->setDefaults([ |
2148 | 2275 | 'name' => 'default', |
2149 | - 'database' => function (OptionsResolver $resolver) { |
|
2276 | + 'database' => function (OptionsResolver $resolver) |
|
2277 | + { |
|
2150 | 2278 | $resolver->setDefined(['host', 'port']); |
2151 | 2279 | }, |
2152 | 2280 | ]); |
@@ -2162,7 +2290,8 @@ discard block |
||
2162 | 2290 | { |
2163 | 2291 | $this->resolver->setDefaults([ |
2164 | 2292 | 'name' => 'default', |
2165 | - 'database' => function (OptionsResolver $resolver) { |
|
2293 | + 'database' => function (OptionsResolver $resolver) |
|
2294 | + { |
|
2166 | 2295 | $resolver->setDefaults([ |
2167 | 2296 | 'host' => 'localhost', |
2168 | 2297 | 'port' => 3306, |
@@ -2184,12 +2313,14 @@ discard block |
||
2184 | 2313 | { |
2185 | 2314 | $this->resolver->setDefaults([ |
2186 | 2315 | 'name' => 'default', |
2187 | - 'database' => function (OptionsResolver $resolver) { |
|
2316 | + 'database' => function (OptionsResolver $resolver) |
|
2317 | + { |
|
2188 | 2318 | $resolver |
2189 | 2319 | ->setRequired(['dbname', 'host']) |
2190 | 2320 | ->setDefaults([ |
2191 | 2321 | 'port' => 3306, |
2192 | - 'replicas' => function (OptionsResolver $resolver) { |
|
2322 | + 'replicas' => function (OptionsResolver $resolver) |
|
2323 | + { |
|
2193 | 2324 | $resolver->setDefaults([ |
2194 | 2325 | 'host' => 'replica1', |
2195 | 2326 | 'port' => 3306, |
@@ -2222,10 +2353,12 @@ discard block |
||
2222 | 2353 | public function testResolveLazyOptionUsingNestedOption() |
2223 | 2354 | { |
2224 | 2355 | $this->resolver->setDefaults([ |
2225 | - 'version' => function (Options $options) { |
|
2356 | + 'version' => function (Options $options) |
|
2357 | + { |
|
2226 | 2358 | return $options['database']['server_version']; |
2227 | 2359 | }, |
2228 | - 'database' => function (OptionsResolver $resolver) { |
|
2360 | + 'database' => function (OptionsResolver $resolver) |
|
2361 | + { |
|
2229 | 2362 | $resolver->setDefault('server_version', '3.15'); |
2230 | 2363 | }, |
2231 | 2364 | ]); |
@@ -2241,7 +2374,8 @@ discard block |
||
2241 | 2374 | { |
2242 | 2375 | $this->resolver |
2243 | 2376 | ->setDefaults([ |
2244 | - 'database' => function (OptionsResolver $resolver) { |
|
2377 | + 'database' => function (OptionsResolver $resolver) |
|
2378 | + { |
|
2245 | 2379 | $resolver->setDefaults([ |
2246 | 2380 | 'port' => 3306, |
2247 | 2381 | 'host' => 'localhost', |
@@ -2249,7 +2383,8 @@ discard block |
||
2249 | 2383 | ]); |
2250 | 2384 | }, |
2251 | 2385 | ]) |
2252 | - ->setNormalizer('database', function (Options $options, $value) { |
|
2386 | + ->setNormalizer('database', function (Options $options, $value) |
|
2387 | + { |
|
2253 | 2388 | ksort($value); |
2254 | 2389 | |
2255 | 2390 | return $value; |
@@ -2266,11 +2401,13 @@ discard block |
||
2266 | 2401 | public function testOverwrittenNestedOptionNotEvaluatedIfLazyDefault() |
2267 | 2402 | { |
2268 | 2403 | // defined by superclass |
2269 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2404 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2405 | + { |
|
2270 | 2406 | Assert::fail('Should not be called'); |
2271 | 2407 | }); |
2272 | 2408 | // defined by subclass |
2273 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
2409 | + $this->resolver->setDefault('foo', function (Options $options) |
|
2410 | + { |
|
2274 | 2411 | return 'lazy'; |
2275 | 2412 | }); |
2276 | 2413 | $this->assertSame(['foo' => 'lazy'], $this->resolver->resolve()); |
@@ -2279,7 +2416,8 @@ discard block |
||
2279 | 2416 | public function testOverwrittenNestedOptionNotEvaluatedIfScalarDefault() |
2280 | 2417 | { |
2281 | 2418 | // defined by superclass |
2282 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2419 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2420 | + { |
|
2283 | 2421 | Assert::fail('Should not be called'); |
2284 | 2422 | }); |
2285 | 2423 | // defined by subclass |
@@ -2290,11 +2428,13 @@ discard block |
||
2290 | 2428 | public function testOverwrittenLazyOptionNotEvaluatedIfNestedOption() |
2291 | 2429 | { |
2292 | 2430 | // defined by superclass |
2293 | - $this->resolver->setDefault('foo', function (Options $options) { |
|
2431 | + $this->resolver->setDefault('foo', function (Options $options) |
|
2432 | + { |
|
2294 | 2433 | Assert::fail('Should not be called'); |
2295 | 2434 | }); |
2296 | 2435 | // defined by subclass |
2297 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2436 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2437 | + { |
|
2298 | 2438 | $resolver->setDefault('bar', 'baz'); |
2299 | 2439 | }); |
2300 | 2440 | $this->assertSame(['foo' => ['bar' => 'baz']], $this->resolver->resolve()); |
@@ -2303,15 +2443,18 @@ discard block |
||
2303 | 2443 | public function testResolveAllNestedOptionDefinitions() |
2304 | 2444 | { |
2305 | 2445 | // defined by superclass |
2306 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2446 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2447 | + { |
|
2307 | 2448 | $resolver->setRequired('bar'); |
2308 | 2449 | }); |
2309 | 2450 | // defined by subclass |
2310 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2451 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2452 | + { |
|
2311 | 2453 | $resolver->setDefault('bar', 'baz'); |
2312 | 2454 | }); |
2313 | 2455 | // defined by subclass |
2314 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2456 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2457 | + { |
|
2315 | 2458 | $resolver->setDefault('ping', 'pong'); |
2316 | 2459 | }); |
2317 | 2460 | $this->assertSame(['foo' => ['ping' => 'pong', 'bar' => 'baz']], $this->resolver->resolve()); |
@@ -2320,11 +2463,13 @@ discard block |
||
2320 | 2463 | public function testNormalizeNestedValue() |
2321 | 2464 | { |
2322 | 2465 | // defined by superclass |
2323 | - $this->resolver->setDefault('foo', function (OptionsResolver $resolver) { |
|
2466 | + $this->resolver->setDefault('foo', function (OptionsResolver $resolver) |
|
2467 | + { |
|
2324 | 2468 | $resolver->setDefault('bar', null); |
2325 | 2469 | }); |
2326 | 2470 | // defined by subclass |
2327 | - $this->resolver->setNormalizer('foo', function (Options $options, $resolvedValue) { |
|
2471 | + $this->resolver->setNormalizer('foo', function (Options $options, $resolvedValue) |
|
2472 | + { |
|
2328 | 2473 | if (null === $resolvedValue['bar']) { |
2329 | 2474 | $resolvedValue['bar'] = 'baz'; |
2330 | 2475 | } |
@@ -2339,7 +2484,8 @@ discard block |
||
2339 | 2484 | */ |
2340 | 2485 | public function testFailsIfCyclicDependencyBetweenSameNestedOption() |
2341 | 2486 | { |
2342 | - $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { |
|
2487 | + $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) |
|
2488 | + { |
|
2343 | 2489 | $resolver->setDefault('replicas', $parent['database']); |
2344 | 2490 | }); |
2345 | 2491 | $this->resolver->resolve(); |
@@ -2351,10 +2497,12 @@ discard block |
||
2351 | 2497 | public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption() |
2352 | 2498 | { |
2353 | 2499 | $this->resolver->setDefaults([ |
2354 | - 'version' => function (Options $options) { |
|
2500 | + 'version' => function (Options $options) |
|
2501 | + { |
|
2355 | 2502 | return $options['database']['server_version']; |
2356 | 2503 | }, |
2357 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2504 | + 'database' => function (OptionsResolver $resolver, Options $parent) |
|
2505 | + { |
|
2358 | 2506 | $resolver->setDefault('server_version', $parent['version']); |
2359 | 2507 | }, |
2360 | 2508 | ]); |
@@ -2368,10 +2516,12 @@ discard block |
||
2368 | 2516 | { |
2369 | 2517 | $this->resolver |
2370 | 2518 | ->setDefault('name', 'default') |
2371 | - ->setDefault('database', function (OptionsResolver $resolver, Options $parent) { |
|
2519 | + ->setDefault('database', function (OptionsResolver $resolver, Options $parent) |
|
2520 | + { |
|
2372 | 2521 | $resolver->setDefault('host', $parent['name']); |
2373 | 2522 | }) |
2374 | - ->setNormalizer('name', function (Options $options, $value) { |
|
2523 | + ->setNormalizer('name', function (Options $options, $value) |
|
2524 | + { |
|
2375 | 2525 | $options['database']; |
2376 | 2526 | }); |
2377 | 2527 | $this->resolver->resolve(); |
@@ -2382,10 +2532,12 @@ discard block |
||
2382 | 2532 | */ |
2383 | 2533 | public function testFailsIfCyclicDependencyBetweenNestedOptions() |
2384 | 2534 | { |
2385 | - $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { |
|
2535 | + $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) |
|
2536 | + { |
|
2386 | 2537 | $resolver->setDefault('host', $parent['replica']['host']); |
2387 | 2538 | }); |
2388 | - $this->resolver->setDefault('replica', function (OptionsResolver $resolver, Options $parent) { |
|
2539 | + $this->resolver->setDefault('replica', function (OptionsResolver $resolver, Options $parent) |
|
2540 | + { |
|
2389 | 2541 | $resolver->setDefault('host', $parent['database']['host']); |
2390 | 2542 | }); |
2391 | 2543 | $this->resolver->resolve(); |
@@ -2395,7 +2547,8 @@ discard block |
||
2395 | 2547 | { |
2396 | 2548 | $this->resolver->setDefaults([ |
2397 | 2549 | 'version' => 3.15, |
2398 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2550 | + 'database' => function (OptionsResolver $resolver, Options $parent) |
|
2551 | + { |
|
2399 | 2552 | $resolver->setDefault('server_version', $parent['version']); |
2400 | 2553 | }, |
2401 | 2554 | ]); |
@@ -2404,7 +2557,8 @@ discard block |
||
2404 | 2557 | |
2405 | 2558 | public function testNestedClosureWithoutTypeHintNotInvoked() |
2406 | 2559 | { |
2407 | - $closure = function ($resolver) { |
|
2560 | + $closure = function ($resolver) |
|
2561 | + { |
|
2408 | 2562 | Assert::fail('Should not be called'); |
2409 | 2563 | }; |
2410 | 2564 | $this->resolver->setDefault('foo', $closure); |
@@ -2413,7 +2567,8 @@ discard block |
||
2413 | 2567 | |
2414 | 2568 | public function testNestedClosureWithoutTypeHint2ndArgumentNotInvoked() |
2415 | 2569 | { |
2416 | - $closure = function (OptionsResolver $resolver, $parent) { |
|
2570 | + $closure = function (OptionsResolver $resolver, $parent) |
|
2571 | + { |
|
2417 | 2572 | Assert::fail('Should not be called'); |
2418 | 2573 | }; |
2419 | 2574 | $this->resolver->setDefault('foo', $closure); |
@@ -2424,13 +2579,16 @@ discard block |
||
2424 | 2579 | { |
2425 | 2580 | $this->resolver->setDefaults([ |
2426 | 2581 | 'ip' => null, |
2427 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2582 | + 'database' => function (OptionsResolver $resolver, Options $parent) |
|
2583 | + { |
|
2428 | 2584 | $resolver->setDefault('host', $parent['ip']); |
2429 | - $resolver->setDefault('primary_replica', function (OptionsResolver $resolver, Options $parent) { |
|
2585 | + $resolver->setDefault('primary_replica', function (OptionsResolver $resolver, Options $parent) |
|
2586 | + { |
|
2430 | 2587 | $resolver->setDefault('host', $parent['host']); |
2431 | 2588 | }); |
2432 | 2589 | }, |
2433 | - 'secondary_replica' => function (Options $options) { |
|
2590 | + 'secondary_replica' => function (Options $options) |
|
2591 | + { |
|
2434 | 2592 | return $options['database']['primary_replica']['host']; |
2435 | 2593 | }, |
2436 | 2594 | ]); |
@@ -2450,13 +2608,16 @@ discard block |
||
2450 | 2608 | { |
2451 | 2609 | $this->resolver->setDefaults([ |
2452 | 2610 | 'debug' => true, |
2453 | - 'database' => function (OptionsResolver $resolver, Options $parent) { |
|
2611 | + 'database' => function (OptionsResolver $resolver, Options $parent) |
|
2612 | + { |
|
2454 | 2613 | $resolver |
2455 | 2614 | ->setDefined('logging') |
2456 | - ->setDefault('profiling', function (Options $options) use ($parent) { |
|
2615 | + ->setDefault('profiling', function (Options $options) use ($parent) |
|
2616 | + { |
|
2457 | 2617 | return $parent['debug']; |
2458 | 2618 | }) |
2459 | - ->setNormalizer('logging', function (Options $options, $value) use ($parent) { |
|
2619 | + ->setNormalizer('logging', function (Options $options, $value) use ($parent) |
|
2620 | + { |
|
2460 | 2621 | return false === $parent['debug'] ? true : $value; |
2461 | 2622 | }); |
2462 | 2623 | }, |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | // autoload.php @generated by Composer |
4 | 4 | |
5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
6 | 6 | |
7 | 7 | return ComposerAutoloaderInit5db96ad6a0e1ea778f383ecdf444d8ac::getLoader(); |
@@ -43,12 +43,12 @@ |
||
43 | 43 | |
44 | 44 | public function getFullVersion(): string |
45 | 45 | { |
46 | - return $this->getShortVersion() . '@' . $this->getCommitHash(); |
|
46 | + return $this->getShortVersion().'@'.$this->getCommitHash(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function getVersionWithShortCommit(): string |
50 | 50 | { |
51 | - return $this->getShortVersion() . '@' . $this->getShortCommitHash(); |
|
51 | + return $this->getShortVersion().'@'.$this->getShortCommitHash(); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function getPackageName(): string |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | public static function loadClassLoader($class) |
13 | 13 | { |
14 | 14 | if ('Composer\Autoload\ClassLoader' === $class) { |
15 | - require __DIR__ . '/ClassLoader.php'; |
|
15 | + require __DIR__.'/ClassLoader.php'; |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | |
29 | 29 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
30 | 30 | if ($useStaticLoader) { |
31 | - require_once __DIR__ . '/autoload_static.php'; |
|
31 | + require_once __DIR__.'/autoload_static.php'; |
|
32 | 32 | |
33 | 33 | call_user_func(ComposerStaticInit5db96ad6a0e1ea778f383ecdf444d8ac::getInitializer($loader)); |
34 | 34 | } else { |
35 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
35 | + $map = require __DIR__.'/autoload_namespaces.php'; |
|
36 | 36 | foreach ($map as $namespace => $path) { |
37 | 37 | $loader->set($namespace, $path); |
38 | 38 | } |
39 | 39 | |
40 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
40 | + $map = require __DIR__.'/autoload_psr4.php'; |
|
41 | 41 | foreach ($map as $namespace => $path) { |
42 | 42 | $loader->setPsr4($namespace, $path); |
43 | 43 | } |
44 | 44 | |
45 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
45 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
46 | 46 | if ($classMap) { |
47 | 47 | $loader->addClassMap($classMap); |
48 | 48 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if ($useStaticLoader) { |
54 | 54 | $includeFiles = Composer\Autoload\ComposerStaticInit5db96ad6a0e1ea778f383ecdf444d8ac::$files; |
55 | 55 | } else { |
56 | - $includeFiles = require __DIR__ . '/autoload_files.php'; |
|
56 | + $includeFiles = require __DIR__.'/autoload_files.php'; |
|
57 | 57 | } |
58 | 58 | foreach ($includeFiles as $fileIdentifier => $file) { |
59 | 59 | composerRequire5db96ad6a0e1ea778f383ecdf444d8ac($fileIdentifier, $file); |
@@ -6,21 +6,21 @@ |
||
6 | 6 | $baseDir = dirname($vendorDir); |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Zend\\Diactoros\\' => array($vendorDir . '/zendframework/zend-diactoros/src'), |
|
10 | - 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), |
|
11 | - 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'), |
|
12 | - 'Sentry\\' => array($vendorDir . '/sentry/sentry/src'), |
|
13 | - 'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'), |
|
14 | - 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'), |
|
15 | - 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), |
|
16 | - 'PackageVersions\\' => array($vendorDir . '/ocramius/package-versions/src/PackageVersions'), |
|
17 | - 'Jean85\\' => array($vendorDir . '/jean85/pretty-package-versions/src'), |
|
18 | - 'Http\\Promise\\' => array($vendorDir . '/php-http/promise/src'), |
|
19 | - 'Http\\Message\\' => array($vendorDir . '/php-http/message-factory/src', $vendorDir . '/php-http/message/src'), |
|
20 | - 'Http\\Discovery\\' => array($vendorDir . '/php-http/discovery/src'), |
|
21 | - 'Http\\Client\\Curl\\' => array($vendorDir . '/php-http/curl-client/src'), |
|
22 | - 'Http\\Client\\Common\\' => array($vendorDir . '/php-http/client-common/src'), |
|
23 | - 'Http\\Client\\' => array($vendorDir . '/php-http/httplug/src'), |
|
24 | - 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), |
|
25 | - 'Clue\\StreamFilter\\' => array($vendorDir . '/clue/stream-filter/src'), |
|
9 | + 'Zend\\Diactoros\\' => array($vendorDir.'/zendframework/zend-diactoros/src'), |
|
10 | + 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir.'/symfony/polyfill-ctype'), |
|
11 | + 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir.'/symfony/options-resolver'), |
|
12 | + 'Sentry\\' => array($vendorDir.'/sentry/sentry/src'), |
|
13 | + 'Ramsey\\Uuid\\' => array($vendorDir.'/ramsey/uuid/src'), |
|
14 | + 'Psr\\Http\\Message\\' => array($vendorDir.'/psr/http-message/src', $vendorDir.'/psr/http-factory/src'), |
|
15 | + 'Psr\\Http\\Client\\' => array($vendorDir.'/psr/http-client/src'), |
|
16 | + 'PackageVersions\\' => array($vendorDir.'/ocramius/package-versions/src/PackageVersions'), |
|
17 | + 'Jean85\\' => array($vendorDir.'/jean85/pretty-package-versions/src'), |
|
18 | + 'Http\\Promise\\' => array($vendorDir.'/php-http/promise/src'), |
|
19 | + 'Http\\Message\\' => array($vendorDir.'/php-http/message-factory/src', $vendorDir.'/php-http/message/src'), |
|
20 | + 'Http\\Discovery\\' => array($vendorDir.'/php-http/discovery/src'), |
|
21 | + 'Http\\Client\\Curl\\' => array($vendorDir.'/php-http/curl-client/src'), |
|
22 | + 'Http\\Client\\Common\\' => array($vendorDir.'/php-http/client-common/src'), |
|
23 | + 'Http\\Client\\' => array($vendorDir.'/php-http/httplug/src'), |
|
24 | + 'GuzzleHttp\\Psr7\\' => array($vendorDir.'/guzzlehttp/psr7/src'), |
|
25 | + 'Clue\\StreamFilter\\' => array($vendorDir.'/clue/stream-filter/src'), |
|
26 | 26 | ); |