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:
Fabien Potencier 2014-12-08 09:43:24 +01:00
commit 23eafccd4a
18 changed files with 132 additions and 52 deletions

View File

@ -24,8 +24,8 @@ use Symfony\Bridge\Propel1\Form\EventListener\TranslationFormListener;
class TranslationType extends AbstractType
{
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(

View File

@ -353,14 +353,17 @@ class ClassCollectionLoader
$unresolved = new \ArrayObject();
}
$nodeName = $node->getName();
$unresolved[$nodeName] = $node;
foreach ($tree[$nodeName] as $dependency) {
if (!$resolved->offsetExists($dependency->getName())) {
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
if (isset($tree[$nodeName])) {
$unresolved[$nodeName] = $node;
foreach ($tree[$nodeName] as $dependency) {
if (!$resolved->offsetExists($dependency->getName())) {
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
}
}
$resolved[$nodeName] = $node;
unset($unresolved[$nodeName]);
}
$resolved[$nodeName] = $node;
unset($unresolved[$nodeName]);
return $resolved;
}

View File

@ -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
*/

View File

@ -0,0 +1,8 @@
<?php
namespace ClassesWithParents;
class F
{
use CTrait;
}

View File

@ -0,0 +1,8 @@
<?php
namespace ClassesWithParents;
class G
{
use CTrait;
}

View File

@ -355,7 +355,13 @@ class QuestionHelper extends Helper
$attempts = $question->getMaxAttempts();
while (null === $attempts || $attempts--) {
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 {

View File

@ -23,6 +23,13 @@ class ChoiceQuestion extends Question
private $prompt = ' > ';
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)
{
parent::__construct($question, $default);
@ -100,6 +107,11 @@ class ChoiceQuestion extends Question
return $this;
}
/**
* Returns the default answer validator.
*
* @return callable
*/
private function getDefaultValidator()
{
$choices = $this->choices;

View File

@ -18,6 +18,12 @@ namespace Symfony\Component\Console\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)
{
parent::__construct($question, (bool) $default);
@ -25,6 +31,11 @@ class ConfirmationQuestion extends Question
$this->setNormalizer($this->getDefaultNormalizer());
}
/**
* Returns the default answer normalizer.
*
* @return callable
*/
private function getDefaultNormalizer()
{
$default = $this->getDefault();

View File

@ -116,7 +116,7 @@ class Question
/**
* Gets values for the autocompleter.
*
* @return null|array|Traversable
* @return null|array|\Traversable
*/
public function getAutocompleterValues()
{
@ -126,7 +126,7 @@ class Question
/**
* Sets values for the autocompleter.
*
* @param null|array|Traversable $values
* @param null|array|\Traversable $values
*
* @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
*/
@ -211,9 +211,9 @@ class Question
/**
* 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
*/
@ -229,7 +229,7 @@ class Question
*
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
*
* @return string|Closure
* @return string|\Closure
*/
public function getNormalizer()
{

View File

@ -20,10 +20,10 @@ namespace Symfony\Component\EventDispatcher;
* You can call the method stopPropagation() to abort the execution of
* further listeners in your event listener.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*/

View File

@ -17,13 +17,13 @@ namespace Symfony\Component\EventDispatcher;
* Listeners are registered on the manager and events are dispatched through the
* manager.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Jordan Alliot <jordan.alliot@gmail.com>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Jordan Alliot <jordan.alliot@gmail.com>
*
* @api
*/

View File

@ -17,10 +17,10 @@ namespace Symfony\Component\EventDispatcher;
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*/

View File

@ -164,7 +164,7 @@ class CurrencyDataGenerator extends AbstractDataGenerator
}
/**
* @param $rootBundle
* @param ArrayAccessibleResourceBundle $rootBundle
*
* @return array
*/

View File

@ -186,7 +186,7 @@ class StringUtil
return $singulars;
}
return $newBase.($firstUpper ? ucFirst($newSuffix) : $newSuffix);
return $newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix);
}
// Suffix is longer than word

View File

@ -24,12 +24,12 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterfac
*/
interface AuthenticationProviderInterface extends AuthenticationManagerInterface
{
/**
* Checks whether this provider supports the given token.
*
* @param TokenInterface $token A TokenInterface instance
*
* @return bool true if the implementation supports the Token, false otherwise
*/
/**
* Checks whether this provider supports the given token.
*
* @param TokenInterface $token A TokenInterface instance
*
* @return bool true if the implementation supports the Token, false otherwise
*/
public function supports(TokenInterface $token);
}

View File

@ -129,17 +129,17 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
return $data;
}
/**
* {@inheritdoc}
*/
/**
* {@inheritdoc}
*/
public function supportsEncoding($format)
{
return 'xml' === $format;
}
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function supportsDecoding($format)
{
return 'xml' === $format;

View File

@ -21,15 +21,15 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class TestDenormalizer implements DenormalizerInterface
{
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function denormalize($data, $class, $format = null, array $context = array())
{
}
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null)
{
return true;

View File

@ -21,15 +21,15 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class TestNormalizer implements NormalizerInterface
{
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = array())
{
}
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
{
return true;