Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a53e8d

Browse files
Merge branch '4.2' into 4.3
* 4.2: [Routing] Fixed unexpected 404 NoConfigurationException [DI] Removes number of elements information in debug mode [Contracts] Simplify implementation declarations Update PR template for 4.3 [Intl] Add FallbackTrait for data generation [Console] Commands with an alias should not be recognized as ambiguous clarify the possible class/interface of the cache
2 parents 6852c84 + c083e20 commit 7a53e8d

File tree

21 files changed

+189
-126
lines changed

21 files changed

+189
-126
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
| Q | A
22
| ------------- | ---
3-
| Branch? | master for features / 3.4 up to 4.2 for bug fixes <!-- see below -->
3+
| Branch? | master for features / 3.4, 4.2 or 4.3 for bug fixes <!-- see below -->
44
| Bug fix? | yes/no
5-
| New feature? | yes/no <!-- don't forget to update src/**/CHANGELOG.md files -->
5+
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
66
| BC breaks? | no <!-- see https://symfony.com/bc -->
7-
| Deprecations? | yes/no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
7+
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
88
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
99
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
1010
| License | MIT
1111
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
1212

1313
<!--
14-
Write a short README entry for your feature/bugfix here (replace this comment block.)
15-
This will help people understand your PR and can be used as a start of the Doc PR.
16-
Additionally:
17-
- Bug fixes must be submitted against the lowest branch where they apply
14+
Replace this notice by a short README for your feature/bugfix. This will help people
15+
understand your PR and can be used as a start for the documentation.
16+
17+
Additionally (see https://symfony.com/roadmap):
18+
- Bug fixes must be submitted against the lowest maintained branch where they apply
1819
(lowest branches are regularly merged to upper ones so they get the fixes too).
1920
- Features and deprecations must be submitted against the master branch.
2021
-->

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
159159
$options['show_hidden'] = $input->getOption('show-hidden');
160160
$options['raw_text'] = $input->getOption('raw');
161161
$options['output'] = $io;
162+
$options['is_debug'] = $this->getApplication()->getKernel()->isDebug();
162163

163164
try {
164165
$helper->describe($io, $object, $options);

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
2020
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
2121
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
22+
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
2223
use Symfony\Component\DependencyInjection\ContainerBuilder;
2324
use Symfony\Component\DependencyInjection\Definition;
2425
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -347,21 +348,21 @@ protected function describeContainerDefinition(Definition $definition, array $op
347348
if ($argument instanceof Reference) {
348349
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
349350
} elseif ($argument instanceof IteratorArgument) {
350-
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
351-
foreach (array_map(function (Reference $value) {return (string) $value; }, $argument->getValues()) as $service) {
352-
$argumentsInformation[] = sprintf('- %s', $service);
351+
if ($argument instanceof TaggedIteratorArgument) {
352+
$argumentsInformation[] = sprintf('Tagged Iterator for "%s"%s', $argument->getTag(), $options['is_debug'] ? '' : sprintf(' (%d element(s))', \count($argument->getValues())));
353+
} else {
354+
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
355+
}
356+
357+
foreach ($argument->getValues() as $ref) {
358+
$argumentsInformation[] = sprintf('- Service(%s)', $ref);
353359
}
354360
} elseif ($argument instanceof ServiceLocatorArgument) {
355361
$argumentsInformation[] = sprintf('Service locator (%d element(s))', \count($argument->getValues()));
356362
} elseif ($argument instanceof Definition) {
357363
$argumentsInformation[] = 'Inlined Service';
358364
} else {
359365
$argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument;
360-
if (\is_array($argument)) {
361-
foreach (array_keys($argument) as $service) {
362-
$argumentsInformation[] = sprintf('- %s', $service);
363-
}
364-
}
365366
}
366367
}
367368

src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<tag name="kernel.cache_warmer" />
9999
</service>
100100

101-
<service id="serializer.mapping.cache.symfony" class="Symfony\Component\Cache\Adapter\PhpArrayAdapter">
101+
<service id="serializer.mapping.cache.symfony" class="Psr\Cache\CacheItemPoolInterface">
102102
<factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" />
103103
<argument>%serializer.mapping.cache.file%</argument>
104104
<argument type="service" id="cache.serializer" />

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ abstract protected function getFormat();
217217

218218
private function assertDescription($expectedDescription, $describedObject, array $options = [])
219219
{
220+
$options['is_debug'] = false;
220221
$options['raw_output'] = true;
221222
$options['raw_text'] = true;
222223
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
 %parameter% 
1818
 Inlined Service 
1919
 Array (3 element(s)) 
20-
 - 0 
21-
 - 1 
22-
 - 2 
2320
 Iterator (2 element(s)) 
24-
 - definition_1 
25-
 - .definition_2
21+
 - Service(definition_1) 
22+
 - Service(.definition_2)
2623
---------------- -----------------------------
2724

src/Symfony/Component/Cache/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"provide": {
1919
"psr/cache-implementation": "1.0",
2020
"psr/simple-cache-implementation": "1.0",
21-
"symfony/cache-contracts-implementation": "1.0"
21+
"symfony/cache-implementation": "1.0"
2222
},
2323
"require": {
2424
"php": "^7.1.3",

src/Symfony/Component/Console/Application.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,15 @@ public function find($name)
614614
$this->init();
615615

616616
$aliases = [];
617+
618+
foreach ($this->commands as $command) {
619+
foreach ($command->getAliases() as $alias) {
620+
if (!$this->has($alias)) {
621+
$this->commands[$alias] = $command;
622+
}
623+
}
624+
}
625+
617626
$allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
618627
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
619628
$commands = preg_grep('{^'.$expr.'}', $allCommands);

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public static function setUpBeforeClass()
7373
require_once self::$fixturesPath.'/FooSubnamespaced1Command.php';
7474
require_once self::$fixturesPath.'/FooSubnamespaced2Command.php';
7575
require_once self::$fixturesPath.'/FooWithoutAliasCommand.php';
76-
require_once self::$fixturesPath.'/TestTiti.php';
77-
require_once self::$fixturesPath.'/TestToto.php';
76+
require_once self::$fixturesPath.'/TestAmbiguousCommandRegistering.php';
77+
require_once self::$fixturesPath.'/TestAmbiguousCommandRegistering2.php';
7878
}
7979

8080
protected function normalizeLineBreaks($text)
@@ -165,6 +165,28 @@ public function testRegister()
165165
$this->assertEquals('foo', $command->getName(), '->register() registers a new command');
166166
}
167167

168+
public function testRegisterAmbiguous()
169+
{
170+
$code = function (InputInterface $input, OutputInterface $output) {
171+
$output->writeln('It works!');
172+
};
173+
174+
$application = new Application();
175+
$application->setAutoExit(false);
176+
$application
177+
->register('test-foo')
178+
->setAliases(['test'])
179+
->setCode($code);
180+
181+
$application
182+
->register('test-bar')
183+
->setCode($code);
184+
185+
$tester = new ApplicationTester($application);
186+
$tester->run(['test']);
187+
$this->assertContains('It works!', $tester->getDisplay(true));
188+
}
189+
168190
public function testAdd()
169191
{
170192
$application = new Application();
@@ -304,9 +326,9 @@ public function testFindAmbiguousNamespace()
304326
public function testFindNonAmbiguous()
305327
{
306328
$application = new Application();
307-
$application->add(new \TestTiti());
308-
$application->add(new \TestToto());
309-
$this->assertEquals('test-toto', $application->find('test')->getName());
329+
$application->add(new \TestAmbiguousCommandRegistering());
330+
$application->add(new \TestAmbiguousCommandRegistering2());
331+
$this->assertEquals('test-ambiguous', $application->find('test')->getName());
310332
}
311333

312334
/**

src/Symfony/Component/Console/Tests/Fixtures/TestToto.php renamed to src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
use Symfony\Component\Console\Input\InputInterface;
55
use Symfony\Component\Console\Output\OutputInterface;
66

7-
class TestToto extends Command
7+
class TestAmbiguousCommandRegistering extends Command
88
{
99
protected function configure()
1010
{
1111
$this
12-
->setName('test-toto')
13-
->setDescription('The test-toto command')
12+
->setName('test-ambiguous')
13+
->setDescription('The test-ambiguous command')
1414
->setAliases(['test'])
1515
;
1616
}
1717

1818
protected function execute(InputInterface $input, OutputInterface $output)
1919
{
20-
$output->write('test-toto');
20+
$output->write('test-ambiguous');
2121
}
2222
}

src/Symfony/Component/Console/Tests/Fixtures/TestTiti.php renamed to src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
use Symfony\Component\Console\Input\InputInterface;
55
use Symfony\Component\Console\Output\OutputInterface;
66

7-
class TestTiti extends Command
7+
class TestAmbiguousCommandRegistering2 extends Command
88
{
99
protected function configure()
1010
{
1111
$this
12-
->setName('test-titi')
13-
->setDescription('The test:titi command')
12+
->setName('test-ambiguous2')
13+
->setDescription('The test-ambiguous2 command')
1414
;
1515
}
1616

1717
protected function execute(InputInterface $input, OutputInterface $output)
1818
{
19-
$output->write('test-titi');
19+
$output->write('test-ambiguous2');
2020
}
2121
}

src/Symfony/Component/DependencyInjection/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"provide": {
4242
"psr/container-implementation": "1.0",
43-
"symfony/service-contracts-implementation": "1.0"
43+
"symfony/service-implementation": "1.0"
4444
},
4545
"autoload": {
4646
"psr-4": { "Symfony\\Component\\DependencyInjection\\": "" },

src/Symfony/Component/HttpClient/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"provide": {
1818
"psr/http-client-implementation": "1.0",
19-
"symfony/http-client-contracts-implementation": "1.1"
19+
"symfony/http-client-implementation": "1.1"
2020
},
2121
"require": {
2222
"php": "^7.1.3",
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\Data\Generator;
13+
14+
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
15+
use Symfony\Component\Intl\Locale;
16+
17+
/**
18+
* @author Roland Franssen <[email protected]>
19+
*
20+
* @internal
21+
*/
22+
trait FallbackTrait
23+
{
24+
private $fallbackCache = [];
25+
private $generatingFallback = false;
26+
27+
/**
28+
* @param string $tempDir
29+
* @param string $displayLocale
30+
*
31+
* @return array|null
32+
*
33+
* @see AbstractDataGenerator::generateDataForLocale()
34+
*/
35+
abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale);
36+
37+
/**
38+
* @param string $tempDir
39+
*
40+
* @return array|null
41+
*
42+
* @see AbstractDataGenerator::generateDataForRoot()
43+
*/
44+
abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir);
45+
46+
private function generateFallbackData(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): array
47+
{
48+
if (null === $fallback = Locale::getFallback($displayLocale)) {
49+
return [];
50+
}
51+
52+
if (isset($this->fallbackCache[$fallback])) {
53+
return $this->fallbackCache[$fallback];
54+
}
55+
56+
$prevGeneratingFallback = $this->generatingFallback;
57+
$this->generatingFallback = true;
58+
59+
try {
60+
$data = 'root' === $fallback ? $this->generateDataForRoot($reader, $tempDir) : $this->generateDataForLocale($reader, $tempDir, $fallback);
61+
} finally {
62+
$this->generatingFallback = $prevGeneratingFallback;
63+
}
64+
65+
return $this->fallbackCache[$fallback] = $data ?: [];
66+
}
67+
}

0 commit comments

Comments
 (0)