From 69fcd075eb641b5a24b2ecfed9632f578006df57 Mon Sep 17 00:00:00 2001 From: Alexandre Parent Date: Thu, 21 Jan 2021 09:05:34 -0500 Subject: [PATCH 01/25] Fix console logger according to PSR-3 --- src/Symfony/Component/Console/EventListener/ErrorListener.php | 4 ++-- .../Console/Tests/EventListener/ErrorListenerTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ErrorListener.php b/src/Symfony/Component/Console/EventListener/ErrorListener.php index a34075793e165..897d9853f2848 100644 --- a/src/Symfony/Component/Console/EventListener/ErrorListener.php +++ b/src/Symfony/Component/Console/EventListener/ErrorListener.php @@ -40,12 +40,12 @@ public function onConsoleError(ConsoleErrorEvent $event) $error = $event->getError(); if (!$inputString = $this->getInputString($event)) { - $this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]); + $this->logger->critical('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]); return; } - $this->logger->error('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]); + $this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]); } public function onConsoleTerminate(ConsoleTerminateEvent $event) diff --git a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php index 68b4b3a3e1654..0b9fb4d367f2b 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php @@ -33,7 +33,7 @@ public function testOnConsoleError() $logger = $this->getLogger(); $logger ->expects($this->once()) - ->method('error') + ->method('critical') ->with('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => 'test:run --foo=baz buzz', 'message' => 'An error occurred']) ; @@ -48,7 +48,7 @@ public function testOnConsoleErrorWithNoCommandAndNoInputString() $logger = $this->getLogger(); $logger ->expects($this->once()) - ->method('error') + ->method('critical') ->with('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => 'An error occurred']) ; From d02f3635c68f841774dac910582fbd1846dfbbfe Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 14:50:17 +0100 Subject: [PATCH 02/25] Update CHANGELOG for 4.4.19 --- CHANGELOG-4.4.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/CHANGELOG-4.4.md b/CHANGELOG-4.4.md index adfe83b05f62e..78e12222ef3b8 100644 --- a/CHANGELOG-4.4.md +++ b/CHANGELOG-4.4.md @@ -7,6 +7,52 @@ in 4.4 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/v4.4.0...v4.4.1 +* 4.4.19 (2021-01-27) + + * bug #38900 [Serializer] Exclude non-initialized properties accessed with getters (BoShurik) + * bug #39887 [Translator] fix handling plural for floating numbers (kylekatarnls) + * bug #39967 [Messenger] fix redis messenger options with dsn (Kleinast) + * bug #39970 [Messenger] Fix transporting non-UTF8 payloads by encoding them using base 64 (nicolas-grekas) + * bug #39909 [PhpUnitBridge] Allow relative path to composer cache (jderusse) + * bug #39944 [HttpKernel] Configure the ErrorHandler even when it is overriden (nicolas-grekas) + * bug #39932 [Console] [Command] Fix Closure code binding when it is a static anonymous function (fancyweb) + * bug #39880 [DoctrineBridge] Add username to UserNameNotFoundException (qurben) + * bug #39633 [HttpFoundation] Drop int return type from parseFilesize() (LukeTowers) + * bug #39889 [HttpClient] Add check for constant in Curl client (pierredup) + * bug #39886 [HttpFoundation] Revert #38614 and add assert to avoid regressions (BafS) + * bug #39858 Fix problem when SYMFONY_PHPUNIT_VERSION is empty string value (alexander-schranz) + * bug #39861 [DependencyInjection] Skip deprecated definitions in CheckTypeDeclarationsPass (chalasr) + * bug #39862 [Security] Replace message data in JSON security error response (wouterj) + * bug #39667 [DoctrineBridge] Take into account that indexBy="person_id" could be a db column name, for a referenced entity (victormacko) + * bug #39799 [DoctrineBridge] Fix circular loop with EntityManager (jderusse) + * bug #39821 [DependencyInjection] Don't trigger notice for deprecated aliases pointing to deprecated definitions (chalasr) + * bug #39816 [HttpFoundation] use atomic writes in MockFileSessionStorage (nicolas-grekas) + * bug #39735 [Serializer] Rename normalize param (VincentLanglet) + * bug #39797 Dont allow unserializing classes with a destructor (jderusse) + * bug #39743 [Mailer] Fix missing BCC recipients in SES bridge (jderusse) + * bug #39764 [Config]  fix handling float-like key attribute values (xabbuh) + * bug #39787 [Yaml] a colon followed by spaces exclusively separates mapping keys and values (xabbuh) + * bug #39788 [Cache] fix possible collision when writing tmp file in filesystem adapter (nicolas-grekas) + * bug #39794 Dont allow unserializing classes with a destructor - 4.4 (jderusse) + * bug #39747 [DependencyInjection] Support PHP 8 builtin types in CheckTypeDeclarationsPass (derrabus) + * bug #39738 [VarDumper] fix mutating $GLOBALS while cloning it (nicolas-grekas) + * bug #39746 [DependencyInjection] Fix InvalidParameterTypeException for function parameters (derrabus) + * bug #39681 [HttpFoundation] parse cookie values containing the equal sign (xabbuh) + * bug #39716 [DependencyInjection] do not break when loading schemas from network paths on Windows (xabbuh) + * bug #39703 [Finder] apply the sort callback on the whole search result (xabbuh) + * bug #39717 [TwigBridge] Remove full head content in HTML to text converter (pupaxxo) + * bug #39708 [WebProfilerBundle] take query and request parameters into account when matching routes (xabbuh) + * bug #39683 [Yaml] keep trailing newlines when dumping multi-line strings (xabbuh) + * bug #39670 [Form] disable error bubbling by default when inherit_data is configured (xabbuh) + * bug #39686 [Lock] Fix config merging in lock (jderusse) + * bug #39668 [Yaml] do not dump extra trailing newlines for multiline blocks (xabbuh) + * bug #39653 [Form] fix passing null $pattern to IntlDateFormatter (nicolas-grekas) + * bug #39598 [Messenger] Fix stopwach usage if it has been reset (lyrixx) + * bug #39631 [VarDumper] Fix display of nullable union return types (derrabus) + * bug #39629 [VarDumper] fixed displaying "mixed" as "?mixed" (nicolas-grekas) + * bug #39597 [Mailer] Handle failure when sending DATA (jderusse) + * bug #39610 [ProxyManagerBridge] fix PHP notice, switch to "friendsofphp/proxy-manager-lts" (nicolas-grekas) + * 4.4.18 (2020-12-18) * bug #39531 [Mailer] Fix parsing Dsn with empty user/password (OskarStark) From f8c9307f485fecb2036747c02be072c3d7b18840 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 14:50:29 +0100 Subject: [PATCH 03/25] Update CONTRIBUTORS for 4.4.19 --- CONTRIBUTORS.md | 80 +++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9f2ebcc65e3ed..5b8efba4073b3 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 - Johannes S (johannes) - Kris Wallsmith (kriswallsmith) - Wouter de Jong (wouterj) - - Yonel Ceruto (yonelceruto) + - Jérémy DERUSSÉ (jderusse) - Thomas Calvet (fancyweb) + - Yonel Ceruto (yonelceruto) - Hugo Hamon (hhamon) - - Jérémy DERUSSÉ (jderusse) - Abdellatif Ait boudad (aitboudad) - Samuel ROZE (sroze) - Romain Neutron (romain) @@ -43,15 +43,16 @@ Symfony is the result of the work of many people who made the code better - Jean-François Simon (jfsimon) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) + - Oskar Stark (oskarstark) - Eriksen Costa (eriksencosta) - Guilhem Niot (energetick) - Sarah Khalil (saro0h) - Jan Schädlich (jschaedl) - Jonathan Wage (jwage) - Lynn van der Berg (kjarli) + - Pierre du Plessis (pierredup) - Matthias Pigulla (mpdude) - Diego Saint Esteben (dosten) - - Pierre du Plessis (pierredup) - Valentin Udaltsov (vudaltsov) - Alexandre Salomé (alexandresalome) - William Durand (couac) @@ -77,11 +78,10 @@ Symfony is the result of the work of many people who made the code better - Mathieu Piot (mpiot) - Vladimir Reznichenko (kalessil) - Bilal Amarni (bamarni) - - Oskar Stark (oskarstark) - Florin Patan (florinpatan) - Jáchym Toušek (enumag) - - Andrej Hudec (pulzarraider) - Michel Weimerskirch (mweimerskirch) + - Andrej Hudec (pulzarraider) - Issei Murasawa (issei_m) - Christian Raue - Eric Clemmons (ericclemmons) @@ -115,12 +115,12 @@ Symfony is the result of the work of many people who made the code better - Michal Piotrowski (eventhorizon) - Jérôme Vasseur (jvasseur) - Tim Nagel (merk) + - Alexander Schranz (alexander-schranz) - Chris Wilkinson (thewilkybarkid) + - Peter Kokot (maastermedia) - Brice BERNARD (brikou) - - Alexander Schranz (alexander-schranz) - marc.weistroff - Tomáš Votruba (tomas_votruba) - - Peter Kokot (maastermedia) - Lars Strojny (lstrojny) - lenar - Alexander Schwenn (xelaris) @@ -172,14 +172,15 @@ Symfony is the result of the work of many people who made the code better - Jérémie Augustin (jaugustin) - François-Xavier de Guillebon (de-gui_f) - Oleg Voronkovich + - Tomas Norkūnas (norkunas) - Philipp Wahala (hifi) - Rafael Dohms (rdohms) - jwdeitch - Ahmed TAILOULOUTE (ahmedtai) + - Mathias Arlaud (mtarld) - Mikael Pajunen - Gary PEGEOT (gary-p) - Arman Hosseini (arman) - - Tomas Norkūnas (norkunas) - Niels Keurentjes (curry684) - Vyacheslav Pavlov - George Mponos (gmponos) @@ -191,17 +192,20 @@ Symfony is the result of the work of many people who made the code better - Ben Davies (bendavies) - Andreas Schempp (aschempp) - Clemens Tolboom + - HypeMC (hypemc) - Helmer Aaviksoo - Hiromi Hishida (77web) - Matthieu Ouellette-Vachon (maoueh) - Michał Pipa (michal.pipa) - Dawid Nowak + - Maxime Helias (maxhelias) - Amal Raghav (kertz) - Jonathan Ingram (jonathaningram) - Artur Kotyrba - Tyson Andre - GDIBass - Samuel NELA (snela) + - Olivier Dolbeau (odolbeau) - Fabien Bourigault (fbourigault) - Saif (╯°□°)╯ (azjezz) - James Halsall (jaitsu) @@ -212,7 +216,6 @@ Symfony is the result of the work of many people who made the code better - Marek Štípek (maryo) - Filippo Tessarotto (slamdunk) - Daniel Espendiller - - Maxime Helias (maxhelias) - Possum - Dorian Villet (gnutix) - Michaël Perrin (michael.perrin) @@ -223,16 +226,16 @@ Symfony is the result of the work of many people who made the code better - Mario A. Alvarez Garcia (nomack84) - Dennis Benkert (denderello) - DQNEO + - David Prévot - Andre Rømcke (andrerom) - Smaine Milianni (ismail1432) - - Mathias Arlaud (mtarld) - mcfedr (mcfedr) + - Christian Scheb - Ruben Gonzalez (rubenrua) - Benjamin Dulau (dbenjamin) - Jan Rosier (rosier) - Mathieu Lemoine (lemoinem) - Rémon van de Kamp (rpkamp) - - HypeMC - Christian Schmidt - Andreas Hucks (meandmymonkey) - Tom Van Looy (tvlooy) @@ -244,6 +247,7 @@ Symfony is the result of the work of many people who made the code better - bronze1man - sun (sun) - Larry Garfield (crell) + - Michael Käfer (michael_kaefer) - Leo Feyer (leofeyer) - Nikolay Labinskiy (e-moe) - Martin Schuhfuß (usefulthink) @@ -251,12 +255,10 @@ Symfony is the result of the work of many people who made the code better - Matthieu Bontemps (mbontemps) - apetitpa - Pierre Minnieur (pminnieur) - - David Prévot - fivestar - Dominique Bongiraud - Hidde Wieringa (hiddewie) - Jeremy Livingston (jeremylivingston) - - Olivier Dolbeau (odolbeau) - Michael Lee (zerustech) - Dmitrii Poddubnyi (karser) - Matthieu Auger (matthieuauger) @@ -283,7 +285,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) - - Michael Käfer (michael_kaefer) - Chi-teck - Pavel Batanov (scaytrase) - Mantis Development @@ -315,6 +316,7 @@ Symfony is the result of the work of many people who made the code better - Alessandro Lai (jean85) - Adam Prager (padam87) - Benoît Burnichon (bburnichon) + - YaFou - Maciej Malarz (malarzm) - Roman Marintšenko (inori) - Xavier Montaña Carreras (xmontana) @@ -336,6 +338,7 @@ Symfony is the result of the work of many people who made the code better - Jakub Kucharovic (jkucharovic) - Loick Piera (pyrech) - Gocha Ossinkine (ossinkine) + - Jeroen Noten (jeroennoten) - Uwe Jäger (uwej711) - Martin Hujer (martinhujer) - Eugene Leonovich (rybakit) @@ -362,7 +365,6 @@ Symfony is the result of the work of many people who made the code better - Alex Rock (pierstoval) - Beau Simensen (simensen) - Michael Hirschler (mvhirsch) - - Christian Scheb - Robert Kiss (kepten) - Zan Baldwin (zanderbaldwin) - Roumen Damianoff (roumen) @@ -372,6 +374,7 @@ Symfony is the result of the work of many people who made the code better - Langlet Vincent (deviling) - Pascal Luna (skalpa) - Wouter Van Hecke + - Iker Ibarguren (ikerib) - Peter Kruithof (pkruithof) - Michael Holm (hollo) - Arjen van der Meijden @@ -379,6 +382,7 @@ Symfony is the result of the work of many people who made the code better - Damien Alexandre (damienalexandre) - Simon Mönch (sm) - Christian Schmidt + - Ben Hakim - Patrick Landolt (scube) - MatTheCat - Denis Brumann (dbrumann) @@ -413,6 +417,7 @@ Symfony is the result of the work of many people who made the code better - Gustavo Piltcher - Jesse Rushlow (geeshoe) - Stepan Tanasiychuk (stfalcon) + - Ivan Kurnosov - Tiago Ribeiro (fixe) - Hidde Boomsma (hboomsma) - John Bafford (jbafford) @@ -434,10 +439,12 @@ Symfony is the result of the work of many people who made the code better - Mark Challoner (markchalloner) - ivan - Karoly Gossler (connorhu) + - Simon Berger - Ahmed Raafat - Philippe Segatori - Gennady Telegin (gtelegin) - Thibaut Cheymol (tcheymol) + - Baptiste Leduc (korbeil) - Erin Millard - Artur Melo (restless) - Matthew Lewinski (lewinski) @@ -448,7 +455,6 @@ Symfony is the result of the work of many people who made the code better - alquerci - Oleg Andreyev - Mateusz Sip (mateusz_sip) - - YaFou - Francesco Levorato - Vitaliy Zakharov (zakharovvi) - Tobias Sjösten (tobiassjosten) @@ -463,7 +469,6 @@ Symfony is the result of the work of many people who made the code better - Thomas Perez (scullwm) - Felix Labrecque - Yaroslav Kiliba - - Ben Hakim - Terje Bråten - Gonzalo Vilaseca (gonzalovilaseca) - Marco Petersen (ocrampete16) @@ -479,7 +484,6 @@ Symfony is the result of the work of many people who made the code better - Haralan Dobrev (hkdobrev) - hossein zolfi (ocean) - Clément Gautier (clementgautier) - - Jeroen Noten (jeroennoten) - Dāvis Zālītis (k0d3r1s) - Sanpi - Eduardo Gulias (egulias) @@ -488,7 +492,6 @@ Symfony is the result of the work of many people who made the code better - Stéphane PY (steph_py) - Philipp Kräutli (pkraeutli) - Grzegorz (Greg) Zdanowski (kiler129) - - Iker Ibarguren (ikerib) - Dimitri Gritsajuk (ottaviano) - Kirill chEbba Chebunin (chebba) - @@ -524,7 +527,6 @@ Symfony is the result of the work of many people who made the code better - Alain Hippolyte (aloneh) - Grenier Kévin (mcsky_biig) - Karoly Negyesi (chx) - - Ivan Kurnosov - Xavier HAUSHERR - Albert Jessurum (ajessu) - Laszlo Korte @@ -563,13 +565,14 @@ Symfony is the result of the work of many people who made the code better - Markus Bachmann (baachi) - Kévin THERAGE (kevin_therage) - Erkhembayar Gantulga (erheme318) + - Greg Anderson - Islam93 - lancergr + - Vincent Langlet - Tri Pham (phamuyentri) - Mihai Stancu - Ivan Nikolaev (destillat) - Gildas Quéméner (gquemener) - - Baptiste Leduc (korbeil) - Laurent Masforné (heisenberg) - Claude Khedhiri (ck-developer) - Desjardins Jérôme (jewome62) @@ -721,6 +724,7 @@ Symfony is the result of the work of many people who made the code better - Steven Surowiec - Kevin Saliou (kbsali) - Shawn Iwinski + - Samuele Lilli (doncallisto) - Gawain Lynch (gawain) - mmokhi - NothingWeAre @@ -766,9 +770,11 @@ Symfony is the result of the work of many people who made the code better - Fred Cox - vitaliytv - Philippe Segatori + - Loïc Frémont (loic425) - fd6130 (fdtvui) - Dalibor Karlović (dkarlovi) - Andrey Sevastianov + - Oleksandr Barabolia (oleksandrbarabolia) - Sebastian Blum - Alexis Lefebvre - aubx @@ -776,7 +782,6 @@ Symfony is the result of the work of many people who made the code better - Marvin Butkereit - Renan - Ricky Su (ricky) - - Vincent Langlet - Kyle Evans (kevans91) - Charles-Henri Bruyand - Max Rath (drak3) @@ -907,7 +912,6 @@ Symfony is the result of the work of many people who made the code better - Richard van den Brand (ricbra) - develop - flip111 - - Greg Anderson - VJ - RJ Garcia - Delf Tonder (leberknecht) @@ -1021,6 +1025,7 @@ Symfony is the result of the work of many people who made the code better - Ben - Vincent Composieux (eko) - Jayson Xu (superjavason) + - Gijs van Lammeren - Hubert Lenoir (hubert_lenoir) - fago - Jan Prieser @@ -1081,6 +1086,7 @@ Symfony is the result of the work of many people who made the code better - Peter Bowyer (pbowyer) - Aleksey Podskrebyshev - Calin Mihai Pristavu + - Vincent Langlet - David Marín Carreño (davefx) - Fabien LUCAS (flucas2) - Konstantin Grachev (grachevko) @@ -1156,7 +1162,6 @@ Symfony is the result of the work of many people who made the code better - Dmitriy Derepko - Stéphane Delprat - Brian Freytag (brianfreytag) - - Samuele Lilli (doncallisto) - Brunet Laurent (lbrunet) - Florent Viel (luxifer) - Mikhail Yurasov (mym) @@ -1185,12 +1190,12 @@ Symfony is the result of the work of many people who made the code better - d-ph - Stewart Malik - Renan Taranto (renan-taranto) + - Gemorroj (gemorroj) - Rikijs Murgs - Mihail Krasilnikov (krasilnikovm) - Uladzimir Tsykun - iamvar - Amaury Leroux de Lens (amo__) - - Loïc Frémont (loic425) - Christian Jul Jensen - Alexandre GESLIN (alexandregeslin) - The Whole Life to Learn @@ -1199,11 +1204,16 @@ Symfony is the result of the work of many people who made the code better - Mikkel Paulson - ergiegonzaga - Daniel González + - Piergiuseppe Longo + - Kevin Auivinet - Liverbool (liverbool) + - Aurélien MARTIN - Malte Schlüter - Jules Matsounga (hyoa) + - Quentin Dequippe (qdequippe) - khoptynskyi - Sam Malone + - Christin Gruber (christingruber) - Phan Thanh Ha (haphan) - Chris Jones (leek) - neghmurken @@ -1371,7 +1381,6 @@ Symfony is the result of the work of many people who made the code better - benatespina (benatespina) - Denis Kop - Jean-Guilhem Rouel (jean-gui) - - HypeMC - jfcixmedia - Dominic Tubach - Nikita Konstantinov @@ -1409,6 +1418,7 @@ Symfony is the result of the work of many people who made the code better - Alex Demchenko (pilot) - Tadas Gliaubicas (tadcka) - Thanos Polymeneas (thanos) + - Jon Green - Atthaphon Urairat - Benoit Garret - Maximilian Ruta (deltachaos) @@ -1524,6 +1534,7 @@ Symfony is the result of the work of many people who made the code better - MightyBranch - Kacper Gunia (cakper) - Peter Thompson (petert82) + - Victor Macko (victor_m) - error56 - Felicitus - Krzysztof Przybyszewski @@ -1542,6 +1553,7 @@ Symfony is the result of the work of many people who made the code better - Islam Israfilov (islam93) - Arthur Woimbée - tsufeki + - Théo DELCEY - dangkhoagms - Philipp Strube - Andrii Serdiuk (andreyserdjuk) @@ -1597,6 +1609,7 @@ Symfony is the result of the work of many people who made the code better - Malaney J. Hill - Alexandre Pavy - Adiel Cristo (arcristo) + - Artem Stepin (astepin) - Christian Flach (cmfcmf) - Cédric Girard (enk_) - Lars Ambrosius Wallenborn (larsborn) @@ -1604,12 +1617,14 @@ Symfony is the result of the work of many people who made the code better - Sebastian Göttschkes (sgoettschkes) - Tatsuya Tsuruoka - Ross Tuck + - Gerben Oolbekkink - Kévin Gomez (kevin) - Mihai Nica (redecs) - Andrei Igna - Adam Prickett - azine - Javier Espinosa + - Luke Towers - Anton Kroshilin - Dawid Sajdak - Norman Soetbeer @@ -1663,6 +1678,7 @@ Symfony is the result of the work of many people who made the code better - Klaas Cuvelier (kcuvelier) - Flavien Knuchel (knuch) - Mathieu TUDISCO (mathieutu) + - Dmytro Dzubenko - markusu49 - Steve Frécinaux - Constantine Shtompel @@ -1674,6 +1690,7 @@ Symfony is the result of the work of many people who made the code better - ShiraNai7 - Cedrick Oka - Antal Áron (antalaron) + - Guillaume Sainthillier (guillaume-sainthillier) - Vašek Purchart (vasek-purchart) - Janusz Jabłoński (yanoosh) - Fleuv @@ -1712,11 +1729,11 @@ Symfony is the result of the work of many people who made the code better - Luis Galeas - Bogdan Scordaliu - Martin Pärtel + - Fabien S (bafs) - Daniel Rotter (danrot) - Frédéric Bouchery (fbouchery) - Patrick Daley (padrig) - Max Summe - - Simon Berger - WedgeSama - Hugo Sales - Felds Liscia @@ -1798,13 +1815,13 @@ Symfony is the result of the work of many people who made the code better - Alex Silcock - Raphael Hardt - Qingshan Luo - - Gijs van Lammeren - Ergie Gonzaga - Matthew J Mucklo - AnrDaemon - SnakePin - Emre Akinci (emre) - fdgdfg (psampaz) + - Andrea Ruggiero (pupax) - Stéphane Seng - Maxwell Vandervelde - kaywalker @@ -2013,6 +2030,7 @@ Symfony is the result of the work of many people who made the code better - Rémi Faivre (rfv) - Thierry Marianne (thierrymarianne) - Nick Stemerdink + - Bernhard Rusch - David Stone - jjanvier - Julius Beckmann @@ -2254,6 +2272,7 @@ Symfony is the result of the work of many people who made the code better - Haritz - Matthieu Prat - Grummfy + - pdragun - Paul Le Corre - Filipe Guerra - Jean Ragouin @@ -2457,6 +2476,7 @@ Symfony is the result of the work of many people who made the code better - wesleyh - sergey - Menno Holtkamp + - Ser5 - Michael Hudson-Doyle - Daniel Bannert - Karim Miladi @@ -2470,7 +2490,9 @@ Symfony is the result of the work of many people who made the code better - Anonymous User - Paweł Tomulik - Eric J. Duran + - Pavol Tuka - Alexandru Bucur + - Alexis Lefebvre - cmfcmf - Michal Forbak - Drew Butler @@ -2573,7 +2595,6 @@ Symfony is the result of the work of many people who made the code better - parhs - Diego Campoy - TeLiXj - - Vincent Langlet - Oncle Tom - Sam Anthony - Christian Stocker @@ -2615,6 +2636,7 @@ Symfony is the result of the work of many people who made the code better - Siragusa (asiragusa) - Daniel Basten (axhm3a) - Dude (b1rdex) + - Gerard Berengue Llobera (bere) - Bernd Matzner (bmatzner) - Bram Tweedegolf (bram_tweedegolf) - Brandon Kelly (brandonkelly) From 7fb2dbf465aa2dbb9960fb32b0c4c48e09ca8f51 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 14:50:53 +0100 Subject: [PATCH 04/25] Update VERSION for 4.4.19 --- 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 c9317c81cae0e..19fead0808382 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.19-DEV'; + public const VERSION = '4.4.19'; public const VERSION_ID = 40419; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 19; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From aeb15a1322ac60ecdff88b327dd7d1435c7a8010 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 14:59:11 +0100 Subject: [PATCH 05/25] Bump Symfony version to 4.4.20 --- 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 19fead0808382..f2b1966ea5aa7 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.19'; - public const VERSION_ID = 40419; + public const VERSION = '4.4.20-DEV'; + public const VERSION_ID = 40420; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 19; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 20; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 712e03352ebe1d711bc31d60c08fe136759ffadd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 15:55:33 +0100 Subject: [PATCH 06/25] Bump Symfony version to 5.2.3 --- 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 409f9519393e4..a83b264db98fe 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -74,12 +74,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '5.2.2'; - public const VERSION_ID = 50202; + public const VERSION = '5.2.3-DEV'; + public const VERSION_ID = 50203; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 3; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2021'; public const END_OF_LIFE = '07/2021'; From b40e71f096d6dc8f265f87cd7a93de27ac02d49c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 27 Jan 2021 14:48:15 +0100 Subject: [PATCH 07/25] Replace "branch-version" by "versions" in composer.json --- .appveyor.yml | 3 ++- .github/build-packages.php | 2 +- .github/workflows/tests.yml | 3 ++- .travis.yml | 8 +++++--- composer.json | 12 +++++++----- src/Symfony/Contracts/Cache/composer.json | 1 - src/Symfony/Contracts/EventDispatcher/composer.json | 1 - src/Symfony/Contracts/HttpClient/composer.json | 1 - src/Symfony/Contracts/Service/composer.json | 1 - src/Symfony/Contracts/Translation/composer.json | 1 - src/Symfony/Contracts/composer.json | 1 - 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a2f36f9d97414..41d9c8d45d701 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -50,9 +50,10 @@ install: - php composer.phar global require --no-progress --no-scripts --no-plugins symfony/flex - git config --global user.email "" - git config --global user.name "Symfony" - - FOR /F "tokens=* USEBACKQ" %%F IN (`bash -c "grep branch-version composer.json | grep -o '[0-9.x]*'"`) DO (SET SYMFONY_VERSION=%%F) + - FOR /F "tokens=* USEBACKQ" %%F IN (`bash -c "grep -m1 SYMFONY_VERSION .travis.yml | grep -o '[0-9.x]*'"`) DO (SET SYMFONY_VERSION=%%F) - php .github/build-packages.php HEAD^ %SYMFONY_VERSION% src\Symfony\Bridge\PhpUnit - SET "SYMFONY_REQUIRE=>=%SYMFONY_VERSION%" + - SET COMPOSER_ROOT_VERSION=%SYMFONY_VERSION%.x-dev - php composer.phar update --no-progress --ansi - php phpunit install diff --git a/.github/build-packages.php b/.github/build-packages.php index c8c802ad595b4..30dcf0c9adce8 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -46,7 +46,7 @@ passthru("cd $dir && git init && git add . && git commit -q -m - && git archive -o package.tar HEAD && rm .git/ -Rf"); } - $package->version = (isset($package->extra->{'branch-version'}) ? $package->extra->{'branch-version'} : $version).'.x-dev'; + $package->version = preg_replace('/(?:\.x)?-dev$/', '', $package->extra->{'branch-alias'}->{'dev-main'} ?? $version).'.x-dev'; $package->dist['type'] = 'tar'; $package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar"; diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0038195fcf9a8..9ef0b10c04ee9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,8 +80,9 @@ jobs: - name: Configure composer run: | COMPOSER_HOME="$(composer config home)" + composer self-update ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" - echo "COMPOSER_ROOT_VERSION=$(grep branch-version composer.json | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV + echo "COMPOSER_ROOT_VERSION=$(grep -m1 SYMFONY_VERSION .travis.yml | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV - name: Determine composer cache directory id: composer-cache diff --git a/.travis.yml b/.travis.yml index 78e02c8c7af60..fb3910f44b1a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ addons: env: global: + - SYMFONY_VERSION=4.4 - MIN_PHP=7.1.3 - SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/shims/php - SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1 @@ -170,8 +171,8 @@ install: git fetch --depth=2 origin refs/pull/$SYMFONY_PHPUNIT_BRIDGE_PR/head git rm -rq src/Symfony/Bridge/PhpUnit git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit - export SYMFONY_VERSION=$(curl -s https://api.github.com/repos/symfony/symfony/pulls/$SYMFONY_PHPUNIT_BRIDGE_PR | jq -r .base.ref) - sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json + SYMFONY_PHPUNIT_BRIDGE_REF=$(curl -s https://api.github.com/repos/symfony/symfony/pulls/$SYMFONY_PHPUNIT_BRIDGE_PR | jq -r .base.ref) + sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_PHPUNIT_BRIDGE_REF'.x@dev"/' composer.json rm -rf .phpunit fi @@ -180,7 +181,6 @@ install: git config --global user.email "" git config --global user.name "Symfony" - export SYMFONY_VERSION=$(grep branch-version composer.json | grep -o '[0-9.x]*') SYMFONY_VERSIONS=$(git ls-remote -q --heads); if [[ ! $deps ]]; then @@ -227,6 +227,7 @@ install: # Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one [[ $deps = high && ${SYMFONY_VERSION%.*} != $(echo "$SYMFONY_VERSIONS" | cut -f2 | grep -FA1 /$SYMFONY_VERSION | tail -n 1 | grep -o '[0-9]*' | head -n 1) ]] && export LEGACY=,legacy + export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi - | @@ -265,6 +266,7 @@ install: export FLIP='^' SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}') echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m" + export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev export SYMFONY_REQUIRE=">=$SYMFONY_VERSION" git fetch --depth=2 origin $SYMFONY_VERSION git checkout -m FETCH_HEAD diff --git a/composer.json b/composer.json index c228650326b27..e12e14c163dea 100644 --- a/composer.json +++ b/composer.json @@ -156,11 +156,13 @@ "repositories": [ { "type": "path", - "url": "src/Symfony/Contracts" + "url": "src/Symfony/Contracts", + "options": { + "versions": { + "symfony/contracts": "1.1.x-dev" + } + } } ], - "minimum-stability": "dev", - "extra": { - "branch-version": "4.4" - } + "minimum-stability": "dev" } diff --git a/src/Symfony/Contracts/Cache/composer.json b/src/Symfony/Contracts/Cache/composer.json index ce40614881bad..dc2b77146c525 100644 --- a/src/Symfony/Contracts/Cache/composer.json +++ b/src/Symfony/Contracts/Cache/composer.json @@ -33,7 +33,6 @@ } }, "extra": { - "branch-version": "1.1", "branch-alias": { "dev-main": "1.1-dev" } diff --git a/src/Symfony/Contracts/EventDispatcher/composer.json b/src/Symfony/Contracts/EventDispatcher/composer.json index 35258e78b76b9..0d14e98fea41a 100644 --- a/src/Symfony/Contracts/EventDispatcher/composer.json +++ b/src/Symfony/Contracts/EventDispatcher/composer.json @@ -33,7 +33,6 @@ } }, "extra": { - "branch-version": "1.1", "branch-alias": { "dev-main": "1.1-dev" } diff --git a/src/Symfony/Contracts/HttpClient/composer.json b/src/Symfony/Contracts/HttpClient/composer.json index f4bcfb2a36116..b56709738b83e 100644 --- a/src/Symfony/Contracts/HttpClient/composer.json +++ b/src/Symfony/Contracts/HttpClient/composer.json @@ -32,7 +32,6 @@ } }, "extra": { - "branch-version": "1.1", "branch-alias": { "dev-main": "1.1-dev" } diff --git a/src/Symfony/Contracts/Service/composer.json b/src/Symfony/Contracts/Service/composer.json index 4f24e1e03d66b..8134ba6b88fba 100644 --- a/src/Symfony/Contracts/Service/composer.json +++ b/src/Symfony/Contracts/Service/composer.json @@ -33,7 +33,6 @@ } }, "extra": { - "branch-version": "1.1", "branch-alias": { "dev-main": "1.1-dev" } diff --git a/src/Symfony/Contracts/Translation/composer.json b/src/Symfony/Contracts/Translation/composer.json index 2b4ddbb38606d..8fd0d88df7ed8 100644 --- a/src/Symfony/Contracts/Translation/composer.json +++ b/src/Symfony/Contracts/Translation/composer.json @@ -32,7 +32,6 @@ } }, "extra": { - "branch-version": "1.1", "branch-alias": { "dev-main": "1.1-dev" } diff --git a/src/Symfony/Contracts/composer.json b/src/Symfony/Contracts/composer.json index ec475e2670d86..62b123dc6bed4 100644 --- a/src/Symfony/Contracts/composer.json +++ b/src/Symfony/Contracts/composer.json @@ -46,7 +46,6 @@ }, "minimum-stability": "dev", "extra": { - "branch-version": "1.1", "branch-alias": { "dev-main": "1.1-dev" } From 8449d8a328f98217c754c7630fd4eb9dba7b307e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 27 Jan 2021 17:33:13 +0100 Subject: [PATCH 08/25] fix merge --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 662fe1f2feaf1..e92efba50fae6 100644 --- a/composer.json +++ b/composer.json @@ -173,7 +173,7 @@ "url": "src/Symfony/Contracts", "options": { "versions": { - "symfony/contracts": "1.1.x-dev" + "symfony/contracts": "2.3.x-dev" } } } From f0409b403f2ea0a8290b417b2ae35dd0a330cec3 Mon Sep 17 00:00:00 2001 From: Julien Falque Date: Wed, 27 Jan 2021 17:40:30 +0100 Subject: [PATCH 09/25] [Serializer] Prevent access to private properties without getters --- .../Normalizer/ObjectNormalizer.php | 10 ++++---- .../DummyPrivatePropertyWithoutGetter.php | 23 +++++++++++++++++++ .../Tests/Normalizer/ObjectNormalizerTest.php | 10 ++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/DummyPrivatePropertyWithoutGetter.php diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index 0e1a378fe6f91..a3bd07440b581 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -107,8 +107,9 @@ protected function extractAttributes($object, $format = null, array $context = [ // properties foreach ($reflClass->getProperties() as $reflProperty) { + $isPublic = $reflProperty->isPublic(); + if ($checkPropertyInitialization) { - $isPublic = $reflProperty->isPublic(); if (!$isPublic) { $reflProperty->setAccessible(true); } @@ -116,9 +117,10 @@ protected function extractAttributes($object, $format = null, array $context = [ unset($attributes[$reflProperty->name]); continue; } - if (!$isPublic) { - continue; - } + } + + if (!$isPublic) { + continue; } if ($reflProperty->isStatic() || !$this->isAllowedAttribute($object, $reflProperty->name, $format, $context)) { diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/DummyPrivatePropertyWithoutGetter.php b/src/Symfony/Component/Serializer/Tests/Fixtures/DummyPrivatePropertyWithoutGetter.php new file mode 100644 index 0000000000000..d20832131b29a --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/DummyPrivatePropertyWithoutGetter.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Serializer\Tests\Fixtures; + +final class DummyPrivatePropertyWithoutGetter +{ + private $foo = 'foo'; + private $bar = 'bar'; + + public function getBar() + { + return $this->bar; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 5c8c54d66cdcc..4d145a5c8b52b 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -33,6 +33,7 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy; +use Symfony\Component\Serializer\Tests\Fixtures\DummyPrivatePropertyWithoutGetter; use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; use Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy; use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy; @@ -143,6 +144,15 @@ public function testNormalizeObjectWithUninitializedPrivateProperties() ); } + public function testNormalizeObjectWithPrivatePropertyWithoutGetter() + { + $obj = new DummyPrivatePropertyWithoutGetter(); + $this->assertEquals( + ['bar' => 'bar'], + $this->normalizer->normalize($obj, 'any') + ); + } + public function testDenormalize() { $obj = $this->normalizer->denormalize( From 9680a27246e0ee1b3d0ee1133201d68acb847d7b Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 27 Jan 2021 17:14:37 +0100 Subject: [PATCH 10/25] [Uid] Fix time to float conversion --- src/Symfony/Component/Uid/BinaryUtil.php | 2 +- src/Symfony/Component/Uid/Tests/UuidTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Uid/BinaryUtil.php b/src/Symfony/Component/Uid/BinaryUtil.php index 32e7e0dff3c6c..bbba6b9c18363 100644 --- a/src/Symfony/Component/Uid/BinaryUtil.php +++ b/src/Symfony/Component/Uid/BinaryUtil.php @@ -124,7 +124,7 @@ public static function timeToFloat(string $time): float $time = self::add($time, self::TIME_OFFSET_COM2); if ($time >= self::TIME_OFFSET_COM2) { - $time = -1 * self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10); + $time = -1 * (self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10) + 1); } else { $time[0] = $time[0] & "\x7F"; $time = self::toBase($time, self::BASE10); diff --git a/src/Symfony/Component/Uid/Tests/UuidTest.php b/src/Symfony/Component/Uid/Tests/UuidTest.php index 5369477d3ca3e..6b5b27f3b5001 100644 --- a/src/Symfony/Component/Uid/Tests/UuidTest.php +++ b/src/Symfony/Component/Uid/Tests/UuidTest.php @@ -199,4 +199,13 @@ public function testFromStringOnExtendedClassReturnsStatic() { $this->assertInstanceOf(CustomUuid::class, CustomUuid::fromString(self::A_UUID_V4)); } + + public function testGetTime() + { + $this->assertSame(103072857660.6847, ((new UuidV1('ffffffff-ffff-1fff-a456-426655440000'))->getTime())); + $this->assertSame(0.0000001, ((new UuidV1('13814001-1dd2-11b2-a456-426655440000'))->getTime())); + $this->assertSame(0.0, (new UuidV1('13814000-1dd2-11b2-a456-426655440000'))->getTime()); + $this->assertSame(-0.0000001, (new UuidV1('13813fff-1dd2-11b2-a456-426655440000'))->getTime()); + $this->assertSame(-12219292800.0, ((new UuidV1('00000000-0000-1000-a456-426655440000'))->getTime())); + } } From 2176ff65507e5b55d51957c2fd22f0ddb8cbf1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 27 Jan 2021 18:47:53 +0100 Subject: [PATCH 11/25] Fix SES test --- .../Transport/SesApiAsyncAwsTransportTest.php | 17 +++++++++-------- .../Transport/SesHttpAsyncAwsTransportTest.php | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php index 2984ba31d11da..52a7c29f41cb7 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php @@ -100,15 +100,16 @@ public function testSend() public function testSendThrowsForErrorResponse() { $client = new MockHttpClient(function (string $method, string $url, array $options): ResponseInterface { - $xml = " - - i'm a teapot - 418 - - "; - - return new MockResponse($xml, [ + $json = json_encode([ + 'message' => 'i\'m a teapot', + 'type' => 'sender', + ]); + + return new MockResponse($json, [ 'http_code' => 418, + 'response_headers' => [ + 'x-amzn-errortype' => '418', + ], ]); }); diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php index 5b79491fbcb0d..6bdd9b779d58d 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php @@ -95,15 +95,16 @@ public function testSend() public function testSendThrowsForErrorResponse() { $client = new MockHttpClient(function (string $method, string $url, array $options): ResponseInterface { - $xml = " - - i'm a teapot - 418 - - "; - - return new MockResponse($xml, [ + $json = json_encode([ + 'message' => 'i\'m a teapot', + 'type' => 'sender', + ]); + + return new MockResponse($json, [ 'http_code' => 418, + 'response_headers' => [ + 'x-amzn-errortype' => '418', + ], ]); }); From 85558248e66bfb8670efe1c2837dc9f8dd77bfc2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 27 Jan 2021 21:47:53 +0100 Subject: [PATCH 12/25] [Uid] improve logic in BinaryUtil::timeToFloat() --- src/Symfony/Component/Uid/BinaryUtil.php | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Uid/BinaryUtil.php b/src/Symfony/Component/Uid/BinaryUtil.php index bbba6b9c18363..5e9741cbea200 100644 --- a/src/Symfony/Component/Uid/BinaryUtil.php +++ b/src/Symfony/Component/Uid/BinaryUtil.php @@ -40,6 +40,8 @@ class BinaryUtil // 0x01b21dd213814000 is the number of 100-ns intervals between the // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. private const TIME_OFFSET_INT = 0x01b21dd213814000; + private const TIME_OFFSET_BIN = "\x01\xb2\x1d\xd2\x13\x81\x40\x00"; + private const TIME_OFFSET_COM1 = "\xfe\x4d\xe2\x2d\xec\x7e\xbf\xff"; private const TIME_OFFSET_COM2 = "\xfe\x4d\xe2\x2d\xec\x7e\xc0\x00"; public static function toBase(string $bytes, array $map): string @@ -114,20 +116,24 @@ public static function add(string $a, string $b): string return $a; } + /** + * @param string $time Count of 100-nanosecond intervals since the UUID epoch 1582-10-15 00:00:00 in hexadecimal + */ public static function timeToFloat(string $time): float { if (\PHP_INT_SIZE >= 8) { - return (hexdec($time) - self::TIME_OFFSET_INT) / 10000000; - } - - $time = str_pad(hex2bin($time), 8, "\0", \STR_PAD_LEFT); - $time = self::add($time, self::TIME_OFFSET_COM2); - - if ($time >= self::TIME_OFFSET_COM2) { - $time = -1 * (self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10) + 1); + $time = hexdec($time) - self::TIME_OFFSET_INT; } else { - $time[0] = $time[0] & "\x7F"; - $time = self::toBase($time, self::BASE10); + $time = str_pad(hex2bin($time), 8, "\0", \STR_PAD_LEFT); + + if (self::TIME_OFFSET_BIN <= $time) { + $time = self::add($time, self::TIME_OFFSET_COM2); + $time[0] = $time[0] & "\x7F"; + $time = self::toBase($time, self::BASE10); + } else { + $time = self::add($time, self::TIME_OFFSET_COM1); + $time = '-'.self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10); + } } return $time / 10000000; From adb0fd1c7dcfc5c6332223f677173da5a7d5fad4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 27 Jan 2021 21:50:32 +0100 Subject: [PATCH 13/25] take into account all label related options --- .../Bridge/Twig/Extension/FormExtension.php | 12 +++++++++++- .../Extension/FormExtensionFieldHelpersTest.php | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index c8229f1049683..7f0b1ed597e36 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -113,8 +113,18 @@ public function getFieldValue(FormView $view) public function getFieldLabel(FormView $view): ?string { + if (false === $label = $view->vars['label']) { + return null; + } + + if (!$label && $labelFormat = $view->vars['label_format']) { + $label = str_replace(['%id%', '%name%'], [$view->vars['id'], $view->vars['name']], $labelFormat); + } elseif (!$label) { + $label = ucfirst(strtolower(trim(preg_replace(['/([A-Z])/', '/[_\s]+/'], ['_$1', ' '], $view->vars['name'])))); + } + return $this->createFieldTranslation( - $view->vars['label'], + $label, $view->vars['label_translation_parameters'] ?: [], $view->vars['translation_domain'] ); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php index b5f936e1c761a..ce3ee926e11b8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php @@ -81,6 +81,7 @@ protected function setUp(): void ], ], 'choice_translation_domain' => 'forms', + 'label_format' => 'label format for field "%name%" with id "%id%"', ]) ->add('choice_multiple', ChoiceType::class, [ 'choices' => [ @@ -89,6 +90,7 @@ protected function setUp(): void ], 'multiple' => true, 'expanded' => true, + 'label' => false, ]) ->getForm() ; @@ -121,6 +123,21 @@ public function testFieldTranslatedLabel() $this->assertSame('[trans]base.username[/trans]', $this->translatorExtension->getFieldLabel($this->view->children['username'])); } + public function testFieldLabelFromFormat() + { + $this->assertSame('label format for field "choice_grouped" with id "register_choice_grouped"', $this->rawExtension->getFieldLabel($this->view->children['choice_grouped'])); + } + + public function testFieldLabelFallsBackToName() + { + $this->assertSame('Choice flat', $this->rawExtension->getFieldLabel($this->view->children['choice_flat'])); + } + + public function testFieldLabelReturnsNullWhenLabelIsDisabled() + { + $this->assertNull($this->rawExtension->getFieldLabel($this->view->children['choice_multiple'])); + } + public function testFieldHelp() { $this->assertSame('base.username_help', $this->rawExtension->getFieldHelp($this->view->children['username'])); From e3801025902bb101624d9c0447ec034aa5489ce7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 28 Jan 2021 15:21:46 +0100 Subject: [PATCH 14/25] [DoctrineBridge] add missing `@experimental` annotation on Uid generators --- src/Symfony/Bridge/Doctrine/CHANGELOG.md | 2 +- src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php | 3 +++ src/Symfony/Bridge/Doctrine/IdGenerator/UuidV1Generator.php | 3 +++ src/Symfony/Bridge/Doctrine/IdGenerator/UuidV4Generator.php | 3 +++ src/Symfony/Bridge/Doctrine/IdGenerator/UuidV6Generator.php | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/CHANGELOG.md b/src/Symfony/Bridge/Doctrine/CHANGELOG.md index ea6918de35f1c..af0b9366a1b66 100644 --- a/src/Symfony/Bridge/Doctrine/CHANGELOG.md +++ b/src/Symfony/Bridge/Doctrine/CHANGELOG.md @@ -5,7 +5,7 @@ CHANGELOG ----- * added support for symfony/uid as `UlidType` and `UuidType` as Doctrine types - * added `UlidGenerator`, `UUidV1Generator`, `UuidV4Generator` and `UuidV6Generator` + * added `UlidGenerator`, `UuidV1Generator`, `UuidV4Generator` and `UuidV6Generator` 5.0.0 ----- diff --git a/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php b/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php index 8953038860fb8..364bf3b3acb96 100644 --- a/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php +++ b/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php @@ -15,6 +15,9 @@ use Doctrine\ORM\Id\AbstractIdGenerator; use Symfony\Component\Uid\Ulid; +/** + * @experimental in 5.2 + */ final class UlidGenerator extends AbstractIdGenerator { public function generate(EntityManager $em, $entity): Ulid diff --git a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV1Generator.php b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV1Generator.php index 21d2fd6c19314..55f6eb1eb2113 100644 --- a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV1Generator.php +++ b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV1Generator.php @@ -15,6 +15,9 @@ use Doctrine\ORM\Id\AbstractIdGenerator; use Symfony\Component\Uid\UuidV1; +/** + * @experimental in 5.2 + */ final class UuidV1Generator extends AbstractIdGenerator { public function generate(EntityManager $em, $entity): UuidV1 diff --git a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV4Generator.php b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV4Generator.php index 35b94a7cd0196..8731daa641032 100644 --- a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV4Generator.php +++ b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV4Generator.php @@ -15,6 +15,9 @@ use Doctrine\ORM\Id\AbstractIdGenerator; use Symfony\Component\Uid\UuidV4; +/** + * @experimental in 5.2 + */ final class UuidV4Generator extends AbstractIdGenerator { public function generate(EntityManager $em, $entity): UuidV4 diff --git a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV6Generator.php b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV6Generator.php index 3677af1c2de70..cdcd908e93647 100644 --- a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV6Generator.php +++ b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidV6Generator.php @@ -15,6 +15,9 @@ use Doctrine\ORM\Id\AbstractIdGenerator; use Symfony\Component\Uid\UuidV6; +/** + * @experimental in 5.2 + */ final class UuidV6Generator extends AbstractIdGenerator { public function generate(EntityManager $em, $entity): UuidV6 From 036c8d71fdc4e00091278c5b145b51c0ca8b4387 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 28 Jan 2021 12:34:38 +0100 Subject: [PATCH 15/25] use proper keys to not override appended files --- src/Symfony/Component/Finder/Finder.php | 3 ++- src/Symfony/Component/Finder/Tests/FinderTest.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 4cf723bf33f53..82c2ec78dc5f3 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -669,7 +669,8 @@ public function append($iterator) } elseif ($iterator instanceof \Traversable || \is_array($iterator)) { $it = new \ArrayIterator(); foreach ($iterator as $file) { - $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file)); + $file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file); + $it[$file->getPathname()] = $file; } $this->iterators[] = $it; } else { diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index db3c4a55ef7be..dbc66cbc474c7 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -1119,6 +1119,17 @@ public function testAppendDoesNotRequireIn() $this->assertIterator(iterator_to_array($finder->getIterator()), $finder1->getIterator()); } + public function testMultipleAppendCallsWithSorting() + { + $finder = $this->buildFinder() + ->sortByName() + ->append([self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1000_1.php']) + ->append([self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1002_0.php']) + ; + + $this->assertOrderedIterator($this->toAbsolute(['qux_1000_1.php', 'qux_1002_0.php']), $finder->getIterator()); + } + public function testCountDirectories() { $directory = Finder::create()->directories()->in(self::$tmpDir); From 66be87bffc92a28c5edada77b08cd424a9cba5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Wed, 27 Jan 2021 17:03:07 +0100 Subject: [PATCH 16/25] [ErrorHandler] Fix strpos error when trying to call a method without a name --- .../UndefinedMethodFatalErrorHandler.php | 2 +- .../UndefinedMethodFatalErrorHandlerTest.php | 9 +++++++++ .../ErrorEnhancer/UndefinedMethodErrorEnhancer.php | 2 +- .../ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php index 773f4dfa78c28..4f622deeca53d 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -40,7 +40,7 @@ public function handleError(array $error, FatalErrorException $exception) $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className); - if (!class_exists($className) || null === $methods = get_class_methods($className)) { + if ('' === $methodName || !class_exists($className) || null === $methods = get_class_methods($className)) { // failed to get the class or its methods on which an unknown method was called (for example on an anonymous class) return new UndefinedMethodException($message, $exception); } diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index 55f2f62880b23..160dc7fa05015 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -48,6 +48,15 @@ public function provideUndefinedMethodData() ], 'Attempted to call an undefined method named "what" of class "SplObjectStorage".', ], + [ + [ + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined method SplObjectStorage::()', + ], + 'Attempted to call an undefined method named "" of class "SplObjectStorage".', + ], [ [ 'type' => 1, diff --git a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php index ad0e4b3eef00b..c4355f92ce089 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php @@ -39,7 +39,7 @@ public function enhance(\Throwable $error): ?\Throwable $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className); - if (!class_exists($className) || null === $methods = get_class_methods($className)) { + if ('' === $methodName || !class_exists($className) || null === $methods = get_class_methods($className)) { // failed to get the class or its methods on which an unknown method was called (for example on an anonymous class) return new UndefinedMethodError($message, $error); } diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php index d6ac6c029c6fb..b31c6c292a8f4 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php @@ -40,6 +40,10 @@ public function provideUndefinedMethodData() 'Call to undefined method SplObjectStorage::what()', 'Attempted to call an undefined method named "what" of class "SplObjectStorage".', ], + [ + 'Call to undefined method SplObjectStorage::()', + 'Attempted to call an undefined method named "" of class "SplObjectStorage".', + ], [ 'Call to undefined method SplObjectStorage::walid()', "Attempted to call an undefined method named \"walid\" of class \"SplObjectStorage\".\nDid you mean to call \"valid\"?", From 9629dafa661db0834c424fddbdb34c77da8f5d2a Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 27 Jan 2021 14:04:45 +0100 Subject: [PATCH 17/25] Use createMock() instead of a getter --- .../Tests/Templating/TimedPhpEngineTest.php | 7 +-- .../WebDebugToolbarListenerTest.php | 44 ++++++-------- .../Tests/Profiler/TemplateManagerTest.php | 20 +------ .../Tests/EventListener/ErrorListenerTest.php | 30 ++++------ .../Component/Form/Tests/FormFactoryTest.php | 13 ++-- .../CacheClearer/ChainCacheClearerTest.php | 7 +-- .../AddRequestFormatsListenerTest.php | 11 +--- .../EventListener/LocaleAwareListenerTest.php | 15 ++--- .../EventListener/TranslatorListenerTest.php | 15 ++--- .../AuthenticationTrustResolverTest.php | 4 +- .../Core/Tests/User/ChainUserProviderTest.php | 60 ++++++++----------- .../Constraints/UserPasswordValidatorTest.php | 7 +-- .../SessionAuthenticationStrategyTest.php | 13 ++-- .../Tests/Mapping/Loader/FilesLoaderTest.php | 9 +-- 14 files changed, 82 insertions(+), 173 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index 86c6d3940c713..72e3fb0f78920 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -29,7 +29,7 @@ class TimedPhpEngineTest extends TestCase { public function testThatRenderLogsTime() { - $container = $this->getContainer(); + $container = $this->createMock(Container::class); $templateNameParser = $this->getTemplateNameParser(); $globalVariables = $this->getGlobalVariables(); $loader = $this->getLoader($this->getStorage()); @@ -48,11 +48,6 @@ public function testThatRenderLogsTime() $engine->render('index.php'); } - private function getContainer(): Container - { - return $this->createMock(Container::class); - } - private function getTemplateNameParser(): TemplateNameParserInterface { $templateReference = $this->createMock(TemplateReferenceInterface::class); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 30b3edf164637..01d586346ad30 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -65,7 +65,7 @@ public function testHtmlRedirectionIsIntercepted($statusCode, $hasSession) { $response = new Response('Some content', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); @@ -78,7 +78,7 @@ public function testNonHtmlRedirectionIsNotIntercepted() { $response = new Response('Some content', '301'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); @@ -92,7 +92,7 @@ public function testToolbarIsInjected() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -108,7 +108,7 @@ public function testToolbarIsNotInjectedOnNonHtmlContentType() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Type', 'text/xml'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -124,7 +124,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Disposition', 'attachment; filename=test.html'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'html'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html'), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -140,7 +140,7 @@ public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession) { $response = new Response('', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -165,7 +165,7 @@ public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader { $response = new Response(''); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -181,7 +181,7 @@ public function testToolbarIsNotInjectedWhenOnSubRequest() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::SUB_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::SUB_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -197,7 +197,7 @@ public function testToolbarIsNotInjectedOnIncompleteHtmlResponses() $response = new Response('
Some content
'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -213,7 +213,7 @@ public function testToolbarIsNotInjectedOnXmlHttpRequests() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(true), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(true), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -229,7 +229,7 @@ public function testToolbarIsNotInjectedOnNonHtmlRequests() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(false, 'json'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json'), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -242,7 +242,7 @@ public function testXDebugUrlHeader() $response = new Response(); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $urlGenerator = $this->getUrlGeneratorMock(); + $urlGenerator = $this->createMock(UrlGeneratorInterface::class); $urlGenerator ->expects($this->once()) ->method('generate') @@ -250,7 +250,7 @@ public function testXDebugUrlHeader() ->willReturn('http://mydomain.com/_profiler/xxxxxxxx') ; - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -263,7 +263,7 @@ public function testThrowingUrlGenerator() $response = new Response(); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $urlGenerator = $this->getUrlGeneratorMock(); + $urlGenerator = $this->createMock(UrlGeneratorInterface::class); $urlGenerator ->expects($this->once()) ->method('generate') @@ -271,7 +271,7 @@ public function testThrowingUrlGenerator() ->willThrowException(new \Exception('foo')) ; - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -284,7 +284,7 @@ public function testThrowingErrorCleanup() $response = new Response(); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $urlGenerator = $this->getUrlGeneratorMock(); + $urlGenerator = $this->createMock(UrlGeneratorInterface::class); $urlGenerator ->expects($this->once()) ->method('generate') @@ -292,7 +292,7 @@ public function testThrowingErrorCleanup() ->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")) ; - $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -331,14 +331,4 @@ protected function getTwigMock($render = 'WDT') return $templating; } - - protected function getUrlGeneratorMock() - { - return $this->createMock(UrlGeneratorInterface::class); - } - - protected function getKernelMock() - { - return $this->createMock(Kernel::class); - } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 9b43ab5350732..5e746c63bffe3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -21,8 +21,6 @@ use Twig\Loader\SourceContextLoaderInterface; /** - * Test for TemplateManager class. - * * @author Artur Wielogórski */ class TemplateManagerTest extends TestCase @@ -38,7 +36,7 @@ class TemplateManagerTest extends TestCase protected $profiler; /** - * @var \Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager + * @var TemplateManager */ protected $templateManager; @@ -46,7 +44,7 @@ protected function setUp(): void { parent::setUp(); - $profiler = $this->mockProfiler(); + $this->profiler = $this->createMock(Profiler::class); $twigEnvironment = $this->mockTwigEnvironment(); $templates = [ 'data_collector.foo' => ['foo', 'FooBundle:Collector:foo'], @@ -54,7 +52,7 @@ protected function setUp(): void 'data_collector.baz' => ['baz', 'FooBundle:Collector:baz'], ]; - $this->templateManager = new TemplateManager($profiler, $twigEnvironment, $templates); + $this->templateManager = new TemplateManager($this->profiler, $twigEnvironment, $templates); } public function testGetNameOfInvalidTemplate() @@ -98,11 +96,6 @@ public function profileHasCollectorCallback($panel) } } - protected function mockProfile() - { - return $this->createMock(Profile::class); - } - protected function mockTwigEnvironment() { $this->twigEnvironment = $this->createMock(Environment::class); @@ -121,13 +114,6 @@ protected function mockTwigEnvironment() return $this->twigEnvironment; } - - protected function mockProfiler() - { - $this->profiler = $this->createMock(Profiler::class); - - return $this->profiler; - } } class ProfileDummy extends Profile diff --git a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php index ce3df1a0ec7bd..280395803c1c2 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php @@ -30,7 +30,7 @@ public function testOnConsoleError() { $error = new \TypeError('An error occurred'); - $logger = $this->getLogger(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->once()) ->method('error') @@ -38,14 +38,14 @@ public function testOnConsoleError() ; $listener = new ErrorListener($logger); - $listener->onConsoleError(new ConsoleErrorEvent(new ArgvInput(['console.php', 'test:run', '--foo=baz', 'buzz']), $this->getOutput(), $error, new Command('test:run'))); + $listener->onConsoleError(new ConsoleErrorEvent(new ArgvInput(['console.php', 'test:run', '--foo=baz', 'buzz']), $this->createMock(OutputInterface::class), $error, new Command('test:run'))); } public function testOnConsoleErrorWithNoCommandAndNoInputString() { $error = new \RuntimeException('An error occurred'); - $logger = $this->getLogger(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->once()) ->method('error') @@ -53,12 +53,12 @@ public function testOnConsoleErrorWithNoCommandAndNoInputString() ; $listener = new ErrorListener($logger); - $listener->onConsoleError(new ConsoleErrorEvent(new NonStringInput(), $this->getOutput(), $error)); + $listener->onConsoleError(new ConsoleErrorEvent(new NonStringInput(), $this->createMock(OutputInterface::class), $error)); } public function testOnConsoleTerminateForNonZeroExitCodeWritesToLog() { - $logger = $this->getLogger(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->once()) ->method('debug') @@ -71,7 +71,7 @@ public function testOnConsoleTerminateForNonZeroExitCodeWritesToLog() public function testOnConsoleTerminateForZeroExitCodeDoesNotWriteToLog() { - $logger = $this->getLogger(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->never()) ->method('debug') @@ -83,7 +83,7 @@ public function testOnConsoleTerminateForZeroExitCodeDoesNotWriteToLog() public function testGetSubscribedEvents() { - $this->assertEquals( + $this->assertSame( [ 'console.error' => ['onConsoleError', -128], 'console.terminate' => ['onConsoleTerminate', -128], @@ -94,7 +94,7 @@ public function testGetSubscribedEvents() public function testAllKindsOfInputCanBeLogged() { - $logger = $this->getLogger(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->exactly(3)) ->method('debug') @@ -109,7 +109,7 @@ public function testAllKindsOfInputCanBeLogged() public function testCommandNameIsDisplayedForNonStringableInput() { - $logger = $this->getLogger(); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->once()) ->method('debug') @@ -120,19 +120,9 @@ public function testCommandNameIsDisplayedForNonStringableInput() $listener->onConsoleTerminate($this->getConsoleTerminateEvent($this->createMock(InputInterface::class), 255)); } - private function getLogger() - { - return $this->getMockForAbstractClass(LoggerInterface::class); - } - private function getConsoleTerminateEvent(InputInterface $input, $exitCode) { - return new ConsoleTerminateEvent(new Command('test:run'), $input, $this->getOutput(), $exitCode); - } - - private function getOutput() - { - return $this->createMock(OutputInterface::class); + return new ConsoleTerminateEvent(new Command('test:run'), $input, $this->createMock(OutputInterface::class), $exitCode); } } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index 0ea4bb26bfd12..c857ca622380f 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -77,7 +77,7 @@ public function testCreateNamedBuilderWithTypeName() { $options = ['a' => '1', 'b' => '2']; $resolvedOptions = ['a' => '2', 'b' => '3']; - $resolvedType = $this->getMockResolvedType(); + $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); $this->registry->expects($this->once()) ->method('getType') @@ -105,7 +105,7 @@ public function testCreateNamedBuilderFillsDataOption() $givenOptions = ['a' => '1', 'b' => '2']; $expectedOptions = array_merge($givenOptions, ['data' => 'DATA']); $resolvedOptions = ['a' => '2', 'b' => '3', 'data' => 'DATA']; - $resolvedType = $this->getMockResolvedType(); + $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); $this->registry->expects($this->once()) ->method('getType') @@ -132,7 +132,7 @@ public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() { $options = ['a' => '1', 'b' => '2', 'data' => 'CUSTOM']; $resolvedOptions = ['a' => '2', 'b' => '3', 'data' => 'CUSTOM']; - $resolvedType = $this->getMockResolvedType(); + $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); $this->registry->expects($this->once()) ->method('getType') @@ -211,7 +211,7 @@ public function testCreateNamed() { $options = ['a' => '1', 'b' => '2']; $resolvedOptions = ['a' => '2', 'b' => '3']; - $resolvedType = $this->getMockResolvedType(); + $resolvedType = $this->createMock(ResolvedFormTypeInterface::class); $this->registry->expects($this->once()) ->method('getType') @@ -485,9 +485,4 @@ private function getMockFactory(array $methods = []) ->setConstructorArgs([$this->registry]) ->getMock(); } - - private function getMockResolvedType() - { - return $this->createMock(ResolvedFormTypeInterface::class); - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php index 80c1b576be3e9..80d9796070bc0 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void public function testInjectClearersInConstructor() { - $clearer = $this->getMockClearer(); + $clearer = $this->createMock(CacheClearerInterface::class); $clearer ->expects($this->once()) ->method('clear'); @@ -39,9 +39,4 @@ public function testInjectClearersInConstructor() $chainClearer = new ChainCacheClearer([$clearer]); $chainClearer->clear(self::$cacheDir); } - - protected function getMockClearer() - { - return $this->createMock(CacheClearerInterface::class); - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index def3831851345..fab9a8a38f607 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -19,8 +19,6 @@ use Symfony\Component\HttpKernel\KernelEvents; /** - * Test AddRequestFormatsListener class. - * * @author Gildas Quemener */ class AddRequestFormatsListenerTest extends TestCase @@ -47,7 +45,7 @@ public function testIsAnEventSubscriber() public function testRegisteredEvent() { - $this->assertEquals( + $this->assertSame( [KernelEvents::REQUEST => ['onKernelRequest', 100]], AddRequestFormatsListener::getSubscribedEvents() ); @@ -55,7 +53,7 @@ public function testRegisteredEvent() public function testSetAdditionalFormats() { - $request = $this->getRequestMock(); + $request = $this->createMock(Request::class); $event = $this->getRequestEventMock($request); $request->expects($this->once()) @@ -65,11 +63,6 @@ public function testSetAdditionalFormats() $this->listener->onKernelRequest($event); } - protected function getRequestMock() - { - return $this->createMock(Request::class); - } - protected function getRequestEventMock(Request $request) { $event = $this->createMock(RequestEvent::class); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php index 20c9f9d8c9e44..ab92a7916877e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php @@ -40,7 +40,7 @@ public function testLocaleIsSetInOnKernelRequest() ->method('setLocale') ->with($this->equalTo('fr')); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -57,7 +57,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() $this->throwException(new \InvalidArgumentException()) ); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -71,7 +71,7 @@ public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists() $this->requestStack->push($this->createRequest('fr')); $this->requestStack->push($subRequest = $this->createRequest('de')); - $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -84,7 +84,7 @@ public function testLocaleIsSetToDefaultOnKernelFinishRequestWhenParentRequestDo $this->requestStack->push($subRequest = $this->createRequest('de')); - $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -104,15 +104,10 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() $this->requestStack->push($this->createRequest('fr')); $this->requestStack->push($subRequest = $this->createRequest('de')); - $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } - private function createHttpKernel() - { - return $this->createMock(HttpKernelInterface::class); - } - private function createRequest($locale) { $request = new Request(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php index 26097696dd577..1eb86b7fb99e5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php @@ -43,7 +43,7 @@ public function testLocaleIsSetInOnKernelRequest() ->method('setLocale') ->with($this->equalTo('fr')); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -60,7 +60,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() $this->throwException(new \InvalidArgumentException()) ); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -72,7 +72,7 @@ public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists() ->with($this->equalTo('fr')); $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -82,7 +82,7 @@ public function testLocaleIsNotSetInOnKernelFinishRequestWhenParentRequestDoesNo ->expects($this->never()) ->method('setLocale'); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -100,15 +100,10 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() ); $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } - private function createHttpKernel() - { - return $this->createMock(HttpKernelInterface::class); - } - private function createRequest($locale) { $request = new Request(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index eb82a596bcfa2..3d6258e2da26b 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -140,8 +140,8 @@ protected function getRememberMeToken() protected function getResolver() { return new AuthenticationTrustResolver( - 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken', - 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken' + AnonymousToken::class, + RememberMeToken::class ); } } diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php index cb172d2b5138b..b7e2a411b392d 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php @@ -24,7 +24,7 @@ class ChainUserProviderTest extends TestCase { public function testLoadUserByUsername() { - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('loadUserByUsername') @@ -32,12 +32,12 @@ public function testLoadUserByUsername() ->willThrowException(new UsernameNotFoundException('not found')) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foo')) - ->willReturn($account = $this->getAccount()) + ->willReturn($account = $this->createMock(UserInterface::class)) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -47,7 +47,7 @@ public function testLoadUserByUsername() public function testLoadUserByUsernameThrowsUsernameNotFoundException() { $this->expectException(UsernameNotFoundException::class); - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('loadUserByUsername') @@ -55,7 +55,7 @@ public function testLoadUserByUsernameThrowsUsernameNotFoundException() ->willThrowException(new UsernameNotFoundException('not found')) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('loadUserByUsername') @@ -69,14 +69,14 @@ public function testLoadUserByUsernameThrowsUsernameNotFoundException() public function testRefreshUser() { - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('supportsClass') ->willReturn(false) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('supportsClass') @@ -89,7 +89,7 @@ public function testRefreshUser() ->willThrowException(new UnsupportedUserException('unsupported')) ; - $provider3 = $this->getProvider(); + $provider3 = $this->createMock(UserProviderInterface::class); $provider3 ->expects($this->once()) ->method('supportsClass') @@ -99,16 +99,16 @@ public function testRefreshUser() $provider3 ->expects($this->once()) ->method('refreshUser') - ->willReturn($account = $this->getAccount()) + ->willReturn($account = $this->createMock(UserInterface::class)) ; $provider = new ChainUserProvider([$provider1, $provider2, $provider3]); - $this->assertSame($account, $provider->refreshUser($this->getAccount())); + $this->assertSame($account, $provider->refreshUser($this->createMock(UserInterface::class))); } public function testRefreshUserAgain() { - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('supportsClass') @@ -121,7 +121,7 @@ public function testRefreshUserAgain() ->willThrowException(new UsernameNotFoundException('not found')) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('supportsClass') @@ -131,17 +131,17 @@ public function testRefreshUserAgain() $provider2 ->expects($this->once()) ->method('refreshUser') - ->willReturn($account = $this->getAccount()) + ->willReturn($account = $this->createMock(UserInterface::class)) ; $provider = new ChainUserProvider([$provider1, $provider2]); - $this->assertSame($account, $provider->refreshUser($this->getAccount())); + $this->assertSame($account, $provider->refreshUser($this->createMock(UserInterface::class))); } public function testRefreshUserThrowsUnsupportedUserException() { $this->expectException(UnsupportedUserException::class); - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('supportsClass') @@ -154,7 +154,7 @@ public function testRefreshUserThrowsUnsupportedUserException() ->willThrowException(new UnsupportedUserException('unsupported')) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('supportsClass') @@ -168,12 +168,12 @@ public function testRefreshUserThrowsUnsupportedUserException() ; $provider = new ChainUserProvider([$provider1, $provider2]); - $provider->refreshUser($this->getAccount()); + $provider->refreshUser($this->createMock(UserInterface::class)); } public function testSupportsClass() { - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('supportsClass') @@ -181,7 +181,7 @@ public function testSupportsClass() ->willReturn(false) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('supportsClass') @@ -195,7 +195,7 @@ public function testSupportsClass() public function testSupportsClassWhenNotSupported() { - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('supportsClass') @@ -203,7 +203,7 @@ public function testSupportsClassWhenNotSupported() ->willReturn(false) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('supportsClass') @@ -217,7 +217,7 @@ public function testSupportsClassWhenNotSupported() public function testAcceptsTraversable() { - $provider1 = $this->getProvider(); + $provider1 = $this->createMock(UserProviderInterface::class); $provider1 ->expects($this->once()) ->method('supportsClass') @@ -230,7 +230,7 @@ public function testAcceptsTraversable() ->willThrowException(new UnsupportedUserException('unsupported')) ; - $provider2 = $this->getProvider(); + $provider2 = $this->createMock(UserProviderInterface::class); $provider2 ->expects($this->once()) ->method('supportsClass') @@ -240,11 +240,11 @@ public function testAcceptsTraversable() $provider2 ->expects($this->once()) ->method('refreshUser') - ->willReturn($account = $this->getAccount()) + ->willReturn($account = $this->createMock(UserInterface::class)) ; $provider = new ChainUserProvider(new \ArrayObject([$provider1, $provider2])); - $this->assertSame($account, $provider->refreshUser($this->getAccount())); + $this->assertSame($account, $provider->refreshUser($this->createMock(UserInterface::class))); } public function testPasswordUpgrades() @@ -268,14 +268,4 @@ public function testPasswordUpgrades() $provider = new ChainUserProvider([$provider1, $provider2]); $provider->upgradePassword($user, 'foobar'); } - - protected function getAccount() - { - return $this->createMock(UserInterface::class); - } - - protected function getProvider() - { - return $this->createMock(UserProviderInterface::class); - } } diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index 7c2d93ada1b24..5fc9ba0eae713 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { $user = $this->createUser(); $this->tokenStorage = $this->createTokenStorage($user); - $this->encoder = $this->createPasswordEncoder(); + $this->encoder = $this->createMock(PasswordEncoderInterface::class); $this->encoderFactory = $this->createEncoderFactory($this->encoder); parent::setUp(); @@ -147,11 +147,6 @@ protected function createUser() return $mock; } - protected function createPasswordEncoder($isPasswordValid = true) - { - return $this->createMock(PasswordEncoderInterface::class); - } - protected function createEncoderFactory($encoder = null) { $mock = $this->createMock(EncoderFactoryInterface::class); diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php index 94ff9228bca29..69953ae6fd14e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -25,7 +25,7 @@ public function testSessionIsNotChanged() $request->expects($this->never())->method('getSession'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE); - $strategy->onAuthentication($request, $this->getToken()); + $strategy->onAuthentication($request, $this->createMock(TokenInterface::class)); } public function testUnsupportedStrategy() @@ -36,7 +36,7 @@ public function testUnsupportedStrategy() $request->expects($this->never())->method('getSession'); $strategy = new SessionAuthenticationStrategy('foo'); - $strategy->onAuthentication($request, $this->getToken()); + $strategy->onAuthentication($request, $this->createMock(TokenInterface::class)); } public function testSessionIsMigrated() @@ -45,7 +45,7 @@ public function testSessionIsMigrated() $session->expects($this->once())->method('migrate')->with($this->equalTo(true)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); - $strategy->onAuthentication($this->getRequest($session), $this->getToken()); + $strategy->onAuthentication($this->getRequest($session), $this->createMock(TokenInterface::class)); } public function testSessionIsInvalidated() @@ -54,7 +54,7 @@ public function testSessionIsInvalidated() $session->expects($this->once())->method('invalidate'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE); - $strategy->onAuthentication($this->getRequest($session), $this->getToken()); + $strategy->onAuthentication($this->getRequest($session), $this->createMock(TokenInterface::class)); } private function getRequest($session = null) @@ -67,9 +67,4 @@ private function getRequest($session = null) return $request; } - - private function getToken() - { - return $this->createMock(TokenInterface::class); - } } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php index bc6aab8a34bf4..6bba637a9b73a 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php @@ -20,13 +20,13 @@ class FilesLoaderTest extends TestCase { public function testCallsGetFileLoaderInstanceForeachPath() { - $loader = $this->getFilesLoader($this->getFileLoader()); + $loader = $this->getFilesLoader($this->createMock(LoaderInterface::class)); $this->assertEquals(4, $loader->getTimesCalled()); } public function testCallsActualFileLoaderForMetadata() { - $fileLoader = $this->getFileLoader(); + $fileLoader = $this->createMock(LoaderInterface::class); $fileLoader->expects($this->exactly(4)) ->method('loadClassMetadata'); $loader = $this->getFilesLoader($fileLoader); @@ -42,9 +42,4 @@ public function getFilesLoader(LoaderInterface $loader) __DIR__.'/constraint-mapping.txt', ], $loader]); } - - public function getFileLoader() - { - return $this->createMock(LoaderInterface::class); - } } From 3ef7bfd9720be68d6d68253af94c1ac8717120a2 Mon Sep 17 00:00:00 2001 From: LoginovIlya Date: Sun, 31 Jan 2021 18:20:26 +0300 Subject: [PATCH 18/25] [yaml] Delelte unused comparison operation --- src/Symfony/Component/Yaml/Dumper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 2de07d023142f..dcb104ccff065 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -68,7 +68,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): $output .= "\n"; } - if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) { + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) { // If the first line starts with a space character, the spec requires a blockIndicationIndicator // http://www.yaml.org/spec/1.2/spec.html#id2793979 $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; @@ -97,7 +97,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): if ($value instanceof TaggedValue) { $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); - if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { // If the first line starts with a space character, the spec requires a blockIndicationIndicator // http://www.yaml.org/spec/1.2/spec.html#id2793979 $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : ''; From 42eeb44f8326ea3efb951df1c2308a338715a3f9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 1 Feb 2021 15:36:03 +0100 Subject: [PATCH 19/25] [Messenger] Fix Doctrine setup when using a migration --- .../Bridge/Doctrine/Transport/PostgreSqlConnection.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php index 9217550d14709..4490c7521f366 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php @@ -87,7 +87,7 @@ public function setup(): void { parent::setup(); - $this->executeStatement(implode("\n", $this->getTriggerSql())); + $this->executeStatement('BEGIN;'.implode("\n", $this->getTriggerSql()).'COMMIT;'); } /** @@ -109,7 +109,6 @@ public function getExtraSetupSqlForTable(Table $createdTable): array private function getTriggerSql(): array { return [ - 'BEGIN;', sprintf('LOCK TABLE %s;', $this->configuration['table_name']), // create trigger function sprintf(<<<'SQL' @@ -124,7 +123,6 @@ private function getTriggerSql(): array // register trigger sprintf('DROP TRIGGER IF EXISTS notify_trigger ON %s;', $this->configuration['table_name']), sprintf('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON %1$s FOR EACH ROW EXECUTE PROCEDURE notify_%1$s();', $this->configuration['table_name']), - 'COMMIT;', ]; } From b2d7454042c5fbd66d2f2a88193ca7a4fe901219 Mon Sep 17 00:00:00 2001 From: Piotr Kugla Date: Sat, 23 Jan 2021 17:20:14 +0100 Subject: [PATCH 20/25] [Mime] Fix case-sensitive handling in Headers::isUniqueHeader() --- src/Symfony/Component/Mime/Header/Headers.php | 2 +- src/Symfony/Component/Mime/Tests/Header/HeadersTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index c6e4c8eaafb77..94614d9881b0b 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -201,7 +201,7 @@ public function remove(string $name): void public static function isUniqueHeader(string $name): bool { - return \in_array($name, self::UNIQUE_HEADERS, true); + return \in_array(strtolower($name), self::UNIQUE_HEADERS, true); } public function toString(): string diff --git a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php index e2eb75a6977f3..89d8be01b0181 100644 --- a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php @@ -212,6 +212,11 @@ public function testRemoveIsNotCaseSensitive() $this->assertFalse($headers->has('Message-ID')); } + public function testIsUniqueHeaderIsNotCaseSensitive() + { + $this->assertTrue(Headers::isUniqueHeader('From')); + } + public function testToStringJoinsHeadersTogether() { $headers = new Headers(); From d563c846f6c5ee93d77dcf547c1b07266d33af32 Mon Sep 17 00:00:00 2001 From: Piotr Kugla Date: Sat, 23 Jan 2021 17:03:13 +0100 Subject: [PATCH 21/25] [Mailer][Mime] Fix case-sensitive handling of header names --- .../Mailer/EventListener/MessageListener.php | 2 +- .../Tests/EventListener/MessageListenerTest.php | 12 ++++++++++++ src/Symfony/Component/Mime/Header/Headers.php | 4 ++-- .../Component/Mime/Tests/Header/HeadersTest.php | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Mailer/EventListener/MessageListener.php b/src/Symfony/Component/Mailer/EventListener/MessageListener.php index dbf2570a27eac..f23c69d91dc74 100644 --- a/src/Symfony/Component/Mailer/EventListener/MessageListener.php +++ b/src/Symfony/Component/Mailer/EventListener/MessageListener.php @@ -58,7 +58,7 @@ public function addHeaderRule(string $headerName, int $rule): void throw new InvalidArgumentException(sprintf('The "%d" rule is not supported.', $rule)); } - $this->headerRules[$headerName] = $rule; + $this->headerRules[strtolower($headerName)] = $rule; } public function onMessage(MessageEvent $event): void diff --git a/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php b/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php index 6096f5614cb2c..41f71f72adf37 100644 --- a/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php +++ b/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php @@ -101,5 +101,17 @@ public function provideHeaders(): iterable ->add(new MailboxListHeader('bcc', [new Address('bcc-initial@example.com'), new Address('bcc-default@example.com'), new Address('bcc-default-1@example.com')])) ; yield 'bcc, add another bcc (unique header)' => [$initialHeaders, $defaultHeaders, $expectedHeaders]; + + $initialHeaders = (new Headers()) + ->add(new UnstructuredHeader('foo', 'initial')) + ; + $defaultHeaders = (new Headers()) + ->add(new UnstructuredHeader('foo', 'bar')) + ->add(new UnstructuredHeader('bar', 'foo')) + ; + $rules = [ + 'Foo' => MessageListener::HEADER_REPLACE, + ]; + yield 'Capitalized header rule (case-insensitive), replace if set' => [$initialHeaders, $defaultHeaders, $defaultHeaders, $rules]; } } diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index 9493e2c2da234..b8d8da64f0718 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -143,7 +143,7 @@ public function addParameterizedHeader(string $name, string $value, array $param */ public function addHeader(string $name, $argument, array $more = []): self { - $parts = explode('\\', self::HEADER_CLASS_MAP[$name] ?? UnstructuredHeader::class); + $parts = explode('\\', self::HEADER_CLASS_MAP[strtolower($name)] ?? UnstructuredHeader::class); $method = 'add'.ucfirst(array_pop($parts)); if ('addUnstructuredHeader' === $method) { $method = 'addTextHeader'; @@ -217,7 +217,7 @@ public function remove(string $name): void public static function isUniqueHeader(string $name): bool { - return \in_array($name, self::UNIQUE_HEADERS, true); + return \in_array(strtolower($name), self::UNIQUE_HEADERS, true); } /** diff --git a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php index 2255dbe7a7c8c..f465fb9e8515f 100644 --- a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php @@ -239,6 +239,20 @@ public function testRemoveIsNotCaseSensitive() $this->assertFalse($headers->has('Message-ID')); } + public function testAddHeaderIsNotCaseSensitive() + { + $headers = new Headers(); + $headers->addHeader('From', ['from@example.com']); + + $this->assertInstanceOf(MailboxListHeader::class, $headers->get('from')); + $this->assertEquals([new Address('from@example.com')], $headers->get('from')->getBody()); + } + + public function testIsUniqueHeaderIsNotCaseSensitive() + { + $this->assertTrue(Headers::isUniqueHeader('From')); + } + public function testToStringJoinsHeadersTogether() { $headers = new Headers(); From a9e9359581fe95be6b6fda9a8129e7c5258fbb4c Mon Sep 17 00:00:00 2001 From: FabienSalles Date: Mon, 1 Feb 2021 18:18:40 +0100 Subject: [PATCH 22/25] fix validator when we have a false current element fix coding styles add type in return --- .../Constraints/UniqueEntityValidatorTest.php | 81 +++++++++++++++++++ .../Constraints/UniqueEntityValidator.php | 3 +- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index d8b7abc8064bc..05faff5872dd8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -793,4 +793,85 @@ public function testValidateUniquenessCause() ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } + + /** + * @dataProvider resultWithEmptyIterator + */ + public function testValidateUniquenessWithEmptyIterator($entity, $result) + { + $constraint = new UniqueEntity([ + 'message' => 'myMessage', + 'fields' => ['name'], + 'em' => self::EM_NAME, + 'repositoryMethod' => 'findByCustom', + ]); + + $repository = $this->createRepositoryMock(); + $repository->expects($this->once()) + ->method('findByCustom') + ->willReturn($result) + ; + $this->em = $this->createEntityManagerMock($repository); + $this->registry = $this->createRegistryMock($this->em); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + $this->validator->validate($entity, $constraint); + + $this->assertNoViolation(); + } + + public function resultWithEmptyIterator(): array + { + $entity = new SingleIntIdEntity(1, 'foo'); + + return [ + [$entity, new class() implements \Iterator { + public function current() + { + return null; + } + + public function valid(): bool + { + return false; + } + + public function next() + { + } + + public function key() + { + } + + public function rewind() + { + } + }], + [$entity, new class() implements \Iterator { + public function current() + { + return false; + } + + public function valid(): bool + { + return false; + } + + public function next() + { + } + + public function key() + { + } + + public function rewind() + { + } + }], + ]; + } } diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 4324dfde55436..399a18d90c7fe 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -147,8 +147,7 @@ public function validate($entity, Constraint $constraint) if ($result instanceof \Countable && 1 < \count($result)) { $result = [$result->current(), $result->current()]; } else { - $result = $result->current(); - $result = null === $result ? [] : [$result]; + $result = $result->valid() && null !== $result->current() ? [$result->current()] : []; } } elseif (\is_array($result)) { reset($result); From 025079b051a81b1cb65a2ad20246e46575d31253 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 29 Jan 2021 10:38:16 +0100 Subject: [PATCH 23/25] Streamline dataproviders --- .../Twig/Tests/Extension/HttpFoundationExtensionTest.php | 4 ++-- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 2 +- src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php | 4 ++-- .../Tests/Normalizer/Features/CallbacksTestTrait.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index df9add8afb42b..cb6658e4bbd32 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -23,7 +23,7 @@ class HttpFoundationExtensionTest extends TestCase { /** - * @dataProvider getGenerateAbsoluteUrlData() + * @dataProvider getGenerateAbsoluteUrlData */ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) { @@ -116,7 +116,7 @@ public function testGenerateAbsoluteUrlWithScriptFileName() } /** - * @dataProvider getGenerateRelativePathData() + * @dataProvider getGenerateRelativePathData */ public function testGenerateRelativePath($expected, $path, $pathinfo) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 12ce2203e83b3..b90dfd645d796 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -728,7 +728,7 @@ public function testGetUriForPath() } /** - * @dataProvider getRelativeUriForPathData() + * @dataProvider getRelativeUriForPathData */ public function testGetRelativeUriForPath($expected, $pathinfo, $path) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php index 758b9c16a8724..7d96f730d7eae 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php @@ -20,7 +20,7 @@ class UrlHelperTest extends TestCase { /** - * @dataProvider getGenerateAbsoluteUrlData() + * @dataProvider getGenerateAbsoluteUrlData */ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) { @@ -113,7 +113,7 @@ public function testGenerateAbsoluteUrlWithScriptFileName() } /** - * @dataProvider getGenerateRelativePathData() + * @dataProvider getGenerateRelativePathData */ public function testGenerateRelativePath($expected, $path, $pathinfo) { diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php index ccb54d9c6fd25..459b01c92408f 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php @@ -29,7 +29,7 @@ public function testCallbacks($callbacks, $valueBar, $result) } /** - * @dataProvider provideInvalidCallbacks() + * @dataProvider provideInvalidCallbacks */ public function testUncallableCallbacks($callbacks) { From 4f48e80649d4df6dbed52ebc231d162cd9b6fb95 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Feb 2021 05:51:42 +0100 Subject: [PATCH 24/25] Update CHANGELOG for 5.2.3 --- CHANGELOG-5.2.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG-5.2.md b/CHANGELOG-5.2.md index 6e42cd86cfbc4..7fe615b1fcca4 100644 --- a/CHANGELOG-5.2.md +++ b/CHANGELOG-5.2.md @@ -7,6 +7,17 @@ in 5.2 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/v5.2.0...v5.2.1 +* 5.2.3 (2021-02-03) + + * bug #39954 [Mailer][Mime] Fix case-sensitive handling of header names (piku235) + * bug #40055 [Messenger] Fix Doctrine setup when using a migration (fabpot) + * bug #40018 [TwigBridge] take into account all label related options (xabbuh) + * bug #40023 [Finder]  use proper keys to not override appended files (xabbuh) + * bug #40019 [ErrorHandler] Fix strpos error when trying to call a method without a name (Deuchnord) + * bug #40027 [DoctrineBridge] add missing `@experimental` annotation on Uid generators (nicolas-grekas) + * bug #40004 [Serializer] Prevent access to private properties without getters (julienfalque) + * bug #40003 [Uid] Fix time to float conversion (fancyweb) + * 5.2.2 (2021-01-27) * bug #38900 [Serializer] Exclude non-initialized properties accessed with getters (BoShurik) From f4220645403bb459995455adbd4649b5cff2281d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Feb 2021 05:51:58 +0100 Subject: [PATCH 25/25] Update VERSION for 5.2.3 --- 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 a83b264db98fe..18c077b5e21a4 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -74,12 +74,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '5.2.3-DEV'; + public const VERSION = '5.2.3'; public const VERSION_ID = 50203; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 3; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2021'; public const END_OF_LIFE = '07/2021'; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy