Skip to content

Commit 23eafcc

Browse files
committed
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
2 parents 51509be + 7bb6f44 commit 23eafcc

File tree

18 files changed

+132
-52
lines changed

18 files changed

+132
-52
lines changed

src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
class TranslationType extends AbstractType
2525
{
2626
/**
27-
* {@inheritdoc}
28-
*/
27+
* {@inheritdoc}
28+
*/
2929
public function buildForm(FormBuilderInterface $builder, array $options)
3030
{
3131
$builder->addEventSubscriber(

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,17 @@ private static function resolveDependencies(array $tree, $node, \ArrayObject $re
353353
$unresolved = new \ArrayObject();
354354
}
355355
$nodeName = $node->getName();
356-
$unresolved[$nodeName] = $node;
357-
foreach ($tree[$nodeName] as $dependency) {
358-
if (!$resolved->offsetExists($dependency->getName())) {
359-
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
356+
357+
if (isset($tree[$nodeName])) {
358+
$unresolved[$nodeName] = $node;
359+
foreach ($tree[$nodeName] as $dependency) {
360+
if (!$resolved->offsetExists($dependency->getName())) {
361+
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
362+
}
360363
}
364+
$resolved[$nodeName] = $node;
365+
unset($unresolved[$nodeName]);
361366
}
362-
$resolved[$nodeName] = $node;
363-
unset($unresolved[$nodeName]);
364367

365368
return $resolved;
366369
}

src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,38 @@ public function getDifferentOrdersForTraits()
146146
);
147147
}
148148

149+
public function testFixClassWithTraitsOrdering()
150+
{
151+
if (PHP_VERSION_ID < 50400) {
152+
$this->markTestSkipped('Requires PHP > 5.4');
153+
154+
return;
155+
}
156+
157+
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
158+
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
159+
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
160+
161+
$classes = array(
162+
'ClassesWithParents\\F',
163+
'ClassesWithParents\\G',
164+
);
165+
166+
$expected = array(
167+
'ClassesWithParents\\CTrait',
168+
'ClassesWithParents\\F',
169+
'ClassesWithParents\\G',
170+
);
171+
172+
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
173+
$m = $r->getMethod('getOrderedClasses');
174+
$m->setAccessible(true);
175+
176+
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
177+
178+
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
179+
}
180+
149181
/**
150182
* @dataProvider getFixNamespaceDeclarationsData
151183
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace ClassesWithParents;
4+
5+
class F
6+
{
7+
use CTrait;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace ClassesWithParents;
4+
5+
class G
6+
{
7+
use CTrait;
8+
}

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,13 @@ private function validateAttempts($interviewer, OutputInterface $output, Questio
355355
$attempts = $question->getMaxAttempts();
356356
while (null === $attempts || $attempts--) {
357357
if (null !== $error) {
358-
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
358+
if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
359+
$message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
360+
} else {
361+
$message = '<error>'.$error->getMessage().'</error>';
362+
}
363+
364+
$output->writeln($message);
359365
}
360366

361367
try {

src/Symfony/Component/Console/Question/ChoiceQuestion.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class ChoiceQuestion extends Question
2323
private $prompt = ' > ';
2424
private $errorMessage = 'Value "%s" is invalid';
2525

26+
/**
27+
* Constructor.
28+
*
29+
* @param string $question The question to ask to the user
30+
* @param array $choices The list of available choices
31+
* @param mixed $default The default answer to return
32+
*/
2633
public function __construct($question, array $choices, $default = null)
2734
{
2835
parent::__construct($question, $default);
@@ -100,6 +107,11 @@ public function setErrorMessage($errorMessage)
100107
return $this;
101108
}
102109

110+
/**
111+
* Returns the default answer validator.
112+
*
113+
* @return callable
114+
*/
103115
private function getDefaultValidator()
104116
{
105117
$choices = $this->choices;

src/Symfony/Component/Console/Question/ConfirmationQuestion.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@
1818
*/
1919
class ConfirmationQuestion extends Question
2020
{
21+
/**
22+
* Constructor.
23+
*
24+
* @param string $question The question to ask to the user
25+
* @param bool $default The default answer to return, true or false
26+
*/
2127
public function __construct($question, $default = true)
2228
{
2329
parent::__construct($question, (bool) $default);
2430

2531
$this->setNormalizer($this->getDefaultNormalizer());
2632
}
2733

34+
/**
35+
* Returns the default answer normalizer.
36+
*
37+
* @return callable
38+
*/
2839
private function getDefaultNormalizer()
2940
{
3041
$default = $this->getDefault();

src/Symfony/Component/Console/Question/Question.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function setHiddenFallback($fallback)
116116
/**
117117
* Gets values for the autocompleter.
118118
*
119-
* @return null|array|Traversable
119+
* @return null|array|\Traversable
120120
*/
121121
public function getAutocompleterValues()
122122
{
@@ -126,7 +126,7 @@ public function getAutocompleterValues()
126126
/**
127127
* Sets values for the autocompleter.
128128
*
129-
* @param null|array|Traversable $values
129+
* @param null|array|\Traversable $values
130130
*
131131
* @return Question The current instance
132132
*
@@ -165,7 +165,7 @@ public function setValidator($validator)
165165
}
166166

167167
/**
168-
* Gets the validator for the question
168+
* Gets the validator for the question.
169169
*
170170
* @return null|callable
171171
*/
@@ -211,9 +211,9 @@ public function getMaxAttempts()
211211
/**
212212
* Sets a normalizer for the response.
213213
*
214-
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
214+
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
215215
*
216-
* @param string|Closure $normalizer
216+
* @param string|\Closure $normalizer
217217
*
218218
* @return Question The current instance
219219
*/
@@ -229,7 +229,7 @@ public function setNormalizer($normalizer)
229229
*
230230
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
231231
*
232-
* @return string|Closure
232+
* @return string|\Closure
233233
*/
234234
public function getNormalizer()
235235
{

src/Symfony/Component/EventDispatcher/Event.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
* You can call the method stopPropagation() to abort the execution of
2121
* further listeners in your event listener.
2222
*
23-
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
24-
* @author Jonathan Wage <jonwage@gmail.com>
25-
* @author Roman Borschel <roman@code-factory.org>
26-
* @author Bernhard Schussek <bschussek@gmail.com>
23+
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
24+
* @author Jonathan Wage <jonwage@gmail.com>
25+
* @author Roman Borschel <roman@code-factory.org>
26+
* @author Bernhard Schussek <bschussek@gmail.com>
2727
*
2828
* @api
2929
*/

0 commit comments

Comments
 (0)