Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e577b9

Browse filesBrowse files
committed
Merge branch '4.4' into 5.1
* 4.4: [Messenger] StopWorkersCommand improve doc helper Added compatibility with PHPunit 9.5 do not apply the Valid constraint on scalar form data [Test] Reproduce issue with cascading validation [SecurityBundle] Don't use the container as resource type in fixtures. Fix bug with whitespace in Kernel::stripComments()
2 parents 2cf0686 + 21ef411 commit 7e577b9
Copy full SHA for 7e577b9

File tree

Expand file treeCollapse file tree

10 files changed

+143
-23
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+143
-23
lines changed

‎phpunit

Copy file name to clipboardExpand all lines: phpunit
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
1313
} elseif (\PHP_VERSION_ID < 70300) {
1414
putenv('SYMFONY_PHPUNIT_VERSION=8.5');
1515
} else {
16-
putenv('SYMFONY_PHPUNIT_VERSION=9.4');
16+
putenv('SYMFONY_PHPUNIT_VERSION=9.5');
1717
}
1818
}
1919
if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {

‎src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function startTest($test)
4242
return;
4343
}
4444

45-
$annotations = $test->getAnnotations();
45+
$annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
4646

4747
$ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing'];
4848

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/argon2i_encoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/argon2i_encoder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$this->load('container1.php', $container);
3+
$this->load('container1.php');
44

55
$container->loadFromExtension('security', [
66
'encoders' => [

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/bcrypt_encoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/bcrypt_encoder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$this->load('container1.php', $container);
3+
$this->load('container1.php');
44

55
$container->loadFromExtension('security', [
66
'encoders' => [

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/migrating_encoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/migrating_encoder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$this->load('container1.php', $container);
3+
$this->load('container1.php');
44

55
$container->loadFromExtension('security', [
66
'encoders' => [

‎src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ public function validate($form, Constraint $formConstraint)
110110
foreach ($constraints as $constraint) {
111111
// For the "Valid" constraint, validate the data in all groups
112112
if ($constraint instanceof Valid) {
113-
$validator->atPath('data')->validate($data, $constraint, $groups);
113+
if (\is_object($data)) {
114+
$validator->atPath('data')->validate($data, $constraint, $groups);
115+
}
114116

115117
continue;
116118
}

‎src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorFunctionalTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorFunctionalTest.php
+94Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Form\Exception\TransformationFailedException;
1818
use Symfony\Component\Form\Extension\Core\Type\DateType;
1919
use Symfony\Component\Form\Extension\Core\Type\FormType;
20+
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
2021
use Symfony\Component\Form\Extension\Core\Type\TextType;
2122
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
2223
use Symfony\Component\Form\FormBuilderInterface;
@@ -27,6 +28,7 @@
2728
use Symfony\Component\Validator\Constraints\GroupSequence;
2829
use Symfony\Component\Validator\Constraints\Length;
2930
use Symfony\Component\Validator\Constraints\NotBlank;
31+
use Symfony\Component\Validator\Constraints\Valid;
3032
use Symfony\Component\Validator\Mapping\ClassMetadata;
3133
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
3234
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
@@ -290,6 +292,39 @@ public function testCascadeValidationToChildFormsUsingPropertyPaths()
290292
$this->assertSame('children[field2].data', $violations[1]->getPropertyPath());
291293
}
292294

295+
public function testCascadeValidationToChildFormsWithTwoValidConstraints()
296+
{
297+
$form = $this->formFactory->create(ReviewType::class);
298+
299+
$form->submit([
300+
'rating' => 1,
301+
'title' => 'Sample Title',
302+
]);
303+
304+
$violations = $this->validator->validate($form);
305+
306+
$this->assertCount(1, $violations);
307+
$this->assertSame('This value should not be blank.', $violations[0]->getMessage());
308+
$this->assertSame('children[author].data.email', $violations[0]->getPropertyPath());
309+
}
310+
311+
public function testCascadeValidationToChildFormsWithTwoValidConstraints2()
312+
{
313+
$form = $this->formFactory->create(ReviewType::class);
314+
315+
$form->submit([
316+
'title' => 'Sample Title',
317+
]);
318+
319+
$violations = $this->validator->validate($form);
320+
321+
$this->assertCount(2, $violations);
322+
$this->assertSame('This value should not be blank.', $violations[0]->getMessage());
323+
$this->assertSame('data.rating', $violations[0]->getPropertyPath());
324+
$this->assertSame('This value should not be blank.', $violations[1]->getMessage());
325+
$this->assertSame('children[author].data.email', $violations[1]->getPropertyPath());
326+
}
327+
293328
public function testCascadeValidationToChildFormsUsingPropertyPathsValidatedInSequence()
294329
{
295330
$form = $this->formFactory->create(FormType::class, null, [
@@ -448,3 +483,62 @@ public function configureOptions(OptionsResolver $resolver)
448483
$resolver->setDefault('data_class', Foo::class);
449484
}
450485
}
486+
487+
class Review
488+
{
489+
public $rating;
490+
public $title;
491+
public $author;
492+
493+
public static function loadValidatorMetadata(ClassMetadata $metadata)
494+
{
495+
$metadata->addPropertyConstraint('title', new NotBlank());
496+
$metadata->addPropertyConstraint('rating', new NotBlank());
497+
}
498+
}
499+
500+
class ReviewType extends AbstractType
501+
{
502+
public function buildForm(FormBuilderInterface $builder, array $options)
503+
{
504+
$builder
505+
->add('rating', IntegerType::class, [
506+
'constraints' => [new Valid()],
507+
])
508+
->add('title')
509+
->add('author', CustomerType::class, [
510+
'constraints' => [new Valid()],
511+
])
512+
;
513+
}
514+
515+
public function configureOptions(OptionsResolver $resolver)
516+
{
517+
$resolver->setDefault('data_class', Review::class);
518+
}
519+
}
520+
521+
class Customer
522+
{
523+
public $email;
524+
525+
public static function loadValidatorMetadata(ClassMetadata $metadata)
526+
{
527+
$metadata->addPropertyConstraint('email', new NotBlank());
528+
}
529+
}
530+
531+
class CustomerType extends AbstractType
532+
{
533+
public function buildForm(FormBuilderInterface $builder, array $options)
534+
{
535+
$builder
536+
->add('email')
537+
;
538+
}
539+
540+
public function configureOptions(OptionsResolver $resolver)
541+
{
542+
$resolver->setDefault('data_class', Customer::class);
543+
}
544+
}

‎src/Symfony/Component/HttpKernel/Kernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,18 @@ public static function stripComments(string $source)
791791
// replace multiple new lines with a single newline
792792
$rawChunk .= preg_replace(['/\n{2,}/S'], "\n", $token[1]);
793793
} elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) {
794+
if (!\in_array($rawChunk[\strlen($rawChunk) - 1], [' ', "\n", "\r", "\t"], true)) {
795+
$rawChunk .= ' ';
796+
}
794797
$ignoreSpace = true;
795798
} else {
796799
$rawChunk .= $token[1];
797800

798801
// The PHP-open tag already has a new-line
799802
if (\T_OPEN_TAG === $token[0]) {
800803
$ignoreSpace = true;
804+
} else {
805+
$ignoreSpace = false;
801806
}
802807
}
803808
}

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+35-16Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,37 @@ public function testHandleBootsTheKernel()
227227
$kernel->handle($request, $type, $catch);
228228
}
229229

230-
public function testStripComments()
230+
/**
231+
* @dataProvider getStripCommentsCodes
232+
*/
233+
public function testStripComments(string $source, string $expected)
234+
{
235+
$output = Kernel::stripComments($source);
236+
237+
// Heredocs are preserved, making the output mixing Unix and Windows line
238+
// endings, switching to "\n" everywhere on Windows to avoid failure.
239+
if ('\\' === \DIRECTORY_SEPARATOR) {
240+
$expected = str_replace("\r\n", "\n", $expected);
241+
$output = str_replace("\r\n", "\n", $output);
242+
}
243+
244+
$this->assertEquals($expected, $output);
245+
}
246+
247+
public function getStripCommentsCodes(): array
231248
{
232-
$source = <<<'EOF'
249+
return [
250+
['<?php echo foo();', '<?php echo foo();'],
251+
['<?php echo/**/foo();', '<?php echo foo();'],
252+
['<?php echo/** bar */foo();', '<?php echo foo();'],
253+
['<?php /**/echo foo();', '<?php echo foo();'],
254+
['<?php echo \foo();', '<?php echo \foo();'],
255+
['<?php echo/**/\foo();', '<?php echo \foo();'],
256+
['<?php echo/** bar */\foo();', '<?php echo \foo();'],
257+
['<?php /**/echo \foo();', '<?php echo \foo();'],
258+
[<<<'EOF'
233259
<?php
260+
include_once \dirname(__DIR__).'/foo.php';
234261
235262
$string = 'string should not be modified';
236263
@@ -268,9 +295,10 @@ public function doStuff()
268295
// inline comment
269296
}
270297
}
271-
EOF;
272-
$expected = <<<'EOF'
298+
EOF
299+
, <<<'EOF'
273300
<?php
301+
include_once \dirname(__DIR__).'/foo.php';
274302
$string = 'string should not be modified';
275303
$string = 'string should not be
276304
@@ -295,18 +323,9 @@ public function doStuff()
295323
{
296324
}
297325
}
298-
EOF;
299-
300-
$output = Kernel::stripComments($source);
301-
302-
// Heredocs are preserved, making the output mixing Unix and Windows line
303-
// endings, switching to "\n" everywhere on Windows to avoid failure.
304-
if ('\\' === \DIRECTORY_SEPARATOR) {
305-
$expected = str_replace("\r\n", "\n", $expected);
306-
$output = str_replace("\r\n", "\n", $output);
307-
}
308-
309-
$this->assertEquals($expected, $output);
326+
EOF
327+
],
328+
];
310329
}
311330

312331
public function testSerialize()

‎src/Symfony/Component/Messenger/Command/StopWorkersCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Command/StopWorkersCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function configure(): void
5050
5151
Each worker command will finish the message they are currently processing
5252
and then exit. Worker commands are *not* automatically restarted: that
53-
should be handled by something like supervisord.
53+
should be handled by a process control system.
5454
EOF
5555
)
5656
;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.