From 72b6c9e0b9309aa4ae55541abe7e04c6c58adc83 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Thu, 1 Sep 2016 12:16:03 +0800 Subject: [PATCH 01/93] Update misleading comment about RFC4627 RFC 4627 does not dictate escaping of HTML special characters --- src/Symfony/Component/HttpFoundation/JsonResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 8df683ddfb7f8..4a533f48ff7f8 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -27,7 +27,7 @@ class JsonResponse extends Response protected $data; protected $callback; - // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML. + // Encode <, >, ', &, and " characters in the JSON, making it also safe to be embedded into HTML. // 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT protected $encodingOptions = 15; From 2d83c1c1e00a3bde76995e327e9dbd392f7c320c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Sep 2016 20:04:58 -0700 Subject: [PATCH 02/93] updated CHANGELOG for 2.7.17 --- CHANGELOG-2.7.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG-2.7.md b/CHANGELOG-2.7.md index 1972244d21f0d..0f7fa8210cbe2 100644 --- a/CHANGELOG-2.7.md +++ b/CHANGELOG-2.7.md @@ -7,6 +7,31 @@ 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.17 (2016-09-02) + + * bug #19794 [VarDumper] Various minor fixes & cleanups (nicolas-grekas) + * bug #19751 Fixes the calendar in constructor to handle null (wakqasahmed) + * bug #19388 [Validator][GroupSequence] fixed GroupSequence validation ignores PropetyMetadata of parent classes (Sandro Hopf) + * bug #19601 [FrameworkBundle] Added friendly exception when constraint validator class does not exist (yceruto) + * bug #19580 [Validator] fixed duplicate constraints with parent class interfaces (dmaicher) + * bug #19647 [Debug] Swap dumper services at bootstrap (lyrixx) + * bug #19685 [DI] Include dynamic services in alternatives (ro0NL) + * bug #19702 [Debug][HttpKernel][VarDumper] Prepare for committed 7.2 changes (aka "small-bc-breaks") (nicolas-grekas) + * bug #19704 [DependencyInjection] PhpDumper::isFrozen inconsistency (allflame) + * bug #19666 Verify explicitly that the request IP is a valid IPv4 address (nesk) + * bug #19660 Disable CLI color for Windows 10 greater than 10.0.10586 (mlocati) + * bug #19663 Exception details break the layout (Dionysis Arvanitis) + * bug #19651 [HttpKernel] Fix HttpCache validation HTTP method (tgalopin) + * bug #19623 [VarDumper] Fix dumping continuations (nicolas-grekas) + * bug #19549 [HttpFoundation] fixed Request::getContent() reusage bug (1ma) + * bug #19373 [Form] Skip CSRF validation on form when POST max size is exceeded (jameshalsall) + * bug #19541 Fix #19531 [Form] DateType fails parsing when midnight is not a valid time (mbeccati) + * bug #19579 [Process] Strengthen Windows pipe files opening (again...) (nicolas-grekas) + * bug #19564 Added class existence check if is_subclass_of() fails in compiler passes (SCIF) + * bug #19522 [SwiftMailerBridge] Fix flawed deprecation message (chalasr) + * bug #19510 [Process] Fix double-fread() when reading unix pipes (nicolas-grekas) + * bug #19508 [Process] Fix AbstractPipes::write() for a situation seen on HHVM (at least) (nicolas-grekas) + * 2.7.16 (2016-07-30) * bug #19470 undefined offset fix (#19406) (ReenExe) From 4050beb41548f9e6d1cc36d03939e76ccd5b4b53 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Sep 2016 20:05:09 -0700 Subject: [PATCH 03/93] update CONTRIBUTORS for 2.7.17 --- CONTRIBUTORS.md | 63 +++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index da27714faff54..e10ae01026ab3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -16,8 +16,8 @@ Symfony is the result of the work of many people who made the code better - Kris Wallsmith (kriswallsmith) - Jakub Zalas (jakubzalas) - Ryan Weaver (weaverryan) - - Javier Eguiluz (javier.eguiluz) - Kévin Dunglas (dunglas) + - Javier Eguiluz (javier.eguiluz) - Hugo Hamon (hhamon) - Abdellatif Ait boudad (aitboudad) - Pascal Borreli (pborreli) @@ -56,17 +56,18 @@ Symfony is the result of the work of many people who made the code better - Ener-Getick (energetick) - Iltar van der Berg (kjarli) - Kevin Bond (kbond) + - Andrej Hudec (pulzarraider) - Gábor Egyed (1ed) - Michel Weimerskirch (mweimerskirch) - Eric Clemmons (ericclemmons) - Matthias Pigulla (mpdude) - - Andrej Hudec (pulzarraider) - Christian Raue + - Arnout Boks (aboks) - Charles Sarrazin (csarrazi) + - Robin Chalas (chalas_r) - Deni - Henrik Westphal (snc) - Dariusz Górecki (canni) - - Arnout Boks (aboks) - Douglas Greenshields (shieldo) - Lee McDermott - Brandon Turner @@ -80,14 +81,14 @@ Symfony is the result of the work of many people who made the code better - Toni Uebernickel (havvg) - Fran Moreno (franmomu) - Antoine Hérault (herzult) - - Robin Chalas (chalas_r) - Arnaud Le Blanc (arnaud-lb) - Jérôme Tamarelle (gromnan) - Paráda József (paradajozsef) + - Titouan Galopin (tgalopin) - Michal Piotrowski (eventhorizon) - Tim Nagel (merk) - - Brice BERNARD (brikou) - Konstantin Myakshin (koc) + - Brice BERNARD (brikou) - Alexander M. Turek (derrabus) - Dariusz Ruminski - marc.weistroff @@ -114,15 +115,14 @@ Symfony is the result of the work of many people who made the code better - Théo FIDRY (theofidry) - Robert Schönthal (digitalkaoz) - Florian Lonqueu-Brochard (florianlb) - - Titouan Galopin (tgalopin) - Stefano Sala (stefano.sala) + - Evgeniy (ewgraf) - Juti Noppornpitak (shiroyuki) - Tigran Azatyan (tigranazatyan) - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) - Sebastiaan Stok (sstok) - - Evgeniy (ewgraf) - Tugdual Saunier (tucksaun) - Guilherme Blanco (guilhermeblanco) - Pablo Godel (pgodel) @@ -132,6 +132,7 @@ Symfony is the result of the work of many people who made the code better - Arnaud Kleinpeter (nanocom) - Joel Wurtz (brouznouf) - Philipp Wahala (hifi) + - Vyacheslav Pavlov - Richard Shank (iampersistent) - Thomas Rabaix (rande) - Vincent AUBERT (vincent) @@ -161,9 +162,9 @@ Symfony is the result of the work of many people who made the code better - Noel Guilbert (noel) - Stepan Anchugov (kix) - bronze1man + - Roland Franssen (ro0) - sun (sun) - Larry Garfield (crell) - - Vyacheslav Pavlov - Martin Schuhfuß (usefulthink) - Matthieu Bontemps (mbontemps) - Pierre Minnieur (pminnieur) @@ -179,12 +180,15 @@ Symfony is the result of the work of many people who made the code better - Justin Hileman (bobthecow) - Blanchon Vincent (blanchonvincent) - Michele Orselli (orso) + - Tom Van Looy (tvlooy) - Sven Paulus (subsven) - Lars Strojny (lstrojny) - Rui Marinho (ruimarinho) - Daniel Espendiller + - Dawid Nowak - Eugene Wissner - Julien Brochet (mewt) + - Yonel Ceruto González (yonelceruto) - Sergey Linnik (linniksa) - Michaël Perrin (michael.perrin) - Marcel Beerta (mazen) @@ -205,8 +209,8 @@ Symfony is the result of the work of many people who made the code better - Danny Berger (dpb587) - Jérôme Vasseur - Roman Marintšenko (inori) + - Christian Schmidt - Xavier Montaña Carreras (xmontana) - - Tom Van Looy (tvlooy) - Chris Wilkinson (thewilkybarkid) - Mickaël Andrieu (mickaelandrieu) - Xavier Perez @@ -214,8 +218,8 @@ Symfony is the result of the work of many people who made the code better - Katsuhiro OGAWA - Alif Rachmawadi - Kristen Gilden (kgilden) - - Dawid Nowak - Pierre-Yves LEBECQ (pylebecq) + - Alex Pott - Jakub Kucharovic (jkucharovic) - Eugene Leonovich (rybakit) - Filippo Tessarotto @@ -227,8 +231,10 @@ Symfony is the result of the work of many people who made the code better - Ray - Grégoire Paris (greg0ire) - Chekote + - Tobias Nyholm (tobias) - Thomas Adam - Albert Casademont (acasademont) + - Jhonny Lidfors (jhonne) - Diego Agulló (aeoris) - jdhoek - Nikita Konstantinov @@ -242,7 +248,6 @@ Symfony is the result of the work of many people who made the code better - Roumen Damianoff (roumen) - Antonio J. García Lagar (ajgarlag) - Kim Hemsø Rasmussen (kimhemsoe) - - Christian Schmidt - Wouter Van Hecke - Peter Kruithof (pkruithof) - Michael Holm (hollo) @@ -257,17 +262,15 @@ Symfony is the result of the work of many people who made the code better - Andrew Moore (finewolf) - Bertrand Zuchuat (garfield-fr) - Gabor Toth (tgabi333) - - Alex Pott - realmfoo - Thomas Tourlourat (armetiz) - Andrey Esaulov (andremaha) - - Tobias Nyholm (tobias) - Grégoire Passault (gregwar) + - Leo Feyer - Ismael Ambrosi (iambrosi) - Uwe Jäger (uwej711) - Aurelijus Valeiša (aurelijus) - Jan Decavele (jandc) - - Yonel Ceruto González (yonelceruto) - Gustavo Piltcher - Stepan Tanasiychuk (stfalcon) - Tiago Ribeiro (fixe) @@ -306,8 +309,8 @@ Symfony is the result of the work of many people who made the code better - Felix Labrecque - Yaroslav Kiliba - Terje Bråten - - Roland Franssen (ro0) - Robbert Klarenbeek (robbertkl) + - Marek Štípek (maryo) - Alessandro Chitolina - JhonnyL - hossein zolfi (ocean) @@ -317,6 +320,8 @@ Symfony is the result of the work of many people who made the code better - Stéphane PY (steph_py) - Philipp Kräutli (pkraeutli) - Kirill chEbba Chebunin (chebba) + - Tristan Darricau (nicofuma) + - SpacePossum - Greg Thornton (xdissent) - Costin Bereveanu (schniper) - Loïc Chardonnet (gnusat) @@ -328,7 +333,6 @@ Symfony is the result of the work of many people who made the code better - Endre Fejes - Tobias Naumann (tna) - Daniel Beyer - - Jhonny Lidfors (jhonne) - Shein Alexey - Baptiste Lafontaine - Joe Lencioni @@ -383,7 +387,6 @@ Symfony is the result of the work of many people who made the code better - cedric lombardot (cedriclombardot) - Jonas Flodén (flojon) - Christian Schmidt - - Marek Štípek (maryo) - Marcin Sikoń (marphi) - Dominik Zogg (dominik.zogg) - Marek Pietrzak @@ -393,6 +396,7 @@ Symfony is the result of the work of many people who made the code better - Christian Wahler - Mathieu Lemoine - Gintautas Miselis + - James Halsall (jaitsu) - David Badura (davidbadura) - Zander Baldwin - Adam Harvey @@ -409,7 +413,6 @@ Symfony is the result of the work of many people who made the code better - Benoît Burnichon (bburnichon) - Sebastian Bergmann - Pablo Díez (pablodip) - - SpacePossum - Kevin McBride - Philipp Rieber (bicpi) - Manuel de Ruiter (manuel) @@ -428,6 +431,7 @@ Symfony is the result of the work of many people who made the code better - Filip Procházka (fprochazka) - mmoreram - Markus Lanthaler (lanthaler) + - Remi Collet - Vicent Soria Durá (vicentgodella) - Nicolas Dewez (nicolas_dewez) - Anthony Ferrara @@ -435,7 +439,7 @@ Symfony is the result of the work of many people who made the code better - Jakub Škvára (jskvara) - Andrew Udvare (audvare) - alexpods - - Tristan Darricau (nicofuma) + - Michele Locati - Erik Trapman (eriktrapman) - De Cock Xavier (xdecock) - Almog Baku (almogbaku) @@ -449,13 +453,13 @@ Symfony is the result of the work of many people who made the code better - DUPUCH (bdupuch) - Benjamin Leveque (benji07) - Nate (frickenate) + - Timothée Barray (tyx) - jhonnyL - sasezaki - Dawid Pakuła (zulusx) - Florian Rey (nervo) - Oskar Stark (oskarstark) - Rodrigo Borrego Bernabé (rodrigobb) - - Leo Feyer - MatTheCat - Denis Gorbachev (starfall) - Peter van Dommelen @@ -557,6 +561,7 @@ Symfony is the result of the work of many people who made the code better - Hossein Bukhamsin - Disparity - origaminal + - Maxime STEINHAUSSER - Paweł Wacławczyk (pwc) - Oleg Zinchenko (cystbear) - Johannes Klauss (cloppy) @@ -567,6 +572,7 @@ Symfony is the result of the work of many people who made the code better - Tiago Brito (blackmx) - Richard van den Brand (ricbra) - develop + - ReenExe - Mark Sonnabaum - Richard Quadling - jochenvdv @@ -596,7 +602,6 @@ Symfony is the result of the work of many people who made the code better - Lars Vierbergen - Dennis Hotson - Andrew Tchircoff (andrewtch) - - Remi Collet - michaelwilliams - 1emming - Leevi Graham (leevigraham) @@ -619,7 +624,6 @@ Symfony is the result of the work of many people who made the code better - possum - Denis Zunke (donalberto) - Olivier Maisonneuve (olineuve) - - Michele Locati - Masterklavi - Francis Turmel (fturmel) - cgonzalez @@ -630,6 +634,7 @@ Symfony is the result of the work of many people who made the code better - Harm van Tilborg - Jan Prieser - Adrien Lucas (adrienlucas) + - Zhuravlev Alexander (scif) - James Michael DuPont - Tom Klingenberg - Christopher Hall (mythmakr) @@ -681,7 +686,6 @@ Symfony is the result of the work of many people who made the code better - abdul malik ikhsan (samsonasik) - Henry Snoek (snoek09) - Simone Di Maulo (toretto460) - - Timothée Barray (tyx) - Sander Toonen (xatoo) - Christian Morgan - Alexander Miehe (engerim) @@ -801,7 +805,6 @@ Symfony is the result of the work of many people who made the code better - Ken Marfilla (marfillaster) - benatespina (benatespina) - Denis Kop - - Maxime STEINHAUSSER - jfcixmedia - Martijn Evers - Benjamin Paap (benjaminpaap) @@ -834,6 +837,7 @@ Symfony is the result of the work of many people who made the code better - Rodrigo Díez Villamuera (rodrigodiez) - e-ivanov - Jochen Bayer (jocl) + - Matteo Beccati (matteobeccati) - Jeremy Bush - wizhippo - Viacheslav Sychov @@ -855,6 +859,7 @@ Symfony is the result of the work of many people who made the code better - Gustavo Adrian - Yannick - spdionis + - Taras Girnyk - Eduardo García Sanz (coma) - James Gilliland - Rhodri Pugh (rodnaph) @@ -882,6 +887,7 @@ Symfony is the result of the work of many people who made the code better - Christian Sciberras - Clement Herreman (clemherreman) - Dan Ionut Dumitriu (danionut90) + - David Maicher (dmaicher) - Nyro (nyro) - Marco - Marc Torres @@ -946,6 +952,7 @@ Symfony is the result of the work of many people who made the code better - ShiraNai7 - Vašek Purchart (vasek-purchart) - Janusz Jabłoński (yanoosh) + - Sandro Hopf - Łukasz Makuch - George Giannoulopoulos - Daniel Richter (richtermeister) @@ -971,7 +978,6 @@ Symfony is the result of the work of many people who made the code better - WedgeSama - Felds Liscia - Ahmed TAILOULOUTE (ahmedtai) - - James Halsall (jaitsu) - Maxime Veber (nek-) - Sullivan SENECHAL - Tadcka @@ -1026,6 +1032,7 @@ Symfony is the result of the work of many people who made the code better - Valentin VALCIU - Kevin Dew - James Cowgill + - 1ma (jautenim) - Nicolas Schwartz (nicoschwartz) - Patrik Gmitter (patie) - Jonathan Gough @@ -1102,8 +1109,8 @@ Symfony is the result of the work of many people who made the code better - David Stone - Jovan Perovic (jperovic) - Pablo Maria Martelletti (pmartelletti) - - Zhuravlev Alexander (scif) - Yassine Guedidi (yguedidi) + - Waqas Ahmed - Luis Muñoz - Andreas - Thomas Chmielowiec @@ -1185,6 +1192,7 @@ Symfony is the result of the work of many people who made the code better - Adam - devel - taiiiraaa + - Johann Pardanaud - Trevor Suarez - gedrox - dropfen @@ -1313,6 +1321,7 @@ Symfony is the result of the work of many people who made the code better - Joseph Deray - Damian Sromek - Ben + - Evgeniy Tetenchuk - dasmfm - Arnaud Buathier (arnapou) - chesteroni (chesteroni) @@ -1403,6 +1412,7 @@ Symfony is the result of the work of many people who made the code better - Benjamin Long - Matt Janssen - Peter Gribanov + - Ben Johnson - kwiateusz - David Soria Parra - Sergiy Sokolenko @@ -1526,6 +1536,7 @@ Symfony is the result of the work of many people who made the code better - smokeybear87 - Gustavo Adrian - Kevin Weber + - Dionysis Arvanitis - Sergey Fedotov - Michael - fh-github@fholzhauer.de From 68124f52fa41df2f10bd1eaa75f20990b2ecd04c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Sep 2016 20:05:16 -0700 Subject: [PATCH 04/93] updated VERSION for 2.7.17 --- 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 d4e7b3d9843fa..9211aa527aaf0 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.17-DEV'; + const VERSION = '2.7.17'; const VERSION_ID = 20717; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 17; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 2511f2a19192c083388113ad75598921e6664678 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Sep 2016 20:54:47 -0700 Subject: [PATCH 05/93] bumped Symfony version to 2.7.18 --- 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 9211aa527aaf0..4215ea070d20b 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.17'; - const VERSION_ID = 20717; + const VERSION = '2.7.18-DEV'; + const VERSION_ID = 20718; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 17; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 18; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 68698f2bd4c2ed64f7702b7a428ff3674abc24c2 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Fri, 2 Sep 2016 17:52:32 +0100 Subject: [PATCH 06/93] [BrowserKit] Fix cookie expiration on 32 bit systems On 32-bit systems the cookie expiration value was not being calculated correctly as it was being fetched as an integer. When the timestamp exceeded the PHP_INT_MAX size it would return an invalid value, breaking the cookie construction. The BrowserKit cookie has now been updated to get the timestamp as a string which works around this platform limitation. --- src/Symfony/Component/BrowserKit/Cookie.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index 604d12d84d55a..eeef805d72099 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -76,7 +76,7 @@ public function __construct($name, $value, $expires = null, $path = null, $domai throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires)); } - $this->expires = $timestampAsDateTime->getTimestamp(); + $this->expires = $timestampAsDateTime->format('U'); } } @@ -205,13 +205,13 @@ private static function parseDate($dateValue) foreach (self::$dateFormats as $dateFormat) { if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { - return $date->getTimestamp(); + return $date->format('U'); } } // attempt a fallback for unusual formatting if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { - return $date->getTimestamp(); + return $date->format('U'); } throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue)); @@ -304,6 +304,6 @@ public function isHttpOnly() */ public function isExpired() { - return null !== $this->expires && 0 !== $this->expires && $this->expires < time(); + return null !== $this->expires && 0 != $this->expires && $this->expires < time(); } } From a4bb2fc588f143794e4f5097f7fa76368d79ff76 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Sep 2016 13:39:02 -0700 Subject: [PATCH 07/93] updated CHANGELOG for 2.8.10 --- CHANGELOG-2.8.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG-2.8.md b/CHANGELOG-2.8.md index f3c89cff979bb..1de96a66a9b3f 100644 --- a/CHANGELOG-2.8.md +++ b/CHANGELOG-2.8.md @@ -7,6 +7,34 @@ 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.10 (2016-09-02) + + * bug #19786 Update profiler's layout to use flexbox (javiereguiluz) + * bug #19794 [VarDumper] Various minor fixes & cleanups (nicolas-grekas) + * bug #19751 Fixes the calendar in constructor to handle null (wakqasahmed) + * bug #19388 [Validator][GroupSequence] fixed GroupSequence validation ignores PropetyMetadata of parent classes (Sandro Hopf) + * bug #19601 [FrameworkBundle] Added friendly exception when constraint validator class does not exist (yceruto) + * bug #19580 [Validator] fixed duplicate constraints with parent class interfaces (dmaicher) + * bug #19647 [Debug] Swap dumper services at bootstrap (lyrixx) + * bug #19685 [DI] Include dynamic services in alternatives (ro0NL) + * bug #19702 [Debug][HttpKernel][VarDumper] Prepare for committed 7.2 changes (aka "small-bc-breaks") (nicolas-grekas) + * bug #19704 [DependencyInjection] PhpDumper::isFrozen inconsistency (allflame) + * bug #19643 [DependencyInjection] Fix service autowiring inheritance (chalasr) + * bug #19667 [SecurityBundle] Add missing deprecation notice for form_login.intention (ro0NL) + * bug #19666 Verify explicitly that the request IP is a valid IPv4 address (nesk) + * bug #19660 Disable CLI color for Windows 10 greater than 10.0.10586 (mlocati) + * bug #19663 Exception details break the layout (Dionysis Arvanitis) + * bug #19651 [HttpKernel] Fix HttpCache validation HTTP method (tgalopin) + * bug #19623 [VarDumper] Fix dumping continuations (nicolas-grekas) + * bug #19549 [HttpFoundation] fixed Request::getContent() reusage bug (1ma) + * bug #19373 [Form] Skip CSRF validation on form when POST max size is exceeded (jameshalsall) + * bug #19541 Fix #19531 [Form] DateType fails parsing when midnight is not a valid time (mbeccati) + * bug #19579 [Process] Strengthen Windows pipe files opening (again...) (nicolas-grekas) + * bug #19564 Added class existence check if is_subclass_of() fails in compiler passes (SCIF) + * bug #19522 [SwiftMailerBridge] Fix flawed deprecation message (chalasr) + * bug #19510 [Process] Fix double-fread() when reading unix pipes (nicolas-grekas) + * bug #19508 [Process] Fix AbstractPipes::write() for a situation seen on HHVM (at least) (nicolas-grekas) + * 2.8.9 (2016-07-30) * bug #19470 undefined offset fix (#19406) (ReenExe) From 84fee0c855e7ad50d599f33dec6cadb0d9d70dbf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Sep 2016 13:39:36 -0700 Subject: [PATCH 08/93] updated VERSION for 2.8.10 --- 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 faa620eeb4f04..476eb4ec96c3e 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.10-DEV'; + const VERSION = '2.8.10'; const VERSION_ID = 20810; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 10; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 356a0ac7e4ed63cb89e75ef4ce34ecd6229f1e74 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Sep 2016 08:25:19 -0700 Subject: [PATCH 09/93] bumped Symfony version to 2.8.11 --- 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 476eb4ec96c3e..1e62cf1266f98 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.10'; - const VERSION_ID = 20810; + const VERSION = '2.8.11-DEV'; + const VERSION_ID = 20811; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 10; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 11; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 260702b3baf8ae1a80059c3f3f40aaeccabecd1c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Sep 2016 09:29:57 -0700 Subject: [PATCH 10/93] bumped Symfony version to 3.1.5 --- 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 28c18dcbab8ae..4b311c8601b2b 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 = '3.1.4'; - const VERSION_ID = 30104; + const VERSION = '3.1.5-DEV'; + const VERSION_ID = 30105; const MAJOR_VERSION = 3; const MINOR_VERSION = 1; - const RELEASE_VERSION = 4; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 5; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2017'; const END_OF_LIFE = '07/2017'; From ac742dfc48fd45fb3307abb8f3b3d4f97941591c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 4 Sep 2016 19:06:49 +0200 Subject: [PATCH 11/93] Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" This reverts commit c89f80a9cd3f291159ba5e466c7c968cf15d476a, reversing changes made to 386e5e78b4ad8356fe01ac5406872a56b5177134. --- src/Symfony/Component/DependencyInjection/Container.php | 5 +++-- .../Component/DependencyInjection/ContainerBuilder.php | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 3cfdd616c5a17..f6c953f550993 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -223,6 +223,7 @@ public function has($id) if ('service_container' === $id || isset($this->aliases[$id]) || isset($this->services[$id]) + || array_key_exists($id, $this->services) ) { return true; } @@ -265,7 +266,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE $id = $this->aliases[$id]; } // Re-use shared service instance if it exists. - if (isset($this->services[$id])) { + if (isset($this->services[$id]) || array_key_exists($id, $this->services)) { return $this->services[$id]; } @@ -347,7 +348,7 @@ public function initialized($id) $id = $this->aliases[$id]; } - return isset($this->services[$id]); + return isset($this->services[$id]) || array_key_exists($id, $this->services); } /** diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 70d1efda4cad7..0813110deda8f 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -436,7 +436,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV return $service; } - if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) { + if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) { return $this->get($this->aliasDefinitions[$id]); } @@ -784,7 +784,7 @@ public function setDefinition($id, Definition $definition) */ public function hasDefinition($id) { - return isset($this->definitions[strtolower($id)]); + return array_key_exists(strtolower($id), $this->definitions); } /** @@ -800,7 +800,7 @@ public function getDefinition($id) { $id = strtolower($id); - if (!isset($this->definitions[$id])) { + if (!array_key_exists($id, $this->definitions)) { throw new ServiceNotFoundException($id); } From 8cb28bf7517d1c2e27da4d3eeb557fbffedc1ec8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Sep 2016 09:18:51 +0200 Subject: [PATCH 12/93] [DI] Add anti-regression test --- .../Tests/ContainerTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 013ee82316084..e451806bb7807 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -256,6 +256,18 @@ public function testGetReturnsNullOnInactiveScope() $this->assertNull($sc->get('inactive', ContainerInterface::NULL_ON_INVALID_REFERENCE)); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExcepionMessage You have requested a synthetic service ("request"). The DIC does not know how to construct this service. + */ + public function testGetSyntheticServiceAlwaysThrows() + { + require_once __DIR__.'/Fixtures/php/services9.php'; + + $container = new \ProjectServiceContainer(); + $container->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE); + } + public function testHas() { $sc = new ProjectServiceContainer(); @@ -287,14 +299,17 @@ public function testEnterLeaveCurrentScope() $container->addScope(new Scope('foo')); $container->enterScope('foo'); + $container->set('foo', new \stdClass(), 'foo'); $scoped1 = $container->get('scoped'); $scopedFoo1 = $container->get('scoped_foo'); $container->enterScope('foo'); + $container->set('foo', new \stdClass(), 'foo'); $scoped2 = $container->get('scoped'); $scoped3 = $container->get('SCOPED'); $scopedFoo2 = $container->get('scoped_foo'); + $container->set('foo', null, 'foo'); $container->leaveScope('foo'); $scoped4 = $container->get('scoped'); $scopedFoo3 = $container->get('scoped_foo'); @@ -641,6 +656,12 @@ protected function getScopedSynchronizedFooService() return $this->services['scoped_bar'] = $this->scopedServices['foo']['scoped_bar'] = new \stdClass(); } + protected function synchronizeFooService() + { + // Typically get the service to pass it to a setter + $this->get('foo'); + } + protected function synchronizeScopedSynchronizedFooService() { $this->synchronized = true; From 4a041e9a759538058c09263fb46b4100144e1a48 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Mon, 5 Sep 2016 15:19:46 +0800 Subject: [PATCH 13/93] Make ReflectionExtractor compatible with ReflectionType changes in PHP 7.1 --- .../Extractor/ReflectionExtractor.php | 2 +- .../Extractors/ReflectionExtractorTest.php | 19 ++++++++++++ .../Tests/Fixtures/Php71Dummy.php | 30 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php71Dummy.php diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 63454a5b45319..1d3d3a2083ca8 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -231,7 +231,7 @@ private function extractFromAccessor($class, $property) */ private function extractFromReflectionType(\ReflectionType $reflectionType) { - $phpTypeOrClass = (string) $reflectionType; + $phpTypeOrClass = method_exists($reflectionType, 'getName') ? $reflectionType->getName() : (string) $reflectionType; $nullable = $reflectionType->allowsNull(); if ($reflectionType->isBuiltin()) { diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index dfc13c025eb41..10b056220d539 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -94,6 +94,25 @@ public function php7TypesProvider() ); } + /** + * @dataProvider php71TypesProvider + * @requires PHP 7.1 + */ + public function testExtractPhp71Type($property, array $type = null) + { + $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php71Dummy', $property, array())); + } + + public function php71TypesProvider() + { + return array( + array('foo', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true))), + array('bar', array(new Type(Type::BUILTIN_TYPE_INT, true))), + array('baz', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))), + array('donotexist', null), + ); + } + public function testIsReadable() { $this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'bar', array())); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php71Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php71Dummy.php new file mode 100644 index 0000000000000..d93c67a3d38bd --- /dev/null +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php71Dummy.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyInfo\Tests\Fixtures; + +/** + * @author Teoh Han Hui + */ +class Php71Dummy +{ + public function getFoo(): ?array + { + } + + public function setBar(?int $bar) + { + } + + public function addBaz(string $baz) + { + } +} From aa3c66e8c98ca16634126b1988b572a879f59ab1 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 5 Sep 2016 17:38:17 +0100 Subject: [PATCH 14/93] [Form] Fix transformer tests after the ICU update --- .../IntegerToLocalizedStringTransformerTest.php | 4 ++-- .../NumberToLocalizedStringTransformerTest.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index c51132518ba67..3295e3d85fe8c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -108,10 +108,10 @@ public function testReverseTransformEmpty() public function testReverseTransformWithGrouping() { - // Since we test against "de_AT", we need the full implementation + // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this); - \Locale::setDefault('de_AT'); + \Locale::setDefault('de_DE'); $transformer = new IntegerToLocalizedStringTransformer(null, true); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 2ea4e9dd2a8f4..ab58d3685d774 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -54,8 +54,8 @@ public function testTransform($from, $to, $locale) public function provideTransformationsWithGrouping() { return array( - array(1234.5, '1.234,5', 'de_AT'), - array(12345.912, '12.345,912', 'de_AT'), + array(1234.5, '1.234,5', 'de_DE'), + array(12345.912, '12.345,912', 'de_DE'), array(1234.5, '1 234,5', 'fr'), array(1234.5, '1 234,5', 'ru'), array(1234.5, '1 234,5', 'fi'), @@ -393,10 +393,10 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() { - // Since we test against "de_AT", we need the full implementation + // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this); - \Locale::setDefault('de_AT'); + \Locale::setDefault('de_DE'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -408,10 +408,10 @@ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() { - // Since we test against "de_AT", we need the full implementation + // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this); - \Locale::setDefault('de_AT'); + \Locale::setDefault('de_DE'); $transformer = new NumberToLocalizedStringTransformer(null, true); From 647b3d2f54f6ae2ac7f61d3597e9661755937413 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Sep 2016 14:06:16 +0200 Subject: [PATCH 15/93] [ClassLoader] Fix ClassCollectionLoader inlining with declare(strict_types=1) --- .../ClassLoader/ClassCollectionLoader.php | 52 ++++++++++++++----- .../Tests/ClassCollectionLoaderTest.php | 14 +++-- .../Tests/ClassMapGeneratorTest.php | 1 + .../Fixtures/Namespaced/WithStrictTypes.php | 13 +++++ 4 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithStrictTypes.php diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index b695b9272f28c..18e22a5bca603 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -58,7 +58,12 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = $classes = array_unique($classes); - $cache = $cacheDir.'/'.$name.$extension; + // cache the core classes + if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { + throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir)); + } + $cacheDir = rtrim(realpath($cacheDir), '/'.DIRECTORY_SEPARATOR); + $cache = $cacheDir.DIRECTORY_SEPARATOR.$name.$extension; // auto-reload $reload = false; @@ -99,6 +104,10 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = } } + $c = '(?:\s*+(?:(?:#|//)[^\n]*+\n|/\*(?:(?getFileName(); + $files[] = $file = $class->getFileName(); + $c = file_get_contents($file); - $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($class->getFileName())); + if (preg_match($strictTypesRegex, $c)) { + $file = explode(DIRECTORY_SEPARATOR, $file); - // fakes namespace declaration for global code - if (!$class->inNamespace()) { - $c = "\nnamespace\n{\n".$c."\n}\n"; - } + for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) { + if ($file[$i] !== $cacheDir[$i]) { + break; + } + } + if (1 >= $i) { + $file = var_export(implode(DIRECTORY_SEPARATOR, $file), true); + } else { + $file = array_slice($file, $i); + $file = str_repeat('..'.DIRECTORY_SEPARATOR, count($cacheDir) - $i).implode(DIRECTORY_SEPARATOR, $file); + $file = '__DIR__.'.var_export(DIRECTORY_SEPARATOR.$file, true); + } - $c = self::fixNamespaceDeclarations('\s*$/'), '', $c); - $content .= $c; - } + // fakes namespace declaration for global code + if (!$class->inNamespace()) { + $c = "\nnamespace\n{\n".$c."\n}\n"; + } - // cache the core classes - if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { - throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir)); + $c = self::fixNamespaceDeclarations(' realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', 'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php', + 'Namespaced\WithStrictTypes' => realpath(__DIR__).'/Fixtures/Namespaced/WithStrictTypes.php', ), ), array(__DIR__.'/Fixtures/beta/NamespaceCollision', array( diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithStrictTypes.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithStrictTypes.php new file mode 100644 index 0000000000000..3c7870592b3cb --- /dev/null +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/Namespaced/WithStrictTypes.php @@ -0,0 +1,13 @@ + Date: Fri, 2 Sep 2016 14:13:13 -0400 Subject: [PATCH 16/93] Code enhancement and cleanup --- .../AbstractDoctrineExtension.php | 2 +- src/Symfony/Bridge/Twig/Command/DebugCommand.php | 1 - .../FrameworkBundle/Command/YamlLintCommand.php | 1 - .../TwigBundle/Extension/ActionsExtension.php | 2 ++ .../EventListener/WebDebugToolbarListener.php | 2 -- .../Component/BrowserKit/Tests/CookieTest.php | 2 +- src/Symfony/Component/Console/Command/Command.php | 2 ++ .../Console/Descriptor/MarkdownDescriptor.php | 2 +- .../Component/Console/Helper/ProgressHelper.php | 2 -- .../Component/Console/Helper/QuestionHelper.php | 4 +++- .../Console/Tests/Helper/HelperSetTest.php | 7 ------- .../Component/CssSelector/XPath/Translator.php | 3 --- src/Symfony/Component/Debug/ErrorHandler.php | 4 +++- .../Compiler/ServiceReferenceGraphEdge.php | 2 +- .../Tests/Dumper/PhpDumperTest.php | 2 +- .../Component/ExpressionLanguage/TokenStream.php | 4 ++++ src/Symfony/Component/Filesystem/Filesystem.php | 2 ++ .../Component/Form/ChoiceList/ArrayChoiceList.php | 13 +++++++------ .../Form/ChoiceList/ArrayKeyChoiceList.php | 13 +++++++------ .../DateTimeToLocalizedStringTransformer.php | 2 -- .../Extension/DataCollector/FormDataExtractor.php | 6 ------ .../Tests/Extension/Core/Type/ChoiceTypeTest.php | 2 +- .../Component/HttpFoundation/JsonResponse.php | 13 ++++++++++++- .../Session/Flash/FlashBagInterface.php | 2 ++ .../Storage/Handler/MongoDbSessionHandler.php | 2 ++ .../LazyLoadingFragmentHandler.php | 1 + .../Component/HttpKernel/Profiler/Profiler.php | 4 ++-- .../EventListener/ValidateRequestListenerTest.php | 2 +- .../Component/HttpKernel/Tests/HttpKernelTest.php | 2 +- src/Symfony/Component/HttpKernel/UriSigner.php | 2 +- .../Intl/DateFormatter/IntlDateFormatter.php | 2 +- .../Intl/ResourceBundle/LanguageBundle.php | 1 + src/Symfony/Component/Process/Tests/ProcessTest.php | 2 +- .../Http/Tests/Firewall/RememberMeListenerTest.php | 2 +- src/Symfony/Component/Templating/PhpEngine.php | 1 + .../Translation/DataCollectorTranslator.php | 2 +- .../Component/Translation/Dumper/MoFileDumper.php | 2 +- .../Component/Translation/Loader/MoFileLoader.php | 2 +- .../Tests/Validator/Abstract2Dot5ApiTest.php | 1 + .../Component/VarDumper/Cloner/VarCloner.php | 1 - .../Component/VarDumper/Dumper/AbstractDumper.php | 5 +++-- 41 files changed, 70 insertions(+), 59 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 534d762e73f11..e1cbbbfb1a36e 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -336,7 +336,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD $memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%'; $memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%'; $memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%'; - $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; + $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; $cacheDef = new Definition($memcacheClass); $memcacheInstance = new Definition($memcacheInstanceClass); $memcacheInstance->addMethodCall('connect', array( diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 4bf52c5dd3e36..898e0e2233bb6 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -140,7 +140,6 @@ private function getMetadata($type, $entity) return; } if ($type === 'functions' || $type === 'filters') { - $args = array(); $cb = $entity->getCallable(); if (is_null($cb)) { return; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php index c4c4bb9cf1d27..4c12e7d2fca05 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php @@ -85,7 +85,6 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename)); } - $files = array(); if (is_file($filename)) { $files = array($filename); } elseif (is_dir($filename)) { diff --git a/src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php b/src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php index 07f956b07ef52..8b4759ea270a8 100644 --- a/src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php +++ b/src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php @@ -52,6 +52,8 @@ public function __construct($handler) * @param string $uri A URI * @param array $options An array of options * + * @return string|null The Response content or null when the Response is streamed + * * @see FragmentHandler::render() */ public function renderUri($uri, array $options = array()) diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index ab67078dd6ecd..2dc0b618d5302 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -108,8 +108,6 @@ public function onKernelResponse(FilterResponseEvent $event) /** * Injects the web debug toolbar into the given Response. - * - * @param Response $response A Response instance */ protected function injectToolbar(Response $response, Request $request) { diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 61b364e6d1eac..5a724333d350f 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -178,7 +178,7 @@ public function testIsExpired() } /** - * @expectedException UnexpectedValueException + * @expectedException \UnexpectedValueException * @expectedExceptionMessage The cookie expiration time "string" is not valid. */ public function testConstructException() diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index e38002b6d8b39..dcda54b637953 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -569,6 +569,8 @@ public function getSynopsis($short = false) * Add a command usage example. * * @param string $usage The usage, it'll be prefixed with the command name + * + * @return Command The current instance */ public function addUsage($usage) { diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index d3d76a4201025..2eb9944d6213c 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -98,7 +98,7 @@ protected function describeCommand(Command $command, array $options = array()) .'* Description: '.($command->getDescription() ?: '')."\n" .'* Usage:'."\n\n" .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) { - return $carry .= ' * `'.$usage.'`'."\n"; + return $carry.' * `'.$usage.'`'."\n"; }) ); diff --git a/src/Symfony/Component/Console/Helper/ProgressHelper.php b/src/Symfony/Component/Console/Helper/ProgressHelper.php index 0e18375895fbf..625fb8120824a 100644 --- a/src/Symfony/Component/Console/Helper/ProgressHelper.php +++ b/src/Symfony/Component/Console/Helper/ProgressHelper.php @@ -371,8 +371,6 @@ private function generate($finish = false) } if (isset($this->formatVars['bar'])) { - $completeBars = 0; - if ($this->max > 0) { $completeBars = floor($percent * $this->barWidth); } else { diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index c158f73593817..6d6850d1ae826 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -200,6 +200,7 @@ protected function writeError(OutputInterface $output, \Exception $error) * * @param OutputInterface $output * @param Question $question + * @param resource $inputStream * * @return string */ @@ -316,7 +317,8 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu /** * Gets a hidden response from user. * - * @param OutputInterface $output An Output instance + * @param OutputInterface $output An Output instance + * @param resource $inputStream The handler resource * * @return string The answer * diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php index d615899ca9899..24deb341f681c 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -107,13 +107,6 @@ public function testIteration() } } - /** - * Create a generic mock for the helper interface. Optionally check for a call to setHelperSet with a specific - * helperset instance. - * - * @param string $name - * @param HelperSet $helperset allows a mock to verify a particular helperset set is being added to the Helper - */ private function getGenericMockHelper($name, HelperSet $helperset = null) { $mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface'); diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index aac2691f1adfb..3582048260496 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -68,9 +68,6 @@ class Translator implements TranslatorInterface */ private $attributeMatchingTranslators = array(); - /** - * Constructor. - */ public function __construct(ParserInterface $parser = null) { $this->mainParser = $parser ?: new Parser(); diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index a8c072f76bf85..bf12d155e56c1 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -349,10 +349,12 @@ private function reRegister($prev) /** * Handles errors by filtering then logging them according to the configured bit fields. * - * @param int $type One of the E_* constants + * @param int $type One of the E_* constants + * @param string $message * @param string $file * @param int $line * @param array $context + * @param array $backtrace * * @return bool Returns false when no handling happens so that the PHP engine can handle the error itself * diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php index 056be7fa3f5d4..e3c793c4f4eaf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php @@ -39,7 +39,7 @@ public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceRefere /** * Returns the value of the edge. * - * @return ServiceReferenceGraphNode + * @return string */ public function getValue() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 118a55244597a..3d9570d4dbcef 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -169,7 +169,7 @@ public function testAddServiceInvalidServiceId() /** * @dataProvider provideInvalidFactories - * @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage Cannot dump definition */ public function testInvalidFactories($factory) diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index ac9599769fa9c..6c4af745b2cfe 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/src/Symfony/Component/ExpressionLanguage/TokenStream.php @@ -60,6 +60,10 @@ public function next() /** * Tests a token. + * + * @param array|int $type The type to test + * @param string|null $value The token value + * @param string|null $message The syntax error message */ public function expect($type, $value = null, $message = null) { diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index df12e9e49992f..f114a2de58bcd 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -285,6 +285,8 @@ public function rename($origin, $target, $overwrite = false) * * @param string $filename Path to the file * + * @return bool + * * @throws IOException When windows path is longer than 258 characters */ private function isReadable($filename) diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index 82ebe7421d9e7..7f2824fab216a 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -183,12 +183,13 @@ public function getValuesForChoices(array $choices) /** * Flattens an array into the given output variables. * - * @param array $choices The array to flatten - * @param callable $value The callable for generating choice values - * @param array $choicesByValues The flattened choices indexed by the - * corresponding values - * @param array $keysByValues The original keys indexed by the - * corresponding values + * @param array $choices The array to flatten + * @param callable $value The callable for generating choice values + * @param array $choicesByValues The flattened choices indexed by the + * corresponding values + * @param array $keysByValues The original keys indexed by the + * corresponding values + * @param array $structuredValues The values indexed by the original keys * * @internal Must not be used by user-land code */ diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php index 7c3c107d0f720..2490fe8fb33cb 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php @@ -153,12 +153,13 @@ public function getValuesForChoices(array $choices) /** * Flattens and flips an array into the given output variable. * - * @param array $choices The array to flatten - * @param callable $value The callable for generating choice values - * @param array $choicesByValues The flattened choices indexed by the - * corresponding values - * @param array $keysByValues The original keys indexed by the - * corresponding values + * @param array $choices The array to flatten + * @param callable $value The callable for generating choice values + * @param array $choicesByValues The flattened choices indexed by the + * corresponding values + * @param array $keysByValues The original keys indexed by the + * corresponding values + * @param array $structuredValues The values indexed by the original keys * * @internal Must not be used by user-land code */ diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 352b7c85ff506..51f692755eb6d 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -178,8 +178,6 @@ protected function getIntlDateFormatter($ignoreTimezone = false) /** * Checks if the pattern contains only a date. * - * @param string $pattern The input pattern - * * @return bool */ protected function isPatternDateOnly() diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php index 71f07b5fe069f..20b270d845a4d 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php @@ -23,14 +23,8 @@ */ class FormDataExtractor implements FormDataExtractorInterface { - /** - * @var ValueExporter - */ private $valueExporter; - /** - * Constructs a new data extractor. - */ public function __construct(ValueExporter $valueExporter = null) { $this->valueExporter = $valueExporter ?: new ValueExporter(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index b7bea7e5c8062..b675d5d6eee08 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -2040,7 +2040,7 @@ public function getOptionsWithPlaceholderAndEmptyValue() 'An empty string empty_value is used if placeholder is also an empty string when required [maintains BC]' => array(false, false, true, '', '', ''), 'A non-empty string empty_value is used if placeholder is an empty string when required [maintains BC]' => array(false, false, true, '', 'bar', 'bar'), 'A non-empty string placeholder takes precedence over an empty_value set to false when required' => array(false, false, true, 'foo', false, 'foo'), - 'A non-empty string placeholder takes precedence over a not set empty_value' => array(false, false, true, 'foo', null, 'foo'), + 'A non-empty string placeholder takes precedence over a not set empty_value when required' => array(false, false, true, 'foo', null, 'foo'), 'A non-empty string placeholder takes precedence over an empty string empty_value when required' => array(false, false, true, 'foo', '', 'foo'), 'A non-empty string placeholder takes precedence over a non-empty string empty_value when required' => array(false, false, true, 'foo', 'bar', 'foo'), // single expanded, not required diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 8df683ddfb7f8..25584ed21c16c 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -50,7 +50,18 @@ public function __construct($data = null, $status = 200, $headers = array()) } /** - * {@inheritdoc} + * Factory method for chainability. + * + * Example: + * + * return JsonResponse::create($data, 200) + * ->setSharedMaxAge(300); + * + * @param mixed $data The json response data + * @param int $status The response status code + * @param array $headers An array of response headers + * + * @return JsonResponse */ public static function create($data = null, $status = 200, $headers = array()) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php index 80e97f17cdff3..25f3d57b5417b 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php @@ -72,6 +72,8 @@ public function all(); /** * Sets all flash messages. + * + * @param array $messages */ public function setAll(array $messages); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 7efc1348c8027..8408f000cdbf8 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -214,6 +214,8 @@ protected function getMongo() * Return an instance of a MongoDate or \MongoDB\BSON\UTCDateTime * * @param int $seconds An integer representing UTC seconds since Jan 1 1970. Defaults to now. + * + * @return \MongoDate|\MongoDB\BSON\UTCDateTime */ private function createDateTime($seconds = null) { diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php b/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php index 4efe7cb620736..c611e9eaf0bfa 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php @@ -35,6 +35,7 @@ public function __construct(ContainerInterface $container, $debug = false, Reque /** * Adds a service as a fragment renderer. * + * @param string $name The service name * @param string $renderer The render service id */ public function addRendererService($name, $renderer) diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php index 35d3a8f1b4713..9bfc54e1a19cf 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -78,7 +78,7 @@ public function enable() * * @param Response $response A Response instance * - * @return Profile A Profile instance + * @return Profile|false A Profile instance */ public function loadProfileFromResponse(Response $response) { @@ -149,7 +149,7 @@ public function export(Profile $profile) * * @param string $data A data string as exported by the export() method * - * @return Profile A Profile instance + * @return Profile|false A Profile instance */ public function import($data) { diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php index 842a3869cba79..b9d8f06f00848 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php @@ -21,7 +21,7 @@ class ValidateRequestListenerTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException + * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException */ public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() { diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 372c2a3c1b1ae..0fd0fdec7b98f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -272,7 +272,7 @@ public function testVerifyRequestStackPushPopDuringHandle() } /** - * @expectedException Symfony\Component\HttpKernel\Exception\BadRequestHttpException + * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException */ public function testInconsistentClientIpsOnMasterRequests() { diff --git a/src/Symfony/Component/HttpKernel/UriSigner.php b/src/Symfony/Component/HttpKernel/UriSigner.php index c2d0d79664c42..fa84899064e88 100644 --- a/src/Symfony/Component/HttpKernel/UriSigner.php +++ b/src/Symfony/Component/HttpKernel/UriSigner.php @@ -98,7 +98,7 @@ private function buildUrl(array $url, array $params = array()) $host = isset($url['host']) ? $url['host'] : ''; $port = isset($url['port']) ? ':'.$url['port'] : ''; $user = isset($url['user']) ? $url['user'] : ''; - $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; + $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; $pass = ($user || $pass) ? "$pass@" : ''; $path = isset($url['path']) ? $url['path'] : ''; $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index c3b85bbb6f0ad..e6b01d3290e28 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -564,7 +564,7 @@ public function setTimeZoneId($timeZoneId) try { $this->dateTimeZone = new \DateTimeZone($timeZoneId); if ('GMT' !== $timeZoneId && $this->dateTimeZone->getName() !== $timeZoneId) { - $timeZoneId = $timeZone = $this->getTimeZoneId(); + $timeZone = $this->getTimeZoneId(); } } catch (\Exception $e) { if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) { diff --git a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php index cfe82ca3c3135..d12b892a10dcb 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php @@ -42,6 +42,7 @@ class LanguageBundle extends LanguageDataProvider implements LanguageBundleInter * @param string $path * @param BundleEntryReaderInterface $reader * @param LocaleDataProvider $localeProvider + * @param ScriptDataProvider $scriptProvider */ public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider, ScriptDataProvider $scriptProvider) { diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 0fcedccf8bf07..f8608337a4a04 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -943,7 +943,7 @@ public function provideMethodsThatNeedARunningProcess() /** * @dataProvider provideMethodsThatNeedATerminatedProcess - * @expectedException Symfony\Component\Process\Exception\LogicException + * @expectedException \Symfony\Component\Process\Exception\LogicException * @expectedExceptionMessage Process must be terminated before calling */ public function testMethodsThatNeedATerminatedProcess($method) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index 7309042d4764b..cd2f1b8735b86 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -101,7 +101,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti } /** - * @expectedException Symfony\Component\Security\Core\Exception\AuthenticationException + * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException * @expectedExceptionMessage Authentication failed. */ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation() diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 253796c0511b3..75846455b9ee4 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -142,6 +142,7 @@ protected function evaluate(Storage $template, array $parameters = array()) throw new \InvalidArgumentException('Invalid parameter (view)'); } + // the view variable is exposed to the require file below $view = $this; if ($this->evalTemplate instanceof FileStorage) { extract($this->evalParameters, EXTR_SKIP); diff --git a/src/Symfony/Component/Translation/DataCollectorTranslator.php b/src/Symfony/Component/Translation/DataCollectorTranslator.php index 1aedab7449aab..f88a467a1d12c 100644 --- a/src/Symfony/Component/Translation/DataCollectorTranslator.php +++ b/src/Symfony/Component/Translation/DataCollectorTranslator.php @@ -108,7 +108,7 @@ public function getCollectedMessages() * @param string|null $locale * @param string|null $domain * @param string $id - * @param string $trans + * @param string $translation */ private function collectMessage($locale, $domain, $id, $translation) { diff --git a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php index f8dc6ac395fc4..b01699071401d 100644 --- a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php @@ -26,7 +26,7 @@ class MoFileDumper extends FileDumper */ public function format(MessageCatalogue $messages, $domain = 'messages') { - $output = $sources = $targets = $sourceOffsets = $targetOffsets = ''; + $sources = $targets = $sourceOffsets = $targetOffsets = ''; $offsets = array(); $size = 0; diff --git a/src/Symfony/Component/Translation/Loader/MoFileLoader.php b/src/Symfony/Component/Translation/Loader/MoFileLoader.php index f6a8fe923a9bf..191b86337aa72 100644 --- a/src/Symfony/Component/Translation/Loader/MoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/MoFileLoader.php @@ -117,7 +117,7 @@ private function parse($resource) $messages = array(); for ($i = 0; $i < $count; ++$i) { - $singularId = $pluralId = null; + $pluralId = null; $translated = null; fseek($stream, $offsetId + $i * 8); diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php index e85177ef59b24..27d5a25ce26a8 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php @@ -40,6 +40,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest /** * @param MetadataFactoryInterface $metadataFactory + * @param array $objectInitializers * * @return ValidatorInterface */ diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 9b34198a41d8b..af467056a5d97 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -25,7 +25,6 @@ class VarCloner extends AbstractCloner protected function doClone($var) { $useExt = $this->useExt; - $i = 0; // Current iteration position in $queue $len = 1; // Length of $queue $pos = 0; // Number of cloned items past the first level $refsCounter = 0; // Hard references counter diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index a5f2b35296870..22c60b6e51c72 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -168,8 +168,9 @@ protected function dumpLine($depth) /** * Generic line dumper callback. * - * @param string $line The line to write - * @param int $depth The recursive depth in the dumped structure + * @param string $line The line to write + * @param int $depth The recursive depth in the dumped structure + * @param string $indentPad The line indent pad */ protected function echoLine($line, $depth, $indentPad) { From c8f3741eba5c8069d99d7149018a22f32093c44b Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Tue, 6 Sep 2016 01:03:05 +0300 Subject: [PATCH 17/93] Update GroupSequence.php Corrected the docblock example --- src/Symfony/Component/Validator/Constraints/GroupSequence.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php index aea05583103d5..4b4384f0beb4f 100644 --- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -19,7 +19,7 @@ * When validating a group sequence, each group will only be validated if all * of the previous groups in the sequence succeeded. For example: * - * $validator->validate($address, null, new GroupSequence('Basic', 'Strict')); + * $validator->validate($address, null, new GroupSequence(['Basic', 'Strict'])); * * In the first step, all constraints that belong to the group "Basic" will be * validated. If none of the constraints fail, the validator will then validate From 8a9e0f526d56d75f0991c25e7f9f7b7ce9281b0f Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 4 Sep 2016 03:01:20 +0200 Subject: [PATCH 18/93] [FrameworkBundle] Check for class existence before is_subclass_of --- .../DependencyInjection/Compiler/AddConsoleCommandPass.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php index 4ab0d82ed120a..7af53395f8744 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php @@ -38,6 +38,10 @@ public function process(ContainerBuilder $container) $class = $container->getParameterBag()->resolveValue($definition->getClass()); if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) { + if (!class_exists($class, false)) { + throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + } + throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id)); } $container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id); From 9c48756a19a930ce4dc13eb47a50b89de9e3b921 Mon Sep 17 00:00:00 2001 From: Iltar van der Berg Date: Thu, 1 Sep 2016 09:08:10 +0200 Subject: [PATCH 19/93] Fixed the nullable support for php 7.1 and below --- .../Controller/ControllerResolver.php | 22 +++++++++++++- .../Controller/ControllerResolverTest.php | 29 +++++++++++++++++++ .../Controller/NullableController.php | 19 ++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 1d7c49607dfe9..c76b57bb6a7db 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -27,6 +27,15 @@ class ControllerResolver implements ControllerResolverInterface { private $logger; + /** + * If the ...$arg functionality is available. + * + * Requires at least PHP 5.6.0 or HHVM 3.9.1 + * + * @var bool + */ + private $supportsVariadic; + /** * Constructor. * @@ -35,6 +44,8 @@ class ControllerResolver implements ControllerResolverInterface public function __construct(LoggerInterface $logger = null) { $this->logger = $logger; + + $this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic'); } /** @@ -99,13 +110,20 @@ public function getArguments(Request $request, $controller) return $this->doGetArguments($request, $controller, $r->getParameters()); } + /** + * @param Request $request + * @param callable $controller + * @param \ReflectionParameter[] $parameters + * + * @return array The arguments to use when calling the action + */ protected function doGetArguments(Request $request, $controller, array $parameters) { $attributes = $request->attributes->all(); $arguments = array(); foreach ($parameters as $param) { if (array_key_exists($param->name, $attributes)) { - if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) { + if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) { $arguments = array_merge($arguments, array_values($attributes[$param->name])); } else { $arguments[] = $attributes[$param->name]; @@ -114,6 +132,8 @@ protected function doGetArguments(Request $request, $controller, array $paramete $arguments[] = $request; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); + } elseif ($param->allowsNull()) { + $arguments[] = null; } else { if (is_array($controller)) { $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 101782e49079e..9aa7e20a9a910 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -13,6 +13,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\HttpKernel\Controller\ControllerResolver; +use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; use Symfony\Component\HttpFoundation\Request; @@ -222,6 +223,34 @@ public function testCreateControllerCanReturnAnyCallable() $mock->getController($request); } + /** + * @requires PHP 7.1 + */ + public function testGetNullableArguments() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); + $request->attributes->set('foo', 'foo'); + $request->attributes->set('bar', new \stdClass()); + $request->attributes->set('mandatory', 'mandatory'); + $controller = array(new NullableController(), 'action'); + $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), $resolver->getArguments($request, $controller)); + } + + /** + * @requires PHP 7.1 + */ + public function testGetNullableArgumentsWithDefaults() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); + $request->attributes->set('mandatory', 'mandatory'); + $controller = array(new NullableController(), 'action'); + $this->assertEquals(array(null, null, 'value', 'mandatory'), $resolver->getArguments($request, $controller)); + } + protected function createControllerResolver(LoggerInterface $logger = null) { return new ControllerResolver($logger); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php new file mode 100644 index 0000000000000..9db4df7b4c173 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; + +class NullableController +{ + public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory) + { + } +} From 42244f2a2ee39b30092fa53d6f669c3a8ee797b9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Sep 2016 15:11:47 +0200 Subject: [PATCH 20/93] [DI] Fix setting synthetic services on ContainerBuilder --- .../DependencyInjection/ContainerBuilder.php | 15 ++++----------- .../Tests/ContainerBuilderTest.php | 6 ++---- .../DependencyInjection/Tests/ContainerTest.php | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 0813110deda8f..6814d28e73116 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -362,21 +362,14 @@ public function getScopeChildren() public function set($id, $service, $scope = self::SCOPE_CONTAINER) { $id = strtolower($id); + $set = isset($this->definitions[$id]); - if ($this->isFrozen()) { + if ($this->isFrozen() && ($set || isset($this->obsoleteDefinitions[$id])) && !$this->{$set ? 'definitions' : 'obsoleteDefinitions'}[$id]->isSynthetic()) { // setting a synthetic service on a frozen container is alright - if ( - (!isset($this->definitions[$id]) && !isset($this->obsoleteDefinitions[$id])) - || - (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic()) - || - (isset($this->obsoleteDefinitions[$id]) && !$this->obsoleteDefinitions[$id]->isSynthetic()) - ) { - throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id)); - } + throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id)); } - if (isset($this->definitions[$id])) { + if ($set) { $this->obsoleteDefinitions[$id] = $this->definitions[$id]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 7870c40ea9841..6b49b1e34fb85 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -637,14 +637,12 @@ public function testThrowsExceptionWhenSetServiceOnAFrozenContainer() $container->set('a', new \stdClass()); } - /** - * @expectedException \BadMethodCallException - */ public function testThrowsExceptionWhenAddServiceOnAFrozenContainer() { $container = new ContainerBuilder(); $container->compile(); - $container->set('a', new \stdClass()); + $container->set('a', $foo = new \stdClass()); + $this->assertSame($foo, $container->get('a')); } public function testNoExceptionWhenSetSyntheticServiceOnAFrozenContainer() diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index e451806bb7807..b4eba04f97340 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -258,7 +258,7 @@ public function testGetReturnsNullOnInactiveScope() /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException - * @expectedExcepionMessage You have requested a synthetic service ("request"). The DIC does not know how to construct this service. + * @expectedExceptionMessage You have requested a synthetic service ("request"). The DIC does not know how to construct this service. */ public function testGetSyntheticServiceAlwaysThrows() { From c03164e4f95eeef83421933dbd90ed900918f786 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Wed, 10 Aug 2016 18:14:01 +0100 Subject: [PATCH 21/93] [form] lazy trans `post_max_size_message`. --- .../Component/Form/Extension/Core/Type/FormType.php | 9 +++++++++ .../HttpFoundation/HttpFoundationRequestHandler.php | 2 +- .../Validator/Type/UploadValidatorExtension.php | 7 ++++--- src/Symfony/Component/Form/NativeRequestHandler.php | 2 +- .../Validator/Type/UploadValidatorExtensionTest.php | 8 +++++++- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index 8590796bfa6e3..1a1a3175e6e4b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -146,6 +146,13 @@ public function configureOptions(OptionsResolver $resolver) }; }; + // Wrap "post_max_size_message" in a closure to translate it lazily + $uploadMaxSizeMessage = function (Options $options) { + return function () use ($options) { + return $options['post_max_size_message']; + }; + }; + // For any form that is not represented by a single HTML control, // errors should bubble up by default $errorBubbling = function (Options $options) { @@ -207,9 +214,11 @@ public function configureOptions(OptionsResolver $resolver) 'action' => '', 'attr' => $defaultAttr, 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', + 'upload_max_size_message' => $uploadMaxSizeMessage, // internal )); $resolver->setAllowedTypes('label_attr', 'array'); + $resolver->setAllowedTypes('upload_max_size_message', array('callable')); } /** diff --git a/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php b/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php index d1e5eece7b5a4..004f4778f98a0 100644 --- a/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php +++ b/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php @@ -78,7 +78,7 @@ public function handleRequest(FormInterface $form, $request = null) $form->submit(null, false); $form->addError(new FormError( - $form->getConfig()->getOption('post_max_size_message'), + call_user_func($form->getConfig()->getOption('upload_max_size_message')), null, array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()) )); diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php index 6f0fa60afd60d..efbfda93d41bf 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php @@ -42,9 +42,10 @@ public function configureOptions(OptionsResolver $resolver) { $translator = $this->translator; $translationDomain = $this->translationDomain; - - $resolver->setNormalizer('post_max_size_message', function (Options $options, $errorMessage) use ($translator, $translationDomain) { - return $translator->trans($errorMessage, array(), $translationDomain); + $resolver->setNormalizer('upload_max_size_message', function (Options $options, $message) use ($translator, $translationDomain) { + return function () use ($translator, $translationDomain, $message) { + return $translator->trans(call_user_func($message), array(), $translationDomain); + }; }); } diff --git a/src/Symfony/Component/Form/NativeRequestHandler.php b/src/Symfony/Component/Form/NativeRequestHandler.php index 5541e96ad5df3..3607feb99cc98 100644 --- a/src/Symfony/Component/Form/NativeRequestHandler.php +++ b/src/Symfony/Component/Form/NativeRequestHandler.php @@ -86,7 +86,7 @@ public function handleRequest(FormInterface $form, $request = null) $form->submit(null, false); $form->addError(new FormError( - $form->getConfig()->getOption('post_max_size_message'), + call_user_func($form->getConfig()->getOption('upload_max_size_message')), null, array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()) )); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php index 95a11a78c71ce..dbe13a27456f6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Validator\Type\UploadValidatorExtension; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\OptionsResolver\Options; class UploadValidatorExtensionTest extends TypeTestCase { @@ -29,10 +30,15 @@ public function testPostMaxSizeTranslation() $resolver = new OptionsResolver(); $resolver->setDefault('post_max_size_message', 'old max {{ max }}!'); + $resolver->setDefault('upload_max_size_message', function (Options $options, $message) { + return function () use ($options) { + return $options['post_max_size_message']; + }; + }); $extension->configureOptions($resolver); $options = $resolver->resolve(); - $this->assertEquals('translated max {{ max }}!', $options['post_max_size_message']); + $this->assertEquals('translated max {{ max }}!', call_user_func($options['upload_max_size_message'])); } } From e4193c746c11c44a6ee83f1a098a16b575a26bf5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 6 Sep 2016 11:23:48 +0200 Subject: [PATCH 22/93] Minor cleanups and improvements --- .../Compiler/RepeatedPass.php | 14 ++++++-------- .../Dumper/GraphvizDumper.php | 6 +++--- .../DependencyInjection/Dumper/PhpDumper.php | 16 ++++++++-------- .../DependencyInjection/Dumper/XmlDumper.php | 4 ++-- .../DependencyInjection/Dumper/YamlDumper.php | 4 ++-- .../Loader/YamlFileLoader.php | 4 ++-- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php index 508a8978ea68b..59d4e0a767a5a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php @@ -56,14 +56,12 @@ public function __construct(array $passes) */ public function process(ContainerBuilder $container) { - $this->repeat = false; - foreach ($this->passes as $pass) { - $pass->process($container); - } - - if ($this->repeat) { - $this->process($container); - } + do { + $this->repeat = false; + foreach ($this->passes as $pass) { + $pass->process($container); + } + } while ($this->repeat); } /** diff --git a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index f69d1e9066bac..c8edea28dbbee 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -130,7 +130,7 @@ private function addEdges() * * @return array An array of edges */ - private function findEdges($id, $arguments, $required, $name) + private function findEdges($id, array $arguments, $required, $name) { $edges = array(); foreach ($arguments as $argument) { @@ -246,7 +246,7 @@ private function endDot() * * @return string A comma separated list of attributes */ - private function addAttributes($attributes) + private function addAttributes(array $attributes) { $code = array(); foreach ($attributes as $k => $v) { @@ -263,7 +263,7 @@ private function addAttributes($attributes) * * @return string A space separated list of options */ - private function addOptions($options) + private function addOptions(array $options) { $code = array(); foreach ($options as $k => $v) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 0c3705647d803..37c3275444bcc 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -375,7 +375,7 @@ private function addServiceReturn($id, $definition) * @throws InvalidArgumentException * @throws RuntimeException */ - private function addServiceInstance($id, $definition) + private function addServiceInstance($id, Definition $definition) { $class = $definition->getClass(); @@ -425,7 +425,7 @@ private function addServiceInstance($id, $definition) * * @return bool */ - private function isSimpleInstance($id, $definition) + private function isSimpleInstance($id, Definition $definition) { foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) { if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) { @@ -449,7 +449,7 @@ private function isSimpleInstance($id, $definition) * * @return string */ - private function addServiceMethodCalls($id, $definition, $variableName = 'instance') + private function addServiceMethodCalls($id, Definition $definition, $variableName = 'instance') { $calls = ''; foreach ($definition->getMethodCalls() as $call) { @@ -464,7 +464,7 @@ private function addServiceMethodCalls($id, $definition, $variableName = 'instan return $calls; } - private function addServiceProperties($id, $definition, $variableName = 'instance') + private function addServiceProperties($id, Definition $definition, $variableName = 'instance') { $code = ''; foreach ($definition->getProperties() as $name => $value) { @@ -484,7 +484,7 @@ private function addServiceProperties($id, $definition, $variableName = 'instanc * * @throws ServiceCircularReferenceException when the container contains a circular reference */ - private function addServiceInlinedDefinitionsSetup($id, $definition) + private function addServiceInlinedDefinitionsSetup($id, Definition $definition) { $this->referenceVariables[$id] = new Variable('instance'); @@ -528,7 +528,7 @@ private function addServiceInlinedDefinitionsSetup($id, $definition) * * @return string */ - private function addServiceConfigurator($id, $definition, $variableName = 'instance') + private function addServiceConfigurator($id, Definition $definition, $variableName = 'instance') { if (!$callable = $definition->getConfigurator()) { return ''; @@ -560,7 +560,7 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta * * @return string */ - private function addService($id, $definition) + private function addService($id, Definition $definition) { $this->definitionVariables = new \SplObjectStorage(); $this->referenceVariables = array(); @@ -1124,7 +1124,7 @@ protected function getDefaultParameters() * * @throws InvalidArgumentException */ - private function exportParameters($parameters, $path = '', $indent = 12) + private function exportParameters(array $parameters, $path = '', $indent = 12) { $php = array(); foreach ($parameters as $key => $value) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index bd8e20071e8b9..3306c4b1a6439 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -262,7 +262,7 @@ private function addServices(\DOMElement $parent) * @param \DOMElement $parent * @param string $keyAttribute */ - private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key') + private function convertParameters(array $parameters, $type, \DOMElement $parent, $keyAttribute = 'key') { $withKeys = array_keys($parameters) !== range(0, count($parameters) - 1); foreach ($parameters as $key => $value) { @@ -311,7 +311,7 @@ private function convertParameters($parameters, $type, \DOMElement $parent, $key * * @return array */ - private function escape($arguments) + private function escape(array $arguments) { $args = array(); foreach ($arguments as $k => $v) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 3acac1c9ad521..955cb7c14ecca 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -304,7 +304,7 @@ private function getExpressionCall($expression) * * @return array */ - private function prepareParameters($parameters, $escape = true) + private function prepareParameters(array $parameters, $escape = true) { $filtered = array(); foreach ($parameters as $key => $value) { @@ -327,7 +327,7 @@ private function prepareParameters($parameters, $escape = true) * * @return array */ - private function escape($arguments) + private function escape(array $arguments) { $args = array(); foreach ($arguments as $k => $v) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index f57ba587c834b..52cc53946b16d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -386,9 +386,9 @@ private function resolveServices($value) { if (is_array($value)) { $value = array_map(array($this, 'resolveServices'), $value); - } elseif (is_string($value) && 0 === strpos($value, '@=')) { + } elseif (is_string($value) && 0 === strpos($value, '@=')) { return new Expression(substr($value, 2)); - } elseif (is_string($value) && 0 === strpos($value, '@')) { + } elseif (is_string($value) && 0 === strpos($value, '@')) { if (0 === strpos($value, '@@')) { $value = substr($value, 1); $invalidBehavior = null; From c49e46259c081a1d0a3fbfadbe118d5e2d07cf6b Mon Sep 17 00:00:00 2001 From: Konstantin Myakshin Date: Mon, 29 Aug 2016 14:19:30 +0300 Subject: [PATCH 23/93] [Security] Added note inside phpdoc. --- .../Component/Security/Core/Authorization/Voter/Voter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php index 8d36fd8f8c919..2396b1e678498 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php @@ -74,6 +74,7 @@ abstract protected function supports($attribute, $subject); /** * Perform a single access check operation on a given attribute, subject and token. + * It is safe to assume that $attribute and $subject already passed the "supports()" method check. * * @param string $attribute * @param mixed $subject From 1393e3e91326036e5d09679c4a72af3dd233cd2d Mon Sep 17 00:00:00 2001 From: Pedro Resende Date: Mon, 29 Aug 2016 21:43:12 +0100 Subject: [PATCH 24/93] [FrameworkBundle] Fix Incorrect line break in exception message (500 debug page) --- .../Bundle/FrameworkBundle/Resources/public/css/body.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css b/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css index c50c1a54c7868..9a1cbb8cc2755 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css @@ -39,7 +39,7 @@ build: 56 font-family: Georgia, "Times New Roman", Times, serif; font-size: 20px; color: #313131; - word-break: break-all; + word-wrap: break-word; } .sf-reset li { padding-bottom: 10px; From c3b68b0d28790c85bab190b030d132f2ddc73438 Mon Sep 17 00:00:00 2001 From: Enleur Date: Tue, 6 Sep 2016 13:52:05 +0300 Subject: [PATCH 25/93] [Security] Optimize RoleHierarchy's buildRoleMap method --- .../Component/Security/Core/Role/RoleHierarchy.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php b/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php index 793007e7f5420..95e76ee279316 100644 --- a/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php +++ b/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php @@ -65,9 +65,17 @@ protected function buildRoleMap() } $visited[] = $role; - $this->map[$main] = array_unique(array_merge($this->map[$main], $this->hierarchy[$role])); - $additionalRoles = array_merge($additionalRoles, array_diff($this->hierarchy[$role], $visited)); + + foreach ($this->hierarchy[$role] as $roleToAdd) { + $this->map[$main][] = $roleToAdd; + } + + foreach (array_diff($this->hierarchy[$role], $visited) as $additionalRole) { + $additionalRoles[] = $additionalRole; + } } + + $this->map[$main] = array_unique($this->map[$main]); } } } From 7735b4eac9e9a4fdd208a8cd1ff26bfc73dc7af4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 17:54:08 -0700 Subject: [PATCH 26/93] updated CHANGELOG for 2.7.18 --- CHANGELOG-2.7.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG-2.7.md b/CHANGELOG-2.7.md index 0f7fa8210cbe2..c5f93200d0d51 100644 --- a/CHANGELOG-2.7.md +++ b/CHANGELOG-2.7.md @@ -7,6 +7,16 @@ 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.18 (2016-09-07) + + * bug #19859 [ClassLoader] Fix ClassCollectionLoader inlining with declare(strict_types=1) (nicolas-grekas) + * bug #19780 [FrameworkBundle] Incorrect line break in exception message (500 debug page) (pedroresende) + * bug #19595 [form] lazy trans `post_max_size_message`. (aitboudad) + * bug #19870 [DI] Fix setting synthetic services on ContainerBuilder (nicolas-grekas) + * bug #19848 Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" (nicolas-grekas) + * bug #19842 [FrameworkBundle] Check for class existence before is_subclass_of (chalasr) + * bug #19827 [BrowserKit] Fix cookie expiration on 32 bit systems (jameshalsall) + * 2.7.17 (2016-09-02) * bug #19794 [VarDumper] Various minor fixes & cleanups (nicolas-grekas) From dbc2ad230cb3ee2f822c1f00360816b64775d011 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 17:54:14 -0700 Subject: [PATCH 27/93] update CONTRIBUTORS for 2.7.18 --- CONTRIBUTORS.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e10ae01026ab3..7cbed979c4960 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -16,8 +16,8 @@ Symfony is the result of the work of many people who made the code better - Kris Wallsmith (kriswallsmith) - Jakub Zalas (jakubzalas) - Ryan Weaver (weaverryan) - - Kévin Dunglas (dunglas) - Javier Eguiluz (javier.eguiluz) + - Kévin Dunglas (dunglas) - Hugo Hamon (hhamon) - Abdellatif Ait boudad (aitboudad) - Pascal Borreli (pborreli) @@ -52,8 +52,8 @@ Symfony is the result of the work of many people who made the code better - Konstantin Kudryashov (everzet) - Bilal Amarni (bamarni) - Florin Patan (florinpatan) - - Peter Rehm (rpet) - Ener-Getick (energetick) + - Peter Rehm (rpet) - Iltar van der Berg (kjarli) - Kevin Bond (kbond) - Andrej Hudec (pulzarraider) @@ -315,6 +315,7 @@ Symfony is the result of the work of many people who made the code better - JhonnyL - hossein zolfi (ocean) - Clément Gautier (clementgautier) + - James Halsall (jaitsu) - Eduardo Gulias (egulias) - giulio de donato (liuggio) - Stéphane PY (steph_py) @@ -396,7 +397,6 @@ Symfony is the result of the work of many people who made the code better - Christian Wahler - Mathieu Lemoine - Gintautas Miselis - - James Halsall (jaitsu) - David Badura (davidbadura) - Zander Baldwin - Adam Harvey @@ -1302,6 +1302,7 @@ Symfony is the result of the work of many people who made the code better - Muriel (metalmumu) - Michael Pohlers (mick_the_big) - Cayetano Soriano Gallego (neoshadybeat) + - Ondrej Machulda (ondram) - Patrick McDougle (patrick-mcdougle) - Pablo Monterde Perez (plebs) - Jimmy Leger (redpanda) From 59985613b286b031241628e1470c5f1bd012570f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 17:54:19 -0700 Subject: [PATCH 28/93] updated VERSION for 2.7.18 --- 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 4215ea070d20b..e0e79545193b2 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.18-DEV'; + const VERSION = '2.7.18'; const VERSION_ID = 20718; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 18; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From be2a6d129131d33e5504091cd540ddb0a82cd6b4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 19:01:26 -0700 Subject: [PATCH 29/93] bumped Symfony version to 2.7.19 --- 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 e0e79545193b2..c6586c02312aa 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.18'; - const VERSION_ID = 20718; + const VERSION = '2.7.19-DEV'; + const VERSION_ID = 20719; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 18; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 19; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From c9ea677719594c02345aef2edc56f2706f086d8a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 19:02:53 -0700 Subject: [PATCH 30/93] updated CHANGELOG for 2.8.11 --- CHANGELOG-2.8.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG-2.8.md b/CHANGELOG-2.8.md index 1de96a66a9b3f..482e20e17c7f9 100644 --- a/CHANGELOG-2.8.md +++ b/CHANGELOG-2.8.md @@ -7,6 +7,16 @@ 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.11 (2016-09-07) + + * bug #19859 [ClassLoader] Fix ClassCollectionLoader inlining with declare(strict_types=1) (nicolas-grekas) + * bug #19780 [FrameworkBundle] Incorrect line break in exception message (500 debug page) (pedroresende) + * bug #19595 [form] lazy trans `post_max_size_message`. (aitboudad) + * bug #19870 [DI] Fix setting synthetic services on ContainerBuilder (nicolas-grekas) + * bug #19848 Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)" (nicolas-grekas) + * bug #19842 [FrameworkBundle] Check for class existence before is_subclass_of (chalasr) + * bug #19827 [BrowserKit] Fix cookie expiration on 32 bit systems (jameshalsall) + * 2.8.10 (2016-09-02) * bug #19786 Update profiler's layout to use flexbox (javiereguiluz) From af440e3f9249e774987886d937a74b430fa45ea5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 19:02:58 -0700 Subject: [PATCH 31/93] updated VERSION for 2.8.11 --- 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 1e62cf1266f98..7b78f1bf21a92 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.11-DEV'; + const VERSION = '2.8.11'; const VERSION_ID = 20811; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 11; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 69afe99f45650afe77f0048b08bedbf75be888e1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Sep 2016 19:58:32 -0700 Subject: [PATCH 32/93] bumped Symfony version to 2.8.12 --- 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 7b78f1bf21a92..150d65e7cfd4a 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.11'; - const VERSION_ID = 20811; + const VERSION = '2.8.12-DEV'; + const VERSION_ID = 20812; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 11; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 12; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From ffdd15ee064affe08b27a79df40ee7e49943f38e Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Wed, 7 Sep 2016 10:32:40 +0200 Subject: [PATCH 33/93] Fix translation:update command count --- .../Command/TranslationUpdateCommand.php | 14 ++++++++------ .../Tests/Command/TranslationUpdateCommandTest.php | 9 +++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index a9a004735b11f..72298480b4e31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -160,11 +160,8 @@ protected function execute(InputInterface $input, OutputInterface $output) foreach ($operation->getDomains() as $domain) { $newKeys = array_keys($operation->getNewMessages($domain)); $allKeys = array_keys($operation->getMessages($domain)); - $domainMessagesCount = count($newKeys) + count($allKeys); - $io->section(sprintf('Messages extracted for domain "%s" (%d messages)', $domain, $domainMessagesCount)); - - $io->listing(array_merge( + $list = array_merge( array_diff($allKeys, $newKeys), array_map(function ($id) { return sprintf('%s', $id); @@ -172,7 +169,12 @@ protected function execute(InputInterface $input, OutputInterface $output) array_map(function ($id) { return sprintf('%s', $id); }, array_keys($operation->getObsoleteMessages($domain))) - )); + ); + + $domainMessagesCount = count($list); + + $io->section(sprintf('Messages extracted for domain "%s" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : '')); + $io->listing($list); $extractedMessagesCount += $domainMessagesCount; } @@ -181,7 +183,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->comment('Xliff output version is 1.2'); } - $resultMessage = sprintf('%d messages were successfully extracted', $extractedMessagesCount); + $resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was'); } if ($input->getOption('no-backup') === true) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index f7eca9d366d38..40eab748c62bf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -28,6 +28,15 @@ public function testDumpMessagesAndClean() $tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); $this->assertRegExp('/foo/', $tester->getDisplay()); + $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); + } + + public function testDumpTwoMessagesAndClean() + { + $tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo', 'bar' => 'bar'))); + $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); + $this->assertRegExp('/foo/', $tester->getDisplay()); + $this->assertRegExp('/bar/', $tester->getDisplay()); $this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay()); } From bf6691ca4617b8b6da22fc7b19801f82009bae13 Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 7 Sep 2016 13:06:20 +0200 Subject: [PATCH 34/93] Fix #19721 Issue was introduced in #19541 --- .../DateTimeToLocalizedStringTransformer.php | 5 ++++- ...DateTimeToLocalizedStringTransformerTest.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 51f692755eb6d..d2e5ddba5cd9d 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -134,7 +134,10 @@ public function reverseTransform($value) } // read timestamp into DateTime object - the formatter delivers a timestamp - $dateTime = new \DateTime(sprintf('@%s', $timestamp), new \DateTimeZone($this->outputTimezone)); + $dateTime = new \DateTime(sprintf('@%s', $timestamp)); + // set timezone separately, as it would be ignored if set via the constructor, + // see http://php.net/manual/en/datetime.construct.php + $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone)); } catch (\Exception $e) { throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index 444cdd4582330..d5abfe7047b5f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -134,6 +134,23 @@ public function testTransformWithDifferentTimezones() $this->assertEquals($dateTime->format('d.m.Y, H:i'), $transformer->transform($input)); } + public function testReverseTransformWithNoConstructorParameters() + { + $tz = date_default_timezone_get(); + date_default_timezone_set('Europe/Rome'); + + $transformer = new DateTimeToLocalizedStringTransformer(); + + $dateTime = new \DateTime('2010-02-03 04:05'); + + $this->assertEquals( + $dateTime->format('c'), + $transformer->reverseTransform('03.02.2010, 04:05')->format('c') + ); + + date_default_timezone_set($tz); + } + public function testTransformWithDifferentPatterns() { $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); From fdd266f28e256bdbb15c0fc0fe1d1d05ce310ebe Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Tue, 6 Sep 2016 15:46:21 +0200 Subject: [PATCH 35/93] Consider the umask setting when dumping a file. --- src/Symfony/Component/Filesystem/Filesystem.php | 3 +-- src/Symfony/Component/Filesystem/Tests/FilesystemTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 72ab9bf8cf17e..5a6f009f8afb4 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -554,8 +554,7 @@ public function dumpFile($filename, $content) throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } - // Ignore for filesystems that do not support umask - @chmod($tmpFile, 0666); + @chmod($tmpFile, 0666 & ~umask()); $this->rename($tmpFile, $filename, true); } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 9a65543098d76..58523c22154cc 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1101,13 +1101,19 @@ public function testDumpFile() { $filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt'; + // skip mode check on Windows + if ('\\' !== DIRECTORY_SEPARATOR) { + $oldMask = umask(0002); + } + $this->filesystem->dumpFile($filename, 'bar'); $this->assertFileExists($filename); $this->assertSame('bar', file_get_contents($filename)); // skip mode check on Windows if ('\\' !== DIRECTORY_SEPARATOR) { - $this->assertFilePermissions(666, $filename); + $this->assertFilePermissions(664, $filename); + umask($oldMask); } } From d3c613be367c5d3b28de03ef669f3ea0354a37c1 Mon Sep 17 00:00:00 2001 From: Hugo Fonseca Date: Wed, 7 Sep 2016 12:59:03 +0100 Subject: [PATCH 36/93] [Console] fixed PHP7 Errors are now handled and converted to Exceptions --- src/Symfony/Component/Console/Application.php | 15 ++++- .../Console/Tests/ApplicationTest.php | 56 +++++++++++++++++++ src/Symfony/Component/Console/composer.json | 3 +- 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 590460ca0de99..c2c13b8aedbd4 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -38,6 +38,7 @@ use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; +use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -849,17 +850,25 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI if ($event->commandShouldRun()) { try { + $e = null; $exitCode = $command->run($input, $output); - } catch (\Exception $e) { + } catch (\Exception $x) { + $e = $x; + } catch (\Throwable $x) { + $e = new FatalThrowableError($x); + } + if (null !== $e) { $event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode()); $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event); - $e = $event->getException(); + if ($e !== $event->getException()) { + $x = $e = $event->getException(); + } $event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode()); $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event); - throw $e; + throw $x; } } else { $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED; diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 918200d53cfb3..eb04e8a0ad0ce 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -949,6 +949,62 @@ public function testRunDispatchesAllEventsWithException() $this->assertContains('before.foo.caught.after.', $tester->getDisplay()); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage caught + */ + public function testRunWithErrorAndDispatcher() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dym.'); + + throw new \Error('dymerr'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'dym')); + $this->assertContains('before.dym.caught.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); + } + + public function testRunDispatchesAllEventsWithError() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dym.'); + + throw new \Error('dymerr'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'dym')); + $this->assertContains('before.dym.caught.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); + } + + public function testRunWithErrorFailingStatusCode() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + + $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dus.'); + + throw new \Error('duserr'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'dus')); + $this->assertSame(1, $tester->getStatusCode(), 'Status code should be 1'); + } + public function testRunWithDispatcherSkippingCommand() { $application = new Application(); diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index b68129ddfc7e5..1bd4af63cb06e 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": ">=5.3.9" + "php": ">=5.3.9", + "symfony/debug": "~2.7,>=2.7.2" }, "require-dev": { "symfony/event-dispatcher": "~2.1", From 193542f84f704592b25bba33bb502222c6ea6a9c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 9 Sep 2016 12:14:33 +0200 Subject: [PATCH 37/93] [FrameworkBundle] Remove cache clearer default value in config --- .../DependencyInjection/Configuration.php | 2 +- .../Tests/Functional/CachePoolsTest.php | 20 ++++++++++++------- .../Functional/app/CachePools/config.yml | 7 ++++++- .../app/CachePools/redis_config.yml | 5 ++++- .../app/CachePools/redis_custom_config.yml | 5 ++++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 4c153f0629c4a..eb7c2d85ba633 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -585,7 +585,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode) ->scalarNode('provider') ->info('The service name to use as provider when the specified adapter needs one.') ->end() - ->scalarNode('clearer')->defaultValue('cache.default_clearer')->end() + ->scalarNode('clearer')->end() ->end() ->end() ->validate() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index 565354343e2d7..9fc420e2c86fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -62,22 +62,28 @@ public function doTestCachePools($options, $adapterClass) static::bootKernel($options); $container = static::$kernel->getContainer(); - $pool = $container->get('cache.test'); - $this->assertInstanceOf($adapterClass, $pool); + $pool1 = $container->get('cache.pool1'); + $this->assertInstanceOf($adapterClass, $pool1); $key = 'foobar'; - $pool->deleteItem($key); - $item = $pool->getItem($key); + $pool1->deleteItem($key); + $item = $pool1->getItem($key); $this->assertFalse($item->isHit()); $item->set('baz'); - $pool->save($item); - $item = $pool->getItem($key); + $pool1->save($item); + $item = $pool1->getItem($key); $this->assertTrue($item->isHit()); + $pool2 = $container->get('cache.pool2'); + $pool2->save($item); + $container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir')); - $item = $pool->getItem($key); + $item = $pool1->getItem($key); $this->assertFalse($item->isHit()); + + $item = $pool2->getItem($key); + $this->assertTrue($item->isHit()); } protected static function createKernel(array $options = array()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml index 20d966780c918..eabf83825e05d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml @@ -4,5 +4,10 @@ imports: framework: cache: pools: - cache.test: + cache.pool1: public: true + cache.pool2: + public: true + adapter: cache.pool3 + cache.pool3: + clearer: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml index ae1fbf62a6ff3..223f074a56a46 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml @@ -5,5 +5,8 @@ framework: cache: app: cache.adapter.redis pools: - cache.test: + cache.pool1: public: true + cache.pool2: + public: true + clearer: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml index 3c99f05ac75cc..c868317512964 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml @@ -17,5 +17,8 @@ services: framework: cache: pools: - cache.test: + cache.pool1: public: true + cache.pool2: + public: true + clearer: ~ From 7806e2a05da3228480b34b2aa867b36235f0c9e3 Mon Sep 17 00:00:00 2001 From: HeahDude Date: Sun, 11 Sep 2016 01:56:49 +0200 Subject: [PATCH 38/93] Fixed collapsed ChoiceType options attributes --- .../Resources/views/Form/choice_attributes.html.php | 1 - src/Symfony/Component/Form/Tests/AbstractLayoutTest.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php index 8d2d6d7fd63c3..18f8368dc8065 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php @@ -1,4 +1,3 @@ -id="escape($id) ?>" name="escape($full_name) ?>" disabled="disabled" $v): ?> diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 01b3d3757a597..6441c07f6bf39 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -612,8 +612,8 @@ public function testSingleChoiceAttributesWithMainAttributes() [@class="bar&baz"] [not(@required)] [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"] + ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"][not(@id)][not(@name)] + /following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"][not(@id)][not(@name)] ] [count(./option)=2] ' From 9eb8524d184d575a052d4850db61e59125cc2b59 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 Sep 2016 12:06:58 +0200 Subject: [PATCH 39/93] [travis/appveyor] Wire simple-phpunit --- .github/build-packages.php | 74 +++++++++++++ .github/travis.php | 54 ---------- .travis.yml | 17 +-- appveyor.yml | 10 +- composer.json | 6 +- phpunit | 213 +------------------------------------ 6 files changed, 97 insertions(+), 277 deletions(-) create mode 100644 .github/build-packages.php delete mode 100644 .github/travis.php diff --git a/.github/build-packages.php b/.github/build-packages.php new file mode 100644 index 0000000000000..2a2b4a396c07f --- /dev/null +++ b/.github/build-packages.php @@ -0,0 +1,74 @@ + $_SERVER['argc']) { + echo "Usage: branch version dir1 dir2 ... dirN\n"; + exit(1); +} +chdir(dirname(__DIR__)); + +$dirs = $_SERVER['argv']; +array_shift($dirs); +$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs)))); +$version = array_shift($dirs); + +$packages = array(); +$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; + +foreach ($dirs as $k => $dir) { + if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) { + if ($exitStatus) { + exit($exitStatus); + } + unset($dirs[$k]); + continue; + } + echo "$dir\n"; + + $json = ltrim(file_get_contents($dir.'/composer.json')); + if (null === $package = json_decode($json)) { + passthru("composer validate $dir/composer.json"); + exit(1); + } + + $package->repositories = array(array( + 'type' => 'composer', + 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/', + )); + if (false === strpos($json, "\n \"repositories\": [\n")) { + $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); + file_put_contents($dir.'/composer.json', $json); + } + passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); + + $package->version = $version.'.999'; + $package->dist['type'] = 'tar'; + $package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar"; + + $packages[$package->name][$package->version] = $package; + + $versions = file_get_contents('https://packagist.org/packages/'.$package->name.'.json'); + $versions = json_decode($versions); + + foreach ($versions->package->versions as $v => $package) { + $packages[$package->name] += array($v => $package); + } +} + +file_put_contents('packages.json', json_encode(compact('packages'), $flags)); + +if ($dirs) { + $json = ltrim(file_get_contents('composer.json')); + if (null === $package = json_decode($json)) { + passthru("composer validate $dir/composer.json"); + exit(1); + } + + $package->repositories = array(array( + 'type' => 'composer', + 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/', + )); + if (false === strpos($json, "\n \"repositories\": [\n")) { + $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); + file_put_contents('composer.json', $json); + } +} diff --git a/.github/travis.php b/.github/travis.php deleted file mode 100644 index 695c69604fe67..0000000000000 --- a/.github/travis.php +++ /dev/null @@ -1,54 +0,0 @@ - $_SERVER['argc']) { - echo "Usage: branch version dir1 dir2 ... dirN\n"; - exit(1); -} -chdir(dirname(__DIR__)); - -$dirs = $_SERVER['argv']; -array_shift($dirs); -$branch = array_shift($dirs); -$version = array_shift($dirs); - -$packages = array(); -$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; - -foreach ($dirs as $dir) { - if (!system("git diff --name-only $branch...HEAD -- $dir", $exitStatus)) { - if ($exitStatus) { - exit($exitStatus); - } - continue; - } - echo "$dir\n"; - - $json = ltrim(file_get_contents($dir.'/composer.json')); - if (null === $package = json_decode($json)) { - passthru("composer validate $dir/composer.json"); - exit(1); - } - - $package->repositories = array(array( - 'type' => 'composer', - 'url' => 'file://'.dirname(__DIR__).'/', - )); - $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); - file_put_contents($dir.'/composer.json', $json); - passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); - - $package->version = $version.'.999'; - $package->dist['type'] = 'tar'; - $package->dist['url'] = 'file://'.dirname(__DIR__)."/$dir/package.tar"; - - $packages[$package->name][$package->version] = $package; - - $versions = file_get_contents('https://packagist.org/packages/'.$package->name.'.json'); - $versions = json_decode($versions); - - foreach ($versions->package->versions as $v => $package) { - $packages[$package->name] += array($v => $package); - } -} - -file_put_contents('packages.json', json_encode(compact('packages'), $flags)); diff --git a/.travis.yml b/.travis.yml index f7fbaa300cf8b..57e639da8592d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,22 +58,27 @@ before_install: - if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi - if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi - if [[ ! $skip ]]; then [ -d ~/.composer ] || mkdir ~/.composer; cp .composer/* ~/.composer/; fi - - if [[ ! $skip ]]; then ./phpunit install; fi - if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi install: + - if [[ ! $skip && $deps ]]; then cp composer.json composer.json.orig; fi + - if [[ ! $skip && $deps ]]; then echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json; fi - if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi # Create local composer packages for each patched components and reference them in composer.json files when cross-testing components - - if [[ ! $skip && $deps ]]; then git fetch origin $TRAVIS_BRANCH && php .github/travis.php FETCH_HEAD $TRAVIS_BRANCH $COMPONENTS; fi + - if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH $COMPONENTS; fi + - if [[ ! $skip && $deps ]]; then mv composer.json composer.json.phpunit; mv composer.json.orig composer.json; fi + - if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH src/Symfony/Bridge/PhpUnit; fi # For the master branch when deps=high, the version before master is checked out and tested with the locally patched components - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi - - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi + - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi # Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one - if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi - export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev - - if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi - - if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi - - if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi + - if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi + - if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi + - if [[ ! $skip ]]; then composer update; fi + - if [[ ! $skip ]]; then COMPOSER_ROOT_VERSION= ./phpunit install; fi + - if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi script: - if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi diff --git a/appveyor.yml b/appveyor.yml index 6e143bf4aba94..768c52416d138 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,18 +48,20 @@ install: - echo curl.cainfo=c:\php\cacert.pem >> php.ini-max - copy /Y php.ini-max php.ini - cd c:\projects\symfony - - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.0/composer.phar) + - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar) - php composer.phar self-update - copy /Y .composer\* %APPDATA%\Composer\ - - php phpunit install + - php .github/build-packages.php "HEAD^" %APPVEYOR_REPO_BRANCH% src\Symfony\Bridge\PhpUnit - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - php composer.phar update --no-progress --ansi + - SET COMPOSER_ROOT_VERSION= + - php phpunit install test_script: - cd c:\projects\symfony - SET X=0 - copy /Y c:\php\php.ini-min c:\php\php.ini - - php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! + - php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! - copy /Y c:\php\php.ini-max c:\php\php.ini - - php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! + - php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! - exit %X% diff --git a/composer.json b/composer.json index 613e53f5aa35e..05e9d158aef31 100644 --- a/composer.json +++ b/composer.json @@ -78,6 +78,7 @@ "monolog/monolog": "~1.11", "ircmaxell/password-compat": "~1.0", "ocramius/proxy-manager": "~0.4|~1.0|~2.0", + "symfony/phpunit-bridge": "~3.2", "egulias/email-validator": "~1.2,>=1.2.1" }, "autoload": { @@ -99,11 +100,6 @@ "**/Tests/" ] }, - "autoload-dev": { - "psr-4": { - "Symfony\\Bridge\\PhpUnit\\": "src/Symfony/Bridge/PhpUnit/" - } - }, "minimum-stability": "dev", "extra": { "branch-alias": { diff --git a/phpunit b/phpunit index 22432a093c267..f9243bcbf9e79 100755 --- a/phpunit +++ b/phpunit @@ -1,212 +1,9 @@ #!/usr/bin/env php - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// Please update when phpunit needs to be reinstalled with fresh deps: -// Cache-Id-Version: 2016-06-29 13:45 UTC - -use Symfony\Component\Process\ProcessUtils; - -error_reporting(-1); -require __DIR__.'/src/Symfony/Component/Process/ProcessUtils.php'; - -// PHPUnit 4.8 does not support PHP 7, while 5.1 requires PHP 5.6+ -$PHPUNIT_VERSION = PHP_VERSION_ID >= 50600 ? '5.1' : '4.8'; -$PHPUNIT_DIR = __DIR__.'/.phpunit'; -$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php'; -$PHP = ProcessUtils::escapeArgument($PHP); -if ('phpdbg' === PHP_SAPI) { - $PHP .= ' -qrr'; -} - -$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar`)) - ? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER) - : 'composer'; - -if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) { - // Build a standalone phpunit without symfony/yaml - - $oldPwd = getcwd(); - @mkdir($PHPUNIT_DIR); - chdir($PHPUNIT_DIR); - if (file_exists("phpunit-$PHPUNIT_VERSION")) { - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION")); - } - if (extension_loaded('openssl') && ini_get('allow_url_fopen')) { - stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb')); - } else { - @unlink("$PHPUNIT_VERSION.zip"); - passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip"); - } - $zip = new ZipArchive(); - $zip->open("$PHPUNIT_VERSION.zip"); - $zip->extractTo(getcwd()); - $zip->close(); - chdir("phpunit-$PHPUNIT_VERSION"); - passthru("$COMPOSER remove --no-update phpspec/prophecy"); - passthru("$COMPOSER remove --no-update symfony/yaml"); - if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { - passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); - } - passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.2@dev\""); - passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit); - if ($exit) { - exit($exit); - } - file_put_contents('phpunit', <<<'EOPHP' -addPsr4('Symfony\\Bridge\\PhpUnit\\', array('src/Symfony/Bridge/PhpUnit'), true); -} -unset($loader); -Symfony\Bridge\PhpUnit\TextUI\Command::main(); - -EOPHP - ); - chdir('..'); - file_put_contents(".$PHPUNIT_VERSION.md5", md5_file(__FILE__)); - chdir($oldPwd); - -} - -$cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv); -$exit = 0; - -if (isset($argv[1]) && 'symfony' === $argv[1]) { - array_shift($cmd); -} - -$cmd[0] = sprintf('%s %s --colors=always', $PHP, ProcessUtils::escapeArgument("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")); -$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s'; - -if ('\\' === DIRECTORY_SEPARATOR) { - $cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"'; -} else { - $cmd .= '%2$s'; -} - -if (isset($argv[1]) && 'symfony' === $argv[1]) { - // Find Symfony components in plain php for Windows portability - - $oldPwd = getcwd(); - chdir(__DIR__); - $finder = new RecursiveDirectoryIterator('src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS); - $finder = new RecursiveIteratorIterator($finder); - $finder->setMaxDepth(3); - - $skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false; - $runningProcs = array(); - - foreach ($finder as $file => $fileInfo) { - if ('phpunit.xml.dist' === $file) { - $component = dirname($fileInfo->getPathname()); - - // Run phpunit tests in parallel - - if ($skippedTests) { - putenv("SYMFONY_PHPUNIT_SKIPPED_TESTS=$component/$skippedTests"); - } - - $c = ProcessUtils::escapeArgument($component); - - if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) { - $runningProcs[$component] = $proc; - } else { - $exit = 1; - echo "\033[41mKO\033[0m $component\n\n"; - } - } - } - chdir($oldPwd); - - // Fixes for colors support on appveyor - // See https://github.com/appveyor/ci/issues/373 - $colorFixes = array( - array("S\033[0m\033[0m\033[36m\033[1mS", "E\033[0m\033[0m\033[31m\033[1mE", "I\033[0m\033[0m\033[33m\033[1mI", "F\033[0m\033[0m\033[41m\033[37mF"), - array("SS", "EE", "II", "FF"), - ); - $colorFixes[0] = array_merge($colorFixes[0], $colorFixes[0]); - $colorFixes[1] = array_merge($colorFixes[1], $colorFixes[1]); - - while ($runningProcs) { - usleep(300000); - $terminatedProcs = array(); - foreach ($runningProcs as $component => $proc) { - $procStatus = proc_get_status($proc); - if (!$procStatus['running']) { - $terminatedProcs[$component] = $procStatus['exitcode']; - unset($runningProcs[$component]); - proc_close($proc); - } - } - - foreach ($terminatedProcs as $component => $procStatus) { - foreach (array('out', 'err') as $file) { - $file = "$component/phpunit.std$file"; - - if ('\\' === DIRECTORY_SEPARATOR) { - $h = fopen($file, 'rb'); - while (false !== $line = fgets($h)) { - echo str_replace($colorFixes[0], $colorFixes[1], preg_replace( - '/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/', - "$1m\033[$2$3$4$4", - $line - )); - } - fclose($h); - } else { - readfile($file); - } - unlink($file); - } - - // Fail on any individual component failures but ignore some error codes on Windows when APCu is enabled: - // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) - // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) - // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374) - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) { - $exit = $procStatus; - echo "\033[41mKO\033[0m $component\n\n"; - } else { - echo "\033[32mOK\033[0m $component\n\n"; - } - } - } -} elseif (!isset($argv[1]) || 'install' !== $argv[1]) { - // Run regular phpunit in a subprocess - - $errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.'); - if ($proc = proc_open(sprintf($cmd, '', ' 2> '.ProcessUtils::escapeArgument($errFile)), array(1 => array('pipe', 'w')), $pipes)) { - stream_copy_to_stream($pipes[1], STDOUT); - fclose($pipes[1]); - $exit = proc_close($proc); - - readfile($errFile); - unlink($errFile); - } - - if (!file_exists($component = array_pop($argv))) { - $component = basename(getcwd()); - } - - if ($exit) { - echo "\033[41mKO\033[0m $component\n\n"; - } else { - echo "\033[32mOK\033[0m $component\n\n"; - } +if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { + echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n"; + exit(1); } - -exit($exit); +putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit'); +require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit'; From 04275945efe1f0d035f1744543138804e3826c3e Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 12 Sep 2016 23:15:58 +0200 Subject: [PATCH 40/93] Use JSON_UNESCAPED_SLASHES for lint commands output --- src/Symfony/Bridge/Twig/Command/LintCommand.php | 2 +- src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 95d550a058bc3..42287a15717a5 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -202,7 +202,7 @@ private function displayJson(OutputInterface $output, $filesInfo) } }); - $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); + $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0)); return min($errors, 1); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php index 4c12e7d2fca05..b41f5f3479ebe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php @@ -156,7 +156,7 @@ private function displayJson(OutputInterface $output, $filesInfo) } }); - $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); + $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0)); return min($errors, 1); } From 4214311a1cf7a076fff999e832a772b96463377f Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 12 Sep 2016 23:49:02 -0300 Subject: [PATCH 41/93] [bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level --- src/Symfony/Component/Console/Application.php | 3 ++- src/Symfony/Component/Console/Tests/ApplicationTest.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index c2c13b8aedbd4..b11268ade33bf 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -337,7 +337,7 @@ public function register($name) * Adds an array of command objects. * * If a Command is not enabled it will not be added. - * + * * @param Command[] $commands An array of commands */ public function addCommands(array $commands) @@ -808,6 +808,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output) if (true === $input->hasParameterOption(array('--quiet', '-q'))) { $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); + $input->setInteractive(false); } else { if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index eb04e8a0ad0ce..9d375f6b7b264 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -636,9 +636,11 @@ public function testRun() $tester->run(array('command' => 'list', '--quiet' => true)); $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); + $this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed'); $tester->run(array('command' => 'list', '-q' => true)); $this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed'); + $this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed'); $tester->run(array('command' => 'list', '--verbose' => true)); $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed'); From 62d28f9204870a4c258637686bb50fd9f372e3b3 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Tue, 13 Sep 2016 15:40:53 +0800 Subject: [PATCH 42/93] [DoctrineBridge][PropertyInfo] Treat Doctrine decimal type as string --- .../Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php | 2 +- .../Tests/PropertyInfo/DoctrineExtractorTest.php | 4 ++++ .../Tests/PropertyInfo/Fixtures/DoctrineDummy.php | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 6e8c29e16b0dd..5446887abf8b0 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -178,12 +178,12 @@ private function getPhpType($doctrineType) return Type::BUILTIN_TYPE_INT; case DBALType::FLOAT: - case DBALType::DECIMAL: return Type::BUILTIN_TYPE_FLOAT; case DBALType::STRING: case DBALType::TEXT: case DBALType::GUID: + case DBALType::DECIMAL: return Type::BUILTIN_TYPE_STRING; case DBALType::BOOLEAN: diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index 1bc57b1140fae..2224517db6708 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -49,6 +49,8 @@ public function testGetProperties() 'time', 'json', 'simpleArray', + 'float', + 'decimal', 'bool', 'binary', 'customFoo', @@ -73,6 +75,8 @@ public function typesProvider() return array( array('id', array(new Type(Type::BUILTIN_TYPE_INT))), array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))), + array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))), + array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))), array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))), array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))), array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))), diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php index 317d14257b203..e6d9155704889 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php @@ -65,6 +65,16 @@ class DoctrineDummy */ private $simpleArray; + /** + * @Column(type="float") + */ + private $float; + + /** + * @Column(type="decimal", precision=10, scale=2) + */ + private $decimal; + /** * @Column(type="boolean") */ From 86a151c9f57adc3cb3734aa7b74d5bf1462bf0ce Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 13 Sep 2016 12:11:56 +0100 Subject: [PATCH 43/93] [Validator] Update IpValidatorTest data set with a valid reserved IP The validator uses PHP filter which was recently fixed (see https://bugs.php.net/bug.php?id=72972). --- .../Component/Validator/Tests/Constraints/IpValidatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index fc40e6104e14b..2c5dea549b71f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -218,7 +218,7 @@ public function getInvalidReservedIpsV4() { return array( array('0.0.0.0'), - array('224.0.0.1'), + array('240.0.0.1'), array('255.255.255.255'), ); } From 221e21cf40eea80781d47b6efc527742e870e613 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 13 Sep 2016 13:35:02 +0200 Subject: [PATCH 44/93] [ci] Fix build-packages.php --- .github/build-packages.php | 11 +++++++---- .travis.yml | 4 ++-- appveyor.yml | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/build-packages.php b/.github/build-packages.php index 2a2b4a396c07f..ec629998f600d 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -1,7 +1,7 @@ $_SERVER['argc']) { - echo "Usage: branch version dir1 dir2 ... dirN\n"; +if (3 > $_SERVER['argc']) { + echo "Usage: branch dir1 dir2 ... dirN\n"; exit(1); } chdir(dirname(__DIR__)); @@ -9,7 +9,6 @@ $dirs = $_SERVER['argv']; array_shift($dirs); $mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs)))); -$version = array_shift($dirs); $packages = array(); $flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; @@ -40,7 +39,11 @@ } passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); - $package->version = $version.'.999'; + if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) { + echo "Missing \"dev-master\" branch-alias in composer.json extra.\n"; + exit(1); + } + $package->version = str_replace('-dev', '.999', $package->extra->{'branch-alias'}->{'dev-master'}); $package->dist['type'] = 'tar'; $package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar"; diff --git a/.travis.yml b/.travis.yml index 57e639da8592d..bbf7547445fb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,9 +65,9 @@ install: - if [[ ! $skip && $deps ]]; then echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json; fi - if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi # Create local composer packages for each patched components and reference them in composer.json files when cross-testing components - - if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH $COMPONENTS; fi + - if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $COMPONENTS; fi - if [[ ! $skip && $deps ]]; then mv composer.json composer.json.phpunit; mv composer.json.orig composer.json; fi - - if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH src/Symfony/Bridge/PhpUnit; fi + - if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ src/Symfony/Bridge/PhpUnit; fi # For the master branch when deps=high, the version before master is checked out and tested with the locally patched components - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi diff --git a/appveyor.yml b/appveyor.yml index 768c52416d138..adf63a1539493 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -51,7 +51,7 @@ install: - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar) - php composer.phar self-update - copy /Y .composer\* %APPDATA%\Composer\ - - php .github/build-packages.php "HEAD^" %APPVEYOR_REPO_BRANCH% src\Symfony\Bridge\PhpUnit + - php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - php composer.phar update --no-progress --ansi - SET COMPOSER_ROOT_VERSION= From d30374d7eb55bd60609e3d4d05cf25906e327e3b Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 13 Sep 2016 22:12:03 +0100 Subject: [PATCH 45/93] Fixed bad merge --- src/Symfony/Component/Console/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index 6078c4b363f97..bfa01d06db34a 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.3.9", "symfony/polyfill-mbstring": "~1.0", - "symfony/debug": "~2.7,>=2.7.2" + "symfony/debug": "~2.7,>=2.7.2|~3.0" }, "require-dev": { "symfony/event-dispatcher": "~2.1|~3.0.0", From e8708195e2b50180dce085f15bec65ccabea7cfe Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 11 Sep 2016 15:39:04 +0200 Subject: [PATCH 46/93] [Config] Handle open_basedir restrictions in FileLocator Silence `file_exists()` call to avoid open_basedir restrictions warning. (can happen when using relative imports) --- src/Symfony/Component/Config/FileLocator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index c6600c7783760..4816724c8190e 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -57,7 +57,7 @@ public function locate($name, $currentPath = null, $first = true) $filepaths = array(); foreach ($paths as $path) { - if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) { + if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) { if (true === $first) { return $file; } From c555d643909866d3b5ced75bba6c3c5df78ddf34 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 14 Sep 2016 08:12:49 +0200 Subject: [PATCH 47/93] Fix version constraint --- src/Symfony/Component/Console/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index bfa01d06db34a..f0af3f214b36f 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.3.9", "symfony/polyfill-mbstring": "~1.0", - "symfony/debug": "~2.7,>=2.7.2|~3.0" + "symfony/debug": "~2.7,>=2.7.2|~3.0.0" }, "require-dev": { "symfony/event-dispatcher": "~2.1|~3.0.0", From 82415a1667462d9e4cabfa6858e7fcda2a86e45a Mon Sep 17 00:00:00 2001 From: Fabien Bourigault Date: Wed, 14 Sep 2016 09:33:27 +0200 Subject: [PATCH 48/93] [Form] Fix typo in doc comment --- src/Symfony/Component/Form/PreloadedExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/PreloadedExtension.php b/src/Symfony/Component/Form/PreloadedExtension.php index 65519f83d493e..871e8b3791bc9 100644 --- a/src/Symfony/Component/Form/PreloadedExtension.php +++ b/src/Symfony/Component/Form/PreloadedExtension.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\Exception\InvalidArgumentException; /** - * A form extension with preloaded types, type exceptions and type guessers. + * A form extension with preloaded types, type extensions and type guessers. * * @author Bernhard Schussek */ From 81e9713c80eae37c3b98b7ea4b2dc34635b05aa5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 14 Sep 2016 13:34:59 -0700 Subject: [PATCH 49/93] fixed CS --- src/Symfony/Bridge/Twig/Command/LintCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 42287a15717a5..4d8b9ce1691fb 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -202,7 +202,7 @@ private function displayJson(OutputInterface $output, $filesInfo) } }); - $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0)); + $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0)); return min($errors, 1); } From 4a1ab6dcd56268990cadd90c38190f91a208d27e Mon Sep 17 00:00:00 2001 From: Iltar van der Berg Date: Wed, 31 Aug 2016 10:55:27 +0200 Subject: [PATCH 50/93] [HttpKernel] Fixed the nullable support for php 7.1 and below --- .../Controller/ArgumentResolver.php | 2 +- .../ArgumentResolver/DefaultValueResolver.php | 4 +- .../ControllerMetadata/ArgumentMetadata.php | 15 +++++- .../ArgumentMetadataFactory.php | 47 +++++++++++++++++-- .../Tests/Controller/ArgumentResolverTest.php | 27 +++++++++++ .../ArgumentMetadataFactoryTest.php | 27 +++++++++-- .../ArgumentMetadataTest.php | 13 ++++- .../Controller/NullableController.php | 10 ++++ 8 files changed, 132 insertions(+), 13 deletions(-) create mode 100644 src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php index 1d8a0410ebbc1..049f89980035e 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php @@ -79,7 +79,7 @@ public function getArguments(Request $request, $controller) $representative = get_class($representative); } - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $representative, $metadata->getName())); + throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.', $representative, $metadata->getName())); } return $arguments; diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php index 5dd7c772b27ab..0962dab885fe9 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php @@ -27,7 +27,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface */ public function supports(Request $request, ArgumentMetadata $argument) { - return $argument->hasDefaultValue(); + return $argument->hasDefaultValue() || $argument->isNullable(); } /** @@ -35,6 +35,6 @@ public function supports(Request $request, ArgumentMetadata $argument) */ public function resolve(Request $request, ArgumentMetadata $argument) { - yield $argument->getDefaultValue(); + yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null; } } diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php index ca0e881fefbb3..72c294f3a3d7c 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php @@ -23,6 +23,7 @@ class ArgumentMetadata private $isVariadic; private $hasDefaultValue; private $defaultValue; + private $isNullable; /** * @param string $name @@ -30,14 +31,16 @@ class ArgumentMetadata * @param bool $isVariadic * @param bool $hasDefaultValue * @param mixed $defaultValue + * @param bool $isNullable */ - public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue) + public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue, $isNullable = false) { $this->name = $name; $this->type = $type; $this->isVariadic = $isVariadic; $this->hasDefaultValue = $hasDefaultValue; $this->defaultValue = $defaultValue; + $this->isNullable = (bool) $isNullable; } /** @@ -84,6 +87,16 @@ public function hasDefaultValue() return $this->hasDefaultValue; } + /** + * Returns whether the argument is nullable in PHP 7.1 or higher. + * + * @return bool + */ + public function isNullable() + { + return $this->isNullable; + } + /** * Returns the default value of the argument. * diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php index 6f49f389321d3..efe5966894495 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php @@ -18,6 +18,30 @@ */ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface { + /** + * If the ...$arg functionality is available. + * + * Requires at least PHP 5.6.0 or HHVM 3.9.1 + * + * @var bool + */ + private $supportsVariadic; + + /** + * If the reflection supports the getType() method to resolve types. + * + * Requires at least PHP 7.0.0 or HHVM 3.11.0 + * + * @var bool + */ + private $supportsParameterType; + + public function __construct() + { + $this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic'); + $this->supportsParameterType = method_exists('ReflectionParameter', 'getType'); + } + /** * {@inheritdoc} */ @@ -34,7 +58,7 @@ public function createArgumentMetadata($controller) } foreach ($reflection->getParameters() as $param) { - $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param)); + $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $this->isNullable($param)); } return $arguments; @@ -49,7 +73,7 @@ public function createArgumentMetadata($controller) */ private function isVariadic(\ReflectionParameter $parameter) { - return PHP_VERSION_ID >= 50600 && $parameter->isVariadic(); + return $this->supportsVariadic && $parameter->isVariadic(); } /** @@ -64,6 +88,23 @@ private function hasDefaultValue(\ReflectionParameter $parameter) return $parameter->isDefaultValueAvailable(); } + /** + * Returns if the argument is allowed to be null but is still mandatory. + * + * @param \ReflectionParameter $parameter + * + * @return bool + */ + private function isNullable(\ReflectionParameter $parameter) + { + if ($this->supportsParameterType) { + return null !== ($type = $parameter->getType()) && $type->allowsNull(); + } + + // fallback for supported php 5.x versions + return $this->hasDefaultValue($parameter) && null === $this->getDefaultValue($parameter); + } + /** * Returns a default value if available. * @@ -85,7 +126,7 @@ private function getDefaultValue(\ReflectionParameter $parameter) */ private function getType(\ReflectionParameter $parameter) { - if (PHP_VERSION_ID >= 70000) { + if ($this->supportsParameterType) { return $parameter->hasType() ? (string) $parameter->getType() : null; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php index 3f647e0bba437..964d83236278e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php @@ -19,6 +19,7 @@ use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\ExtendingRequest; +use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; use Symfony\Component\HttpFoundation\Request; @@ -202,6 +203,32 @@ public function testGetArgumentWithoutArray() $resolver->getArguments($request, $controller); } + /** + * @requires PHP 7.1 + */ + public function testGetNullableArguments() + { + $request = Request::create('/'); + $request->attributes->set('foo', 'foo'); + $request->attributes->set('bar', new \stdClass()); + $request->attributes->set('mandatory', 'mandatory'); + $controller = array(new NullableController(), 'action'); + + $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); + } + + /** + * @requires PHP 7.1 + */ + public function testGetNullableArgumentsWithDefaults() + { + $request = Request::create('/'); + $request->attributes->set('mandatory', 'mandatory'); + $controller = array(new NullableController(), 'action'); + + $this->assertEquals(array(null, null, 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); + } + public function __invoke($foo, $bar = null) { } diff --git a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index c6c2b597b1e5b..49931f052c82e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -15,10 +15,14 @@ use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\BasicTypesController; +use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; class ArgumentMetadataFactoryTest extends \PHPUnit_Framework_TestCase { + /** + * @var ArgumentMetadataFactory + */ private $factory; protected function setUp() @@ -42,9 +46,9 @@ public function testSignature2() $arguments = $this->factory->createArgumentMetadata(array($this, 'signature2')); $this->assertEquals(array( - new ArgumentMetadata('foo', self::class, false, true, null), - new ArgumentMetadata('bar', __NAMESPACE__.'\FakeClassThatDoesNotExist', false, true, null), - new ArgumentMetadata('baz', 'Fake\ImportedAndFake', false, true, null), + new ArgumentMetadata('foo', self::class, false, true, null, true), + new ArgumentMetadata('bar', __NAMESPACE__.'\FakeClassThatDoesNotExist', false, true, null, true), + new ArgumentMetadata('baz', 'Fake\ImportedAndFake', false, true, null, true), ), $arguments); } @@ -74,7 +78,7 @@ public function testSignature5() $arguments = $this->factory->createArgumentMetadata(array($this, 'signature5')); $this->assertEquals(array( - new ArgumentMetadata('foo', 'array', false, true, null), + new ArgumentMetadata('foo', 'array', false, true, null, true), new ArgumentMetadata('bar', null, false, false, null), ), $arguments); } @@ -106,6 +110,21 @@ public function testBasicTypesSignature() ), $arguments); } + /** + * @requires PHP 7.1 + */ + public function testNullableTypesSignature() + { + $arguments = $this->factory->createArgumentMetadata(array(new NullableController(), 'action')); + + $this->assertEquals(array( + new ArgumentMetadata('foo', 'string', false, false, null, true), + new ArgumentMetadata('bar', \stdClass::class, false, false, null, true), + new ArgumentMetadata('baz', 'string', false, true, 'value', true), + new ArgumentMetadata('mandatory', null, false, false, null), + ), $arguments); + } + private function signature1(ArgumentMetadataFactoryTest $foo, array $bar, callable $baz) { } diff --git a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php index 9713d70f8e649..cbb0d1bece382 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php @@ -15,10 +15,18 @@ class ArgumentMetadataTest extends \PHPUnit_Framework_TestCase { - public function testDefaultValueAvailable() + public function testWithBcLayerWithDefault() { $argument = new ArgumentMetadata('foo', 'string', false, true, 'default value'); + $this->assertFalse($argument->isNullable()); + } + + public function testDefaultValueAvailable() + { + $argument = new ArgumentMetadata('foo', 'string', false, true, 'default value', true); + + $this->assertTrue($argument->isNullable()); $this->assertTrue($argument->hasDefaultValue()); $this->assertSame('default value', $argument->getDefaultValue()); } @@ -28,8 +36,9 @@ public function testDefaultValueAvailable() */ public function testDefaultValueUnavailable() { - $argument = new ArgumentMetadata('foo', 'string', false, false, null); + $argument = new ArgumentMetadata('foo', 'string', false, false, null, false); + $this->assertFalse($argument->isNullable()); $this->assertFalse($argument->hasDefaultValue()); $argument->getDefaultValue(); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php new file mode 100644 index 0000000000000..d64e66d26b695 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php @@ -0,0 +1,10 @@ + Date: Tue, 16 Aug 2016 16:22:05 +0200 Subject: [PATCH 51/93] [Finder] no PHP warning on empty directory iteration --- .../Component/Finder/Iterator/RecursiveDirectoryIterator.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index 402033a5c2816..f011ce8d4d921 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -137,6 +137,10 @@ public function isRewindable() return $this->rewindable; } + if ('' === $this->getPath()) { + return $this->rewindable = false; + } + if (false !== $stream = @opendir($this->getPath())) { $infos = stream_get_meta_data($stream); closedir($stream); From b28cd815753b40585657e3d0af9dace8e52eba78 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 14 Sep 2016 14:04:40 -0700 Subject: [PATCH 52/93] added a comment about a workaround --- .../Component/Finder/Iterator/RecursiveDirectoryIterator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index f011ce8d4d921..1df2f5014f622 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -137,6 +137,7 @@ public function isRewindable() return $this->rewindable; } + // workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed if ('' === $this->getPath()) { return $this->rewindable = false; } From e0e5f0c3795399528b8232f189f42c80f00f1144 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sat, 13 Aug 2016 10:02:45 +0000 Subject: [PATCH 53/93] apply rtrim --- .../Iterator/ExcludeDirectoryFilterIterator.php | 3 ++- .../ExcludeDirectoryFilterIteratorTest.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index b7bb3c4f31310..3f5a5dfeb133c 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -35,6 +35,7 @@ public function __construct(\Iterator $iterator, array $directories) $this->isRecursive = $iterator instanceof \RecursiveIterator; $patterns = array(); foreach ($directories as $directory) { + $directory = rtrim($directory, '/'); if (!$this->isRecursive || false !== strpos($directory, '/')) { $patterns[] = preg_quote($directory, '#'); } else { @@ -51,7 +52,7 @@ public function __construct(\Iterator $iterator, array $directories) /** * Filters the iterator values. * - * @return bool true if the value should be kept, false otherwise + * @return bool True if the value should be kept, false otherwise */ public function accept() { diff --git a/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php index c5f4ba495a7ca..fa192c31f4dec 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php @@ -58,9 +58,23 @@ public function getAcceptData() 'foo bar', ); + $toto = array( + '.bar', + '.foo', + '.foo/.bar', + '.foo/bar', + '.git', + 'test.py', + 'foo', + 'foo/bar.tmp', + 'test.php', + 'foo bar', + ); + return array( array(array('foo'), $this->toAbsolute($foo)), array(array('fo'), $this->toAbsolute($fo)), + array(array('toto/'), $this->toAbsolute($toto)), ); } } From 8952155f9249473d49ce8d14aef8a8fcc1d90e47 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Thu, 15 Sep 2016 22:28:04 +0200 Subject: [PATCH 54/93] [Console] Fix empty optionnal options with = separator in argv --- .../Component/Console/Input/ArgvInput.php | 7 +++- .../Console/Tests/Input/ArgvInputTest.php | 38 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index f18d6e189970c..119be49170853 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -145,7 +145,10 @@ private function parseLongOption($token) $name = substr($token, 2); if (false !== $pos = strpos($name, '=')) { - $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1)); + if (0 === strlen($value = substr($name, $pos + 1))) { + array_unshift($this->parsed, null); + } + $this->addLongOption(substr($name, 0, $pos), $value); } else { $this->addLongOption($name, null); } @@ -232,7 +235,7 @@ private function addLongOption($name, $value) if (isset($next[0]) && '-' !== $next[0]) { $value = $next; } elseif (empty($next)) { - $value = ''; + $value = null; } else { array_unshift($this->parsed, $next); } diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 3b0dc3f231659..06347c87ba807 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -71,6 +71,18 @@ public function provideOptions() array('foo' => 'bar'), '->parse() parses long options with a required value (with a space separator)', ), + array( + array('cli.php', '--foo='), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => null), + '->parse() parses long options with optional value which is empty (with a = separator) as null', + ), + array( + array('cli.php', '--foo=', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)), + array('foo' => null), + '->parse() parses long options with optional value which is empty (with a = separator) followed by an argument', + ), array( array('cli.php', '-f'), array(new InputOption('foo', 'f')), @@ -324,4 +336,30 @@ public function testParseSingleDashAsArgument() $input->bind(new InputDefinition(array(new InputArgument('file')))); $this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument'); } + + public function testParseOptionWithValueOptionalGivenEmptyAndRequiredArgument() + { + $input = new ArgvInput(array('cli.php', '--foo=', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)))); + $this->assertEquals(array('foo' => null), $input->getOptions(), '->parse() parses optional options with empty value as null'); + $this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses required arguments'); + + $input = new ArgvInput(array('cli.php', '--foo=0', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)))); + $this->assertEquals(array('foo' => '0'), $input->getOptions(), '->parse() parses optional options with empty value as null'); + $this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses required arguments'); + } + + public function testParseOptionWithValueOptionalGivenEmptyAndOptionalArgument() + { + $input = new ArgvInput(array('cli.php', '--foo=', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::OPTIONAL)))); + $this->assertEquals(array('foo' => null), $input->getOptions(), '->parse() parses optional options with empty value as null'); + $this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses optional arguments'); + + $input = new ArgvInput(array('cli.php', '--foo=0', 'bar')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::OPTIONAL)))); + $this->assertEquals(array('foo' => '0'), $input->getOptions(), '->parse() parses optional options with empty value as null'); + $this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses optional arguments'); + } } From c87de00e9ad2d5a9ebb69be4e1b2eaf2847b1921 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 19 Sep 2016 16:03:56 +0100 Subject: [PATCH 55/93] Make redis host configurable in tests --- phpunit.xml.dist | 1 + .../Tests/Functional/CachePoolsTest.php | 14 ++++++++++++-- .../Functional/app/CachePools/redis_config.yml | 1 + .../app/CachePools/redis_custom_config.yml | 2 +- .../Bundle/FrameworkBundle/phpunit.xml.dist | 1 + .../Tests/Adapter/AbstractRedisAdapterTest.php | 2 +- .../Cache/Tests/Adapter/PredisAdapterTest.php | 8 +++++--- .../Cache/Tests/Adapter/RedisAdapterTest.php | 14 ++++++++------ .../Cache/Tests/Adapter/RedisArrayAdapterTest.php | 2 +- src/Symfony/Component/Cache/phpunit.xml.dist | 1 + 10 files changed, 32 insertions(+), 14 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a350a926d38d2..7652c58475569 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,6 +15,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index 565354343e2d7..9c7b27cab6de2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -17,6 +17,16 @@ class CachePoolsTest extends WebTestCase { + protected function setUp() + { + $_SERVER['SYMFONY__REDIS_HOST'] = getenv('REDIS_HOST'); + } + + protected function tearDown() + { + unset($_SERVER['SYMFONY__REDIS_HOST']); + } + public function testCachePools() { $this->doTestCachePools(array(), FilesystemAdapter::class); @@ -30,7 +40,7 @@ public function testRedisCachePools() try { $this->doTestCachePools(array('root_config' => 'redis_config.yml', 'environment' => 'redis_cache'), RedisAdapter::class); } catch (\PHPUnit_Framework_Error_Warning $e) { - if (0 !== strpos($e->getMessage(), 'unable to connect to 127.0.0.1')) { + if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); @@ -50,7 +60,7 @@ public function testRedisCustomCachePools() try { $this->doTestCachePools(array('root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'), RedisAdapter::class); } catch (\PHPUnit_Framework_Error_Warning $e) { - if (0 !== strpos($e->getMessage(), 'unable to connect to 127.0.0.1')) { + if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml index ae1fbf62a6ff3..9c41b34d5f930 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml @@ -4,6 +4,7 @@ imports: framework: cache: app: cache.adapter.redis + default_redis_provider: "redis://%redis_host%" pools: cache.test: public: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml index 3c99f05ac75cc..cd6084c7f3551 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml @@ -6,7 +6,7 @@ services: public: false class: Redis calls: - - [connect, [127.0.0.1]] + - [connect, ['%redis_host%']] cache.app: parent: cache.adapter.redis diff --git a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist index 1d25eeb3304c5..a105f7ece0a98 100644 --- a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist @@ -8,6 +8,7 @@ > + diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php index ff0b7eab2be18..86b16d436f23f 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php @@ -33,7 +33,7 @@ public static function setupBeforeClass() if (!extension_loaded('redis')) { self::markTestSkipped('Extension redis required.'); } - if (!@((new \Redis())->connect('127.0.0.1'))) { + if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) { $e = error_get_last(); self::markTestSkipped($e['message']); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php index 87a6db0736e0a..b2c87b23bbc4e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php @@ -19,12 +19,14 @@ class PredisAdapterTest extends AbstractRedisAdapterTest public static function setupBeforeClass() { parent::setupBeforeClass(); - self::$redis = new \Predis\Client(); + self::$redis = new \Predis\Client(array('host' => getenv('REDIS_HOST'))); } public function testCreateConnection() { - $redis = RedisAdapter::createConnection('redis://localhost/1', array('class' => \Predis\Client::class, 'timeout' => 3)); + $redisHost = getenv('REDIS_HOST'); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', array('class' => \Predis\Client::class, 'timeout' => 3)); $this->assertInstanceOf(\Predis\Client::class, $redis); $connection = $redis->getConnection(); @@ -32,7 +34,7 @@ public function testCreateConnection() $params = array( 'scheme' => 'tcp', - 'host' => 'localhost', + 'host' => $redisHost, 'path' => '', 'dbindex' => '1', 'port' => 6379, diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php index 2716f7b5abc6f..ab2e18b5a1e78 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php @@ -19,26 +19,28 @@ public static function setupBeforeClass() { parent::setupBeforeClass(); self::$redis = new \Redis(); - self::$redis->connect('127.0.0.1'); + self::$redis->connect(getenv('REDIS_HOST')); } public function testCreateConnection() { - $redis = RedisAdapter::createConnection('redis://localhost'); + $redisHost = getenv('REDIS_HOST'); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost); $this->assertInstanceOf(\Redis::class, $redis); $this->assertTrue($redis->isConnected()); $this->assertSame(0, $redis->getDbNum()); - $redis = RedisAdapter::createConnection('redis://localhost/2'); + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/2'); $this->assertSame(2, $redis->getDbNum()); - $redis = RedisAdapter::createConnection('redis://localhost', array('timeout' => 3)); + $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('timeout' => 3)); $this->assertEquals(3, $redis->getTimeout()); - $redis = RedisAdapter::createConnection('redis://localhost?timeout=4'); + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'?timeout=4'); $this->assertEquals(4, $redis->getTimeout()); - $redis = RedisAdapter::createConnection('redis://localhost', array('read_timeout' => 5)); + $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('read_timeout' => 5)); $this->assertEquals(5, $redis->getReadTimeout()); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php index d2968aea47c2c..bef3eb88729f5 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -19,6 +19,6 @@ public static function setupBeforeClass() if (!class_exists('RedisArray')) { self::markTestSkipped('The RedisArray class is required.'); } - self::$redis = new \RedisArray(array('localhost'), array('lazy_connect' => true)); + self::$redis = new \RedisArray(array(getenv('REDIS_HOST')), array('lazy_connect' => true)); } } diff --git a/src/Symfony/Component/Cache/phpunit.xml.dist b/src/Symfony/Component/Cache/phpunit.xml.dist index 480bb6aeef0e0..3e164e64b50d9 100644 --- a/src/Symfony/Component/Cache/phpunit.xml.dist +++ b/src/Symfony/Component/Cache/phpunit.xml.dist @@ -8,6 +8,7 @@ > + From 12350c2eb1e6785edb28b4b938a3c5cc73222711 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Sep 2016 12:59:08 -0700 Subject: [PATCH 56/93] [TwigBridge] removed Twig null nodes (deprecated as of Twig 1.25) --- src/Symfony/Bridge/Twig/Node/DumpNode.php | 13 +++++---- .../Bridge/Twig/Node/StopwatchNode.php | 2 +- src/Symfony/Bridge/Twig/Node/TransNode.php | 29 ++++++++++++++----- .../TranslationDefaultDomainNodeVisitor.php | 2 +- .../NodeVisitor/TranslationNodeVisitor.php | 8 ++--- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Node/DumpNode.php b/src/Symfony/Bridge/Twig/Node/DumpNode.php index 522497ba655dc..a7c152944618f 100644 --- a/src/Symfony/Bridge/Twig/Node/DumpNode.php +++ b/src/Symfony/Bridge/Twig/Node/DumpNode.php @@ -20,7 +20,12 @@ class DumpNode extends \Twig_Node public function __construct($varPrefix, \Twig_Node $values = null, $lineno, $tag = null) { - parent::__construct(array('values' => $values), array(), $lineno, $tag); + $nodes = array(); + if (null !== $values) { + $nodes['values'] = $values; + } + + parent::__construct($nodes, array(), $lineno, $tag); $this->varPrefix = $varPrefix; } @@ -33,9 +38,7 @@ public function compile(\Twig_Compiler $compiler) ->write("if (\$this->env->isDebug()) {\n") ->indent(); - $values = $this->getNode('values'); - - if (null === $values) { + if (!$this->hasNode('values')) { // remove embedded templates (macros) from the context $compiler ->write(sprintf('$%svars = array();'."\n", $this->varPrefix)) @@ -50,7 +53,7 @@ public function compile(\Twig_Compiler $compiler) ->write("}\n") ->addDebugInfo($this) ->write(sprintf('\Symfony\Component\VarDumper\VarDumper::dump($%svars);'."\n", $this->varPrefix)); - } elseif (1 === $values->count()) { + } elseif (($values = $this->getNode('values')) && 1 === $values->count()) { $compiler ->addDebugInfo($this) ->write('\Symfony\Component\VarDumper\VarDumper::dump(') diff --git a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php index 06eeb492728c6..839e3f7698684 100644 --- a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php +++ b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php @@ -18,7 +18,7 @@ */ class StopwatchNode extends \Twig_Node { - public function __construct(\Twig_Node $name, $body, \Twig_Node_Expression_AssignName $var, $lineno = 0, $tag = null) + public function __construct(\Twig_Node $name, \Twig_Node $body, \Twig_Node_Expression_AssignName $var, $lineno = 0, $tag = null) { parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag); } diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index af85d8f1858ec..5f1915d05e086 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -18,7 +18,21 @@ class TransNode extends \Twig_Node { public function __construct(\Twig_Node $body, \Twig_Node $domain = null, \Twig_Node_Expression $count = null, \Twig_Node_Expression $vars = null, \Twig_Node_Expression $locale = null, $lineno = 0, $tag = null) { - parent::__construct(array('count' => $count, 'body' => $body, 'domain' => $domain, 'vars' => $vars, 'locale' => $locale), array(), $lineno, $tag); + $nodes = array('body' => $body); + if (null !== $domain) { + $nodes['domain'] = $domain; + } + if (null !== $count) { + $nodes['count'] = $count; + } + if (null !== $vars) { + $nodes['vars'] = $vars; + } + if (null !== $locale) { + $nodes['locale'] = $locale; + } + + parent::__construct($nodes, array(), $lineno, $tag); } /** @@ -30,15 +44,14 @@ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); - $vars = $this->getNode('vars'); $defaults = new \Twig_Node_Expression_Array(array(), -1); - if ($vars instanceof \Twig_Node_Expression_Array) { + if ($this->hasNode('vars') && ($vars = $this->getNode('vars')) instanceof \Twig_Node_Expression_Array) { $defaults = $this->getNode('vars'); $vars = null; } list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars); - $method = null === $this->getNode('count') ? 'trans' : 'transChoice'; + $method = !$this->hasNode('count') ? 'trans' : 'transChoice'; $compiler ->write('echo $this->env->getExtension(\'translator\')->getTranslator()->'.$method.'(') @@ -47,7 +60,7 @@ public function compile(\Twig_Compiler $compiler) $compiler->raw(', '); - if (null !== $this->getNode('count')) { + if ($this->hasNode('count')) { $compiler ->subcompile($this->getNode('count')) ->raw(', ') @@ -68,13 +81,13 @@ public function compile(\Twig_Compiler $compiler) $compiler->raw(', '); - if (null === $this->getNode('domain')) { + if (!$this->hasNode('domain')) { $compiler->repr('messages'); } else { $compiler->subcompile($this->getNode('domain')); } - if (null !== $this->getNode('locale')) { + if ($this->hasNode('locale')) { $compiler ->raw(', ') ->subcompile($this->getNode('locale')) @@ -98,7 +111,7 @@ protected function compileString(\Twig_Node $body, \Twig_Node_Expression_Array $ foreach ($matches[1] as $var) { $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine()); if (!$vars->hasElement($key)) { - if ('count' === $var && null !== $this->getNode('count')) { + if ('count' === $var && $this->hasNode('count')) { $vars->addElement($this->getNode('count'), $key); } else { $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine()); diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index c923df9944c60..3e850350fd144 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -78,7 +78,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env) } } } elseif ($node instanceof TransNode) { - if (null === $node->getNode('domain')) { + if (!$node->hasNode('domain')) { $node->setNode('domain', $this->scope->get('domain')); } } diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index 4426a9d3b6666..6e3880d09ed98 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -75,7 +75,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env) // extract trans nodes $this->messages[] = array( $node->getNode('body')->getAttribute('data'), - $this->getReadDomainFromNode($node->getNode('domain')), + $node->hasNode('domain') ? $this->getReadDomainFromNode($node->getNode('domain')) : null, ); } @@ -122,12 +122,8 @@ private function getReadDomainFromArguments(\Twig_Node $arguments, $index) * * @return string|null */ - private function getReadDomainFromNode(\Twig_Node $node = null) + private function getReadDomainFromNode(\Twig_Node $node) { - if (null === $node) { - return; - } - if ($node instanceof \Twig_Node_Expression_Constant) { return $node->getAttribute('value'); } From 0d9dacc6db3818bd0a7067d01b68089602c1701b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 20 Sep 2016 14:38:50 +0200 Subject: [PATCH 57/93] [VarDumper] Fix extra whitespace --- .../Tests/DataCollector/DumpDataCollectorTest.php | 8 +++----- src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php index 18824635ea44f..68d28cf2d211a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php @@ -87,19 +87,17 @@ public function testCollectHtml() $file = __FILE__; if (PHP_VERSION_ID >= 50400) { $xOutput = <<DumpDataCollectorTest.php on line {$line}: +
DumpDataCollectorTest.php on line {$line}:
 123
 
- EOTXT; } else { $len = strlen("DumpDataCollectorTest.php on line {$line}:"); $xOutput = <<"DumpDataCollectorTest.php on line {$line}:" +
"DumpDataCollectorTest.php on line {$line}:"
 
123
 
- EOTXT; } @@ -111,7 +109,7 @@ public function testCollectHtml() $output = preg_replace('#<(script|style).*?#s', '', $output); $output = preg_replace('/sf-dump-\d+/', 'sf-dump', $output); - $this->assertSame($xOutput, $output); + $this->assertSame($xOutput, trim($output)); $this->assertSame(1, $collector->getDumpsCount()); $collector->serialize(); } diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 9a47aea7ee296..bd69f2eddf371 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -288,8 +288,7 @@ function isCtrlKey(e) { }; })(document); - -