8000 Merge branch '2.8' into 3.3 · dunglas/symfony@67ceb50 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67ceb50

Browse files
author
Robin Chalas
committed
Merge branch '2.8' into 3.3
* 2.8: [Serializer] Correct typing mistake in DocBlock [Config] Fix closure CS PHP CS Fixer: use PHPUnit Migration ruleset [Console] Commands with an alias should not be recognized as ambiguous
2 parents 8a1a9f9 + 88f7e33 commit 67ceb50

File tree

7 files changed

+61
-6
lines changed

7 files changed

+61
-6
lines changed

.php_cs.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ return PhpCsFixer\Config::create()
88
->setRules(array(
99
'@Symfony' => true,
1010
'@Symfony:risky' => true,
11+
'@PHPUnit48Migration:risky' => true,
12+
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
1113
'array_syntax' => array('syntax' => 'long'),
1214
'protected_to_private' => false,
13-
'php_unit_dedicate_assert' => array('target' => '3.5'),
1415
))
1516
->setRiskyAllowed(true)
1617
->setFinder(

src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function thenEmptyArray()
186186
*/
187187
public function thenInvalid($message)
188188
{
189-
$this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
189+
$this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
190190

191191
return $this;
192192
}

src/Symfony/Component/Console/Application.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public function findNamespace($namespace)
550550
public function find($name)
551551
{
552552
$this->init();
553-
553+
$aliases = array();
554554
$allCommands = array_keys($this->commands);
555555
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
556556
$commands = preg_grep('{^'.$expr.'}', $allCommands);
@@ -578,14 +578,15 @@ public function find($name)
578578
// filter out aliases for commands which are already on the list
579579
if (count($commands) > 1) {
580580
$commandList = $this->commands;
581-
$commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) {
581+
$commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
582582
$commandName = $commandList[$nameOrAlias]->getName();
583+
$aliases[$nameOrAlias] = $commandName;
583584

584585
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
585586
});
586587
}
587588

588-
$exact = in_array($name, $commands, true);
589+
$exact = in_array($name, $commands, true) || isset($aliases[$name]);
589590
if (count($commands) > 1 && !$exact) {
590591
$usableWidth = $this->terminal->getWidth() - 10;
591592
$abbrevs = array_values($commands);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public static function setUpBeforeClass()
5151
require_once self::$fixturesPath.'/BarBucCommand.php';
5252
require_once self::$fixturesPath.'/FooSubnamespaced1Command.php';
5353
require_once self::$fixturesPath.'/FooSubnamespaced2Command.php';
54+
require_once self::$fixturesPath.'/TestTiti.php';
55+
require_once self::$fixturesPath.'/TestToto.php';
5456
}
5557

5658
protected function normalizeLineBreaks($text)
@@ -234,6 +236,14 @@ public function testFindAmbiguousNamespace()
234236
$application->findNamespace('f');
235237
}
236238

239+
public function testFindNonAmbiguous()
240+
{
241+
$application = new Application();
242+
$application->add(new \TestTiti());
243+
$application->add(new \TestToto());
244+
$this->assertEquals('test-toto', $application->find('test')->getName());
245+
}
246+
237247
/**
238248
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException
239249
* @expectedExceptionMessage There are no commands defined in the "bar" namespace.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Command\Command;
4+
use Symfony\Component\Console\Input\InputInterface;
5+
use Symfony\Component\Console\Output\OutputInterface;
6+
7+
class TestTiti extends Command
8+
{
9+
protected function configure()
10+
{
11+
$this
12+
->setName('test-titi')
13+
->setDescription('The test:titi command')
14+
;
15+
}
16+
17+
protected function execute(InputInterface $input, OutputInterface $output)
18+
{
19+
$output->write('test-titi');
20+
}
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Command\Command;
4+
use Symfony\Component\Console\Input\InputInterface;
5+
use Symfony\Component\Console\Output\OutputInterface;
6+
7+
class TestToto extends Command
8+
{
9+
protected function configure()
10+
{
11+
$this
12+
->setName('test-toto')
13+
->setDescription('The test-toto command')
14+
->setAliases(array('test'))
15+
;
16+
}
17+
18+
protected function execute(InputInterface $input, OutputInterface $output)
19+
{
20+
$output->write('test-toto');
21+
}
22+
}

src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function supportsNormalization($data, $format = null)
5454
}
5555

5656
/**
57-
* Checks if the given class implements the NormalizableInterface.
57+
* Checks if the given class implements the DenormalizableInterface.
5858
*
5959
* @param mixed $data Data to denormalize from
6060
* @param string $type The class to which the data should be denormalized

0 commit comments

Comments
 (0)
0