8000 Merge branch '4.4' · symfony/symfony@6b6562c · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b6562c

Browse files
Merge branch '4.4'
* 4.4: (21 commits) [appveyor] exclude tty group [HttpFoundation] Add types to private/final/internal methods and constructors. Add types to private/final/internal methods and constructors. SCA: minor code tweaks Tweak output [FrameworkBundle] Added --sort option for TranslationUpdateCommand [HttpClient] fallbackto CURLMOPT_MAXCONNECTS when CURLMOPT_MAX_HOST_CONNECTIONS is not available [DI] generate preload.php file for PHP 7.4 in cache folder Allow version 2 of the contracts package. [Serializer] Allow multi-dimenstion object array in AbstractObjectNormalizer fixed typo [HttpKernel] Fix Apache mod_expires Session Cache-Control issue deprecated not passing dash symbol (-) to STDIN commands [VarDumper] display ellipsed FQCN for nested classes [VarDumper] Display fully qualified title [Mailer] Change the syntax for DSNs using failover or roundrobin Removed workaround introduced in 4.3 [Console] Added support for definition list [OptionsResolver] Display full nested options hierarchy in exceptions New welcome page ...
2 parents 407652b + 81ac674 commit 6b6562c

File tree

103 files changed

+967
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+967
-274
lines changed

.appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test_script:
5656
- SET SYMFONY_PHPUNIT_SKIPPED_TESTS=phpunit.skipped
5757
- copy /Y c:\php\php.ini-min c:\php\php.ini
5858
- IF %APPVEYOR_REPO_BRANCH% neq master (rm -Rf src\Symfony\Bridge\PhpUnit)
59-
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
59+
- php phpunit src\Symfony --exclude-group tty,benchmark,intl-data || SET X=!errorlevel!
6060
- copy /Y c:\php\php.ini-max c:\php\php.ini
61-
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
61+
- php phpunit src\Symfony --exclude-group tty,benchmark,intl-data || SET X=!errorlevel!
6262
- exit %X%

UPGRADE-4.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,14 @@ Translation
207207
-----------
208208

209209
* Deprecated support for using `null` as the locale in `Translator`.
210+
* Deprecated accepting STDIN implicitly when using the `lint:xliff` command, use `lint:xliff -` (append a dash) instead to make it explicit.
210211

211212
TwigBridge
212213
----------
213214

214215
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
215216
`DebugCommand::__construct()` method, swap the variables position.
217+
* Deprecated accepting STDIN implicitly when using the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
216218

217219
TwigBundle
218220
----------
@@ -326,3 +328,8 @@ WebServerBundle
326328
---------------
327329

328330
* The bundle is deprecated and will be removed in 5.0.
331+
332+
Yaml
333+
----
334+
335+
* Deprecated accepting STDIN implicitly when using the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.

UPGRADE-5.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ Translation
531531
* The `MessageSelector`, `Interval` and `PluralizationRules` classes have been removed, use `IdentityTranslator` instead
532532
* The `Translator::getFallbackLocales()` and `TranslationDataCollector::getFallbackLocales()` method are now internal
533533
* The `Translator::transChoice()` method has been removed in favor of using `Translator::trans()` with "%count%" as the parameter driving plurals
534+
* Removed support for implicit STDIN usage in the `lint:xliff` command, use `lint:xliff -` (append a dash) instead to make it explicit.
534535

535536
TwigBundle
536537
----------
@@ -548,6 +549,7 @@ TwigBridge
548549
* removed the `$requestStack` and `$requestContext` arguments of the
549550
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
550551
instance as the only argument instead
552+
* Removed support for implicit STDIN usage in the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
551553

552554
Validator
553555
--------
@@ -653,6 +655,7 @@ Yaml
653655

654656
* The parser is now stricter and will throw a `ParseException` when a
655657
mapping is found inside a multi-line string.
658+
* Removed support for implicit STDIN usage in the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
656659

657660
WebProfilerBundle
658661
-----------------

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"psr/container": "^1.0",
2626
"psr/link": "^1.0",
2727
"psr/log": "~1.0",
28-
"symfony/contracts": "^1.1.3",
28+
"symfony/contracts": "^1.1.3|^2",
2929
"symfony/polyfill-ctype": "~1.8",
3030
"symfony/polyfill-intl-icu": "~1.0",
3131
"symfony/polyfill-intl-idn": "^1.10",

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ protected function detectMetadataDriver(string $dir, ContainerBuilder $container
246246
$configPath = $this->getMappingResourceConfigDirectory();
247247
$extension = $this->getMappingResourceExtension();
248248

249-
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) {
249+
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', GLOB_NOSORT)) {
250250
$driver = 'xml';
251-
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) {
251+
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', GLOB_NOSORT)) {
252252
$driver = 'yml';
253-
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) {
253+
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', GLOB_NOSORT)) {
254254
$driver = 'php';
255255
} else {
256256
// add the closest existing directory as a resource

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"doctrine/persistence": "~1.0",
2222
"symfony/polyfill-ctype": "~1.8",
2323
"symfony/polyfill-mbstring": "~1.0",
24-
"symfony/service-contracts": "^1.1"
24+
"symfony/service-contracts": "^1.1|^2"
2525
},
2626
"require-dev": {
2727
"symfony/stopwatch": "^4.4|^5.0",

src/Symfony/Bridge/Monolog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.2.9",
2020
"monolog/monolog": "^1.25.1|^2",
21-
"symfony/service-contracts": "^1.1",
21+
"symfony/service-contracts": "^1.1|^2",
2222
"symfony/http-kernel": "^4.4|^5.0"
2323
},
2424
"require-dev": {

src/Symfony/Bridge/Twig/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CHANGELOG
1515
* deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
1616
`DebugCommand::__construct()` method, swap the variables position.
1717
* the `LintCommand` lints all the templates stored in all configured Twig paths if none argument is provided
18+
* deprecated accepting STDIN implicitly when using the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
1819

1920
4.3.0
2021
-----

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function configure()
5050
$this
5151
->setDescription('Lints a template and outputs encountered errors')
5252
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
53-
->addArgument('filename', InputArgument::IS_ARRAY)
53+
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
5454
->setHelp(<<<'EOF'
5555
The <info>%command.name%</info> command lints a template and outputs to STDOUT
5656
the first encountered syntax error.
@@ -77,15 +77,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
7777
{
7878
$io = new SymfonyStyle($input, $output);
7979
$filenames = $input->getArgument('filename');
80+
$hasStdin = '-' === ($filenames[0] ?? '');
8081

81-
if (0 === \count($filenames)) {
82-
if (0 === ftell(STDIN)) {
83-
$template = '';
84-
while (!feof(STDIN)) {
85-
$template .= fread(STDIN, 1024);
82+
if ($hasStdin || 0 === \count($filenames)) {
83+
if ($hasStdin || 0 === ftell(STDIN)) { // remove 0 === ftell(STDIN) check in 5.0
84+
if (!$hasStdin) {
85+
@trigger_error('Calling to the "lint:twig" command providing pipe file content to STDIN without passing the dash symbol "-" explicitly is deprecated since Symfony 4.4.', E_USER_DEPRECATED);
8686
}
8787

88-
return $this->display($input, $output, $io, [$this->validate($template, uniqid('sf_', true))]);
88+
return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]);
8989
}
9090

9191
$loader = $this->twig->getLoader();
@@ -107,6 +107,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
107107
return $this->display($input, $output, $io, $filesInfo);
108108
}
109109

110+
private function getStdin(): string
111+
{
112+
$template = '';
113+
while (!feof(STDIN)) {
114+
$template .= fread(STDIN, 1024);
115+
}
116+
117+
return $template;
118+
}
119+
110120
private function getFilesInfo(array $filenames)
111121
{
112122
$filesInfo = [];

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^7.2.9",
20-
"symfony/translation-contracts": "^1.1",
20+
"symfony/translation-contracts": "^1.1|^2",
2121
"twig/twig": "^2.10|^3"
2222
},
2323
"require-dev": {

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ CHANGELOG
3434
* Not tagging service route loaders with `routing.route_loader` has been deprecated.
3535
* Overriding the methods `KernelTestCase::tearDown()` and `WebTestCase::tearDown()` without the `void` return-type is deprecated.
3636
* Added new `error_controller` configuration to handle system exceptions
37-
37+
* Added sort option for `translation:update` command.
38+
3839
4.3.0
3940
-----
4041

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
*/
3737
class TranslationUpdateCommand extends Command
3838
{
39+
private const ASC = 'asc';
40+
private const DESC = 'desc';
41+
private const SORT_ORDERS = [self::ASC, self::DESC];
42+
3943
protected static $defaultName = 'translation:update';
4044

4145
private $writer;
@@ -78,22 +82,31 @@ protected function configure()
7882
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
7983
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
8084
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version', '1.2'),
85+
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically'),
8186
])
8287
->setDescription('Updates the translation file')
8388
->setHelp(<<<'EOF'
8489
The <info>%command.name%</info> command extracts translation strings from templates
85-
of a given bundle or the default translations directory. It can display them or merge the new ones into the translation files.
90+
of a given bundle or the default translations directory. It can display them or merge
91+
the new ones into the translation files.
8692
8793
When new translation strings are found it can automatically add a prefix to the translation
8894
message.
8995
9096
Example running against a Bundle (AcmeBundle)
97+
9198
<info>php %command.full_name% --dump-messages en AcmeBundle</info>
9299
<info>php %command.full_name% --force --prefix="new_" fr AcmeBundle</info>
93100
94101
Example running against default messages directory
102+
95103
<info>php %command.full_name% --dump-messages en</info>
96104
<info>php %command.full_name% --force --prefix="new_" fr</info>
105+
106+
You can sort the output with the <comment>--sort</> flag:
107+
108+
<info>php %command.full_name% --dump-messages --sort=asc en AcmeBundle</info>
109+
<info>php %command.full_name% --dump-messages --sort=desc fr</info>
97110
EOF
98111
)
99112
;
@@ -223,6 +236,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
223236

224237
$domainMessagesCount = \count($list);
225238

239+
if ($sort = $input->getOption('sort')) {
240+
$sort = strtolower($sort);
241+
if (!\in_array($sort, self::SORT_ORDERS, true)) {
242+
$errorIo->error(['Wrong sort order', 'Supported formats are: '.implode(', ', self::SORT_ORDERS).'.']);
243+
244+
return 1;
245+
}
246+
247+
if (self::DESC === $sort) {
248+
rsort($list);
249+
} else {
250+
sort($list);
251+
}
252+
}
253+
226254
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
227255
$io->listing($list);
228256

src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

14+
use Psr\Container\ContainerInterface;
1415
use Symfony\Component\DependencyInjection\Container;
1516
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
1617
use Symfony\Component\HttpKernel\KernelInterface;
@@ -135,7 +136,7 @@ public function getRemovedIds(): array
135136
return $this->getPublicContainer()->getRemovedIds();
136137
}
137138

138-
private function getPublicContainer()
139+
private function getPublicContainer(): Container
139140
{
140141
if (null === $container = $this->kernel->getContainer()) {
141142
throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?');
@@ -144,7 +145,7 @@ private function getPublicContainer()
144145
return $container;
145146
}
146147

147-
private function getPrivateContainer()
148+
private function getPrivateContainer(): ContainerInterface
148149
{
149150
return $this->getPublicContainer()->get($this->privateServicesLocatorId);
150151
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@ public function testDumpMessagesAndClean()
3232
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
3333
}
3434

35+
public function testDumpSortedMessagesAndClean()
36+
{
37+
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
38+
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'asc']);
39+
$this->assertRegExp("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
40+
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
41+
}
42+
43+
public function testDumpReverseSortedMessagesAndClean()
44+
{
45+
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
46+
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'desc']);
47+
$this->assertRegExp("/\*test\*foo\*bar/", preg_replace('/\s+/', '', $tester->getDisplay()));
48+
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
49+
}
50+
51+
public function testDumpWrongSortAndClean()
52+
{
53+
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
54+
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'test']);
55+
$this->assertRegExp('/\[ERROR\] Wrong sort order/', $tester->getDisplay());
56+
}
57+
3558
public function testDumpMessagesAndCleanInRootDirectory()
3659
{
3760
$this->fs->remove($this->translationDir);
@@ -101,7 +124,10 @@ protected function tearDown(): void
101124
$this->fs->remove($this->translationDir);
102125
}
103126

104-
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
127+
/**
128+
* @return CommandTester
129+
*/
130+
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
105131
{
106132
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
107133
->disableOriginalConstructor()

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/MissingUserProvider/bundles.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
return [
1717
new FrameworkBundle(),
1818
new SecurityBundle(),
19-
new Symfony\Bundle\TwigBundle\TwigBundle(),
2019
new MissingUserProviderBundle(),
2120
];

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/MissingUserProvider/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
imports:
2-
- { resource: ./../config/default.yml }
2+
- { resource: ./../config/framework.yml }
33

44
security:
55
firewalls:

src/Symfony/Component/Cache/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"php": "^7.2.9",
2525
"psr/cache": "~1.0",
2626
"psr/log": "~1.0",
27-
"symfony/cache-contracts": "^1.1",
28-
"symfony/service-contracts": "^1.1",
27+
"symfony/cache-contracts": "^1.1|^2",
28+
"symfony/service-contracts": "^1.1|^2",
2929
"symfony/var-exporter": "^4.4|^5.0"
3030
},
3131
"require-dev": {

src/Symfony/Component/Config/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/event-dispatcher": "^4.4|^5.0",
2525
"symfony/finder": "^4.4|^5.0",
2626
"symfony/messenger": "^4.4|^5.0",
27-
"symfony/service-contracts": "^1.1",
27+
"symfony/service-contracts": "^1.1|^2",
2828
"symfony/yaml": "^4.4|^5.0"
2929
},
3030
"conflict": {

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,7 @@ private function getAbbreviationSuggestions(array $abbrevs): string
10151015
*/
10161016
public function extractNamespace(string $name, int $limit = null)
10171017
{
1018-
$parts = explode(':', $name);
1019-
array_pop($parts);
1018+
$parts = explode(':', $name, -1);
10201019

10211020
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
10221021
}

src/Symfony/Component/Console/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CHANGELOG
2020
* added method `preventRedrawFasterThan()` and `forceRedrawSlowerThan()` on `ProgressBar`
2121
* `Application` implements `ResetInterface`
2222
* marked all dispatched event classes as `@final`
23+
* added support for displaying table horizontally
2324

2425
4.3.0
2526
-----

0 commit comments

Comments
 (0)
0