From fe586acd92d67be07f269d0b48e0046cfe62efe8 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 27 Feb 2018 17:11:57 +0100 Subject: [PATCH 01/32] [Config] Backport string|null api for node names --- src/Symfony/Component/Config/Definition/BaseNode.php | 4 ++-- .../Component/Config/Definition/Builder/NodeBuilder.php | 4 ++-- .../Component/Config/Definition/Builder/NodeDefinition.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index 2e346d7907..8568bf182b 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -33,8 +33,8 @@ abstract class BaseNode implements NodeInterface protected $attributes = array(); /** - * @param string $name The name of the node - * @param NodeInterface $parent The parent of this node + * @param string|null $name The name of the node + * @param NodeInterface|null $parent The parent of this node * * @throws \InvalidArgumentException if the name contains a period */ diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php index 152a497b14..1fac66fd37 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php @@ -143,8 +143,8 @@ class NodeBuilder implements NodeParentInterface /** * Creates a child node. * - * @param string $name The name of the node - * @param string $type The type of the node + * @param string|null $name The name of the node + * @param string $type The type of the node * * @return NodeDefinition The child node * diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 3c2610b5d1..8546fcd5ef 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -36,7 +36,7 @@ abstract class NodeDefinition implements NodeParentInterface protected $attributes = array(); /** - * @param string $name The name of the node + * @param string|null $name The name of the node * @param NodeParentInterface|null $parent The parent */ public function __construct($name, NodeParentInterface $parent = null) From dc399138351361759ad3114fcabfdca49e3c1c4d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 10:31:53 -0800 Subject: [PATCH 02/32] updated CHANGELOG for 2.7.43 --- CHANGELOG-2.7.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG-2.7.md b/CHANGELOG-2.7.md index fbc5fec755..2d7bfd9f74 100644 --- a/CHANGELOG-2.7.md +++ b/CHANGELOG-2.7.md @@ -7,6 +7,10 @@ in 2.7 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.7.0...v2.7.1 +* 2.7.43 (2018-03-05) + + * bug #26368 [WebProfilerBundle] Fix Debug toolbar breaks app (xkobal) + * 2.7.42 (2018-02-28) * bug #26338 [Debug] Keep previous errors of Error instances (Philipp91) From 4683c3f960fef9ad37be447335a7db0a4452ea60 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 10:31:59 -0800 Subject: [PATCH 03/32] update CONTRIBUTORS for 2.7.43 --- CONTRIBUTORS.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0b1fbb47f3..1034172772 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -43,11 +43,11 @@ Symfony is the result of the work of many people who made the code better - Diego Saint Esteben (dosten) - Alexandre Salomé (alexandresalome) - William Durand (couac) + - Hamza Amrouche (simperfit) - ornicar - Francis Besset (francisbesset) - Iltar van der Berg (kjarli) - stealth35 ‏ (stealth35) - - Hamza Amrouche (simperfit) - Alexander Mols (asm89) - Yonel Ceruto (yonelceruto) - Bulat Shakirzyanov (avalanche123) @@ -57,8 +57,8 @@ Symfony is the result of the work of many people who made the code better - Henrik Bjørnskov (henrikbjorn) - Miha Vrhovnik - Diego Saint Esteben (dii3g0) - - Dany Maillard (maidmaid) - Pierre du Plessis (pierredup) + - Dany Maillard (maidmaid) - Konstantin Kudryashov (everzet) - Kevin Bond (kbond) - Bilal Amarni (bamarni) @@ -66,6 +66,7 @@ Symfony is the result of the work of many people who made the code better - Jérémy DERUSSÉ (jderusse) - Florin Patan (florinpatan) - Samuel ROZE (sroze) + - Tobias Nyholm (tobias) - Gábor Egyed (1ed) - Michel Weimerskirch (mweimerskirch) - Andrej Hudec (pulzarraider) @@ -75,7 +76,6 @@ Symfony is the result of the work of many people who made the code better - Titouan Galopin (tgalopin) - Konstantin Myakshin (koc) - Christian Raue - - Tobias Nyholm (tobias) - Arnout Boks (aboks) - Deni - Henrik Westphal (snc) @@ -200,6 +200,7 @@ Symfony is the result of the work of many people who made the code better - Matthieu Bontemps (mbontemps) - apetitpa - Pierre Minnieur (pminnieur) + - Jannik Zschiesche (apfelbox) - fivestar - Dominique Bongiraud - Jeremy Livingston (jeremylivingston) @@ -224,7 +225,6 @@ Symfony is the result of the work of many people who made the code better - Marcel Beerta (mazen) - gadelat (gadelat) - Loïc Faugeron - - Jannik Zschiesche (apfelbox) - Hidde Wieringa (hiddewie) - Marco Pivetta (ocramius) - Rob Frawley 2nd (robfrawley) @@ -697,6 +697,7 @@ Symfony is the result of the work of many people who made the code better - Nykopol (nykopol) - Jordan Deitch - Casper Valdemar Poulsen + - Remon van de Kamp - Josiah (josiah) - Joschi Kuphal - John Bohn (jbohn) @@ -736,6 +737,7 @@ Symfony is the result of the work of many people who made the code better - Adrien Lucas (adrienlucas) - Zhuravlev Alexander (scif) - James Michael DuPont + - Xavier HAUSHERR - Tom Klingenberg - Christopher Hall (mythmakr) - Patrick Dawkins (pjcdawkins) @@ -1102,7 +1104,6 @@ Symfony is the result of the work of many people who made the code better - Pierre Tachoire (krichprollsch) - Marc J. Schmidt (marcjs) - Marco Jantke - - Remon van de Kamp - Saem Ghani - Clément LEFEBVRE - Conrad Kleinespel @@ -1225,7 +1226,6 @@ Symfony is the result of the work of many people who made the code better - Sebastian Ionescu - Thomas Ploch - Simon Neidhold - - Xavier HAUSHERR - Valentin VALCIU - Jeremiah VALERIE - Kevin Dew @@ -1573,6 +1573,7 @@ Symfony is the result of the work of many people who made the code better - Vladimir Chernyshev (volch) - Yorkie Chadwick (yorkie76) - GuillaumeVerdon + - Philipp Keck - Ondrej Mirtes - akimsko - Youpie @@ -1630,6 +1631,7 @@ Symfony is the result of the work of many people who made the code better - Jordan Hoff - znerol - Christian Eikermann + - Kai Eichinger - Antonio Angelino - Matt Fields - Niklas Keller From 4d96c086a000f562fb5563cc11d84130acf21abc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 10:32:00 -0800 Subject: [PATCH 04/32] updated VERSION for 2.7.43 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index fb24b4d650..a27a875f18 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.43-DEV'; + const VERSION = '2.7.43'; const VERSION_ID = 20743; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 43; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 1616d368d9f633df000a32c04d10b1bad67d67f4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:05:22 -0800 Subject: [PATCH 05/32] bumped Symfony version to 2.7.44 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a27a875f18..ff57c10b47 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.43'; - const VERSION_ID = 20743; + const VERSION = '2.7.44-DEV'; + const VERSION_ID = 20744; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 43; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 44; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 7fc8041bcb487de155cc99c1f6b2d6b88b49ccfb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:06:21 -0800 Subject: [PATCH 06/32] updated CHANGELOG for 2.8.36 --- CHANGELOG-2.8.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG-2.8.md b/CHANGELOG-2.8.md index 239dbb5c83..9f4767672e 100644 --- a/CHANGELOG-2.8.md +++ b/CHANGELOG-2.8.md @@ -7,6 +7,10 @@ in 2.8 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.8.0...v2.8.1 +* 2.8.36 (2018-03-05) + + * bug #26368 [WebProfilerBundle] Fix Debug toolbar breaks app (xkobal) + * 2.8.35 (2018-03-01) * bug #26338 [Debug] Keep previous errors of Error instances (Philipp91) From af393d7663cb24d9f763f620ed36f65482814dcd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:06:26 -0800 Subject: [PATCH 07/32] updated VERSION for 2.8.36 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 52b08bf2bc..2ee1982875 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.36-DEV'; + const VERSION = '2.8.36'; const VERSION_ID = 20836; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 36; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 6e80476d64fbe5ed1a3b0f3ddcce3e5764ccbb75 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:40:00 -0800 Subject: [PATCH 08/32] bumped Symfony version to 2.8.37 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 2ee1982875..cb055f5a67 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.36'; - const VERSION_ID = 20836; + const VERSION = '2.8.37-DEV'; + const VERSION_ID = 20837; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 36; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 37; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 028c9f23667ee02180a49b099bbf74f876cf0114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 6 Mar 2018 23:27:05 +0100 Subject: [PATCH 09/32] [DomCrawler] extract(): fix a bug when the attribute list is empty --- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index cccea633dd..a49bb3930a 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -605,7 +605,7 @@ class Crawler extends \SplObjectStorage } } - $data[] = $count > 1 ? $elements : $elements[0]; + $data[] = 1 === $count ? $elements[0] : $elements; } return $data; diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 3ba9247618..74acfdf8c6 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -369,6 +369,7 @@ EOF $this->assertEquals(array('One', 'Two', 'Three'), $crawler->extract('_text'), '->extract() returns an array of extracted data from the node list'); $this->assertEquals(array(array('One', 'first'), array('Two', ''), array('Three', '')), $crawler->extract(array('_text', 'class')), '->extract() returns an array of extracted data from the node list'); + $this->assertEquals(array(array(), array(), array()), $crawler->extract(array()), '->extract() returns empty arrays if the attribute list is empty'); $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty'); } From 16e86bc0c0e416071fbabbd5f22be0cb115e4364 Mon Sep 17 00:00:00 2001 From: Jakub Kulhan Date: Thu, 8 Mar 2018 00:00:26 +0100 Subject: [PATCH 10/32] [CssSelector] Fix CSS identifiers parsing - they can start with dash --- .../CssSelector/Parser/Tokenizer/TokenizerPatterns.php | 2 +- src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php index b548905fa2..15dfb0eb0e 100644 --- a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php +++ b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php @@ -44,7 +44,7 @@ class TokenizerPatterns $this->nonAsciiPattern = '[^\x00-\x7F]'; $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; - $this->identifierPattern = '(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; + $this->identifierPattern = '-?(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)'; $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)'; $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php index 37a3ef1d58..53b35a9547 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -186,6 +186,7 @@ class ParserTest extends TestCase array('foo:after', 'Element[foo]', 'after'), array('foo::selection', 'Element[foo]', 'selection'), array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'), + array('video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'), ); } From 1debf79430f84d612f1ac0c1b7765f35bf8f1b3a Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 7 Mar 2018 23:32:04 +0000 Subject: [PATCH 11/32] [Intl] Load locale aliases to support alias fallbacks --- src/Symfony/Component/Intl/Intl.php | 6 ++ src/Symfony/Component/Intl/Tests/IntlTest.php | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/Symfony/Component/Intl/Tests/IntlTest.php diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php index 3444c10f83..e552b994fd 100644 --- a/src/Symfony/Component/Intl/Intl.php +++ b/src/Symfony/Component/Intl/Intl.php @@ -15,6 +15,7 @@ use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; use Symfony\Component\Intl\Data\Bundle\Reader\BufferedBundleReader; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; +use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; use Symfony\Component\Intl\ResourceBundle\CurrencyBundle; use Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface; @@ -259,6 +260,11 @@ final class Intl new JsonBundleReader(), self::BUFFER_SIZE )); + $localeDataProvider = new LocaleDataProvider( + self::getDataDirectory().'/'.self::LOCALE_DIR, + self::$entryReader + ); + self::$entryReader->setLocaleAliases($localeDataProvider->getAliases()); } return self::$entryReader; diff --git a/src/Symfony/Component/Intl/Tests/IntlTest.php b/src/Symfony/Component/Intl/Tests/IntlTest.php new file mode 100644 index 0000000000..d77655b77d --- /dev/null +++ b/src/Symfony/Component/Intl/Tests/IntlTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl\Tests; + +use Symfony\Component\Intl\Intl; +use PHPUnit\Framework\TestCase; + +class IntlTest extends TestCase +{ + /** + * @requires extension intl + */ + public function testIsExtensionLoadedChecksIfIntlExtensionIsLoaded() + { + $this->assertTrue(Intl::isExtensionLoaded()); + } + + public function testGetCurrencyBundleCreatesTheCurrencyBundle() + { + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface', Intl::getCurrencyBundle()); + } + + public function testGetLanguageBundleCreatesTheLanguageBundle() + { + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface', Intl::getLanguageBundle()); + } + + public function testGetLocaleBundleCreatesTheLocaleBundle() + { + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface', Intl::getLocaleBundle()); + } + + public function testGetRegionBundleCreatesTheRegionBundle() + { + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface', Intl::getLocaleBundle()); + } + + public function testGetIcuVersionReadsTheVersionOfInstalledIcuLibrary() + { + $this->assertStringMatchesFormat('%d.%d', Intl::getIcuVersion()); + } + + public function testGetIcuDataVersionReadsTheVersionOfInstalledIcuData() + { + $this->assertStringMatchesFormat('%d.%d', Intl::getIcuDataVersion()); + } + + public function testGetIcuStubVersionReadsTheVersionOfBundledStubs() + { + $this->assertStringMatchesFormat('%d.%d', Intl::getIcuStubVersion()); + } + + public function testGetDataDirectoryReturnsThePathToIcuData() + { + $this->assertTrue(is_dir(Intl::getDataDirectory())); + } + + /** + * @requires extension intl + */ + public function testLocaleAliasesAreLoaded() + { + \Locale::setDefault('zh_TW'); + $countryNameZhTw = Intl::getRegionBundle()->getCountryName('AD'); + + \Locale::setDefault('zh_Hant_TW'); + $countryNameHantZhTw = Intl::getRegionBundle()->getCountryName('AD'); + + \Locale::setDefault('zh'); + $countryNameZh = Intl::getRegionBundle()->getCountryName('AD'); + + $this->assertSame($countryNameZhTw, $countryNameHantZhTw, 'zh_TW is an alias to zh_Hant_TW'); + $this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh'); + } +} From f16d99ecfa2c98a41c8ebcd42c69fd27720d634c Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Sat, 10 Mar 2018 10:27:05 +0100 Subject: [PATCH 12/32] Php Inspections (EA Ultimate): address some of one-time used local variables --- src/Symfony/Bridge/Twig/Translation/TwigExtractor.php | 3 +-- src/Symfony/Component/DomCrawler/Crawler.php | 4 +--- .../Component/Form/ChoiceList/LegacyChoiceListAdapter.php | 4 +--- .../Component/Form/Extension/Core/Type/FormType.php | 7 ++++--- .../Validator/EventListener/ValidationListener.php | 4 +--- .../Form/Extension/Validator/ValidatorTypeGuesser.php | 8 ++------ 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index db388ab70b..a921582dba 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -54,8 +54,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface */ public function extract($resource, MessageCatalogue $catalogue) { - $files = $this->extractFiles($resource); - foreach ($files as $file) { + foreach ($this->extractFiles($resource) as $file) { try { $this->extractTemplate(file_get_contents($file->getPathname()), $catalogue); } catch (Error $e) { diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index cccea633dd..a387b5245e 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -1039,8 +1039,6 @@ class Crawler extends \SplObjectStorage */ private function createSubCrawler($nodes) { - $crawler = new static($nodes, $this->uri, $this->baseHref); - - return $crawler; + return new static($nodes, $this->uri, $this->baseHref); } } diff --git a/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php b/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php index 929ef8c290..57ec192e49 100644 --- a/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php +++ b/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php @@ -133,9 +133,7 @@ class LegacyChoiceListAdapter implements ChoiceListInterface $this->values = array(); $this->structuredValues = $this->adaptedList->getValues(); - $innerChoices = $this->adaptedList->getChoices(); - - foreach ($innerChoices as $index => $choice) { + foreach ($this->adaptedList->getChoices() as $index => $choice) { $value = $this->structuredValues[$index]; $this->values[] = $value; $this->choices[$value] = $choice; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index d8e8ff3176..9c5642b116 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -81,6 +81,7 @@ class FormType extends BaseType } } + $formConfig = $form->getConfig(); $view->vars = array_replace($view->vars, array( 'read_only' => $readOnly, 'errors' => $form->getErrors(), @@ -92,9 +93,9 @@ class FormType extends BaseType 'pattern' => isset($options['attr']['pattern']) ? $options['attr']['pattern'] : null, // Deprecated 'size' => null, 'label_attr' => $options['label_attr'], - 'compound' => $form->getConfig()->getCompound(), - 'method' => $form->getConfig()->getMethod(), - 'action' => $form->getConfig()->getAction(), + 'compound' => $formConfig->getCompound(), + 'method' => $formConfig->getMethod(), + 'action' => $formConfig->getAction(), 'submitted' => $form->isSubmitted(), )); } diff --git a/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php b/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php index 4bebce09cd..884bfca9e4 100644 --- a/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php @@ -61,9 +61,7 @@ class ValidationListener implements EventSubscriberInterface if ($form->isRoot()) { // Validate the form in group "Default" - $violations = $this->validator->validate($form); - - foreach ($violations as $violation) { + foreach ($this->validator->validate($form) as $violation) { // Allow the "invalid" constraint to be put onto // non-synchronized forms // ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0) diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 90dadd08d9..f40347d2a1 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -261,12 +261,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface $classMetadata = $this->metadataFactory->getMetadataFor($class); if ($classMetadata instanceof ClassMetadataInterface && $classMetadata->hasPropertyMetadata($property)) { - $memberMetadatas = $classMetadata->getPropertyMetadata($property); - - foreach ($memberMetadatas as $memberMetadata) { - $constraints = $memberMetadata->getConstraints(); - - foreach ($constraints as $constraint) { + foreach ($classMetadata->getPropertyMetadata($property) as $memberMetadata) { + foreach ($memberMetadata->getConstraints() as $constraint) { if ($guess = $closure($constraint)) { $guesses[] = $guess; } From 4d075da9347c693045e57130d5c92655996f1180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 1 Mar 2018 14:58:28 +0100 Subject: [PATCH 13/32] [FrameworkBundle] HttpCache is not longer abstract --- .../Bundle/FrameworkBundle/HttpCache/HttpCache.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php index fa89292804..8455baafc7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php @@ -11,7 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\HttpCache; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpCache\Store; @@ -23,16 +23,16 @@ use Symfony\Component\HttpFoundation\Response; * * @author Fabien Potencier */ -abstract class HttpCache extends BaseHttpCache +class HttpCache extends BaseHttpCache { protected $cacheDir; protected $kernel; /** - * @param HttpKernelInterface $kernel An HttpKernelInterface instance - * @param string $cacheDir The cache directory (default used if null) + * @param KernelInterface $kernel A KernelInterface instance + * @param string $cacheDir The cache directory (default used if null) */ - public function __construct(HttpKernelInterface $kernel, $cacheDir = null) + public function __construct(KernelInterface $kernel, $cacheDir = null) { $this->kernel = $kernel; $this->cacheDir = $cacheDir; From c77d1428e8fb77faf8fbc4c6a71d1cd27063616e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 15 Mar 2018 17:07:34 +0100 Subject: [PATCH 14/32] [DomCrawler] Avoid a useless call to strtolower --- src/Symfony/Component/DomCrawler/Field/InputFormField.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Field/InputFormField.php b/src/Symfony/Component/DomCrawler/Field/InputFormField.php index 090913efa3..1c3c84d721 100644 --- a/src/Symfony/Component/DomCrawler/Field/InputFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/InputFormField.php @@ -32,11 +32,12 @@ class InputFormField extends FormField throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); } - if ('checkbox' === strtolower($this->node->getAttribute('type'))) { + $type = strtolower($this->node->getAttribute('type')); + if ('checkbox' === $type) { throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); } - if ('file' === strtolower($this->node->getAttribute('type'))) { + if ('file' === $type) { throw new \LogicException('File inputs should be instances of FileFormField.'); } From 0c62f659fb2b3be9d7403505febf4d7952697c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 15 Mar 2018 17:51:38 +0100 Subject: [PATCH 15/32] [DomCrawler] Fix the PHPDoc of ChoiceFormField::setValue --- src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index c479daa75e..0553c54563 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -113,7 +113,7 @@ class ChoiceFormField extends FormField /** * Sets the value of the field. * - * @param string $value The value of the field + * @param string|array $value The value of the field * * @throws \InvalidArgumentException When value type provided is not correct */ From a4ec6d3c9c33ac4472615e049643a5bf882a3338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 15 Mar 2018 18:10:20 +0100 Subject: [PATCH 16/32] [DomCrawler] Change bad wording in ChoiceFormField::untick --- src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index c479daa75e..ce22edc2db 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -97,14 +97,14 @@ class ChoiceFormField extends FormField } /** - * Ticks a checkbox. + * Unticks a checkbox. * * @throws \LogicException When the type provided is not correct */ public function untick() { if ('checkbox' !== $this->type) { - throw new \LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->name, $this->type)); + throw new \LogicException(sprintf('You cannot untick "%s" as it is not a checkbox (%s).', $this->name, $this->type)); } $this->setValue(false); From 4ac5d3c3159d1762f5715103c40ae4919c51e2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 16 Mar 2018 16:11:23 +0100 Subject: [PATCH 17/32] [BrowserKit] Fix Cookie's PHPDoc --- src/Symfony/Component/BrowserKit/Cookie.php | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index e6159da74d..1afd8da5f8 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -44,14 +44,14 @@ class Cookie /** * Sets a cookie. * - * @param string $name The cookie name - * @param string $value The value of the cookie - * @param string $expires The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available - * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client - * @param bool $httponly The cookie httponly flag - * @param bool $encodedValue Whether the value is encoded or not + * @param string $name The cookie name + * @param string $value The value of the cookie + * @param string|null $expires The time the cookie expires + * @param string|null $path The path on the server in which the cookie will be available on + * @param string $domain The domain that the cookie is available + * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client + * @param bool $httponly The cookie httponly flag + * @param bool $encodedValue Whether the value is encoded or not */ public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false) { @@ -112,8 +112,8 @@ class Cookie /** * Creates a Cookie instance from a Set-Cookie header value. * - * @param string $cookie A Set-Cookie header value - * @param string $url The base URL + * @param string $cookie A Set-Cookie header value + * @param string|null $url The base URL * * @return static * @@ -242,7 +242,7 @@ class Cookie /** * Gets the expires time of the cookie. * - * @return string The cookie expires time + * @return string|null The cookie expires time */ public function getExpiresTime() { From 57993143a9a57ac39d846a2118e891464e971b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 16 Mar 2018 17:11:50 +0100 Subject: [PATCH 18/32] [BrowserKit] Improves CookieJar::get --- src/Symfony/Component/BrowserKit/CookieJar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/CookieJar.php b/src/Symfony/Component/BrowserKit/CookieJar.php index 232cefc8b6..faa8f6ec44 100644 --- a/src/Symfony/Component/BrowserKit/CookieJar.php +++ b/src/Symfony/Component/BrowserKit/CookieJar.php @@ -47,13 +47,13 @@ class CookieJar foreach ($this->cookieJar as $cookieDomain => $pathCookies) { if ($cookieDomain) { $cookieDomain = '.'.ltrim($cookieDomain, '.'); - if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) { + if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) { continue; } } foreach ($pathCookies as $cookiePath => $namedCookies) { - if ($cookiePath != substr($path, 0, strlen($cookiePath))) { + if (0 !== strpos($path, $cookiePath)) { continue; } if (isset($namedCookies[$name])) { From f656dc2082a12fdcc9033f9b4043b1ff316848a8 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 16 Mar 2018 17:35:29 +0100 Subject: [PATCH 19/32] [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore --- .../Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php | 6 +++--- .../Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php index ebdcb02ca7..26079cd09f 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php @@ -95,7 +95,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface $classMetadata = $classMetadatas[0]; // Check whether the field exists and is nullable or not - if ($classMetadata->hasField($property)) { + if (isset($classMetadata->fieldMappings[$property])) { if (!$classMetadata->isNullable($property) && Type::BOOLEAN !== $classMetadata->getTypeOfField($property)) { return new ValueGuess(true, Guess::HIGH_CONFIDENCE); } @@ -124,7 +124,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface public function guessMaxLength($class, $property) { $ret = $this->getMetadata($class); - if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) { + if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) { $mapping = $ret[0]->getFieldMapping($property); if (isset($mapping['length'])) { @@ -143,7 +143,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface public function guessPattern($class, $property) { $ret = $this->getMetadata($class); - if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) { + if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) { if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 12296729e2..0eda4a3ba6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -33,21 +33,20 @@ class DoctrineOrmTypeGuesserTest extends TestCase // Simple field, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true)); + $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false)); $return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)); // Simple field, nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true)); + $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true)); $return[] = array($classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)); // One-to-one, nullable (by default) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $mapping = array('joinColumns' => array(array())); @@ -57,7 +56,6 @@ class DoctrineOrmTypeGuesserTest extends TestCase // One-to-one, nullable (explicit) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $mapping = array('joinColumns' => array(array('nullable' => true))); @@ -67,7 +65,6 @@ class DoctrineOrmTypeGuesserTest extends TestCase // One-to-one, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $mapping = array('joinColumns' => array(array('nullable' => false))); @@ -77,7 +74,6 @@ class DoctrineOrmTypeGuesserTest extends TestCase // One-to-many, no clue $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false)); $return[] = array($classMetadata, null); From acc20fc7553a941e03c85407c7f9536197708998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 16 Mar 2018 18:29:18 +0100 Subject: [PATCH 20/32] [BrowserKit] Fix cookie path handling when $domain is null --- .../Component/BrowserKit/CookieJar.php | 35 +++++++------------ .../BrowserKit/Tests/CookieJarTest.php | 2 ++ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/CookieJar.php b/src/Symfony/Component/BrowserKit/CookieJar.php index faa8f6ec44..7a4d64c10e 100644 --- a/src/Symfony/Component/BrowserKit/CookieJar.php +++ b/src/Symfony/Component/BrowserKit/CookieJar.php @@ -43,32 +43,21 @@ class CookieJar { $this->flushExpiredCookies(); - if (!empty($domain)) { - foreach ($this->cookieJar as $cookieDomain => $pathCookies) { - if ($cookieDomain) { - $cookieDomain = '.'.ltrim($cookieDomain, '.'); - if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) { - continue; - } - } - - foreach ($pathCookies as $cookiePath => $namedCookies) { - if (0 !== strpos($path, $cookiePath)) { - continue; - } - if (isset($namedCookies[$name])) { - return $namedCookies[$name]; - } + foreach ($this->cookieJar as $cookieDomain => $pathCookies) { + if ($cookieDomain && $domain) { + $cookieDomain = '.'.ltrim($cookieDomain, '.'); + if ($cookieDomain !== substr('.'.$domain, -\strlen($cookieDomain))) { + continue; } } - return; - } - - // avoid relying on this behavior that is mainly here for BC reasons - foreach ($this->cookieJar as $cookies) { - if (isset($cookies[$path][$name])) { - return $cookies[$path][$name]; + foreach ($pathCookies as $cookiePath => $namedCookies) { + if (0 !== strpos($path, $cookiePath)) { + continue; + } + if (isset($namedCookies[$name])) { + return $namedCookies[$name]; + } } } } diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 9c9e122e86..3117e5ce47 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -237,6 +237,8 @@ class CookieJarTest extends TestCase $this->assertEquals($cookie1, $cookieJar->get('foo', '/test', 'example.com')); $this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'example.com')); $this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar', 'example.com')); + + $this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar')); } public function testCookieWithWildcardDomain() From 44008c404703b6f0b4d6cd0440fd454a9016780b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Sat, 17 Mar 2018 23:42:44 +0100 Subject: [PATCH 21/32] [Validator] Fix docblock of ClassMetadata#members Structure of this array is in reality >, so MemberMetadata is 2 levels deep in this array, instead of one --- src/Symfony/Component/Validator/Mapping/ClassMetadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index c79f1259e7..6472066c83 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -48,7 +48,7 @@ class ClassMetadata extends ElementMetadata implements ClassMetadataInterface public $defaultGroup; /** - * @var MemberMetadata[] + * @var MemberMetadata[][] * * @internal This property is public in order to reduce the size of the * class' serialized representation. Do not access it. Use From 986f9151fee81e6022a9203484131ab9755cba38 Mon Sep 17 00:00:00 2001 From: Florent Mata Date: Sat, 17 Mar 2018 16:10:21 +0100 Subject: [PATCH 22/32] add hint in Github pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2d64894f41..94f0fabcc4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,7 +4,7 @@ | Bug fix? | yes/no | New feature? | yes/no | BC breaks? | no -| Deprecations? | yes/no +| Deprecations? | yes/no | Tests pass? | yes | Fixed tickets | #... | License | MIT From f7e1bb05e24d4340e7bea42a6f2b0f4caa271f45 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 16 Mar 2018 17:37:42 +0100 Subject: [PATCH 23/32] [Debug] Reset previous exception handler ealier to prevent infinite loop --- src/Symfony/Component/Debug/ErrorHandler.php | 7 ++++--- .../Component/Debug/Tests/ErrorHandlerTest.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 8875e03e84..e056862b8e 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -544,15 +544,16 @@ class ErrorHandler } } } + $exceptionHandler = $this->exceptionHandler; + $this->exceptionHandler = null; try { - if (null !== $this->exceptionHandler) { - return \call_user_func($this->exceptionHandler, $exception); + if (null !== $exceptionHandler) { + return \call_user_func($exceptionHandler, $exception); } $handlerException = $handlerException ?: $exception; } catch (\Exception $handlerException) { } catch (\Throwable $handlerException) { } - $this->exceptionHandler = null; if ($exception === $handlerException) { self::$reservedMemory = null; // Disable the fatal error handler throw $exception; // Give back $exception to the native handler diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index f2d0fc8b0b..18834badae 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -530,4 +530,17 @@ class ErrorHandlerTest extends TestCase throw $e; } } + + /** + * @expectedException \Exception + */ + public function testCustomExceptionHandler() + { + $handler = new ErrorHandler(); + $handler->setExceptionHandler(function ($e) use ($handler) { + $handler->handleException($e); + }); + + $handler->handleException(new \Exception()); + } } From 7a049769bfd8da96ed3015ea170cfe0499f3a201 Mon Sep 17 00:00:00 2001 From: temperatur <36632383+temperatur@users.noreply.github.com> Date: Mon, 19 Mar 2018 14:47:13 +0100 Subject: [PATCH 24/32] Fixes #26563 (open_basedir restriction in effect) If the open_basedir is set is_file(PHP_BINARY) is false. --- src/Symfony/Component/Process/PhpExecutableFinder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index 4bc27fe4d4..9b3b0f4f68 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -44,7 +44,7 @@ class PhpExecutableFinder } // PHP_BINARY return the current sapi executable - if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) { + if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg'))) { return PHP_BINARY.$args; } From cc38c6bb62ad7ea4cf2f7840288f2640953fd321 Mon Sep 17 00:00:00 2001 From: Egor Gorbachev Date: Mon, 19 Mar 2018 20:40:47 +0300 Subject: [PATCH 25/32] Fix typo in test method name --- src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php index c523e5cd5e..24e3224ce5 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php @@ -20,7 +20,7 @@ class ConfigCacheFactoryTest extends TestCase * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid type for callback argument. Expected callable, but got "object". */ - public function testCachWithInvalidCallback() + public function testCacheWithInvalidCallback() { $cacheFactory = new ConfigCacheFactory(true); From ee47236a4c08c39ba5fb33ee9ff13bb838f3a4d9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 19 Mar 2018 19:37:04 +0100 Subject: [PATCH 26/32] [Debug] fix test --- src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 18834badae..4eb4aef0c0 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -533,6 +533,7 @@ class ErrorHandlerTest extends TestCase /** * @expectedException \Exception + * @group no-hhvm */ public function testCustomExceptionHandler() { From cb9c92d06553f60a0b7b6b036c4b2a3c1813e738 Mon Sep 17 00:00:00 2001 From: Boris Vujicic Date: Fri, 2 Mar 2018 09:14:52 +0100 Subject: [PATCH 27/32] [Security] added userChecker to SimpleAuthenticationProvider --- .../Security/Factory/SimpleFormFactory.php | 1 + .../Provider/SimpleAuthenticationProvider.php | 16 +++- .../SimpleAuthenticationProviderTest.php | 89 +++++++++++++++++++ 3 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php index 6241cf4f39..69b8b943ab 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php @@ -55,6 +55,7 @@ class SimpleFormFactory extends FormLoginFactory ->replaceArgument(0, new Reference($config['authenticator'])) ->replaceArgument(1, new Reference($userProviderId)) ->replaceArgument(2, $id) + ->replaceArgument(3, new Reference('security.user_checker.'.$id)) ; return $provider; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php index ffbc72c055..a82fb7eea4 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Security\Core\Authentication\Provider; +use Symfony\Component\Security\Core\User\UserChecker; +use Symfony\Component\Security\Core\User\UserCheckerInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; @@ -24,23 +26,29 @@ class SimpleAuthenticationProvider implements AuthenticationProviderInterface private $simpleAuthenticator; private $userProvider; private $providerKey; + private $userChecker; - public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, $providerKey) + public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, $providerKey, UserCheckerInterface $userChecker = null) { $this->simpleAuthenticator = $simpleAuthenticator; $this->userProvider = $userProvider; $this->providerKey = $providerKey; + $this->userChecker = $userChecker ?: new UserChecker(); } public function authenticate(TokenInterface $token) { $authToken = $this->simpleAuthenticator->authenticateToken($token, $this->userProvider, $this->providerKey); - if ($authToken instanceof TokenInterface) { - return $authToken; + if (!$authToken instanceof TokenInterface) { + throw new AuthenticationException('Simple authenticator failed to return an authenticated token.'); } - throw new AuthenticationException('Simple authenticator failed to return an authenticated token.'); + $user = $authToken->getUser(); + $this->userChecker->checkPreAuth($user); + $this->userChecker->checkPostAuth($user); + + return $authToken; } public function supports(TokenInterface $token) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php new file mode 100644 index 0000000000..1e7069c1fa --- /dev/null +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Tests\Authentication\Provider; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Security\Core\Exception\DisabledException; +use Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider; +use Symfony\Component\Security\Core\Exception\LockedException; + +class SimpleAuthenticationProviderTest extends TestCase +{ + /** + * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException + */ + public function testAuthenticateWhenPreChecksFails() + { + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token->expects($this->any()) + ->method('getUser') + ->will($this->returnValue($user)); + + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker->expects($this->once()) + ->method('checkPreAuth') + ->will($this->throwException(new DisabledException())); + + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator->expects($this->once()) + ->method('authenticateToken') + ->will($this->returnValue($token)); + + $provider = $this->getProvider($authenticator, null, $userChecker); + + $provider->authenticate($token); + } + + /** + * @expectedException \Symfony\Component\Security\Core\Exception\LockedException + */ + public function testAuthenticateWhenPostChecksFails() + { + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token->expects($this->any()) + ->method('getUser') + ->will($this->returnValue($user)); + + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker->expects($this->once()) + ->method('checkPostAuth') + ->will($this->throwException(new LockedException())); + + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator->expects($this->once()) + ->method('authenticateToken') + ->will($this->returnValue($token)); + + $provider = $this->getProvider($authenticator, null, $userChecker); + + $provider->authenticate($token); + } + + protected function getProvider($simpleAuthenticator = null, $userProvider = null, $userChecker = null, $key = 'test') + { + if (null === $userChecker) { + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + } + if (null === $simpleAuthenticator) { + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + } + if (null === $userProvider) { + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + } + + return new SimpleAuthenticationProvider($simpleAuthenticator, $userProvider, $key, $userChecker); + } +} From 5c3e6a95b307e5065855daaf05ace19e09c81203 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 27 Feb 2018 16:54:37 +0100 Subject: [PATCH 28/32] [Config] Handle nullable node name + fix inheritdocs --- .../Component/Config/Definition/ArrayNode.php | 14 ++----- .../Component/Config/Definition/BaseNode.php | 38 ++++--------------- .../Builder/ArrayNodeDefinition.php | 18 ++------- .../Builder/ParentNodeDefinitionInterface.php | 23 +++++++++++ .../Config/Definition/NodeInterface.php | 16 +++++++- .../Config/Definition/PrototypedArrayNode.php | 8 +--- .../Config/Definition/VariableNode.php | 3 -- 7 files changed, 52 insertions(+), 68 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 2c2738ac4c..3ec00350a8 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -150,9 +150,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } /** - * Sets the node Name. - * - * @param string $name The node's name + * {@inheritdoc} */ public function setName($name) { @@ -160,9 +158,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } /** - * Checks if the node has a default value. - * - * @return bool + * {@inheritdoc} */ public function hasDefaultValue() { @@ -170,11 +166,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface } /** - * Retrieves the default value. - * - * @return array The default value - * - * @throws \RuntimeException if the node has no default value + * {@inheritdoc} */ public function getDefaultValue() { diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index 2e346d7907..63aac0874c 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -40,7 +40,7 @@ abstract class BaseNode implements NodeInterface */ public function __construct($name, NodeInterface $parent = null) { - if (false !== strpos($name, '.')) { + if (false !== strpos($name = (string) $name, '.')) { throw new \InvalidArgumentException('The name must not contain ".".'); } @@ -170,9 +170,7 @@ abstract class BaseNode implements NodeInterface } /** - * Checks if this node is required. - * - * @return bool + * {@inheritdoc} */ public function isRequired() { @@ -180,9 +178,7 @@ abstract class BaseNode implements NodeInterface } /** - * Returns the name of this node. - * - * @return string The Node's name + * {@inheritdoc} */ public function getName() { @@ -190,9 +186,7 @@ abstract class BaseNode implements NodeInterface } /** - * Retrieves the path of this node. - * - * @return string The Node's path + * {@inheritdoc} */ public function getPath() { @@ -206,14 +200,7 @@ abstract class BaseNode implements NodeInterface } /** - * Merges two values together. - * - * @param mixed $leftSide - * @param mixed $rightSide - * - * @return mixed The merged value - * - * @throws ForbiddenOverwriteException + * {@inheritdoc} */ final public function merge($leftSide, $rightSide) { @@ -233,11 +220,7 @@ abstract class BaseNode implements NodeInterface } /** - * Normalizes a value, applying all normalization closures. - * - * @param mixed $value Value to normalize - * - * @return mixed The normalized value + * {@inheritdoc} */ final public function normalize($value) { @@ -285,14 +268,7 @@ abstract class BaseNode implements NodeInterface } /** - * Finalizes a value, applying all finalization closures. - * - * @param mixed $value The value to finalize - * - * @return mixed The finalized value - * - * @throws Exception - * @throws InvalidConfigurationException + * {@inheritdoc} */ final public function finalize($value) { diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index a0ad77edd0..bb751c237a 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -47,7 +47,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition } /** - * Sets a custom children builder. + * {@inheritdoc} */ public function setBuilder(NodeBuilder $builder) { @@ -55,9 +55,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition } /** - * Returns a builder to add children nodes. - * - * @return NodeBuilder + * {@inheritdoc} */ public function children() { @@ -306,17 +304,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition } /** - * Appends a node definition. - * - * $node = new ArrayNodeDefinition() - * ->children() - * ->scalarNode('foo')->end() - * ->scalarNode('baz')->end() - * ->end() - * ->append($this->getBarNodeDefinition()) - * ; - * - * @return $this + * {@inheritdoc} */ public function append(NodeDefinition $node) { diff --git a/src/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php b/src/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php index 575495bb68..1bf2ad4bf6 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php +++ b/src/Symfony/Component/Config/Definition/Builder/ParentNodeDefinitionInterface.php @@ -18,9 +18,32 @@ namespace Symfony\Component\Config\Definition\Builder; */ interface ParentNodeDefinitionInterface { + /** + * Returns a builder to add children nodes. + * + * @return NodeBuilder + */ public function children(); + /** + * Appends a node definition. + * + * Usage: + * + * $node = $parentNode + * ->children() + * ->scalarNode('foo')->end() + * ->scalarNode('baz')->end() + * ->append($this->getBarNodeDefinition()) + * ->end() + * ; + * + * @return $this + */ public function append(NodeDefinition $node); + /** + * Sets a custom children builder. + */ public function setBuilder(NodeBuilder $builder); } diff --git a/src/Symfony/Component/Config/Definition/NodeInterface.php b/src/Symfony/Component/Config/Definition/NodeInterface.php index b9bddc4938..45f1f681c1 100644 --- a/src/Symfony/Component/Config/Definition/NodeInterface.php +++ b/src/Symfony/Component/Config/Definition/NodeInterface.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Config\Definition; +use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; +use Symfony\Component\Config\Definition\Exception\InvalidTypeException; + /** * Common Interface among all nodes. * @@ -59,11 +63,13 @@ interface NodeInterface public function getDefaultValue(); /** - * Normalizes the supplied value. + * Normalizes a value. * * @param mixed $value The value to normalize * * @return mixed The normalized value + * + * @throws InvalidTypeException if the value type is invalid */ public function normalize($value); @@ -73,7 +79,10 @@ interface NodeInterface * @param mixed $leftSide * @param mixed $rightSide * - * @return mixed The merged values + * @return mixed The merged value + * + * @throws ForbiddenOverwriteException if the configuration path cannot be overwritten + * @throws InvalidTypeException if the value type is invalid */ public function merge($leftSide, $rightSide); @@ -83,6 +92,9 @@ interface NodeInterface * @param mixed $value The value to finalize * * @return mixed The finalized value + * + * @throws InvalidTypeException if the value type is invalid + * @throws InvalidConfigurationException if the value is invalid configuration */ public function finalize($value); } diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 08f335a015..d377b73e6c 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -102,9 +102,7 @@ class PrototypedArrayNode extends ArrayNode } /** - * Checks if the node has a default value. - * - * @return bool + * {@inheritdoc} */ public function hasDefaultValue() { @@ -126,12 +124,10 @@ class PrototypedArrayNode extends ArrayNode } /** - * Retrieves the default value. + * {@inheritdoc} * * The default value could be either explicited or derived from the prototype * default value. - * - * @return array The default value */ public function getDefaultValue() { diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index a9c35284cd..0cd84c72bf 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -27,9 +27,6 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface protected $defaultValue; protected $allowEmptyValue = true; - /** - * {@inheritdoc} - */ public function setDefaultValue($value) { $this->defaultValueSet = true; From dad27b0b2a7b105648ae8b35a0095006001861b6 Mon Sep 17 00:00:00 2001 From: Tim Goudriaan Date: Mon, 19 Mar 2018 21:46:57 +0100 Subject: [PATCH 29/32] [Console] Fix docblock of DescriptorInterface::describe --- .../Component/Console/Descriptor/DescriptorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php b/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php index 3929b6d9ed..5d3339a9e6 100644 --- a/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php +++ b/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php @@ -21,7 +21,7 @@ use Symfony\Component\Console\Output\OutputInterface; interface DescriptorInterface { /** - * Describes an InputArgument instance. + * Describes an object if supported. * * @param OutputInterface $output * @param object $object From f3ec39616c96ce0037a3bb62c8d31f7a4ac638a1 Mon Sep 17 00:00:00 2001 From: Artur Eshenbrener Date: Tue, 13 Mar 2018 19:09:28 +0300 Subject: [PATCH 30/32] [FrameworkBundle] Respect debug mode when warm up annotations --- .../CacheWarmer/AnnotationsCacheWarmer.php | 7 +- .../Resources/config/annotations.xml | 1 + .../AnnotationsCacheWarmerTest.php | 103 ++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index ec55e9c6fc..3c32cb1c4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -28,17 +28,20 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer { private $annotationReader; private $excludeRegexp; + private $debug; /** * @param Reader $annotationReader * @param string $phpArrayFile The PHP file where annotations are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached + * @param bool $debug Run in debug mode */ - public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool, $excludeRegexp = null) + public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool, $excludeRegexp = null, $debug = false) { parent::__construct($phpArrayFile, $fallbackPool); $this->annotationReader = $annotationReader; $this->excludeRegexp = $excludeRegexp; + $this->debug = $debug; } /** @@ -53,7 +56,7 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer } $annotatedClasses = include $annotatedClassPatterns; - $reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter)); + $reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug); foreach ($annotatedClasses as $class) { if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml index 6e8cc4f9e6..2b4ea42962 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml @@ -38,6 +38,7 @@ %kernel.cache_dir%/annotations.php #^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))# + %kernel.debug% diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php new file mode 100644 index 0000000000..b32274e7e7 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -0,0 +1,103 @@ +cacheDir = sys_get_temp_dir().'/'.uniqid(); + $fs = new Filesystem(); + $fs->mkdir($this->cacheDir); + parent::setUp(); + } + + protected function tearDown() + { + $fs = new Filesystem(); + $fs->remove($this->cacheDir); + parent::tearDown(); + } + + public function testAnnotationsCacheWarmerWithDebugDisabled() + { + file_put_contents($this->cacheDir.'/annotations.map', sprintf('cacheDir, __FUNCTION__); + $reader = new AnnotationReader(); + $fallbackPool = new ArrayAdapter(); + $warmer = new AnnotationsCacheWarmer( + $reader, + $cacheFile, + $fallbackPool, + null + ); + $warmer->warmUp($this->cacheDir); + $this->assertFileExists($cacheFile); + + // Assert cache is valid + $reader = new CachedReader( + $this->getReadOnlyReader(), + new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter())) + ); + $refClass = new \ReflectionClass($this); + $reader->getClassAnnotations($refClass); + $reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__)); + $reader->getPropertyAnnotations($refClass->getProperty('cacheDir')); + } + + public function testAnnotationsCacheWarmerWithDebugEnabled() + { + file_put_contents($this->cacheDir.'/annotations.map', sprintf('cacheDir, __FUNCTION__); + $reader = new AnnotationReader(); + $fallbackPool = new ArrayAdapter(); + $warmer = new AnnotationsCacheWarmer( + $reader, + $cacheFile, + $fallbackPool, + null, + true + ); + $warmer->warmUp($this->cacheDir); + $this->assertFileExists($cacheFile); + // Assert cache is valid + $reader = new CachedReader( + $this->getReadOnlyReader(), + new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter())), + true + ); + $refClass = new \ReflectionClass($this); + $reader->getClassAnnotations($refClass); + $reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__)); + $reader->getPropertyAnnotations($refClass->getProperty('cacheDir')); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Reader + */ + private function getReadOnlyReader() + { + $readerMock = $this->getMockBuilder('Doctrine\Common\Annotations\Reader')->getMock(); + $readerMock->expects($this->exactly(0))->method('getClassAnnotations'); + $readerMock->expects($this->exactly(0))->method('getClassAnnotation'); + $readerMock->expects($this->exactly(0))->method('getMethodAnnotations'); + $readerMock->expects($this->exactly(0))->method('getMethodAnnotation'); + $readerMock->expects($this->exactly(0))->method('getPropertyAnnotations'); + $readerMock->expects($this->exactly(0))->method('getPropertyAnnotation'); + + return $readerMock; + } +} From e4973ad8dcc3b30ea2116d8b933e098ffee1e40f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 19 Mar 2018 23:12:11 +0100 Subject: [PATCH 31/32] [Cache] Rely on mock for Doctrine ArrayCache --- phpunit.xml.dist | 1 + .../Tests/Adapter/DoctrineAdapterTest.php | 2 +- .../Cache/Tests/Fixtures/ArrayCache.php | 52 +++++++++++++++++++ .../Cache/Tests/Simple/DoctrineCacheTest.php | 2 +- src/Symfony/Component/Cache/phpunit.xml.dist | 1 + 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e44535a81a..59ec772525 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -65,6 +65,7 @@ Cache\IntegrationTests Doctrine\Common\Cache Symfony\Component\Cache + Symfony\Component\Cache\Tests\Fixtures Symfony\Component\Cache\Traits Symfony\Component\Console Symfony\Component\HttpFoundation diff --git a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php index 93ec982438..8d4dfe2858 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Cache\Tests\Adapter; -use Doctrine\Common\Cache\ArrayCache; use Symfony\Component\Cache\Adapter\DoctrineAdapter; +use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; /** * @group time-sensitive diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php new file mode 100644 index 0000000000..1a6157e822 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php @@ -0,0 +1,52 @@ +doContains($id) ? $this->data[$id][0] : false; + } + + protected function doContains($id) + { + if (!isset($this->data[$id])) { + return false; + } + + $expiry = $this->data[$id][1]; + + return !$expiry || time() <= $expiry || !$this->doDelete($id); + } + + protected function doSave($id, $data, $lifeTime = 0) + { + $this->data[$id] = array($data, $lifeTime ? time() + $lifeTime : false); + + return true; + } + + protected function doDelete($id) + { + unset($this->data[$id]); + + return true; + } + + protected function doFlush() + { + $this->data = array(); + + return true; + } + + protected function doGetStats() + { + return null; + } +} diff --git a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php index 0a185297ab..127c96858c 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Cache\Tests\Simple; -use Doctrine\Common\Cache\ArrayCache; use Symfony\Component\Cache\Simple\DoctrineCache; +use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; /** * @group time-sensitive diff --git a/src/Symfony/Component/Cache/phpunit.xml.dist b/src/Symfony/Component/Cache/phpunit.xml.dist index 6b5c79331d..9b3c30d76f 100644 --- a/src/Symfony/Component/Cache/phpunit.xml.dist +++ b/src/Symfony/Component/Cache/phpunit.xml.dist @@ -39,6 +39,7 @@ Cache\IntegrationTests Doctrine\Common\Cache Symfony\Component\Cache + Symfony\Component\Cache\Tests\Fixtures Symfony\Component\Cache\Traits From ed028fc4f491b2b2606b1f155614e59bbce3f606 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 19 Mar 2018 23:30:33 +0100 Subject: [PATCH 32/32] [Form] fix tests and deps --- src/Symfony/Bridge/Twig/composer.json | 4 ++-- .../Component/Form/Tests/AbstractBootstrap4LayoutTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 8a531dcc62..40c6767dbb 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -23,7 +23,7 @@ "symfony/asset": "~2.8|~3.0|~4.0", "symfony/dependency-injection": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/form": "^3.4.5|^4.0.5", + "symfony/form": "^3.4.7|^4.0.7", "symfony/http-foundation": "^3.3.11|~4.0", "symfony/http-kernel": "~3.2|~4.0", "symfony/polyfill-intl-icu": "~1.0", @@ -41,7 +41,7 @@ "symfony/workflow": "~3.3|~4.0" }, "conflict": { - "symfony/form": "<3.4.5|<4.0.5,>=4.0", + "symfony/form": "<3.4.7|<4.0.7,>=4.0", "symfony/console": "<3.4" }, "suggest": { diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php index 6e448c413a..beabaa21cd 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php @@ -166,10 +166,10 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest ./span[@class="mb-0 d-block"] [./span[.="[trans]Error[/trans]"]] [./span[.="[trans]Error 1[/trans]"]] - + /following-sibling::span[@class="mb-0 d-block"] [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error 2[/trans]"]] + [./span[.="[trans]Error 2[/trans]"]] ] [count(./span)=2] '