From 9b35449216a6f66188f9b17851ee57fe86c82e18 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Mon, 2 May 2016 12:14:36 +0100 Subject: [PATCH 1/8] [console][table] adjust width of colspanned cell. --- .../Component/Console/Helper/Table.php | 16 ++++-- .../Console/Tests/Helper/TableTest.php | 56 ++++++++++--------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 3823e9c4f6..f0445e118d 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -521,6 +521,18 @@ class Table continue; } + foreach ($row as $i => $cell) { + if ($cell instanceof TableCell) { + $textLength = strlen($cell); + if ($textLength > 0) { + $contentColumns = str_split($cell, ceil($textLength / $cell->getColspan())); + foreach ($contentColumns as $position => $content) { + $row[$i + $position] = $content; + } + } + } + } + $lengths[] = $this->getCellWidth($row, $column); } @@ -550,10 +562,6 @@ class Table if (isset($row[$column])) { $cell = $row[$column]; $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell); - if ($cell instanceof TableCell && $cell->getColspan() > 1) { - // we assume that cell value will be across more than one column. - $cellWidth = $cellWidth / $cell->getColspan(); - } return $cellWidth; } diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index ab562fdb57..c933ff6a69 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -269,21 +269,27 @@ TABLE '9971-5-0210-0', new TableCell("A Tale of \nTwo Cities", array('colspan' => 2)), ), + new TableSeparator(), + array( + new TableCell('Cupiditate dicta atque porro, tempora exercitationem modi animi nulla nemo vel nihil!', array('colspan' => 3)), + ), ), 'default', << Date: Fri, 13 May 2016 09:29:13 +0200 Subject: [PATCH 2/8] Updated the link to the list of currency codes --- src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 7118a03515..d16f96ee58 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -308,7 +308,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) { From 7101cab29f7ccd95eb96a0c258a11a36d05c3cb7 Mon Sep 17 00:00:00 2001 From: "Issei.M" Date: Wed, 11 May 2016 01:50:58 +0900 Subject: [PATCH 3/8] [2.3] [Form] Modified iterator_to_array's 2nd parameter to false in ViolationMapper --- .../ViolationMapper/ViolationMapper.php | 8 ++--- .../ViolationMapper/ViolationMapperTest.php | 29 +++++++++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php index bef225c422..5cc6b65d20 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php @@ -161,9 +161,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()) { @@ -188,7 +186,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; @@ -197,7 +195,7 @@ class ViolationMapper implements ViolationMapperInterface continue; } - unset($children[$key]); + unset($children[$i]); } $it->next(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index f6ad34eccb..222c36bdd5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -1477,22 +1477,39 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase public function testBacktrackIfSeveralSubFormsWithSamePropertyPath() { - $violation = $this->getConstraintViolation('data.address[street]'); $parent = $this->getForm('parent'); $child1 = $this->getForm('subform1', 'address'); $child2 = $this->getForm('subform2', 'address'); - $grandChild = $this->getForm('street'); + $child3 = $this->getForm('subform3', null, null, array(), true); + $child4 = $this->getForm('subform4', null, null, array(), true); + $grandChild1 = $this->getForm('street'); + $grandChild2 = $this->getForm('street', '[sub_address1_street]'); + $grandChild3 = $this->getForm('street', '[sub_address2_street]'); $parent->add($child1); $parent->add($child2); - $child2->add($grandChild); + $parent->add($child3); + $parent->add($child4); + $child2->add($grandChild1); + $child3->add($grandChild2); + $child4->add($grandChild3); - $this->mapper->mapViolation($violation, $parent); + $parent->submit(array()); + + $violation1 = $this->getConstraintViolation('data.address[street]'); + $violation2 = $this->getConstraintViolation('data[sub_address1_street]'); + $violation3 = $this->getConstraintViolation('data[sub_address2_street]'); + $this->mapper->mapViolation($violation1, $parent); + $this->mapper->mapViolation($violation2, $parent); + $this->mapper->mapViolation($violation3, $parent); - // The error occurred on the child of the second form with the same path $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); $this->assertCount(0, $child1->getErrors(), $child1->getName().' should not have an error, but has one'); $this->assertCount(0, $child2->getErrors(), $child2->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChild->getName().' should have an error, but has none'); + $this->assertCount(0, $child3->getErrors(), $child3->getName().' should not have an error, but has one'); + $this->assertCount(0, $child4->getErrors(), $child4->getName().' should not have an error, but has one'); + $this->assertEquals(array($this->getFormError($violation1, $grandChild1)), $grandChild1->getErrors(), $grandChild1->getName().' should have an error, but has none'); + $this->assertEquals(array($this->getFormError($violation2, $grandChild2)), $grandChild2->getErrors(), $grandChild2->getName().' should have an error, but has none'); + $this->assertEquals(array($this->getFormError($violation3, $grandChild3)), $grandChild3->getErrors(), $grandChild3->getName().' should have an error, but has none'); } } From 94b9e449934084ac4bfd9ab94d2d626a2d0aad16 Mon Sep 17 00:00:00 2001 From: Daniel Espendiller Date: Fri, 6 May 2016 13:34:38 +0200 Subject: [PATCH 4/8] Add SplFileInfo array doc on Finder iterator methods so that IDE will know what it returns --- src/Symfony/Component/Finder/Finder.php | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 51b8183023..1b13509f63 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -171,7 +171,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() { @@ -183,7 +183,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() { @@ -202,7 +202,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 @@ -226,7 +226,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 @@ -250,7 +250,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 */ @@ -266,7 +266,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 (string or regexp) * - * @return Finder The current Finder instance + * @return Finder|SplFileInfo[] The current Finder instance * * @see FilecontentFilterIterator */ @@ -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 */ @@ -331,7 +331,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 */ @@ -354,7 +354,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 */ @@ -374,7 +374,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 @@ -391,7 +391,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 */ @@ -407,7 +407,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 */ @@ -427,7 +427,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 */ @@ -467,7 +467,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 */ @@ -483,7 +483,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 */ @@ -499,7 +499,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 */ @@ -517,7 +517,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 */ @@ -537,7 +537,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 */ @@ -555,7 +555,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 */ @@ -574,7 +574,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 */ @@ -588,7 +588,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() { @@ -604,7 +604,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) { @@ -618,7 +618,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 */ @@ -679,7 +679,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. */ From 80300f52d485c6e77dcc675c20b2ad42838a5d86 Mon Sep 17 00:00:00 2001 From: danionut90 Date: Wed, 4 May 2016 22:31:11 +0300 Subject: [PATCH 5/8] added StaticVerionStrategyTest --- .../StaticVersionStrategyTest.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php new file mode 100644 index 0000000000..77958ce2ca --- /dev/null +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php @@ -0,0 +1,43 @@ + + * + * 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'), + ); + } +} From 31285c22fa0f60414b5723cd8918fdd5af039089 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 25 Apr 2016 19:03:00 +0200 Subject: [PATCH 6/8] [Console][#18619] Prevent fatal error when calling Command#getHelper() without helperSet Use Command::setHelperSet rather than Command#setHelperSet in exception msg Simplify exception message Add DidYouForget to exception msg --- src/Symfony/Component/Console/Command/Command.php | 5 +++++ .../Component/Console/Tests/Command/CommandTest.php | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 3d3f2c14d7..e4b8fb0aa7 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -537,10 +537,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); } diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index baa7c7e3df..c066bebf2e 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -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(); From fa99fbd7cf8b4283662ea39e025487c75d528098 Mon Sep 17 00:00:00 2001 From: dasmfm <2@borisklimenko.ru> Date: Wed, 27 Apr 2016 11:40:10 +0300 Subject: [PATCH 7/8] Update HTTP statuses list --- src/Symfony/Component/HttpFoundation/Response.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 37e9c9f057..f50bc875e8 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -53,7 +53,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 2012-02-13). + * (last updated 2016-03-01). * * Unless otherwise noted, the status code is defined in RFC2616. * @@ -101,6 +101,7 @@ class Response 416 => 'Requested 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 From 4a065b44dd9056a4173b1a2e9cc2fb95d078cfdb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 13 May 2016 10:31:27 -0500 Subject: [PATCH 8/8] added missing constant in Response --- src/Symfony/Component/HttpFoundation/Response.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index e6373b8ef2..62b67cce85 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -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