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.
This commit is contained in:
Fabien Potencier 2016-05-13 10:38:45 -05:00
commit 1253b1d344
7 changed files with 90 additions and 32 deletions

View File

@ -0,0 +1,43 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Asset\Tests\VersionStrategy;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
class StaticVersionStrategyTest extends \PHPUnit_Framework_TestCase
{
public function testGetVersion()
{
$version = 'v1';
$path = 'test-path';
$staticVersionStrategy = new StaticVersionStrategy($version);
$this->assertEquals($version, $staticVersionStrategy->getVersion($path));
}
/**
* @dataProvider getConfigs
*/
public function testApplyVersion($path, $version, $format)
{
$staticVersionStrategy = new StaticVersionStrategy($version, $format);
$formatted = sprintf($format ?: '%s?%s', $path, $version);
$this->assertEquals($formatted, $staticVersionStrategy->applyVersion($path));
}
public function getConfigs()
{
return array(
array('test-path', 'v1', null),
array('test-path', 'v2', '%s?test%s'),
);
}
}

View File

@ -608,10 +608,15 @@ class Command
*
* @return mixed The helper value
*
* @throws LogicException if no HelperSet is defined
* @throws InvalidArgumentException if the helper is not defined
*/
public function getHelper($name)
{
if (null === $this->helperSet) {
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));
}
return $this->helperSet->get($name);
}

View File

@ -173,6 +173,16 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Cannot retrieve helper "formatter" because there is no HelperSet defined.
*/
public function testGetHelperWithoutHelperSet()
{
$command = new \TestCommand();
$command->getHelper('formatter');
}
public function testMergeApplicationDefinition()
{
$application1 = new Application();

View File

@ -192,7 +192,7 @@ class Finder implements \IteratorAggregate, \Countable
/**
* Restricts the matching to directories only.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*/
public function directories()
{
@ -204,7 +204,7 @@ class Finder implements \IteratorAggregate, \Countable
/**
* Restricts the matching to files only.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*/
public function files()
{
@ -223,7 +223,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param int $level The depth level expression
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see DepthRangeFilterIterator
* @see NumberComparator
@ -247,7 +247,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $date A date range string
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see strtotime
* @see DateRangeFilterIterator
@ -271,7 +271,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $pattern A pattern (a regexp, a glob, or a string)
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see FilenameFilterIterator
*/
@ -287,7 +287,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $pattern A pattern (a regexp, a glob, or a string)
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see FilenameFilterIterator
*/
@ -308,7 +308,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $pattern A pattern (string or regexp)
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see FilecontentFilterIterator
*/
@ -329,7 +329,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $pattern A pattern (string or regexp)
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see FilecontentFilterIterator
*/
@ -352,7 +352,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $pattern A pattern (a regexp or a string)
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see FilenameFilterIterator
*/
@ -375,7 +375,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $pattern A pattern (a regexp or a string)
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see FilenameFilterIterator
*/
@ -395,7 +395,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string $size A size range string
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SizeRangeFilterIterator
* @see NumberComparator
@ -412,7 +412,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string|array $dirs A directory path or an array of directories
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see ExcludeDirectoryFilterIterator
*/
@ -428,7 +428,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param bool $ignoreDotFiles Whether to exclude "hidden" files or not
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see ExcludeDirectoryFilterIterator
*/
@ -448,7 +448,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param bool $ignoreVCS Whether to exclude VCS files or not
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see ExcludeDirectoryFilterIterator
*/
@ -488,7 +488,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param \Closure $closure An anonymous function
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SortableIterator
*/
@ -504,7 +504,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* This can be slow as all the matching files and directories must be retrieved for comparison.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SortableIterator
*/
@ -520,7 +520,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* This can be slow as all the matching files and directories must be retrieved for comparison.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SortableIterator
*/
@ -538,7 +538,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* This can be slow as all the matching files and directories must be retrieved for comparison.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SortableIterator
*/
@ -558,7 +558,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* This can be slow as all the matching files and directories must be retrieved for comparison.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SortableIterator
*/
@ -576,7 +576,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* This can be slow as all the matching files and directories must be retrieved for comparison.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see SortableIterator
*/
@ -595,7 +595,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param \Closure $closure An anonymous function
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @see CustomFilterIterator
*/
@ -609,7 +609,7 @@ class Finder implements \IteratorAggregate, \Countable
/**
* Forces the following of symlinks.
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*/
public function followLinks()
{
@ -625,7 +625,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param bool $ignore
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*/
public function ignoreUnreadableDirs($ignore = true)
{
@ -639,7 +639,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param string|array $dirs A directory path or an array of directories
*
* @return Finder The current Finder instance
* @return Finder|SplFileInfo[] The current Finder instance
*
* @throws \InvalidArgumentException if one of the directories does not exist
*/
@ -700,7 +700,7 @@ class Finder implements \IteratorAggregate, \Countable
*
* @param mixed $iterator
*
* @return Finder The finder
* @return Finder|SplFileInfo[] The finder
*
* @throws \InvalidArgumentException When the given argument is not iterable.
*/

View File

@ -162,9 +162,7 @@ class ViolationMapper implements ViolationMapperInterface
}
}
$children = iterator_to_array(new \RecursiveIteratorIterator(
new InheritDataAwareIterator($form)
));
$children = iterator_to_array(new \RecursiveIteratorIterator(new InheritDataAwareIterator($form)), false);
while ($it->valid()) {
if ($it->isIndex()) {
@ -189,7 +187,7 @@ class ViolationMapper implements ViolationMapperInterface
}
/** @var FormInterface $child */
foreach ($children as $key => $child) {
foreach ($children as $i => $child) {
$childPath = (string) $child->getPropertyPath();
if ($childPath === $chunk) {
$target = $child;
@ -198,7 +196,7 @@ class ViolationMapper implements ViolationMapperInterface
continue;
}
unset($children[$key]);
unset($children[$i]);
}
$it->next();

View File

@ -59,6 +59,7 @@ class Response
const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
const HTTP_EXPECTATION_FAILED = 417;
const HTTP_I_AM_A_TEAPOT = 418; // RFC2324
const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540
const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
const HTTP_LOCKED = 423; // RFC4918
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
@ -115,7 +116,7 @@ class Response
*
* The list of codes is complete according to the
* {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry}
* (last updated 2015-05-19).
* (last updated 2016-03-01).
*
* Unless otherwise noted, the status code is defined in RFC2616.
*
@ -162,6 +163,7 @@ class Response
416 => 'Range Not Satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot', // RFC2324
421 => 'Misdirected Request', // RFC7540
422 => 'Unprocessable Entity', // RFC4918
423 => 'Locked', // RFC4918
424 => 'Failed Dependency', // RFC4918

View File

@ -328,7 +328,7 @@ class NumberFormatter
* @return string The formatted currency value
*
* @see http://www.php.net/manual/en/numberformatter.formatcurrency.php
* @see http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm
* @see https://en.wikipedia.org/wiki/ISO_4217#Active_codes
*/
public function formatCurrency($value, $currency)
{