Merge branch '2.5' into 2.6
* 2.5: Added information when an error occured during validation of an answer of a question [Console] fixes some typos and phpdoc. fix phpdoc's alignment Minor phpcs fixes [ClassLoader] Fix undefined index in ClassCollectionLoader
This commit is contained in:
commit
23eafccd4a
@ -353,6 +353,8 @@ class ClassCollectionLoader
|
|||||||
$unresolved = new \ArrayObject();
|
$unresolved = new \ArrayObject();
|
||||||
}
|
}
|
||||||
$nodeName = $node->getName();
|
$nodeName = $node->getName();
|
||||||
|
|
||||||
|
if (isset($tree[$nodeName])) {
|
||||||
$unresolved[$nodeName] = $node;
|
$unresolved[$nodeName] = $node;
|
||||||
foreach ($tree[$nodeName] as $dependency) {
|
foreach ($tree[$nodeName] as $dependency) {
|
||||||
if (!$resolved->offsetExists($dependency->getName())) {
|
if (!$resolved->offsetExists($dependency->getName())) {
|
||||||
@ -361,6 +363,7 @@ class ClassCollectionLoader
|
|||||||
}
|
}
|
||||||
$resolved[$nodeName] = $node;
|
$resolved[$nodeName] = $node;
|
||||||
unset($unresolved[$nodeName]);
|
unset($unresolved[$nodeName]);
|
||||||
|
}
|
||||||
|
|
||||||
return $resolved;
|
return $resolved;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,38 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFixClassWithTraitsOrdering()
|
||||||
|
{
|
||||||
|
if (PHP_VERSION_ID < 50400) {
|
||||||
|
$this->markTestSkipped('Requires PHP > 5.4');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||||
|
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
|
||||||
|
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
|
||||||
|
|
||||||
|
$classes = array(
|
||||||
|
'ClassesWithParents\\F',
|
||||||
|
'ClassesWithParents\\G',
|
||||||
|
);
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
'ClassesWithParents\\CTrait',
|
||||||
|
'ClassesWithParents\\F',
|
||||||
|
'ClassesWithParents\\G',
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||||
|
$m = $r->getMethod('getOrderedClasses');
|
||||||
|
$m->setAccessible(true);
|
||||||
|
|
||||||
|
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getFixNamespaceDeclarationsData
|
* @dataProvider getFixNamespaceDeclarationsData
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ClassesWithParents;
|
||||||
|
|
||||||
|
class F
|
||||||
|
{
|
||||||
|
use CTrait;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ClassesWithParents;
|
||||||
|
|
||||||
|
class G
|
||||||
|
{
|
||||||
|
use CTrait;
|
||||||
|
}
|
@ -355,7 +355,13 @@ class QuestionHelper extends Helper
|
|||||||
$attempts = $question->getMaxAttempts();
|
$attempts = $question->getMaxAttempts();
|
||||||
while (null === $attempts || $attempts--) {
|
while (null === $attempts || $attempts--) {
|
||||||
if (null !== $error) {
|
if (null !== $error) {
|
||||||
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
|
if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
|
||||||
|
$message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
|
||||||
|
} else {
|
||||||
|
$message = '<error>'.$error->getMessage().'</error>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -23,6 +23,13 @@ class ChoiceQuestion extends Question
|
|||||||
private $prompt = ' > ';
|
private $prompt = ' > ';
|
||||||
private $errorMessage = 'Value "%s" is invalid';
|
private $errorMessage = 'Value "%s" is invalid';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $question The question to ask to the user
|
||||||
|
* @param array $choices The list of available choices
|
||||||
|
* @param mixed $default The default answer to return
|
||||||
|
*/
|
||||||
public function __construct($question, array $choices, $default = null)
|
public function __construct($question, array $choices, $default = null)
|
||||||
{
|
{
|
||||||
parent::__construct($question, $default);
|
parent::__construct($question, $default);
|
||||||
@ -100,6 +107,11 @@ class ChoiceQuestion extends Question
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default answer validator.
|
||||||
|
*
|
||||||
|
* @return callable
|
||||||
|
*/
|
||||||
private function getDefaultValidator()
|
private function getDefaultValidator()
|
||||||
{
|
{
|
||||||
$choices = $this->choices;
|
$choices = $this->choices;
|
||||||
|
@ -18,6 +18,12 @@ namespace Symfony\Component\Console\Question;
|
|||||||
*/
|
*/
|
||||||
class ConfirmationQuestion extends Question
|
class ConfirmationQuestion extends Question
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $question The question to ask to the user
|
||||||
|
* @param bool $default The default answer to return, true or false
|
||||||
|
*/
|
||||||
public function __construct($question, $default = true)
|
public function __construct($question, $default = true)
|
||||||
{
|
{
|
||||||
parent::__construct($question, (bool) $default);
|
parent::__construct($question, (bool) $default);
|
||||||
@ -25,6 +31,11 @@ class ConfirmationQuestion extends Question
|
|||||||
$this->setNormalizer($this->getDefaultNormalizer());
|
$this->setNormalizer($this->getDefaultNormalizer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default answer normalizer.
|
||||||
|
*
|
||||||
|
* @return callable
|
||||||
|
*/
|
||||||
private function getDefaultNormalizer()
|
private function getDefaultNormalizer()
|
||||||
{
|
{
|
||||||
$default = $this->getDefault();
|
$default = $this->getDefault();
|
||||||
|
@ -116,7 +116,7 @@ class Question
|
|||||||
/**
|
/**
|
||||||
* Gets values for the autocompleter.
|
* Gets values for the autocompleter.
|
||||||
*
|
*
|
||||||
* @return null|array|Traversable
|
* @return null|array|\Traversable
|
||||||
*/
|
*/
|
||||||
public function getAutocompleterValues()
|
public function getAutocompleterValues()
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ class Question
|
|||||||
/**
|
/**
|
||||||
* Sets values for the autocompleter.
|
* Sets values for the autocompleter.
|
||||||
*
|
*
|
||||||
* @param null|array|Traversable $values
|
* @param null|array|\Traversable $values
|
||||||
*
|
*
|
||||||
* @return Question The current instance
|
* @return Question The current instance
|
||||||
*
|
*
|
||||||
@ -165,7 +165,7 @@ class Question
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the validator for the question
|
* Gets the validator for the question.
|
||||||
*
|
*
|
||||||
* @return null|callable
|
* @return null|callable
|
||||||
*/
|
*/
|
||||||
@ -211,9 +211,9 @@ class Question
|
|||||||
/**
|
/**
|
||||||
* Sets a normalizer for the response.
|
* Sets a normalizer for the response.
|
||||||
*
|
*
|
||||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
|
||||||
*
|
*
|
||||||
* @param string|Closure $normalizer
|
* @param string|\Closure $normalizer
|
||||||
*
|
*
|
||||||
* @return Question The current instance
|
* @return Question The current instance
|
||||||
*/
|
*/
|
||||||
@ -229,7 +229,7 @@ class Question
|
|||||||
*
|
*
|
||||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||||
*
|
*
|
||||||
* @return string|Closure
|
* @return string|\Closure
|
||||||
*/
|
*/
|
||||||
public function getNormalizer()
|
public function getNormalizer()
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,7 @@ class CurrencyDataGenerator extends AbstractDataGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $rootBundle
|
* @param ArrayAccessibleResourceBundle $rootBundle
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -186,7 +186,7 @@ class StringUtil
|
|||||||
return $singulars;
|
return $singulars;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $newBase.($firstUpper ? ucFirst($newSuffix) : $newSuffix);
|
return $newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suffix is longer than word
|
// Suffix is longer than word
|
||||||
|
Reference in New Issue
Block a user