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 2f607de

Browse filesBrowse files
committed
Merge branch '5.1' into 5.2
* 5.1: [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 72abcc3 + 7e577b9 commit 2f607de
Copy full SHA for 2f607de

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;
@@ -286,6 +288,39 @@ public function testCascadeValidationToChildFormsUsingPropertyPaths()
286288
$this->assertSame('children[field2].data', $violations[1]->getPropertyPath());
287289
}
288290

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

‎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
@@ -831,13 +831,18 @@ public static function stripComments(string $source)
831831
// replace multiple new lines with a single newline
832832
$rawChunk .= preg_replace(['/\n{2,}/S'], "\n", $token[1]);
833833
} elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) {
834+
if (!\in_array($rawChunk[\strlen($rawChunk) - 1], [' ', "\n", "\r", "\t"], true)) {
835+
$rawChunk .= ' ';
836+
}
834837
$ignoreSpace = true;
835838
} else {
836839
$rawChunk .= $token[1];
837840

838841
// The PHP-open tag already has a new-line
839842
if (\T_OPEN_TAG === $token[0]) {
840843
$ignoreSpace = true;
844+
} else {
845+
$ignoreSpace = false;
841846
}
842847
}
843848
}

‎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
@@ -226,10 +226,37 @@ public function testHandleBootsTheKernel()
226226
$kernel->handle($request, $type, $catch);
227227
}
228228

229-
public function testStripComments()
229+
/**
230+
* @dataProvider getStripCommentsCodes
231+
*/
232+
public function testStripComments(string $source, string $expected)
233+
{
234+
$output = Kernel::stripComments($source);
235+
236+
// Heredocs are preserved, making the output mixing Unix and Windows line
237+
// endings, switching to "\n" everywhere on Windows to avoid failure.
238+
if ('\\' === \DIRECTORY_SEPARATOR) {
239+
$expected = str_replace("\r\n", "\n", $expected);
240+
$output = str_replace("\r\n", "\n", $output);
241+
}
242+
243+
$this->assertEquals($expected, $output);
244+
}
245+
246+
public function getStripCommentsCodes(): array
230247
{
231-
$source = <<<'EOF'
248+
return [
249+
['<?php echo foo();', '<?php echo foo();'],
250+
['<?php echo/**/foo();', '<?php echo foo();'],
251+
['<?php echo/** bar */foo();', '<?php echo foo();'],
252+
['<?php /**/echo foo();', '<?php echo foo();'],
253+
['<?php echo \foo();', '<?php echo \foo();'],
254+
['<?php echo/**/\foo();', '<?php echo \foo();'],
255+
['<?php echo/** bar */\foo();', '<?php echo \foo();'],
256+
['<?php /**/echo \foo();', '<?php echo \foo();'],
257+
[<<<'EOF'
232258
<?php
259+
include_once \dirname(__DIR__).'/foo.php';
233260
234261
$string = 'string should not be modified';
235262
@@ -267,9 +294,10 @@ public function doStuff()
267294
// inline comment
268295
}
269296
}
270-
EOF;
271-
$expected = <<<'EOF'
297+
EOF
298+
, <<<'EOF'
272299
<?php
300+
include_once \dirname(__DIR__).'/foo.php';
273301
$string = 'string should not be modified';
274302
$string = 'string should not be
275303
@@ -294,18 +322,9 @@ public function doStuff()
294322
{
295323
}
296324
}
297-
EOF;
298-
299-
$output = Kernel::stripComments($source);
300-
301-
// Heredocs are preserved, making the output mixing Unix and Windows line
302-
// endings, switching to "\n" everywhere on Windows to avoid failure.
303-
if ('\\' === \DIRECTORY_SEPARATOR) {
304-
$expected = str_replace("\r\n", "\n", $expected);
305-
$output = str_replace("\r\n", "\n", $output);
306-
}
307-
308-
$this->assertEquals($expected, $output);
325+
EOF
326+
],
327+
];
309328
}
310329

311330
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.