8000 Merge branch '2.7' into 2.8 · symfony/symfony@1253b1d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1253b1d

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: added missing constant in Response Update HTTP statuses list [Console][#18619] Prevent fatal error when calling Command#getHelper() without helperSet added StaticVerionStrategyTest Add SplFileInfo array doc on Finder iterator methods so that IDE will know what it returns [2.3] [Form] Modified iterator_to_array's 2nd parameter to false in ViolationMapper Updated the link to the list of currency codes [console][table] adjust width of colspanned cell.
2 parents c96d76d + 4a065b4 commit 1253b1d

File tree

7 files changed

+90
-32
lines changed

7 files changed

+90
-32
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Asset\Tests\VersionStrategy;
13+
14+
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
15+
16+
class StaticVersionStrategyTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testGetVersion()
19+
{
20+
$version = 'v1';
21+
$path = 'test-path';
22+
$staticVersionStrategy = new StaticVersionStrategy($version);
23+
$this->assertEquals($version, $staticVersionStrategy->getVersion($path));
24+
}
25+
26+
/**
27+
* @dataProvider getConfigs
28+
*/
29+
public function testApplyVersion($path, $version, $format)
30+
{
31+
$staticVersionStrategy = new StaticVersionStrategy($version, $format);
32+
$formatted = sprintf($format ?: '%s?%s', $path, $version);
33+
$this->assertEquals($formatted, $staticVersionStrategy->applyVersion($path));
34+
}
35+
36+
public function getConfigs()
37+
{
38+
return array(
39+
array('test-path', 'v1', null),
40+
array('test-path', 'v2', '%s?test%s'),
41+
);
42+
}
43+
}

src/Symfony/Component/Console/Command/Command.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,15 @@ public function getUsages()
608608
*
609609
* @return mixed The helper value
610610
*
611+
* @throws LogicException if no HelperSet is defined
611612
* @throws InvalidArgumentException if the helper is not defined
612613
*/
613614
public function getHelper($name)
614615
{
616+
if (null === $this->helperSet) {
617+
throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
618+
}
619+
615620
return $this->helperSet->get($name);
616621
}
617622

src/Symfony/Component/Console/Tests/Command/CommandTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ public function testGetHelper()
173173
$this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper');
174174
}
175175

176+
/**
177+
* @expectedException \LogicException
178+
* @expectedExceptionMessage Cannot retrieve helper "formatter" because there is no HelperSet defined.
179+
*/
180+
public function testGetHelperWithoutHelperSet()
181+
{
182+
$command = new \TestCommand();
183+
$command->getHelper('formatter');
184+
}
185+
176186
public function testMergeApplicationDefinition()
177187
{
178188
$application1 = new Application();

src/Symfony/Component/Finder/Finder.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function getAdapters()
192192
/**
193193
* Restricts the matching to directories only.
194194
*
195-
* @return Finder The current Finder instance
195+
* @return Finder|SplFileInfo[] The current Finder instance
196196
*/
197197
public function directories()
198198
{
@@ -204,7 +204,7 @@ public function directories()
204204
/**
205205
* Restricts the matching to files only.
206206
*
207-
* @return Finder The current Finder instance
207+
* @return Finder|SplFileInfo[] The current Finder instance
208208
*/
209209
public function files()
210210
{
@@ -223,7 +223,7 @@ public function files()
223223
*
224224
* @param int $level The depth level expression
225225
*
226-
* @return Finder The current Finder instance
226+
* @return Finder|SplFileInfo[] The current Finder instance
227227
*
228228
* @see DepthRangeFilterIterator
229229
* @see NumberComparator
@@ -247,7 +247,7 @@ public function depth($level)
247247
*
248248
* @param string $date A date range string
249249
*
250-
* @return Finder The current Finder instance
250+
* @return Finder|SplFileInfo[] The current Finder instance
251251
*
252252
* @see strtotime
253253
* @see DateRangeFilterIterator
@@ -271,7 +271,7 @@ public function date($date)
271271
*
272272
* @param string $pattern A pattern (a regexp, a glob, or a string)
273273
*
274-
* @return Finder The current Finder instance
274+
* @return Finder|SplFileInfo[] The current Finder instance
275275
*
276276
* @see FilenameFilterIterator
277277
*/
@@ -287,7 +287,7 @@ public function name($pattern)
287287
*
288288
* @param string $pattern A pattern (a regexp, a glob, or a string)
289289
*
290-
* @return Finder The current Finder instance
290+
* @return Finder|SplFileInfo[] The current Finder instance
291291
*
292292
* @see FilenameFilterIterator
293293
*/
@@ -308,7 +308,7 @@ public function notName($pattern)
308308
*
309309
* @param string $pattern A pattern (string or regexp)
310310
*
311-
* @return Finder The current Finder instance
311+
* @return Finder|SplFileInfo[] The current Finder instance
312312
*
313313
* @see FilecontentFilterIterator
314314
*/
@@ -329,7 +329,7 @@ public function contains($pattern)
329329
*
330330
* @param string $pattern A pattern (string or regexp)
331331
*
332-
* @return Finder The current Finder instance
332+
* @return Finder|SplFileInfo[] The current Finder instance
333333
*
334334
* @see FilecontentFilterIterator
335335
*/
@@ -352,7 +352,7 @@ public function notContains($pattern)
352352
*
353353
* @param string $pattern A pattern (a regexp or a string)
354354
*
355-
* @return Finder The current Finder instance
355+
* @return Finder|SplFileInfo[] The current Finder instance
356356
*
357357
* @see FilenameFilterIterator
358358
*/
@@ -375,7 +375,7 @@ public function path($pattern)
375375
*
376376
* @param string $pattern A pattern (a regexp or a string)
377377
*
378-
* @return Finder The current Finder instance
378+
* @return Finder|SplFileInfo[] The current Finder instance
379379
*
380380
* @see FilenameFilterIterator
381381
*/
@@ -395,7 +395,7 @@ public function notPath($pattern)
395395
*
396396
* @param string $size A size range string
397397
*
398-
* @return Finder The current Finder instance
398+
* @return Finder|SplFileInfo[] The current Finder instance
399399
*
400400
* @see SizeRangeFilterIterator
401401
* @see NumberComparator
@@ -412,7 +412,7 @@ public function size($size)
412412
*
413413
* @param string|array $dirs A directory path or an array of directories
414414
*
415-
* @return Finder The current Finder instance
415+
* @return Finder|SplFileInfo[] The current Finder instance
416416
*
417417
* @see ExcludeDirectoryFilterIterator
418418
*/
@@ -428,7 +428,7 @@ public function exclude($dirs)
428428
*
429429
* @param bool $ignoreDotFiles Whether to exclude "hidden" files or not
430430
*
431-
* @return Finder The current Finder instance
431+
* @return Finder|SplFileInfo[] The current Finder instance
432432
*
433433
* @see ExcludeDirectoryFilterIterator
434434
*/
@@ -448,7 +448,7 @@ public function ignoreDotFiles($ignoreDotFiles)
448448
*
449449
* @param bool $ignoreVCS Whether to exclude VCS files or not
450450
*
451-
* @return Finder The current Finder instance
451+
* @return Finder|SplFileInfo[] The current Finder instance
452452
*
453453
* @see ExcludeDirectoryFilterIterator
454454
*/
@@ -488,7 +488,7 @@ public static function addVCSPattern($pattern)
488488
*
489489
* @param \Closure $closure An anonymous function
490490
*
491-
* @return Finder The current Finder instance
491+
* @return Finder|SplFileInfo[] The current Finder instance
492492
*
493493
* @see SortableIterator
494494
*/
@@ -504,7 +504,7 @@ public function sort(\Closure $closure)
504504
*
505505
* This can be slow as all the matching files and directories must be retrieved for comparison.
506506
*
507-
* @return Finder The current Finder instance
507+
* @return Finder|SplFileInfo[] The current Finder instance
508508
*
509509
* @see SortableIterator
510510
*/
@@ -520,7 +520,7 @@ public function sortByName()
520520
*
521521
* This can be slow as all the matching files and directories must be retrieved for comparison.
522522
*
523-
* @return Finder The current Finder instance
523+
* @return Finder|SplFileInfo[] The current Finder instance
524524
*
525525
* @see SortableIterator
526526
*/
@@ -538,7 +538,7 @@ public function sortByType()
538538
*
539539
* This can be slow as all the matching files and directories must be retrieved for comparison.
540540
*
541-
* @return Finder The current Finder instance
541+
* @return Finder|SplFileInfo[] The current Finder instance
542542
*
543543
* @see SortableIterator
544544
*/
@@ -558,7 +558,7 @@ public function sortByAccessedTime()
558558
*
559559
* This can be slow as all the matching files and directories must be retrieved for comparison.
560560
*
561-
* @return Finder The current Finder instance
561+
* @return Finder|SplFileInfo[] The current Finder instance
562562
*
563563
* @see SortableIterator
564564
*/
@@ -576,7 +576,7 @@ public function sortByChangedTime()
576576
*
577577
* This can be slow as all the matching files and directories must be retrieved for comparison.
578578
*
579-
* @return Finder The current Finder instance
579+
* @return Finder|SplFileInfo[] The current Finder instance
580580
*
581581
* @see SortableIterator
582582
*/
@@ -595,7 +595,7 @@ public function sortByModifiedTime()
595595
*
596596
* @param \Closure $closure An anonymous function
597597
*
598-
* @return Finder The current Finder instance
598+
* @return Finder|SplFileInfo[] The current Finder instance
599599
*
600600
* @see CustomFilterIterator
601601
*/
@@ -609,7 +609,7 @@ public function filter(\Closure $closure)
609609
/**
610610
* Forces the following of symlinks.
611611
*
612-
* @return Finder The current Finder instance
612+
* @return Finder|SplFileInfo[] The current Finder instance
613613
*/
614614
public function followLinks()
615615
{
@@ -625,7 +625,7 @@ public function followLinks()
625625
*
626626
* @param bool $ignore
627627
*
628-
* @return Finder The current Finder instance
628+
* @return Finder|SplFileInfo[] The current Finder instance
629629
*/
630630
public function ignoreUnreadableDirs($ignore = true)
631631
{
@@ -639,7 +639,7 @@ public function ignoreUnreadableDirs($ignore = true)
639639
*
640640
* @param string|array $dirs A directory path or an array of directories
641641
*
642-
* @return Finder The current Finder instance
642+
* @return Finder|SplFileInfo[] The current Finder instance
643643
*
644644
* @throws \InvalidArgumentException if one of the directories does not exist
645645
*/
@@ -700,7 +700,7 @@ public function getIterator()
700700
*
701701
* @param mixed $iterator
702702
*
703-
* @return Finder The finder
703+
* @return Finder|SplFileInfo[] The finder
704704
*
705705
* @throws \InvalidArgumentException When the given argument is not iterable.
706706
*/

src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $
162162
}
163163
}
164164

165-
$children = iterator_to_array(new \RecursiveIteratorIterator(
166-
new InheritDataAwareIterator($form)
167-
));
165+
$children = iterator_to_array(new \RecursiveIteratorIterator(new InheritDataAwareIterator($form)), false);
168166

169167
while ($it->valid()) {
170168
if ($it->isIndex()) {
@@ -189,7 +187,7 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $
189187
}
190188

191189
/** @var FormInterface $child */
192-
foreach ($children as $key => $child) {
190+
foreach ($children as $i => $child) {
193191
$childPath = (string) $child->getPropertyPath();
194192
if ($childPath === $chunk) {
195193
$target = $child;
@@ -198,7 +196,7 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $
198196
continue;
199197
}
200198

201-
unset($children[$key]);
199+
unset($children[$i]);
202200
}
203201

204202
$it->next();

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Response
5959
const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
6060
const HTTP_EXPECTATION_FAILED = 417;
6161
const HTTP_I_AM_A_TEAPOT = 418; // RFC2324
62+
const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540
6263
const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
6364
const HTTP_LOCKED = 423; // RFC4918
6465
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
@@ -115,7 +116,7 @@ class Response
115116
*
116117
* The list of codes is complete according to the
117118
* {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry}
118-
* (last updated 2015-05-19).
119+
* (last updated 2016-03-01).
119120
*
120121
* Unless otherwise noted, the status code is defined in RFC2616.
121122
*
@@ -162,6 +163,7 @@ class Response
162163
416 => 'Range Not Satisfiable',
163164
417 => 'Expectation Failed',
164165
418 => 'I\'m a teapot', // RFC2324
166+
421 => 'Misdirected Request', // RFC7540
165167
422 => 'Unprocessable Entity', // RFC4918
166168
423 => 'Locked', // RFC4918
167169
424 => 'Failed Dependency', // RFC4918

src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public static function create($locale = 'en', $style = null, $pattern = null)
328328
* @return string The formatted currency value
329329
*
330330
* @see http://www.php.net/manual/en/numberformatter.formatcurrency.php
331-
* @see http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm
331+
* @see https://en.wikipedia.org/wiki/ISO_4217#Active_codes
332332
*/
333333
public function formatCurrency($value, $currency)
334334
{

0 commit comments

Comments
 (0)
0