From f0bb7a36c50fa5e331ff812a763e6e33f1edff0c Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Mon, 12 Jul 2021 09:30:02 -0500 Subject: [PATCH 1/6] Add a Special Case for Translating Choices in en_US_POSIX See https://github.com/symfony/symfony/issues/42036 This adds a special case similar to `pt_BR` for handling `en_US_POSIX` which is set as the default locale on some operating systems (Alpine Linux, for instance). --- .../Component/Translation/PluralizationRules.php | 3 ++- .../Contracts/Translation/Test/TranslatorTest.php | 13 ++++++++++++- .../Contracts/Translation/TranslatorTrait.php | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php index 2a46ce094f..e69ceabc17 100644 --- a/src/Symfony/Component/Translation/PluralizationRules.php +++ b/src/Symfony/Component/Translation/PluralizationRules.php @@ -43,7 +43,7 @@ class PluralizationRules $locale = 'xbr'; } - if (\strlen($locale) > 3) { + if ('en_US_POSIX' !== $locale && \strlen($locale) > 3) { $locale = substr($locale, 0, -\strlen(strrchr($locale, '_'))); } @@ -88,6 +88,7 @@ class PluralizationRules case 'de': case 'el': case 'en': + case 'en_US_POSIX': case 'eo': case 'es': case 'et': diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php index 196ec1859f..35519f34b9 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -80,6 +80,17 @@ class TranslatorTest extends TestCase $this->assertEquals($expected, $translator->trans($id, ['%count%' => $number])); } + /** + * @dataProvider getTransChoiceTests + */ + public function testTransChoiceWithEnUsPosix($expected, $id, $number) + { + $translator = $this->getTranslator(); + $translator->setLocale('en_US_POSIX'); + + $this->assertEquals($expected, $translator->trans($id, ['%count%' => $number])); + } + public function testGetSetLocale() { $translator = $this->getTranslator(); @@ -296,7 +307,7 @@ class TranslatorTest extends TestCase { return [ ['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']], - ['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM']], + ['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM', 'en_US_POSIX']], ['3', ['be', 'bs', 'cs', 'hr']], ['4', ['cy', 'mt', 'sl']], ['6', ['ar']], diff --git a/src/Symfony/Contracts/Translation/TranslatorTrait.php b/src/Symfony/Contracts/Translation/TranslatorTrait.php index 2c09c5f14d..92a6a00214 100644 --- a/src/Symfony/Contracts/Translation/TranslatorTrait.php +++ b/src/Symfony/Contracts/Translation/TranslatorTrait.php @@ -140,7 +140,7 @@ EOF; { $number = abs($number); - switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) { + switch ('pt_BR' !== $locale && 'en_US_POSIX' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) { case 'af': case 'bn': case 'bg': @@ -149,6 +149,7 @@ EOF; case 'de': case 'el': case 'en': + case 'en_US_POSIX': case 'eo': case 'es': case 'et': From 5c57324117a8fde15a0eeecaa86a81e72c6f2b57 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 12 Jul 2021 21:04:52 +0100 Subject: [PATCH 2/6] Fix ctype_digit deprecation --- src/Symfony/Component/Yaml/Inline.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 10ed14fe51..bef3426616 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -161,8 +161,8 @@ class Inline return 'true'; case false === $value: return 'false'; - case ctype_digit($value): - return \is_string($value) ? "'$value'" : (int) $value; + case \is_int($value): + return $value; case is_numeric($value) && false === strpos($value, "\f") && false === strpos($value, "\n") && false === strpos($value, "\r") && false === strpos($value, "\t") && false === strpos($value, "\v"): $locale = setlocale(\LC_NUMERIC, 0); if (false !== $locale) { From 7036f2f56152d9160cd47f172997908c50b70e52 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 13 Jul 2021 10:50:48 +0200 Subject: [PATCH 3/6] [Yaml] Fixed an exception message --- src/Symfony/Component/Yaml/Inline.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 10ed14fe51..2742122576 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -711,7 +711,7 @@ class Inline $nextOffset += strspn($value, ' ', $nextOffset); if ('' === $tag && (!isset($value[$nextOffset]) || \in_array($value[$nextOffset], [']', '}', ','], true))) { - throw new ParseException(sprintf('Using the unquoted scalar value "!" is not supported. You must quote it.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename); + throw new ParseException('Using the unquoted scalar value "!" is not supported. You must quote it.', self::$parsedLineNumber + 1, $value, self::$parsedFilename); } // Is followed by a scalar and is a built-in tag From e335c28d44bc8a6b85e1fb183adb96e36f20803a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 13 Jul 2021 11:24:46 +0200 Subject: [PATCH 4/6] [WebProfilerBundle] Fix the values of some CSS properties --- .../Resources/views/Collector/exception.css.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig index ea028e026f..aad7625a22 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig @@ -1,5 +1,5 @@ .container { - max-width: auto; + max-width: none; margin: 0; padding: 0; } @@ -28,5 +28,5 @@ } .exception-message-wrapper .container { - min-height: auto; + min-height: unset; } From bed9cd9176605b709ea963c6076206a4a19bbe32 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 13 Jul 2021 11:47:43 +0200 Subject: [PATCH 5/6] Fix minor typos --- .../Tests/Console/Descriptor/AbstractDescriptorTest.php | 2 +- .../Component/Console/Tests/Helper/ProgressBarTest.php | 6 +++--- .../SendFailedMessageForRetryListenerTest.php | 8 ++++---- .../Messenger/Tests/Transport/AmqpExt/ConnectionTest.php | 2 +- .../Validator/Tests/Validator/RecursiveValidatorTest.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php index 30cc22e203..550dcb46ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -209,7 +209,7 @@ abstract class AbstractDescriptorTest extends TestCase } /** @dataProvider getClassDescriptionTestData */ - public function testGetClassDecription($object, $expectedDescription) + public function testGetClassDescription($object, $expectedDescription) { $this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object)); } diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 9fdaa570d3..0cf06353d2 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -1018,14 +1018,14 @@ And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whi $bar->setRedrawFrequency(4); // disable step based redraws $bar->start(); - $bar->setProgress(1); // No treshold hit, no redraw + $bar->setProgress(1); // No threshold hit, no redraw $bar->maxSecondsBetweenRedraws(2); sleep(1); $bar->setProgress(2); // Still no redraw because it takes 2 seconds for a redraw sleep(1); $bar->setProgress(3); // 1+1 = 2 -> redraw finally $bar->setProgress(4); // step based redraw freq hit, redraw even without sleep - $bar->setProgress(5); // No treshold hit, no redraw + $bar->setProgress(5); // No threshold hit, no redraw $bar->maxSecondsBetweenRedraws(3); sleep(2); $bar->setProgress(6); // No redraw even though 2 seconds passed. Throttling has priority @@ -1056,7 +1056,7 @@ And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whi $bar->setProgress(3); // 1 second passed but we changed threshold, should not draw sleep(1); $bar->setProgress(4); // 1+1 seconds = 2 seconds passed which conforms threshold, draw - $bar->setProgress(5); // No treshold hit, no redraw + $bar->setProgress(5); // No threshold hit, no redraw rewind($output->getStream()); $this->assertEquals( diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php index 9a5861a317..f746689f99 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php @@ -99,12 +99,12 @@ class SendFailedMessageForRetryListenerTest extends TestCase $senderLocator = $this->createMock(ContainerInterface::class); $senderLocator->expects($this->once())->method('has')->willReturn(true); $senderLocator->expects($this->once())->method('get')->willReturn($sender); - $retryStategy = $this->createMock(RetryStrategyInterface::class); - $retryStategy->expects($this->once())->method('isRetryable')->willReturn(true); - $retryStategy->expects($this->once())->method('getWaitingTime')->willReturn(1000); + $retryStrategy = $this->createMock(RetryStrategyInterface::class); + $retryStrategy->expects($this->once())->method('isRetryable')->willReturn(true); + $retryStrategy->expects($this->once())->method('getWaitingTime')->willReturn(1000); $retryStrategyLocator = $this->createMock(ContainerInterface::class); $retryStrategyLocator->expects($this->once())->method('has')->willReturn(true); - $retryStrategyLocator->expects($this->once())->method('get')->willReturn($retryStategy); + $retryStrategyLocator->expects($this->once())->method('get')->willReturn($retryStrategy); $listener = new SendFailedMessageForRetryListener($senderLocator, $retryStrategyLocator); diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php index 1fbbb1e753..f75a3e7a3b 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php @@ -480,7 +480,7 @@ class ConnectionTest extends TestCase $connection->publish('body', ['Foo' => 'X'], 0, new AmqpStamp(null, \AMQP_NOPARAM, ['headers' => ['Bar' => 'Y']])); } - public function testAmqpStampDelireryModeIsUsed() + public function testAmqpStampDeliveryModeIsUsed() { $factory = new TestAmqpFactory( $this->createMock(\AMQPConnection::class), diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index 0e55cca834..7f47990135 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -1905,7 +1905,7 @@ class RecursiveValidatorTest extends TestCase $this->assertSame($constraint, $violations[0]->getConstraint()); } - public function testCollectionConstraitViolationHasCorrectContext() + public function testCollectionConstraintViolationHasCorrectContext() { $data = [ 'foo' => 'fooValue', From becf11aa143c1a6067cb00f2ef13c74a78c2785a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 13 Jul 2021 11:55:30 +0200 Subject: [PATCH 6/6] Fix tests --- .github/workflows/unit-tests.yml | 2 +- .../Contracts/Tests/Service/ServiceSubscriberTraitTest.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 0f8f1230f2..430d67c4c8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -139,7 +139,7 @@ jobs: if: "${{ matrix.php == '8.0' && ! matrix.mode }}" run: | sed -i 's/"\*\*\/Tests\/"//' composer.json - composer install --optimize-autoloader + composer install -q --optimize-autoloader SYMFONY_PATCH_TYPE_DECLARATIONS=force=1 php .github/patch-types.php SYMFONY_PATCH_TYPE_DECLARATIONS=force=1 php .github/patch-types.php # ensure the script is idempotent echo PHPUNIT="$PHPUNIT,legacy" >> $GITHUB_ENV diff --git a/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php b/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php index 7d1ddd75c2..ff2a6455c8 100644 --- a/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php +++ b/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php @@ -42,7 +42,10 @@ class ParentTestService { } - public function setContainer(ContainerInterface $container): ContainerInterface + /** + * @return ContainerInterface + */ + public function setContainer(ContainerInterface $container) { return $container; }