diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 53a2faec2f..449973d757 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -24,10 +24,10 @@ Symfony is the result of the work of many people who made the code better - Kris Wallsmith (kriswallsmith) - Yonel Ceruto (yonelceruto) - Hugo Hamon (hhamon) + - Wouter de Jong (wouterj) + - Thomas Calvet (fancyweb) - Abdellatif Ait boudad (aitboudad) - Samuel ROZE (sroze) - - Thomas Calvet (fancyweb) - - Wouter de Jong (wouterj) - Romain Neutron (romain) - Pascal Borreli (pborreli) - Joseph Bielawski (stloyd) @@ -37,8 +37,8 @@ Symfony is the result of the work of many people who made the code better - Jules Pietri (heah) - Hamza Amrouche (simperfit) - Martin Hasoň (hason) - - Jeremy Mikola (jmikola) - Jérémy DERUSSÉ (jderusse) + - Jeremy Mikola (jmikola) - Jean-François Simon (jfsimon) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) @@ -50,9 +50,9 @@ Symfony is the result of the work of many people who made the code better - Lynn van der Berg (kjarli) - Diego Saint Esteben (dosten) - Matthias Pigulla (mpdude) + - Pierre du Plessis (pierredup) - Alexandre Salomé (alexandresalome) - William Durand (couac) - - Pierre du Plessis (pierredup) - ornicar - Dany Maillard (maidmaid) - Francis Besset (francisbesset) @@ -69,10 +69,10 @@ Symfony is the result of the work of many people who made the code better - Gabriel Ostrolucký (gadelat) - Miha Vrhovnik - David Maicher (dmaicher) - - Diego Saint Esteben (dii3g0) - Gábor Egyed (1ed) - - Titouan Galopin (tgalopin) + - Diego Saint Esteben (dii3g0) - Jan Schädlich (jschaedl) + - Titouan Galopin (tgalopin) - Konstantin Kudryashov (everzet) - Bilal Amarni (bamarni) - Mathieu Piot (mpiot) @@ -110,6 +110,7 @@ Symfony is the result of the work of many people who made the code better - Baptiste Clavié (talus) - Michal Piotrowski (eventhorizon) - Tim Nagel (merk) + - Sebastiaan Stok (sstok) - Chris Wilkinson (thewilkybarkid) - Brice BERNARD (brikou) - marc.weistroff @@ -119,7 +120,6 @@ Symfony is the result of the work of many people who made the code better - lenar - Alexander Schwenn (xelaris) - Włodzimierz Gajda (gajdaw) - - Sebastiaan Stok (sstok) - Adrien Brault (adrienbrault) - Jacob Dreesen (jdreesen) - Florian Voutzinos (florianv) @@ -139,18 +139,18 @@ Symfony is the result of the work of many people who made the code better - Przemysław Bogusz (przemyslaw-bogusz) - Eric GELOEN (gelo) - Lars Strojny (lstrojny) + - Massimiliano Arione (garak) - Jannik Zschiesche (apfelbox) - Robert Schönthal (digitalkaoz) - Gregor Harlan (gharlan) - Florian Lonqueu-Brochard (florianlb) + - Alexander Schranz (alexander-schranz) - Gabriel Caruso (carusogabriel) - Stefano Sala (stefano.sala) - Evgeniy (ewgraf) - - Massimiliano Arione (garak) - Julien Falque (julienfalque) - Vincent AUBERT (vincent) - Juti Noppornpitak (shiroyuki) - - Alexander Schranz (alexander-schranz) - Anthony MARTIN (xurudragon) - Tigran Azatyan (tigranazatyan) - Sebastian Hörl (blogsh) @@ -176,6 +176,7 @@ Symfony is the result of the work of many people who made the code better - Richard van Laak (rvanlaak) - Richard Shank (iampersistent) - Thomas Rabaix (rande) + - Ahmed TAILOULOUTE (ahmedtai) - Vincent Touzet (vincenttouzet) - jeremyFreeAgent (jeremyfreeagent) - Rouven Weßling (realityking) @@ -198,6 +199,7 @@ Symfony is the result of the work of many people who made the code better - James Halsall (jaitsu) - Matthieu Napoli (mnapoli) - Florent Mata (fmata) + - Antoine Makdessi (amakdessi) - Warnar Boekkooi (boekkooi) - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) @@ -213,15 +215,18 @@ Symfony is the result of the work of many people who made the code better - Dennis Benkert (denderello) - DQNEO - Andre Rømcke (andrerom) + - Saif (╯°□°)╯ (azjezz) - mcfedr (mcfedr) - Gary PEGEOT (gary-p) - Ruben Gonzalez (rubenrua) - Benjamin Dulau (dbenjamin) + - Jan Rosier (rosier) - Andreas Braun - Mathieu Lemoine (lemoinem) - Christian Schmidt - Andreas Hucks (meandmymonkey) - Tom Van Looy (tvlooy) + - Guillaume Pédelagrabe - Noel Guilbert (noel) - Anthony GRASSIOT (antograssiot) - Stadly @@ -233,7 +238,7 @@ Symfony is the result of the work of many people who made the code better - Nikolay Labinskiy (e-moe) - Martin Schuhfuß (usefulthink) - apetitpa - - Antoine Makdessi (amakdessi) + - Maxime Helias (maxhelias) - Matthieu Bontemps (mbontemps) - apetitpa - Pierre Minnieur (pminnieur) @@ -243,14 +248,13 @@ Symfony is the result of the work of many people who made the code better - Laurent VOULLEMIER (lvo) - Michael Lee (zerustech) - Matthieu Auger (matthieuauger) - - Ahmed TAILOULOUTE (ahmedtai) + - Mathias Arlaud (mtarld) - Leszek Prabucki (l3l0) - Fabien Bourigault (fbourigault) - François Zaninotto (fzaninotto) - Dustin Whittle (dustinwhittle) - jeff - John Kary (johnkary) - - Jan Rosier (rosier) - Justin Hileman (bobthecow) - Blanchon Vincent (blanchonvincent) - Michele Orselli (orso) @@ -270,7 +274,6 @@ Symfony is the result of the work of many people who made the code better - Marcel Beerta (mazen) - Christopher Hertel (chertel) - Ruud Kamphuis (ruudk) - - Maxime Helias (maxhelias) - Pavel Batanov (scaytrase) - Mantis Development - David Prévot @@ -283,7 +286,6 @@ Symfony is the result of the work of many people who made the code better - Lorenz Schori - Sébastien Lavoie (lavoiesl) - Dariusz - - Saif (╯°□°)╯ (azjezz) - Dmitrii Poddubnyi (karser) - Michael Babker (mbabker) - Francois Zaninotto @@ -307,7 +309,6 @@ Symfony is the result of the work of many people who made the code better - Arjen Brouwer (arjenjb) - Katsuhiro OGAWA - Patrick McDougle (patrick-mcdougle) - - Guillaume Pédelagrabe - Alif Rachmawadi - Anton Chernikov (anton_ch1989) - Kristen Gilden (kgilden) @@ -336,9 +337,9 @@ Symfony is the result of the work of many people who made the code better - Jeroen Spee (jeroens) - Nikita Konstantinov - Wodor Wodorski + - Olivier Dolbeau (odolbeau) - Thomas Lallement (raziel057) - Colin O'Dell (colinodell) - - Mathias Arlaud (mtarld) - Giorgio Premi - renanbr - Alex Rock (pierstoval) @@ -364,6 +365,7 @@ Symfony is the result of the work of many people who made the code better - Vilius Grigaliūnas - David Badura (davidbadura) - Chad Sikorra (chadsikorra) + - Alan Poulain (alanpoulain) - Chris Smith (cs278) - Thomas Bisignani (toma) - Florian Klein (docteurklein) @@ -413,7 +415,6 @@ Symfony is the result of the work of many people who made the code better - Thomas Royer (cydonia7) - Nicolas LEFEVRE (nicoweb) - alquerci - - Olivier Dolbeau (odolbeau) - Oleg Andreyev - Mateusz Sip (mateusz_sip) - Francesco Levorato @@ -426,6 +427,7 @@ Symfony is the result of the work of many people who made the code better - Tomasz Kowalczyk (thunderer) - Artur Eshenbrener - Timo Bakx (timobakx) + - Antonio Pauletich (x-coder264) - Thomas Perez (scullwm) - Felix Labrecque - Yaroslav Kiliba @@ -443,7 +445,6 @@ Symfony is the result of the work of many people who made the code better - Eduardo Gulias (egulias) - giulio de donato (liuggio) - ShinDarth - - Alan Poulain - Stéphane PY (steph_py) - Philipp Kräutli (pkraeutli) - Grzegorz (Greg) Zdanowski (kiler129) @@ -540,10 +541,10 @@ Symfony is the result of the work of many people who made the code better - Martijn Cuppens - Vlad Gregurco (vgregurco) - Boris Vujicic (boris.vujicic) + - Artem Lopata - Chris Sedlmayr (catchamonkey) - Kamil Kokot (pamil) - Seb Koelen - - Antonio Pauletich (x-coder264) - Christoph Mewes (xrstf) - Vitaliy Tverdokhlib (vitaliytv) - Ariel Ferrandini (aferrandini) @@ -553,14 +554,17 @@ Symfony is the result of the work of many people who made the code better - Jonas Flodén (flojon) - Tobias Weichart - Gonzalo Vilaseca (gonzalovilaseca) + - Daniel STANCU - Tarmo Leppänen (tarlepp) - Marcin Sikoń (marphi) - Dominik Zogg (dominik.zogg) - Marek Pietrzak - Luc Vieillescazes (iamluc) - franek (franek) + - soyuka - Raulnet - Christian Wahler + - Giso Stallenberg (gisostallenberg) - Gintautas Miselis - Rob Bast - Roberto Espinoza (respinoza) @@ -599,6 +603,7 @@ Symfony is the result of the work of many people who made the code better - Philipp Rieber (bicpi) - Manuel de Ruiter (manuel) - Nathanael Noblet (gnat) + - Dimitri Gritsajuk (ottaviano) - nikos.sotiropoulos - Eduardo Oliveira (entering) - Ilya Antipenko (aivus) @@ -744,6 +749,7 @@ Symfony is the result of the work of many people who made the code better - Benjamin Cremer (bcremer) - Javier López (loalf) - Reinier Kip + - Jérôme Tamarelle (jtamarelle-prismamedia) - Geoffrey Brier (geoffrey-brier) - Alexandre Parent - Vladimir Tsykun @@ -778,7 +784,6 @@ Symfony is the result of the work of many people who made the code better - Miquel Rodríguez Telep (mrtorrent) - Sergey Kolodyazhnyy (skolodyazhnyy) - umpirski - - Artem Lopata - M. Vondano - Quentin de Longraye (quentinus95) - Chris Heng (gigablah) @@ -786,10 +791,10 @@ Symfony is the result of the work of many people who made the code better - Richard Bradley - Ulumuddin Yunus (joenoez) - rtek + - Ivan Grigoriev - Johann Saunier (prophet777) - Sergey (upyx) - Andreas Erhard - - Giso Stallenberg (gisostallenberg) - Michael Devery (mickadoo) - Antoine Corcy - Ahmed Ashraf (ahmedash95) @@ -810,6 +815,7 @@ Symfony is the result of the work of many people who made the code better - Cameron Porter - Hossein Bukhamsin - Oliver Hoff + - William Arslett - Christian Sciberras (uuf6429) - Disparity - origaminal @@ -856,7 +862,6 @@ Symfony is the result of the work of many people who made the code better - Markus Fasselt (digilist) - Julien DIDIER (juliendidier) - Dominik Ritter (dritter) - - Dimitri Gritsajuk (ottaviano) - Sebastian Grodzicki (sgrodzicki) - Mohamed Gamal - Jeroen van den Enden (stoefke) @@ -871,6 +876,7 @@ Symfony is the result of the work of many people who made the code better - Yuen-Chi Lian - Tarjei Huse (tarjei) - Besnik Br + - Axel Guckelsberger (guite) - Jose Gonzalez - Jonathan (jls-esokia) - Oleksii Zhurbytskyi @@ -881,12 +887,14 @@ Symfony is the result of the work of many people who made the code better - Jakub Kulhan (jakubkulhan) - Shaharia Azam - avorobiev + - stoccc - Grégoire Penverne (gpenverne) - Venu - Lars Vierbergen - Jonatan Männchen - Dennis Hotson - Andrew Tchircoff (andrewtch) + - Ahmed Raafat - michaelwilliams - Martin Kirilov - 1emming @@ -894,6 +902,7 @@ Symfony is the result of the work of many people who made the code better - Tri Pham (phamuyentri) - Jordan Deitch - Casper Valdemar Poulsen + - Laurent Masforné (heisenberg) - Josiah (josiah) - Guillaume Verstraete (versgui) - Greg ORIOL @@ -961,10 +970,8 @@ Symfony is the result of the work of many people who made the code better - Laurent Bassin (lbassin) - andrey1s - Abhoryo - - Daniel STANCU - Fabian Vogler (fabian) - Korvin Szanto - - soyuka - Stéphan Kochen - Arjan Keeman - Alaattin Kahramanlar (alaattin) @@ -1133,6 +1140,7 @@ Symfony is the result of the work of many people who made the code better - Nicolas Le Goff (nlegoff) - Ben Oman - Chris de Kok + - Eduard Bulava (nonanerz) - Lorenzo Millucci - Andreas Kleemann - Manuele Menozzi @@ -1150,6 +1158,7 @@ Symfony is the result of the work of many people who made the code better - hamza - dantleech - Bastien DURAND (deamon) + - Kajetan Kołtuniak (kajtii) - Sander Goossens (sandergo90) - Rudy Onfroy - Tero Alén (tero) @@ -1237,7 +1246,6 @@ Symfony is the result of the work of many people who made the code better - Benjamin Paap (benjaminpaap) - Claus Due (namelesscoder) - Christian - - William Arslett - Denis Golubovskiy (bukashk0zzz) - Sergii Smertin (nfx) - Mikkel Paulson @@ -1246,6 +1254,7 @@ Symfony is the result of the work of many people who made the code better - Marc Duboc (icemad) - Matthias Krauser (mkrauser) - Martynas Narbutas + - Nilmar Sanchez Muguercia - Toon Verwerft (veewee) - Bailey Parker - Eddie Jaoude @@ -1289,6 +1298,7 @@ Symfony is the result of the work of many people who made the code better - Stephen Clouse - e-ivanov - Michał (bambucha15) + - Benjamin Dos Santos - Einenlum - Jérémy Jarrié (gagnar) - Jochen Bayer (jocl) @@ -1344,6 +1354,7 @@ Symfony is the result of the work of many people who made the code better - Klaus Purer - arnaud (arnooo999) - Gilles Doge (gido) + - Oscar Esteve (oesteve) - abulford - Philipp Kretzschmar - antograssiot @@ -1367,7 +1378,6 @@ Symfony is the result of the work of many people who made the code better - Derek Lambert - MightyBranch - Kacper Gunia (cakper) - - Jérôme Tamarelle (jtamarelle-prismamedia) - Peter Thompson (petert82) - error56 - Felicitus @@ -1392,6 +1402,7 @@ Symfony is the result of the work of many people who made the code better - Nyro (nyro) - Marco - Marc Torres + - Mark Spink - Alberto Aldegheri - Dmitri Petmanson - heccjj @@ -1412,7 +1423,6 @@ Symfony is the result of the work of many people who made the code better - David Négrier (moufmouf) - Quique Porta (quiqueporta) - mohammadreza honarkhah - - stoccc - Andrea Quintino (dirk39) - Tomasz Szymczyk (karion) - Alex Vasilchenko @@ -1468,7 +1478,6 @@ Symfony is the result of the work of many people who made the code better - Walter Dal Mut (wdalmut) - abluchet - Ruud Arentsen - - Ahmed Raafat - Harald Tollefsen - Matthieu - Albin Kerouaton @@ -1504,7 +1513,6 @@ Symfony is the result of the work of many people who made the code better - Antal Áron (antalaron) - Vašek Purchart (vasek-purchart) - Janusz Jabłoński (yanoosh) - - Ivan Grigoriev - Fleuv - Sandro Hopf - Łukasz Makuch @@ -1522,6 +1530,7 @@ Symfony is the result of the work of many people who made the code better - Philip Frank - David Brooks - Lance McNearney + - Serhiy Lunak (slunak) - Giorgio Premi - Aurélien Fontaine - ncou @@ -1531,6 +1540,7 @@ Symfony is the result of the work of many people who made the code better - Matt Daum (daum) - Alberto Pirovano (geezmo) - Pete Mitchell (peterjmit) + - phuc vo (phucwan) - Tom Corrigan (tomcorrigan) - Luis Galeas - Bogdan Scordaliu @@ -1543,7 +1553,6 @@ Symfony is the result of the work of many people who made the code better - WedgeSama - Felds Liscia - Chihiro Adachi (chihiro-adachi) - - Axel Guckelsberger (guite) - Raphaëll Roussel - Tadcka - Beth Binkovitz @@ -1651,6 +1660,7 @@ Symfony is the result of the work of many people who made the code better - Flavian (2much) - Gautier Deuette - mike + - tadas - Kirk Madera - Keith Maika - Mephistofeles @@ -1834,6 +1844,7 @@ Symfony is the result of the work of many people who made the code better - alefranz - David Barratt - Andrea Giannantonio + - Dries Vints - Pavel.Batanov - avi123 - Pavel Prischepa @@ -1900,6 +1911,7 @@ Symfony is the result of the work of many people who made the code better - Yannick Warnier (ywarnier) - Kevin Decherf - Jason Woods + - Christian Weiske - Maria Grazia Patteri - klemens - dened @@ -2149,6 +2161,7 @@ Symfony is the result of the work of many people who made the code better - Evgeniy Tetenchuk - Sjoerd Adema - Shrey Puranik + - Evgeniy Koval - Lars Moelleken - dasmfm - Mathias Geat @@ -2208,6 +2221,7 @@ Symfony is the result of the work of many people who made the code better - Niklas Keller - Andras Debreczeni - Vladimir Sazhin + - Michel Bardelmeijer - Tomas Kmieliauskas - Billie Thompson - lol768 @@ -2241,6 +2255,7 @@ Symfony is the result of the work of many people who made the code better - Michael Schneider - Cédric Bertolini - n-aleha + - Talha Zekeriya Durmuş - Anatol Belski - Anderson Müller - Şəhriyar İmanov @@ -2268,6 +2283,7 @@ Symfony is the result of the work of many people who made the code better - Neophy7e - bokonet - Arrilot + - ampaze - Markus Staab - Pierre-Louis LAUNAY - djama @@ -2417,6 +2433,7 @@ Symfony is the result of the work of many people who made the code better - Michal Čihař (mcihar) - Matt Drollette (mdrollette) - Adam Monsen (meonkeys) + - Mike Milano (mmilano) - diego aguiar (mollokhan) - Hugo Monteiro (monteiro) - Ala Eddine Khefifi (nayzo) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index dfffb36537..21cdfa970e 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -50,7 +50,12 @@ class SymfonyTestsListenerTrait */ public function __construct(array $mockedNamespaces = []) { - Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; + if (method_exists(Blacklist::class, 'addDirectory')) { + (new BlackList())->getBlacklistedDirectories(); + Blacklist::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2)); + } else { + Blacklist::$blacklistedClassNames[__CLASS__] = 2; + } $enableDebugClassLoader = class_exists(DebugClassLoader::class) || class_exists(LegacyDebugClassLoader::class); diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index 401aafde16..dc2730bc9a 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -215,9 +215,10 @@ require PHPUNIT_COMPOSER_INSTALL; if (!class_exists('SymfonyBlacklistPhpunit', false)) { class SymfonyBlacklistPhpunit {} } -if (class_exists('PHPUnit_Util_Blacklist')) { - PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; - PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; +if (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) { + (new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistPhpunit'))->getFileName())); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistSimplePhpunit'))->getFileName())); } else { PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index e1a8737b37..a285a435ce 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -24,7 +24,7 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0|<6.4,>=6.0" + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0|<6.4,>=6.0|9.1.2" }, "autoload": { "files": [ "bootstrap.php" ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php index 04d391da17..32bd630f32 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php @@ -103,9 +103,10 @@ EOF $serviceIdsNb = 0; foreach ($serviceIds as $serviceId) { $text = []; + $resolvedServiceId = $serviceId; if (0 !== strpos($serviceId, $previousId)) { $text[] = ''; - if ('' !== $description = Descriptor::getClassDescription($serviceId, $serviceId)) { + if ('' !== $description = Descriptor::getClassDescription($serviceId, $resolvedServiceId)) { if (isset($hasAlias[$serviceId])) { continue; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ClassAliasExampleClass.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ClassAliasExampleClass.php new file mode 100644 index 0000000000..c129865859 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ClassAliasExampleClass.php @@ -0,0 +1,14 @@ +run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]); $this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay()); } + + public function testNotConfusedByClassAliases() + { + static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']); + + $application = new Application(static::$kernel); + $application->setAutoExit(false); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'debug:autowiring', 'search' => 'ClassAlias']); + $this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass (public)', $tester->getDisplay()); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index 2199560ac8..7dbe15c6c9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -16,7 +16,6 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\Kernel; @@ -101,15 +100,6 @@ class AppKernel extends Kernel implements ExtensionInterface, ConfigurationInter return $parameters; } - public function getContainer(): ContainerInterface - { - if (!$this->container) { - throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?'); - } - - return parent::getContainer(); - } - public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('foo'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/config.yml index 0cc73dbc81..25c1c78429 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/config.yml @@ -13,6 +13,7 @@ services: public: false Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass: class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass + Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass: '@public' env: class: stdClass arguments: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index c4e7e4a15b..8e622282c2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app; use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\Kernel; @@ -99,13 +98,4 @@ class AppKernel extends Kernel return $parameters; } - - public function getContainer(): ContainerInterface - { - if (!$this->container) { - throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?'); - } - - return parent::getContainer(); - } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig index 268f8fdc7e..49878a72d5 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig @@ -5,18 +5,18 @@ {% set status_color = (collector.memory / 1024 / 1024) > 50 ? 'yellow' : '' %} {{ include('@WebProfiler/Icon/memory.svg') }} {{ '%.1f'|format(collector.memory / 1024 / 1024) }} - MB + MiB {% endset %} {% set text %}
Peak memory usage - {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB + {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MiB
PHP memory limit - {{ collector.memoryLimit == -1 ? 'Unlimited' : '%.0f MB'|format(collector.memoryLimit / 1024 / 1024) }} + {{ collector.memoryLimit == -1 ? 'Unlimited' : '%.0f MiB'|format(collector.memoryLimit / 1024 / 1024) }}
{% endset %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index 62187dbab4..9284a0a708 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -52,7 +52,7 @@ {% if profile.collectors.memory %}
- {{ '%.2f'|format(profile.collectors.memory.memory / 1024 / 1024) }} MB + {{ '%.2f'|format(profile.collectors.memory.memory / 1024 / 1024) }} MiB Peak memory usage
{% endif %} diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 58b1d62aea..3cb6f17131 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Adapter; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\ResettableInterface; @@ -112,10 +111,12 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg return $opcache; } - $apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version); - if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { - $apcu->setLogger(new NullLogger()); - } elseif (null !== $logger) { + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + return $opcache; + } + + $apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version); + if (null !== $logger) { $apcu->setLogger($logger); } diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index e54f204c59..5432ce92fb 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -51,6 +51,9 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa if (!$adapter instanceof CacheItemPoolInterface) { throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class)); } + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + continue; // skip putting APCu in the chain when the backend is disabled + } if ($adapter instanceof AdapterInterface) { $this->adapters[] = $adapter; diff --git a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php b/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php index 68671dc238..b534e5dc8a 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php @@ -46,29 +46,38 @@ class CacheCollectorPass implements CompilerPassInterface return; } - $collectorDefinition = $container->getDefinition($this->dataCollectorCacheId); foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $attributes) { - $definition = $container->getDefinition($id); - if ($definition->isAbstract()) { - continue; + $this->addToCollector($id, $container); + + if (($attributes[0]['name'] ?? $id) !== $id) { + $this->addToCollector($attributes[0]['name'], $container); } - - $recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class); - $recorder->setTags($definition->getTags()); - if (!$definition->isPublic() || !$definition->isPrivate()) { - $recorder->setPublic($definition->isPublic()); - } - $recorder->setArguments([new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)]); - - $definition->setTags([]); - $definition->setPublic(false); - - $container->setDefinition($innerId, $definition); - $container->setDefinition($id, $recorder); - - // Tell the collector to add the new instance - $collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id)]); - $collectorDefinition->setPublic(false); } } + + private function addToCollector(string $id, ContainerBuilder $container) + { + $definition = $container->getDefinition($id); + if ($definition->isAbstract()) { + return; + } + + $collectorDefinition = $container->getDefinition($this->dataCollectorCacheId); + $recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class); + $recorder->setTags($definition->getTags()); + if (!$definition->isPublic() || !$definition->isPrivate()) { + $recorder->setPublic($definition->isPublic()); + } + $recorder->setArguments([new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)]); + + $definition->setTags([]); + $definition->setPublic(false); + + $container->setDefinition($innerId, $definition); + $container->setDefinition($id, $recorder); + + // Tell the collector to add the new instance + $collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id)]); + $collectorDefinition->setPublic(false); + } } diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php index 7e77491de8..8aff19fc3e 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\Cache\Adapter\TraceableAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; @@ -34,16 +35,29 @@ class CacheCollectorPassTest extends TestCase ->addArgument(new Reference('fs')) ->addTag('cache.pool'); + $container + ->register('.php.inner', PhpArrayAdapter::class) + ->addTag('cache.pool', ['name' => 'php']); + $container + ->register('php', TagAwareAdapter::class) + ->addArgument(new Reference('.php.inner')); + $collector = $container->register('data_collector.cache', CacheDataCollector::class); (new CacheCollectorPass())->process($container); $this->assertEquals([ ['addInstance', ['fs', new Reference('fs')]], ['addInstance', ['tagged_fs', new Reference('tagged_fs')]], + ['addInstance', ['.php.inner', new Reference('.php.inner')]], + ['addInstance', ['php', new Reference('php')]], ], $collector->getMethodCalls()); $this->assertSame(TraceableAdapter::class, $container->findDefinition('fs')->getClass()); $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('tagged_fs')->getClass()); + + $this->assertSame(TraceableAdapter::class, $container->findDefinition('.php.inner')->getClass()); + $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('php')->getClass()); + $this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing'); } } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index b379bae2ed..5c8bb9c9d3 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1726,7 +1726,11 @@ EOF; if (!$v) { continue; } - $definition = $this->container->findDefinition($id = (string) $v); + $id = (string) $v; + while ($this->container->hasAlias($id)) { + $id = (string) $this->container->getAlias($id); + } + $definition = $this->container->getDefinition($id); $load = !($definition->hasErrors() && $e = $definition->getErrors()) ? $this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition) : reset($e); $serviceMap .= sprintf("\n %s => [%s, %s, %s, %s],", $this->export($k), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php index 6046f79639..ee5b386932 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php @@ -88,6 +88,7 @@ class RegisterServiceSubscribersPassTest extends TestCase CustomDefinition::class => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)), 'bar' => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'bar')), 'baz' => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE, 'baz')), + 'late_alias' => new ServiceClosureArgument(new TypedReference(TestDefinition1::class, TestDefinition1::class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'late_alias')), ]; $this->assertEquals($expected, $container->getDefinition((string) $locator->getFactory()[0])->getArgument(0)); @@ -118,6 +119,7 @@ class RegisterServiceSubscribersPassTest extends TestCase CustomDefinition::class => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)), 'bar' => new ServiceClosureArgument(new TypedReference('bar', CustomDefinition::class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'bar')), 'baz' => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE, 'baz')), + 'late_alias' => new ServiceClosureArgument(new TypedReference(TestDefinition1::class, TestDefinition1::class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'late_alias')), ]; $this->assertEquals($expected, $container->getDefinition((string) $locator->getFactory()[0])->getArgument(0)); @@ -260,6 +262,7 @@ class RegisterServiceSubscribersPassTest extends TestCase CustomDefinition::class => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)), 'bar' => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'bar')), 'baz' => new ServiceClosureArgument(new TypedReference(CustomDefinition::class, CustomDefinition::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE, 'baz')), + 'late_alias' => new ServiceClosureArgument(new TypedReference(TestDefinition1::class, TestDefinition1::class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'late_alias')), ]; $this->assertEquals($expected, $container->getDefinition((string) $locator->getFactory()[0])->getArgument(0)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index b85cae02df..2958a29b2a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -21,6 +21,8 @@ use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocator as ArgumentServiceLocator; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface; use Symfony\Component\DependencyInjection\Definition; @@ -38,6 +40,7 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument; use Symfony\Component\DependencyInjection\Tests\Fixtures\ScalarFactory; use Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator; +use Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1; use Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber; use Symfony\Component\DependencyInjection\TypedReference; use Symfony\Component\DependencyInjection\Variable; @@ -911,6 +914,20 @@ class PhpDumperTest extends TestCase $container->register(CustomDefinition::class, CustomDefinition::class) ->setPublic(false); + + $container->register(TestDefinition1::class, TestDefinition1::class)->setPublic(true); + + $container->addCompilerPass(new class() implements CompilerPassInterface { + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container) + { + $container->setDefinition('late_alias', new Definition(TestDefinition1::class)); + $container->setAlias(TestDefinition1::class, 'late_alias'); + } + }, PassConfig::TYPE_AFTER_REMOVING); + $container->compile(); $dumper = new PhpDumper($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php index 6876fc5cca..f4a4bdda64 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php @@ -22,6 +22,7 @@ class TestServiceSubscriber implements ServiceSubscriberInterface '?'.CustomDefinition::class, 'bar' => CustomDefinition::class, 'baz' => '?'.CustomDefinition::class, + 'late_alias' => TestDefinition1::class, ]; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index aba10028e1..05364b6bab 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -24,9 +24,11 @@ class ProjectServiceContainer extends Container $this->methodMap = [ 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'getTestServiceSubscriberService', 'foo_service' => 'getFooServiceService', + 'late_alias' => 'getLateAliasService', + ]; + $this->aliases = [ + 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1' => 'late_alias', ]; - - $this->aliases = []; } public function compile(): void @@ -42,11 +44,13 @@ class ProjectServiceContainer extends Container public function getRemovedIds(): array { return [ - '.service_locator.Csd_kfL' => true, - '.service_locator.Csd_kfL.foo_service' => true, + '.service_locator.dZze14t' => true, + '.service_locator.dZze14t.foo_service' => true, 'Psr\\Container\\ContainerInterface' => true, 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true, + 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1' => true, + 'late_alias' => true, ]; } @@ -72,14 +76,26 @@ class ProjectServiceContainer extends Container 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false], 'bar' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false], 'baz' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false], + 'late_alias' => ['services', 'late_alias', 'getLateAliasService', false], ], [ 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'bar' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'baz' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', + 'late_alias' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1', ]))->withContext('foo_service', $this)); } + /** + * Gets the public 'late_alias' shared service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1 + */ + protected function getLateAliasService() + { + return $this->services['late_alias'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1(); + } + /** * Gets the private 'Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition' shared service. * diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index ba673728e3..ec1e7fe387 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -215,6 +215,14 @@ class DateTimeType extends AbstractType // * the html5 is set to true if ($options['html5'] && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { $view->vars['type'] = 'datetime-local'; + + // we need to force the browser to display the seconds by + // adding the HTML attribute step if not already defined. + // Otherwise the browser will not display and so not send the seconds + // therefore the value will always be considered as invalid. + if ($options['with_seconds'] && !isset($view->vars['attr']['step'])) { + $view->vars['attr']['step'] = 1; + } } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index afa941dccc..4c047b67c2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -482,6 +482,37 @@ class DateTimeTypeTest extends BaseTypeTest $this->assertArrayNotHasKey('type', $view->vars); } + public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute() + { + $view = $this->factory + ->create(static::TESTED_TYPE, null, [ + 'widget' => 'single_text', + 'with_seconds' => true, + ]) + ->createView() + ; + + $this->assertArrayHasKey('step', $view->vars['attr']); + $this->assertEquals(1, $view->vars['attr']['step']); + } + + public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute() + { + $view = $this->factory + ->create(static::TESTED_TYPE, null, [ + 'widget' => 'single_text', + 'with_seconds' => true, + 'attr' => [ + 'step' => 30, + ], + ]) + ->createView() + ; + + $this->assertArrayHasKey('step', $view->vars['attr']); + $this->assertEquals(30, $view->vars['attr']['step']); + } + public function testSingleTextWidgetWithCustomNonHtml5Format() { $form = $this->factory->create(static::TESTED_TYPE, new \DateTime('2019-02-13 19:12:13'), [ diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profile.php b/src/Symfony/Component/HttpKernel/Profiler/Profile.php index c18e9980a1..37b690ed86 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -101,7 +101,7 @@ class Profile return $this->ip; } - public function setIp(string $ip) + public function setIp(?string $ip) { $this->ip = $ip; } @@ -131,7 +131,7 @@ class Profile return $this->url; } - public function setUrl(string $url) + public function setUrl(?string $url) { $this->url = $url; } diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php index 3f68227ba4..afa522ae97 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php @@ -106,6 +106,9 @@ class EsmtpTransport extends SmtpTransport /** @var SocketStream $stream */ $stream = $this->getStream(); + // WARNING: !$stream->isTLS() is right, 100% sure :) + // if you think that the ! should be removed, read the code again + // if doing so "fixes" your issue then it probably means your SMTP server behaves incorrectly or is wrongly configured if (!$stream->isTLS() && \defined('OPENSSL_VERSION_NUMBER') && \array_key_exists('STARTTLS', $capabilities)) { $this->executeCommand("STARTTLS\r\n", [220]); diff --git a/src/Symfony/Component/Validator/Tests/Violation/ConstraintViolationBuilderTest.php b/src/Symfony/Component/Validator/Tests/Violation/ConstraintViolationBuilderTest.php new file mode 100644 index 0000000000..4121dc2622 --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/Violation/ConstraintViolationBuilderTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Violation; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Translation\IdentityTranslator; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\Test\ForwardCompatTestTrait; +use Symfony\Component\Validator\Violation\ConstraintViolationBuilder; + +class ConstraintViolationBuilderTest extends TestCase +{ + use ForwardCompatTestTrait; + + private $root; + private $violations; + private $messageTemplate = '%value% is invalid'; + private $builder; + + private function doSetUp() + { + $this->root = [ + 'data' => [ + 'foo' => 'bar', + 'baz' => 'foobar', + ], + ]; + $this->violations = new ConstraintViolationList(); + $this->builder = new ConstraintViolationBuilder($this->violations, new Valid(), $this->messageTemplate, [], $this->root, 'data', 'foo', new IdentityTranslator()); + } + + public function testAddViolation() + { + $this->builder->addViolation(); + + $this->assertViolationEquals(new ConstraintViolation($this->messageTemplate, $this->messageTemplate, [], $this->root, 'data', 'foo', null, null, new Valid())); + } + + public function testAppendPropertyPath() + { + $this->builder + ->atPath('foo') + ->addViolation(); + + $this->assertViolationEquals(new ConstraintViolation($this->messageTemplate, $this->messageTemplate, [], $this->root, 'data.foo', 'foo', null, null, new Valid())); + } + + public function testAppendMultiplePropertyPaths() + { + $this->builder + ->atPath('foo') + ->atPath('bar') + ->addViolation(); + + $this->assertViolationEquals(new ConstraintViolation($this->messageTemplate, $this->messageTemplate, [], $this->root, 'data.foo.bar', 'foo', null, null, new Valid())); + } + + public function testCodeCanBeSet() + { + $this->builder + ->setCode(5) + ->addViolation(); + + $this->assertViolationEquals(new ConstraintViolation($this->messageTemplate, $this->messageTemplate, [], $this->root, 'data', 'foo', null, 5, new Valid())); + } + + public function testCauseCanBeSet() + { + $cause = new \LogicException(); + + $this->builder + ->setCause($cause) + ->addViolation(); + + $this->assertViolationEquals(new ConstraintViolation($this->messageTemplate, $this->messageTemplate, [], $this->root, 'data', 'foo', null, null, new Valid(), $cause)); + } + + private function assertViolationEquals(ConstraintViolation $expectedViolation) + { + $this->assertCount(1, $this->violations); + + $violation = $this->violations->get(0); + + $this->assertSame($expectedViolation->getMessage(), $violation->getMessage()); + $this->assertSame($expectedViolation->getMessageTemplate(), $violation->getMessageTemplate()); + $this->assertSame($expectedViolation->getParameters(), $violation->getParameters()); + $this->assertSame($expectedViolation->getPlural(), $violation->getPlural()); + $this->assertSame($expectedViolation->getRoot(), $violation->getRoot()); + $this->assertSame($expectedViolation->getPropertyPath(), $violation->getPropertyPath()); + $this->assertSame($expectedViolation->getInvalidValue(), $violation->getInvalidValue()); + $this->assertSame($expectedViolation->getCode(), $violation->getCode()); + $this->assertEquals($expectedViolation->getConstraint(), $violation->getConstraint()); + $this->assertSame($expectedViolation->getCause(), $violation->getCause()); + } +} diff --git a/src/Symfony/Component/Yaml/Escaper.php b/src/Symfony/Component/Yaml/Escaper.php index afff1683e0..b975fb34cc 100644 --- a/src/Symfony/Component/Yaml/Escaper.php +++ b/src/Symfony/Component/Yaml/Escaper.php @@ -22,7 +22,7 @@ namespace Symfony\Component\Yaml; class Escaper { // Characters that would cause a dumped string to require double quoting. - const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"; + const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\x7f|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"; // Mapping arrays for escaping a double quoted string. The backslash is // first to ensure proper escaping because str_replace operates iteratively @@ -33,6 +33,7 @@ class Escaper "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", + "\x7f", "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", ]; private static $escaped = ['\\\\', '\\"', '\\\\', '\\"', @@ -40,6 +41,7 @@ class Escaper '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', + '\\x7f', '\\N', '\\_', '\\L', '\\P', ]; diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 7d25367cc8..cc2b1e26fe 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -223,6 +223,7 @@ EOF; 'double-quote' => ['"', "'\"'"], 'slash' => ['/', '/'], 'backslash' => ['\\', '\\'], + 'del' => ["\x7f", '"\x7f"'], 'next-line' => ["\xC2\x85", '"\\N"'], 'non-breaking-space' => ["\xc2\xa0", '"\\_"'], 'line-separator' => ["\xE2\x80\xA8", '"\\L"'],