diff --git a/.github/patch-types.php b/.github/patch-types.php index a308eda397d51..a714a3370358d 100644 --- a/.github/patch-types.php +++ b/.github/patch-types.php @@ -32,6 +32,7 @@ case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'): + case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/compositetype_classes.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'): @@ -46,6 +47,7 @@ case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'): case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'): case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'): + case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php'): continue 2; } diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index cf6787a8d8e77..cf869eea173cd 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -12,6 +12,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: tests: diff --git a/.github/workflows/intl-data-tests.yml b/.github/workflows/intl-data-tests.yml index bb54e306c3d4d..477278e416c4d 100644 --- a/.github/workflows/intl-data-tests.yml +++ b/.github/workflows/intl-data-tests.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: tests: name: Tests diff --git a/.github/workflows/phpunit-bridge.yml b/.github/workflows/phpunit-bridge.yml index e8a19360a8b32..d10098d119114 100644 --- a/.github/workflows/phpunit-bridge.yml +++ b/.github/workflows/phpunit-bridge.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: lint: name: Lint diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 8631d6c6a2b3d..96f34721f4a46 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -11,6 +11,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: psalm: name: Psalm diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6be35796056d5..c9bd72085e803 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -12,6 +12,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: tests: diff --git a/CHANGELOG-4.4.md b/CHANGELOG-4.4.md index 0231db585bc0b..9e6451685ab5c 100644 --- a/CHANGELOG-4.4.md +++ b/CHANGELOG-4.4.md @@ -7,6 +7,31 @@ 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.44 (2022-07-29) + + * bug #47069 [Security] Allow redirect after login to absolute URLs (Tim Ward) + * bug #47073 [HttpKernel] Fix non-scalar check in surrogate fragment renderer (aschempp) + * bug #43329 [Serializer] Respect default context in DateTimeNormalizer::denormalize (hultberg) + * bug #47086 Workaround disabled "var_dump" (nicolas-grekas) + * bug #40828 [BrowserKit] Merge fields and files recursively if they are multidimensional array (januszmk) + * bug #47048 [Serializer] Fix XmlEncoder encoding attribute false (alamirault) + * bug #47000 [ErrorHandler] Fix return type patching for list and class-string pseudo types (derrabus) + * bug #43998 [HttpKernel] [HttpCache] Don't throw on 304 Not Modified (aleho) + * bug #46981 [Mime]  quote address names if they contain parentheses (xabbuh) + * bug #46960 [FrameworkBundle] Fail gracefully when forms use disabled CSRF (HeahDude) + * bug #46973 [DependencyInjection] Fail gracefully when attempting to autowire composite types (derrabus) + * bug #46963 [Mime] Fix inline parts when added via attachPart() (fabpot) + * bug #46968 [PropertyInfo] Make sure nested composite types do not crash ReflectionExtractor (derrabus) + * bug #46931 Flush backend output buffer after closing. (bradjones1) + * bug #46905 [BrowserKit] fix sending request to paths containing multiple slashes (xabbuh) + * bug #42033 [HttpFoundation] Fix deleteFileAfterSend on client abortion (nerg4l) + * bug #46941 [Messenger] Fix calls to deprecated DBAL methods (derrabus) + * bug #46863 [Mime] Fix invalid DKIM signature with multiple parts (BrokenSourceCode) + * bug #46808 [HttpFoundation] Fix TypeError on null `$_SESSION` in `NativeSessionStorage::save()` (chalasr) + * bug #46790 [HttpFoundation] Prevent PHP Warning: Session ID is too long or contains illegal characters (BrokenSourceCode) + * bug #46800 Spaces in system temp folder path cause deprecation errors in php 8 (demeritcowboy) + * bug #46797 [Messenger] Ceil waiting time when multiplier is a float on retry (WissameMekhilef) + * 4.4.43 (2022-06-26) * bug #46765 [Serializer] Fix denormalization union types with constructor (Gwemox) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ec4fddccc86be..99d8c121d9fce 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -21,8 +21,8 @@ The Symfony Connect username in parenthesis allows to get more information - Jordi Boggiano (seldaek) - Roland Franssen (ro0) - Victor Berchet (victor) - - Tobias Nyholm (tobias) - Yonel Ceruto (yonelceruto) + - Tobias Nyholm (tobias) - Oskar Stark (oskarstark) - Ryan Weaver (weaverryan) - Javier Eguiluz (javier.eguiluz) @@ -34,35 +34,35 @@ The Symfony Connect username in parenthesis allows to get more information - Samuel ROZE (sroze) - Pascal Borreli (pborreli) - Romain Neutron - - Joseph Bielawski (stloyd) - Jules Pietri (heah) + - Joseph Bielawski (stloyd) - Drak (drak) - Abdellatif Ait boudad (aitboudad) - Lukas Kahwe Smith (lsmith) - Jan Schädlich (jschaedl) - Martin Hasoň (hason) - - Jeremy Mikola (jmikola) - Jérôme Tamarelle (gromnan) + - Jeremy Mikola (jmikola) - Jean-François Simon (jfsimon) - Benjamin Eberlei (beberlei) - Kevin Bond (kbond) - Igor Wiedler - Valentin Udaltsov (vudaltsov) - Vasilij Duško (staff) + - HypeMC (hypemc) - Matthias Pigulla (mpdude) - Laurent VOULLEMIER (lvo) - Pierre du Plessis (pierredup) - - Grégoire Paris (greg0ire) - - Jonathan Wage (jwage) - Antoine Makdessi (amakdessi) - - HypeMC (hypemc) + - Grégoire Paris (greg0ire) - Gabriel Ostrolucký (gadelat) + - Jonathan Wage (jwage) - David Maicher (dmaicher) - Titouan Galopin (tgalopin) - Alexandre Salomé (alexandresalome) - William DURAND - - ornicar - Alexander Schranz (alexander-schranz) + - ornicar - Dany Maillard (maidmaid) - Eriksen Costa - Diego Saint Esteben (dosten) @@ -70,26 +70,26 @@ The Symfony Connect username in parenthesis allows to get more information - Alexander Mols (asm89) - Gábor Egyed (1ed) - Francis Besset (francisbesset) + - Alexandre Daubois (alexandre-daubois) - Vasilij Dusko | CREATION - - Bulat Shakirzyanov (avalanche123) - Mathieu Santostefano (welcomattic) + - Bulat Shakirzyanov (avalanche123) - Iltar van der Berg - - Alexandre Daubois (alexandre-daubois) - Miha Vrhovnik (mvrhov) - Saša Stamenković (umpirsky) - Mathieu Piot (mpiot) - - Guilhem N (guilhemn) - Alex Pott + - Guilhem N (guilhemn) - Vladimir Reznichenko (kalessil) - Sarah Khalil (saro0h) - Konstantin Kudryashov (everzet) + - Vincent Langlet (deviling) - Bilal Amarni (bamarni) + - Tomas Norkūnas (norkunas) - Eriksen Costa - Florin Patan (florinpatan) - Peter Rehm (rpet) - - Tomas Norkūnas (norkunas) - Henrik Bjørnskov (henrikbjorn) - - Vincent Langlet (deviling) - Konstantin Myakshin (koc) - Andrej Hudec (pulzarraider) - Julien Falque (julienfalque) @@ -104,8 +104,8 @@ The Symfony Connect username in parenthesis allows to get more information - Fran Moreno (franmomu) - Jáchym Toušek (enumag) - Malte Schlüter (maltemaltesich) - - Vasilij Dusko - Mathias Arlaud (mtarld) + - Vasilij Dusko - Denis (yethee) - Arnout Boks (aboks) - Charles Sarrazin (csarrazi) @@ -125,14 +125,15 @@ The Symfony Connect username in parenthesis allows to get more information - Toni Uebernickel (havvg) - Bart van den Burg (burgov) - Jordan Alliot (jalliot) + - Smaine Milianni (ismail1432) - John Wards (johnwards) - Dariusz Ruminski - Lars Strojny (lstrojny) - - Smaine Milianni (ismail1432) + - Yanick Witschi (toflar) - Antoine Hérault (herzult) - Konstantin.Myakshin + - Rokas Mikalkėnas (rokasm) - Arman Hosseini (arman) - - Yanick Witschi (toflar) - Arnaud Le Blanc (arnaud-lb) - Maxime STEINHAUSSER - Peter Kokot (maastermedia) @@ -145,22 +146,23 @@ The Symfony Connect username in parenthesis allows to get more information - YaFou - Gary PEGEOT (gary-p) - Chris Wilkinson (thewilkybarkid) - - Rokas Mikalkėnas (rokasm) - Brice BERNARD (brikou) - Roman Martinuk (a2a4) - Gregor Harlan (gharlan) + - Antoine Lamirault - Baptiste Clavié (talus) - Adrien Brault (adrienbrault) - Michal Piotrowski - marc.weistroff - lenar + - Jesse Rushlow (geeshoe) - Théo FIDRY - jeremyFreeAgent (jeremyfreeagent) - Włodzimierz Gajda (gajdaw) - Christian Scheb - Guillaume (guill) - Mathieu Lechat (mat_the_cat) - - Jesse Rushlow (geeshoe) + - Tugdual Saunier (tucksaun) - Jacob Dreesen (jdreesen) - Joel Wurtz (brouznouf) - Michael Babker (mbabker) @@ -169,7 +171,6 @@ The Symfony Connect username in parenthesis allows to get more information - zairig imad (zairigimad) - Colin Frei - Javier Spagnoletti (phansys) - - Tugdual Saunier (tucksaun) - excelwebzone - Jérôme Parmentier (lctrs) - HeahDude @@ -209,6 +210,7 @@ The Symfony Connect username in parenthesis allows to get more information - Timo Bakx (timobakx) - Juti Noppornpitak (shiroyuki) - Joe Bennett (kralos) + - Hugo Alliaume (kocal) - Anthony MARTIN - Colin O'Dell (colinodell) - Sebastian Hörl (blogsh) @@ -223,16 +225,16 @@ The Symfony Connect username in parenthesis allows to get more information - Chi-teck - Guilliam Xavier - Nate Wiebe (natewiebe13) - - Hugo Alliaume (kocal) - Michael Voříšek - SpacePossum - - Antoine Lamirault + - Andreas Schempp (aschempp) - Pablo Godel (pgodel) - Romaric Drigon (romaricdrigon) - Andréia Bohner (andreia) - Jannik Zschiesche - Rafael Dohms (rdohms) - George Mponos (gmponos) + - Fritz Michael Gschwantner (fritzmg) - Aleksandar Jakovljevic (ajakov) - jwdeitch - Jurica Vlahoviček (vjurica) @@ -243,7 +245,8 @@ The Symfony Connect username in parenthesis allows to get more information - Farhad Safarov (safarov) - Jérémy Derussé - Nicolas Philippe (nikophil) - - Andreas Schempp (aschempp) + - Hubert Lenoir (hubert_lenoir) + - Florent Mata (fmata) - mcfedr (mcfedr) - Denis Brumann (dbrumann) - Maciej Malarz (malarzm) @@ -260,6 +263,7 @@ The Symfony Connect username in parenthesis allows to get more information - Dmitrii Poddubnyi (karser) - soyuka - Rouven Weßling (realityking) + - BoShurik - Zmey - Clemens Tolboom - Oleg Voronkovich @@ -269,6 +273,7 @@ The Symfony Connect username in parenthesis allows to get more information - Ben Hakim - Sylvain Fabre (sylfabre) - Filippo Tessarotto (slamdunk) + - Tom Van Looy (tvlooy) - 77web - Bohan Yang (brentybh) - Bastien Jaillot (bastnic) @@ -279,7 +284,6 @@ The Symfony Connect username in parenthesis allows to get more information - Dawid Nowak - Amal Raghav (kertz) - Jonathan Ingram - - Fritz Michael Gschwantner (fritzmg) - Artur Kotyrba - Tyson Andre - Thomas Landauer (thomas-landauer) @@ -291,11 +295,9 @@ The Symfony Connect username in parenthesis allows to get more information - Sebastien Morel (plopix) - Sergey (upyx) - Yoann RENARD (yrenard) - - BoShurik + - Thomas Lallement (raziel057) - Timothée Barray (tyx) - James Halsall (jaitsu) - - Hubert Lenoir (hubert_lenoir) - - Florent Mata (fmata) - Mikael Pajunen - Warnar Boekkooi (boekkooi) - Marco Petersen (ocrampete16) @@ -303,13 +305,13 @@ The Symfony Connect username in parenthesis allows to get more information - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) - Vilius Grigaliūnas - - Tom Van Looy (tvlooy) - Marek Štípek (maryo) - Patrick Landolt (scube) - François Pluchino (francoispluchino) - Daniel Espendiller - Arnaud PETITPAS (apetitpa) - Dorian Villet (gnutix) + - Wojciech Kania - Alexey Kopytko (sanmai) - Sergey Linnik (linniksa) - Richard Miller @@ -330,7 +332,6 @@ The Symfony Connect username in parenthesis allows to get more information - Julien Pauli - Islam Israfilov (islam93) - Oleg Andreyev (oleg.andreyev) - - Thomas Lallement (raziel057) - Daniel Gorgan - Hendrik Luup (hluup) - Martin Herndl (herndlm) @@ -366,6 +367,7 @@ The Symfony Connect username in parenthesis allows to get more information - Dominique Bongiraud - Hidde Wieringa (hiddewie) - Christopher Davis (chrisguitarguy) + - Lukáš Holeczy (holicz) - Florian Lonqueu-Brochard (florianlb) - Leszek Prabucki (l3l0) - Emanuele Panzeri (thepanz) @@ -391,7 +393,6 @@ The Symfony Connect username in parenthesis allows to get more information - Pascal Montoya - Julien Brochet - Michaël Perrin (michael.perrin) - - Wojciech Kania - Tristan Darricau (tristandsensio) - Fabien S (bafs) - Victor Bocharsky (bocharsky_bw) @@ -425,6 +426,7 @@ The Symfony Connect username in parenthesis allows to get more information - Iker Ibarguren (ikerib) - Manuel Reinhard (sprain) - Johann Pardanaud + - Alexis Lefebvre - Indra Gunawan (indragunawan) - Tim Goudriaan (codedmonkey) - Harm van Tilborg (hvt) @@ -449,7 +451,6 @@ The Symfony Connect username in parenthesis allows to get more information - Xavier Perez - Arjen Brouwer (arjenjb) - Tavo Nieves J (tavoniievez) - - Lukáš Holeczy (holicz) - Arjen van der Meijden - Patrick McDougle (patrick-mcdougle) - Jerzy (jlekowski) @@ -467,14 +468,17 @@ The Symfony Connect username in parenthesis allows to get more information - David Badura (davidbadura) - Uwe Jäger (uwej711) - Eugene Leonovich (rybakit) + - Damien Alexandre (damienalexandre) - Joseph Rouff (rouffj) - Félix Labrecque (woodspire) - GordonsLondon - Roman Anasal - Jan Sorgalla (jsor) - Piotr Kugla (piku235) + - Quynh Xuan Nguyen (seriquynh) - Ray - Philipp Cordes (corphi) + - Simon Podlipsky (simpod) - Chekote - bhavin (bhavin4u) - Pavel Popov (metaer) @@ -494,6 +498,7 @@ The Symfony Connect username in parenthesis allows to get more information - Frank de Jonge - Chris Tanaskoski - julien57 + - Loïc Frémont (loic425) - Ben Ramsey (ramsey) - Matthieu Auger (matthieuauger) - Josip Kruslin (jkruslin) @@ -505,12 +510,12 @@ The Symfony Connect username in parenthesis allows to get more information - Beau Simensen (simensen) - Robert Kiss (kepten) - Zan Baldwin (zanbaldwin) - - Alexis Lefebvre - Antonio J. García Lagar (ajgarlag) - Alexandre Quercia (alquerci) - Marcos Sánchez - Jérôme Tanghe (deuchnord) - Kim Hemsø Rasmussen (kimhemsoe) + - Maximilian Reichel (phramz) - Dane Powell - jaugustin - Dmytro Borysovskyi (dmytr0) @@ -530,7 +535,6 @@ The Symfony Connect username in parenthesis allows to get more information - Martin Kirilov (wucdbm) - Chris Smith (cs278) - Florian Klein (docteurklein) - - Damien Alexandre (damienalexandre) - Bilge - Rhodri Pugh (rodnaph) - Manuel Kiessling (manuelkiessling) @@ -544,15 +548,14 @@ The Symfony Connect username in parenthesis allows to get more information - Andrew Moore (finewolf) - Bertrand Zuchuat (garfield-fr) - Marc Morera (mmoreram) - - Quynh Xuan Nguyen (seriquynh) - Gabor Toth (tgabi333) - realmfoo - Thomas Tourlourat (armetiz) - Andrey Esaulov (andremaha) - - Simon Podlipsky (simpod) - Grégoire Passault (gregwar) - Jerzy Zawadzki (jzawadzki) - Ismael Ambrosi (iambrosi) + - Yannick Ihmels (ihmels) - Saif Eddin G - Emmanuel BORGES (eborges78) - Aurelijus Valeiša (aurelijus) @@ -566,6 +569,7 @@ The Symfony Connect username in parenthesis allows to get more information - Adrian Rudnik (kreischweide) - Pavel Batanov (scaytrase) - Francesc Rosàs (frosas) + - Andrii Dembitskyi - Bongiraud Dominique - janschoenherr - Marko Kaznovac (kaznovac) @@ -577,7 +581,6 @@ The Symfony Connect username in parenthesis allows to get more information - James Hemery - Egor Taranov - Philippe Segatori - - Loïc Frémont (loic425) - Adrian Nguyen (vuphuong87) - benjaminmal - Thierry T (lepiaf) @@ -595,6 +598,7 @@ The Symfony Connect username in parenthesis allows to get more information - Erkhembayar Gantulga (erheme318) - Fractal Zombie - Gunnstein Lye (glye) + - Thomas Talbot (ioni) - Kévin THERAGE (kevin_therage) - Noémi Salaün (noemi-salaun) - Michel Hunziker @@ -638,6 +642,7 @@ The Symfony Connect username in parenthesis allows to get more information - rtek - Inal DJAFAR (inalgnu) - Christian Gärtner (dagardner) + - Artem Stepin (astepin) - Adrien Jourdier (eclairia) - Ivan Grigoriev (greedyivan) - Tomasz Kowalczyk (thunderer) @@ -652,6 +657,7 @@ The Symfony Connect username in parenthesis allows to get more information - Thomas P - Kristijan Kanalaš (kristijan_kanalas_infostud) - Felix Labrecque + - mondrake (mondrake) - Yaroslav Kiliba - “Filip - Simon Watiau (simonwatiau) @@ -679,6 +685,7 @@ The Symfony Connect username in parenthesis allows to get more information - Dalibor Karlović - Randy Geraads - Sanpi (sanpi) + - James Gilliland (neclimdul) - Eduardo Gulias (egulias) - Andreas Leathley (iquito) - Nathanael Noblet (gnat) @@ -724,7 +731,6 @@ The Symfony Connect username in parenthesis allows to get more information - Tamas Szijarto - stlrnz - Adrien Wilmet (adrienfr) - - Yannick Ihmels (ihmels) - Alex Bacart - hugovms - Michele Locati @@ -763,7 +769,6 @@ The Symfony Connect username in parenthesis allows to get more information - Shakhobiddin - Kai - Lee Rowlands - - Maximilian Reichel (phramz) - siganushka (siganushka) - Alain Hippolyte (aloneh) - Karoly Negyesi (chx) @@ -793,7 +798,6 @@ The Symfony Connect username in parenthesis allows to get more information - Vadim Kharitonov (vadim) - Oscar Cubo Medina (ocubom) - Karel Souffriau - - Andrii Dembitskyi - Christophe L. (christophelau) - Daniël Brekelmans (dbrekelmans) - Simon Heimberg (simon_heimberg) @@ -814,12 +818,14 @@ The Symfony Connect username in parenthesis allows to get more information - Thiago Cordeiro (thiagocordeiro) - Julien Maulny - Brian King + - Paul Oms - Steffen Roßkamp - Alexandru Furculita (afurculita) - Michel Salib (michelsalib) - Valentin Jonovs - geoffrey - Bastien DURAND (deamon) + - Benoit Galati (benoitgalati) - Jon Gotlin (jongotlin) - Jeanmonod David (jeanmonod) - Daniel González (daniel.gonzalez) @@ -833,6 +839,7 @@ The Symfony Connect username in parenthesis allows to get more information - Markus Bachmann (baachi) - Roger Guasch (rogerguasch) - Luis Tacón (lutacon) + - Alex Hofbauer (alexhofbauer) - Andrii Popov (andrii-popov) - lancergr - Ivan Nikolaev (destillat) @@ -842,6 +849,7 @@ The Symfony Connect username in parenthesis allows to get more information - ampaze - Arturs Vonda - Xavier Briand (xavierbriand) + - Daniel Badura - Asmir Mustafic (goetas) - vagrant - Asier Illarramendi (doup) @@ -851,7 +859,6 @@ The Symfony Connect username in parenthesis allows to get more information - Vlad Gregurco (vgregurco) - Boris Vujicic (boris.vujicic) - Chris Sedlmayr (catchamonkey) - - mondrake (mondrake) - Kamil Kokot (pamil) - Seb Koelen - Christoph Mewes (xrstf) @@ -893,13 +900,14 @@ The Symfony Connect username in parenthesis allows to get more information - Pablo Díez (pablodip) - Damien Fa - Kevin McBride + - BrokenSourceCode - Sergio Santoro - - James Gilliland (neclimdul) - Philipp Rieber (bicpi) - Dennis Væversted (srnzitcom) - Manuel de Ruiter (manuel) - nikos.sotiropoulos - Eduardo Oliveira (entering) + - Jonathan Johnson (jrjohnson) - Eugene Wissner - Ricardo Oliveira (ricardolotr) - Roy Van Ginneken (rvanginneken) @@ -907,6 +915,7 @@ The Symfony Connect username in parenthesis allows to get more information - Barry vd. Heuvel (barryvdh) - Jon Dufresne - Chad Sikorra (chadsikorra) + - Mathias Brodala (mbrodala) - Evan S Kaufman (evanskaufman) - Jonathan Sui Lioung Lee Slew (jlslew) - mcben @@ -914,6 +923,7 @@ The Symfony Connect username in parenthesis allows to get more information - Filip Procházka (fprochazka) - stoccc - Markus Lanthaler (lanthaler) + - Gigino Chianese (sajito) - Xav` (xavismeh) - Remi Collet - Mathieu Rochette (mathroc) @@ -957,6 +967,7 @@ The Symfony Connect username in parenthesis allows to get more information - Rodrigo Borrego Bernabé (rodrigobb) - John Bafford (jbafford) - Emanuele Iannone + - Gasan Guseynov (gassan) - Ondrej Machulda (ondram) - Denis Gorbachev (starfall) - Martin Morávek (keeo) @@ -990,12 +1001,12 @@ The Symfony Connect username in parenthesis allows to get more information - Markus S. (staabm) - Geoffrey Tran (geoff) - Elan Ruusamäe (glen) + - Brad Jones - Nicolas de Marqué (nicola) - a.dmitryuk - Jannik Zschiesche - Jan Ole Behrens (deegital) - Mantas Var (mvar) - - Paul Oms - Yann LUCAS (drixs6o9) - Sebastian Krebs - Htun Htun Htet (ryanhhh91) @@ -1036,7 +1047,9 @@ The Symfony Connect username in parenthesis allows to get more information - Iliya Miroslavov Iliev (i.miroslavov) - Safonov Nikita (ns3777k) - Simon DELICATA + - Thibault Buathier (gwemox) - vitaliytv + - Arnaud Frézet - Nicolas Martin (cocorambo) - luffy1727 - LHommet Nicolas (nicolaslh) @@ -1044,7 +1057,6 @@ The Symfony Connect username in parenthesis allows to get more information - Amirreza Shafaat (amirrezashafaat) - Laurent Clouet - Adoni Pavlakis (adoni) - - Alex Hofbauer (alexhofbauer) - Maarten Nusteling (nusje2000) - Ahmed EBEN HASSINE (famas23) - Eduard Bulava (nonanerz) @@ -1096,6 +1108,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jacek Wilczyński (jacekwilczynski) - Hany el-Kerdany - Wang Jingyu + - Benjamin Georgeault (wedgesama) - Åsmund Garfors - Maxime Douailin - Jean Pasdeloup @@ -1105,6 +1118,7 @@ The Symfony Connect username in parenthesis allows to get more information - tamar peled - Reinier Kip - Geoffrey Brier (geoffrey-brier) + - Sofien Naas - Christophe Meneses (c77men) - Vladimir Tsykun - Andrei O @@ -1167,6 +1181,7 @@ The Symfony Connect username in parenthesis allows to get more information - Israel J. Carberry - Julius Kiekbusch - Miquel Rodríguez Telep (mrtorrent) + - Tamás Nagy (t-bond) - Sergey Kolodyazhnyy (skolodyazhnyy) - umpirski - Benjamin @@ -1174,6 +1189,7 @@ The Symfony Connect username in parenthesis allows to get more information - Chris Heng (gigablah) - Oleksii Svitiashchuk - Tristan Bessoussa (sf_tristanb) + - FORT Pierre-Louis (plfort) - Richard Bradley - Nathanaël Martel (nathanaelmartel) - Nicolas Jourdan (nicolasjc) @@ -1189,7 +1205,6 @@ The Symfony Connect username in parenthesis allows to get more information - Andreas Erhard (andaris) - Evgeny Efimov (edefimov) - John VanDeWeghe - - Daniel Badura - Oleg Mifle - gnito-org - Michael Devery (mickadoo) @@ -1198,6 +1213,7 @@ The Symfony Connect username in parenthesis allows to get more information - Markkus Millend - Clément - Jorrit Schippers (jorrit) + - Aurimas Niekis (aurimasniekis) - maxime.perrimond - rvoisin - cthulhu @@ -1286,6 +1302,7 @@ The Symfony Connect username in parenthesis allows to get more information - develop - flip111 - Artem Oliinyk (artemoliynyk) + - Marvin Feldmann (breyndotechse) - fruty - VJ - RJ Garcia @@ -1298,9 +1315,9 @@ The Symfony Connect username in parenthesis allows to get more information - Ondrej Exner - Mark Sonnabaum - Adiel Cristo (arcristo) - - Artem Stepin (astepin) - Fabian Kropfhamer (fabiank) - Junaid Farooq (junaidfarooq) + - Chris Jones (magikid) - Massimiliano Braglia (massimilianobraglia) - Swen van Zanten (swenvanzanten) - Frankie Wittevrongel @@ -1346,6 +1363,7 @@ The Symfony Connect username in parenthesis allows to get more information - Tayfun Aydin - Arne Groskurth - Ilya Chekalsky + - zenas1210 - Ostrzyciel - Julien DIDIER (juliendidier) - Ilia Sergunin (maranqz) @@ -1384,6 +1402,7 @@ The Symfony Connect username in parenthesis allows to get more information - BrokenSourceCode - Fabian Haase - Nikita Popov (nikic) + - Robert Fischer (sandoba) - Tarjei Huse (tarjei) - Besnik Br - Michael Olšavský @@ -1475,6 +1494,7 @@ The Symfony Connect username in parenthesis allows to get more information - Martin (meckhardt) - Radosław Kowalewski - JustDylan23 + - buffcode - Juraj Surman - Victor - Andreas Allacher @@ -1493,7 +1513,6 @@ The Symfony Connect username in parenthesis allows to get more information - John Stevenson - everyx - Stanislav Gamayunov (happyproff) - - Jonathan Johnson (jrjohnson) - Alexander McCullagh (mccullagh) - Paul L McNeely (mcneely) - Mike Meier (mykon) @@ -1504,6 +1523,7 @@ The Symfony Connect username in parenthesis allows to get more information - Francis Turmel (fturmel) - Nikita Nefedov (nikita2206) - Bernat Llibre + - Daniel Burger - cgonzalez - Ben - Joni Halme @@ -1534,6 +1554,7 @@ The Symfony Connect username in parenthesis allows to get more information - Zhuravlev Alexander (scif) - Stefano Degenkamp (steef) - James Michael DuPont + - kor3k kor3k (kor3k) - Eric Schildkamp - agaktr - Vincent CHALAMON @@ -1725,7 +1746,6 @@ The Symfony Connect username in parenthesis allows to get more information - robmro27 - Vallel Blanco - Bastien Clément - - Thomas Talbot - Benjamin Franzke - Pavinthan - Sylvain METAYER @@ -1784,7 +1804,6 @@ The Symfony Connect username in parenthesis allows to get more information - Evgeniy Koval - Claas Augner - Balazs Csaba - - Benoit Galati (benoitgalati) - Bill Hance (billhance) - Douglas Reith (douglas_reith) - Harry Walter (haswalt) @@ -1817,7 +1836,6 @@ The Symfony Connect username in parenthesis allows to get more information - Michel Bardelmeijer - Ikko Ashimine - Erwin Dirks - - Brad Jones - Markus Ramšak - den - George Dietrich @@ -1889,7 +1907,6 @@ The Symfony Connect username in parenthesis allows to get more information - Jordane VASPARD (elementaire) - Erwan Nader (ernadoo) - Faizan Akram Dar (faizanakram) - - Gasan Guseynov (gassan) - Greg Szczotka (greg606) - Ian Littman (iansltx) - Nathan DIdier (icz) @@ -1901,7 +1918,6 @@ The Symfony Connect username in parenthesis allows to get more information - Florent Viel (luxifer) - Maks 3w (maks3w) - Mamikon Arakelyan (mamikon) - - Mathias Brodala (mbrodala) - Michiel Boeckaert (milio) - Mike Milano (mmilano) - Guillaume Lajarige (molkobain) @@ -1945,21 +1961,23 @@ The Symfony Connect username in parenthesis allows to get more information - Antoine Bluchet (soyuka) - Patrick Kaufmann - Anton Dyshkant + - Kirill Nesmeyanov (serafim) - Reece Fowell (reecefowell) - Guillaume Gammelin - Valérian Galliat - d-ph - Renan Taranto (renan-taranto) - - Thomas Talbot - Rikijs Murgs - Uladzimir Tsykun - Amaury Leroux de Lens (amo__) - Christian Jul Jensen + - Franck RANAIVO-HARISOA (franckranaivo) - Alexandre GESLIN - The Whole Life to Learn - Mikkel Paulson - ergiegonzaga - Liverbool (liverbool) + - Julien Boudry - Dalibor Karlović - Sam Malone - Ha Phan (haphan) @@ -1976,15 +1994,18 @@ The Symfony Connect username in parenthesis allows to get more information - Ganesh Chandrasekaran (gxc4795) - Sander Marechal - Franz Wilding (killerpoke) + - Ferenczi Krisztian (fchris82) - Oleg Golovakhin (doc_tr) - Icode4Food (icode4food) - Radosław Benkel + - Bert ter Heide (bertterheide) - Kevin Nadin (kevinjhappy) - jean pasqualini (darkilliant) - Ross Motley (rossmotley) - ttomor - Mei Gwilym (meigwilym) - Michael H. Arieli + - Jitendra Adhikari (adhocore) - Tom Panier (neemzy) - Fred Cox - Luciano Mammino (loige) @@ -1994,8 +2015,10 @@ The Symfony Connect username in parenthesis allows to get more information - Anne-Sophie Bachelard - Marvin Butkereit - Ben Oman + - Jack Worman (jworman) - Chris de Kok - Andreas Kleemann (andesk) + - Hubert Moreau (hmoreau) - Manuele Menozzi - Anton Babenko (antonbabenko) - Irmantas Šiupšinskas (irmantas) @@ -2033,6 +2056,7 @@ The Symfony Connect username in parenthesis allows to get more information - tamirvs - gauss - julien.galenski + - Florian Guimier - Christian Neff (secondtruth) - Chris Tiearney - Oliver Hoff @@ -2043,6 +2067,7 @@ The Symfony Connect username in parenthesis allows to get more information - Goran Juric - Laurent G. (laurentg) - Nicolas Macherey + - Bhujagendra Ishaya - Guido Donnari - Mert Simsek (mrtsmsk0) - Lin Clark @@ -2070,12 +2095,12 @@ The Symfony Connect username in parenthesis allows to get more information - Paul Mitchum (paul-m) - Angel Koilov (po_taka) - Dan Finnie - - Sofien Naas - Ken Marfilla (marfillaster) - Max Grigorian (maxakawizard) - benatespina (benatespina) - Denis Kop - Jean-Guilhem Rouel (jean-gui) + - Ivan Yivoff - EdgarPE - jfcixmedia - Dominic Tubach @@ -2086,11 +2111,11 @@ The Symfony Connect username in parenthesis allows to get more information - Serge (nfx) - Mikkel Paulson - Michał Strzelecki - - Aurimas Niekis (aurimasniekis) - Hugo Fonseca (fonsecas72) - Martynas Narbutas - Bailey Parker - Antanas Arvasevicius + - Kris Kelly - Eddie Abou-Jaoude (eddiejaoude) - Haritz Iturbe (hizai) - Nerijus Arlauskas (nercury) @@ -2113,7 +2138,6 @@ The Symfony Connect username in parenthesis allows to get more information - Jonathan Hedstrom - Peter Smeets (darkspartan) - Julien Bianchi (jubianchi) - - Tamás Nagy (t-bond) - Robert Meijers - Tijs Verkoyen - James Sansbury @@ -2177,6 +2201,7 @@ The Symfony Connect username in parenthesis allows to get more information - Oxan van Leeuwen - pkowalczyk - Soner Sayakci + - Andreas Hennings - Max Voloshin (maxvoloshin) - Nicolas Fabre (nfabre) - Raul Rodriguez (raul782) @@ -2184,11 +2209,11 @@ The Symfony Connect username in parenthesis allows to get more information - MightyBranch - Kacper Gunia (cakper) - Derek Lambert (dlambert) + - Mark Pedron (markpedron) - Peter Thompson (petert82) - error56 - Felicitus - alexpozzi - - Marvin Feldmann (breyndotechse) - Krzysztof Przybyszewski (kprzybyszewski) - Boullé William (williamboulle) - Frederic Godfrin @@ -2226,7 +2251,9 @@ The Symfony Connect username in parenthesis allows to get more information - Jelte Steijaert (jelte) - David Négrier (moufmouf) - Quique Porta (quiqueporta) + - Tobias Feijten (tobias93) - Andrea Quintino (dirk39) + - Andreas Heigl (heiglandreas) - Tomasz Szymczyk (karion) - Peter Dietrich (xosofox) - Alex Vasilchenko @@ -2249,7 +2276,9 @@ The Symfony Connect username in parenthesis allows to get more information - Ross Tuck - omniError - Zander Baldwin + - László GÖRÖG - Kévin Gomez (kevin) + - Kevin van Sonsbeek (kevin_van_sonsbeek) - Mihai Nica (redecs) - Andrei Igna - azine @@ -2299,8 +2328,8 @@ The Symfony Connect username in parenthesis allows to get more information - Steve Frécinaux - Constantine Shtompel - Jules Lamur - - zenas1210 - Renato Mendes Figueiredo + - Raphaël Droz - Eric Stern - ShiraNai7 - Antal Áron (antalaron) @@ -2318,6 +2347,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jason Desrosiers - m.chwedziak - Andreas Frömer + - Bikal Basnet - Philip Frank - Lance McNearney - Illia Antypenko (aivus) @@ -2339,10 +2369,10 @@ The Symfony Connect username in parenthesis allows to get more information - Martin Pärtel - Frédéric Bouchery (fbouchery) - Patrick Daley (padrig) + - Phillip Look (plook) - Max Summe - Ema Panz - Chihiro Adachi (chihiro-adachi) - - Benjamin Georgeault (wedgesama) - Raphaëll Roussel - Tadcka - Abudarham Yuval @@ -2400,6 +2430,7 @@ The Symfony Connect username in parenthesis allows to get more information - Michael Lively (mlivelyjr) - Abderrahim (phydev) - Attila Bukor (r1pp3rj4ck) + - Thomas Boileau (tboileau) - Thomas Chmielowiec (chmielot) - Jānis Lukss - rkerner @@ -2410,6 +2441,7 @@ The Symfony Connect username in parenthesis allows to get more information - AnrDaemon - Charly Terrier (charlypoppins) - Emre Akinci (emre) + - Rustam Bakeev (nommyde) - psampaz (psampaz) - Maxwell Vandervelde - kaywalker @@ -2441,7 +2473,6 @@ The Symfony Connect username in parenthesis allows to get more information - Ciaran McNulty (ciaranmcnulty) - Andrew (drew) - j4nr6n (j4nr6n) - - kor3k kor3k (kor3k) - Stelian Mocanita (stelian) - Gautier Deuette - Kirk Madera @@ -2469,6 +2500,7 @@ The Symfony Connect username in parenthesis allows to get more information - georaldc - wusuopu - Wouter de Wild + - Peter Potrowl - povilas - Gavin Staniforth - Alessandro Tagliapietra (alex88) @@ -2495,6 +2527,7 @@ The Symfony Connect username in parenthesis allows to get more information - Martin Schophaus (m_schophaus_adcada) - Martynas Sudintas (martiis) - Anton Sukhachev (mrsuh) + - Marcel Siegert - ryunosuke - Francisco Facioni (fran6co) - Iwan van Staveren (istaveren) @@ -2513,12 +2546,14 @@ The Symfony Connect username in parenthesis allows to get more information - Matt Farmer - catch - Alexandre Segura + - Asier Etxebeste - Josef Cech - Andrii Boiko - Harold Iedema - Ikhsan Agustian - Benoit Lévêque (benoit_leveque) - Simon Bouland (bouland) + - Jakub Janata (janatjak) - Jibé Barth (jibbarth) - Matthew Foster (mfoster) - Reyo Stallenberg (reyostallenberg) @@ -2552,6 +2587,7 @@ The Symfony Connect username in parenthesis allows to get more information - Houziaux mike - Phobetor - Markus + - Janusz Mocek - Thomas Chmielowiec - shdev - Andrey Ryaguzov @@ -2569,6 +2605,7 @@ The Symfony Connect username in parenthesis allows to get more information - František Bereň - Jeremiah VALERIE - Mike Francis + - Nil Borodulia - Almog Baku (almogbaku) - Gerd Christian Kunze (derdu) - Ionel Scutelnicu (ionelscutelnicu) @@ -2578,6 +2615,7 @@ The Symfony Connect username in parenthesis allows to get more information - Nick Stemerdink - David Stone - Grayson Koonce + - Wissame MEKHILEF - Romain Dorgueil - Christopher Parotat - Dennis Haarbrink @@ -2598,6 +2636,7 @@ The Symfony Connect username in parenthesis allows to get more information - Felix Marezki - Normunds - Thomas Rothe + - Troy Crawford - nietonfir - alefranz - David Barratt @@ -2623,6 +2662,7 @@ The Symfony Connect username in parenthesis allows to get more information - efeen - Nicolas Pion - Muhammed Akbulut + - Xesau - Aaron Somi - Michał Dąbrowski (defrag) - Simone Fumagalli (hpatoio) @@ -2644,10 +2684,12 @@ The Symfony Connect username in parenthesis allows to get more information - Gijs Kunze - Artyom Protaskin - Nathanael d. Noblet + - Yurun - helmer - ged15 - Simon Asika - Daan van Renterghem + - Boudry Julien - amcastror - Bram Van der Sype (brammm) - Guile (guile) @@ -2723,6 +2765,7 @@ The Symfony Connect username in parenthesis allows to get more information - Rémi Blaise - Nicolas Séverin - Joel Marcey + - zolikonta - David Christmann - root - pf @@ -2764,8 +2807,10 @@ The Symfony Connect username in parenthesis allows to get more information - Jelle Kapitein - Jochen Mandl - Marin Nicolae + - Albert Prat - Alessandro Loffredo - Ian Phillips + - Remi Collet - Haritz - Matthieu Prat - Brieuc Thomas @@ -2791,6 +2836,7 @@ The Symfony Connect username in parenthesis allows to get more information - Erik van Wingerden - Valouleloup - Alexis MARQUIS + - Matheus Gontijo - Gerrit Drost - Linnaea Von Lavia - Simon Mönch @@ -2810,6 +2856,8 @@ The Symfony Connect username in parenthesis allows to get more information - Rafał - Adria Lopez (adlpz) - Aaron Scherer (aequasi) + - Alexandre Jardin (alexandre.jardin) + - Bart Brouwer (bartbrouwer) - Rosio (ben-rosio) - Simon Paarlberg (blamh) - Masao Maeda (brtriver) @@ -2836,6 +2884,7 @@ The Symfony Connect username in parenthesis allows to get more information - Kevin Verschaeve (keversc) - Kevin Herrera (kherge) - Luis Ramón López López (lrlopez) + - Matheo Daninos (mathdns) - Mehdi Mabrouk (mehdidev) - Bart Reunes (metalarend) - Muriel (metalmumu) @@ -2847,6 +2896,7 @@ The Symfony Connect username in parenthesis allows to get more information - Olivier Laviale (olvlvl) - Pablo Monterde Perez (plebs) - Jimmy Leger (redpanda) + - Mokhtar Tlili (sf-djuba) - Marcin Szepczynski (szepczynski) - Simone Di Maulo (toretto460) - Cyrille Jouineau (tuxosaurus) @@ -2861,6 +2911,7 @@ The Symfony Connect username in parenthesis allows to get more information - Taylan Kasap - Michael Orlitzky - Nicolas A. Bérard-Nault + - Francois Martin - Saem Ghani - Stefan Oderbolz - Gabriel Moreira @@ -2901,6 +2952,7 @@ The Symfony Connect username in parenthesis allows to get more information - temperatur - Paul Andrieux - Cas + - Gwendolen Lynch - ghazy ben ahmed - Karolis - Myke79 @@ -2941,6 +2993,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jack Wright - MrNicodemuz - Anonymous User + - demeritcowboy - Paweł Tomulik - Eric J. Duran - Blackfelix @@ -3025,7 +3078,9 @@ The Symfony Connect username in parenthesis allows to get more information - Yurii K - Richard Trebichavský - g123456789l + - Mark Ogilvie - Jonathan Vollebregt + - Vladimir Vasilev - oscartv - DanSync - Peter Zwosta @@ -3053,6 +3108,7 @@ The Symfony Connect username in parenthesis allows to get more information - sualko - ADmad - Nicolas Roudaire + - Abdouni Karim (abdounikarim) - Andreas Forsblom (aforsblo) - Alex Olmos (alexolmos) - Cedric BERTOLINI (alsciende) @@ -3150,6 +3206,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jesper Søndergaard Pedersen (zerrvox) - Florent Cailhol - szymek + - Konrad - Kovacs Nicolas - craigmarvelley - Stano Turza diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php index d259e4123976a..24024cefd14c8 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -59,7 +59,7 @@ public function addLogger($name, DebugStack $logger) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $queries = []; foreach ($this->loggers as $name => $logger) { diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 383462ca95ee7..2d9302ac141ea 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -345,7 +345,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance); $cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))]); break; - case 'redis': + case 'redis': $redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%'; $redisInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.redis_instance.class').'%'; $redisHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.redis_host').'%'; diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php index c5ff1aa3674f1..944c305ab70a7 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php @@ -60,12 +60,15 @@ public function guessType($class, $property) switch ($metadata->getTypeOfField($property)) { case self::$useDeprecatedConstants ? Type::TARRAY : Types::ARRAY: + // no break case self::$useDeprecatedConstants ? Type::SIMPLE_ARRAY : Types::SIMPLE_ARRAY: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', [], Guess::MEDIUM_CONFIDENCE); case self::$useDeprecatedConstants ? Type::BOOLEAN : Types::BOOLEAN: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::HIGH_CONFIDENCE); case self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE: + // no break case self::$useDeprecatedConstants ? Type::DATETIMETZ : Types::DATETIMETZ_MUTABLE: + // no break case 'vardatetime': return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE); case 'datetime_immutable': @@ -86,7 +89,9 @@ public function guessType($class, $property) case self::$useDeprecatedConstants ? Type::FLOAT : Types::FLOAT: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', [], Guess::MEDIUM_CONFIDENCE); case self::$useDeprecatedConstants ? Type::INTEGER : Types::INTEGER: + // no break case self::$useDeprecatedConstants ? Type::BIGINT : Types::BIGINT: + // no break case self::$useDeprecatedConstants ? Type::SMALLINT : Types::SMALLINT: return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', [], Guess::MEDIUM_CONFIDENCE); case self::$useDeprecatedConstants ? Type::STRING : Types::STRING: diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 0c7c48d1c0968..4391411a94a76 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -114,16 +114,16 @@ public function getTypes($class, $property, array $context = []) $fieldName = $associationMapping['indexBy']; if (null === ($typeOfField = $subMetadata->getTypeOfField($fieldName))) { $fieldName = $subMetadata->getFieldForColumn($associationMapping['indexBy']); - //Not a property, maybe a column name? + // Not a property, maybe a column name? if (null === ($typeOfField = $subMetadata->getTypeOfField($fieldName))) { - //Maybe the column name is the association join column? + // Maybe the column name is the association join column? $associationMapping = $subMetadata->getAssociationMapping($fieldName); /** @var ClassMetadataInfo $subMetadata */ $indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName); $subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']); - //Not a property, maybe a column name? + // Not a property, maybe a column name? if (null === ($typeOfField = $subMetadata->getTypeOfField($indexProperty))) { $fieldName = $subMetadata->getFieldForColumn($indexProperty); $typeOfField = $subMetadata->getTypeOfField($fieldName); @@ -168,8 +168,11 @@ public function getTypes($class, $property, array $context = []) case Type::BUILTIN_TYPE_OBJECT: switch ($typeOfField) { case self::$useDeprecatedConstants ? DBALType::DATE : Types::DATE_MUTABLE: + // no break case self::$useDeprecatedConstants ? DBALType::DATETIME : Types::DATETIME_MUTABLE: + // no break case self::$useDeprecatedConstants ? DBALType::DATETIMETZ : Types::DATETIMETZ_MUTABLE: + // no break case 'vardatetime': case self::$useDeprecatedConstants ? DBALType::TIME : Types::TIME_MUTABLE: return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')]; @@ -188,6 +191,7 @@ public function getTypes($class, $property, array $context = []) case Type::BUILTIN_TYPE_ARRAY: switch ($typeOfField) { case self::$useDeprecatedConstants ? DBALType::TARRAY : Types::ARRAY: + // no break case 'json_array': // return null if $enumType is set, because we can't determine if collectionKeyType is string or int if ($enumType) { @@ -279,6 +283,7 @@ private function getPhpType(string $doctrineType): ?string { switch ($doctrineType) { case self::$useDeprecatedConstants ? DBALType::SMALLINT : Types::SMALLINT: + // no break case self::$useDeprecatedConstants ? DBALType::INTEGER : Types::INTEGER: return Type::BUILTIN_TYPE_INT; @@ -286,9 +291,13 @@ private function getPhpType(string $doctrineType): ?string return Type::BUILTIN_TYPE_FLOAT; case self::$useDeprecatedConstants ? DBALType::BIGINT : Types::BIGINT: + // no break case self::$useDeprecatedConstants ? DBALType::STRING : Types::STRING: + // no break case self::$useDeprecatedConstants ? DBALType::TEXT : Types::TEXT: + // no break case self::$useDeprecatedConstants ? DBALType::GUID : Types::GUID: + // no break case self::$useDeprecatedConstants ? DBALType::DECIMAL : Types::DECIMAL: return Type::BUILTIN_TYPE_STRING; @@ -296,15 +305,21 @@ private function getPhpType(string $doctrineType): ?string return Type::BUILTIN_TYPE_BOOL; case self::$useDeprecatedConstants ? DBALType::BLOB : Types::BLOB: + // no break case 'binary': return Type::BUILTIN_TYPE_RESOURCE; case self::$useDeprecatedConstants ? DBALType::OBJECT : Types::OBJECT: + // no break case self::$useDeprecatedConstants ? DBALType::DATE : Types::DATE_MUTABLE: + // no break case self::$useDeprecatedConstants ? DBALType::DATETIME : Types::DATETIME_MUTABLE: + // no break case self::$useDeprecatedConstants ? DBALType::DATETIMETZ : Types::DATETIMETZ_MUTABLE: + // no break case 'vardatetime': case self::$useDeprecatedConstants ? DBALType::TIME : Types::TIME_MUTABLE: + // no break case 'date_immutable': case 'datetime_immutable': case 'datetimetz_immutable': @@ -313,7 +328,9 @@ private function getPhpType(string $doctrineType): ?string return Type::BUILTIN_TYPE_OBJECT; case self::$useDeprecatedConstants ? DBALType::TARRAY : Types::ARRAY: + // no break case self::$useDeprecatedConstants ? DBALType::SIMPLE_ARRAY : Types::SIMPLE_ARRAY: + // no break case 'json_array': return Type::BUILTIN_TYPE_ARRAY; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php index 29da316d20feb..535795f061060 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php @@ -315,8 +315,8 @@ public function testLoadChoicesForValuesLoadsOnlyChoicesIfSingleIntId() $this->assertSame( [4 => $this->obj3, 7 => $this->obj2], - $loader->loadChoicesForValues([4 => '3', 7 => '2'] - )); + $loader->loadChoicesForValues([4 => '3', 7 => '2']) + ); } public function testLoadChoicesForValuesLoadsAllIfSingleIntIdAndValueGiven() diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index 32caea8bd3093..bd1a26487a6b5 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -185,9 +185,9 @@ public function testExtractEnum() } $this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', [])); $this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumInt', [])); - $this->assertEquals(null, $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', [])); + $this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', [])); $this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class))], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumIntArray', [])); - $this->assertEquals(null, $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', [])); + $this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', [])); } public function typesProvider() diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 00fb4bc8a2433..68d8d8e339590 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -196,7 +196,7 @@ public function shutdown() if (class_exists(DebugClassLoader::class, false)) { DebugClassLoader::checkClasses(); } - $currErrorHandler = set_error_handler('var_dump'); + $currErrorHandler = set_error_handler('is_int'); restore_error_handler(); if ($currErrorHandler !== [$this, 'handleError']) { diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index e7c3da2b8d7a3..fe776b90d3df1 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -66,14 +66,14 @@ $phpunitConfigFilename = $phpunitConfigFilename ?: $getPhpUnitConfig('phpunit.xml'); if ($phpunitConfigFilename) { - $phpunitConfig = new DomDocument(); + $phpunitConfig = new DOMDocument(); $phpunitConfig->load($phpunitConfigFilename); } else { $phpunitConfig = false; } } if (false !== $phpunitConfig) { - $var = new DOMXpath($phpunitConfig); + $var = new DOMXPath($phpunitConfig); foreach ($var->query('//php/server[@name="'.$name.'"]') as $var) { return $var->getAttribute('value'); } diff --git a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php index fd6bc2d1e2663..c81d16c9606a4 100644 --- a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php +++ b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php @@ -45,7 +45,7 @@ public function __construct(Profile $profile, Environment $twig = null) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { } diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 54b43caca2cb3..eeea01d84532e 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -35,7 +35,7 @@ class CodeExtension extends AbstractExtension */ public function __construct($fileLinkFormat, string $projectDir, string $charset) { - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); + $this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->projectDir = str_replace('\\', '/', $projectDir).'/'; $this->charset = $charset; } @@ -241,7 +241,7 @@ public function formatLogMessage(string $message, array $context): string if ($context && str_contains($message, '{')) { $replacements = []; foreach ($context as $key => $val) { - if (is_scalar($val)) { + if (\is_scalar($val)) { $replacements['{'.$key.'}'] = $val; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php index 69064a003d7fe..05fe771254894 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php @@ -21,7 +21,7 @@ public function testLabelOnForm() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/label + '/label [@class="col-sm-2 control-label required"] [.="[trans]Name[/trans]"] ' @@ -38,7 +38,7 @@ public function testLabelDoesNotRenderFieldAttributes() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="col-sm-2 control-label required"] ' @@ -55,7 +55,7 @@ public function testLabelWithCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class col-sm-2 control-label required"] ' @@ -72,7 +72,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class col-sm-2 control-label required"] [.="[trans]Custom label[/trans]"] @@ -92,7 +92,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class col-sm-2 control-label required"] [.="[trans]Custom label[/trans]"] @@ -170,7 +170,7 @@ public function testCheckboxRowWithHelp() $html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']); $this->assertMatchesXpath($html, -'/div + '/div [@class="form-group"] [ ./div[@class="col-sm-2" or @class="col-sm-10"] diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index eb40559ef6b55..7c06163806af0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -25,7 +25,7 @@ public function testLabelOnForm() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/label + '/label [@class="control-label required"] [.="[trans]Name[/trans]"] ' @@ -42,7 +42,7 @@ public function testLabelDoesNotRenderFieldAttributes() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="control-label required"] ' @@ -59,7 +59,7 @@ public function testLabelWithCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class control-label required"] ' @@ -76,7 +76,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class control-label required"] [.="[trans]Custom label[/trans]"] @@ -96,7 +96,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class control-label required"] [.="[trans]Custom label[/trans]"] @@ -113,7 +113,7 @@ public function testHelp() $html = $this->renderHelp($view); $this->assertMatchesXpath($html, -'/span + '/span [@id="name_help"] [@class="help-block"] [.="[trans]Help text test![/trans]"] @@ -233,7 +233,7 @@ public function testErrors() $html = $this->renderErrors($view); $this->assertMatchesXpath($html, -'/div + '/div [@class="alert alert-danger"] [ ./ul @@ -263,7 +263,7 @@ public function testOverrideWidgetBlock() $html = $this->renderWidget($form->createView()); $this->assertMatchesXpath($html, -'/div + '/div [ ./input [@type="text"] @@ -280,7 +280,7 @@ public function testCheckedCheckbox() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="checkbox"] [ ./label @@ -298,7 +298,7 @@ public function testUncheckedCheckbox() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="checkbox"] [ ./label @@ -318,7 +318,7 @@ public function testCheckboxWithValue() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="checkbox"] [ ./label @@ -337,7 +337,7 @@ public function testCheckboxRowWithHelp() $html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']); $this->assertMatchesXpath($html, -'/div + '/div [@class="form-group"] [ ./span[text() = "[trans]really helpful text[/trans]"] @@ -355,7 +355,7 @@ public function testSingleChoice() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -378,7 +378,7 @@ public function testSingleChoiceAttributesWithMainAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], -'/select + '/select [@name="name"] [@class="bar&baz form-control"] [not(@required)] @@ -401,7 +401,7 @@ public function testSingleExpandedChoiceAttributesWithMainAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], -'/div + '/div [@class="bar&baz"] [ ./div @@ -438,7 +438,7 @@ public function testSelectWithSizeBiggerThanOneCanBeRequired() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => '']], -'/select + '/select [@name="name"] [@required="required"] [@size="2"] @@ -457,7 +457,7 @@ public function testSingleChoiceWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -482,7 +482,7 @@ public function testSingleChoiceWithPlaceholderWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -506,7 +506,7 @@ public function testSingleChoiceAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -529,7 +529,7 @@ public function testSingleChoiceWithPreferred() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --', 'attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -554,7 +554,7 @@ public function testSingleChoiceWithSelectedPreferred() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --', 'attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -579,7 +579,7 @@ public function testSingleChoiceWithPreferredAndNoSeparator() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => null, 'attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -603,7 +603,7 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '', 'attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -628,7 +628,7 @@ public function testChoiceWithOnlyPreferred() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@class="my&class form-control"] [count(./option)=5] ' @@ -645,7 +645,7 @@ public function testSingleChoiceNonRequired() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -669,7 +669,7 @@ public function testSingleChoiceNonRequiredNoneSelected() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -694,7 +694,7 @@ public function testSingleChoiceNonRequiredWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -719,7 +719,7 @@ public function testSingleChoiceRequiredWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [@required="required"] @@ -743,7 +743,7 @@ public function testSingleChoiceRequiredWithPlaceholderViaView() ]); $this->assertWidgetMatchesXpath($form->createView(), ['placeholder' => '', 'attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [@required="required"] @@ -769,7 +769,7 @@ public function testSingleChoiceGrouped() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [./optgroup[@label="[trans]Group&1[/trans]"] @@ -798,7 +798,7 @@ public function testMultipleChoice() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name[]"] [@class="my&class form-control"] [@required="required"] @@ -823,7 +823,7 @@ public function testMultipleChoiceAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name[]"] [@class="my&class form-control"] [@required="required"] @@ -847,7 +847,7 @@ public function testMultipleChoiceSkipsPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name[]"] [@class="my&class form-control"] [@multiple="multiple"] @@ -870,7 +870,7 @@ public function testMultipleChoiceNonRequired() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name[]"] [@class="my&class form-control"] [@multiple="multiple"] @@ -892,7 +892,7 @@ public function testSingleChoiceExpanded() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -928,7 +928,7 @@ public function testSingleChoiceExpandedWithLabelsAsFalse() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -968,7 +968,7 @@ public function testSingleChoiceExpandedWithLabelsSetByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1014,7 +1014,7 @@ public function testSingleChoiceExpandedWithLabelsSetFalseByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1048,7 +1048,7 @@ public function testSingleChoiceExpandedWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1084,7 +1084,7 @@ public function testSingleChoiceExpandedAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1121,7 +1121,7 @@ public function testSingleChoiceExpandedWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1168,7 +1168,7 @@ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1212,7 +1212,7 @@ public function testSingleChoiceExpandedWithBooleanValue() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="radio"] @@ -1248,7 +1248,7 @@ public function testMultipleChoiceExpanded() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="checkbox"] @@ -1293,7 +1293,7 @@ public function testMultipleChoiceExpandedWithLabelsAsFalse() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="checkbox"] @@ -1379,7 +1379,7 @@ public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="checkbox"] @@ -1414,7 +1414,7 @@ public function testMultipleChoiceExpandedWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="checkbox"] @@ -1460,7 +1460,7 @@ public function testMultipleChoiceExpandedAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="checkbox"] @@ -1500,7 +1500,7 @@ public function testCountry() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [./option[@value="AT"][@selected="selected"][.="Austria"]] @@ -1517,7 +1517,7 @@ public function testCountryWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]] @@ -1535,7 +1535,7 @@ public function testDateTime() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [ ./select [@id="name_date_month"] @@ -1572,7 +1572,7 @@ public function testDateTimeWithPlaceholderGlobal() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1611,7 +1611,7 @@ public function testDateTimeWithHourAndMinute() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1648,7 +1648,7 @@ public function testDateTimeWithSeconds() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1690,7 +1690,7 @@ public function testDateTimeSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./input @@ -1720,7 +1720,7 @@ public function testDateTimeWithWidgetSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="datetime-local"] [@name="name"] [@class="my&class form-control"] @@ -1744,7 +1744,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="datetime-local"] [@name="name"] [@class="my&class form-control"] @@ -1761,7 +1761,7 @@ public function testDateChoice() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1792,7 +1792,7 @@ public function testDateChoiceWithPlaceholderGlobal() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1823,7 +1823,7 @@ public function testDateChoiceWithPlaceholderOnYear() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1852,7 +1852,7 @@ public function testDateText() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./input @@ -1884,7 +1884,7 @@ public function testDateSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="date"] [@name="name"] [@class="my&class form-control"] @@ -1900,7 +1900,7 @@ public function testBirthDay() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1930,7 +1930,7 @@ public function testBirthDayWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -1959,7 +1959,7 @@ public function testEmail() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="email"] [@name="name"] [@class="my&class form-control"] @@ -1976,7 +1976,7 @@ public function testEmailWithMaxLength() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="email"] [@name="name"] [@class="my&class form-control"] @@ -1991,7 +1991,7 @@ public function testHidden() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="hidden"] [@name="name"] [@class="my&class"] @@ -2007,7 +2007,7 @@ public function testDisabled() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="text"] [@name="name"] [@class="my&class form-control"] @@ -2021,7 +2021,7 @@ public function testInteger() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="number"] [@name="name"] [@class="my&class form-control"] @@ -2037,7 +2037,7 @@ public function testIntegerTypeWithGroupingRendersAsTextInput() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="text"] [@name="name"] [@class="my&class form-control"] @@ -2051,7 +2051,7 @@ public function testLanguage() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [./option[@value="de"][@selected="selected"][.="German"]] @@ -2065,7 +2065,7 @@ public function testLocale() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [./option[@value="de_AT"][@selected="selected"][.="German (Austria)"]] @@ -2081,7 +2081,7 @@ public function testMoney() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="input-group"] [ ./span @@ -2105,7 +2105,7 @@ public function testMoneyWithoutCurrency() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/input + '/input [@id="my&id"] [@type="text"] [@name="name"] @@ -2122,7 +2122,7 @@ public function testNumber() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="text"] [@name="name"] [@class="my&class form-control"] @@ -2152,7 +2152,7 @@ public function testPassword() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="password"] [@name="name"] [@class="my&class form-control"] @@ -2168,7 +2168,7 @@ public function testPasswordSubmittedWithNotAlwaysEmpty() $form->submit('foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="password"] [@name="name"] [@class="my&class form-control"] @@ -2184,7 +2184,7 @@ public function testPasswordWithMaxLength() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="password"] [@name="name"] [@class="my&class form-control"] @@ -2198,7 +2198,7 @@ public function testPercent() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="input-group"] [ ./input @@ -2219,7 +2219,7 @@ public function testPercentNoSymbol() { $form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => false]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/input + '/input [@id="my&id"] [@type="text"] [@name="name"] @@ -2233,7 +2233,7 @@ public function testPercentCustomSymbol() { $form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => '‱']); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="input-group"] [ ./input @@ -2255,7 +2255,7 @@ public function testCheckedRadio() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="radio"] [ ./label @@ -2279,7 +2279,7 @@ public function testUncheckedRadio() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="radio"] [ ./label @@ -2304,7 +2304,7 @@ public function testRadioWithValue() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="radio"] [ ./label @@ -2328,7 +2328,7 @@ public function testRadioRowWithHelp() $html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']); $this->assertMatchesXpath($html, -'/div + '/div [@class="form-group"] [ ./span[text() = "[trans]really helpful text[/trans]"] @@ -2342,7 +2342,7 @@ public function testRange() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5]]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="range"] [@name="name"] [@value="42"] @@ -2357,7 +2357,7 @@ public function testRangeWithMinMaxValues() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5, 'max' => 57]]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="range"] [@name="name"] [@value="42"] @@ -2375,7 +2375,7 @@ public function testTextarea() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/textarea + '/textarea [@name="name"] [not(@pattern)] [@class="my&class form-control"] @@ -2389,7 +2389,7 @@ public function testText() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="text"] [@name="name"] [@class="my&class form-control"] @@ -2406,7 +2406,7 @@ public function testTextWithMaxLength() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="text"] [@name="name"] [@class="my&class form-control"] @@ -2421,7 +2421,7 @@ public function testSearch() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="search"] [@name="name"] [@class="my&class form-control"] @@ -2439,7 +2439,7 @@ public function testTime() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -2466,7 +2466,7 @@ public function testTimeWithSeconds() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -2501,7 +2501,7 @@ public function testTimeText() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./input @@ -2534,7 +2534,7 @@ public function testTimeSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="time"] [@name="name"] [@class="my&class form-control"] @@ -2553,7 +2553,7 @@ public function testTimeWithPlaceholderGlobal() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -2580,7 +2580,7 @@ public function testTimeWithPlaceholderOnYear() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/div + '/div [@class="my&class form-inline"] [ ./select @@ -2603,7 +2603,7 @@ public function testTimezone() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna'); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@name="name"] [@class="my&class form-control"] [not(@required)] @@ -2621,7 +2621,7 @@ public function testTimezoneWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/select + '/select [@class="my&class form-control"] [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] [count(.//option)>201] @@ -2635,7 +2635,7 @@ public function testUrlWithDefaultProtocol() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => 'http']); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="text"] [@name="name"] [@class="my&class form-control"] diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php index e20f4818b2810..51aa10e416d88 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php @@ -53,7 +53,7 @@ public function testLabelOnForm() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/legend + '/legend [@class="col-form-label col-sm-2 col-form-label required"] [.="[trans]Name[/trans]"] ' @@ -70,7 +70,7 @@ public function testLabelDoesNotRenderFieldAttributes() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="col-form-label col-sm-2 required"] ' @@ -87,7 +87,7 @@ public function testLabelWithCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class col-form-label col-sm-2 required"] ' @@ -104,7 +104,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class col-form-label col-sm-2 required"] [.="[trans]Custom label[/trans]"] @@ -124,7 +124,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class col-form-label col-sm-2 required"] [.="[trans]Custom label[/trans]"] @@ -144,7 +144,7 @@ public function testLegendOnExpandedType() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/legend + '/legend [@class="col-sm-2 col-form-label required"] [.="[trans]Custom label[/trans]"] ' @@ -222,7 +222,7 @@ public function testCheckboxRowWithHelp() $html = $this->renderRow($view, ['label' => 'foo', 'help' => 'really helpful text']); $this->assertMatchesXpath($html, -'/div + '/div [@class="form-group row"] [ ./div[@class="col-sm-2" or @class="col-sm-10"] @@ -241,7 +241,7 @@ public function testRadioRowWithHelp() $html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']); $this->assertMatchesXpath($html, -'/div + '/div [@class="form-group row"] [ ./div[@class="col-sm-2" or @class="col-sm-10"] diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php index 224469a516f2e..3e02351c4f9f4 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php @@ -63,7 +63,7 @@ public function testLabelOnForm() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/legend + '/legend [@class="col-form-label required"] [.="[trans]Name[/trans]"] ' @@ -80,7 +80,7 @@ public function testLabelDoesNotRenderFieldAttributes() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="required"] ' @@ -97,7 +97,7 @@ public function testLabelWithCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class required"] ' @@ -114,7 +114,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class required"] [.="[trans]Custom label[/trans]"] @@ -134,7 +134,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class required"] [.="[trans]Custom label[/trans]"] @@ -154,7 +154,7 @@ public function testLegendOnExpandedType() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/legend + '/legend [@class="col-form-label required"] [.="[trans]Custom label[/trans]"] ' @@ -170,7 +170,7 @@ public function testHelp() $html = $this->renderHelp($view); $this->assertMatchesXpath($html, -'/small + '/small [@id="name_help"] [@class="form-text text-muted"] [.="[trans]Help text test![/trans]"] @@ -290,7 +290,7 @@ public function testErrors() $html = $this->renderErrors($view); $this->assertMatchesXpath($html, -'/span + '/span [@class="alert alert-danger d-block"] [ ./span[@class="d-block"] @@ -321,7 +321,7 @@ public function testCheckedCheckbox() $form = $this->factory->createNamed('name', CheckboxType::class, true); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="form-check"] [ ./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class form-check-input"][@checked="checked"][@value="1"] @@ -343,7 +343,7 @@ public function testSingleChoiceAttributesWithMainAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], -'/select + '/select [@name="name"] [@class="bar&baz form-control"] [not(@required)] @@ -366,7 +366,7 @@ public function testSingleExpandedChoiceAttributesWithMainAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], -'/div + '/div [@class="bar&baz"] [ ./div @@ -394,7 +394,7 @@ public function testUncheckedCheckbox() $form = $this->factory->createNamed('name', CheckboxType::class, false); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="form-check"] [ ./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class form-check-input"][not(@checked)] @@ -412,7 +412,7 @@ public function testCheckboxWithValue() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="form-check"] [ ./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class form-check-input"][@value="foo&bar"] @@ -447,7 +447,7 @@ public function testSingleChoiceExpanded() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -479,7 +479,7 @@ public function testSingleChoiceExpandedWithLabelsAsFalse() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -515,7 +515,7 @@ public function testSingleChoiceExpandedWithLabelsSetByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -555,7 +555,7 @@ public function testSingleChoiceExpandedWithLabelsSetFalseByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -585,7 +585,7 @@ public function testSingleChoiceExpandedWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -617,7 +617,7 @@ public function testSingleChoiceExpandedAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -650,7 +650,7 @@ public function testSingleChoiceExpandedWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -691,7 +691,7 @@ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -729,7 +729,7 @@ public function testSingleChoiceExpandedWithBooleanValue() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -761,7 +761,7 @@ public function testMultipleChoiceExpanded() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -800,7 +800,7 @@ public function testMultipleChoiceExpandedWithLabelsAsFalse() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -876,7 +876,7 @@ public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -907,7 +907,7 @@ public function testMultipleChoiceExpandedWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -947,7 +947,7 @@ public function testMultipleChoiceExpandedAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@class="form-check"] @@ -981,7 +981,7 @@ public function testCheckedRadio() $form = $this->factory->createNamed('name', RadioType::class, true); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="form-check"] [ ./input @@ -1003,7 +1003,7 @@ public function testUncheckedRadio() $form = $this->factory->createNamed('name', RadioType::class, false); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="form-check"] [ ./input @@ -1026,7 +1026,7 @@ public function testRadioWithValue() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="form-check"] [ ./input @@ -1049,7 +1049,7 @@ public function testRadioRowWithHelp() $html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']); $this->assertMatchesXpath($html, -'/div + '/div [@class="form-group"] [ ./small[text() = "[trans]really helpful text[/trans]"] @@ -1075,7 +1075,7 @@ public function testFile() $form = $this->factory->createNamed('name', FileType::class); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'n/a', 'attr' => ['class' => 'my&class form-control-file']], -'/div + '/div [@class="custom-file"] [ ./input @@ -1093,7 +1093,7 @@ public function testFileLabelIdNotDuplicated() $form = $this->factory->createNamed('name', FileType::class); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'n/a', 'attr' => ['class' => 'my&class form-control-file'], 'label_attr' => ['id' => 'label-id']], -'/div + '/div [@class="custom-file"] [ ./input @@ -1111,7 +1111,7 @@ public function testFileWithPlaceholder() $form = $this->factory->createNamed('name', FileType::class); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'n/a', 'attr' => ['class' => 'my&class form-control-file', 'placeholder' => 'Custom Placeholder']], -'/div + '/div [@class="custom-file"] [ ./input @@ -1131,7 +1131,7 @@ public function testMoney() ]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="input-group"] [ ./div @@ -1157,7 +1157,7 @@ public function testPercent() $form = $this->factory->createNamed('name', PercentType::class, 0.1); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="input-group"] [ ./input @@ -1182,7 +1182,7 @@ public function testPercentNoSymbol() { $form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => false]); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/input + '/input [@id="my&id"] [@type="text"] [@name="name"] @@ -1196,7 +1196,7 @@ public function testPercentCustomSymbol() { $form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => '‱']); $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], -'/div + '/div [@class="input-group"] [ ./input @@ -1224,7 +1224,7 @@ public function testRange() $this->assertWidgetMatchesXpath( $form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="range"] [@name="name"] [@value="42"] @@ -1241,7 +1241,7 @@ public function testRangeWithMinMaxValues() $this->assertWidgetMatchesXpath( $form->createView(), ['attr' => ['class' => 'my&class']], -'/input + '/input [@type="range"] [@name="name"] [@value="42"] diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 38c445f927726..3535d4b6356e0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -102,7 +102,7 @@ public function testMoneyWidgetInIso() HTML - , trim($this->renderWidget($view))); + , trim($this->renderWidget($view))); } protected function renderForm(FormView $view, array $vars = []) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index 7dda79420ca12..5158c5a1e895c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -106,7 +106,7 @@ public function testMoneyWidgetInIso() HTML - , trim($this->renderWidget($view))); + , trim($this->renderWidget($view))); } protected function renderForm(FormView $view, array $vars = []) diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 89d4460fa98cb..ab45b83fecd72 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -64,7 +64,7 @@ public function testCompile() sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], true);', $this->getVariableGetter('form') - ), + ), trim($compiler->compile($node)->getSource()) ); @@ -74,7 +74,7 @@ public function testCompile() sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], false);', $this->getVariableGetter('form') - ), + ), trim($compiler->compile($node)->getSource()) ); @@ -86,7 +86,7 @@ public function testCompile() sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1", true);', $this->getVariableGetter('form') - ), + ), trim($compiler->compile($node)->getSource()) ); @@ -96,7 +96,7 @@ public function testCompile() sprintf( '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1", false);', $this->getVariableGetter('form') - ), + ), trim($compiler->compile($node)->getSource()) ); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index 59a8b10a9d065..42cb1762b050d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -38,7 +38,7 @@ public function testCompileWidget() sprintf( '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\')', $this->getVariableGetter('form') - ), + ), trim($compiler->compile($node)->getSource()) ); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index 72997273aced1..c6d3064676937 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -38,8 +38,8 @@ public function testCompileStrict() 'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");', $this->getVariableGetterWithoutStrictCheck('var'), $this->getVariableGetterWithStrictCheck('foo') - ), - trim($compiler->compile($node)->getSource()) + ), + trim($compiler->compile($node)->getSource()) ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index 8c454cbded9b3..23cd6ac8eceb3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -84,8 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int ['Architecture', (\PHP_INT_SIZE * 8).' bits'], ['Intl locale', class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'], ['Timezone', date_default_timezone_get().' ('.(new \DateTime())->format(\DateTime::W3C).')'], - ['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], - ['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], + ['OPcache', \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], + ['APCu', \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], ['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'], ]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index a0623f396127b..063932dee5782 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (null === $path = $input->getArgument('path')) { $io->title( - sprintf('Current configuration for %s', ($name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))) + sprintf('Current configuration for %s', $name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name)) ); $io->writeln(Yaml::dump([$extensionAlias => $config], 10)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php index a52177acc0471..648e210d4807d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php @@ -57,6 +57,6 @@ protected function configure() php %command.full_name% @AcmeDemoBundle EOF - ); + ); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index ea1d3a6abec31..67669e5a3c3cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -87,11 +87,11 @@ protected function describeRoute(Route $route, array $options = []) ['Route Name', $options['name'] ?? ''], ['Path', $route->getPath()], ['Path Regex', $route->compile()->getRegex()], - ['Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')], - ['Host Regex', ('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')], - ['Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')], - ['Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')], - ['Requirements', ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')], + ['Host', '' !== $route->getHost() ? $route->getHost() : 'ANY'], + ['Host Regex', '' !== $route->getHost() ? $route->compile()->getHostRegex() : ''], + ['Scheme', $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'], + ['Method', $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'], + ['Requirements', $route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'], ['Class', \get_class($route)], ['Defaults', $this->formatRouterConfig($route->getDefaults())], ['Options', $this->formatRouterConfig($route->getOptions())], diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index ca338fc2054db..c19144ba5f204 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -227,7 +227,7 @@ public function load(array $configs, ContainerBuilder $container) // mark any env vars found in the ide setting as used $container->resolveEnvPlaceholders($ide); - $container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: ($links[$ide] ?? $ide)); + $container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: ($links[$ide] ?? $ide)); } $container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%'); } @@ -496,6 +496,10 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont } if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) { + if (!$container->hasDefinition('security.csrf.token_generator')) { + throw new \LogicException('To use form CSRF protection, "framework.csrf_protection" must be enabled.'); + } + $loader->load('form_csrf.xml'); $container->setParameter('form.type_extension.csrf.enabled', true); @@ -719,7 +723,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']); if ('method' === $workflow['marking_store']['type']) { $markingStoreDefinition->setArguments([ - 'state_machine' === $type, //single state + 'state_machine' === $type, // single state $workflow['marking_store']['property'] ?? 'marking', ]); } else { diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index de23e474fc16c..50b820871427d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -178,14 +178,14 @@ private function resolve($value) $resolved = ($this->paramFetcher)($match[1]); - if (is_scalar($resolved)) { + if (\is_scalar($resolved)) { $this->collectedParameters[$match[1]] = $resolved; if (\is_string($resolved)) { $resolved = $this->resolve($resolved); } - if (is_scalar($resolved)) { + if (\is_scalar($resolved)) { return false === $resolved ? '0' : (string) $resolved; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index 427bd41d0dee8..b0a7291d93ab4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -36,7 +36,7 @@ class CodeHelper extends Helper */ public function __construct($fileLinkFormat, string $projectDir, string $charset) { - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); + $this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->rootDir = str_replace('\\', '/', $projectDir).'/'; $this->charset = $charset; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php index d45814da781e6..fec5a980926c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -208,11 +208,25 @@ public function testDescribeCallable($callable, $expectedDescription) $this->assertDescription($expectedDescription, $callable); } - public function getDescribeCallableTestData() + public function getDescribeCallableTestData(): array { return $this->getDescriptionTestData(ObjectsProvider::getCallables()); } + /** + * @group legacy + * @dataProvider getDescribeDeprecatedCallableTestData + */ + public function testDescribeDeprecatedCallable($callable, $expectedDescription) + { + $this->assertDescription($expectedDescription, $callable); + } + + public function getDescribeDeprecatedCallableTestData(): array + { + return $this->getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); + } + /** @dataProvider getClassDescriptionTestData */ public function testGetClassDescription($object, $expectedDescription) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index 05031fa7fcfb6..a097e058be7dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -229,19 +229,25 @@ public static function getEventDispatchers() return ['event_dispatcher_1' => $eventDispatcher]; } - public static function getCallables() + public static function getCallables(): array { return [ 'callable_1' => 'array_key_exists', 'callable_2' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass', 'staticMethod'], 'callable_3' => [new CallableClass(), 'method'], 'callable_4' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass::staticMethod', - 'callable_5' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'], 'callable_6' => function () { return 'Closure'; }, 'callable_7' => new CallableClass(), 'callable_from_callable' => \Closure::fromCallable(new CallableClass()), ]; } + + public static function getDeprecatedCallables(): array + { + return [ + 'callable_5' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'], + ]; + } } class CallableClass diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_disabled.php new file mode 100644 index 0000000000000..bd482c48de63c --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_disabled.php @@ -0,0 +1,8 @@ +loadFromExtension('framework', [ + 'csrf_protection' => false, + 'form' => [ + 'csrf_protection' => true, + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_disabled.xml new file mode 100644 index 0000000000000..e2b7167c84238 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_disabled.xml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_disabled.yml new file mode 100644 index 0000000000000..9319019c8641a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_disabled.yml @@ -0,0 +1,4 @@ +framework: + csrf_protection: false + form: + csrf_protection: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e86e22a201d53..38e502db56b46 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -84,6 +84,14 @@ public function testFormCsrfProtection() $this->assertEquals('%form.type_extension.csrf.field_name%', $def->getArgument(2)); } + public function testFormCsrfProtectionWithCsrfDisabled() + { + $this->expectException(\LogicException::class); + $this->expectExceptionMessage('To use form CSRF protection, "framework.csrf_protection" must be enabled.'); + + $this->createContainerFromFile('form_csrf_disabled'); + } + public function testPropertyAccessWithDefaultValue() { $container = $this->createContainerFromFile('full'); @@ -1009,7 +1017,7 @@ public function testAnnotations() public function testFileLinkFormat() { - if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { + if (\ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { $this->markTestSkipped('A custom file_link_format is defined.'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php index 537ee77174622..70b7bfcaafc5d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php @@ -116,7 +116,7 @@ public function testDescribeEnvVars() * UNKNOWN TXT - , $tester->getDisplay(true)); + , $tester->getDisplay(true)); putenv('REAL'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 9c3f2e78d610f..c05b7093c7538 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -176,7 +176,7 @@ public function testInvalidOptions() $this->expectExceptionMessage('The Translator does not support the following options: \'foo\''); $container = $this->createMock(ContainerInterface::class); - (new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar'])); + new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar']); } /** @dataProvider getDebugModeAndCacheDirCombinations */ diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index e5756bb0060a3..6efe388aab8b0 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -63,7 +63,7 @@ public function __construct(TokenStorageInterface $tokenStorage = null, RoleHier * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { if (null === $this->tokenStorage) { $this->data = [ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index 78864da648876..c2591b7f7f219 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -284,7 +284,7 @@ public function testEncodePasswordAsksNonProvidedUserClass() [2] Custom\Class\Test\User [3] Symfony\Component\Security\Core\User\User EOTXT - , $this->passwordEncoderCommandTester->getDisplay(true)); + , $this->passwordEncoderCommandTester->getDisplay(true)); } public function testNonInteractiveEncodePasswordUsesFirstUserClass() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php index 24ec5dd6c6d05..f7fa05ab4f98d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php @@ -99,7 +99,7 @@ public function getNames(Profile $profile) /** * @deprecated since Symfony 4.4 */ - protected function templateExists($template/*, bool $triggerDeprecation = true */) + protected function templateExists($template/* , bool $triggerDeprecation = true */) { if (1 === \func_num_args()) { @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use the "exists()" method of the Twig loader instead.', __METHOD__), \E_USER_DEPRECATED); diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php index cd135385c822e..d52ad02934bde 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php @@ -143,7 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $message = sprintf('Server listening on all interfaces, port %s -- see http://%s', $config->getPort(), $displayAddress); } $io->success($message); - if (ini_get('xdebug.profiler_enable_trigger')) { + if (\ini_get('xdebug.profiler_enable_trigger')) { $io->comment('Xdebug profiler trigger enabled.'); } $io->comment('Quit the server with CONTROL-C.'); diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php index 673b7b3179a34..bd45408f63de6 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php @@ -154,7 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $message = sprintf('Server listening on all interfaces, port %s -- see http://%s', $config->getPort(), $displayAddress); } $io->success($message); - if (ini_get('xdebug.profiler_enable_trigger')) { + if (\ini_get('xdebug.profiler_enable_trigger')) { $io->comment('Xdebug profiler trigger enabled.'); } } diff --git a/src/Symfony/Bundle/WebServerBundle/WebServer.php b/src/Symfony/Bundle/WebServerBundle/WebServer.php index 9b9a36b7e888b..1cde95ad12f76 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServer.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServer.php @@ -156,7 +156,7 @@ private function createServerProcess(WebServerConfig $config): Process throw new \RuntimeException('Unable to find the PHP binary.'); } - $xdebugArgs = ini_get('xdebug.profiler_enable_trigger') ? ['-dxdebug.profiler_enable_trigger=1'] : []; + $xdebugArgs = \ini_get('xdebug.profiler_enable_trigger') ? ['-dxdebug.profiler_enable_trigger=1'] : []; $process = new Process(array_merge([$binary], $finder->findArguments(), $xdebugArgs, ['-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()])); $process->setWorkingDirectory($config->getDocumentRoot()); diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 06b55cd380281..e299aa2d855f4 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -312,7 +312,7 @@ public function clickLink(string $linkText): Crawler * * @return Crawler */ - public function submit(Form $form, array $values = []/*, array $serverParameters = []*/) + public function submit(Form $form, array $values = []/* , array $serverParameters = [] */) { if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) { @trigger_error(sprintf('The "%s()" method will have a new "array $serverParameters = []" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', static::class.'::'.__FUNCTION__), \E_USER_DEPRECATED); @@ -676,7 +676,7 @@ protected function getAbsoluteUri($uri) } // protocol relative URL - if (str_starts_with($uri, '//')) { + if ('' !== trim($uri, '/') && str_starts_with($uri, '//')) { return parse_url($currentUri, \PHP_URL_SCHEME).':'.$uri; } diff --git a/src/Symfony/Component/BrowserKit/HttpBrowser.php b/src/Symfony/Component/BrowserKit/HttpBrowser.php index e2d6477673e82..62542087b1c21 100644 --- a/src/Symfony/Component/BrowserKit/HttpBrowser.php +++ b/src/Symfony/Component/BrowserKit/HttpBrowser.php @@ -82,7 +82,7 @@ private function getBodyAndExtraHeaders(Request $request, array $headers): array $fields = $request->getParameters(); if ($uploadedFiles = $this->getUploadedFiles($request->getFiles())) { - $part = new FormDataPart(array_merge($fields, $uploadedFiles)); + $part = new FormDataPart(array_replace_recursive($fields, $uploadedFiles)); return [$part->bodyToIterable(), $part->getPreparedHeaders()->toArray()]; } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClassThatInheritClient.php b/src/Symfony/Component/BrowserKit/Tests/ClassThatInheritClient.php index 9b445472042fc..55721335b9e07 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClassThatInheritClient.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClassThatInheritClient.php @@ -40,7 +40,7 @@ protected function doRequest($request): Response /** * @param array $serverParameters */ - public function submit(DomCrawlerForm $form, array $values = []/*, array $serverParameters = []*/): Crawler + public function submit(DomCrawlerForm $form, array $values = []/* , array $serverParameters = [] */): Crawler { return parent::submit($form, $values); } diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index 8125d1a77c919..522af77d843f2 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -86,7 +86,11 @@ public function testMultiPartRequestWithSingleFile() ->with('POST', 'http://example.com/', $this->callback(function ($options) { $this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers'])); $this->assertInstanceOf(\Generator::class, $options['body']); - $this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body']))); + $values = implode('', iterator_to_array($options['body'], false)); + $this->assertStringContainsString('name="foo[file]"', $values); + $this->assertStringContainsString('my_file', $values); + $this->assertStringContainsString('name="foo[bar]"', $values); + $this->assertStringContainsString('foo2', $values); return true; })) @@ -95,7 +99,7 @@ public function testMultiPartRequestWithSingleFile() $browser = new HttpBrowser($client); $path = tempnam(sys_get_temp_dir(), 'http'); file_put_contents($path, 'my_file'); - $browser->request('POST', 'http://example.com/', [], ['file' => ['tmp_name' => $path, 'name' => 'foo']]); + $browser->request('POST', 'http://example.com/', ['foo' => ['bar' => 'foo2']], ['foo' => ['file' => ['tmp_name' => $path, 'name' => 'foo']]]); } public function testMultiPartRequestWithNormalFlatArray() @@ -172,6 +176,30 @@ public function testMultiPartRequestWithAdditionalParametersOfTheSameName() ]); } + /** + * @dataProvider forwardSlashesRequestPathProvider + */ + public function testMultipleForwardSlashesRequestPath(string $requestPath) + { + $client = $this->createMock(HttpClientInterface::class); + $client + ->expects($this->once()) + ->method('request') + ->with('GET', 'http://localhost'.$requestPath) + ->willReturn($this->createMock(ResponseInterface::class)); + $browser = new HttpBrowser($client); + $browser->request('GET', $requestPath); + } + + public function forwardSlashesRequestPathProvider() + { + return [ + 'one slash' => ['/'], + 'two slashes' => ['//'], + 'multiple slashes' => ['////'], + ]; + } + private function uploadFile(string $data): string { $path = tempnam(sys_get_temp_dir(), 'http'); diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 59fe570b3123d..656474425335b 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -117,7 +117,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version, return $opcache; } - if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { return $opcache; } diff --git a/src/Symfony/Component/Cache/Adapter/AdapterInterface.php b/src/Symfony/Component/Cache/Adapter/AdapterInterface.php index fbc74cae79014..9e359e17e0a87 100644 --- a/src/Symfony/Component/Cache/Adapter/AdapterInterface.php +++ b/src/Symfony/Component/Cache/Adapter/AdapterInterface.php @@ -45,5 +45,5 @@ public function getItems(array $keys = []); * * @return bool */ - public function clear(/*string $prefix = ''*/); + public function clear(/* string $prefix = '' */); } diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index 257b0734095d5..57fb096bff377 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -51,7 +51,7 @@ public function __construct(array $adapters, int $defaultLifetime = 0) if (!$adapter instanceof CacheItemPoolInterface) { throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($adapter), CacheItemPoolInterface::class)); } - if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { continue; // skip putting APCu in the chain when the backend is disabled } @@ -210,7 +210,7 @@ public function hasItem($key) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : ''; $cleared = true; diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index 81f772fd88c6a..3c2979bd2a5ad 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -82,7 +82,7 @@ public function hasItem($key) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { return true; } diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 3a1e658bc0ac4..e006ea0146751 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -155,7 +155,7 @@ public function hasItem($key) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : ''; diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index e72c38599567e..105d4a64f9ba5 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -237,7 +237,7 @@ public function getItems(array $keys = []) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : ''; diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index c296c8847c5cf..9e65b2ef986b3 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -180,7 +180,7 @@ public function getItems(array $keys = []) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : ''; $event = $this->start(__FUNCTION__); diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 1bb1d22427ac6..4dd6fd7c54a27 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -194,7 +194,7 @@ public static function log(?LoggerInterface $logger, string $message, array $con } else { $replace = []; foreach ($context as $k => $v) { - if (is_scalar($v)) { + if (\is_scalar($v)) { $replace['{'.$k.'}'] = $v; } } diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index ed86fcadfc8b7..9bcd5b0618ba2 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -44,7 +44,7 @@ public function addInstance($name, TraceableAdapter $instance) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []]; $this->data = ['instances' => $empty, 'total' => $empty]; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php index da55270348224..01f17fdb8a729 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php @@ -106,18 +106,19 @@ public function testDontSaveWhenAskedNotTo() $cache = $this->createCachePool(0, __FUNCTION__); - $v1 = $cache->get('some-key', function($item, &$save){ - $save = false; - return 1; + $v1 = $cache->get('some-key', function ($item, &$save) { + $save = false; + + return 1; }); $this->assertSame($v1, 1); - $v2 = $cache->get('some-key', function(){ + $v2 = $cache->get('some-key', function () { return 2; }); $this->assertSame($v2, 2, 'First value was cached and should not have been'); - $v3 = $cache->get('some-key', function(){ + $v3 = $cache->get('some-key', function () { $this->fail('Value should have come from cache'); }); $this->assertSame($v3, 2); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php index 120a4e5a17a4b..8f7219ba68407 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php @@ -25,10 +25,10 @@ class ApcuAdapterTest extends AdapterTestCase public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface { - if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) { + if (!\function_exists('apcu_fetch') || !filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) { $this->markTestSkipped('APCu extension is required.'); } - if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { + if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { if ('testWithCliSapi' !== $this->getName()) { $this->markTestSkipped('apc.enable_cli=1 is required.'); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index ef024c97bbd43..210ef1689d819 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -148,7 +148,7 @@ public function provideServersSetting(): iterable 'localhost', 11222, ]; - if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(\ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { yield [ 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', @@ -165,7 +165,7 @@ public function provideServersSetting(): iterable '/var/local/run/memcached.socket', 0, ]; - if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(\ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { yield [ 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index dfb2a10e6821e..a28d320e11103 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -123,7 +123,7 @@ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemTags() $anotherPool = $this->createCachePool(); $adapter = new FilesystemAdapter(); - $adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair + $adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); // simulate item losing tags pair $this->assertFalse($anotherPool->hasItem($itemKey)); } @@ -139,7 +139,7 @@ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemTags() $anotherPool = $this->createCachePool(); $adapter = new FilesystemAdapter(); - $adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair + $adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); // simulate item losing tags pair $item = $anotherPool->getItem($itemKey); $this->assertFalse($item->isHit()); @@ -156,7 +156,7 @@ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemAndOnlyHasTags() $anotherPool = $this->createCachePool(); $adapter = new FilesystemAdapter(); - $adapter->deleteItem($itemKey); //simulate losing item but keeping tags + $adapter->deleteItem($itemKey); // simulate losing item but keeping tags $this->assertFalse($anotherPool->hasItem($itemKey)); } @@ -191,7 +191,7 @@ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags $anotherPool = $this->createCachePool(); $adapter = new FilesystemAdapter(); - $adapter->deleteItem($itemKey); //simulate losing item but keeping tags + $adapter->deleteItem($itemKey); // simulate losing item but keeping tags $item = $anotherPool->getItem($itemKey); $this->assertFalse($item->isHit()); diff --git a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php index 01ef63d808b9b..f15de082c9dfa 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php @@ -27,7 +27,7 @@ class ApcuCacheTest extends CacheTestCase public function createSimpleCache(int $defaultLifetime = 0): CacheInterface { - if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { + if (!\function_exists('apcu_fetch') || !filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { $this->markTestSkipped('APCu extension is required.'); } if ('\\' === \DIRECTORY_SEPARATOR) { diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php index 9da19ff11a1d8..ee07594854c6c 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php @@ -157,7 +157,7 @@ public function provideServersSetting(): iterable 'localhost', 11222, ]; - if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(\ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { yield [ 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', @@ -174,7 +174,7 @@ public function provideServersSetting(): iterable '/var/local/run/memcached.socket', 0, ]; - if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(\ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { yield [ 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php index 84f73012cad24..b18bd31cbb985 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php @@ -27,7 +27,7 @@ class PhpArrayCacheWithFallbackTest extends CacheTestCase 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', - //'testSetValidData' => 'PhpArrayCache does no validation', + // 'testSetValidData' => 'PhpArrayCache does no validation', 'testSetInvalidKeys' => 'PhpArrayCache does no validation', 'testSetInvalidTtl' => 'PhpArrayCache does no validation', 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php index a2914fa3578b6..f4902917d38b0 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php @@ -109,7 +109,7 @@ public function hasItem($key) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $this->deferred = []; if ($cleared = $this->versioningIsEnabled) { diff --git a/src/Symfony/Component/Cache/Traits/ApcuTrait.php b/src/Symfony/Component/Cache/Traits/ApcuTrait.php index ace28c7d37bd8..46bd20fe2f814 100644 --- a/src/Symfony/Component/Cache/Traits/ApcuTrait.php +++ b/src/Symfony/Component/Cache/Traits/ApcuTrait.php @@ -23,7 +23,7 @@ trait ApcuTrait { public static function isSupported() { - return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN); + return \function_exists('apcu_fetch') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN); } private function init(string $namespace, int $defaultLifetime, ?string $version) @@ -88,8 +88,8 @@ protected function doHave($id) */ protected function doClear($namespace) { - return isset($namespace[0]) && class_exists(\APCuIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) - ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY)) + return isset($namespace[0]) && class_exists(\APCUIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) + ? apcu_delete(new \APCUIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY)) : apcu_clear_cache(); } diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php index 2682eb146cd44..e41daebc6af0c 100644 --- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/ArrayTrait.php @@ -73,7 +73,7 @@ public function hasItem($key) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : ''; @@ -141,7 +141,7 @@ private function freeze($value, $key) if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { return serialize($value); } - } elseif (!is_scalar($value)) { + } elseif (!\is_scalar($value)) { try { $serialized = serialize($value); } catch (\Exception $e) { diff --git a/src/Symfony/Component/Cache/Traits/ContractsTrait.php b/src/Symfony/Component/Cache/Traits/ContractsTrait.php index 823af9e679e19..49a96eed359f5 100644 --- a/src/Symfony/Component/Cache/Traits/ContractsTrait.php +++ b/src/Symfony/Component/Cache/Traits/ContractsTrait.php @@ -42,7 +42,7 @@ trait ContractsTrait public function setCallbackWrapper(?callable $callbackWrapper): callable { if (!isset($this->callbackWrapper)) { - $this->callbackWrapper = \Closure::fromCallable([LockRegistry::class, 'compute']);; + $this->callbackWrapper = \Closure::fromCallable([LockRegistry::class, 'compute']); if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { $this->setCallbackWrapper(null); diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index b68c5a3d2463b..230c7bd4275c4 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -89,7 +89,7 @@ public function warmUp(array $values) $isStaticValue = false; } $value = var_export($value, true); - } elseif (!is_scalar($value)) { + } elseif (!\is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value))); } else { $value = var_export($value, true); @@ -130,7 +130,7 @@ public function warmUp(array $values) * * @return bool */ - public function clear(/*string $prefix = ''*/) + public function clear(/* string $prefix = '' */) { $prefix = 0 < \func_num_args() ? (string) func_get_arg(0) : ''; $this->keys = $this->values = []; diff --git a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php index 6df6888bad716..c76e7fe312bc9 100644 --- a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php @@ -41,7 +41,7 @@ public static function isSupported() { self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time(); - return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN)); + return \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN)); } /** @@ -217,7 +217,7 @@ protected function doSave(array $values, int $lifetime) $isStaticValue = false; } $value = var_export($value, true); - } elseif (!is_scalar($value)) { + } elseif (!\is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value))); } else { $value = var_export($value, true); diff --git a/src/Symfony/Component/Config/Definition/ScalarNode.php b/src/Symfony/Component/Config/Definition/ScalarNode.php index 5ad28ec4c53ab..7a5adf1b7819d 100644 --- a/src/Symfony/Component/Config/Definition/ScalarNode.php +++ b/src/Symfony/Component/Config/Definition/ScalarNode.php @@ -32,7 +32,7 @@ class ScalarNode extends VariableNode */ protected function validateType($value) { - if (!is_scalar($value) && null !== $value) { + if (!\is_scalar($value) && null !== $value) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), \gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index 8aef0ffba40ed..f4cdb8aa838de 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -71,7 +71,7 @@ public function getLocator() * @throws FileLoaderImportCircularReferenceException * @throws FileLocatorFileNotFoundException */ - public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/*, $exclude = null*/) + public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/* , $exclude = null */) { if (\func_num_args() < 5 && __CLASS__ !== static::class && !str_starts_with(static::class, 'Symfony\Component\\') && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) { @trigger_error(sprintf('The "%s()" method will have a new "$exclude = null" argument in version 5.0, not defining it is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php index d41b3c43c743e..5131173138fe4 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php @@ -137,7 +137,7 @@ public function write($content, array $metadata = null) } } - if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) { + if (\function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) { @opcache_invalidate($this->file, true); } } diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 9c74f6d60a379..2185b37b7640c 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -26,12 +26,12 @@ public function testImportWithFileLocatorDelegation() $locatorMockForAdditionalLoader = $this->createMock(FileLocatorInterface::class); $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls( - ['path/to/file1'], // Default - ['path/to/file1', 'path/to/file2'], // First is imported - ['path/to/file1', 'path/to/file2'], // Second is imported - ['path/to/file1'], // Exception - ['path/to/file1', 'path/to/file2'] // Exception - )); + ['path/to/file1'], // Default + ['path/to/file1', 'path/to/file2'], // First is imported + ['path/to/file1', 'path/to/file2'], // Second is imported + ['path/to/file1'], // Exception + ['path/to/file1', 'path/to/file2'] // Exception + )); $fileLoader = new TestFileLoader($locatorMock); $fileLoader->setSupports(false); diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index da9b9f6af1730..b0c1bf864b118 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -195,7 +195,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) * * @return int The command exit code * - * @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}. + * @throws ExceptionInterface When input binding fails. Bypass this by calling {@link ignoreValidationErrors()}. * * @see setCode() * @see execute() diff --git a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php index aff892cc25b7e..d9449dc56a247 100644 --- a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php +++ b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php @@ -55,7 +55,7 @@ public function process(ContainerBuilder $container) if (!$r->isSubclassOf(Command::class)) { throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class)); } - $commandName = $class::getDefaultName() !== null ? str_replace('%', '%%', $class::getDefaultName()) : null; + $commandName = null !== $class::getDefaultName() ? str_replace('%', '%%', $class::getDefaultName()) : null; } if (null === $commandName) { diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 99496b1c72dea..f068f02faeffc 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -641,7 +641,7 @@ private function fillNextRows(array $rows, int $line): array { $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { - if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) { + if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) { throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \gettype($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index c9ee03561b355..4a10fa1720d51 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -110,7 +110,7 @@ private function interpolate(string $message, array $context): string $replacements = []; foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { + if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index 66db3ad5ad6c0..1c99a1865d93e 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -430,18 +430,18 @@ private function autoPrependBlock(): void $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); if (!isset($chars[0])) { - $this->newLine(); //empty history, so we should start with a new line. + $this->newLine(); // empty history, so we should start with a new line. return; } - //Prepend new line for each non LF chars (This means no blank line was output before) + // Prepend new line for each non LF chars (This means no blank line was output before) $this->newLine(2 - substr_count($chars, "\n")); } private function autoPrependText(): void { $fetched = $this->bufferedOutput->fetch(); - //Prepend new line if last char isn't EOL: + // Prepend new line if last char isn't EOL: if (!str_ends_with($fetched, "\n")) { $this->newLine(); } diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index f418f446fc703..b041a0db5abce 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -279,7 +279,7 @@ public function testContentWithLineBreaks() some text EOF - )); + )); $this->assertEquals(<<some text EOF - )); + )); $this->assertEquals(<< EOF - )); + )); $this->assertEquals(<< EOF - )); + )); } public function testFormatAndWrap() diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index b8623e1995a65..296c9fd005ac3 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -162,7 +162,7 @@ public function testChoiceQuestionPadding() [łabądź] baz > EOT - , $output, true); + , $output, true); } public function testChoiceQuestionCustomPrompt() @@ -181,7 +181,7 @@ public function testChoiceQuestionCustomPrompt() [0] foo >ccc> EOT - , $output, true); + , $output, true); } protected function getInputStream($input) diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index 244a3f1d01814..ac8bb76918ec1 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -217,8 +217,7 @@ public function testErrorOutput() $command->addArgument('foo'); $command->setCode(function ($input, $output) { $output->getErrorOutput()->write('foo'); - } - ); + }); $tester = new CommandTester($command); $tester->execute( diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index f04d8cdd3e5db..0a1ba4dcdcc2c 100644 --- a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -156,7 +156,7 @@ public function testOnlyOfTypeFindsSingleChildrenOfGivenType() HTML -); + ); $xpath = new \DOMXPath($document); $nodeList = $xpath->query($translator->cssToXPath('span:only-of-type')); diff --git a/src/Symfony/Component/Debug/Debug.php b/src/Symfony/Component/Debug/Debug.php index a44b993f37a91..99215cf3f18e4 100644 --- a/src/Symfony/Component/Debug/Debug.php +++ b/src/Symfony/Component/Debug/Debug.php @@ -49,7 +49,7 @@ public static function enable($errorReportingLevel = \E_ALL, $displayErrors = tr if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { ini_set('display_errors', 0); ExceptionHandler::register(); - } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) { + } elseif ($displayErrors && (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || \ini_get('error_log'))) { // CLI - display errors only if they're not already logged to STDERR ini_set('display_errors', 1); } diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 99791f9aad9f3..fe425e05c7509 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -354,8 +354,8 @@ public function screamAt($levels, $replace = false) */ private function reRegister(int $prev) { - if ($prev !== $this->thrownErrors | $this->loggedErrors) { - $handler = set_error_handler('var_dump'); + if ($prev !== ($this->thrownErrors | $this->loggedErrors)) { + $handler = set_error_handler('is_int'); $handler = \is_array($handler) ? $handler[0] : null; restore_error_handler(); if ($handler === $this) { @@ -490,7 +490,7 @@ public function handleError($type, $message, $file, $line) $log = 0; } else { if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) { - $currentErrorHandler = set_error_handler('var_dump'); + $currentErrorHandler = set_error_handler('is_int'); restore_error_handler(); } @@ -601,7 +601,7 @@ public static function handleFatalError(array $error = null) $sameHandlerLimit = 10; while (!\is_array($handler) || !$handler[0] instanceof self) { - $handler = set_exception_handler('var_dump'); + $handler = set_exception_handler('is_int'); restore_exception_handler(); if (!$handler) { diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 21be2827cd864..fd8a7fd5d75f1 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -55,7 +55,7 @@ class ExceptionHandler public function __construct(bool $debug = true, string $charset = null, $fileLinkFormat = null) { $this->debug = $debug; - $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8'; + $this->charset = $charset ?: \ini_get('default_charset') ?: 'UTF-8'; $this->fileLinkFormat = $fileLinkFormat; } @@ -390,7 +390,7 @@ private function formatClass(string $class): string private function formatPath(string $path, int $line): string { $file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path); - $fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); + $fmt = $this->fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if (!$fmt) { return sprintf('in %s%s', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : ''); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index 92e4acacfba2f..4b7970cb4dd80 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -120,7 +120,7 @@ protected function processValue($value, $isRoot = false) $value, $this->lazy || ($targetDefinition && $targetDefinition->isLazy()), true - ); + ); } return $value; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php index 7abac908f5a01..40ea56df51282 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php @@ -63,7 +63,7 @@ public function process(ContainerBuilder $container) foreach ($definition->getTags() as $name => $tags) { foreach ($tags as $attributes) { foreach ($attributes as $attribute => $value) { - if (!is_scalar($value) && null !== $value) { + if (!\is_scalar($value) && null !== $value) { throw new RuntimeException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute)); } } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 34ddbbbdd838b..f5cf7c5abe93e 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -143,7 +143,7 @@ public function getFactory() * * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals */ - public function setDecoratedService($id, $renamedId = null, $priority = 0/*, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE*/) + public function setDecoratedService($id, $renamedId = null, $priority = 0/* , int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE */) { if ($renamedId && $id === $renamedId) { throw new InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); @@ -370,7 +370,7 @@ public function setMethodCalls(array $calls = []) * * @throws InvalidArgumentException on empty $method param */ - public function addMethodCall($method, array $arguments = []/*, bool $returnsClone = false*/) + public function addMethodCall($method, array $arguments = []/* , bool $returnsClone = false */) { if (empty($method)) { throw new InvalidArgumentException('Method name cannot be empty.'); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index e2abcc2b94d49..e8f8f86087881 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -688,13 +688,13 @@ private function isTrivialInstance(Definition $definition): bool if ($v instanceof Reference && $this->container->has($id = (string) $v) && $this->container->findDefinition($id)->isSynthetic()) { continue; } - if (!is_scalar($v) || $this->dumpValue($v) !== $this->dumpValue($v, false)) { + if (!\is_scalar($v) || $this->dumpValue($v) !== $this->dumpValue($v, false)) { return false; } } } elseif ($arg instanceof Reference && $this->container->has($id = (string) $arg) && $this->container->findDefinition($id)->isSynthetic()) { continue; - } elseif (!is_scalar($arg) || $this->dumpValue($arg) !== $this->dumpValue($arg, false)) { + } elseif (!\is_scalar($arg) || $this->dumpValue($arg) !== $this->dumpValue($arg, false)) { return false; } } diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php index 3441febfcf378..a3fb6d2e05bcb 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php @@ -111,7 +111,7 @@ public function getEnv($prefix, $name, \Closure $getEnv) } if ('file' === $prefix || 'require' === $prefix) { - if (!is_scalar($file = $getEnv($name))) { + if (!\is_scalar($file = $getEnv($name))) { throw new RuntimeException(sprintf('Invalid file name: env var "%s" is non-scalar.', $name)); } if (!file_exists($file)) { @@ -183,7 +183,7 @@ public function getEnv($prefix, $name, \Closure $getEnv) return null; } - if (!is_scalar($env)) { + if (!\is_scalar($env)) { throw new RuntimeException(sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix)); } @@ -280,7 +280,7 @@ public function getEnv($prefix, $name, \Closure $getEnv) $value = $this->container->getParameter($match[1]); } - if (!is_scalar($value)) { + if (!\is_scalar($value)) { throw new RuntimeException(sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, \gettype($value))); } diff --git a/src/Symfony/Component/DependencyInjection/Extension/Extension.php b/src/Symfony/Component/DependencyInjection/Extension/Extension.php index 01c1e0014647c..8a436fc8f0428 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/src/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -94,7 +94,7 @@ public function getConfiguration(array $config, ContainerBuilder $container) if (!$class->implementsInterface(ConfigurationInterface::class)) { @trigger_error(sprintf('Not implementing "%s" in the extension configuration class "%s" is deprecated since Symfony 4.1.', ConfigurationInterface::class, $class->getName()), \E_USER_DEPRECATED); - //throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class)); + // throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class)); return null; } diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php b/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php index 32b94df04bd95..46897efba2c1d 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php @@ -32,6 +32,11 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa return null; } + return self::getTypeHintForType($type, $r, $noBuiltin); + } + + private static function getTypeHintForType(\ReflectionType $type, \ReflectionFunctionAbstract $r, bool $noBuiltin): ?string + { $types = []; $glue = '|'; if ($type instanceof \ReflectionUnionType) { @@ -46,6 +51,17 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa } foreach ($reflectionTypes as $type) { + if ($type instanceof \ReflectionIntersectionType) { + $typeHint = self::getTypeHintForType($type, $r, $noBuiltin); + if (null === $typeHint) { + return null; + } + + $types[] = sprintf('(%s)', $typeHint); + + continue; + } + if ($type->isBuiltin()) { if (!$noBuiltin) { $types[] = $type->getName(); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php index a983b502423f5..39959eb7ec745 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php @@ -82,7 +82,7 @@ public static function processValue($value, $allowServices = false) switch (true) { case null === $value: - case is_scalar($value): + case \is_scalar($value): return $value; case $value instanceof ArgumentInterface: diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php index 49a92e5ce3a76..e0b42750d55c3 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php @@ -49,7 +49,7 @@ final public function tag(string $name, array $attributes = []): self } foreach ($attributes as $attribute => $value) { - if (null !== $value && !is_scalar($value)) { + if (null !== $value && !\is_scalar($value)) { throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute)); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php index f4d5f002cf87d..ba9f8afa90aec 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php @@ -27,7 +27,7 @@ final public function tag(string $name, array $attributes = []): self } foreach ($attributes as $attribute => $value) { - if (!is_scalar($value) && null !== $value) { + if (!\is_scalar($value) && null !== $value) { throw new InvalidArgumentException(sprintf('A tag attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $this->id, $name, $attribute)); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index d5a6e2e55667f..34197b9a1f181 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -51,7 +51,7 @@ public function __construct(ContainerBuilder $container, FileLocatorInterface $l * @param bool|string $ignoreErrors Whether errors should be ignored; pass "not_found" to ignore only when the loaded resource is not found * @param string|string[]|null $exclude Glob patterns to exclude from the import */ - public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/*, $exclude = null*/) + public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/* , $exclude = null */) { $args = \func_get_args(); diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index fdf4fa1f4c887..9add847acb111 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -676,7 +676,7 @@ private function shouldEnableEntityLoader(): bool }); $schema = ' - + '; file_put_contents($tmpfile, ' diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index f15fc3492bd34..7843ec97397b7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -277,7 +277,7 @@ private function parseDefaults(array &$content, string $file): array } foreach ($tag as $attribute => $value) { - if (!is_scalar($value) && null !== $value) { + if (!\is_scalar($value) && null !== $value) { throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in "%s". Check your YAML syntax.', $name, $attribute, $file)); } } @@ -534,7 +534,7 @@ private function parseDefinition(string $id, $service, string $file, array $defa } foreach ($tag as $attribute => $value) { - if (!is_scalar($value) && null !== $value) { + if (!\is_scalar($value) && null !== $value) { throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, $attribute, $file)); } } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php index 22f6812093c9f..450e39cd2d0ed 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php @@ -51,10 +51,10 @@ public function get($name) if ($this->has($name)) { $defaultValue = parent::get($name); - if (null !== $defaultValue && !is_scalar($defaultValue)) { // !is_string in 5.0 - //throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); + if (null !== $defaultValue && !\is_scalar($defaultValue)) { // !is_string in 5.0 + // throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); - } elseif (is_scalar($defaultValue) && !\is_string($defaultValue)) { + } elseif (\is_scalar($defaultValue) && !\is_string($defaultValue)) { @trigger_error(sprintf('A non-string default value of an env() parameter is deprecated since 4.3, cast "%s" to string instead.', $name), \E_USER_DEPRECATED); } } @@ -162,10 +162,10 @@ public function resolve() @trigger_error(sprintf('A non-string default value of env parameter "%s" is deprecated since 4.3, cast it to string instead.', $env), \E_USER_DEPRECATED); } $this->parameters[$name] = (string) $default; - } elseif (null !== $default && !is_scalar($default)) { // !is_string in 5.0 - //throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \gettype($default))); + } elseif (null !== $default && !\is_scalar($default)) { // !is_string in 5.0 + // throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \gettype($default))); throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, "%s" given.', $env, \gettype($default))); - } elseif (is_scalar($default) && !\is_string($default)) { + } elseif (\is_scalar($default) && !\is_string($default)) { @trigger_error(sprintf('A non-string default value of env parameter "%s" is deprecated since 4.3, cast it to string instead.', $env), \E_USER_DEPRECATED); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 4e90bfb1c7a46..1cfc3f0889113 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -241,8 +241,6 @@ public function testTypeNotGuessableNoServicesFound() */ public function testTypeNotGuessableUnionType() { - $this->expectException(AutowiringFailedException::class); - $this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\UnionClasses::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionA|Symfony\Component\DependencyInjection\Tests\Compiler\CollisionB" but this class was not found.'); $container = new ContainerBuilder(); $container->register(CollisionA::class); @@ -252,6 +250,9 @@ public function testTypeNotGuessableUnionType() $aDefinition->setAutowired(true); $pass = new AutowirePass(); + + $this->expectException(AutowiringFailedException::class); + $this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\UnionClasses::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionA|Symfony\Component\DependencyInjection\Tests\Compiler\CollisionB" but this class was not found.'); $pass->process($container); } @@ -260,17 +261,38 @@ public function testTypeNotGuessableUnionType() */ public function testTypeNotGuessableIntersectionType() { + $container = new ContainerBuilder(); + + $container->register(CollisionInterface::class); + $container->register(AnotherInterface::class); + + $aDefinition = $container->register('a', IntersectionClasses::class); + $aDefinition->setAutowired(true); + + $pass = new AutowirePass(); + $this->expectException(AutowiringFailedException::class); $this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\IntersectionClasses::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface&Symfony\Component\DependencyInjection\Tests\Compiler\AnotherInterface" but this class was not found.'); + $pass->process($container); + } + + /** + * @requires PHP 8.2 + */ + public function testTypeNotGuessableCompositeType() + { $container = new ContainerBuilder(); $container->register(CollisionInterface::class); $container->register(AnotherInterface::class); - $aDefinition = $container->register('a', IntersectionClasses::class); + $aDefinition = $container->register('a', CompositeTypeClasses::class); $aDefinition->setAutowired(true); $pass = new AutowirePass(); + + $this->expectException(AutowiringFailedException::class); + $this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CompositeTypeClasses::__construct()" has type "(Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface&Symfony\Component\DependencyInjection\Tests\Compiler\AnotherInterface)|Symfony\Component\DependencyInjection\Tests\Compiler\YetAnotherInterface" but this class was not found.'); $pass->process($container); } @@ -373,6 +395,22 @@ public function testParameterWithNullUnionIsSkipped() $this->assertNull($definition->getArgument(0)); } + /** + * @requires PHP 8.2 + */ + public function testParameterWithNullableIntersectionIsSkipped() + { + $container = new ContainerBuilder(); + + $optDefinition = $container->register('opt', NullableIntersection::class); + $optDefinition->setAutowired(true); + + (new AutowirePass())->process($container); + + $definition = $container->getDefinition('opt'); + $this->assertNull($definition->getArgument(0)); + } + /** * @requires PHP 8 */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php index b7c98e70d2bca..fef4ca8658cd6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php @@ -135,7 +135,7 @@ public function testProcessDoesNotErrorOnServicesThatDoNotHaveDefinitions() ->addArgument(new Reference('not.defined')) ->setPublic(true); - $container->set('not.defined', new \StdClass()); + $container->set('not.defined', new \stdClass()); $this->process($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php index 74b976e224dd8..a3bdd82ff8496 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php @@ -10,6 +10,9 @@ if (\PHP_VERSION_ID >= 80100) { require __DIR__.'/intersectiontype_classes.php'; } +if (\PHP_VERSION_ID >= 80200) { + require __DIR__.'/compositetype_classes.php'; +} class Foo { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/compositetype_classes.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/compositetype_classes.php new file mode 100644 index 0000000000000..d0de7432fc4cf --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/compositetype_classes.php @@ -0,0 +1,21 @@ +markTestSkipped('To run this test, add "phar" to the "suhosin.executor.include.whitelist" settings in your php.ini file.'); } diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php index 6bfd9256165c4..1d75e18a49216 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php @@ -136,7 +136,7 @@ public function testAddHtmlContentInvalidBaseTag() public function testAddHtmlContentCharsetGbk() { $crawler = $this->createCrawler(); - //gbk encode of

中文

+ // gbk encode of

中文

$crawler->addHtmlContent($this->getDoctype().base64_decode('PGh0bWw+PHA+1tDOxDwvcD48L2h0bWw+'), 'gbk'); $this->assertEquals('中文', $crawler->filterXPath('//p')->text()); diff --git a/src/Symfony/Component/ErrorHandler/BufferingLogger.php b/src/Symfony/Component/ErrorHandler/BufferingLogger.php index fdfc72497a7e4..cfd55c61f30a4 100644 --- a/src/Symfony/Component/ErrorHandler/BufferingLogger.php +++ b/src/Symfony/Component/ErrorHandler/BufferingLogger.php @@ -53,7 +53,7 @@ public function __destruct() foreach ($this->logs as [$level, $message, $context]) { if (false !== strpos($message, '{')) { foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || (\is_object($val) && \is_callable([$val, '__toString']))) { + if (null === $val || \is_scalar($val) || (\is_object($val) && \is_callable([$val, '__toString']))) { $message = str_replace("{{$key}}", $val, $message); } elseif ($val instanceof \DateTimeInterface) { $message = str_replace("{{$key}}", $val->format(\DateTime::RFC3339), $message); diff --git a/src/Symfony/Component/ErrorHandler/Debug.php b/src/Symfony/Component/ErrorHandler/Debug.php index 4a828121821d8..343a35a77b11b 100644 --- a/src/Symfony/Component/ErrorHandler/Debug.php +++ b/src/Symfony/Component/ErrorHandler/Debug.php @@ -24,7 +24,7 @@ public static function enable(): ErrorHandler if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { ini_set('display_errors', 0); - } elseif (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log')) { + } elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || \ini_get('error_log')) { // CLI - display errors only if they're not already logged to STDERR ini_set('display_errors', 1); } diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 342e6e83b06f0..ce05790b17f1b 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -70,6 +70,8 @@ class DebugClassLoader 'self' => 'self', 'parent' => 'parent', 'mixed' => 'mixed', + 'list' => 'array', + 'class-string' => 'string', ] + (\PHP_VERSION_ID >= 80000 ? [ 'static' => 'static', '$this' => 'static', diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index ceadcaf674fc6..fba6f8cf77d91 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -374,8 +374,8 @@ public function screamAt(int $levels, bool $replace = false): int */ private function reRegister(int $prev): void { - if ($prev !== $this->thrownErrors | $this->loggedErrors) { - $handler = set_error_handler('var_dump'); + if ($prev !== ($this->thrownErrors | $this->loggedErrors)) { + $handler = set_error_handler('is_int'); $handler = \is_array($handler) ? $handler[0] : null; restore_error_handler(); if ($handler === $this) { @@ -522,7 +522,7 @@ public function handleError(int $type, string $message, string $file, int $line) $log = 0; } else { if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) { - $currentErrorHandler = set_error_handler('var_dump'); + $currentErrorHandler = set_error_handler('is_int'); restore_error_handler(); } @@ -639,7 +639,7 @@ public static function handleFatalError(array $error = null): void $sameHandlerLimit = 10; while (!\is_array($handler) || !$handler[0] instanceof self) { - $handler = set_exception_handler('var_dump'); + $handler = set_exception_handler('is_int'); restore_exception_handler(); if (!$handler) { diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php index 69e1b9ce74555..4c0fb9cc20d58 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php @@ -56,8 +56,8 @@ public function __construct($debug = false, string $charset = null, $fileLinkFor } $this->debug = $debug; - $this->charset = $charset ?: (ini_get('default_charset') ?: 'UTF-8'); - $this->fileLinkFormat = $fileLinkFormat ?: (ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')); + $this->charset = $charset ?: (\ini_get('default_charset') ?: 'UTF-8'); + $this->fileLinkFormat = $fileLinkFormat ?: (\ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')); $this->projectDir = $projectDir; $this->outputBuffer = $outputBuffer; $this->logger = $logger; @@ -319,7 +319,7 @@ private function formatLogMessage(string $message, array $context) if ($context && false !== strpos($message, '{')) { $replacements = []; foreach ($context as $key => $val) { - if (is_scalar($val)) { + if (\is_scalar($val)) { $replacements['{'.$key.'}'] = $val; } } diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php index e921ea198e26b..64dc3f7f31718 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php @@ -661,7 +661,7 @@ public function errorHandlerWhenLoggingProvider(): iterable public function testAssertQuietEval() { - if ('-1' === ini_get('zend.assertions')) { + if ('-1' === \ini_get('zend.assertions')) { $this->markTestSkipped('zend.assertions is forcibly disabled'); } diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index 56116cf44f5cc..98e7df6344e46 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -133,7 +133,7 @@ public function hasListeners($eventName = null) * * @param string|null $eventName */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event/* , string $eventName = null */) { if (null === $this->callStack) { $this->callStack = new \SplObjectStorage(); diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index 4a8f6c6f121de..3d8ac4281fd11 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -48,7 +48,7 @@ public function __construct() * * @param string|null $eventName */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event/* , string $eventName = null */) { $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; diff --git a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php index 75a7d7318187b..f3d04d25ac7d7 100644 --- a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php @@ -30,11 +30,11 @@ public function __construct(EventDispatcherInterface $dispatcher) * * @param string|null $eventName */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event/* , string $eventName = null */) { $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; - if (is_scalar($event)) { + if (\is_scalar($event)) { // deprecated $swap = $event; $event = $eventName ?? new Event(); diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php index 8ee6cba1b5112..a802c99324eec 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php @@ -53,7 +53,7 @@ public static function decorate(?ContractsEventDispatcherInterface $dispatcher): * * @return object */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event/* , string $eventName = null */) { $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; diff --git a/src/Symfony/Component/ExpressionLanguage/Node/Node.php b/src/Symfony/Component/ExpressionLanguage/Node/Node.php index decb06d1bb781..b0540b0980107 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/Node.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/Node.php @@ -87,7 +87,7 @@ public function dump() $dump = ''; foreach ($this->toArray() as $v) { - $dump .= is_scalar($v) ? $v : $v->dump(); + $dump .= \is_scalar($v) ? $v : $v->dump(); } return $dump; diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/NodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/NodeTest.php index 351da05144bc3..158973cec3aa5 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/NodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/NodeTest.php @@ -26,7 +26,7 @@ public function testToString() ConstantNode(value: 'foo') ) EOF - , (string) $node); + , (string) $node); } public function testSerialization() diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 4fb1cb4d953ae..562dce70aa90f 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -1344,12 +1344,12 @@ public function getTestPathData() ], ['A/B', 'foobar', [ - //dirs + // dirs 'A'.\DIRECTORY_SEPARATOR.'B', 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C', 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B', 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C', - //files + // files 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat', 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat', 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat.copy', diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/a.txt b/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/a.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/c.txt b/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/c.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/dir/b.txt b/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/dir/b.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/dir/c.txt b/src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/dir/c.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Component/Finder/Tests/GitignoreTest.php b/src/Symfony/Component/Finder/Tests/GitignoreTest.php index 0297bc0c29cac..b05663c3e1bb0 100644 --- a/src/Symfony/Component/Finder/Tests/GitignoreTest.php +++ b/src/Symfony/Component/Finder/Tests/GitignoreTest.php @@ -349,7 +349,7 @@ public function provider(): array 'logs/', '!logs/important.log', ], - ['logs/debug.log'/* must be pruned on traversal 'logs/important.log'*/], + ['logs/debug.log'/* must be pruned on traversal 'logs/important.log' */], [], ], [ diff --git a/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php index 9040ee04c3c7a..e2c1325276d95 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php @@ -28,37 +28,37 @@ public function getTestFilterData() { $inner = new MockFileListIterator(); - //PATH: A/B/C/abc.dat + // PATH: A/B/C/abc.dat $inner[] = new MockSplFileInfo([ 'name' => 'abc.dat', 'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat', ]); - //PATH: A/B/ab.dat + // PATH: A/B/ab.dat $inner[] = new MockSplFileInfo([ 'name' => 'ab.dat', 'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat', ]); - //PATH: A/a.dat + // PATH: A/a.dat $inner[] = new MockSplFileInfo([ 'name' => 'a.dat', 'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'a.dat', ]); - //PATH: copy/A/B/C/abc.dat.copy + // PATH: copy/A/B/C/abc.dat.copy $inner[] = new MockSplFileInfo([ 'name' => 'abc.dat.copy', 'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat', ]); - //PATH: copy/A/B/ab.dat.copy + // PATH: copy/A/B/ab.dat.copy $inner[] = new MockSplFileInfo([ 'name' => 'ab.dat.copy', 'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat', ]); - //PATH: copy/A/a.dat.copy + // PATH: copy/A/a.dat.copy $inner[] = new MockSplFileInfo([ 'name' => 'a.dat.copy', 'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'a.dat', diff --git a/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php b/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php index b43f900c3b3fe..d92a11dca05b3 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php @@ -72,9 +72,9 @@ public static function setUpBeforeClass(): void public static function tearDownAfterClass(): void { $paths = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), - \RecursiveIteratorIterator::CHILD_FIRST - ); + new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), + \RecursiveIteratorIterator::CHILD_FIRST + ); foreach ($paths as $path) { if ($path->isDir()) { diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index 49b991a46584f..7917f4a543da9 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -219,7 +219,7 @@ private function castableToString(array $choices, array &$cache = []): bool } continue; - } elseif (!is_scalar($choice)) { + } elseif (!\is_scalar($choice)) { return false; } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index 2d91a2207f056..c8bdfac08b38f 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -168,7 +168,7 @@ public function reverseTransform($value) $value['hour'] ?? $this->referenceDate->format('H'), $value['minute'] ?? $this->referenceDate->format('i'), $value['second'] ?? $this->referenceDate->format('s') - ), + ), new \DateTimeZone($this->outputTimezone) ); diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php index b452d60784e27..5524b1ae519f0 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php @@ -57,7 +57,7 @@ public function convertTransformationFailureToFormError(FormEvent $event) } } - $clientDataAsString = is_scalar($form->getViewData()) ? (string) $form->getViewData() : \gettype($form->getViewData()); + $clientDataAsString = \is_scalar($form->getViewData()) ? (string) $form->getViewData() : \gettype($form->getViewData()); $messageTemplate = 'The value {{ value }} is not valid.'; if (null !== $this->translator) { diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 7310e3b6d35c1..2b3587c0343ba 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -175,7 +175,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) if (\count($unknownValues) > 0) { $form = $event->getForm(); - $clientDataAsString = is_scalar($form->getViewData()) ? (string) $form->getViewData() : (\is_array($form->getViewData()) ? implode('", "', array_keys($unknownValues)) : \gettype($form->getViewData())); + $clientDataAsString = \is_scalar($form->getViewData()) ? (string) $form->getViewData() : (\is_array($form->getViewData()) ? implode('", "', array_keys($unknownValues)) : \gettype($form->getViewData())); if (null !== $this->translator) { $message = $this->translator->trans($messageTemplate, ['{{ value }}' => $clientDataAsString], 'validators'); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index dec5bbf6aca54..df8811c8e331f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -324,7 +324,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setDeprecated('date_format', function (Options $options, $dateFormat) { if (null !== $dateFormat && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { return sprintf('Using the "date_format" option of %s with an HTML5 date widget is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "date_format" option of the "%s" with an HTML5 date.', self::class)); + // throw new LogicException(sprintf('Cannot use the "date_format" option of the "%s" with an HTML5 date.', self::class)); } return ''; @@ -332,7 +332,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setDeprecated('date_widget', function (Options $options, $dateWidget) { if (null !== $dateWidget && 'single_text' === $options['widget']) { return sprintf('Using the "date_widget" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "date_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class)); + // throw new LogicException(sprintf('Cannot use the "date_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class)); } return ''; @@ -340,7 +340,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setDeprecated('time_widget', function (Options $options, $timeWidget) { if (null !== $timeWidget && 'single_text' === $options['widget']) { return sprintf('Using the "time_widget" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "time_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class)); + // throw new LogicException(sprintf('Cannot use the "time_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class)); } return ''; @@ -356,7 +356,7 @@ public function configureOptions(OptionsResolver $resolver) if ($html5 && self::HTML5_FORMAT !== $format) { return sprintf('Using a custom format when the "html5" option of %s is enabled is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); + // throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); } return ''; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index a03e06ab23cd7..1d7a3888e17d0 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -335,7 +335,7 @@ public function configureOptions(OptionsResolver $resolver) if ($html5 && 'single_text' === $widget && self::HTML5_FORMAT !== $format) { return sprintf('Using a custom format when the "html5" option of %s is enabled is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); + // throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); } return ''; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index b610d4c65edc3..ee1271cffc82e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -183,7 +183,7 @@ private function getFileUploadError(int $errorCode) */ private static function getMaxFilesize() { - $iniMax = strtolower(ini_get('upload_max_filesize')); + $iniMax = strtolower(\ini_get('upload_max_filesize')); if ('' === $iniMax) { return \PHP_INT_MAX; @@ -200,8 +200,11 @@ private static function getMaxFilesize() switch (substr($iniMax, -1)) { case 't': $max *= 1024; + // no break case 'g': $max *= 1024; + // no break case 'm': $max *= 1024; + // no break case 'k': $max *= 1024; } diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php index 005683ec89d84..ef38368c928c2 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php @@ -85,7 +85,7 @@ public function __construct(FormDataExtractorInterface $dataExtractor) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { } diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index fc50af4d01d94..3739d2a137f1f 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -168,7 +168,7 @@ public function validate($form, Constraint $formConstraint) // child. // See also https://github.com/symfony/symfony/issues/4359 if ($childrenSynchronized) { - $clientDataAsString = is_scalar($form->getViewData()) + $clientDataAsString = \is_scalar($form->getViewData()) ? (string) $form->getViewData() : \gettype($form->getViewData()); diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 5f00c7aa2eed0..dc5748041b2b5 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -355,7 +355,7 @@ public function setData($modelData) } // Treat data as strings unless a transformer exists - if (is_scalar($modelData) && !$this->config->getViewTransformers() && !$this->config->getModelTransformers()) { + if (\is_scalar($modelData) && !$this->config->getViewTransformers() && !$this->config->getModelTransformers()) { $modelData = (string) $modelData; } @@ -540,7 +540,7 @@ public function submit($submittedData, $clearMissing = true) // and radio buttons with empty values. if (false === $submittedData) { $submittedData = null; - } elseif (is_scalar($submittedData)) { + } elseif (\is_scalar($submittedData)) { $submittedData = (string) $submittedData; } elseif ($this->config->getRequestHandler()->isFileUpload($submittedData)) { if (!$this->config->getOption('allow_file_upload')) { @@ -1120,7 +1120,7 @@ private function normToView($value) // compound forms is passed to the data mapper and thus should // not be converted to a string before. if (!($transformers = $this->config->getViewTransformers()) && !$this->config->getCompound()) { - return null === $value || is_scalar($value) ? (string) $value : $value; + return null === $value || \is_scalar($value) ? (string) $value : $value; } try { diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index 6eef4179e89f0..6a38a77017dba 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -24,7 +24,7 @@ public function testRow() $html = $this->renderRow($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name"] /following-sibling::ul @@ -46,7 +46,7 @@ public function testRowOverrideVariables() ]); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name"][@class="my&label&class required"][.="[trans]foo&bar[/trans]"] /following-sibling::input[@id="name"][@class="my&class"] @@ -68,7 +68,7 @@ public function testRepeatedRow() // (see RepeatedTypeValidatorExtension) $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name_first"] /following-sibling::input[@id="name_first"] @@ -89,7 +89,7 @@ public function testButtonRow() $html = $this->renderRow($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./button[@type="button"][@name="name"] ] @@ -119,7 +119,7 @@ public function testRest() $html = $this->renderRest($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name_field1"] /following-sibling::input[@type="text"][@id="name_field1"] @@ -165,7 +165,7 @@ public function testRestWithChildrenForms() $html = $this->renderRest($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[not(@for)] /following-sibling::div[@id="parent_child1"] @@ -210,7 +210,7 @@ public function testRestAndRepeatedWithRow() $html = $this->renderRest($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name_first"] /following-sibling::input[@type="text"][@id="name_first"] @@ -237,7 +237,7 @@ public function testRestAndRepeatedWithRowPerChild() $html = $this->renderRest($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name_first"] /following-sibling::input[@type="text"][@id="name_first"] @@ -267,7 +267,7 @@ public function testRestAndRepeatedWithWidgetPerChild() $html = $this->renderRest($view); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name_first"] /following-sibling::input[@type="text"][@id="name_first"] @@ -288,7 +288,7 @@ public function testCollection() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div[./input[@type="text"][@value="a"]] /following-sibling::div[./input[@type="text"][@value="b"]] @@ -310,7 +310,7 @@ public function testCollectionWithAlternatingRowTypes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div[./div/div/input[@type="text"][@value="a"]] /following-sibling::div[./div/div/textarea[.="b"]] @@ -328,7 +328,7 @@ public function testEmptyCollection() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [./input[@type="hidden"][@id="names__token"]] [count(./div)=0] ' @@ -349,7 +349,7 @@ public function testCollectionRow() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [ @@ -391,7 +391,7 @@ public function testForm() ]); $this->assertMatchesXpath($html, -'/form + '/form [ ./input[@type="hidden"][@name="_method"][@value="PUT"] /following-sibling::div @@ -427,7 +427,7 @@ public function testFormWidget() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [ @@ -459,7 +459,7 @@ public function testNestedFormError() $form->get('child')->addError(new FormError('[trans]Error![/trans]')); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div/label /following-sibling::ul[./li[.="[trans]Error![/trans]"]] @@ -484,7 +484,7 @@ public function testCsrf() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div /following-sibling::input[@type="hidden"][@id="name__token"][@value="foo&bar"] @@ -501,7 +501,7 @@ public function testRepeated() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [ @@ -529,7 +529,7 @@ public function testRepeatedWithCustomOptions() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [ @@ -555,7 +555,7 @@ public function testSearchInputName() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [ @@ -575,7 +575,7 @@ public function testLabelHasNoId() $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, -'/div + '/div [ ./label[@for="name"][not(@id)] /following-sibling::input[@id="name"] @@ -592,7 +592,7 @@ public function testLabelIsNotRenderedWhenSetToFalse() $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, -'/div + '/div [ ./input[@id="name"] ] @@ -638,7 +638,7 @@ public function testThemeInheritance($parentTheme, $childTheme) $this->setTheme($view['child'], $childTheme); $this->assertWidgetMatchesXpath($view, [], -'/div + '/div [ ./div [ @@ -674,7 +674,7 @@ public function testCollectionRowWithCustomBlock() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div[./label[.="Custom label: [trans]0[/trans]"]] /following-sibling::div[./label[.="Custom label: [trans]1[/trans]"]] @@ -697,7 +697,7 @@ public function testChoiceRowWithCustomBlock() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./label[.="Custom name label: [trans]ChoiceA[/trans]"] /following-sibling::label[.="Custom name label: [trans]ChoiceB[/trans]"] @@ -793,7 +793,7 @@ public function testMultipleChoiceExpandedWithLabelsAsFalse() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@value="&a"][@checked] /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)] @@ -821,7 +821,7 @@ public function testMultipleChoiceExpandedWithLabelsSetByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@value="&a"][@checked] /following-sibling::label[@for="name_0"][.="[trans]label.&a[/trans]"] @@ -848,7 +848,7 @@ public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@value="&a"][@checked] /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)] @@ -875,7 +875,7 @@ public function testFormEndWithRest() // Insert the start tag, the end tag should be rendered by the helper $this->assertMatchesXpath('
'.$html, -'/form + '/form [ ./div [ diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 97ff43fc8f96b..8c44c61eb0247 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -149,7 +149,7 @@ public function testLabel() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [.="[trans]Name[/trans]"] ' @@ -163,7 +163,7 @@ public function testLabelWithoutTranslation() ]); $this->assertMatchesXpath($this->renderLabel($form->createView()), -'/label + '/label [@for="name"] [.="Name"] ' @@ -178,7 +178,7 @@ public function testLabelOnForm() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/label + '/label [@class="required"] [.="[trans]Name[/trans]"] ' @@ -193,7 +193,7 @@ public function testLabelWithCustomTextPassedAsOption() $html = $this->renderLabel($form->createView()); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [.="[trans]Custom label[/trans]"] ' @@ -206,7 +206,7 @@ public function testLabelWithCustomTextPassedDirectly() $html = $this->renderLabel($form->createView(), 'Custom label'); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [.="[trans]Custom label[/trans]"] ' @@ -221,7 +221,7 @@ public function testLabelWithCustomTextPassedAsOptionAndDirectly() $html = $this->renderLabel($form->createView(), 'Overridden label'); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [.="[trans]Overridden label[/trans]"] ' @@ -238,7 +238,7 @@ public function testLabelDoesNotRenderFieldAttributes() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="required"] ' @@ -255,7 +255,7 @@ public function testLabelWithCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class required"] ' @@ -272,7 +272,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() ]); $this->assertMatchesXpath($html, -'/label + '/label [@for="name"] [@class="my&class required"] [.="[trans]Custom label[/trans]"] @@ -310,7 +310,7 @@ public function testLabelFormatName() $html = $this->renderLabel($view, null, ['label_format' => 'form.%name%']); $this->assertMatchesXpath($html, -'/label + '/label [@for="myform_myfield"] [.="[trans]form.myfield[/trans]"] ' @@ -326,7 +326,7 @@ public function testLabelFormatId() $html = $this->renderLabel($view, null, ['label_format' => 'form.%id%']); $this->assertMatchesXpath($html, -'/label + '/label [@for="myform_myfield"] [.="[trans]form.myform_myfield[/trans]"] ' @@ -344,7 +344,7 @@ public function testLabelFormatAsFormOption() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/label + '/label [@for="myform_myfield"] [.="[trans]form.myfield[/trans]"] ' @@ -362,7 +362,7 @@ public function testLabelFormatOverriddenOption() $html = $this->renderLabel($view); $this->assertMatchesXpath($html, -'/label + '/label [@for="myform_myfield"] [.="[trans]field.myfield[/trans]"] ' @@ -380,7 +380,7 @@ public function testLabelWithoutTranslationOnButton() $html = $this->renderWidget($view); $this->assertMatchesXpath($html, -'/button + '/button [@type="button"] [@name="myform[mybutton]"] [.="Mybutton"] @@ -397,7 +397,7 @@ public function testLabelFormatOnButton() $html = $this->renderWidget($view, ['label_format' => 'form.%name%']); $this->assertMatchesXpath($html, -'/button + '/button [@type="button"] [@name="myform[mybutton]"] [.="[trans]form.mybutton[/trans]"] @@ -414,7 +414,7 @@ public function testLabelFormatOnButtonId() $html = $this->renderWidget($view, ['label_format' => 'form.%id%']); $this->assertMatchesXpath($html, -'/button + '/button [@type="button"] [@name="myform[mybutton]"] [.="[trans]form.myform_mybutton[/trans]"] @@ -431,7 +431,7 @@ public function testHelp() $html = $this->renderHelp($view); $this->assertMatchesXpath($html, -'/p + '/p [@id="name_help"] [@class="help-text"] [.="[trans]Help text test![/trans]"] @@ -460,7 +460,7 @@ public function testHelpSetLinkFromWidget() $this->renderHelp($view); $this->assertMatchesXpath($html, -'//input + '//input [@aria-describedby="name_help"] ' ); @@ -476,7 +476,7 @@ public function testHelpNotSetNotLinkedFromWidget() $this->renderHelp($view); $this->assertMatchesXpath($html, -'//input + '//input [not(@aria-describedby)] ' ); @@ -491,7 +491,7 @@ public function testErrors() $html = $this->renderErrors($view); $this->assertMatchesXpath($html, -'/ul + '/ul [ ./li[.="[trans]Error 1[/trans]"] /following-sibling::li[.="[trans]Error 2[/trans]"] @@ -508,7 +508,7 @@ public function testOverrideWidgetBlock() $html = $this->renderWidget($form->createView()); $this->assertMatchesXpath($html, -'/div + '/div [ ./input [@type="text"] @@ -524,7 +524,7 @@ public function testCheckedCheckbox() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="checkbox"] [@name="name"] [@checked="checked"] @@ -538,7 +538,7 @@ public function testUncheckedCheckbox() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="checkbox"] [@name="name"] [not(@checked)] @@ -553,7 +553,7 @@ public function testCheckboxWithValue() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="checkbox"] [@name="name"] [@value="foo&bar"] @@ -582,7 +582,7 @@ public function testSingleChoice() // then the select element must have a placeholder label option." $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -604,7 +604,7 @@ public function testSelectWithSizeBiggerThanOneCanBeRequired() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [@required="required"] [@size="2"] @@ -623,7 +623,7 @@ public function testSingleChoiceWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -647,7 +647,7 @@ public function testSingleChoiceWithPlaceholderWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -670,7 +670,7 @@ public function testSingleChoiceAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -692,7 +692,7 @@ public function testSingleChoiceAttributesWithMainAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], -'/select + '/select [@name="name"] [@class="bar&baz"] [not(@required)] @@ -715,7 +715,7 @@ public function testSingleExpandedChoiceAttributesWithMainAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], -'/div + '/div [@class="bar&baz"] [ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] @@ -741,7 +741,7 @@ public function testSingleChoiceWithPreferred() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --'], -'/select + '/select [@name="name"] [not(@required)] [ @@ -767,7 +767,7 @@ public function testSingleChoiceWithPreferredAndNoSeparator() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => null], -'/select + '/select [@name="name"] [not(@required)] [ @@ -792,7 +792,7 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() ]); $this->assertWidgetMatchesXpath($form->createView(), ['separator' => ''], -'/select + '/select [@name="name"] [not(@required)] [ @@ -818,7 +818,7 @@ public function testChoiceWithOnlyPreferred() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [count(./option)=5] ' ); @@ -834,7 +834,7 @@ public function testSingleChoiceNonRequired() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -857,7 +857,7 @@ public function testSingleChoiceNonRequiredNoneSelected() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -881,7 +881,7 @@ public function testSingleChoiceNonRequiredWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [ @@ -908,7 +908,7 @@ public function testSingleChoiceRequiredWithPlaceholder() // BlackBerry 10 browser. // See https://github.com/symfony/symfony/pull/7678 $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [@required="required"] [ @@ -934,7 +934,7 @@ public function testSingleChoiceRequiredWithPlaceholderViaView() // BlackBerry 10 browser. // See https://github.com/symfony/symfony/pull/7678 $this->assertWidgetMatchesXpath($form->createView(), ['placeholder' => ''], -'/select + '/select [@name="name"] [@required="required"] [ @@ -959,7 +959,7 @@ public function testSingleChoiceGrouped() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [./optgroup[@label="[trans]Group&1[/trans]"] [ @@ -987,7 +987,7 @@ public function testMultipleChoice() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name[]"] [@required="required"] [@multiple="multiple"] @@ -1011,7 +1011,7 @@ public function testMultipleChoiceAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name[]"] [@required="required"] [@multiple="multiple"] @@ -1034,7 +1034,7 @@ public function testMultipleChoiceSkipsPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name[]"] [@multiple="multiple"] [ @@ -1056,7 +1056,7 @@ public function testMultipleChoiceNonRequired() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name[]"] [@multiple="multiple"] [ @@ -1077,7 +1077,7 @@ public function testSingleChoiceExpanded() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] @@ -1101,7 +1101,7 @@ public function testSingleChoiceExpandedWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] /following-sibling::label[@for="name_0"][.="Choice&A"] @@ -1124,7 +1124,7 @@ public function testSingleChoiceExpandedAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] @@ -1148,7 +1148,7 @@ public function testSingleChoiceExpandedWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)] /following-sibling::label[@for="name_placeholder"][.="[trans]Test&Me[/trans]"] @@ -1175,7 +1175,7 @@ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)] /following-sibling::label[@for="name_placeholder"][.="Placeholder&Not&Translated"] @@ -1199,7 +1199,7 @@ public function testSingleChoiceExpandedWithBooleanValue() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="radio"][@name="name"][@id="name_0"][@checked] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] @@ -1222,7 +1222,7 @@ public function testMultipleChoiceExpanded() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] @@ -1248,7 +1248,7 @@ public function testMultipleChoiceExpandedWithoutTranslation() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] /following-sibling::label[@for="name_0"][.="Choice&A"] @@ -1274,7 +1274,7 @@ public function testMultipleChoiceExpandedAttributes() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] @@ -1294,7 +1294,7 @@ public function testCountry() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [./option[@value="AT"][@selected="selected"][.="Austria"]] [count(./option)>200] @@ -1310,7 +1310,7 @@ public function testCountryWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]] [./option[@value="AT"][@selected="selected"][.="Austria"]] @@ -1327,7 +1327,7 @@ public function testDateTime() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@id="name_date"] @@ -1367,7 +1367,7 @@ public function testDateTimeWithPlaceholderGlobal() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@id="name_date"] @@ -1408,7 +1408,7 @@ public function testDateTimeWithHourAndMinute() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@id="name_date"] @@ -1447,7 +1447,7 @@ public function testDateTimeWithSeconds() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./div [@id="name_date"] @@ -1490,7 +1490,7 @@ public function testDateTimeSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input [@type="date"] @@ -1517,7 +1517,7 @@ public function testDateTimeWithWidgetSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="datetime-local"] [@name="name"] [@value="2011-02-03T04:05:06"] @@ -1540,7 +1540,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="datetime-local"] [@name="name"] [@value="2011-02-03T04:05:06"] @@ -1556,7 +1556,7 @@ public function testDateChoice() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_month"] @@ -1583,7 +1583,7 @@ public function testDateChoiceWithPlaceholderGlobal() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_month"] @@ -1610,7 +1610,7 @@ public function testDateChoiceWithPlaceholderOnYear() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_month"] @@ -1635,7 +1635,7 @@ public function testDateText() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input [@id="name_month"] @@ -1663,7 +1663,7 @@ public function testDateSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="date"] [@name="name"] [@value="2011-02-03"] @@ -1690,7 +1690,7 @@ public function testBirthDay() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_month"] @@ -1716,7 +1716,7 @@ public function testBirthDayWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_month"] @@ -1741,7 +1741,7 @@ public function testEmail() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="email"] [@name="name"] [@value="foo&bar"] @@ -1757,7 +1757,7 @@ public function testEmailWithMaxLength() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="email"] [@name="name"] [@value="foo&bar"] @@ -1771,7 +1771,7 @@ public function testFile() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\FileType'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="file"] ' ); @@ -1782,7 +1782,7 @@ public function testHidden() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="hidden"] [@name="name"] [@value="foo&bar"] @@ -1797,7 +1797,7 @@ public function testDisabled() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@disabled="disabled"] @@ -1810,7 +1810,7 @@ public function testInteger() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="number"] [@name="name"] [@value="123"] @@ -1825,7 +1825,7 @@ public function testIntegerTypeWithGroupingRendersAsTextInput() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="123"] @@ -1838,7 +1838,7 @@ public function testLanguage() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [./option[@value="de"][@selected="selected"][.="German"]] [count(./option)>200] @@ -1851,7 +1851,7 @@ public function testLocale() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [./option[@value="de_AT"][@selected="selected"][.="German (Austria)"]] [count(./option)>200] @@ -1866,7 +1866,7 @@ public function testMoney() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="1234.56"] @@ -1880,7 +1880,7 @@ public function testNumber() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="1234.56"] @@ -1897,7 +1897,7 @@ public function testRenderNumberWithHtml5NumberType() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="number"] [@name="name"] [@value="1234.56"] @@ -1910,7 +1910,7 @@ public function testPassword() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="password"] [@name="name"] ' @@ -1925,7 +1925,7 @@ public function testPasswordSubmittedWithNotAlwaysEmpty() $form->submit('foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="password"] [@name="name"] [@value="foo&bar"] @@ -1940,7 +1940,7 @@ public function testPasswordWithMaxLength() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="password"] [@name="name"] [@maxlength="123"] @@ -1953,7 +1953,7 @@ public function testPercent() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="10"] @@ -1968,7 +1968,7 @@ public function testPercentNoSymbol() $form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => false]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="10"] @@ -1983,7 +1983,7 @@ public function testPercentCustomSymbol() $form = $this->factory->createNamed('name', PercentType::class, 0.1, ['symbol' => '‱']); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="10"] @@ -1997,7 +1997,7 @@ public function testCheckedRadio() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="radio"] [@name="name"] [@checked="checked"] @@ -2011,7 +2011,7 @@ public function testUncheckedRadio() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="radio"] [@name="name"] [not(@checked)] @@ -2026,7 +2026,7 @@ public function testRadioWithValue() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="radio"] [@name="name"] [@value="foo&bar"] @@ -2039,7 +2039,7 @@ public function testRange() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5]]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="range"] [@name="name"] [@value="42"] @@ -2053,7 +2053,7 @@ public function testRangeWithMinMaxValues() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5, 'max' => 57]]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="range"] [@name="name"] [@value="42"] @@ -2070,7 +2070,7 @@ public function testTextarea() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/textarea + '/textarea [@name="name"] [not(@pattern)] [.="foo&bar"] @@ -2083,7 +2083,7 @@ public function testText() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="foo&bar"] @@ -2099,7 +2099,7 @@ public function testTextWithMaxLength() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="foo&bar"] @@ -2113,7 +2113,7 @@ public function testSearch() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="search"] [@name="name"] [@value="foo&bar"] @@ -2130,7 +2130,7 @@ public function testTime() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_hour"] @@ -2154,7 +2154,7 @@ public function testTimeWithSeconds() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_hour"] @@ -2185,7 +2185,7 @@ public function testTimeText() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./input [@type="text"] @@ -2215,7 +2215,7 @@ public function testTimeSingleText() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="time"] [@name="name"] [@value="04:05"] @@ -2233,7 +2233,7 @@ public function testTimeWithPlaceholderGlobal() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_hour"] @@ -2258,7 +2258,7 @@ public function testTimeWithPlaceholderOnYear() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/div + '/div [ ./select [@id="name_hour"] @@ -2291,7 +2291,7 @@ public function testTimezone() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna'); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [@name="name"] [not(@required)] [./option[@value="Europe/Vienna"][@selected="selected"][.="Europe / Vienna"]] @@ -2308,7 +2308,7 @@ public function testTimezoneWithPlaceholder() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/select + '/select [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] [count(./option)>201] ' @@ -2321,7 +2321,7 @@ public function testUrlWithDefaultProtocol() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => 'http']); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="text"] [@name="name"] [@value="http://www.example.com?foo1=bar1&foo2=bar2"] @@ -2336,7 +2336,7 @@ public function testUrlWithoutDefaultProtocol() $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => null]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/input + '/input [@type="url"] [@name="name"] [@value="http://www.example.com?foo1=bar1&foo2=bar2"] @@ -2439,7 +2439,7 @@ public function testStartTagForPutRequest() $html = $this->renderStart($form->createView()); $this->assertMatchesXpath($html.'
', -'/form + '/form [./input[@type="hidden"][@name="_method"][@value="PUT"]] [@method="post"] [@action="http://example.com/directory"]' diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index 6240ad23168c4..5ce77a7f8aec4 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -24,7 +24,7 @@ public function testRow() $html = $this->renderRow($view); $this->assertMatchesXpath($html, -'/tr + '/tr [ ./td [./label[@for="name"]] @@ -48,7 +48,7 @@ public function testLabelIsNotRenderedWhenSetToFalse() $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, -'/tr + '/tr [ ./td [count(//label)=0] @@ -65,7 +65,7 @@ public function testRepeatedRow() $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, -'/tr + '/tr [ ./td [./label[@for="name_first"]] @@ -102,7 +102,7 @@ public function testRepeatedRowWithErrors() // (see RepeatedTypeValidatorExtension) $this->assertMatchesXpath($html, -'/tr + '/tr [ ./td [./label[@for="name_first"]] @@ -133,7 +133,7 @@ public function testButtonRow() $html = $this->renderRow($view); $this->assertMatchesXpath($html, -'/tr + '/tr [ ./td [.=""] @@ -166,7 +166,7 @@ public function testRest() $html = $this->renderRest($view); $this->assertMatchesXpath($html, -'/tr + '/tr [ ./td [./label[@for="name_field1"]] @@ -199,7 +199,7 @@ public function testCollection() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [ ./tr[./td/input[@type="text"][@value="a"]] /following-sibling::tr[./td/input[@type="text"][@value="b"]] @@ -217,7 +217,7 @@ public function testEmptyCollection() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [./tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]]] [count(./tr[./td/input])=1] ' @@ -240,7 +240,7 @@ public function testForm() ]); $this->assertMatchesXpath($html, -'/form + '/form [ ./input[@type="hidden"][@name="_method"][@value="PUT"] /following-sibling::table @@ -285,7 +285,7 @@ public function testFormWidget() ->createView(); $this->assertWidgetMatchesXpath($view, [], -'/table + '/table [ ./tr [ @@ -325,7 +325,7 @@ public function testNestedFormError() $form->get('child')->addError(new FormError('[trans]Error![/trans]')); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [ ./tr/td/ul[./li[.="[trans]Error![/trans]"]] /following-sibling::table[@id="name_child"] @@ -350,7 +350,7 @@ public function testCsrf() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [ ./tr[@style="display: none"] [./td[@colspan="2"]/input @@ -370,7 +370,7 @@ public function testRepeated() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [ ./tr [ @@ -406,7 +406,7 @@ public function testRepeatedWithCustomOptions() ]); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [ ./tr [ @@ -444,7 +444,7 @@ public function testCollectionRowWithCustomBlock() ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), [], -'/table + '/table [ ./tr[./td/label[.="Custom label: [trans]0[/trans]"]] /following-sibling::tr[./td/label[.="Custom label: [trans]1[/trans]"]] @@ -473,7 +473,7 @@ public function testFormEndWithRest() // manually, they should call form_rest() explicitly within the // tag. $this->assertMatchesXpath(''.$html, -'/form + '/form [ ./tr [ diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index 25fb551df7ce8..d9251250863ca 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -216,12 +216,12 @@ public function testCreateViewFlat() $view = $this->factory->createView($this->list); $this->assertEquals(new ChoiceListView( - [ - 0 => new ChoiceView($this->obj1, '0', 'A'), - 1 => new ChoiceView($this->obj2, '1', 'B'), - 2 => new ChoiceView($this->obj3, '2', 'C'), - 3 => new ChoiceView($this->obj4, '3', 'D'), - ], [] + [ + 0 => new ChoiceView($this->obj1, '0', 'A'), + 1 => new ChoiceView($this->obj2, '1', 'B'), + 2 => new ChoiceView($this->obj3, '2', 'C'), + 3 => new ChoiceView($this->obj4, '3', 'D'), + ], [] ), $view); } @@ -296,12 +296,12 @@ public function testCreateViewFlatPreferredChoicesEmptyArray() ); $this->assertEquals(new ChoiceListView( - [ - 0 => new ChoiceView($this->obj1, '0', 'A'), - 1 => new ChoiceView($this->obj2, '1', 'B'), - 2 => new ChoiceView($this->obj3, '2', 'C'), - 3 => new ChoiceView($this->obj4, '3', 'D'), - ], [] + [ + 0 => new ChoiceView($this->obj1, '0', 'A'), + 1 => new ChoiceView($this->obj2, '1', 'B'), + 2 => new ChoiceView($this->obj3, '2', 'C'), + 3 => new ChoiceView($this->obj4, '3', 'D'), + ], [] ), $view); } @@ -769,64 +769,64 @@ private function assertObjectListWithCustomValues(ChoiceListInterface $list) private function assertFlatView($view) { $this->assertEquals(new ChoiceListView( - [ - 0 => new ChoiceView($this->obj1, '0', 'A'), - 1 => new ChoiceView($this->obj2, '1', 'B'), - 2 => new ChoiceView($this->obj3, '2', 'C'), - 3 => new ChoiceView($this->obj4, '3', 'D'), - ], [ - 1 => new ChoiceView($this->obj2, '1', 'B'), - 2 => new ChoiceView($this->obj3, '2', 'C'), - ] + [ + 0 => new ChoiceView($this->obj1, '0', 'A'), + 1 => new ChoiceView($this->obj2, '1', 'B'), + 2 => new ChoiceView($this->obj3, '2', 'C'), + 3 => new ChoiceView($this->obj4, '3', 'D'), + ], [ + 1 => new ChoiceView($this->obj2, '1', 'B'), + 2 => new ChoiceView($this->obj3, '2', 'C'), + ] ), $view); } private function assertFlatViewWithCustomIndices($view) { $this->assertEquals(new ChoiceListView( - [ - 'w' => new ChoiceView($this->obj1, '0', 'A'), - 'x' => new ChoiceView($this->obj2, '1', 'B'), - 'y' => new ChoiceView($this->obj3, '2', 'C'), - 'z' => new ChoiceView($this->obj4, '3', 'D'), - ], [ - 'x' => new ChoiceView($this->obj2, '1', 'B'), - 'y' => new ChoiceView($this->obj3, '2', 'C'), - ] + [ + 'w' => new ChoiceView($this->obj1, '0', 'A'), + 'x' => new ChoiceView($this->obj2, '1', 'B'), + 'y' => new ChoiceView($this->obj3, '2', 'C'), + 'z' => new ChoiceView($this->obj4, '3', 'D'), + ], [ + 'x' => new ChoiceView($this->obj2, '1', 'B'), + 'y' => new ChoiceView($this->obj3, '2', 'C'), + ] ), $view); } private function assertFlatViewWithAttr($view) { $this->assertEquals(new ChoiceListView( - [ - 0 => new ChoiceView($this->obj1, '0', 'A'), - 1 => new ChoiceView( - $this->obj2, - '1', - 'B', - ['attr1' => 'value1'] - ), - 2 => new ChoiceView( - $this->obj3, - '2', - 'C', - ['attr2' => 'value2'] - ), - 3 => new ChoiceView($this->obj4, '3', 'D'), - ], [ - 1 => new ChoiceView( - $this->obj2, - '1', - 'B', - ['attr1' => 'value1'] - ), - 2 => new ChoiceView( - $this->obj3, - '2', - 'C', - ['attr2' => 'value2'] - ), + [ + 0 => new ChoiceView($this->obj1, '0', 'A'), + 1 => new ChoiceView( + $this->obj2, + '1', + 'B', + ['attr1' => 'value1'] + ), + 2 => new ChoiceView( + $this->obj3, + '2', + 'C', + ['attr2' => 'value2'] + ), + 3 => new ChoiceView($this->obj4, '3', 'D'), + ], [ + 1 => new ChoiceView( + $this->obj2, + '1', + 'B', + ['attr1' => 'value1'] + ), + 2 => new ChoiceView( + $this->obj3, + '2', + 'C', + ['attr2' => 'value2'] + ), ] ), $view); } @@ -834,30 +834,30 @@ private function assertFlatViewWithAttr($view) private function assertGroupedView($view) { $this->assertEquals(new ChoiceListView( - [ - 'Group 1' => new ChoiceGroupView( - 'Group 1', - [ - 0 => new ChoiceView($this->obj1, '0', 'A'), - 1 => new ChoiceView($this->obj2, '1', 'B'), - ] - ), - 'Group 2' => new ChoiceGroupView( - 'Group 2', - [ - 2 => new ChoiceView($this->obj3, '2', 'C'), - 3 => new ChoiceView($this->obj4, '3', 'D'), - ] - ), - ], [ - 'Group 1' => new ChoiceGroupView( - 'Group 1', - [1 => new ChoiceView($this->obj2, '1', 'B')] - ), - 'Group 2' => new ChoiceGroupView( - 'Group 2', - [2 => new ChoiceView($this->obj3, '2', 'C')] - ), + [ + 'Group 1' => new ChoiceGroupView( + 'Group 1', + [ + 0 => new ChoiceView($this->obj1, '0', 'A'), + 1 => new ChoiceView($this->obj2, '1', 'B'), + ] + ), + 'Group 2' => new ChoiceGroupView( + 'Group 2', + [ + 2 => new ChoiceView($this->obj3, '2', 'C'), + 3 => new ChoiceView($this->obj4, '3', 'D'), + ] + ), + ], [ + 'Group 1' => new ChoiceGroupView( + 'Group 1', + [1 => new ChoiceView($this->obj2, '1', 'B')] + ), + 'Group 2' => new ChoiceGroupView( + 'Group 2', + [2 => new ChoiceView($this->obj3, '2', 'C')] + ), ] ), $view); } diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index 431fcc16a8819..29789215115b4 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -55,7 +55,7 @@ public function testDebugDeprecatedDefaults() TXT - , $tester->getDisplay(true)); + , $tester->getDisplay(true)); } public function testDebugSingleFormType() @@ -137,7 +137,7 @@ public function testDebugAmbiguousFormTypeInteractive() %A\A\AmbiguousType (Block prefix: "ambiguous") %A TXT - , $output); + , $output); } public function testDebugInvalidFormType() diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index ec05102496613..fcfd8fe9e520f 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -806,9 +806,9 @@ public function testGetErrors() $errors = $this->form->getErrors(); $this->assertSame( - "ERROR: Error 1\n". - "ERROR: Error 2\n", - (string) $errors + "ERROR: Error 1\n". + "ERROR: Error 2\n", + (string) $errors ); $this->assertSame([$error1, $error2], iterator_to_array($errors)); @@ -826,15 +826,15 @@ public function testGetErrorsDeep() $errors = $this->form->getErrors(true); $this->assertSame( - "ERROR: Error 1\n". - "ERROR: Error 2\n". - "ERROR: Nested Error\n", - (string) $errors + "ERROR: Error 1\n". + "ERROR: Error 2\n". + "ERROR: Nested Error\n", + (string) $errors ); $this->assertSame( - [$error1, $error2, $nestedError], - iterator_to_array($errors) + [$error1, $error2, $nestedError], + iterator_to_array($errors) ); } @@ -850,11 +850,11 @@ public function testGetErrorsDeepRecursive() $errors = $this->form->getErrors(true, false); $this->assertSame( - "ERROR: Error 1\n". - "ERROR: Error 2\n". - "Child:\n". - " ERROR: Nested Error\n", - (string) $errors + "ERROR: Error 1\n". + "ERROR: Error 2\n". + "Child:\n". + " ERROR: Nested Error\n", + (string) $errors ); $errorsAsArray = iterator_to_array($errors); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index ece8df76b2318..2212bcf99ef7e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -197,9 +197,9 @@ public function testTransformWrapsIntlErrors() // HOW TO REPRODUCE? - //$this->expectException(\Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException::class); + // $this->expectException(\Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException::class); - //$transformer->transform(1.5); + // $transformer->transform(1.5); } /** diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index a7299e67ba237..4bdfff1ed053b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -41,8 +41,8 @@ public function dataProvider(): array // this will not work as PHP will use actual date to replace missing info // and after change of date will lookup for closest Wednesday // i.e. value: 2010-02, PHP value: 2010-02-(today i.e. 20), parsed date: 2010-02-24 - //['Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'], - //['Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'], + // ['Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'], + // ['Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'], // different month representations ['Y-n-d', '2010-2-03', '2010-02-03 00:00:00 UTC'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorFunctionalTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorFunctionalTest.php index 35712707b1aca..3a04363578129 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorFunctionalTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorFunctionalTest.php @@ -465,12 +465,12 @@ function () { } )); $formBuilder->get('field2')->addModelTransformer(new CallbackTransformer( - function () { - }, - function () { - throw new TransformationFailedException('This value is invalid.'); - } - )); + function () { + }, + function () { + throw new TransformationFailedException('This value is invalid.'); + } + )); $form = $formBuilder->getForm(); $form->submit([ diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index 58b8d4e05f892..1cedb568c3bde 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -309,9 +309,9 @@ public function testAddInvalidErrorEvenIfNoValidationGroups() ]) ->setData($object) ->addViewTransformer(new CallbackTransformer( - function ($data) { return $data; }, - function () { throw new TransformationFailedException(); } - )) + function ($data) { return $data; }, + function () { throw new TransformationFailedException(); } + )) ->getForm(); // Launch transformer diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 0b1dab5485ecc..b7899369f32ce 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -66,7 +66,7 @@ public function testGroupSequenceWithConstraintsOption() $form = Forms::createFormFactoryBuilder() ->addExtension(new ValidatorExtension(Validation::createValidator())) ->getFormFactory() - ->create(FormTypeTest::TESTED_TYPE, null, (['validation_groups' => new GroupSequence(['First', 'Second'])])) + ->create(FormTypeTest::TESTED_TYPE, null, ['validation_groups' => new GroupSequence(['First', 'Second'])]) ->add('field', TextTypeTest::TESTED_TYPE, [ 'constraints' => [ new Length(['min' => 10, 'groups' => ['First']] + $allowEmptyString), @@ -114,7 +114,7 @@ public function testManyFieldsGroupSequenceWithConstraintsOption() $form = Forms::createFormFactoryBuilder() ->addExtension(new ValidatorExtension($validator)) ->getFormFactory() - ->create(FormTypeTest::TESTED_TYPE, new Author(), (['validation_groups' => new GroupSequence(['First', 'Second'])])) + ->create(FormTypeTest::TESTED_TYPE, new Author(), ['validation_groups' => new GroupSequence(['First', 'Second'])]) ->add('firstName', TextTypeTest::TESTED_TYPE) ->add('lastName', TextTypeTest::TESTED_TYPE, [ 'constraints' => [ diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index f1f6ce80a585a..6d6b0a4d5ab42 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -169,7 +169,7 @@ public function testFalseIsConvertedToNull() $config = new FormConfigBuilder('name', null, new EventDispatcher()); $config->addEventListener(FormEvents::PRE_SUBMIT, static function (FormEvent $event) use (&$passedDataIsNull): void { - $passedDataIsNull = $event->getData() === null; + $passedDataIsNull = null === $event->getData(); }); $form = new Form($config); diff --git a/src/Symfony/Component/Form/Util/ServerParams.php b/src/Symfony/Component/Form/Util/ServerParams.php index 446e9cfed3707..02a038db2aea4 100644 --- a/src/Symfony/Component/Form/Util/ServerParams.php +++ b/src/Symfony/Component/Form/Util/ServerParams.php @@ -62,8 +62,11 @@ public function getPostMaxSize() switch (substr($iniMax, -1)) { case 't': $max *= 1024; + // no break case 'g': $max *= 1024; + // no break case 'm': $max *= 1024; + // no break case 'k': $max *= 1024; } @@ -77,7 +80,7 @@ public function getPostMaxSize() */ public function getNormalizedIniPostMaxSize() { - return strtoupper(trim(ini_get('post_max_size'))); + return strtoupper(trim(\ini_get('post_max_size'))); } /** diff --git a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php index 9247b7479a4e1..b81000647fd94 100644 --- a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php +++ b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php @@ -37,7 +37,7 @@ public function registerClient(string $name, TraceableHttpClient $client) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $this->reset(); diff --git a/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php b/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php index 7ab27524faa0f..8cbaa1cd106ff 100644 --- a/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php +++ b/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php @@ -61,7 +61,7 @@ public function __construct(ResponseInterface $response) $separator = isset($body['hydra:title'], $body['hydra:description']) ? "\n\n" : ''; $message = ($body['hydra:title'] ?? '').$separator.($body['hydra:description'] ?? ''); } elseif ((isset($body['title']) || isset($body['detail'])) - && (is_scalar($body['title'] ?? '') && is_scalar($body['detail'] ?? ''))) { + && (\is_scalar($body['title'] ?? '') && \is_scalar($body['detail'] ?? ''))) { // see RFC 7807 and https://jsonapi.org/format/#error-objects $separator = isset($body['title'], $body['detail']) ? "\n\n" : ''; $message = ($body['title'] ?? '').$separator.($body['detail'] ?? ''); diff --git a/src/Symfony/Component/HttpClient/HttpClient.php b/src/Symfony/Component/HttpClient/HttpClient.php index 1828413294cbd..fd963d05940d6 100644 --- a/src/Symfony/Component/HttpClient/HttpClient.php +++ b/src/Symfony/Component/HttpClient/HttpClient.php @@ -30,7 +30,7 @@ final class HttpClient public static function create(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50): HttpClientInterface { if (\extension_loaded('curl')) { - if ('\\' !== \DIRECTORY_SEPARATOR || isset($defaultOptions['cafile']) || isset($defaultOptions['capath']) || ini_get('curl.cainfo') || ini_get('openssl.cafile') || ini_get('openssl.capath')) { + if ('\\' !== \DIRECTORY_SEPARATOR || isset($defaultOptions['cafile']) || isset($defaultOptions['capath']) || \ini_get('curl.cainfo') || \ini_get('openssl.cafile') || \ini_get('openssl.capath')) { return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes); } diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 9fceef2fd6443..7f0965cb568dc 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -106,7 +106,7 @@ private static function prepareRequest(?string $method, ?string $url, array $opt } // Validate on_progress - if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) { + if (isset($options['on_progress']) && !\is_callable($onProgress = $options['on_progress'])) { throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress))); } @@ -160,7 +160,7 @@ private static function prepareRequest(?string $method, ?string $url, array $opt // Finalize normalization of options $options['http_version'] = (string) ($options['http_version'] ?? '') ?: null; - if (0 > $options['timeout'] = (float) ($options['timeout'] ?? ini_get('default_socket_timeout'))) { + if (0 > $options['timeout'] = (float) ($options['timeout'] ?? \ini_get('default_socket_timeout'))) { $options['timeout'] = 172800.0; // 2 days } @@ -195,9 +195,11 @@ private static function mergeDefaultOptions(array $options, array $defaultOption $options += $defaultOptions; - foreach (isset(self::$emptyDefaults) ? self::$emptyDefaults : [] as $k => $v) { - if (!isset($options[$k])) { - $options[$k] = $v; + if (isset(self::$emptyDefaults)) { + foreach (self::$emptyDefaults as $k => $v) { + if (!isset($options[$k])) { + $options[$k] = $v; + } } } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 2fc42c0b66229..aa2c08145b2c1 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -292,7 +292,7 @@ private static function perform(ClientState $multi, array &$responses = null): v $id = (int) $ch = $info['handle']; $waitFor = @curl_getinfo($ch, \CURLINFO_PRIVATE) ?: '_0'; - if (\in_array($result, [\CURLE_SEND_ERROR, \CURLE_RECV_ERROR, /*CURLE_HTTP2*/ 16, /*CURLE_HTTP2_STREAM*/ 92], true) && $waitFor[1] && 'C' !== $waitFor[0]) { + if (\in_array($result, [\CURLE_SEND_ERROR, \CURLE_RECV_ERROR, /* CURLE_HTTP2 */ 16, /* CURLE_HTTP2_STREAM */ 92], true) && $waitFor[1] && 'C' !== $waitFor[0]) { curl_multi_remove_handle($multi->handle, $ch); $waitFor[1] = (string) ((int) $waitFor[1] - 1); // decrement the retry counter curl_setopt($ch, \CURLOPT_PRIVATE, $waitFor); diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 238c254cbdcda..f44eb6daf44e9 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -34,6 +34,7 @@ class BinaryFileResponse extends Response protected $offset = 0; protected $maxlen = -1; protected $deleteFileAfterSend = false; + protected $chunkSize = 8 * 1024; /** * @param \SplFileInfo|string $file The file to stream @@ -124,6 +125,22 @@ public function getFile() return $this->file; } + /** + * Sets the response stream chunk size. + * + * @return $this + */ + public function setChunkSize(int $chunkSize): self + { + if ($chunkSize < 1 || $chunkSize > \PHP_INT_MAX) { + throw new \LogicException('The chunk size of a BinaryFileResponse cannot be less than 1 or greater than PHP_INT_MAX.'); + } + + $this->chunkSize = $chunkSize; + + return $this; + } + /** * Automatically sets the Last-Modified header according the file modification date. */ @@ -303,7 +320,23 @@ public function sendContent() $out = fopen('php://output', 'w'); $file = fopen($this->file->getPathname(), 'r'); - stream_copy_to_stream($file, $out, $this->maxlen, $this->offset); + ignore_user_abort(true); + + if (0 !== $this->offset) { + fseek($file, $this->offset); + } + + $length = $this->maxlen; + while ($length && !feof($file)) { + $read = ($length > $this->chunkSize) ? $this->chunkSize : $length; + $length -= $read; + + stream_copy_to_stream($file, $out, $read); + + if (connection_aborted()) { + break; + } + } fclose($out); fclose($file); diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 3e482b8a830fa..6148f1d8b0f4b 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -243,8 +243,8 @@ public function move($directory, $name = null) */ public static function getMaxFilesize() { - $sizePostMax = self::parseFilesize(ini_get('post_max_size')); - $sizeUploadMax = self::parseFilesize(ini_get('upload_max_filesize')); + $sizePostMax = self::parseFilesize(\ini_get('post_max_size')); + $sizeUploadMax = self::parseFilesize(\ini_get('upload_max_filesize')); return min($sizePostMax ?: \PHP_INT_MAX, $sizeUploadMax ?: \PHP_INT_MAX); } @@ -273,8 +273,11 @@ private static function parseFilesize(string $size) switch (substr($size, -1)) { case 't': $max *= 1024; + // no break case 'g': $max *= 1024; + // no break case 'm': $max *= 1024; + // no break case 'k': $max *= 1024; } diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index 9fb113de44e26..ac61ab2b64d7c 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -62,7 +62,7 @@ public function __toString() * * @return array An array of headers */ - public function all(/*string $key = null*/) + public function all(/* string $key = null */) { if (1 <= \func_num_args() && null !== $key = func_get_arg(0)) { return $this->headers[strtr($key, self::UPPER, self::LOWER)] ?? []; diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index cbe61a152a885..4b2c4d96752c4 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -551,7 +551,7 @@ public function overrideGlobals() $request = ['g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE]; - $requestOrder = ini_get('request_order') ?: ini_get('variables_order'); + $requestOrder = \ini_get('request_order') ?: \ini_get('variables_order'); $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp'; $_REQUEST = [[]]; diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index bfdc1b24a789a..c14a7bbfdfcb5 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -77,7 +77,7 @@ class Response public const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 public const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 public const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 - public const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; + public const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; // RFC7725 public const HTTP_INTERNAL_SERVER_ERROR = 500; public const HTTP_NOT_IMPLEMENTED = 501; public const HTTP_BAD_GATEWAY = 502; @@ -1236,6 +1236,7 @@ public static function closeOutputBuffers(int $targetLevel, bool $flush): void while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) { if ($flush) { ob_end_flush(); + flush(); } else { ob_end_clean(); } diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index 3dc5a801e3fc7..3c94cd2a68e8e 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -90,7 +90,7 @@ public function replace(array $headers = []) * * @param string|null $key The name of the headers to return or null to get them all */ - public function all(/*string $key = null*/) + public function all(/* string $key = null */) { $headers = parent::all(); @@ -254,7 +254,7 @@ public function getCookies($format = self::COOKIES_FLAT) * @param bool $httpOnly * @param string $sameSite */ - public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true/*, $sameSite = null*/) + public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true/* , $sameSite = null */) { $sameSite = \func_num_args() > 5 ? func_get_arg(5) : null; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php index 3ae8b9ea443de..dbbda3c39a028 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php @@ -35,8 +35,8 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess public function open($savePath, $sessionName) { $this->sessionName = $sessionName; - if (!headers_sent() && !ini_get('session.cache_limiter') && '0' !== ini_get('session.cache_limiter')) { - header(sprintf('Cache-Control: max-age=%d, private, must-revalidate', 60 * (int) ini_get('session.cache_expire'))); + if (!headers_sent() && !\ini_get('session.cache_limiter') && '0' !== \ini_get('session.cache_limiter')) { + header(sprintf('Cache-Control: max-age=%d, private, must-revalidate', 60 * (int) \ini_get('session.cache_expire'))); } return true; @@ -133,7 +133,7 @@ public function write($sessionId, $data) #[\ReturnTypeWillChange] public function destroy($sessionId) { - if (!headers_sent() && filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) { + if (!headers_sent() && filter_var(\ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) { if (!$this->sessionName) { throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', static::class)); } @@ -148,7 +148,7 @@ public function destroy($sessionId) */ if (null === $cookie || isset($_COOKIE[$this->sessionName])) { if (\PHP_VERSION_ID < 70300) { - setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), \FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), \FILTER_VALIDATE_BOOLEAN)); + setcookie($this->sessionName, '', 0, \ini_get('session.cookie_path'), \ini_get('session.cookie_domain'), filter_var(\ini_get('session.cookie_secure'), \FILTER_VALIDATE_BOOLEAN), filter_var(\ini_get('session.cookie_httponly'), \FILTER_VALIDATE_BOOLEAN)); } else { $params = session_get_cookie_params(); unset($params['lifetime']); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 2c3cb53c1e6dd..084556b2ece9d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -116,7 +116,7 @@ public function gc($maxlifetime) */ protected function doWrite($sessionId, $data) { - $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000); + $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) \ini_get('session.gc_maxlifetime')) * 1000); $fields = [ $this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(), @@ -139,7 +139,7 @@ protected function doWrite($sessionId, $data) #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $data) { - $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000); + $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) \ini_get('session.gc_maxlifetime')) * 1000); $this->getCollection()->updateOne( [$this->options['id_field'] => $sessionId], diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php index effc9db544bcf..1ca4bfeb08335 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php @@ -31,7 +31,7 @@ class NativeFileSessionHandler extends \SessionHandler public function __construct(string $savePath = null) { if (null === $savePath) { - $savePath = ini_get('session.save_path'); + $savePath = \ini_get('session.save_path'); } $baseDir = $savePath; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index ed09f72944495..78efa2e82b944 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -328,7 +328,7 @@ protected function doDestroy($sessionId) */ protected function doWrite($sessionId, $data) { - $maxlifetime = (int) ini_get('session.gc_maxlifetime'); + $maxlifetime = (int) \ini_get('session.gc_maxlifetime'); try { // We use a single MERGE SQL query when supported by the database. @@ -375,7 +375,7 @@ protected function doWrite($sessionId, $data) #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $data) { - $expiry = time() + (int) ini_get('session.gc_maxlifetime'); + $expiry = time() + (int) \ini_get('session.gc_maxlifetime'); try { $updateStmt = $this->pdo->prepare( @@ -650,7 +650,7 @@ protected function doRead($sessionId) throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.'); } - if (!filter_var(ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { + if (!filter_var(\ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { // In strict mode, session fixation is not possible: new sessions always start with a unique // random id, so that concurrency is not possible and this code path can be skipped. // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block @@ -898,7 +898,7 @@ private function getMergeStatement(string $sessionId, string $data, int $maxlife protected function getConnection() { if (null === $this->pdo) { - $this->connect($this->dsn ?: ini_get('session.save_path')); + $this->connect($this->dsn ?: \ini_get('session.save_path')); } return $this->pdo; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index 51bec203dfa17..d9bd3835abb1f 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -79,7 +79,7 @@ protected function doRead($sessionId): string */ protected function doWrite($sessionId, $data): bool { - $result = $this->redis->setEx($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime')), $data); + $result = $this->redis->setEx($this->prefix.$sessionId, (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime')), $data); return $result && !$result instanceof ErrorInterface; } @@ -120,6 +120,6 @@ public function gc($maxlifetime) #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $data) { - return (bool) $this->redis->expire($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime'))); + return (bool) $this->redis->expire($this->prefix.$sessionId, (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime'))); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php index 8efdb856f16e5..0a4dec605b3fc 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php @@ -163,6 +163,6 @@ private function stampCreated(int $lifetime = null): void { $timeStamp = time(); $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp; - $this->meta[self::LIFETIME] = $lifetime ?? (int) ini_get('session.cookie_lifetime'); + $this->meta[self::LIFETIME] = $lifetime ?? (int) \ini_get('session.cookie_lifetime'); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 4caba27dbc2df..6005df3462d6c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -148,12 +148,42 @@ public function start() throw new \RuntimeException('Failed to start the session: already started by PHP.'); } - if (filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN) && headers_sent($file, $line)) { + if (filter_var(\ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN) && headers_sent($file, $line)) { throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line)); } $sessionId = $_COOKIE[session_name()] ?? null; - if ($sessionId && $this->saveHandler instanceof AbstractProxy && 'files' === $this->saveHandler->getSaveHandlerName() && !preg_match('/^[a-zA-Z0-9,-]{22,}$/', $sessionId)) { + /* + * Explanation of the session ID regular expression: `/^[a-zA-Z0-9,-]{22,250}$/`. + * + * ---------- Part 1 + * + * The part `[a-zA-Z0-9,-]` is related to the PHP ini directive `session.sid_bits_per_character` defined as 6. + * See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character. + * Allowed values are integers such as: + * - 4 for range `a-f0-9` + * - 5 for range `a-v0-9` + * - 6 for range `a-zA-Z0-9,-` + * + * ---------- Part 2 + * + * The part `{22,250}` is related to the PHP ini directive `session.sid_length`. + * See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-length. + * Allowed values are integers between 22 and 256, but we use 250 for the max. + * + * Where does the 250 come from? + * - The length of Windows and Linux filenames is limited to 255 bytes. Then the max must not exceed 255. + * - The session filename prefix is `sess_`, a 5 bytes string. Then the max must not exceed 255 - 5 = 250. + * + * ---------- Conclusion + * + * The parts 1 and 2 prevent the warning below: + * `PHP Warning: SessionHandler::read(): Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed.` + * + * The part 2 prevents the warning below: + * `PHP Warning: SessionHandler::read(): open(filepath, O_RDWR) failed: No such file or directory (2).` + */ + if ($sessionId && $this->saveHandler instanceof AbstractProxy && 'files' === $this->saveHandler->getSaveHandlerName() && !preg_match('/^[a-zA-Z0-9,-]{22,250}$/', $sessionId)) { // the session ID in the header is invalid, create a new one session_id(session_create_id()); } @@ -221,7 +251,7 @@ public function regenerate($destroy = false, $lifetime = null) return false; } - if (null !== $lifetime && $lifetime != ini_get('session.cookie_lifetime')) { + if (null !== $lifetime && $lifetime != \ini_get('session.cookie_lifetime')) { $this->save(); ini_set('session.cookie_lifetime', $lifetime); $this->start(); @@ -256,7 +286,7 @@ public function save() unset($_SESSION[$key]); } } - if ([$key = $this->metadataBag->getStorageKey()] === array_keys($_SESSION)) { + if ($_SESSION && [$key = $this->metadataBag->getStorageKey()] === array_keys($_SESSION)) { unset($_SESSION[$key]); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php index 9b0cdeb7fe1d0..6539acf989387 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php @@ -22,7 +22,7 @@ public function __construct(\SessionHandlerInterface $handler) { $this->handler = $handler; $this->wrapper = $handler instanceof \SessionHandler; - $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user'; + $this->saveHandlerName = $this->wrapper ? \ini_get('session.save_handler') : 'user'; } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index 590483214dd68..17107b43406d0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -27,7 +27,7 @@ class UploadedFileTest extends TestCase { protected function setUp(): void { - if (!ini_get('file_uploads')) { + if (!\ini_get('file_uploads')) { $this->markTestSkipped('file_uploads is disabled in php.ini'); } } @@ -367,7 +367,7 @@ public function testGetMaxFilesize() $this->assertGreaterThan(0, $size); - if (0 === (int) ini_get('post_max_size') && 0 === (int) ini_get('upload_max_filesize')) { + if (0 === (int) \ini_get('post_max_size') && 0 === (int) \ini_get('upload_max_filesize')) { $this->assertSame(\PHP_INT_MAX, $size); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php index c4da2b8673ae0..d34e396aa6846 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php @@ -99,7 +99,7 @@ public function testUseSessionGcMaxLifetimeAsTimeToLive() $this->storage->write('id', 'data'); $ttl = $this->redisClient->ttl(self::PREFIX.'id'); - $this->assertLessThanOrEqual(ini_get('session.gc_maxlifetime'), $ttl); + $this->assertLessThanOrEqual(\ini_get('session.gc_maxlifetime'), $ttl); $this->assertGreaterThanOrEqual(0, $ttl); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index a96fcc42ade1d..ff9eabb092b0d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -121,7 +121,7 @@ public function testWrite() $this->assertEquals(['upsert' => true], $options); $data = $updateData['$set']; - $expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime'); + $expectedExpiry = time() + (int) \ini_get('session.gc_maxlifetime'); $this->assertInstanceOf(\MongoDB\BSON\Binary::class, $data[$this->options['data_field']]); $this->assertEquals('bar', $data[$this->options['data_field']]->getData()); $this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['time_field']]); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index 89e628754c370..ffb2e25bb8f28 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -29,10 +29,10 @@ public function testConstruct() { new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir())); - $this->assertEquals('user', ini_get('session.save_handler')); + $this->assertEquals('user', \ini_get('session.save_handler')); - $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); + $this->assertEquals(sys_get_temp_dir(), \ini_get('session.save_path')); + $this->assertEquals('TESTING', \ini_get('session.name')); } /** @@ -41,7 +41,7 @@ public function testConstruct() public function testConstructSavePath($savePath, $expectedSavePath, $path) { new NativeFileSessionHandler($savePath); - $this->assertEquals($expectedSavePath, ini_get('session.save_path')); + $this->assertEquals($expectedSavePath, \ini_get('session.save_path')); $this->assertDirectoryExists(realpath($path)); rmdir($path); @@ -66,9 +66,9 @@ public function testConstructException() public function testConstructDefault() { - $path = ini_get('session.save_path'); + $path = \ini_get('session.save_path'); new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler()); - $this->assertEquals($path, ini_get('session.save_path')); + $this->assertEquals($path, \ini_get('session.save_path')); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php index f793db144c6ac..76a8594b3118a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php @@ -29,7 +29,7 @@ class NullSessionHandlerTest extends TestCase public function testSaveHandlers() { $this->getStorage(); - $this->assertEquals('user', ini_get('session.save_handler')); + $this->assertEquals('user', \ini_get('session.save_handler')); } public function testSession() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 408ce32f33bae..21718c593a0f7 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -147,7 +147,7 @@ public function testReadConvertsStreamToString() public function testReadLockedConvertsStreamToString() { - if (filter_var(ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(\ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOLEAN)) { $this->markTestSkipped('Strict mode needs no locking for new sessions.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php index 46d6cd40151d5..dc9aee0be8fcf 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php @@ -33,7 +33,7 @@ public function testCreateHandler(string $connectionDSN, string $expectedPath, s $handler = SessionHandlerFactory::createHandler($connectionDSN); $this->assertInstanceOf($expectedHandlerType, $handler); - $this->assertEquals($expectedPath, ini_get('session.save_path')); + $this->assertEquals($expectedPath, \ini_get('session.save_path')); } public function provideConnectionDSN(): array @@ -41,7 +41,7 @@ public function provideConnectionDSN(): array $base = sys_get_temp_dir(); return [ - 'native file handler using save_path from php.ini' => ['connectionDSN' => 'file://', 'expectedPath' => ini_get('session.save_path'), 'expectedHandlerType' => StrictSessionHandler::class], + 'native file handler using save_path from php.ini' => ['connectionDSN' => 'file://', 'expectedPath' => \ini_get('session.save_path'), 'expectedHandlerType' => StrictSessionHandler::class], 'native file handler using provided save_path' => ['connectionDSN' => 'file://'.$base.'/session/storage', 'expectedPath' => $base.'/session/storage', 'expectedHandlerType' => StrictSessionHandler::class], ]; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 86b4dd505567b..f9c2a33edeafb 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -130,7 +130,7 @@ public function testRegenerateWithCustomLifetime() $storage->regenerate(false, $lifetime); $this->assertNotEquals($id, $storage->getId()); $this->assertEquals(11, $storage->getBag('attributes')->get('legs')); - $this->assertEquals($lifetime, ini_get('session.cookie_lifetime')); + $this->assertEquals($lifetime, \ini_get('session.cookie_lifetime')); } public function testSessionGlobalIsUpToDateAfterIdRegeneration() @@ -156,7 +156,7 @@ public function testDefaultSessionCacheLimiter() $this->iniSet('session.cache_limiter', 'nocache'); new NativeSessionStorage(); - $this->assertEquals('', ini_get('session.cache_limiter')); + $this->assertEquals('', \ini_get('session.cache_limiter')); } public function testExplicitSessionCacheLimiter() @@ -164,7 +164,7 @@ public function testExplicitSessionCacheLimiter() $this->iniSet('session.cache_limiter', 'nocache'); new NativeSessionStorage(['cache_limiter' => 'public']); - $this->assertEquals('public', ini_get('session.cache_limiter')); + $this->assertEquals('public', \ini_get('session.cache_limiter')); } public function testCookieOptions() @@ -201,8 +201,8 @@ public function testSessionOptions() $this->getStorage($options); - $this->assertSame('a=href', ini_get('url_rewriter.tags')); - $this->assertSame('200', ini_get('session.cache_expire')); + $this->assertSame('a=href', \ini_get('url_rewriter.tags')); + $this->assertSame('200', \ini_get('session.cache_expire')); } public function testSetSaveHandlerException() @@ -302,7 +302,7 @@ public function testRegenerateInvalidSessionIdForNativeFileSessionHandler() $started = $storage->start(); $this->assertTrue($started); - $this->assertMatchesRegularExpression('/^[a-zA-Z0-9,-]{22,}$/', session_id()); + $this->assertMatchesRegularExpression('/^[a-zA-Z0-9,-]{22,250}$/', session_id()); $storage->save(); $_COOKIE[session_name()] = '&~['; @@ -311,7 +311,7 @@ public function testRegenerateInvalidSessionIdForNativeFileSessionHandler() $started = $storage->start(); $this->assertTrue($started); - $this->assertMatchesRegularExpression('/^[a-zA-Z0-9,-]{22,}$/', session_id()); + $this->assertMatchesRegularExpression('/^[a-zA-Z0-9,-]{22,250}$/', session_id()); $storage->save(); $_COOKIE[session_name()] = '&~['; @@ -321,4 +321,13 @@ public function testRegenerateInvalidSessionIdForNativeFileSessionHandler() $this->assertTrue($started); $this->assertSame('&~[', session_id()); } + + public function testSaveHandlesNullSessionGracefully() + { + $storage = $this->getStorage(); + $_SESSION = null; + $storage->save(); + + $this->addToAssertionCount(1); + } } diff --git a/src/Symfony/Component/HttpKernel/Config/FileLocator.php b/src/Symfony/Component/HttpKernel/Config/FileLocator.php index a30241970179e..2dda23470ae35 100644 --- a/src/Symfony/Component/HttpKernel/Config/FileLocator.php +++ b/src/Symfony/Component/HttpKernel/Config/FileLocator.php @@ -28,7 +28,7 @@ class FileLocator extends BaseFileLocator */ private $path; - public function __construct(KernelInterface $kernel/*, string $path = null, array $paths = [], bool $triggerDeprecation = true*/) + public function __construct(KernelInterface $kernel/* , string $path = null, array $paths = [], bool $triggerDeprecation = true */) { $this->kernel = $kernel; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/AjaxDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/AjaxDataCollector.php index 356ce227e8993..a134ebc25f11f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/AjaxDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/AjaxDataCollector.php @@ -28,7 +28,7 @@ class AjaxDataCollector extends DataCollector * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { // all collecting is done client side } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 2d3ad5ce4aac0..91b62899fa25e 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -57,7 +57,7 @@ public function setKernel(KernelInterface $kernel = null) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE); $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE); @@ -79,8 +79,8 @@ public function collect(Request $request, Response $response/*, \Throwable $exce 'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), - 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), - 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), + 'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), + 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), 'bundles' => [], 'sapi_name' => \PHP_SAPI, ]; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php b/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php index a302ad3009572..2ee955ba0c99f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php @@ -27,7 +27,7 @@ interface DataCollectorInterface extends ResetInterface * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/); + public function collect(Request $request, Response $response/* , \Throwable $exception = null */); /** * Returns the name of the collector. diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index a66224b6f4029..155d41c3cf414 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -49,9 +49,10 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface */ public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, $dumper = null) { + $fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->stopwatch = $stopwatch; - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->charset = $charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'; + $this->fileLinkFormat = $fileLinkFormat instanceof FileLinkFormatter && false === $fileLinkFormat->format('', 0) ? false : $fileLinkFormat; + $this->charset = $charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8'; $this->requestStack = $requestStack; $this->dumper = $dumper; @@ -105,7 +106,7 @@ public function dump(Data $data) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { if (!$this->dataCount) { $this->data = []; @@ -237,7 +238,7 @@ public function __destruct() $h = headers_list(); $i = \count($h); - array_unshift($h, 'Content-Type: '.ini_get('default_mimetype')); + array_unshift($h, 'Content-Type: '.\ini_get('default_mimetype')); while (0 !== stripos($h[$i], 'Content-Type:')) { --$i; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php index 89fd18338688f..24ed55961e3e4 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php @@ -43,7 +43,7 @@ public function __construct(EventDispatcherInterface $dispatcher = null, Request * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null; $this->data = [ diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php index 222cae5d2d24c..9868659b93494 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php @@ -29,7 +29,7 @@ class ExceptionDataCollector extends DataCollector * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $exception = 2 < \func_num_args() ? func_get_arg(2) : null; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 0e25f8960fe54..849adfd8cdf9c 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -44,7 +44,7 @@ public function __construct($logger = null, string $containerPathPrefix = null, * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php index 7119bf31ada8a..f6015bafad838 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php @@ -33,7 +33,7 @@ public function __construct() * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $this->updateMemoryUsage(); } @@ -45,7 +45,7 @@ public function reset() { $this->data = [ 'memory' => 0, - 'memory_limit' => $this->convertToBytes(ini_get('memory_limit')), + 'memory_limit' => $this->convertToBytes(\ini_get('memory_limit')), ]; } @@ -114,8 +114,11 @@ private function convertToBytes(string $memoryLimit) switch (substr($memoryLimit, -1)) { case 't': $max *= 1024; + // no break case 'g': $max *= 1024; + // no break case 'm': $max *= 1024; + // no break case 'k': $max *= 1024; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 1fb226d13c38f..2147c678f23b3 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -39,7 +39,7 @@ public function __construct() * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { // attributes are serialized and as they can be anything, they need to be converted to strings. $attributes = []; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php index 5f12392330883..8ff676cc83427 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php @@ -38,7 +38,7 @@ public function __construct() * * @final since Symfony 4.4 */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { if ($response instanceof RedirectResponse) { $this->data['redirect'] = true; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index b83c44a48dea5..c6166c8aaeb7f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -38,7 +38,7 @@ public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { if (null !== $this->kernel) { $startTime = $this->kernel->getStartTime(); diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 27c71708b2450..c235b1dbb2ef9 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -30,12 +30,12 @@ class FileLinkFormatter private $urlFormat; /** - * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand + * @param string|array|null $fileLinkFormat + * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ - public function __construct(string $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) + public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) { - $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - if ($fileLinkFormat && !\is_array($fileLinkFormat)) { + if (!\is_array($fileLinkFormat) && $fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) { $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f); $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE); } diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 5027bd11698dd..6563487f36107 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -54,7 +54,7 @@ class DebugHandlersListener implements EventSubscriberInterface */ public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true) { - $handler = set_exception_handler('var_dump'); + $handler = set_exception_handler('is_int'); $this->earlyHandler = \is_array($handler) ? $handler[0] : null; restore_exception_handler(); @@ -80,7 +80,7 @@ public function configure(Event $event = null) } $this->firstCall = $this->hasTerminatedWithException = false; - $handler = set_exception_handler('var_dump'); + $handler = set_exception_handler('is_int'); $handler = \is_array($handler) ? $handler[0] : null; restore_exception_handler(); diff --git a/src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php index 06d8c380bdbec..f59f86247bdd3 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php @@ -96,9 +96,11 @@ private function generateSignedFragmentUri(ControllerReference $uri, Request $re private function containsNonScalars(array $values): bool { foreach ($values as $value) { - if (\is_array($value)) { - return $this->containsNonScalars($value); - } elseif (!is_scalar($value) && null !== $value) { + if (\is_scalar($value) || null === $value) { + continue; + } + + if (!\is_array($value) || $this->containsNonScalars($value)) { return true; } } diff --git a/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php index bd8f85b19a807..bd86a42df5b21 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php @@ -80,7 +80,7 @@ private function checkNonScalar(array $values) foreach ($values as $key => $value) { if (\is_array($value)) { $this->checkNonScalar($value); - } elseif (!is_scalar($value) && null !== $value) { + } elseif (!\is_scalar($value) && null !== $value) { throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); } } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php index 3385940243470..9301d0c11bbf6 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php @@ -95,7 +95,7 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) try { $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); - if (!$response->isSuccessful()) { + if (!$response->isSuccessful() && Response::HTTP_NOT_MODIFIED !== $response->getStatusCode()) { throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index ca163944dddd8..978324f29fb6a 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,11 +76,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.43'; - public const VERSION_ID = 40443; + public const VERSION = '4.4.44'; + public const VERSION_ID = 40444; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 43; + public const RELEASE_VERSION = 44; public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; @@ -237,7 +237,7 @@ public function getBundle($name) /** * {@inheritdoc} */ - public function locateResource($name/*, $dir = null, $first = true, $triggerDeprecation = true*/) + public function locateResource($name/* , $dir = null, $first = true, $triggerDeprecation = true */) { if (2 <= \func_num_args()) { $dir = func_get_arg(1); diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/Component/HttpKernel/KernelInterface.php index 00a1aec817e35..d18e3b22f07e1 100644 --- a/src/Symfony/Component/HttpKernel/KernelInterface.php +++ b/src/Symfony/Component/HttpKernel/KernelInterface.php @@ -87,7 +87,7 @@ public function getBundle($name); * @throws \InvalidArgumentException if the file cannot be found or the name is not valid * @throws \RuntimeException if the name contains invalid/unsafe characters */ - public function locateResource($name/*, $dir = null, $first = true*/); + public function locateResource($name/* , $dir = null, $first = true */); /** * Gets the name of the kernel. diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 3e1db33466f53..d7f297f5864cd 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -91,7 +91,7 @@ private function format(string $level, string $message, array $context, bool $pr if (str_contains($message, '{')) { $replacements = []; foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { + if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php index 60a623684cd02..32bde2bbc915b 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -143,7 +143,7 @@ public function find($ip, $url, $limit, $method, $start, $end, $statusCode = nul * * @return Profile|null A Profile instance or null if the profiler is disabled */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $exception = 2 < \func_num_args() ? func_get_arg(2) : null; diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 86bd394f56087..89e266c64a280 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -39,8 +39,8 @@ public function testCollect() $this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts()); $this->assertNull($c->getToken()); $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); - $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); - $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); + $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); + $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); @@ -83,8 +83,8 @@ public function testCollectWithoutKernel() $this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts()); $this->assertNull($c->getToken()); $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); - $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); - $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); + $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); + $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php index c69166bf09244..b86e53df79087 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector; +use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Dumper\CliDumper; use Symfony\Component\VarDumper\Server\Connection; @@ -28,7 +29,7 @@ public function testDump() { $data = new Data([[123]]); - $collector = new DumpDataCollector(); + $collector = new DumpDataCollector(null, new FileLinkFormatter([])); $this->assertSame('dump', $collector->getName()); diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php index 1f4d298bf3768..f649455764f78 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php @@ -20,7 +20,7 @@ class FileLinkFormatterTest extends TestCase { public function testWhenNoFileLinkFormatAndNoRequest() { - $sut = new FileLinkFormatter(); + $sut = new FileLinkFormatter([]); $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); } @@ -47,7 +47,7 @@ public function testWhenNoFileLinkFormatAndRequest() $request->server->set('SCRIPT_FILENAME', '/public/index.php'); $request->server->set('REQUEST_URI', '/index.php/example'); - $sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); + $sut = new FileLinkFormatter([], $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); $this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php index 9b49936f468b2..75a1ae7379a46 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php @@ -87,7 +87,7 @@ public function testResponseIsPrivateIfSessionStarted() $this->assertTrue($response->headers->hasCacheControlDirective('private')); $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate')); $this->assertSame('0', $response->headers->getCacheControlDirective('max-age')); - $this->assertLessThanOrEqual((new \DateTime('now', new \DateTimeZone('UTC'))), (new \DateTime($response->headers->get('Expires')))); + $this->assertLessThanOrEqual(new \DateTime('now', new \DateTimeZone('UTC')), new \DateTime($response->headers->get('Expires'))); $this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER)); } @@ -193,7 +193,7 @@ public function testSurrogateMasterRequestIsPublic() $this->assertSame('0', $response->headers->getCacheControlDirective('max-age')); $this->assertTrue($response->headers->has('Expires')); - $this->assertLessThanOrEqual((new \DateTime('now', new \DateTimeZone('UTC'))), (new \DateTime($response->headers->get('Expires')))); + $this->assertLessThanOrEqual(new \DateTime('now', new \DateTimeZone('UTC')), new \DateTime($response->headers->get('Expires'))); } public function testGetSessionIsCalledOnce() diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index e708c2ae5f4a6..32bd3ac7b5c75 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -221,6 +221,15 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() $this->assertEquals('bar', $esi->handle($cache, '/', '/alt', false)); } + public function testHandleWhenResponseIsNotModified() + { + $esi = new Esi(); + $response = new Response(''); + $response->setStatusCode(304); + $cache = $this->getCache(Request::create('/'), $response); + $this->assertEquals('', $esi->handle($cache, '/', '/alt', true)); + } + protected function getCache($request, $response) { $cache = $this->getMockBuilder(HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index ec57289ddeadf..dacb8a582977f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -662,7 +662,7 @@ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() $kernel->boot(); $preReBoot = $kernel->getStartTime(); - sleep(3600); //Intentionally large value to detect if ClockMock ever breaks + sleep(3600); // Intentionally large value to detect if ClockMock ever breaks $kernel->reboot(null); $this->assertGreaterThan($preReBoot, $kernel->getStartTime()); diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php index d2daa67bce0cd..884c446ae68ba 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php @@ -272,7 +272,7 @@ public function testDuplicates() $profile->setUrl('http://example.net/'); $profile->setMethod('GET'); - ///three duplicates + // three duplicates $this->storage->write($profile); $this->storage->write($profile); $this->storage->write($profile); diff --git a/src/Symfony/Component/Inflector/Tests/InflectorTest.php b/src/Symfony/Component/Inflector/Tests/InflectorTest.php index 5d7bf48761d45..dec90a6ff64e1 100644 --- a/src/Symfony/Component/Inflector/Tests/InflectorTest.php +++ b/src/Symfony/Component/Inflector/Tests/InflectorTest.php @@ -86,7 +86,7 @@ public function singularizeProvider() ['halves', ['half', 'halve', 'halff']], ['hats', 'hat'], ['heroes', ['hero', 'heroe']], - ['hippopotamuses', ['hippopotamus', 'hippopotamuse', 'hippopotamusis']], //hippopotami + ['hippopotamuses', ['hippopotamus', 'hippopotamuse', 'hippopotamusis']], // hippopotami ['hoaxes', 'hoax'], ['hooves', ['hoof', 'hoove', 'hooff']], ['houses', ['hous', 'house', 'housis']], @@ -129,7 +129,7 @@ public function singularizeProvider() ['roses', ['ros', 'rose', 'rosis']], ['sandwiches', ['sandwich', 'sandwiche']], ['scarves', ['scarf', 'scarve', 'scarff']], - ['schemas', 'schema'], //schemata + ['schemas', 'schema'], // schemata ['seasons', 'season'], ['selfies', 'selfie'], ['series', 'series'], @@ -159,9 +159,9 @@ public function singularizeProvider() ['SubTrees', 'SubTree'], // Known issues - //['insignia', 'insigne'], - //['insignias', 'insigne'], - //['rattles', 'rattle'], + // ['insignia', 'insigne'], + // ['insignias', 'insigne'], + // ['rattles', 'rattle'], ]; } @@ -175,7 +175,7 @@ public function pluralizeProvider() ['agenda', 'agendas'], ['alumnus', 'alumni'], ['analysis', 'analyses'], - ['antenna', 'antennas'], //antennae + ['antenna', 'antennas'], // antennae ['appendix', ['appendicies', 'appendixes']], ['arch', 'arches'], ['atlas', 'atlases'], @@ -220,7 +220,7 @@ public function pluralizeProvider() ['feedback', 'feedback'], ['focus', 'focuses'], ['foot', 'feet'], - ['formula', 'formulas'], //formulae + ['formula', 'formulas'], // formulae ['conspectus', 'conspectuses'], ['fungus', 'fungi'], ['garage', 'garages'], @@ -228,7 +228,7 @@ public function pluralizeProvider() ['half', ['halfs', 'halves']], ['hat', 'hats'], ['hero', 'heroes'], - ['hippopotamus', 'hippopotami'], //hippopotamuses + ['hippopotamus', 'hippopotami'], // hippopotamuses ['hoax', 'hoaxes'], ['hoof', ['hoofs', 'hooves']], ['house', 'houses'], @@ -268,7 +268,7 @@ public function pluralizeProvider() ['rose', 'roses'], ['sandwich', 'sandwiches'], ['scarf', ['scarfs', 'scarves']], - ['schema', 'schemas'], //schemata + ['schema', 'schemas'], // schemata ['season', 'seasons'], ['selfie', 'selfies'], ['series', 'series'], diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php index 4a4e38e3e1a1a..9672f39cd8030 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php @@ -57,7 +57,7 @@ public function format(\DateTime $dateTime, int $length): string return $dateTime->format('\G\M\TP'); } - return sprintf('GMT%s%d', ($offset >= 0 ? '+' : ''), $offset / 100); + return sprintf('GMT%s%d', $offset >= 0 ? '+' : '', $offset / 100); } /** diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index 77be43ba9b84e..defed4e35a787 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -137,7 +137,7 @@ protected function configureOptions(OptionsResolver $resolver) } if (!isset($parent['network_timeout'])) { - $options->setDefault('network_timeout', ini_get('default_socket_timeout')); + $options->setDefault('network_timeout', \ini_get('default_socket_timeout')); } $options->setDefaults([ diff --git a/src/Symfony/Component/Mailer/DataCollector/MessageDataCollector.php b/src/Symfony/Component/Mailer/DataCollector/MessageDataCollector.php index 122ab342ad24a..4f7d9005212b7 100644 --- a/src/Symfony/Component/Mailer/DataCollector/MessageDataCollector.php +++ b/src/Symfony/Component/Mailer/DataCollector/MessageDataCollector.php @@ -34,7 +34,7 @@ public function __construct(MessageLoggerListener $logger) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $this->data['events'] = $this->events; } diff --git a/src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php b/src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php index 119c1131abad7..99be0e01e6e87 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php @@ -142,10 +142,10 @@ public function testSendOneDeadButRecover() $t2 = $this->createMock(TransportInterface::class); $t2->expects($this->exactly(3)) ->method('send')->willReturnOnConsecutiveCalls( - null, - null, - $this->throwException(new TransportException()) - ); + null, + null, + $this->throwException(new TransportException()) + ); $t = new FailoverTransport([$t1, $t2], 1); $t->send(new RawMessage('')); sleep(1); diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php index 609c87d7e956d..2b8afd4c6fa67 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php @@ -75,7 +75,7 @@ public function readLine(): string } $line = fgets($this->out); - if (0 === \strlen($line)) { + if ('' === $line) { $metas = stream_get_meta_data($this->out); if ($metas['timed_out']) { throw new TransportException(sprintf('Connection to "%s" timed out.', $this->getReadConnectionDescription())); diff --git a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php index 8873f43cd44e8..defa1a4385b64 100644 --- a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php @@ -219,8 +219,11 @@ private function convertToBytes(string $memoryLimit): int switch (substr(rtrim($memoryLimit, 'b'), -1)) { case 't': $max *= 1024; + // no break case 'g': $max *= 1024; + // no break case 'm': $max *= 1024; + // no break case 'k': $max *= 1024; } diff --git a/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php b/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php index 6e182f544478b..b15418b085ff3 100644 --- a/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php +++ b/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php @@ -37,7 +37,7 @@ public function registerBus(string $name, TraceableMessageBus $bus) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { // Noop. Everything is collected live by the traceable buses & cloned as late as possible. } diff --git a/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php b/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php index 3a208deacc3e7..02a72de4b3984 100644 --- a/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Messenger\Exception; /** - * Base Message component's exception. + * Base Messenger component's exception. * * @author Samuel Roze */ diff --git a/src/Symfony/Component/Messenger/Retry/MultiplierRetryStrategy.php b/src/Symfony/Component/Messenger/Retry/MultiplierRetryStrategy.php index ba3dacf2515fd..8aefc2fe5afcf 100644 --- a/src/Symfony/Component/Messenger/Retry/MultiplierRetryStrategy.php +++ b/src/Symfony/Component/Messenger/Retry/MultiplierRetryStrategy.php @@ -80,6 +80,6 @@ public function getWaitingTime(Envelope $message): int return $this->maxDelayMilliseconds; } - return $delay; + return (int) ceil($delay); } } diff --git a/src/Symfony/Component/Messenger/Tests/DataCollector/MessengerDataCollectorTest.php b/src/Symfony/Component/Messenger/Tests/DataCollector/MessengerDataCollectorTest.php index a920e30125b47..af419bf7639af 100644 --- a/src/Symfony/Component/Messenger/Tests/DataCollector/MessengerDataCollectorTest.php +++ b/src/Symfony/Component/Messenger/Tests/DataCollector/MessengerDataCollectorTest.php @@ -122,7 +122,7 @@ public function testHandleWithException() ] ] DUMP - , $this->getDataAsString($messages[0])); + , $this->getDataAsString($messages[0])); } public function testKeepsOrderedDispatchCalls() diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php index f746689f99427..89170321a17d9 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php @@ -81,8 +81,8 @@ public function testEnvelopeKeepOnlyTheLast10Stamps() { $exception = new \Exception('no!'); $stamps = array_merge( - array_fill(0, 15, new DelayStamp(1)), - array_fill(0, 3, new RedeliveryStamp(1)) + array_fill(0, 15, new DelayStamp(1)), + array_fill(0, 3, new RedeliveryStamp(1)) ); $envelope = new Envelope(new \stdClass(), $stamps); diff --git a/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php b/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php index e1572bbbae58c..e2fdb4b2a82f3 100644 --- a/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php +++ b/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php @@ -52,7 +52,7 @@ public function testIsRetryableWithNoStamp() /** * @dataProvider getWaitTimeTests */ - public function testGetWaitTime(int $delay, int $multiplier, int $maxDelay, int $previousRetries, int $expectedDelay) + public function testGetWaitTime(int $delay, float $multiplier, int $maxDelay, int $previousRetries, int $expectedDelay) { $strategy = new MultiplierRetryStrategy(10, $delay, $multiplier, $maxDelay); $envelope = new Envelope(new \stdClass(), [new RedeliveryStamp($previousRetries)]); @@ -83,5 +83,10 @@ public function getWaitTimeTests(): iterable // never a delay yield [0, 2, 10000, 0, 0]; yield [0, 2, 10000, 1, 0]; + + // Float delay + yield [1000, 1.5555, 5000, 0, 1000]; + yield [1000, 1.5555, 5000, 1, 1556]; + yield [1000, 1.5555, 5000, 2, 2420]; } } diff --git a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php index c00e8f86d3b18..83434752d91ec 100644 --- a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php @@ -25,6 +25,7 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\SchemaDiff; use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; @@ -453,8 +454,9 @@ private function updateSchema(): void return; } - $comparator = new Comparator(); - $schemaDiff = $comparator->compare($this->createSchemaManager()->createSchema(), $this->getSchema()); + $schemaManager = $this->createSchemaManager(); + $comparator = $this->createComparator($schemaManager); + $schemaDiff = $this->compareSchemas($comparator, $schemaManager->createSchema(), $this->getSchema()); foreach ($schemaDiff->toSaveSql($this->driverConnection->getDatabasePlatform()) as $sql) { if (method_exists($this->driverConnection, 'executeStatement')) { @@ -471,4 +473,18 @@ private function createSchemaManager(): AbstractSchemaManager ? $this->driverConnection->createSchemaManager() : $this->driverConnection->getSchemaManager(); } + + private function createComparator(AbstractSchemaManager $schemaManager): Comparator + { + return method_exists($schemaManager, 'createComparator') + ? $schemaManager->createComparator() + : new Comparator(); + } + + private function compareSchemas(Comparator $comparator, Schema $from, Schema $to): SchemaDiff + { + return method_exists($comparator, 'compareSchemas') + ? $comparator->compareSchemas($from, $to) + : $comparator->compare($from, $to); + } } diff --git a/src/Symfony/Component/Messenger/Transport/Sender/SendersLocator.php b/src/Symfony/Component/Messenger/Transport/Sender/SendersLocator.php index b14434bff2a9c..f228d4f9789b8 100644 --- a/src/Symfony/Component/Messenger/Transport/Sender/SendersLocator.php +++ b/src/Symfony/Component/Messenger/Transport/Sender/SendersLocator.php @@ -32,7 +32,7 @@ class SendersLocator implements SendersLocatorInterface * @param string[][] $sendersMap An array, keyed by "type", set to an array of sender aliases * @param ContainerInterface $sendersLocator Locator of senders, keyed by sender alias */ - public function __construct(array $sendersMap, /*ContainerInterface*/ $sendersLocator = null) + public function __construct(array $sendersMap, /* ContainerInterface */ $sendersLocator = null) { $this->sendersMap = $sendersMap; diff --git a/src/Symfony/Component/Mime/CharacterStream.php b/src/Symfony/Component/Mime/CharacterStream.php index 749066f2a8b7c..6400a4aa62eb1 100644 --- a/src/Symfony/Component/Mime/CharacterStream.php +++ b/src/Symfony/Component/Mime/CharacterStream.php @@ -81,17 +81,17 @@ public function __construct($input, ?string $charset = 'utf-8') $this->fixedWidth = 2; break; - // 32 bits + // 32 bits case 'ucs4': case 'ucs-4': case 'utf32': case 'utf-32': $this->fixedWidth = 4; - break; + break; - // 7-8 bit charsets: (us-)?ascii, (iso|iec)-?8859-?[0-9]+, windows-?125[0-9], cp-?[0-9]+, ansi, macintosh, + // 7-8 bit charsets: (us-)?ascii, (iso|iec)-?8859-?[0-9]+, windows-?125[0-9], cp-?[0-9]+, ansi, macintosh, // koi-?7, koi-?8-?.+, mik, (cork|t1), v?iscii - // and fallback + // and fallback default: $this->fixedWidth = 1; } diff --git a/src/Symfony/Component/Mime/Email.php b/src/Symfony/Component/Mime/Email.php index 5e31cb92a85f2..29da5ef2fdcb9 100644 --- a/src/Symfony/Component/Mime/Email.php +++ b/src/Symfony/Component/Mime/Email.php @@ -43,6 +43,10 @@ class Email extends Message private $html; private $htmlCharset; private $attachments = []; + /** + * @var AbstractPart|null + */ + private $cachedBody; // Used to avoid wrong body hash in DKIM signatures with multiple parts (e.g. HTML + TEXT) due to multiple boundaries. /** * @return $this @@ -282,6 +286,7 @@ public function text($body, string $charset = 'utf-8') throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body))); } + $this->cachedBody = null; $this->text = $body; $this->textCharset = $charset; @@ -312,6 +317,7 @@ public function html($body, string $charset = 'utf-8') throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body))); } + $this->cachedBody = null; $this->html = $body; $this->htmlCharset = $charset; @@ -342,6 +348,7 @@ public function attach($body, string $name = null, string $contentType = null) throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body))); } + $this->cachedBody = null; $this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => false]; return $this; @@ -352,6 +359,7 @@ public function attach($body, string $name = null, string $contentType = null) */ public function attachFromPath(string $path, string $name = null, string $contentType = null) { + $this->cachedBody = null; $this->attachments[] = ['path' => $path, 'name' => $name, 'content-type' => $contentType, 'inline' => false]; return $this; @@ -368,6 +376,7 @@ public function embed($body, string $name = null, string $contentType = null) throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body))); } + $this->cachedBody = null; $this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => true]; return $this; @@ -378,6 +387,7 @@ public function embed($body, string $name = null, string $contentType = null) */ public function embedFromPath(string $path, string $name = null, string $contentType = null) { + $this->cachedBody = null; $this->attachments[] = ['path' => $path, 'name' => $name, 'content-type' => $contentType, 'inline' => true]; return $this; @@ -388,6 +398,7 @@ public function embedFromPath(string $path, string $name = null, string $content */ public function attachPart(DataPart $part) { + $this->cachedBody = null; $this->attachments[] = ['part' => $part]; return $this; @@ -446,6 +457,10 @@ public function ensureValidity() */ private function generateBody(): AbstractPart { + if (null !== $this->cachedBody) { + return $this->cachedBody; + } + $this->ensureValidity(); [$htmlPart, $attachmentParts, $inlineParts] = $this->prepareParts(); @@ -471,7 +486,7 @@ private function generateBody(): AbstractPart } } - return $part; + return $this->cachedBody = $part; } private function prepareParts(): ?array @@ -492,25 +507,37 @@ private function prepareParts(): ?array $names = array_filter(array_unique(array_merge($names[2], $names[3]))); } + // usage of reflection is a temporary workaround for missing getters that will be added in 6.2 + $dispositionRef = new \ReflectionProperty(TextPart::class, 'disposition'); + $dispositionRef->setAccessible(true); + $nameRef = new \ReflectionProperty(TextPart::class, 'name'); + $nameRef->setAccessible(true); $attachmentParts = $inlineParts = []; foreach ($this->attachments as $attachment) { + $part = $this->createDataPart($attachment); + if (isset($attachment['part'])) { + $attachment['name'] = $nameRef->getValue($part); + } + foreach ($names as $name) { - if (isset($attachment['part'])) { - continue; - } if ($name !== $attachment['name']) { continue; } if (isset($inlineParts[$name])) { continue 2; } - $attachment['inline'] = true; - $inlineParts[$name] = $part = $this->createDataPart($attachment); + $part->setDisposition('inline'); $html = str_replace('cid:'.$name, 'cid:'.$part->getContentId(), $html); $part->setName($part->getContentId()); - continue 2; + + break; + } + + if ('inline' === $dispositionRef->getValue($part)) { + $inlineParts[$attachment['name']] = $part; + } else { + $attachmentParts[] = $part; } - $attachmentParts[] = $this->createDataPart($attachment); } if (null !== $htmlPart) { $htmlPart = new TextPart($html, $this->htmlCharset, 'html'); diff --git a/src/Symfony/Component/Mime/Header/AbstractHeader.php b/src/Symfony/Component/Mime/Header/AbstractHeader.php index b82eb53ec6eb9..5de9066873edc 100644 --- a/src/Symfony/Component/Mime/Header/AbstractHeader.php +++ b/src/Symfony/Component/Mime/Header/AbstractHeader.php @@ -109,6 +109,11 @@ protected function createPhrase(HeaderInterface $header, string $string, string } $phraseStr = $this->encodeWords($header, $string, $usedLength); } + } elseif (str_contains($phraseStr, '(')) { + foreach (['\\', '"'] as $char) { + $phraseStr = str_replace($char, '\\'.$char, $phraseStr); + } + $phraseStr = '"'.$phraseStr.'"'; } return $phraseStr; @@ -195,7 +200,7 @@ protected function getTokenAsEncodedWord(string $token, int $firstLineOffset = 0 $encodingWrapperLength = \strlen('=?'.$charsetDecl.'?'.self::$encoder->getName().'??='); if ($firstLineOffset >= 75) { - //Does this logic need to be here? + // Does this logic need to be here? $firstLineOffset = 0; } diff --git a/src/Symfony/Component/Mime/MessageConverter.php b/src/Symfony/Component/Mime/MessageConverter.php index a810cb704a394..4163e51cd25af 100644 --- a/src/Symfony/Component/Mime/MessageConverter.php +++ b/src/Symfony/Component/Mime/MessageConverter.php @@ -83,7 +83,7 @@ private static function createEmailFromAlternativePart(Message $message, Alterna 2 === \count($parts) && $parts[0] instanceof TextPart && 'text' === $parts[0]->getMediaType() && 'plain' === $parts[0]->getMediaSubtype() && $parts[1] instanceof TextPart && 'text' === $parts[1]->getMediaType() && 'html' === $parts[1]->getMediaSubtype() - ) { + ) { return (new Email(clone $message->getHeaders())) ->text($parts[0]->getBody(), $parts[0]->getPreparedHeaders()->getHeaderParameter('Content-Type', 'charset') ?: 'utf-8') ->html($parts[1]->getBody(), $parts[1]->getPreparedHeaders()->getHeaderParameter('Content-Type', 'charset') ?: 'utf-8') diff --git a/src/Symfony/Component/Mime/Tests/EmailTest.php b/src/Symfony/Component/Mime/Tests/EmailTest.php index a12ca180e611c..a79a785576361 100644 --- a/src/Symfony/Component/Mime/Tests/EmailTest.php +++ b/src/Symfony/Component/Mime/Tests/EmailTest.php @@ -246,76 +246,116 @@ public function testGetBody() $this->assertEquals($text, $e->getBody()); } - public function testGenerateBody() + public function testGenerateBodyWithTextOnly() { $text = new TextPart('text content'); - $html = new TextPart('html content', 'utf-8', 'html'); - $att = new DataPart($file = fopen(__DIR__.'/Fixtures/mimetypes/test', 'r')); - $img = new DataPart($image = fopen(__DIR__.'/Fixtures/mimetypes/test.gif', 'r'), 'test.gif'); - $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->text('text content'); $this->assertEquals($text, $e->getBody()); $this->assertEquals('text content', $e->getTextBody()); + } + public function testGenerateBodyWithHtmlOnly() + { + $html = new TextPart('html content', 'utf-8', 'html'); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html('html content'); $this->assertEquals($html, $e->getBody()); $this->assertEquals('html content', $e->getHtmlBody()); + } + public function testGenerateBodyWithTextAndHtml() + { + $text = new TextPart('text content'); + $html = new TextPart('html content', 'utf-8', 'html'); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html('html content'); $e->text('text content'); $this->assertEquals(new AlternativePart($text, $html), $e->getBody()); + } + public function testGenerateBodyWithTextAndHtmlNotUtf8() + { $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html('html content', 'iso-8859-1'); $e->text('text content', 'iso-8859-1'); $this->assertEquals('iso-8859-1', $e->getTextCharset()); $this->assertEquals('iso-8859-1', $e->getHtmlCharset()); $this->assertEquals(new AlternativePart(new TextPart('text content', 'iso-8859-1'), new TextPart('html content', 'iso-8859-1', 'html')), $e->getBody()); + } + public function testGenerateBodyWithTextContentAndAttachedFile() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->attach($file); $e->text('text content'); - $this->assertEquals(new MixedPart($text, $att), $e->getBody()); + $this->assertEquals(new MixedPart($text, $filePart), $e->getBody()); + } + public function testGenerateBodyWithHtmlContentAndAttachedFile() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->attach($file); $e->html('html content'); - $this->assertEquals(new MixedPart($html, $att), $e->getBody()); + $this->assertEquals(new MixedPart($html, $filePart), $e->getBody()); + } + public function testGenerateBodyWithAttachedFileOnly() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->attach($file); - $this->assertEquals(new MixedPart($att), $e->getBody()); + $this->assertEquals(new MixedPart($filePart), $e->getBody()); + } + public function testGenerateBodyWithTextAndHtmlContentAndAttachedFile() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html('html content'); $e->text('text content'); $e->attach($file); - $this->assertEquals(new MixedPart(new AlternativePart($text, $html), $att), $e->getBody()); + $this->assertEquals(new MixedPart(new AlternativePart($text, $html), $filePart), $e->getBody()); + } + public function testGenerateBodyWithTextAndHtmlAndAttachedFileAndAttachedImageNotReferenced() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html('html content'); $e->text('text content'); $e->attach($file); $e->attach($image, 'test.gif'); - $this->assertEquals(new MixedPart(new AlternativePart($text, $html), $att, $img), $e->getBody()); + $this->assertEquals(new MixedPart(new AlternativePart($text, $html), $filePart, $imagePart), $e->getBody()); + } + public function testGenerateBodyWithTextAndAttachedFileAndAttachedImageNotReferenced() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->text('text content'); $e->attach($file); $e->attach($image, 'test.gif'); - $this->assertEquals(new MixedPart($text, $att, $img), $e->getBody()); + $this->assertEquals(new MixedPart($text, $filePart, $imagePart), $e->getBody()); + } + public function testGenerateBodyWithTextAndHtmlAndAttachedFileAndAttachedImageNotReferencedViaCid() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html($content = 'html content '); $e->text('text content'); $e->attach($file); $e->attach($image, 'test.gif'); $fullhtml = new TextPart($content, 'utf-8', 'html'); - $this->assertEquals(new MixedPart(new AlternativePart($text, $fullhtml), $att, $img), $e->getBody()); + $this->assertEquals(new MixedPart(new AlternativePart($text, $fullhtml), $filePart, $imagePart), $e->getBody()); + } + public function testGenerateBodyWithTextAndHtmlAndAttachedFileAndAttachedImageReferencedViaCid() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html($content = 'html content '); $e->text('text content'); @@ -325,12 +365,35 @@ public function testGenerateBody() $this->assertInstanceOf(MixedPart::class, $body); $this->assertCount(2, $related = $body->getParts()); $this->assertInstanceOf(RelatedPart::class, $related[0]); - $this->assertEquals($att, $related[1]); + $this->assertEquals($filePart, $related[1]); + $this->assertCount(2, $parts = $related[0]->getParts()); + $this->assertInstanceOf(AlternativePart::class, $parts[0]); + $generatedHtml = $parts[0]->getParts()[1]; + $this->assertStringContainsString('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody()); + } + + public function testGenerateBodyWithTextAndHtmlAndAttachedFileAndAttachedImagePartAsInlineReferencedViaCid() + { + [$text, $html, $filePart, $file, $imagePart, $image] = $this->generateSomeParts(); + $e = (new Email())->from('me@example.com')->to('you@example.com'); + $e->html($content = 'html content '); + $e->text('text content'); + $e->attach($file); + $e->attachPart((new DataPart($image, 'test.gif'))->asInline()); + $body = $e->getBody(); + $this->assertInstanceOf(MixedPart::class, $body); + $this->assertCount(2, $related = $body->getParts()); + $this->assertInstanceOf(RelatedPart::class, $related[0]); + $this->assertEquals($filePart, $related[1]); $this->assertCount(2, $parts = $related[0]->getParts()); $this->assertInstanceOf(AlternativePart::class, $parts[0]); $generatedHtml = $parts[0]->getParts()[1]; $this->assertStringContainsString('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody()); + } + public function testGenerateBodyWithHtmlAndInlinedImageTwiceReferencedViaCid() + { + // inline image (twice) referenced in the HTML content $content = 'html content '; $r = fopen('php://memory', 'r+', false); fwrite($r, $content); @@ -339,6 +402,7 @@ public function testGenerateBody() $e = (new Email())->from('me@example.com')->to('you@example.com'); $e->html($r); // embedding the same image twice results in one image only in the email + $image = fopen(__DIR__.'/Fixtures/mimetypes/test.gif', 'r'); $e->embed($image, 'test.gif'); $e->embed($image, 'test.gif'); $body = $e->getBody(); @@ -348,8 +412,19 @@ public function testGenerateBody() $this->assertStringMatchesFormat('html content ', $parts[0]->bodyToString()); } + private function generateSomeParts(): array + { + $text = new TextPart('text content'); + $html = new TextPart('html content', 'utf-8', 'html'); + $filePart = new DataPart($file = fopen(__DIR__.'/Fixtures/mimetypes/test', 'r')); + $imagePart = new DataPart($image = fopen(__DIR__.'/Fixtures/mimetypes/test.gif', 'r'), 'test.gif'); + + return [$text, $html, $filePart, $file, $imagePart, $image]; + } + public function testAttachments() { + // inline part $contents = file_get_contents($name = __DIR__.'/Fixtures/mimetypes/test', 'r'); $att = new DataPart($file = fopen($name, 'r'), 'test'); $inline = (new DataPart($contents, 'test'))->asInline(); @@ -358,6 +433,7 @@ public function testAttachments() $e->embed($contents, 'test'); $this->assertEquals([$att, $inline], $e->getAttachments()); + // inline part from path $att = DataPart::fromPath($name, 'test'); $inline = DataPart::fromPath($name, 'test')->asInline(); $e = new Email(); @@ -458,4 +534,24 @@ public function testTextBodyAcceptedTypes() $email->text($contents); $this->assertSame($contents, $email->getTextBody()); } + + public function testBodyCache() + { + $email = new Email(); + $email->from('fabien@symfony.com'); + $email->to('fabien@symfony.com'); + $email->text('foo'); + $body1 = $email->getBody(); + $body2 = $email->getBody(); + $this->assertSame($body1, $body2, 'The two bodies must reference the same object, so the body cache ensures that the hash for the DKIM signature is unique.'); + + $email = new Email(); + $email->from('fabien@symfony.com'); + $email->to('fabien@symfony.com'); + $email->text('foo'); + $body1 = $email->getBody(); + $email->html('bar'); // We change a part to reset the body cache. + $body2 = $email->getBody(); + $this->assertNotSame($body1, $body2, 'The two bodies must not reference the same object, so the body cache does not ensure that the hash for the DKIM signature is unique.'); + } } diff --git a/src/Symfony/Component/Mime/Tests/Encoder/Base64EncoderTest.php b/src/Symfony/Component/Mime/Tests/Encoder/Base64EncoderTest.php index a6c60236bf02d..864db4eb6f17b 100644 --- a/src/Symfony/Component/Mime/Tests/Encoder/Base64EncoderTest.php +++ b/src/Symfony/Component/Mime/Tests/Encoder/Base64EncoderTest.php @@ -97,12 +97,12 @@ public function testMaximumLineLengthIs76Characters() 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $output = - 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 - 'NERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1'."\r\n".//76 * - 'Njc4OTBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3'.//38 - 'h5ekFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFla'."\r\n".//76 * - 'MTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BRUl'.//38 - 'NUVVZXWFla'; //48 + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.// 38 + 'NERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1'."\r\n".// 76 * + 'Njc4OTBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3'.// 38 + 'h5ekFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFla'."\r\n".// 76 * + 'MTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BRUl'.// 38 + 'NUVVZXWFla'; // 48 $encoder = new Base64Encoder(); $this->assertEquals($output, $encoder->encodeString($input), 'Lines should be no more than 76 characters'); @@ -120,14 +120,14 @@ public function testMaximumLineLengthCanBeSpecified() 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $output = - 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 - 'NERUZHSElKS0'."\r\n".//50 * - 'xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNk'.//38 - 'ZWZnaGlqa2xt'."\r\n".//50 * - 'bm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLTE1OT1'.//38 - 'BRUlNUVVZXWF'."\r\n".//50 * - 'laMTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BR'.//38 - 'UlNUVVZXWFla'; //50 * + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.// 38 + 'NERUZHSElKS0'."\r\n".// 50 * + 'xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNk'.// 38 + 'ZWZnaGlqa2xt'."\r\n".// 50 * + 'bm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLTE1OT1'.// 38 + 'BRUlNUVVZXWF'."\r\n".// 50 * + 'laMTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BR'.// 38 + 'UlNUVVZXWFla'; // 50 * $encoder = new Base64Encoder(); $this->assertEquals($output, $encoder->encodeString($input, 'utf-8', 0, 50), 'Lines should be no more than 100 characters'); @@ -145,12 +145,12 @@ public function testFirstLineLengthCanBeDifferent() 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $output = - 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 - 'NERUZHSElKS0xNTk9QU'."\r\n".//57 * - 'VJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNkZWZnaGl'.//38 - 'qa2xtbm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLT'."\r\n".//76 * - 'E1OT1BRUlNUVVZXWFlaMTIzNDU2Nzg5MEFCQ0R'.//38 - 'FRkdISUpLTE1OT1BRUlNUVVZXWFla'; //67 + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.// 38 + 'NERUZHSElKS0xNTk9QU'."\r\n".// 57 * + 'VJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNkZWZnaGl'.// 38 + 'qa2xtbm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLT'."\r\n".// 76 * + 'E1OT1BRUlNUVVZXWFlaMTIzNDU2Nzg5MEFCQ0R'.// 38 + 'FRkdISUpLTE1OT1BRUlNUVVZXWFla'; // 67 $encoder = new Base64Encoder(); $this->assertEquals($output, $encoder->encodeString($input, 'utf-8', 19), 'First line offset is 19 so first line should be 57 chars long'); diff --git a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php index 168d0bcbbe0d9..847419568f62a 100644 --- a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php @@ -254,7 +254,7 @@ public function testInReplyToAcceptsNonIdentifierValues() public function testReferencesAcceptsNonIdentifierValues() { $headers = new Headers(); - $headers->addTextHeader('References' , 'foobar'); + $headers->addTextHeader('References', 'foobar'); $this->assertEquals('foobar', $headers->get('References')->getBody()); } } diff --git a/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php index 1c047cd2b1840..7adc77bf7de69 100644 --- a/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php @@ -50,6 +50,12 @@ public function testEscapeCharsInNameAreQuoted() $this->assertEquals(['"Chris Corbyn, \\\\escaped\\\\" '], $header->getAddressStrings()); } + public function testParenthesesInNameAreQuoted() + { + $header = new MailboxListHeader('From', [new Address('j.doe@example.com', 'J Doe (ACME)')]); + $this->assertEquals(['"J Doe (ACME)" '], $header->getAddressStrings()); + } + public function testUtf8CharsInDomainAreIdnEncoded() { $header = new MailboxListHeader('From', [new Address('chris@swïftmailer.org', 'Chris Corbyn')]); diff --git a/src/Symfony/Component/Mime/Tests/Header/UnstructuredHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/UnstructuredHeaderTest.php index 8da0aecb7f1cc..a405c78c2d8cc 100644 --- a/src/Symfony/Component/Mime/Tests/Header/UnstructuredHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/UnstructuredHeaderTest.php @@ -61,7 +61,7 @@ public function testLongHeadersAreFoldedAtWordBoundary() */ $this->assertEquals( 'X-Custom-Header: The quick brown fox jumped over the fence, he was a'. - ' very'."\r\n".//Folding + ' very'."\r\n".// Folding ' very scary brown fox with a bushy tail', $header->toString(), '%s: The header should have been folded at 76th char' ); @@ -149,10 +149,10 @@ public function testEncodedWordsAreNoMoreThan75CharsPerLine() $nonAsciiChar = pack('C', 0x8F); - //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 - //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + // Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + // Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 - //* X-Test: is 8 chars + // * X-Test: is 8 chars $header = new UnstructuredHeader('X-Test', $nonAsciiChar); $header->setCharset('iso-8859-1'); $this->assertEquals('X-Test: =?'.$header->getCharset().'?Q?=8F?=', $header->toString()); @@ -169,7 +169,7 @@ public function testFWSPIsUsedWhenEncoderReturnsMultipleLines() // Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 // Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 - //* X-Test: is 8 chars + // * X-Test: is 8 chars $header = new UnstructuredHeader('X-Test', pack('C', 0x8F).'line_one_here'."\r\n".'line_two_here'); $header->setCharset('iso-8859-1'); $this->assertEquals('X-Test: =?'.$header->getCharset().'?Q?=8Fline=5Fone=5Fhere?='."\r\n".' =?'.$header->getCharset().'?Q?line=5Ftwo=5Fhere?=', $header->toString()); diff --git a/src/Symfony/Component/Mime/Tests/MessageConverterTest.php b/src/Symfony/Component/Mime/Tests/MessageConverterTest.php index a0e71a08a9416..31bc81a674a3e 100644 --- a/src/Symfony/Component/Mime/Tests/MessageConverterTest.php +++ b/src/Symfony/Component/Mime/Tests/MessageConverterTest.php @@ -76,6 +76,12 @@ private function assertConversion(Email $expected) $expected->html('HTML content'); $converted->html('HTML content'); } + + $r = new \ReflectionProperty($expected, 'cachedBody'); + $r->setAccessible(true); + $r->setValue($expected, null); + $r->setValue($converted, null); + $this->assertEquals($expected, $converted); } } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index fc1cf85475861..3c9e16c901386 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -833,7 +833,7 @@ public function resolve(array $options = []) * lazy options and/or normalizers */ #[\ReturnTypeWillChange] - public function offsetGet($option/*, bool $triggerDeprecation = true*/) + public function offsetGet($option/* , bool $triggerDeprecation = true */) { if (!$this->locked) { throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index ff68ed33192e3..e2dd064d60e84 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -50,8 +50,8 @@ public function addSuffix($suffix) */ public function find($name, $default = null, array $extraDirs = []) { - if (ini_get('open_basedir')) { - $searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); + if (\ini_get('open_basedir')) { + $searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs); $dirs = []; foreach ($searchPath as $path) { // Silencing against https://bugs.php.net/69240 diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index ab65866c2ba06..9532e3ef67d22 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -104,7 +104,7 @@ protected function write(): ?array stream_set_blocking($input, 0); } elseif (!isset($this->inputBuffer[0])) { if (!\is_string($input)) { - if (!is_scalar($input)) { + if (!\is_scalar($input)) { throw new InvalidArgumentException(sprintf('"%s" yielded a value of type "%s", but only scalars and stream resources are supported.', \get_class($this->input), \gettype($input))); } $input = (string) $input; diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index eb39a4a9e3145..121693baaa73f 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -48,7 +48,7 @@ public static function validateInput($caller, $input) if (\is_string($input)) { return $input; } - if (is_scalar($input)) { + if (\is_scalar($input)) { return (string) $input; } if ($input instanceof Process) { diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index d056841fb79c5..5c63cf0f91c47 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -37,7 +37,7 @@ private function setPath($path) public function testFind() { - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } @@ -51,7 +51,7 @@ public function testFind() public function testFindWithDefault() { - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } @@ -67,7 +67,7 @@ public function testFindWithDefault() public function testFindWithNullAsDefault() { - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } @@ -82,7 +82,7 @@ public function testFindWithNullAsDefault() public function testFindWithExtraDirs() { - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } @@ -105,7 +105,7 @@ public function testFindWithOpenBaseDir() $this->markTestSkipped('Cannot run test on windows'); } - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } @@ -122,7 +122,7 @@ public function testFindWithOpenBaseDir() */ public function testFindProcessInOpenBasedir() { - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } if ('\\' === \DIRECTORY_SEPARATOR) { @@ -140,7 +140,7 @@ public function testFindProcessInOpenBasedir() public function testFindBatchExecutableOnWindows() { - if (ini_get('open_basedir')) { + if (\ini_get('open_basedir')) { $this->markTestSkipped('Cannot test when open_basedir is set'); } if ('\\' !== \DIRECTORY_SEPARATOR) { diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index d4ab4dbcd6312..74c662fb9bb67 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1133,7 +1133,7 @@ public function testTermSignalTerminatesProcessCleanly() public function responsesCodeProvider() { return [ - //expected output / getter / code to execute + // expected output / getter / code to execute // [1,'getExitCode','exit(1);'], // [true,'isSuccessful','exit();'], ['output', 'getOutput', 'echo \'output\';'], diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 607c8fad571ac..3e1a4de97bf8a 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -918,7 +918,7 @@ public static function createCache($namespace, $defaultLifetime, $version, Logge } $apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version); - if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { + if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { $apcu->setLogger(new NullLogger()); } elseif (null !== $logger) { $apcu->setLogger($logger); diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 6498fab2bfd90..06847eba36700 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -834,7 +834,7 @@ public function testWriteToSingularPropertyWhilePluralOneExists() { $object = new TestSingularAndPluralProps(); - $this->propertyAccessor->isWritable($object, 'email'); //cache access info + $this->propertyAccessor->isWritable($object, 'email'); // cache access info $this->propertyAccessor->setValue($object, 'email', 'test@email.com'); self::assertEquals('test@email.com', $object->getEmail()); @@ -845,7 +845,7 @@ public function testWriteToPluralPropertyWhileSingularOneExists() { $object = new TestSingularAndPluralProps(); - $this->propertyAccessor->isWritable($object, 'emails'); //cache access info + $this->propertyAccessor->isWritable($object, 'emails'); // cache access info $this->propertyAccessor->setValue($object, 'emails', ['test@email.com']); $this->assertEquals(['test@email.com'], $object->getEmails()); @@ -856,7 +856,7 @@ public function testAdderAndRemoverArePreferredOverSetter() { $object = new TestPluralAdderRemoverAndSetter(); - $this->propertyAccessor->isWritable($object, 'emails'); //cache access info + $this->propertyAccessor->isWritable($object, 'emails'); // cache access info $this->propertyAccessor->setValue($object, 'emails', ['test@email.com']); $this->assertEquals(['test@email.com'], $object->getEmails()); @@ -866,7 +866,7 @@ public function testAdderAndRemoverArePreferredOverSetterForSameSingularAndPlura { $object = new TestPluralAdderRemoverAndSetterSameSingularAndPlural(); - $this->propertyAccessor->isWritable($object, 'aircraft'); //cache access info + $this->propertyAccessor->isWritable($object, 'aircraft'); // cache access info $this->propertyAccessor->setValue($object, 'aircraft', ['aeroplane']); $this->assertEquals(['aeroplane'], $object->getAircraft()); diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index be22f95855b9e..a6e3738e7cb0c 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -334,6 +334,11 @@ private function extractFromReflectionType(\ReflectionType $reflectionType, \Ref $nullable = $reflectionType->allowsNull(); foreach (($reflectionType instanceof \ReflectionUnionType || $reflectionType instanceof \ReflectionIntersectionType) ? $reflectionType->getTypes() : [$reflectionType] as $type) { + if (!$type instanceof \ReflectionNamedType) { + // Nested composite types are not supported yet. + return []; + } + $phpTypeOrClass = $type->getName(); if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass || 'never' === $phpTypeOrClass) { continue; diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php index 3f97527b720da..315171333d137 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php @@ -281,10 +281,14 @@ public function testExtractPhp82Type($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php82Dummy', $property, [])); } - public function php82TypesProvider() + public function php82TypesProvider(): iterable { yield ['nil', null]; yield ['false', [new Type(Type::BUILTIN_TYPE_FALSE)]]; + + // Nesting intersection and union types is not supported yet, + // but we should make sure this kind of composite types does not crash the extractor. + yield ['someCollection', null]; } /** diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php82Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php82Dummy.php index b830fabf8842a..784c868369390 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php82Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php82Dummy.php @@ -16,4 +16,6 @@ class Php82Dummy public null $nil = null; public false $false = false; + + public (\Traversable&\Countable)|null $someCollection = null; } diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 2f087793b5b61..2b115b10df00b 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -182,7 +182,7 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $ $this->setCurrentDir(\dirname($path)); /** @var RouteCollection[] $imported */ - $imported = $this->import($resource, ('' !== $type ? $type : null), false, $file, $exclude) ?: []; + $imported = $this->import($resource, '' !== $type ? $type : null, false, $file, $exclude) ?: []; if (!\is_array($imported)) { $imported = [$imported]; diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index 30c6e52619dba..e4f167b1efae3 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -439,7 +439,7 @@ private function checkDeprecatedOption(string $key) private static function getCompiledRoutes(string $path): array { - if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { + if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { self::$cache = null; } diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php index 4f3ea6eb2251d..bce375a2f68ef 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php @@ -87,7 +87,7 @@ public function testDumpWithRoutes() public function testDumpWithSimpleLocalizedRoutes() { - $this->routeCollection->add('test', (new Route('/foo'))); + $this->routeCollection->add('test', new Route('/foo')); $this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'en')); $this->routeCollection->add('test.nl', (new Route('/testen/is/leuk'))->setDefault('_locale', 'nl')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'nl')); diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php index ca25f4a8e8abd..cd0926055beb4 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php @@ -90,7 +90,7 @@ public function testDumpWithRoutes() public function testDumpWithSimpleLocalizedRoutes() { - $this->routeCollection->add('test', (new Route('/foo'))); + $this->routeCollection->add('test', new Route('/foo')); $this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'en')); $this->routeCollection->add('test.nl', (new Route('/testen/is/leuk'))->setDefault('_locale', 'nl')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'nl')); diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index f006f4ce9d587..8687968503af6 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -708,7 +708,7 @@ public function testGenerateRelativePath() ['author' => 'bernhard', 'article' => 'forms-are-great'], UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme', - ['author' => 'bernhard'], UrlGeneratorInterface::RELATIVE_PATH) + ['author' => 'bernhard'], UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../../about', $generator->generate('unrelated', [], UrlGeneratorInterface::RELATIVE_PATH) diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index a6a490db019db..6bfbcea781837 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -334,7 +334,7 @@ public function testLocaleRequirementWithLocalizedRoutes(Route $route) public function provideNonLocalizedRoutes() { return [ - [(new Route('/foo'))], + [new Route('/foo')], [(new Route('/foo'))->setDefault('_locale', 'en')], [(new Route('/foo'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'foo')], [(new Route('/foo'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'foo')->setRequirement('_locale', 'foobar')], diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index ea30549333c62..bdfb7b2cca40a 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -57,7 +57,7 @@ public function __construct(iterable $voters = [], string $strategy = self::STRA * * {@inheritdoc} */ - public function decide(TokenInterface $token, array $attributes, $object = null/*, bool $allowMultipleAttributes = false*/) + public function decide(TokenInterface $token, array $attributes, $object = null/* , bool $allowMultipleAttributes = false */) { $allowMultipleAttributes = 3 < \func_num_args() && func_get_arg(3); diff --git a/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php index 3b5004edf2fcd..81a9afc334083 100644 --- a/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php @@ -50,7 +50,7 @@ public function __construct(AccessDecisionManagerInterface $manager) * * @param bool $allowMultipleAttributes Whether to allow passing multiple values to the $attributes array */ - public function decide(TokenInterface $token, array $attributes, $object = null/*, bool $allowMultipleAttributes = false*/): bool + public function decide(TokenInterface $token, array $attributes, $object = null/* , bool $allowMultipleAttributes = false */): bool { $currentDecisionLog = [ 'attributes' => $attributes, diff --git a/src/Symfony/Component/Security/Core/Security.php b/src/Symfony/Component/Security/Core/Security.php index f4a2e7c7b4347..a5a593c1815e3 100644 --- a/src/Symfony/Component/Security/Core/Security.php +++ b/src/Symfony/Component/Security/Core/Security.php @@ -50,7 +50,7 @@ public function getUser() if (!$user instanceof UserInterface) { @trigger_error(sprintf('Accessing the user object "%s" that is not an instance of "%s" from "%s()" is deprecated since Symfony 4.2, use "getToken()->getUser()" instead.', \get_class($user), UserInterface::class, __METHOD__), \E_USER_DEPRECATED); - //return null; // 5.0 behavior + // return null; // 5.0 behavior } return $user; diff --git a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php index 5265eb7aea354..01afc80860a33 100644 --- a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php +++ b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php @@ -64,7 +64,7 @@ public function getUserTests() yield ['string_username', null]; - //yield [new StringishUser(), null]; // 5.0 behavior + // yield [new StringishUser(), null]; // 5.0 behavior $user = new User('nice_user', 'foo'); yield [$user, $user]; diff --git a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php index 46489f6394bd9..5e6e871a13d3e 100644 --- a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php @@ -73,7 +73,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio $options = $this->options; $failureUrl = ParameterBagUtils::getRequestParameterValue($request, $options['failure_path_parameter']); - if (\is_string($failureUrl) && str_starts_with($failureUrl, '/')) { + if (\is_string($failureUrl) && (str_starts_with($failureUrl, '/') || str_starts_with($failureUrl, 'http'))) { $options['failure_path'] = $failureUrl; } elseif ($this->logger && $failureUrl) { $this->logger->debug(sprintf('Ignoring query parameter "%s": not a valid URL.', $options['failure_path_parameter'])); diff --git a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php index 391fe5369c73b..4652fa6ad04ee 100644 --- a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php @@ -107,7 +107,7 @@ protected function determineTargetUrl(Request $request) $targetUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['target_path_parameter']); - if (\is_string($targetUrl) && str_starts_with($targetUrl, '/')) { + if (\is_string($targetUrl) && (str_starts_with($targetUrl, '/') || str_starts_with($targetUrl, 'http'))) { return $targetUrl; } diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index 22a2b9277bbbd..46ac724383519 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -207,6 +207,21 @@ public function testFailurePathFromRequestWithInvalidUrl() $handler->onAuthenticationFailure($this->request, $this->exception); } + public function testAbsoluteUrlRedirectionFromRequest() + { + $options = ['failure_path_parameter' => '_my_failure_path']; + + $this->request->expects($this->once()) + ->method('get')->with('_my_failure_path') + ->willReturn('https://localhost/some-path'); + + $this->httpUtils->expects($this->once()) + ->method('createRedirectResponse')->with($this->request, 'https://localhost/some-path'); + + $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, $options, $this->logger); + $handler->onAuthenticationFailure($this->request, $this->exception); + } + private function getRequest() { $request = $this->createMock(Request::class); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index 5f05248911f91..563a855e1a695 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -135,4 +135,21 @@ public function testTargetPathFromRequestWithInvalidUrl() $handler->onAuthenticationSuccess($request, $token); } + + public function testTargetPathWithAbsoluteUrlFromRequest() + { + $options = ['target_path_parameter' => '_my_target_path']; + + $request = $this->createMock(Request::class); + $request->expects($this->once()) + ->method('get')->with('_my_target_path') + ->willReturn('https://localhost/some-path'); + + $httpUtils = $this->createMock(HttpUtils::class); + $httpUtils->expects($this->once()) + ->method('createRedirectResponse')->with($request, 'https://localhost/some-path'); + + $handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options); + $handler->onAuthenticationSuccess($request, $this->createMock(TokenInterface::class)); + } } diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 6557071078118..ed442c58cc91b 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -100,7 +100,7 @@ public function encode($data, $format, array $context = []) $dom = $this->createDomDocument($context); - if (null !== $data && !is_scalar($data)) { + if (null !== $data && !\is_scalar($data)) { $root = $dom->createElement($xmlRootNodeName); $dom->appendChild($root); $this->buildXml($root, $data, $format, $context, $xmlRootNodeName); @@ -412,11 +412,14 @@ private function buildXml(\DOMNode $parentNode, $data, string $format, array $co if (\is_array($data) || ($data instanceof \Traversable && (null === $this->serializer || !$this->serializer->supportsNormalization($data, $format)))) { foreach ($data as $key => $data) { - //Ah this is the magic @ attribute types. + // Ah this is the magic @ attribute types. if (str_starts_with($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) { - if (!is_scalar($data)) { + if (!\is_scalar($data)) { $data = $this->serializer->normalize($data, $format, $context); } + if (\is_bool($data)) { + $data = (int) $data; + } $parentNode->setAttribute($attributeName, $data); } elseif ('#' === $key) { $append = $this->selectNodeType($parentNode, $data, $format, $context); @@ -454,7 +457,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $format, array $co } $data = $this->serializer->normalize($data, $format, $context); - if (null !== $data && !is_scalar($data)) { + if (null !== $data && !\is_scalar($data)) { return $this->buildXml($parentNode, $data, $format, $context, $xmlRootNodeName); } @@ -479,7 +482,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $format, array $co */ private function appendNode(\DOMNode $parentNode, $data, string $format, array $context, string $nodeName, string $key = null): bool { - $dom = $parentNode instanceof \DomDocument ? $parentNode : $parentNode->ownerDocument; + $dom = $parentNode instanceof \DOMDocument ? $parentNode : $parentNode->ownerDocument; $node = $dom->createElement($nodeName); if (null !== $key) { $node->setAttribute('key', $key); diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 7a43e63c9b7a4..a9f46238eab0e 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -304,7 +304,7 @@ protected function isCircularReference($object, &$context) * * @throws CircularReferenceException */ - protected function handleCircularReference($object/*, string $format = null, array $context = []*/) + protected function handleCircularReference($object/* , string $format = null, array $context = [] */) { if (\func_num_args() < 2 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) { @trigger_error(sprintf('The "%s()" method will have two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED); @@ -342,7 +342,7 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu } $tmpGroups = $context[self::GROUPS] ?? $this->defaultContext[self::GROUPS] ?? null; - $groups = (\is_array($tmpGroups) || is_scalar($tmpGroups)) ? (array) $tmpGroups : false; + $groups = (\is_array($tmpGroups) || \is_scalar($tmpGroups)) ? (array) $tmpGroups : false; if (false === $groups && $allowExtraAttributes) { return false; } @@ -542,7 +542,7 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara * * @internal */ - protected function createChildContext(array $parentContext, $attribute/*, ?string $format */): array + protected function createChildContext(array $parentContext, $attribute/* , ?string $format */): array { if (\func_num_args() < 3) { @trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), \E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index fbe5d25d479a9..4b8df1f544779 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -196,7 +196,7 @@ public function normalize($object, $format = null, array $context = []) $attributeValue = $this->applyCallbacks($attributeValue, $object, $attribute, $format, $context); - if (null !== $attributeValue && !is_scalar($attributeValue)) { + if (null !== $attributeValue && !\is_scalar($attributeValue)) { $stack[$attribute] = $attributeValue; } @@ -647,7 +647,7 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str * * @internal */ - protected function createChildContext(array $parentContext, $attribute/*, ?string $format */): array + protected function createChildContext(array $parentContext, $attribute/* , ?string $format */): array { if (\func_num_args() >= 3) { $format = func_get_arg(2); diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php index f48745031e8b7..5fab3d8a55d6d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php @@ -113,6 +113,16 @@ public function denormalize($data, $type, $format = null, array $context = []) throw new NotNormalizableValueException(sprintf('Parsing datetime string "%s" using format "%s" resulted in %d errors: ', $data, $dateTimeFormat, $dateTimeErrors['error_count'])."\n".implode("\n", $this->formatDateTimeErrors($dateTimeErrors['errors']))); } + $defaultDateTimeFormat = $this->defaultContext[self::FORMAT_KEY] ?? null; + + if (null !== $defaultDateTimeFormat) { + $object = \DateTime::class === $type ? \DateTime::createFromFormat($defaultDateTimeFormat, $data, $timezone) : \DateTimeImmutable::createFromFormat($defaultDateTimeFormat, $data, $timezone); + + if (false !== $object) { + return $object; + } + } + try { return \DateTime::class === $type ? new \DateTime($data, $timezone) : new \DateTimeImmutable($data, $timezone); } catch (\Exception $e) { diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index d3a3f2fc48d35..5cfdc9ee0f5b5 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -153,7 +153,7 @@ public function normalize($data, $format = null, array $context = []) return $normalizer->normalize($data, $format, $context); } - if (null === $data || is_scalar($data)) { + if (null === $data || \is_scalar($data)) { return $data; } diff --git a/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php b/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php index 654a6c6e90717..1130c82de7b10 100644 --- a/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php +++ b/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php @@ -23,9 +23,9 @@ class DeserializeNestedArrayOfObjectsTest extends TestCase public function provider() { return [ - //from property PhpDoc + // from property PhpDoc [Zoo::class], - //from argument constructor PhpDoc + // from argument constructor PhpDoc [ZooImmutable::class], ]; } @@ -35,7 +35,7 @@ public function provider() */ public function testPropertyPhpDoc($class) { - //GIVEN + // GIVEN $json = << new JsonEncoder()]); - //WHEN + // WHEN /** @var Zoo $zoo */ $zoo = $serializer->deserialize($json, $class, 'json'); - //THEN + // THEN self::assertCount(1, $zoo->getAnimals()); self::assertInstanceOf(Animal::class, $zoo->getAnimals()[0]); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php index 596afa28b7eed..edfa00ce32b62 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php @@ -47,7 +47,7 @@ public function testTrueFalseValues() foo,2,0,1,1,1 CSV - , $this->encoder->encode($data, 'csv')); + , $this->encoder->encode($data, 'csv')); $this->assertSame([ 'string' => 'foo', @@ -69,7 +69,7 @@ public function testDoubleQuotesAndSlashes() ,"""","foo""","\""",\,foo\ CSV - , $this->encoder->encode($data = ['', '"', 'foo"', '\\"', '\\', 'foo\\'], 'csv')); + , $this->encoder->encode($data = ['', '"', 'foo"', '\\"', '\\', 'foo\\'], 'csv')); $this->assertSame($data, $this->encoder->decode($csv, 'csv', [CsvEncoder::AS_COLLECTION_KEY => false])); } @@ -99,7 +99,7 @@ public function testEncode() hello,"hey ho" CSV - , $this->encoder->encode($value, 'csv')); + , $this->encoder->encode($value, 'csv')); } public function testEncodeCollection() @@ -115,7 +115,7 @@ public function testEncodeCollection() hi,"let's go" CSV - , $this->encoder->encode($value, 'csv')); + , $this->encoder->encode($value, 'csv')); } public function testEncodePlainIndexedArray() @@ -150,7 +150,7 @@ public function testEncodeNestedArrays() hello,yo,wesh,Halo,olá CSV - , $this->encoder->encode($value, 'csv')); + , $this->encoder->encode($value, 'csv')); } public function testEncodeCustomSettings() @@ -183,7 +183,7 @@ private function doTestEncodeCustomSettings(bool $legacy = false) 'he''llo';foo CSV - , $this->encoder->encode($value, 'csv')); + , $this->encoder->encode($value, 'csv')); } public function testEncodeCustomSettingsPassedInContext() @@ -195,12 +195,12 @@ public function testEncodeCustomSettingsPassedInContext() 'he''llo';foo CSV - , $this->encoder->encode($value, 'csv', [ - CsvEncoder::DELIMITER_KEY => ';', - CsvEncoder::ENCLOSURE_KEY => "'", - CsvEncoder::ESCAPE_CHAR_KEY => '|', - CsvEncoder::KEY_SEPARATOR_KEY => '-', - ])); + , $this->encoder->encode($value, 'csv', [ + CsvEncoder::DELIMITER_KEY => ';', + CsvEncoder::ENCLOSURE_KEY => "'", + CsvEncoder::ESCAPE_CHAR_KEY => '|', + CsvEncoder::KEY_SEPARATOR_KEY => '-', + ])); } public function testEncodeCustomSettingsPassedInConstructor() @@ -218,7 +218,7 @@ public function testEncodeCustomSettingsPassedInConstructor() 'he''llo';foo CSV - , $encoder->encode($value, 'csv')); + , $encoder->encode($value, 'csv')); } public function testEncodeEmptyArray() @@ -527,7 +527,7 @@ public function testDecodeLegacy() foo,bar a,b CSV - , 'csv')); + , 'csv')); } public function testDecodeAsSingle() @@ -538,7 +538,7 @@ public function testDecodeAsSingle() foo,bar a,b CSV - , 'csv', [CsvEncoder::AS_COLLECTION_KEY => false])); + , 'csv', [CsvEncoder::AS_COLLECTION_KEY => false])); } public function testDecodeCollection() @@ -556,7 +556,7 @@ public function testDecodeCollection() f CSV - , 'csv')); + , 'csv')); } public function testDecode() @@ -570,9 +570,9 @@ public function testDecode() a CSV - , 'csv', [ - CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 - ])); + , 'csv', [ + CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 + ])); } public function testDecodeToManyRelation() @@ -606,7 +606,7 @@ public function testDecodeNestedArrays() a,b c,d CSV - , 'csv')); + , 'csv')); } public function testDecodeCustomSettings() @@ -637,9 +637,9 @@ private function doTestDecodeCustomSettings(bool $legacy = false) a;bar-baz 'hell''o';b;c CSV - , 'csv', [ - CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 - ])); + , 'csv', [ + CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 + ])); } public function testDecodeCustomSettingsPassedInContext() @@ -649,13 +649,13 @@ public function testDecodeCustomSettingsPassedInContext() a;bar-baz 'hell''o';b;c CSV - , 'csv', [ - CsvEncoder::DELIMITER_KEY => ';', - CsvEncoder::ENCLOSURE_KEY => "'", - CsvEncoder::ESCAPE_CHAR_KEY => '|', - CsvEncoder::KEY_SEPARATOR_KEY => '-', - CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 - ])); + , 'csv', [ + CsvEncoder::DELIMITER_KEY => ';', + CsvEncoder::ENCLOSURE_KEY => "'", + CsvEncoder::ESCAPE_CHAR_KEY => '|', + CsvEncoder::KEY_SEPARATOR_KEY => '-', + CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 + ])); } public function testDecodeCustomSettingsPassedInConstructor() @@ -672,7 +672,7 @@ public function testDecodeCustomSettingsPassedInConstructor() a;bar-baz 'hell''o';b;c CSV - , 'csv')); + , 'csv')); } public function testDecodeMalformedCollection() @@ -705,18 +705,18 @@ public function testDecodeWithoutHeader() c,d CSV - , 'csv', [ - CsvEncoder::NO_HEADERS_KEY => true, - ])); + , 'csv', [ + CsvEncoder::NO_HEADERS_KEY => true, + ])); $encoder = new CsvEncoder([CsvEncoder::NO_HEADERS_KEY => true]); $this->assertEquals([['a', 'b'], ['c', 'd']], $encoder->decode(<<<'CSV' a,b c,d CSV - , 'csv', [ - CsvEncoder::NO_HEADERS_KEY => true, - ])); + , 'csv', [ + CsvEncoder::NO_HEADERS_KEY => true, + ])); } public function testBOMIsAddedOnDemand() diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index f5d2d312a9243..012059289849a 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -111,6 +111,13 @@ public function testAttributes() 'föo_bär' => 'a', 'Bar' => [1, 2, 3], 'a' => 'b', + 'scalars' => [ + '@bool-true' => true, + '@bool-false' => false, + '@int' => 3, + '@float' => 3.4, + '@sring' => 'a', + ], ]; $expected = ''."\n". ''. @@ -121,6 +128,7 @@ public function testAttributes() '2'. '3'. 'b'. + ''. ''."\n"; $this->assertEquals($expected, $this->encoder->encode($obj, 'xml')); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php index 51fc17d85afea..ca740a4d7e89e 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php @@ -305,6 +305,28 @@ public function testDenormalizeDateTimeStringWithSpacesUsingFormatPassedInContex $this->normalizer->denormalize(' 2016.01.01 ', \DateTime::class, null, [DateTimeNormalizer::FORMAT_KEY => 'Y.m.d|']); } + public function testDenormalizeDateTimeStringWithDefaultContextFormat() + { + $format = 'd/m/Y'; + $string = '01/10/2018'; + + $normalizer = new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY => $format]); + $denormalizedDate = $normalizer->denormalize($string, \DateTimeInterface::class); + + $this->assertSame('01/10/2018', $denormalizedDate->format($format)); + } + + public function testDenormalizeDateTimeStringWithDefaultContextAllowsErrorFormat() + { + $format = 'd/m/Y'; // the default format + $string = '2020-01-01'; // the value which is in the wrong format, but is accepted because of `new \DateTime` in DateTimeNormalizer::denormalize + + $normalizer = new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY => $format]); + $denormalizedDate = $normalizer->denormalize($string, \DateTimeInterface::class); + + $this->assertSame('2020-01-01', $denormalizedDate->format('Y-m-d')); + } + public function testDenormalizeFormatMismatchThrowsException() { $this->expectException(UnexpectedValueException::class); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index df8732d29e342..ef6cd7b85ec4c 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -214,7 +214,7 @@ public function testSerializeEmpty() $serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]); $data = ['foo' => new \stdClass()]; - //Old buggy behaviour + // Old buggy behaviour $result = $serializer->serialize($data, 'json'); $this->assertEquals('{"foo":[]}', $result); @@ -505,14 +505,14 @@ public function testNotNormalizableValueExceptionMessageForAResource() public function testNormalizeTransformEmptyArrayObjectToArray() { $serializer = new Serializer( - [ - new PropertyNormalizer(), - new ObjectNormalizer(), - new ArrayDenormalizer(), - ], - [ - 'json' => new JsonEncoder(), - ] + [ + new PropertyNormalizer(), + new ObjectNormalizer(), + new ArrayDenormalizer(), + ], + [ + 'json' => new JsonEncoder(), + ] ); $object = []; @@ -526,14 +526,14 @@ public function testNormalizeTransformEmptyArrayObjectToArray() public function testNormalizePreserveEmptyArrayObject() { $serializer = new Serializer( - [ - new PropertyNormalizer(), - new ObjectNormalizer(), - new ArrayDenormalizer(), - ], - [ - 'json' => new JsonEncoder(), - ] + [ + new PropertyNormalizer(), + new ObjectNormalizer(), + new ArrayDenormalizer(), + ], + [ + 'json' => new JsonEncoder(), + ] ); $object = []; diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index e4f85606981ce..540d938898461 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -315,7 +315,7 @@ public function escape($value, $context = 'html') // If we deal with a scalar value, we can cache the result to increase // the performance when the same value is escaped multiple times (e.g. loops) - if (is_scalar($value)) { + if (\is_scalar($value)) { if (!isset(self::$escaperCache[$context][$value])) { self::$escaperCache[$context][$value] = $this->getEscaper($context)($value); } diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php index e4f0b3a5acfdc..88894ec019ff0 100644 --- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php +++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php @@ -50,7 +50,7 @@ public function lateCollect() * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { $this->data['locale'] = $this->translator->getLocale(); $this->data['fallback_locales'] = $this->translator->getFallbackLocales(); diff --git a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php index 829e0d0c25ce6..44104eb6043c1 100644 --- a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php @@ -47,7 +47,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti $data .= pack('V', \strlen($target)) .mb_convert_encoding($target."\0", 'UTF-16LE', 'UTF-8') .$this->writePadding($data) - ; + ; } $resOffset = $this->getPosition($data); @@ -56,7 +56,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti .$indexes .$this->writePadding($data) .$resources - ; + ; $bundleTop = $this->getPosition($data); diff --git a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php index 5a96dacec0b39..9bed418f21ad5 100644 --- a/src/Symfony/Component/Translation/Dumper/MoFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/MoFileDumper.php @@ -62,7 +62,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti .$targetOffsets .$sources .$targets - ; + ; return $output; } diff --git a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php index 32389c677cacd..e0622e6a88e7d 100644 --- a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php @@ -211,7 +211,7 @@ private function getValue(\Iterator $tokenIterator) * @param array $tokens * @param string $filename */ - protected function parseTokens($tokens, MessageCatalogue $catalog/*, string $filename*/) + protected function parseTokens($tokens, MessageCatalogue $catalog/* , string $filename */) { if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) { @trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php index c361d5293cc0f..2310740bd821b 100644 --- a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php @@ -25,7 +25,7 @@ class PhpFileLoader extends FileLoader */ protected function loadResource($resource) { - if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { + if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { self::$cache = null; } diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php index e69ceabc17abc..84513a245f415 100644 --- a/src/Symfony/Component/Translation/PluralizationRules.php +++ b/src/Symfony/Component/Translation/PluralizationRules.php @@ -30,7 +30,7 @@ class PluralizationRules * * @return int The plural position */ - public static function get($number, $locale/*, bool $triggerDeprecation = true*/) + public static function get($number, $locale/* , bool $triggerDeprecation = true */) { $number = abs($number); diff --git a/src/Symfony/Component/Validator/Constraints/BicValidator.php b/src/Symfony/Component/Validator/Constraints/BicValidator.php index 84c646732cc9e..d51f375256b1c 100644 --- a/src/Symfony/Component/Validator/Constraints/BicValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BicValidator.php @@ -68,7 +68,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/CountryValidator.php b/src/Symfony/Component/Validator/Constraints/CountryValidator.php index d8289e0e52b9b..f4eafc32f838c 100644 --- a/src/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -38,7 +38,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php index fdb8128d16a68..465cfb956eaa3 100644 --- a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -39,7 +39,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php index d16727082bc2d..1a3ae3784b422 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php @@ -40,7 +40,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index 761690e62ee4b..ff06bec52ad9d 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -52,7 +52,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index d895b3ac10b60..c5a4b21ef21b3 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -76,7 +76,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index cebb6eda29673..101330f6553bd 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -116,7 +116,7 @@ public function validate($value, Constraint $constraint) } } - if (!is_scalar($value) && !$value instanceof FileObject && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !$value instanceof FileObject && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 0f39a3a9ceaf3..6db31e5359dbb 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -150,7 +150,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/IpValidator.php b/src/Symfony/Component/Validator/Constraints/IpValidator.php index e48d41e6d4bb2..9db41f9c28541 100644 --- a/src/Symfony/Component/Validator/Constraints/IpValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IpValidator.php @@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } @@ -49,48 +49,48 @@ public function validate($value, Constraint $constraint) switch ($constraint->version) { case Ip::V4: - $flag = \FILTER_FLAG_IPV4; - break; + $flag = \FILTER_FLAG_IPV4; + break; case Ip::V6: - $flag = \FILTER_FLAG_IPV6; - break; + $flag = \FILTER_FLAG_IPV6; + break; case Ip::V4_NO_PRIV: - $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE; - break; + $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE; + break; case Ip::V6_NO_PRIV: - $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE; - break; + $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE; + break; case Ip::ALL_NO_PRIV: - $flag = \FILTER_FLAG_NO_PRIV_RANGE; - break; + $flag = \FILTER_FLAG_NO_PRIV_RANGE; + break; case Ip::V4_NO_RES: - $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_RES_RANGE; - break; + $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_RES_RANGE; + break; case Ip::V6_NO_RES: - $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_RES_RANGE; - break; + $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_RES_RANGE; + break; case Ip::ALL_NO_RES: - $flag = \FILTER_FLAG_NO_RES_RANGE; - break; + $flag = \FILTER_FLAG_NO_RES_RANGE; + break; case Ip::V4_ONLY_PUBLIC: - $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; - break; + $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; + break; case Ip::V6_ONLY_PUBLIC: - $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; - break; + $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; + break; case Ip::ALL_ONLY_PUBLIC: - $flag = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; - break; + $flag = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; + break; default: $flag = 0; diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index e0da13d7aa395..3cda0af156151 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -40,7 +40,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php index aa83201cdabc1..66f44af985211 100644 --- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -39,7 +39,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/JsonValidator.php b/src/Symfony/Component/Validator/Constraints/JsonValidator.php index e553ae359b147..176331f6f0314 100644 --- a/src/Symfony/Component/Validator/Constraints/JsonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/JsonValidator.php @@ -33,7 +33,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedTypeException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php index c204712306709..38e468430aa70 100644 --- a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -38,7 +38,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/LengthValidator.php b/src/Symfony/Component/Validator/Constraints/LengthValidator.php index 13c6015ef712f..af7338b37653d 100644 --- a/src/Symfony/Component/Validator/Constraints/LengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LengthValidator.php @@ -38,7 +38,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index ec2c7c8f03d17..78c98025262bf 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -38,7 +38,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/NotCompromisedPasswordValidator.php b/src/Symfony/Component/Validator/Constraints/NotCompromisedPasswordValidator.php index adcdb7a59ff54..efc770f001654 100644 --- a/src/Symfony/Component/Validator/Constraints/NotCompromisedPasswordValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NotCompromisedPasswordValidator.php @@ -63,7 +63,7 @@ public function validate($value, Constraint $constraint) return; } - if (null !== $value && !is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (null !== $value && !\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/RegexValidator.php b/src/Symfony/Component/Validator/Constraints/RegexValidator.php index 7fadf7682b056..bf828168efbec 100644 --- a/src/Symfony/Component/Validator/Constraints/RegexValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RegexValidator.php @@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index b827764801e93..ad9a1b25e7e0e 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -52,7 +52,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php b/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php index ab6b4eed626a4..a83d78c2b72ed 100644 --- a/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php @@ -39,7 +39,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 1150a8ab8e03d..c0d1f3b0da2d0 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -59,7 +59,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/UuidValidator.php b/src/Symfony/Component/Validator/Constraints/UuidValidator.php index 9082b59247819..7005f4eb22b20 100644 --- a/src/Symfony/Component/Validator/Constraints/UuidValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UuidValidator.php @@ -75,7 +75,7 @@ public function validate($value, Constraint $constraint) return; } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { + if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/DataCollector/ValidatorDataCollector.php b/src/Symfony/Component/Validator/DataCollector/ValidatorDataCollector.php index 928f2293259a4..b4b5a5b116607 100644 --- a/src/Symfony/Component/Validator/DataCollector/ValidatorDataCollector.php +++ b/src/Symfony/Component/Validator/DataCollector/ValidatorDataCollector.php @@ -42,7 +42,7 @@ public function __construct(TraceableValidator $validator) * * @param \Throwable|null $exception */ - public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) + public function collect(Request $request, Response $response/* , \Throwable $exception = null */) { // Everything is collected once, on kernel terminate. } diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf index ec58c60369be2..ece2da0d7331f 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf @@ -390,6 +390,18 @@ This value should be a valid expression. Balio hori baliozko adierazpena izan beharko litzateke. + + This value is not a valid CSS color. + Balio hori ez da baliozko CSS kolorea. + + + This value is not a valid CIDR notation. + Balio hori ez da baliozko CIDR notazioa. + + + The value of the netmask should be between {{ min }} and {{ max }}. + Maskararen balioa {{ min }} eta {{ max }} artekoa izan beharko litzateke. + diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 483e2c1310aab..54613f0b5f5dc 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -91,10 +91,10 @@ public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.'); - $this->createConstraint(([ + $this->createConstraint([ 'value' => 'value', 'propertyPath' => 'propertyPath', - ])); + ]); } /** diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 7748ba00a26f2..d21b400b0fc72 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -332,7 +332,7 @@ public function getInvalidEmailsForStrictChecks() ['test@email>'], ['test@email<'], ['test@email{'], - [str_repeat('x', 254).'@example.com'], //email with warnings + [str_repeat('x', 254).'@example.com'], // email with warnings ]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index ba426799ca4e1..391f24a0a80a9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -55,108 +55,108 @@ public function getValidIbans() // Country list // http://www.rbs.co.uk/corporate/international/g0/guide-to-international-business/regulatory-information/iban/iban-example.ashx - ['AL47 2121 1009 0000 0002 3569 8741'], //Albania - ['AD12 0001 2030 2003 5910 0100'], //Andorra - ['AT61 1904 3002 3457 3201'], //Austria - ['AZ21 NABZ 0000 0000 1370 1000 1944'], //Azerbaijan - ['BH67 BMAG 0000 1299 1234 56'], //Bahrain - ['BE62 5100 0754 7061'], //Belgium - ['BA39 1290 0794 0102 8494'], //Bosnia and Herzegovina - ['BG80 BNBG 9661 1020 3456 78'], //Bulgaria - ['BY 13 NBRB 3600 900000002Z00AB00'], //Belarus - ['BY13 NBRB 3600 900000002Z00AB00'], //Belarus - ['BY22NB23324232T78YR7823HR32U'], //Belarus - ['HR12 1001 0051 8630 0016 0'], //Croatia - ['CY17 0020 0128 0000 0012 0052 7600'], //Cyprus - ['CZ65 0800 0000 1920 0014 5399'], //Czech Republic - ['DK50 0040 0440 1162 43'], //Denmark - ['EE38 2200 2210 2014 5685'], //Estonia - ['FO97 5432 0388 8999 44'], //Faroe Islands - ['FI21 1234 5600 0007 85'], //Finland - ['FR14 2004 1010 0505 0001 3M02 606'], //France - ['GE29 NB00 0000 0101 9049 17'], //Georgia - ['DE89 3704 0044 0532 0130 00'], //Germany - ['GI75 NWBK 0000 0000 7099 453'], //Gibraltar - ['GR16 0110 1250 0000 0001 2300 695'], //Greece - ['GL56 0444 9876 5432 10'], //Greenland - ['HU42 1177 3016 1111 1018 0000 0000'], //Hungary - ['IS14 0159 2600 7654 5510 7303 39'], //Iceland - ['IE29 AIBK 9311 5212 3456 78'], //Ireland - ['IL62 0108 0000 0009 9999 999'], //Israel - ['IT40 S054 2811 1010 0000 0123 456'], //Italy - ['LV80 BANK 0000 4351 9500 1'], //Latvia - ['LB62 0999 0000 0001 0019 0122 9114'], //Lebanon - ['LI21 0881 0000 2324 013A A'], //Liechtenstein - ['LT12 1000 0111 0100 1000'], //Lithuania - ['LU28 0019 4006 4475 0000'], //Luxembourg - ['MK072 5012 0000 0589 84'], //Macedonia - ['MT84 MALT 0110 0001 2345 MTLC AST0 01S'], //Malta - ['MU17 BOMM 0101 1010 3030 0200 000M UR'], //Mauritius - ['MD24 AG00 0225 1000 1310 4168'], //Moldova - ['MC93 2005 2222 1001 1223 3M44 555'], //Monaco - ['ME25 5050 0001 2345 6789 51'], //Montenegro - ['NL39 RABO 0300 0652 64'], //Netherlands - ['NO93 8601 1117 947'], //Norway - ['PK36 SCBL 0000 0011 2345 6702'], //Pakistan - ['PL60 1020 1026 0000 0422 7020 1111'], //Poland - ['PT50 0002 0123 1234 5678 9015 4'], //Portugal - ['RO49 AAAA 1B31 0075 9384 0000'], //Romania - ['SM86 U032 2509 8000 0000 0270 100'], //San Marino - ['SA03 8000 0000 6080 1016 7519'], //Saudi Arabia - ['RS35 2600 0560 1001 6113 79'], //Serbia - ['SK31 1200 0000 1987 4263 7541'], //Slovak Republic - ['SI56 1910 0000 0123 438'], //Slovenia - ['ES80 2310 0001 1800 0001 2345'], //Spain - ['SE35 5000 0000 0549 1000 0003'], //Sweden - ['CH93 0076 2011 6238 5295 7'], //Switzerland - ['TN59 1000 6035 1835 9847 8831'], //Tunisia - ['TR33 0006 1005 1978 6457 8413 26'], //Turkey - ['AE07 0331 2345 6789 0123 456'], //UAE - ['GB12 CPBK 0892 9965 0449 91'], //United Kingdom + ['AL47 2121 1009 0000 0002 3569 8741'], // Albania + ['AD12 0001 2030 2003 5910 0100'], // Andorra + ['AT61 1904 3002 3457 3201'], // Austria + ['AZ21 NABZ 0000 0000 1370 1000 1944'], // Azerbaijan + ['BH67 BMAG 0000 1299 1234 56'], // Bahrain + ['BE62 5100 0754 7061'], // Belgium + ['BA39 1290 0794 0102 8494'], // Bosnia and Herzegovina + ['BG80 BNBG 9661 1020 3456 78'], // Bulgaria + ['BY 13 NBRB 3600 900000002Z00AB00'], // Belarus + ['BY13 NBRB 3600 900000002Z00AB00'], // Belarus + ['BY22NB23324232T78YR7823HR32U'], // Belarus + ['HR12 1001 0051 8630 0016 0'], // Croatia + ['CY17 0020 0128 0000 0012 0052 7600'], // Cyprus + ['CZ65 0800 0000 1920 0014 5399'], // Czech Republic + ['DK50 0040 0440 1162 43'], // Denmark + ['EE38 2200 2210 2014 5685'], // Estonia + ['FO97 5432 0388 8999 44'], // Faroe Islands + ['FI21 1234 5600 0007 85'], // Finland + ['FR14 2004 1010 0505 0001 3M02 606'], // France + ['GE29 NB00 0000 0101 9049 17'], // Georgia + ['DE89 3704 0044 0532 0130 00'], // Germany + ['GI75 NWBK 0000 0000 7099 453'], // Gibraltar + ['GR16 0110 1250 0000 0001 2300 695'], // Greece + ['GL56 0444 9876 5432 10'], // Greenland + ['HU42 1177 3016 1111 1018 0000 0000'], // Hungary + ['IS14 0159 2600 7654 5510 7303 39'], // Iceland + ['IE29 AIBK 9311 5212 3456 78'], // Ireland + ['IL62 0108 0000 0009 9999 999'], // Israel + ['IT40 S054 2811 1010 0000 0123 456'], // Italy + ['LV80 BANK 0000 4351 9500 1'], // Latvia + ['LB62 0999 0000 0001 0019 0122 9114'], // Lebanon + ['LI21 0881 0000 2324 013A A'], // Liechtenstein + ['LT12 1000 0111 0100 1000'], // Lithuania + ['LU28 0019 4006 4475 0000'], // Luxembourg + ['MK072 5012 0000 0589 84'], // Macedonia + ['MT84 MALT 0110 0001 2345 MTLC AST0 01S'], // Malta + ['MU17 BOMM 0101 1010 3030 0200 000M UR'], // Mauritius + ['MD24 AG00 0225 1000 1310 4168'], // Moldova + ['MC93 2005 2222 1001 1223 3M44 555'], // Monaco + ['ME25 5050 0001 2345 6789 51'], // Montenegro + ['NL39 RABO 0300 0652 64'], // Netherlands + ['NO93 8601 1117 947'], // Norway + ['PK36 SCBL 0000 0011 2345 6702'], // Pakistan + ['PL60 1020 1026 0000 0422 7020 1111'], // Poland + ['PT50 0002 0123 1234 5678 9015 4'], // Portugal + ['RO49 AAAA 1B31 0075 9384 0000'], // Romania + ['SM86 U032 2509 8000 0000 0270 100'], // San Marino + ['SA03 8000 0000 6080 1016 7519'], // Saudi Arabia + ['RS35 2600 0560 1001 6113 79'], // Serbia + ['SK31 1200 0000 1987 4263 7541'], // Slovak Republic + ['SI56 1910 0000 0123 438'], // Slovenia + ['ES80 2310 0001 1800 0001 2345'], // Spain + ['SE35 5000 0000 0549 1000 0003'], // Sweden + ['CH93 0076 2011 6238 5295 7'], // Switzerland + ['TN59 1000 6035 1835 9847 8831'], // Tunisia + ['TR33 0006 1005 1978 6457 8413 26'], // Turkey + ['AE07 0331 2345 6789 0123 456'], // UAE + ['GB12 CPBK 0892 9965 0449 91'], // United Kingdom - //Extended country list - //http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html + // Extended country list + // http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html // https://www.swift.com/sites/default/files/resources/iban_registry.pdf - ['AO06000600000100037131174'], //Angola - ['AZ21NABZ00000000137010001944'], //Azerbaijan - ['BH29BMAG1299123456BH00'], //Bahrain - ['BJ11B00610100400271101192591'], //Benin + ['AO06000600000100037131174'], // Angola + ['AZ21NABZ00000000137010001944'], // Azerbaijan + ['BH29BMAG1299123456BH00'], // Bahrain + ['BJ11B00610100400271101192591'], // Benin ['BR9700360305000010009795493P1'], // Brazil ['BR1800000000141455123924100C2'], // Brazil - ['VG96VPVG0000012345678901'], //British Virgin Islands - ['BF1030134020015400945000643'], //Burkina Faso - ['BI43201011067444'], //Burundi - ['CM2110003001000500000605306'], //Cameroon - ['CV64000300004547069110176'], //Cape Verde - ['FR7630007000110009970004942'], //Central African Republic - ['CG5230011000202151234567890'], //Congo - ['CR05015202001026284066'], //Costa Rica - ['DO28BAGR00000001212453611324'], //Dominican Republic - ['GT82TRAJ01020000001210029690'], //Guatemala - ['IR580540105180021273113007'], //Iran - ['IL620108000000099999999'], //Israel - ['CI05A00060174100178530011852'], //Ivory Coast + ['VG96VPVG0000012345678901'], // British Virgin Islands + ['BF1030134020015400945000643'], // Burkina Faso + ['BI43201011067444'], // Burundi + ['CM2110003001000500000605306'], // Cameroon + ['CV64000300004547069110176'], // Cape Verde + ['FR7630007000110009970004942'], // Central African Republic + ['CG5230011000202151234567890'], // Congo + ['CR05015202001026284066'], // Costa Rica + ['DO28BAGR00000001212453611324'], // Dominican Republic + ['GT82TRAJ01020000001210029690'], // Guatemala + ['IR580540105180021273113007'], // Iran + ['IL620108000000099999999'], // Israel + ['CI05A00060174100178530011852'], // Ivory Coast ['JO94CBJO0010000000000131000302'], // Jordan - ['KZ176010251000042993'], //Kazakhstan - ['KW74NBOK0000000000001000372151'], //Kuwait - ['LB30099900000001001925579115'], //Lebanon - ['MG4600005030010101914016056'], //Madagascar - ['ML03D00890170001002120000447'], //Mali - ['MR1300012000010000002037372'], //Mauritania - ['MU17BOMM0101101030300200000MUR'], //Mauritius - ['MZ59000100000011834194157'], //Mozambique - ['PS92PALS000000000400123456702'], //Palestinian Territory - ['QA58DOHB00001234567890ABCDEFG'], //Qatar - ['XK051212012345678906'], //Republic of Kosovo - ['PT50000200000163099310355'], //Sao Tome and Principe - ['SA0380000000608010167519'], //Saudi Arabia - ['SN12K00100152000025690007542'], //Senegal - ['TL380080012345678910157'], //Timor-Leste - ['TN5914207207100707129648'], //Tunisia - ['TR330006100519786457841326'], //Turkey - ['UA213223130000026007233566001'], //Ukraine - ['AE260211000000230064016'], //United Arab Emirates - ['VA59001123000012345678'], //Vatican City State + ['KZ176010251000042993'], // Kazakhstan + ['KW74NBOK0000000000001000372151'], // Kuwait + ['LB30099900000001001925579115'], // Lebanon + ['MG4600005030010101914016056'], // Madagascar + ['ML03D00890170001002120000447'], // Mali + ['MR1300012000010000002037372'], // Mauritania + ['MU17BOMM0101101030300200000MUR'], // Mauritius + ['MZ59000100000011834194157'], // Mozambique + ['PS92PALS000000000400123456702'], // Palestinian Territory + ['QA58DOHB00001234567890ABCDEFG'], // Qatar + ['XK051212012345678906'], // Republic of Kosovo + ['PT50000200000163099310355'], // Sao Tome and Principe + ['SA0380000000608010167519'], // Saudi Arabia + ['SN12K00100152000025690007542'], // Senegal + ['TL380080012345678910157'], // Timor-Leste + ['TN5914207207100707129648'], // Tunisia + ['TR330006100519786457841326'], // Turkey + ['UA213223130000026007233566001'], // Ukraine + ['AE260211000000230064016'], // United Arab Emirates + ['VA59001123000012345678'], // Vatican City State ]; } @@ -171,111 +171,111 @@ public function testIbansWithInvalidFormat($iban) public function getIbansWithInvalidFormat() { return [ - ['AL47 2121 1009 0000 0002 3569 874'], //Albania - ['AD12 0001 2030 2003 5910 010'], //Andorra - ['AT61 1904 3002 3457 320'], //Austria - ['AZ21 NABZ 0000 0000 1370 1000 194'], //Azerbaijan - ['AZ21 N1BZ 0000 0000 1370 1000 1944'], //Azerbaijan - ['BH67 BMAG 0000 1299 1234 5'], //Bahrain - ['BH67 B2AG 0000 1299 1234 56'], //Bahrain - ['BE62 5100 0754 7061 2'], //Belgium - ['BA39 1290 0794 0102 8494 4'], //Bosnia and Herzegovina - ['BG80 BNBG 9661 1020 3456 7'], //Bulgaria - ['BG80 B2BG 9661 1020 3456 78'], //Bulgaria - ['BY 13 NBRB 3600 900000002Z00AB001'], //Belarus - ['BY 13 NBRB 3600 900000002Z00AB0'], //Belarus - ['BYRO NBRB 3600 900000002Z00AB0'], //Belarus - ['BY 13 3600 NBRB 900000002Z00AB05'], //Belarus - ['HR12 1001 0051 8630 0016 01'], //Croatia - ['CY17 0020 0128 0000 0012 0052 7600 1'], //Cyprus - ['CZ65 0800 0000 1920 0014 5399 1'], //Czech Republic - ['DK50 0040 0440 1162 431'], //Denmark - ['EE38 2200 2210 2014 5685 1'], //Estonia - ['FO97 5432 0388 8999 441'], //Faroe Islands - ['FI21 1234 5600 0007 851'], //Finland - ['FR14 2004 1010 0505 0001 3M02 6061'], //France - ['GE29 NB00 0000 0101 9049 171'], //Georgia - ['DE89 3704 0044 0532 0130 001'], //Germany - ['GI75 NWBK 0000 0000 7099 4531'], //Gibraltar - ['GR16 0110 1250 0000 0001 2300 6951'], //Greece - ['GL56 0444 9876 5432 101'], //Greenland - ['HU42 1177 3016 1111 1018 0000 0000 1'], //Hungary - ['IS14 0159 2600 7654 5510 7303 391'], //Iceland - ['IE29 AIBK 9311 5212 3456 781'], //Ireland - ['IL62 0108 0000 0009 9999 9991'], //Israel - ['IT40 S054 2811 1010 0000 0123 4561'], //Italy - ['LV80 BANK 0000 4351 9500 11'], //Latvia - ['LB62 0999 0000 0001 0019 0122 9114 1'], //Lebanon - ['LI21 0881 0000 2324 013A A1'], //Liechtenstein - ['LT12 1000 0111 0100 1000 1'], //Lithuania - ['LU28 0019 4006 4475 0000 1'], //Luxembourg - ['MK072 5012 0000 0589 84 1'], //Macedonia - ['MT84 MALT 0110 0001 2345 MTLC AST0 01SA'], //Malta - ['MU17 BOMM 0101 1010 3030 0200 000M URA'], //Mauritius - ['MD24 AG00 0225 1000 1310 4168 1'], //Moldova - ['MC93 2005 2222 1001 1223 3M44 5551'], //Monaco - ['ME25 5050 0001 2345 6789 511'], //Montenegro - ['NL39 RABO 0300 0652 641'], //Netherlands - ['NO93 8601 1117 9471'], //Norway - ['PK36 SCBL 0000 0011 2345 6702 1'], //Pakistan - ['PL60 1020 1026 0000 0422 7020 1111 1'], //Poland - ['PT50 0002 0123 1234 5678 9015 41'], //Portugal - ['RO49 AAAA 1B31 0075 9384 0000 1'], //Romania - ['SM86 U032 2509 8000 0000 0270 1001'], //San Marino - ['SA03 8000 0000 6080 1016 7519 1'], //Saudi Arabia - ['RS35 2600 0560 1001 6113 791'], //Serbia - ['SK31 1200 0000 1987 4263 7541 1'], //Slovak Republic - ['SI56 1910 0000 0123 4381'], //Slovenia - ['ES80 2310 0001 1800 0001 2345 1'], //Spain - ['SE35 5000 0000 0549 1000 0003 1'], //Sweden - ['CH93 0076 2011 6238 5295 71'], //Switzerland - ['TN59 1000 6035 1835 9847 8831 1'], //Tunisia - ['TR33 0006 1005 1978 6457 8413 261'], //Turkey - ['AE07 0331 2345 6789 0123 4561'], //UAE - ['GB12 CPBK 0892 9965 0449 911'], //United Kingdom + ['AL47 2121 1009 0000 0002 3569 874'], // Albania + ['AD12 0001 2030 2003 5910 010'], // Andorra + ['AT61 1904 3002 3457 320'], // Austria + ['AZ21 NABZ 0000 0000 1370 1000 194'], // Azerbaijan + ['AZ21 N1BZ 0000 0000 1370 1000 1944'], // Azerbaijan + ['BH67 BMAG 0000 1299 1234 5'], // Bahrain + ['BH67 B2AG 0000 1299 1234 56'], // Bahrain + ['BE62 5100 0754 7061 2'], // Belgium + ['BA39 1290 0794 0102 8494 4'], // Bosnia and Herzegovina + ['BG80 BNBG 9661 1020 3456 7'], // Bulgaria + ['BG80 B2BG 9661 1020 3456 78'], // Bulgaria + ['BY 13 NBRB 3600 900000002Z00AB001'], // Belarus + ['BY 13 NBRB 3600 900000002Z00AB0'], // Belarus + ['BYRO NBRB 3600 900000002Z00AB0'], // Belarus + ['BY 13 3600 NBRB 900000002Z00AB05'], // Belarus + ['HR12 1001 0051 8630 0016 01'], // Croatia + ['CY17 0020 0128 0000 0012 0052 7600 1'], // Cyprus + ['CZ65 0800 0000 1920 0014 5399 1'], // Czech Republic + ['DK50 0040 0440 1162 431'], // Denmark + ['EE38 2200 2210 2014 5685 1'], // Estonia + ['FO97 5432 0388 8999 441'], // Faroe Islands + ['FI21 1234 5600 0007 851'], // Finland + ['FR14 2004 1010 0505 0001 3M02 6061'], // France + ['GE29 NB00 0000 0101 9049 171'], // Georgia + ['DE89 3704 0044 0532 0130 001'], // Germany + ['GI75 NWBK 0000 0000 7099 4531'], // Gibraltar + ['GR16 0110 1250 0000 0001 2300 6951'], // Greece + ['GL56 0444 9876 5432 101'], // Greenland + ['HU42 1177 3016 1111 1018 0000 0000 1'], // Hungary + ['IS14 0159 2600 7654 5510 7303 391'], // Iceland + ['IE29 AIBK 9311 5212 3456 781'], // Ireland + ['IL62 0108 0000 0009 9999 9991'], // Israel + ['IT40 S054 2811 1010 0000 0123 4561'], // Italy + ['LV80 BANK 0000 4351 9500 11'], // Latvia + ['LB62 0999 0000 0001 0019 0122 9114 1'], // Lebanon + ['LI21 0881 0000 2324 013A A1'], // Liechtenstein + ['LT12 1000 0111 0100 1000 1'], // Lithuania + ['LU28 0019 4006 4475 0000 1'], // Luxembourg + ['MK072 5012 0000 0589 84 1'], // Macedonia + ['MT84 MALT 0110 0001 2345 MTLC AST0 01SA'], // Malta + ['MU17 BOMM 0101 1010 3030 0200 000M URA'], // Mauritius + ['MD24 AG00 0225 1000 1310 4168 1'], // Moldova + ['MC93 2005 2222 1001 1223 3M44 5551'], // Monaco + ['ME25 5050 0001 2345 6789 511'], // Montenegro + ['NL39 RABO 0300 0652 641'], // Netherlands + ['NO93 8601 1117 9471'], // Norway + ['PK36 SCBL 0000 0011 2345 6702 1'], // Pakistan + ['PL60 1020 1026 0000 0422 7020 1111 1'], // Poland + ['PT50 0002 0123 1234 5678 9015 41'], // Portugal + ['RO49 AAAA 1B31 0075 9384 0000 1'], // Romania + ['SM86 U032 2509 8000 0000 0270 1001'], // San Marino + ['SA03 8000 0000 6080 1016 7519 1'], // Saudi Arabia + ['RS35 2600 0560 1001 6113 791'], // Serbia + ['SK31 1200 0000 1987 4263 7541 1'], // Slovak Republic + ['SI56 1910 0000 0123 4381'], // Slovenia + ['ES80 2310 0001 1800 0001 2345 1'], // Spain + ['SE35 5000 0000 0549 1000 0003 1'], // Sweden + ['CH93 0076 2011 6238 5295 71'], // Switzerland + ['TN59 1000 6035 1835 9847 8831 1'], // Tunisia + ['TR33 0006 1005 1978 6457 8413 261'], // Turkey + ['AE07 0331 2345 6789 0123 4561'], // UAE + ['GB12 CPBK 0892 9965 0449 911'], // United Kingdom - //Extended country list - ['AO060006000001000371311741'], //Angola - ['AZ21NABZ000000001370100019441'], //Azerbaijan - ['BH29BMAG1299123456BH001'], //Bahrain - ['BJ11B006101004002711011925911'], //Benin + // Extended country list + ['AO060006000001000371311741'], // Angola + ['AZ21NABZ000000001370100019441'], // Azerbaijan + ['BH29BMAG1299123456BH001'], // Bahrain + ['BJ11B006101004002711011925911'], // Benin ['BR9700360305000010009795493P11'], // Brazil ['BR1800000000141455123924100C21'], // Brazil - ['VG96VPVG00000123456789011'], //British Virgin Islands - ['BF10301340200154009450006431'], //Burkina Faso - ['BI432010110674441'], //Burundi - ['CM21100030010005000006053061'], //Cameroon - ['CV640003000045470691101761'], //Cape Verde - ['FR76300070001100099700049421'], //Central African Republic - ['CG52300110002021512345678901'], //Congo - ['CR05152020010262840661'], //Costa Rica - ['CR0515202001026284066'], //Costa Rica - ['DO28BAGR000000012124536113241'], //Dominican Republic - ['GT82TRAJ010200000012100296901'], //Guatemala - ['IR5805401051800212731130071'], //Iran - ['IL6201080000000999999991'], //Israel - ['CI05A000601741001785300118521'], //Ivory Coast + ['VG96VPVG00000123456789011'], // British Virgin Islands + ['BF10301340200154009450006431'], // Burkina Faso + ['BI432010110674441'], // Burundi + ['CM21100030010005000006053061'], // Cameroon + ['CV640003000045470691101761'], // Cape Verde + ['FR76300070001100099700049421'], // Central African Republic + ['CG52300110002021512345678901'], // Congo + ['CR05152020010262840661'], // Costa Rica + ['CR0515202001026284066'], // Costa Rica + ['DO28BAGR000000012124536113241'], // Dominican Republic + ['GT82TRAJ010200000012100296901'], // Guatemala + ['IR5805401051800212731130071'], // Iran + ['IL6201080000000999999991'], // Israel + ['CI05A000601741001785300118521'], // Ivory Coast ['JO94CBJO00100000000001310003021'], // Jordan - ['KZ1760102510000429931'], //Kazakhstan - ['KW74NBOK00000000000010003721511'], //Kuwait - ['LB300999000000010019255791151'], //Lebanon - ['MG46000050300101019140160561'], //Madagascar - ['ML03D008901700010021200004471'], //Mali - ['MR13000120000100000020373721'], //Mauritania - ['MU17BOMM0101101030300200000MUR1'], //Mauritius - ['MZ590001000000118341941571'], //Mozambique - ['PS92PALS0000000004001234567021'], //Palestinian Territory - ['QA58DOHB00001234567890ABCDEFG1'], //Qatar - ['XK0512120123456789061'], //Republic of Kosovo - ['PT500002000001630993103551'], //Sao Tome and Principe - ['SA03800000006080101675191'], //Saudi Arabia - ['SN12K001001520000256900075421'], //Senegal - ['TL3800800123456789101571'], //Timor-Leste - ['TN59142072071007071296481'], //Tunisia - ['TR3300061005197864578413261'], //Turkey - ['UA21AAAA1300000260072335660012'], //Ukraine - ['AE2602110000002300640161'], //United Arab Emirates - ['VA590011230000123456781'], //Vatican City State + ['KZ1760102510000429931'], // Kazakhstan + ['KW74NBOK00000000000010003721511'], // Kuwait + ['LB300999000000010019255791151'], // Lebanon + ['MG46000050300101019140160561'], // Madagascar + ['ML03D008901700010021200004471'], // Mali + ['MR13000120000100000020373721'], // Mauritania + ['MU17BOMM0101101030300200000MUR1'], // Mauritius + ['MZ590001000000118341941571'], // Mozambique + ['PS92PALS0000000004001234567021'], // Palestinian Territory + ['QA58DOHB00001234567890ABCDEFG1'], // Qatar + ['XK0512120123456789061'], // Republic of Kosovo + ['PT500002000001630993103551'], // Sao Tome and Principe + ['SA03800000006080101675191'], // Saudi Arabia + ['SN12K001001520000256900075421'], // Senegal + ['TL3800800123456789101571'], // Timor-Leste + ['TN59142072071007071296481'], // Tunisia + ['TR3300061005197864578413261'], // Turkey + ['UA21AAAA1300000260072335660012'], // Ukraine + ['AE2602110000002300640161'], // United Arab Emirates + ['VA590011230000123456781'], // Vatican City State ]; } @@ -290,104 +290,104 @@ public function testIbansWithValidFormatButIncorrectChecksum($iban) public function getIbansWithValidFormatButIncorrectChecksum() { return [ - ['AL47 2121 1009 0000 0002 3569 8742'], //Albania - ['AD12 0001 2030 2003 5910 0101'], //Andorra - ['AT61 1904 3002 3457 3202'], //Austria - ['AZ21 NABZ 0000 0000 1370 1000 1945'], //Azerbaijan - ['BH67 BMAG 0000 1299 1234 57'], //Bahrain - ['BE62 5100 0754 7062'], //Belgium - ['BA39 1290 0794 0102 8495'], //Bosnia and Herzegovina - ['BG80 BNBG 9661 1020 3456 79'], //Bulgaria - ['BY90 NBRB 3600 900000002Z00AB00'], //Belarus - ['HR12 1001 0051 8630 0016 1'], //Croatia - ['CY17 0020 0128 0000 0012 0052 7601'], //Cyprus - ['CZ65 0800 0000 1920 0014 5398'], //Czech Republic - ['DK50 0040 0440 1162 44'], //Denmark - ['EE38 2200 2210 2014 5684'], //Estonia - ['FO97 5432 0388 8999 43'], //Faroe Islands - ['FI21 1234 5600 0007 84'], //Finland - ['FR14 2004 1010 0505 0001 3M02 605'], //France - ['GE29 NB00 0000 0101 9049 16'], //Georgia - ['DE89 3704 0044 0532 0130 01'], //Germany - ['GI75 NWBK 0000 0000 7099 452'], //Gibraltar - ['GR16 0110 1250 0000 0001 2300 694'], //Greece - ['GL56 0444 9876 5432 11'], //Greenland - ['HU42 1177 3016 1111 1018 0000 0001'], //Hungary - ['IS14 0159 2600 7654 5510 7303 38'], //Iceland - ['IE29 AIBK 9311 5212 3456 79'], //Ireland - ['IL62 0108 0000 0009 9999 998'], //Israel - ['IT40 S054 2811 1010 0000 0123 457'], //Italy - ['LV80 BANK 0000 4351 9500 2'], //Latvia - ['LB62 0999 0000 0001 0019 0122 9115'], //Lebanon - ['LI21 0881 0000 2324 013A B'], //Liechtenstein - ['LT12 1000 0111 0100 1001'], //Lithuania - ['LU28 0019 4006 4475 0001'], //Luxembourg - ['MK072 5012 0000 0589 85'], //Macedonia - ['MT84 MALT 0110 0001 2345 MTLC AST0 01T'], //Malta - ['MU17 BOMM 0101 1010 3030 0200 000M UP'], //Mauritius - ['MD24 AG00 0225 1000 1310 4169'], //Moldova - ['MC93 2005 2222 1001 1223 3M44 554'], //Monaco - ['ME25 5050 0001 2345 6789 52'], //Montenegro - ['NL39 RABO 0300 0652 65'], //Netherlands - ['NO93 8601 1117 948'], //Norway - ['PK36 SCBL 0000 0011 2345 6703'], //Pakistan - ['PL60 1020 1026 0000 0422 7020 1112'], //Poland - ['PT50 0002 0123 1234 5678 9015 5'], //Portugal - ['RO49 AAAA 1B31 0075 9384 0001'], //Romania - ['SM86 U032 2509 8000 0000 0270 101'], //San Marino - ['SA03 8000 0000 6080 1016 7518'], //Saudi Arabia - ['RS35 2600 0560 1001 6113 78'], //Serbia - ['SK31 1200 0000 1987 4263 7542'], //Slovak Republic - ['SI56 1910 0000 0123 439'], //Slovenia - ['ES80 2310 0001 1800 0001 2346'], //Spain - ['SE35 5000 0000 0549 1000 0004'], //Sweden - ['CH93 0076 2011 6238 5295 8'], //Switzerland - ['TN59 1000 6035 1835 9847 8832'], //Tunisia - ['TR33 0006 1005 1978 6457 8413 27'], //Turkey - ['AE07 0331 2345 6789 0123 457'], //UAE - ['GB12 CPBK 0892 9965 0449 92'], //United Kingdom + ['AL47 2121 1009 0000 0002 3569 8742'], // Albania + ['AD12 0001 2030 2003 5910 0101'], // Andorra + ['AT61 1904 3002 3457 3202'], // Austria + ['AZ21 NABZ 0000 0000 1370 1000 1945'], // Azerbaijan + ['BH67 BMAG 0000 1299 1234 57'], // Bahrain + ['BE62 5100 0754 7062'], // Belgium + ['BA39 1290 0794 0102 8495'], // Bosnia and Herzegovina + ['BG80 BNBG 9661 1020 3456 79'], // Bulgaria + ['BY90 NBRB 3600 900000002Z00AB00'], // Belarus + ['HR12 1001 0051 8630 0016 1'], // Croatia + ['CY17 0020 0128 0000 0012 0052 7601'], // Cyprus + ['CZ65 0800 0000 1920 0014 5398'], // Czech Republic + ['DK50 0040 0440 1162 44'], // Denmark + ['EE38 2200 2210 2014 5684'], // Estonia + ['FO97 5432 0388 8999 43'], // Faroe Islands + ['FI21 1234 5600 0007 84'], // Finland + ['FR14 2004 1010 0505 0001 3M02 605'], // France + ['GE29 NB00 0000 0101 9049 16'], // Georgia + ['DE89 3704 0044 0532 0130 01'], // Germany + ['GI75 NWBK 0000 0000 7099 452'], // Gibraltar + ['GR16 0110 1250 0000 0001 2300 694'], // Greece + ['GL56 0444 9876 5432 11'], // Greenland + ['HU42 1177 3016 1111 1018 0000 0001'], // Hungary + ['IS14 0159 2600 7654 5510 7303 38'], // Iceland + ['IE29 AIBK 9311 5212 3456 79'], // Ireland + ['IL62 0108 0000 0009 9999 998'], // Israel + ['IT40 S054 2811 1010 0000 0123 457'], // Italy + ['LV80 BANK 0000 4351 9500 2'], // Latvia + ['LB62 0999 0000 0001 0019 0122 9115'], // Lebanon + ['LI21 0881 0000 2324 013A B'], // Liechtenstein + ['LT12 1000 0111 0100 1001'], // Lithuania + ['LU28 0019 4006 4475 0001'], // Luxembourg + ['MK072 5012 0000 0589 85'], // Macedonia + ['MT84 MALT 0110 0001 2345 MTLC AST0 01T'], // Malta + ['MU17 BOMM 0101 1010 3030 0200 000M UP'], // Mauritius + ['MD24 AG00 0225 1000 1310 4169'], // Moldova + ['MC93 2005 2222 1001 1223 3M44 554'], // Monaco + ['ME25 5050 0001 2345 6789 52'], // Montenegro + ['NL39 RABO 0300 0652 65'], // Netherlands + ['NO93 8601 1117 948'], // Norway + ['PK36 SCBL 0000 0011 2345 6703'], // Pakistan + ['PL60 1020 1026 0000 0422 7020 1112'], // Poland + ['PT50 0002 0123 1234 5678 9015 5'], // Portugal + ['RO49 AAAA 1B31 0075 9384 0001'], // Romania + ['SM86 U032 2509 8000 0000 0270 101'], // San Marino + ['SA03 8000 0000 6080 1016 7518'], // Saudi Arabia + ['RS35 2600 0560 1001 6113 78'], // Serbia + ['SK31 1200 0000 1987 4263 7542'], // Slovak Republic + ['SI56 1910 0000 0123 439'], // Slovenia + ['ES80 2310 0001 1800 0001 2346'], // Spain + ['SE35 5000 0000 0549 1000 0004'], // Sweden + ['CH93 0076 2011 6238 5295 8'], // Switzerland + ['TN59 1000 6035 1835 9847 8832'], // Tunisia + ['TR33 0006 1005 1978 6457 8413 27'], // Turkey + ['AE07 0331 2345 6789 0123 457'], // UAE + ['GB12 CPBK 0892 9965 0449 92'], // United Kingdom - //Extended country list - ['AO06000600000100037131175'], //Angola - ['AZ21NABZ00000000137010001945'], //Azerbaijan - ['BH29BMAG1299123456BH01'], //Bahrain - ['BJ11B00610100400271101192592'], //Benin + // Extended country list + ['AO06000600000100037131175'], // Angola + ['AZ21NABZ00000000137010001945'], // Azerbaijan + ['BH29BMAG1299123456BH01'], // Bahrain + ['BJ11B00610100400271101192592'], // Benin ['BR9700360305000010009795493P2'], // Brazil ['BR1800000000141455123924100C3'], // Brazil - ['VG96VPVG0000012345678902'], //British Virgin Islands - ['BF1030134020015400945000644'], //Burkina Faso - ['BI43201011067445'], //Burundi - ['CM2110003001000500000605307'], //Cameroon - ['CV64000300004547069110177'], //Cape Verde - ['FR7630007000110009970004943'], //Central African Republic - ['CG5230011000202151234567891'], //Congo - ['CR96042332432534543564'], //Costa Rica - ['DO28BAGR00000001212453611325'], //Dominican Republic - ['GT82TRAJ01020000001210029691'], //Guatemala - ['IR580540105180021273113008'], //Iran - ['IL620108000000099999998'], //Israel - ['CI05A00060174100178530011853'], //Ivory Coast + ['VG96VPVG0000012345678902'], // British Virgin Islands + ['BF1030134020015400945000644'], // Burkina Faso + ['BI43201011067445'], // Burundi + ['CM2110003001000500000605307'], // Cameroon + ['CV64000300004547069110177'], // Cape Verde + ['FR7630007000110009970004943'], // Central African Republic + ['CG5230011000202151234567891'], // Congo + ['CR96042332432534543564'], // Costa Rica + ['DO28BAGR00000001212453611325'], // Dominican Republic + ['GT82TRAJ01020000001210029691'], // Guatemala + ['IR580540105180021273113008'], // Iran + ['IL620108000000099999998'], // Israel + ['CI05A00060174100178530011853'], // Ivory Coast ['JO94CBJO0010000000000131000303'], // Jordan - ['KZ176010251000042994'], //Kazakhstan - ['KW74NBOK0000000000001000372152'], //Kuwait - ['LB30099900000001001925579116'], //Lebanon - ['MG4600005030010101914016057'], //Madagascar - ['ML03D00890170001002120000448'], //Mali - ['MR1300012000010000002037373'], //Mauritania - ['MU17BOMM0101101030300200000MUP'], //Mauritius - ['MZ59000100000011834194158'], //Mozambique - ['PS92PALS000000000400123456703'], //Palestinian Territory - ['QA58DOHB00001234567890ABCDEFH'], //Qatar - ['XK051212012345678907'], //Republic of Kosovo - ['PT50000200000163099310356'], //Sao Tome and Principe - ['SA0380000000608010167518'], //Saudi Arabia - ['SN12K00100152000025690007543'], //Senegal - ['TL380080012345678910158'], //Timor-Leste - ['TN5914207207100707129649'], //Tunisia - ['TR330006100519786457841327'], //Turkey - ['UA213223130000026007233566002'], //Ukraine - ['AE260211000000230064017'], //United Arab Emirates - ['VA59001123000012345671'], //Vatican City State + ['KZ176010251000042994'], // Kazakhstan + ['KW74NBOK0000000000001000372152'], // Kuwait + ['LB30099900000001001925579116'], // Lebanon + ['MG4600005030010101914016057'], // Madagascar + ['ML03D00890170001002120000448'], // Mali + ['MR1300012000010000002037373'], // Mauritania + ['MU17BOMM0101101030300200000MUP'], // Mauritius + ['MZ59000100000011834194158'], // Mozambique + ['PS92PALS000000000400123456703'], // Palestinian Territory + ['QA58DOHB00001234567890ABCDEFH'], // Qatar + ['XK051212012345678907'], // Republic of Kosovo + ['PT50000200000163099310356'], // Sao Tome and Principe + ['SA0380000000608010167518'], // Saudi Arabia + ['SN12K00100152000025690007543'], // Senegal + ['TL380080012345678910158'], // Timor-Leste + ['TN5914207207100707129649'], // Tunisia + ['TR330006100519786457841327'], // Turkey + ['UA213223130000026007233566002'], // Ukraine + ['AE260211000000230064017'], // United Arab Emirates + ['VA59001123000012345671'], // Vatican City State ]; } diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index 0e8f50c348a14..1042e4f84eeb5 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -471,15 +471,15 @@ private function validateClassNode($object, ?string $cacheKey, ClassMetadataInte // group sequence and abort if necessary (G1, G2) if ($group instanceof GroupSequence) { $this->stepThroughGroupSequence( - $object, - $object, - $cacheKey, - $metadata, - $propertyPath, - $traversalStrategy, - $group, - $defaultOverridden ? Constraint::DEFAULT_GROUP : null, - $context + $object, + $object, + $cacheKey, + $metadata, + $propertyPath, + $traversalStrategy, + $group, + $defaultOverridden ? Constraint::DEFAULT_GROUP : null, + $context ); // Skip the group sequence when validating properties, because @@ -588,15 +588,15 @@ private function validateGenericNode($value, $object, ?string $cacheKey, ?Metada foreach ($groups as $key => $group) { if ($group instanceof GroupSequence) { $this->stepThroughGroupSequence( - $value, - $object, - $cacheKey, - $metadata, - $propertyPath, - $traversalStrategy, - $group, - null, - $context + $value, + $object, + $cacheKey, + $metadata, + $propertyPath, + $traversalStrategy, + $group, + null, + $context ); // Skip the group sequence when cascading, as the cascading @@ -695,26 +695,26 @@ private function stepThroughGroupSequence($value, $object, ?string $cacheKey, ?M if ($metadata instanceof ClassMetadataInterface) { $this->validateClassNode( - $value, - $cacheKey, - $metadata, - $propertyPath, - $groups, - $cascadedGroups, - $traversalStrategy, - $context + $value, + $cacheKey, + $metadata, + $propertyPath, + $groups, + $cascadedGroups, + $traversalStrategy, + $context ); } else { $this->validateGenericNode( - $value, - $object, - $cacheKey, - $metadata, - $propertyPath, - $groups, - $cascadedGroups, - $traversalStrategy, - $context + $value, + $object, + $cacheKey, + $metadata, + $propertyPath, + $groups, + $cascadedGroups, + $traversalStrategy, + $context ); } diff --git a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php index f8b485bd40c3f..b3f7bbee3a7a9 100644 --- a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php @@ -28,7 +28,7 @@ public function __construct(array $args, string $function, ?string $class) $values = []; foreach ($args as $k => $v) { - $values[$k] = !is_scalar($v) && !$v instanceof Stub ? new CutStub($v) : $v; + $values[$k] = !\is_scalar($v) && !$v instanceof Stub ? new CutStub($v) : $v; } if (null === $params) { parent::__construct($values, false); diff --git a/src/Symfony/Component/VarDumper/Caster/IntlCaster.php b/src/Symfony/Component/VarDumper/Caster/IntlCaster.php index d7099cb18a8c6..581324d10d36e 100644 --- a/src/Symfony/Component/VarDumper/Caster/IntlCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/IntlCaster.php @@ -102,7 +102,7 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $ 'SIGNIFICANT_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL), 'MONETARY_GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL), ] - ), + ), ]; return self::castError($c, $a); diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 2d3bb0138ac35..4185329a098d6 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -45,7 +45,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface public function __construct($output = null, string $charset = null, int $flags = 0) { $this->flags = $flags; - $this->setCharset($charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'); + $this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8'); $this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point']; $this->setOutput($output ?: static::$defaultOutput); if (!$output && \is_string(static::$defaultOutput)) { diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index b3d9e2561e1af..e3861cdaf5a4f 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -83,7 +83,7 @@ public function __construct($output = null, string $charset = null, int $flags = ]); } - $this->displayOptions['fileLinkFormat'] = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l'; + $this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l'; } /** diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 7fe31ef4918ab..9b57f900eaf08 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -81,7 +81,7 @@ public function __construct($output = null, string $charset = null, int $flags = { AbstractDumper::__construct($output, $charset, $flags); $this->dumpId = 'sf-dump-'.mt_rand(); - $this->displayOptions['fileLinkFormat'] = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); + $this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->styles = static::$themes['dark'] ?? self::$themes['dark']; } @@ -882,7 +882,7 @@ protected function style($style, $value, $attr = []) } if ('const' === $style && isset($attr['value'])) { - $style .= sprintf(' title="%s"', esc(is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value']))); + $style .= sprintf(' title="%s"', esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value']))); } elseif ('public' === $style) { $style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property'); } elseif ('str' === $style && 1 < $attr['length']) { diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php index 71c34f7646940..6c588919d09b2 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php @@ -151,7 +151,7 @@ public function testShouldReturnTraceForConcreteTwigWithError() public function testHtmlDump() { - if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { + if (\ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { $this->markTestSkipped('A custom file_link_format is defined.'); } diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index b7bccc0bdcda6..1940d17da0b14 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -20,6 +20,7 @@ use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionIntersectionTypeFixture; use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionNamedTypeFixture; use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionUnionTypeFixture; +use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionUnionTypeWithIntersectionFixture; /** * @author Nicolas Grekas @@ -78,7 +79,7 @@ public function testClosureCaster() $b: & 123 } file: "%sReflectionCasterTest.php" - line: "71 to 71" + line: "72 to 72" } EOTXT , $var @@ -131,7 +132,7 @@ public function testReflectionParameter() typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass" } EOTXT - , $var + , $var ); } @@ -326,6 +327,44 @@ public function testReflectionIntersectionType() ); } + /** + * @requires PHP 8.2 + */ + public function testReflectionUnionTypeWithIntersection() + { + $var = (new \ReflectionProperty(ReflectionUnionTypeWithIntersectionFixture::class, 'a'))->getType(); + $this->assertDumpMatchesFormat( + <<<'EOTXT' +ReflectionUnionType { + allowsNull: true + types: array:2 [ + 0 => ReflectionIntersectionType { + allowsNull: false + types: array:2 [ + 0 => ReflectionNamedType { + name: "Traversable" + allowsNull: false + isBuiltin: false + } + 1 => ReflectionNamedType { + name: "Countable" + allowsNull: false + isBuiltin: false + } + ] + } + 1 => ReflectionNamedType { + name: "null" + allowsNull: true + isBuiltin: true + } + ] +} +EOTXT + , $var + ); + } + /** * @requires PHP 8 */ diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php index f109caba82f75..cde1d7e91236e 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php @@ -26,7 +26,7 @@ class XmlReaderCasterTest extends TestCase protected function setUp(): void { - $this->reader = new \XmlReader(); + $this->reader = new \XMLReader(); $this->reader->open(__DIR__.'/../Fixtures/xml_reader.xml'); } @@ -248,7 +248,7 @@ public function provideNodes() public function testWithUninitializedXMLReader() { - $this->reader = new \XmlReader(); + $this->reader = new \XMLReader(); $expectedDump = <<<'EODUMP' XMLReader { diff --git a/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php b/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php index fed2d669a7654..8096f1afa9e0d 100644 --- a/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php @@ -330,7 +330,7 @@ public function testLimits() public function testJsonCast() { - if (2 == ini_get('xdebug.overload_var_dump')) { + if (2 == \ini_get('xdebug.overload_var_dump')) { $this->markTestSkipped('xdebug is active'); } diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php index 9921dc715a4dd..e63ad156e4955 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php @@ -23,7 +23,7 @@ class HtmlDumperTest extends TestCase { public function testGet() { - if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { + if (\ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { $this->markTestSkipped('A custom file_link_format is defined.'); } diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php index 447d4856f7329..921cfda456acf 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php @@ -79,7 +79,7 @@ public function getContext(): ?array ] %d DUMP - , $dumped); + , $dumped); } private function getServerProcess(): Process diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php new file mode 100644 index 0000000000000..630d0e77f69e6 --- /dev/null +++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php @@ -0,0 +1,8 @@ +tearDownVarDumper(); diff --git a/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php b/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php index 3ff0a89befbe2..1bfe412f73896 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php @@ -39,5 +39,5 @@ public function getMarking($subject); * @param object $subject A subject * @param array $context Some context */ - public function setMarking($subject, Marking $marking/*, array $context = []*/); + public function setMarking($subject, Marking $marking/* , array $context = [] */); } diff --git a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php index f541d1bf81a76..22e6c8c0072a5 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php @@ -58,8 +58,8 @@ public function getMarking($subject): Marking try { $marking = $subject->{$method}(); } catch (\Error $e) { - $unInitializedPropertyMassage = sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property); - if ($e->getMessage() !== $unInitializedPropertyMassage) { + $unInitializedPropertyMessage = sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property); + if ($e->getMessage() !== $unInitializedPropertyMessage) { throw $e; } } diff --git a/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php index 9305d99c98e0e..e69099436fc88 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php @@ -52,7 +52,7 @@ public function getMarking($subject) * * @param array $context Some context */ - public function setMarking($subject, Marking $marking/*, array $context = []*/) + public function setMarking($subject, Marking $marking/* , array $context = [] */) { $this->propertyAccessor->setValue($subject, $this->property, $marking->getPlaces()); } diff --git a/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php index 808e2767bb40a..c804e8c8b288e 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php @@ -57,7 +57,7 @@ public function getMarking($subject) * * @param array $context Some context */ - public function setMarking($subject, Marking $marking/*, array $context = []*/) + public function setMarking($subject, Marking $marking/* , array $context = [] */) { $this->propertyAccessor->setValue($subject, $this->property, key($marking->getPlaces())); } diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index 2fd62ea98336e..f38b6eb7b15a6 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -159,7 +159,7 @@ public function buildTransitionBlockerList($subject, string $transitionName): Tr * * @param array $context Some context */ - public function apply($subject, $transitionName/*, array $context = []*/) + public function apply($subject, $transitionName/* , array $context = [] */) { $context = \func_get_args()[2] ?? []; diff --git a/src/Symfony/Component/Workflow/WorkflowInterface.php b/src/Symfony/Component/Workflow/WorkflowInterface.php index b43a5c7bcc1cf..a42f8315e653c 100644 --- a/src/Symfony/Component/Workflow/WorkflowInterface.php +++ b/src/Symfony/Component/Workflow/WorkflowInterface.php @@ -59,7 +59,7 @@ public function buildTransitionBlockerList($subject, string $transitionName): Tr * * @throws LogicException If the transition is not applicable */ - public function apply($subject, $transitionName/*, array $context = []*/); + public function apply($subject, $transitionName/* , array $context = [] */); /** * Returns all enabled transitions. diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index dcb104ccff065..52db38c3b032b 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -110,7 +110,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): continue; } - if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) { + if ($inline - 1 <= 0 || null === $value->getValue() || \is_scalar($value->getValue())) { $output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n"; } else { $output .= "\n"; diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 24c802bcfa338..1d4bbda697de4 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -68,7 +68,7 @@ public static function parse(string $value = null, int $flags = 0, array &$refer return ''; } - if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) { + if (2 /* MB_OVERLOAD_STRING */ & (int) \ini_get('mbstring.func_overload')) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 646818f6b9a14..5c385f4fa778a 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -87,7 +87,7 @@ public function parse(string $value, int $flags = 0) $mbEncoding = null; - if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) { + if (2 /* MB_OVERLOAD_STRING */ & (int) \ini_get('mbstring.func_overload')) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('UTF-8'); } @@ -988,7 +988,7 @@ private function isCurrentLineBlank(): bool */ private function isCurrentLineComment(): bool { - //checking explicitly the first char of the trim is faster than loops or strpos + // checking explicitly the first char of the trim is faster than loops or strpos $ltrimmedLine = ltrim($this->currentLine, ' '); return '' !== $ltrimmedLine && '#' === $ltrimmedLine[0]; diff --git a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php index 2d470af92006c..eb3dc5e3865a0 100644 --- a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php @@ -32,7 +32,7 @@ interface EventDispatcherInterface extends PsrEventDispatcherInterface * * @return object The passed $event MUST be returned */ - public function dispatch($event/*, string $eventName = null*/); + public function dispatch($event/* , string $eventName = null */); } } else { /** @@ -53,6 +53,6 @@ interface EventDispatcherInterface * * @return object The passed $event MUST be returned */ - public function dispatch($event/*, string $eventName = null*/); + public function dispatch($event/* , string $eventName = null */); } } diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php index f6f9aa493769e..83551cb84d71c 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -348,7 +348,7 @@ protected function validateMatrix($nplural, $matrix, $expectSuccess = true) foreach ($matrix as $langCode => $data) { $indexes = array_flip($data); if ($expectSuccess) { - $this->assertEquals($nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms."); + $this->assertCount($nplural, $indexes, "Langcode '$langCode' has '$nplural' plural forms."); } else { $this->assertNotEquals((int) $nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms."); }