diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 426b55def0001..3d686194101c0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ | Q | A | ------------- | --- -| Branch? | master for features / 3.4, 4.2 or 4.3 for bug fixes +| Branch? | 4.4 for features / 3.4, 4.2 or 4.3 for bug fixes | Bug fix? | yes/no | New feature? | yes/no | BC breaks? | no @@ -17,5 +17,6 @@ understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - - Features and deprecations must be submitted against the master branch. + - Features and deprecations must be submitted against branch 4.4. + - Legacy code removals go to the master branch. --> diff --git a/.php_cs.dist b/.php_cs.dist index 8523be670698e..85c75692eb44f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,7 +15,7 @@ return PhpCsFixer\Config::create() 'ordered_imports' => true, 'protected_to_private' => false, // Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading - 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], + 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true], // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], ]) diff --git a/.travis.yml b/.travis.yml index 405eb68e90ac2..3a022159513e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -260,12 +260,12 @@ install: tfold 'phpunit install' ./phpunit install fi if [[ $deps = high ]]; then - echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" + echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" elif [[ $deps = low ]]; then [[ -e ~/php-ext/composer-lowest.lock.tar ]] && tar -xf ~/php-ext/composer-lowest.lock.tar tar -cf ~/php-ext/composer-lowest.lock.tar --files-from /dev/null php .github/rm-invalid-lowest-lock-files.php $COMPONENTS - echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'" + echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'" echo "$COMPONENTS" | xargs -n1 -I{} tar --append -f ~/php-ext/composer-lowest.lock.tar {}/composer.lock elif [[ $PHP = hhvm* ]]; then rm src/Symfony/Bridge/PhpUnit -Rf diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index 7b2094530cef7..a358d609f3cc6 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -7,6 +7,31 @@ in 3.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/v3.4.0...v3.4.1 +* 3.4.29 (2019-06-26) + + * bug #32137 [HttpFoundation] fix accessing session bags (xabbuh) + * bug #32164 [EventDispatcher] collect called listeners information only once (xabbuh) + * bug #32173 [FrameworkBundle] Fix calling Client::getProfile() before sending a request (dunglas) + * bug #32163 [DoctrineBridge] Fix type error (norkunas) + * bug #32170 [Security/Core] Don't use ParagonIE_Sodium_Compat (nicolas-grekas) + * bug #32123 [Form] fix translation domain (xabbuh) + * bug #32116 [FrameworkBundle] tag the FileType service as a form type (xabbuh) + * bug #32090 [Debug] workaround BC break in PHP 7.3 (nicolas-grekas) + * bug #32071 Fix expired lock not cleaned (jderusse) + * bug #32057 [HttpFoundation] Fix SA/phpdoc JsonResponse (ro0NL) + * bug #32025 SimpleCacheAdapter fails to cache any item if a namespace is used (moufmouf) + * bug #32037 [Form] validate composite constraints in all groups (xabbuh) + * bug #32007 [Serializer] Handle true and false appropriately in CSV encoder (battye) + * bug #32000 [Routing] fix absolute url generation when scheme is not known (Tobion) + * bug #32024 [VarDumper] fix dumping objects that implement __debugInfo() (nicolas-grekas) + * bug #31962 Fix reporting unsilenced deprecations from insulated tests (nicolas-grekas) + * bug #31865 [Form] Fix wrong DateTime on outdated ICU library (aweelex) + * bug #31863 [HttpFoundation] Fixed case-sensitive handling of cache-control header in RedirectResponse constructor (Ivo) + * bug #31869 Fix json-encoding when JSON_THROW_ON_ERROR is used (nicolas-grekas) + * bug #31860 [HttpFoundation] work around PHP 7.3 bug related to json_encode() (nicolas-grekas) + * bug #31407 [Security] added support for updated "distinguished name" format in x509 authentication (Robert Kopera) + * bug #31654 [HttpFoundation] Do not set X-Accel-Redirect for paths outside of X-Accel-Mapping (vilius-g) + * 3.4.28 (2019-05-28) * bug #31584 [Workflow] Do not trigger extra guards (lyrixx) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index fddccc428e7c9..011ad9bee0777 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -19,8 +19,8 @@ Symfony is the result of the work of many people who made the code better - Jakub Zalas (jakubzalas) - Johannes S (johannes) - Javier Eguiluz (javier.eguiluz) - - Kris Wallsmith (kriswallsmith) - Roland Franssen (ro0) + - Kris Wallsmith (kriswallsmith) - Grégoire Pineau (lyrixx) - Hugo Hamon (hhamon) - Abdellatif Ait boudad (aitboudad) @@ -31,9 +31,9 @@ Symfony is the result of the work of many people who made the code better - Joseph Bielawski (stloyd) - Karma Dordrak (drak) - Lukas Kahwe Smith (lsmith) + - Yonel Ceruto (yonelceruto) - Martin Hasoň (hason) - Jeremy Mikola (jmikola) - - Yonel Ceruto (yonelceruto) - Jean-François Simon (jfsimon) - Jules Pietri (heah) - Benjamin Eberlei (beberlei) @@ -45,35 +45,35 @@ Symfony is the result of the work of many people who made the code better - Jonathan Wage (jwage) - Tobias Nyholm (tobias) - Lynn van der Berg (kjarli) + - Jérémy DERUSSÉ (jderusse) - Diego Saint Esteben (dosten) - Alexandre Salomé (alexandresalome) - William Durand (couac) - ornicar - - Jérémy DERUSSÉ (jderusse) + - Alexander M. Turek (derrabus) - Dany Maillard (maidmaid) - Francis Besset (francisbesset) - stealth35 ‏ (stealth35) - Alexander Mols (asm89) - Matthias Pigulla (mpdude) - Bulat Shakirzyanov (avalanche123) - - Alexander M. Turek (derrabus) - Saša Stamenković (umpirsky) - Peter Rehm (rpet) - - Kevin Bond (kbond) - Pierre du Plessis (pierredup) + - Kevin Bond (kbond) - Henrik Bjørnskov (henrikbjorn) - Miha Vrhovnik - Diego Saint Esteben (dii3g0) + - Grégoire Paris (greg0ire) - Konstantin Kudryashov (everzet) - Gábor Egyed (1ed) - - Grégoire Paris (greg0ire) - - Bilal Amarni (bamarni) - Titouan Galopin (tgalopin) + - Konstantin Myakshin (koc) + - Bilal Amarni (bamarni) - Mathieu Piot (mpiot) - David Maicher (dmaicher) - Florin Patan (florinpatan) - Valentin Udaltsov (vudaltsov) - - Konstantin Myakshin (koc) - Gabriel Ostrolucký (gadelat) - Vladimir Reznichenko (kalessil) - Jáchym Toušek (enumag) @@ -95,12 +95,12 @@ Symfony is the result of the work of many people who made the code better - Luis Cordova (cordoval) - Graham Campbell (graham) - Daniel Holmes (dholmes) + - Thomas Calvet (fancyweb) - Toni Uebernickel (havvg) - Bart van den Burg (burgov) - Jordan Alliot (jalliot) - Jérôme Tamarelle (gromnan) - John Wards (johnwards) - - Thomas Calvet (fancyweb) - Fran Moreno (franmomu) - Antoine Hérault (herzult) - Paráda József (paradajozsef) @@ -120,6 +120,7 @@ Symfony is the result of the work of many people who made the code better - Peter Kokot (maastermedia) - Jacob Dreesen (jdreesen) - Florian Voutzinos (florianv) + - Jan Schädlich (jschaedl) - Colin Frei - Javier Spagnoletti (phansys) - Adrien Brault (adrienbrault) @@ -152,7 +153,6 @@ Symfony is the result of the work of many people who made the code better - Arnaud Kleinpeter (nanocom) - Jannik Zschiesche (apfelbox) - Guilherme Blanco (guilhermeblanco) - - Jan Schädlich (jschaedl) - SpacePossum - Pablo Godel (pgodel) - Jérémie Augustin (jaugustin) @@ -175,13 +175,17 @@ Symfony is the result of the work of many people who made the code better - Alessandro Chitolina (alekitto) - Hiromi Hishida (77web) - Matthieu Ouellette-Vachon (maoueh) + - Massimiliano Arione (garak) - Michał Pipa (michal.pipa) - Dawid Nowak + - George Mponos (gmponos) - Amal Raghav (kertz) - Jonathan Ingram (jonathaningram) - Artur Kotyrba - Tyson Andre - GDIBass + - Samuel NELA (snela) + - Vincent Touzet (vincenttouzet) - Alexander Schranz (alexander-schranz) - jeremyFreeAgent (Jérémy Romey) (jeremyfreeagent) - James Halsall (jaitsu) @@ -194,15 +198,12 @@ Symfony is the result of the work of many people who made the code better - Daniel Espendiller - Possum - Dorian Villet (gnutix) - - George Mponos (gmponos) - Sergey Linnik (linniksa) - Richard Miller (mr_r_miller) - Albert Casademont (acasademont) - Mario A. Alvarez Garcia (nomack84) - Dennis Benkert (denderello) - DQNEO - - Samuel NELA (snela) - - Vincent Touzet (vincenttouzet) - Gregor Harlan (gharlan) - Gary PEGEOT (gary-p) - Ruben Gonzalez (rubenrua) @@ -242,12 +243,12 @@ Symfony is the result of the work of many people who made the code better - Sven Paulus (subsven) - Maxime Veber (nek-) - Rui Marinho (ruimarinho) - - Massimiliano Arione (garak) - Eugene Wissner - Pascal Montoya - Julien Brochet (mewt) - Leo Feyer - Tristan Darricau (nicofuma) + - Victor Bocharsky (bocharsky_bw) - Marcel Beerta (mazen) - Pavel Batanov (scaytrase) - Mantis Development @@ -300,7 +301,6 @@ Symfony is the result of the work of many people who made the code better - Chekote - Antoine Makdessi (amakdessi) - Thomas Adam - - Viktor Bocharskyi (bocharsky_bw) - Jhonny Lidfors (jhonne) - Diego Agulló (aeoris) - jdhoek @@ -374,6 +374,7 @@ Symfony is the result of the work of many people who made the code better - Berny Cantos (xphere81) - Thierry Thuon (lepiaf) - Ricard Clau (ricardclau) + - dFayet - Mark Challoner (markchalloner) - Gennady Telegin (gtelegin) - Erin Millard @@ -438,6 +439,7 @@ Symfony is the result of the work of many people who made the code better - Joe Lencioni - Daniel Tschinder - vladimir.reznichenko + - Ruud Kamphuis (ruudk) - Kai - Lee Rowlands - Krzysztof Piasecki (krzysztek) @@ -458,6 +460,7 @@ Symfony is the result of the work of many people who made the code better - Karel Souffriau - Christophe L. (christophelau) - Anthon Pang (robocoder) + - Michael Käfer (michael_kaefer) - Sébastien Santoro (dereckson) - Brian King - Michel Salib (michelsalib) @@ -539,6 +542,7 @@ Symfony is the result of the work of many people who made the code better - Sergio Santoro - Robin van der Vleuten (robinvdvleuten) - Philipp Rieber (bicpi) + - Tomas Norkūnas (norkunas) - Manuel de Ruiter (manuel) - Eduardo Oliveira (entering) - Ilya Antipenko (aivus) @@ -563,6 +567,7 @@ Symfony is the result of the work of many people who made the code better - Jakub Škvára (jskvara) - Andrew Udvare (audvare) - alexpods + - Saif Eddin G - Adam Szaraniec (mimol) - Dariusz Ruminski - Erik Trapman (eriktrapman) @@ -597,7 +602,6 @@ Symfony is the result of the work of many people who made the code better - Martin Morávek (keeo) - Steven Surowiec - Kevin Saliou (kbsali) - - Ruud Kamphuis (ruudk) - Shawn Iwinski - Gawain Lynch (gawain) - NothingWeAre @@ -630,6 +634,7 @@ Symfony is the result of the work of many people who made the code better - Baptiste Leduc (bleduc) - Jean-Christophe Cuvelier [Artack] - Simon DELICATA + - Dmitry Simushev - alcaeus - Fred Cox - vitaliytv @@ -688,7 +693,6 @@ Symfony is the result of the work of many people who made the code better - Vincent Simonin - Alex Bogomazov (alebo) - maxime.steinhausser - - dFayet - adev - Stefan Warman - Arkadius Stefanski (arkadius) @@ -722,6 +726,7 @@ Symfony is the result of the work of many people who made the code better - Jaroslav Kuba - Stephan Vock - Benjamin Zikarsky (bzikarsky) + - battye - Simon Schick (simonsimcity) - redstar504 - Tristan Roussel @@ -763,10 +768,10 @@ Symfony is the result of the work of many people who made the code better - Arturas Smorgun (asarturas) - Alexander Volochnev (exelenz) - Michael Piecko + - Toni Peric (tperic) - yclian - Alan Poulain - Aleksey Prilipko - - Tomas Norkūnas (norkunas) - Andrew Berry - twifty - Indra Gunawan (guind) @@ -816,6 +821,7 @@ Symfony is the result of the work of many people who made the code better - John Bohn (jbohn) - Marc Morera (mmoreram) - Saif Eddin Gmati (azjezz) + - BENOIT POLASZEK (bpolaszek) - Andrew Hilobok (hilobok) - Noah Heck (myesain) - Christian Soronellas (theunic) @@ -837,6 +843,7 @@ Symfony is the result of the work of many people who made the code better - Olivier Maisonneuve (olineuve) - Pedro Miguel Maymone de Resende (pedroresende) - Masterklavi + - Franco Traversaro (belinde) - Francis Turmel (fturmel) - Nikita Nefedov (nikita2206) - cgonzalez @@ -851,6 +858,7 @@ Symfony is the result of the work of many people who made the code better - Antoine Lamirault - Adrien Lucas (adrienlucas) - Zhuravlev Alexander (scif) + - Stefano Degenkamp (steef) - James Michael DuPont - Tom Klingenberg - Christopher Hall (mythmakr) @@ -904,6 +912,7 @@ Symfony is the result of the work of many people who made the code better - Benoît Bourgeois - mantulo - Stefan Kruppa + - mmokhi - corphi - grizlik - Derek ROTH @@ -912,6 +921,7 @@ Symfony is the result of the work of many people who made the code better - Dmytro Boiko (eagle) - Shin Ohno (ganchiku) - Geert De Deckere (geertdd) + - Jacek Jędrzejewski (jacek.jedrzejewski) - Jan Kramer (jankramer) - abdul malik ikhsan (samsonasik) - Henry Snoek (snoek09) @@ -922,7 +932,6 @@ Symfony is the result of the work of many people who made the code better - Morgan Auchede (mauchede) - Sascha Dens (saschadens) - Don Pinkster - - Saif Eddin G - Maksim Muruev - Emil Einarsson - Thomas Landauer @@ -933,13 +942,14 @@ Symfony is the result of the work of many people who made the code better - Tony Tran - Jacques Moati - Balazs Csaba (balazscsaba2006) + - Bill Hance (billhance) - Douglas Reith (douglas_reith) - Forfarle (forfarle) - Harry Walter (haswalt) - Johnson Page (jwpage) - - Michael Käfer (michael_kaefer) - Ruben Gonzalez (rubenruateltek) - Michael Roterman (wtfzdotnet) + - Andrii Dembitskyi - Arno Geurts - Adán Lobato (adanlobato) - Ian Jenkins (jenkoian) @@ -986,7 +996,6 @@ Symfony is the result of the work of many people who made the code better - d-ph - Renan Taranto (renan-taranto) - Thomas Talbot (ioni) - - Dmitry Simushev - Rikijs Murgs - Uladzimir Tsykun - Ben Ramsey (ramsey) @@ -1132,7 +1141,6 @@ Symfony is the result of the work of many people who made the code better - hugofonseca (fonsecas72) - Martynas Narbutas - Toon Verwerft (veewee) - - battye - Bailey Parker - Eddie Jaoude - Antanas Arvasevicius @@ -1269,6 +1277,7 @@ Symfony is the result of the work of many people who made the code better - Pablo Schläpfer - Gert de Pagter - Jelte Steijaert (jelte) + - David Négrier (moufmouf) - Quique Porta (quiqueporta) - stoccc - Andrea Quintino (dirk39) @@ -1290,7 +1299,6 @@ Symfony is the result of the work of many people who made the code better - Lars Ambrosius Wallenborn (larsborn) - Oriol Mangas Abellan (oriolman) - Sebastian Göttschkes (sgoettschkes) - - Toni Peric (tperic) - Tatsuya Tsuruoka - Ross Tuck - Kévin Gomez (kevin) @@ -1324,7 +1332,6 @@ Symfony is the result of the work of many people who made the code better - Sébastien HOUZÉ - Jingyu Wang - steveYeah - - BENOIT POLASZEK (bpolaszek) - Samy Dindane (dinduks) - Keri Henare (kerihenare) - Cédric Lahouste (rapotor) @@ -1431,6 +1438,7 @@ Symfony is the result of the work of many people who made the code better - BilgeXA - r1pp3rj4ck - phydevs + - mmokhi - Robert Queck - Peter Bouwdewijn - mlively @@ -1455,6 +1463,7 @@ Symfony is the result of the work of many people who made the code better - Mike Meier - Tim Jabs - Sebastian Ionescu + - Robert Kopera - Pablo Ogando Ferreira - Thomas Ploch - Simon Neidhold @@ -1490,6 +1499,7 @@ Symfony is the result of the work of many people who made the code better - LubenZA - Olivier - Cyril PASCAL + - Michael Bessolov - pscheit - Wybren Koelmans - Zdeněk Drahoš @@ -1651,6 +1661,7 @@ Symfony is the result of the work of many people who made the code better - downace - Aarón Nieves Fernández - Mike Meier + - Vilius Grigaliūnas - Kirill Saksin - Julien Pauli - Koalabaerchen @@ -1698,6 +1709,7 @@ Symfony is the result of the work of many people who made the code better - Nicole Cordes - Martin Kirilov - amcastror + - Alexander Li (aweelex) - Bram Van der Sype (brammm) - Guile (guile) - Julien Moulin (lizjulien) @@ -1717,6 +1729,7 @@ Symfony is the result of the work of many people who made the code better - Sam Ward - Walther Lalk - Adam + - Ivo - Sören Bernstein - devel - taiiiraaa @@ -1751,7 +1764,6 @@ Symfony is the result of the work of many people who made the code better - Hans Nilsson (hansnilsson) - Andrew Marcinkevičius (ifdattic) - Ioana Hazsda (ioana-hazsda) - - Jacek Jędrzejewski (jacek.jedrzejewski) - Jan Marek (janmarek) - Mark de Haan (markdehaan) - Dan Patrick (mdpatrick) @@ -1760,6 +1772,7 @@ Symfony is the result of the work of many people who made the code better - tante kinast (tante) - Ahmed Hannachi (tiecoders) - Vincent LEFORT (vlefort) + - Walid BOUGHDIRI (walidboughdiri) - Darryl Hein (xmmedia) - Sadicov Vladimir (xtech) - Kevin EMO (zarcox) @@ -1774,6 +1787,7 @@ Symfony is the result of the work of many people who made the code better - Vincent Chalnot - James Hudson - Tom Maguire + - Mateusz Lerczak - Richard Quadling - David Zuelke - Adrian @@ -1948,6 +1962,7 @@ Symfony is the result of the work of many people who made the code better - Ulf Reimers (ureimers) - Wotre - goohib + - Chi-teck - Tom Counsell - Xavier HAUSHERR - Ron Gähler @@ -2007,6 +2022,7 @@ Symfony is the result of the work of many people who made the code better - Cédric Bertolini - n-aleha - Anatol Belski + - Anderson Müller - Şəhriyar İmanov - Alexis BOYER - Kaipi Yann @@ -2019,7 +2035,6 @@ Symfony is the result of the work of many people who made the code better - Tammy D - Daniel STANCU - Ryan Rud - - mmokhi - Ondrej Slinták - vlechemin - Brian Corrigan @@ -2110,10 +2125,10 @@ Symfony is the result of the work of many people who made the code better - Alex Olmos (alexolmos) - Antonio Mansilla (amansilla) - Robin Kanters (anddarerobin) + - Andrii Popov (andrii-popov) - Juan Ases García (ases) - Siragusa (asiragusa) - Daniel Basten (axhm3a) - - Bill Hance (billhance) - Bernd Matzner (bmatzner) - Bram Tweedegolf (bram_tweedegolf) - Brandon Kelly (brandonkelly) @@ -2150,6 +2165,7 @@ Symfony is the result of the work of many people who made the code better - Justin Rainbow (jrainbow) - Juan Luis (juanlugb) - JuntaTom (juntatom) + - Julien Manganne (juuuuuu) - Ismail Faizi (kanafghan) - Sébastien Armand (khepin) - Pierre-Chanel Gauthier (kmecnin) diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index fbe988fa3497f..5703b4a5a7408 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -297,19 +297,17 @@ Form `ArrayAccess` in `ResizeFormListener::preSubmit` method has been removed. * Using callable strings as choice options in ChoiceType is not supported - anymore in favor of passing PropertyPath instances. + anymore. Before: ```php - 'choice_value' => new PropertyPath('range'), 'choice_label' => 'strtoupper', ``` After: ```php - 'choice_value' => 'range', 'choice_label' => function ($choice) { return strtoupper($choice); }, diff --git a/composer.json b/composer.json index 6da4810c5c456..143f73d3c2f35 100644 --- a/composer.json +++ b/composer.json @@ -98,7 +98,7 @@ "ocramius/proxy-manager": "~0.4|~1.0|~2.0", "predis/predis": "~1.0", "egulias/email-validator": "~1.2,>=1.2.8|~2.0", - "symfony/phpunit-bridge": "~3.4|~4.0", + "symfony/phpunit-bridge": "~3.4|~4.0|~5.0", "symfony/security-acl": "~2.8|~3.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0" }, diff --git a/phpunit b/phpunit index 5bbbf0ded1863..dc9e127b78fb7 100755 --- a/phpunit +++ b/phpunit @@ -1,7 +1,7 @@ #!/usr/bin/env php $param) { if (isset($query['types'][$j])) { // Transform the param according to the type diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php index 3f6ffeebb6e2d..24da0b8deec02 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -58,7 +58,7 @@ public static function createTestConfiguration() $config = new Configuration(); $config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']); $config->setAutoGenerateProxyClasses(true); - $config->setProxyDir(\sys_get_temp_dir()); + $config->setProxyDir(sys_get_temp_dir()); $config->setProxyNamespace('SymfonyTests\Doctrine'); $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader())); $config->setQueryCacheImpl(new ArrayCache()); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 186610820c085..a789b7a9793fc 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -102,6 +102,18 @@ public function testCollectQueryWithNoParams() $this->assertTrue($collectedQueries['default'][1]['explainable']); } + public function testCollectQueryWithNoTypes() + { + $queries = [ + ['sql' => 'SET sql_mode=(SELECT REPLACE(@@sql_mode, \'ONLY_FULL_GROUP_BY\', \'\'))', 'params' => [], 'types' => null, 'executionMS' => 1], + ]; + $c = $this->createCollector($queries); + $c->collect(new Request(), new Response()); + + $collectedQueries = $c->getQueries(); + $this->assertSame([], $collectedQueries['default'][0]['types']); + } + public function testReset() { $queries = [ @@ -166,20 +178,20 @@ private function createCollector($queries) ->getMock(); $connection->expects($this->any()) ->method('getDatabasePlatform') - ->will($this->returnValue(new MySqlPlatform())); + ->willReturn(new MySqlPlatform()); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry ->expects($this->any()) ->method('getConnectionNames') - ->will($this->returnValue(['default' => 'doctrine.dbal.default_connection'])); + ->willReturn(['default' => 'doctrine.dbal.default_connection']); $registry ->expects($this->any()) ->method('getManagerNames') - ->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager'])); + ->willReturn(['default' => 'doctrine.orm.default_entity_manager']); $registry->expects($this->any()) ->method('getConnection') - ->will($this->returnValue($connection)); + ->willReturn($connection); $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock(); $logger->queries = $queries; diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 0f53d0952c14b..fb9becd072943 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -44,9 +44,9 @@ protected function setUp() $this->extension->expects($this->any()) ->method('getObjectManagerElementName') - ->will($this->returnCallback(function ($name) { + ->willReturnCallback(function ($name) { return 'doctrine.orm.'.$name; - })); + }); } /** diff --git a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php index 394b1b0dfe9a2..e376f0a422368 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php @@ -26,7 +26,7 @@ public function testFetch() $doctrineCacheMock->expects($this->once()) ->method('fetch') - ->will($this->returnValue('bar')); + ->willReturn('bar'); $result = $parserCache->fetch('foo'); @@ -41,7 +41,7 @@ public function testFetchUnexisting() $doctrineCacheMock ->expects($this->once()) ->method('fetch') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertNull($parserCache->fetch('')); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index c323385ff1929..d2e101b4cdc58 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -34,47 +34,47 @@ public function requiredProvider() // Simple field, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; - $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false)); + $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false); $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // Simple field, nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; - $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true); $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; // One-to-one, nullable (by default) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [[]]]; - $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); + $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, nullable (explicit) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => true]]]; - $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); + $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => false]]]; - $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); + $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // One-to-many, no clue $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false); $return[] = [$classMetadata, null]; @@ -84,10 +84,10 @@ public function requiredProvider() private function getGuesser(ClassMetadata $classMetadata) { $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); - $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata)); + $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); - $registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em])); + $registry->expects($this->once())->method('getManagers')->willReturn([$em]); return new DoctrineOrmTypeGuesser($registry); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index 5012171542f7b..5dc184fb91009 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -38,11 +38,11 @@ protected function getExtensions() $manager->expects($this->any()) ->method('getManager') - ->will($this->returnValue($this->em)); + ->willReturn($this->em); $manager->expects($this->any()) ->method('getManagerForClass') - ->will($this->returnValue($this->em)); + ->willReturn($this->em); return [ new CoreExtension(), diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 1cb59c38436ef..7a806d76cd7fa 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -1087,7 +1087,7 @@ public function testGetManagerForClassIfNoEm() $this->emRegistry->expects($this->once()) ->method('getManagerForClass') ->with(self::SINGLE_IDENT_CLASS) - ->will($this->returnValue($this->em)); + ->willReturn($this->em); $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'class' => self::SINGLE_IDENT_CLASS, @@ -1237,7 +1237,7 @@ protected function createRegistryMock($name, $em) $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) - ->will($this->returnValue($em)); + ->willReturn($em); return $registry; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 7188a3abc1a75..e88a0a715c391 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -188,7 +188,7 @@ private function getManager($em, $name = null) $manager->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) - ->will($this->returnValue($em)); + ->willReturn($em); return $manager; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 60007eb8a3ba8..24a7f555f4f67 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -82,7 +82,7 @@ protected function createRegistryMock(ObjectManager $em = null) $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo(self::EM_NAME)) - ->will($this->returnValue($em)); + ->willReturn($em); return $registry; } @@ -104,14 +104,14 @@ protected function createEntityManagerMock($repositoryMock) ; $em->expects($this->any()) ->method('getRepository') - ->will($this->returnValue($repositoryMock)) + ->willReturn($repositoryMock) ; $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock(); $classMetadata ->expects($this->any()) ->method('hasField') - ->will($this->returnValue(true)) + ->willReturn(true) ; $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') ->disableOriginalConstructor() @@ -125,12 +125,12 @@ protected function createEntityManagerMock($repositoryMock) $refl ->expects($this->any()) ->method('getValue') - ->will($this->returnValue(true)) + ->willReturn(true) ; $classMetadata->reflFields = ['name' => $refl]; $em->expects($this->any()) ->method('getClassMetadata') - ->will($this->returnValue($classMetadata)) + ->willReturn($classMetadata) ; return $em; @@ -366,7 +366,7 @@ public function testValidateUniquenessUsingCustomRepositoryMethod() $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); @@ -394,15 +394,15 @@ public function testValidateUniquenessWithUnrewoundArray() $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will( - $this->returnCallback(function () use ($entity) { + ->willReturnCallback( + function () use ($entity) { $returnValue = [ $entity, ]; next($returnValue); return $returnValue; - }) + } ) ; $this->em = $this->createEntityManagerMock($repository); @@ -430,7 +430,7 @@ public function testValidateResultTypes($entity1, $result) $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue($result)) + ->willReturn($result) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); @@ -564,7 +564,7 @@ public function testValidateUniquenessWithArrayValue() $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue([$entity1])) + ->willReturn([$entity1]) ; $this->em->persist($entity1); @@ -635,7 +635,7 @@ public function testValidateUniquenessOnNullResult() $repository = $this->createRepositoryMock(); $repository ->method('find') - ->will($this->returnValue(null)) + ->willReturn(null) ; $this->em = $this->createEntityManagerMock($repository); diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 47cb2bd730317..cf0ed8c962101 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -186,7 +186,7 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, return $this->formatValue($value, self::PRETTY_DATE); } - if (\method_exists($value, '__toString')) { + if (method_exists($value, '__toString')) { return (string) $value; } diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index 0f042a90ae862..45a32dea84da4 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -50,7 +50,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map $output ->expects($this->atLeastOnce()) ->method('getVerbosity') - ->will($this->returnValue($verbosity)) + ->willReturn($verbosity) ; $handler = new ConsoleHandler($output, true, $map); $this->assertSame($isHandling, $handler->isHandling(['level' => $level]), @@ -114,12 +114,12 @@ public function testVerbosityChanged() $output ->expects($this->at(0)) ->method('getVerbosity') - ->will($this->returnValue(OutputInterface::VERBOSITY_QUIET)) + ->willReturn(OutputInterface::VERBOSITY_QUIET) ; $output ->expects($this->at(1)) ->method('getVerbosity') - ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) + ->willReturn(OutputInterface::VERBOSITY_DEBUG) ; $handler = new ConsoleHandler($output); $this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]), @@ -144,7 +144,7 @@ public function testWritingAndFormatting() $output ->expects($this->any()) ->method('getVerbosity') - ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) + ->willReturn(OutputInterface::VERBOSITY_DEBUG) ; $output ->expects($this->once()) diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 4da83aa7d6d2c..a69ab75620364 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -95,10 +95,10 @@ private function createRequestEvent($additionalServerParameters = []) ->getMock(); $event->expects($this->any()) ->method('isMasterRequest') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); return [$event, $server]; } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 2c7391a00bbda..481a860aab132 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -284,7 +284,8 @@ public function endTest($test, $time) foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { $error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null)); if ($deprecation[0]) { - @trigger_error($error, E_USER_DEPRECATED); + // unsilenced on purpose + trigger_error($error, E_USER_DEPRECATED); } else { @trigger_error($error, E_USER_DEPRECATED); } diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit index c81dcd26bec5e..c0f4b782b64a9 100755 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit @@ -11,7 +11,7 @@ */ // Please update when phpunit needs to be reinstalled with fresh deps: -// Cache-Id-Version: 2018-11-20 15:30 UTC +// Cache-Id-Version: 2019-06-26 11:00 UTC error_reporting(-1); diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 7c12b7015e620..7acc1c65420b7 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -58,7 +58,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = $instantiation = 'return'; if ($definition->isShared()) { - $instantiation .= sprintf(' $this->%s[%s] =', \method_exists(ContainerBuilder::class, 'addClassResource') || ($definition->isPublic() && !$definition->isPrivate()) ? 'services' : 'privates', var_export($id, true)); + $instantiation .= sprintf(' $this->%s[%s] =', method_exists(ContainerBuilder::class, 'addClassResource') || ($definition->isPublic() && !$definition->isPrivate()) ? 'services' : 'privates', var_export($id, true)); } if (null === $factoryCode) { @@ -120,7 +120,7 @@ public function getProxyCode(Definition $definition) */ private static function getProxyManagerVersion() { - if (!\class_exists(Version::class)) { + if (!class_exists(Version::class)) { return '0.0.1'; } diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index f0822d4616422..5328c9ae1227d 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -103,7 +103,7 @@ public function getPrivatePublicDefinitions() [ (new Definition(__CLASS__)) ->setPublic(false), - \method_exists(ContainerBuilder::class, 'addClassResource') ? 'services' : 'privates', + method_exists(ContainerBuilder::class, 'addClassResource') ? 'services' : 'privates', ], [ (new Definition(__CLASS__)) diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 3b9e479da0791..2f4cc9cd870f7 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -70,7 +70,7 @@ public function testWithGlobals() $display = $tester->getDisplay(); - $this->assertContains(\json_encode($message), $display); + $this->assertContains(json_encode($message), $display); } public function testWithGlobalsJson() @@ -81,7 +81,7 @@ public function testWithGlobalsJson() $tester->execute(['--format' => 'json'], ['decorated' => true]); $display = $tester->getDisplay(); - $display = \json_decode($display, true); + $display = json_decode($display, true); $this->assertSame($globals, $display['globals']); } @@ -91,11 +91,11 @@ public function testWithFilter() $tester = $this->createCommandTester([]); $tester->execute(['--format' => 'json'], ['decorated' => false]); $display = $tester->getDisplay(); - $display1 = \json_decode($display, true); + $display1 = json_decode($display, true); $tester->execute(['filter' => 'date', '--format' => 'json'], ['decorated' => false]); $display = $tester->getDisplay(); - $display2 = \json_decode($display, true); + $display2 = json_decode($display, true); $this->assertNotSame($display1, $display2); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index 9fe36b40c9063..22084ec1ae616 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -62,7 +62,7 @@ public function testUnknownFragmentRenderer() protected function getFragmentHandler($return) { $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock(); - $strategy->expects($this->once())->method('getName')->will($this->returnValue('inline')); + $strategy->expects($this->once())->method('getName')->willReturn('inline'); $strategy->expects($this->once())->method('render')->will($return); $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') @@ -70,7 +70,7 @@ protected function getFragmentHandler($return) ->getMock() ; - $context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); + $context->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); return new FragmentHandler($context, [$strategy], false); } @@ -82,9 +82,9 @@ protected function renderTemplate(FragmentHandler $renderer, $template = '{{ ren $twig->addExtension(new HttpKernelExtension()); $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); - $loader->expects($this->any())->method('load')->will($this->returnValueMap([ + $loader->expects($this->any())->method('load')->willReturnMap([ ['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)], - ])); + ]); $twig->addRuntimeLoader($loader); return $twig->render('index'); diff --git a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php index 8476e89cab0ee..9c2d18b4a4d6e 100644 --- a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php +++ b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php @@ -84,7 +84,7 @@ public static function onUndefinedFunction($name) private static function onUndefined($name, $type, $component) { - if (\class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) { + if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) { throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 6473f97584f39..6c75b5ab14029 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -66,7 +66,7 @@ public function getKernel() */ public function getProfile() { - if (!$this->kernel->getContainer()->has('profiler')) { + if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 6b05612ff53d9..c18d278688193 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -185,6 +185,7 @@ protected function describeContainerParameter($parameter, array $options = []) private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; + $this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml index 5088554ff1947..c5bc8cf5dbae6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml @@ -93,6 +93,7 @@ The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0. + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php index 94b5432c3ab9b..c1b49c34f992c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php @@ -34,7 +34,7 @@ public function testFindAllTemplates() $kernel ->expects($this->once()) ->method('getBundles') - ->will($this->returnValue(['BaseBundle' => new BaseBundle()])) + ->willReturn(['BaseBundle' => new BaseBundle()]) ; $parser = new TemplateFilenameParser(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php index 30d0242663723..b63c746eb60ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php @@ -68,13 +68,13 @@ public function testWarmUp() $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue([$template])); + ->willReturn([$template]); $this->fileLocator ->expects($this->once()) ->method('locate') ->with($template->getPath()) - ->will($this->returnValue(\dirname($this->tmpDir).'/path/to/template.html.twig')); + ->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig'); $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); $warmer->warmUp($this->tmpDir); @@ -87,7 +87,7 @@ public function testWarmUpEmpty() $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue([])); + ->willReturn([]); $this->fileLocator ->expects($this->never()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php index 35a9e4ac0cb28..4790f271de3ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php @@ -82,7 +82,7 @@ private function getRouter() $router ->expects($this->any()) ->method('getRouteCollection') - ->will($this->returnValue($routeCollection)); + ->willReturn($routeCollection); return $router; } @@ -93,13 +93,13 @@ private function getKernel() $container ->expects($this->atLeastOnce()) ->method('has') - ->will($this->returnCallback(function ($id) { + ->willReturnCallback(function ($id) { if ('console.command_loader' === $id) { return false; } return true; - })) + }) ; $container ->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php index a04ef46a90f38..e0bc2de0eb9f4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php @@ -80,11 +80,11 @@ private function getRouter() $router ->expects($this->any()) ->method('getRouteCollection') - ->will($this->returnValue($routeCollection)); + ->willReturn($routeCollection); $router ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($requestContext)); + ->willReturn($requestContext); return $router; } @@ -95,9 +95,9 @@ private function getKernel() $container ->expects($this->atLeastOnce()) ->method('has') - ->will($this->returnCallback(function ($id) { + ->willReturnCallback(function ($id) { return 'console.command_loader' !== $id; - })) + }) ; $container ->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 622033e897d90..cfa6e3b8a877e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -136,26 +136,26 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $translator ->expects($this->any()) ->method('getFallbackLocales') - ->will($this->returnValue(['en'])); + ->willReturn(['en']); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor ->expects($this->any()) ->method('extract') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($extractedMessages) { $catalogue->add($extractedMessages); - }) + } ); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader ->expects($this->any()) ->method('read') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($loadedMessages) { $catalogue->add($loadedMessages); - }) + } ); if (null === $kernel) { @@ -173,23 +173,23 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnValueMap($returnValues)); + ->willReturnMap($returnValues); } $kernel ->expects($this->any()) ->method('getRootDir') - ->will($this->returnValue($this->translationDir)); + ->willReturn($this->translationDir); $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock())); + ->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()); $command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates'); @@ -214,23 +214,23 @@ public function testLegacyDebugCommand() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['translation.extractor', 1, $extractor], ['translation.reader', 1, $loader], ['translator', 1, $translator], ['kernel', 1, $kernel], - ])); + ]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($container)); + ->willReturn($container); $command = new TranslationDebugCommand(); $command->setContainer($container); @@ -250,7 +250,7 @@ private function getBundle($path) $bundle ->expects($this->any()) ->method('getPath') - ->will($this->returnValue($path)) + ->willReturn($path) ; return $bundle; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 87bc6c09e2eb9..7e487ff527113 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -114,36 +114,36 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $translator ->expects($this->any()) ->method('getFallbackLocales') - ->will($this->returnValue(['en'])); + ->willReturn(['en']); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor ->expects($this->any()) ->method('extract') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($extractedMessages) { foreach ($extractedMessages as $domain => $messages) { $catalogue->add($messages, $domain); } - }) + } ); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader ->expects($this->any()) ->method('read') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($loadedMessages) { $catalogue->add($loadedMessages); - }) + } ); $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); $writer ->expects($this->any()) ->method('getFormats') - ->will( - $this->returnValue(['xlf', 'yml', 'yaml']) + ->willReturn( + ['xlf', 'yml', 'yaml'] ); if (null === $kernel) { @@ -161,23 +161,23 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnValueMap($returnValues)); + ->willReturnMap($returnValues); } $kernel ->expects($this->any()) ->method('getRootDir') - ->will($this->returnValue($this->translationDir)); + ->willReturn($this->translationDir); $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock())); + ->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()); $command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates'); @@ -203,24 +203,24 @@ public function testLegacyUpdateCommand() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['translation.extractor', 1, $extractor], ['translation.reader', 1, $loader], ['translation.writer', 1, $writer], ['translator', 1, $translator], ['kernel', 1, $kernel], - ])); + ]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($container)); + ->willReturn($container); $command = new TranslationUpdateCommand(); $command->setContainer($container); @@ -240,7 +240,7 @@ private function getBundle($path) $bundle ->expects($this->any()) ->method('getPath') - ->will($this->returnValue($path)) + ->willReturn($path) ; return $bundle; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 8c25ef9672f45..fbc5a77339311 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -206,7 +206,7 @@ private function getKernel(array $bundles, $useDispatcher = false) ->expects($this->atLeastOnce()) ->method('get') ->with($this->equalTo('event_dispatcher')) - ->will($this->returnValue($dispatcher)); + ->willReturn($dispatcher); } $container @@ -226,12 +226,12 @@ private function getKernel(array $bundles, $useDispatcher = false) $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue($bundles)) + ->willReturn($bundles) ; $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($container)) + ->willReturn($container) ; return $kernel; @@ -243,9 +243,9 @@ private function createBundleMock(array $commands) $bundle ->expects($this->once()) ->method('registerCommands') - ->will($this->returnCallback(function (Application $application) use ($commands) { + ->willReturnCallback(function (Application $application) use ($commands) { $application->addCommands($commands); - })) + }) ; return $bundle; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php index 66729f5fa4ea0..91a72821e9539 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php @@ -156,13 +156,13 @@ private function createParser() $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnCallback(function ($bundle) use ($bundles) { + ->willReturnCallback(function ($bundle) use ($bundles) { if (!isset($bundles[$bundle])) { throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle)); } return $bundles[$bundle]; - })) + }) ; $bundles = [ @@ -175,7 +175,7 @@ private function createParser() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue($bundles)) + ->willReturn($bundles) ; return new ControllerNameParser($kernel); @@ -184,8 +184,8 @@ private function createParser() private function getBundle($namespace, $name) { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); - $bundle->expects($this->any())->method('getName')->will($this->returnValue($name)); - $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace)); + $bundle->expects($this->any())->method('getName')->willReturn($name); + $bundle->expects($this->any())->method('getNamespace')->willReturn($namespace); return $bundle; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php index 93ce1527ba238..6af19862e6e83 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -55,7 +55,7 @@ public function testGetControllerWithBundleNotation() $parser->expects($this->once()) ->method('parse') ->with($shortName) - ->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')) + ->willReturn('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction') ; $resolver = $this->createControllerResolver(null, null, $parser); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index e72c558b7edc4..da950ce0c8041 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -43,9 +43,9 @@ public function testForward() $requestStack->push($request); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat().'--'.$request->getLocale()); - })); + }); $container = new Container(); $container->set('request_stack', $requestStack); @@ -110,7 +110,7 @@ private function getContainerWithTokenStorage($token = null) $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $container = new Container(); $container->set('security.token_storage', $tokenStorage); @@ -137,7 +137,7 @@ public function testJsonWithSerializer() ->expects($this->once()) ->method('serialize') ->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS]) - ->will($this->returnValue('[]')); + ->willReturn('[]'); $container->set('serializer', $serializer); @@ -158,7 +158,7 @@ public function testJsonWithSerializerContextOverride() ->expects($this->once()) ->method('serialize') ->with([], 'json', ['json_encode_options' => 0, 'other' => 'context']) - ->will($this->returnValue('[]')); + ->willReturn('[]'); $container->set('serializer', $serializer); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 076912d6e2d68..4bd0212e6953d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -72,7 +72,7 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte ->expects($this->once()) ->method('generate') ->with($this->equalTo($route), $this->equalTo($expectedAttributes)) - ->will($this->returnValue($url)); + ->willReturn($url); $controller = new RedirectController($router); @@ -250,23 +250,23 @@ private function createRequestObject($scheme, $host, $port, $baseUrl, $queryStri $request ->expects($this->any()) ->method('getScheme') - ->will($this->returnValue($scheme)); + ->willReturn($scheme); $request ->expects($this->any()) ->method('getHost') - ->will($this->returnValue($host)); + ->willReturn($host); $request ->expects($this->any()) ->method('getPort') - ->will($this->returnValue($port)); + ->willReturn($port); $request ->expects($this->any()) ->method('getBaseUrl') - ->will($this->returnValue($baseUrl)); + ->willReturn($baseUrl); $request ->expects($this->any()) ->method('getQueryString') - ->will($this->returnValue($queryString)); + ->willReturn($queryString); return $request; } @@ -288,24 +288,24 @@ private function createLegacyRedirectController($httpPort = null, $httpsPort = n ->expects($this->once()) ->method('hasParameter') ->with($this->equalTo('request_listener.http_port')) - ->will($this->returnValue(true)); + ->willReturn(true); $container ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.http_port')) - ->will($this->returnValue($httpPort)); + ->willReturn($httpPort); } if (null !== $httpsPort) { $container ->expects($this->once()) ->method('hasParameter') ->with($this->equalTo('request_listener.https_port')) - ->will($this->returnValue(true)); + ->willReturn(true); $container ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.https_port')) - ->will($this->returnValue($httpsPort)); + ->willReturn($httpsPort); } $controller = new RedirectController(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index 497c112eedb5f..9dba1c05a2bcb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -49,9 +49,9 @@ public function testLegacyTwig() $twig->expects($this->once())->method('render')->willReturn('bar'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $container->expects($this->at(0))->method('has')->will($this->returnValue(false)); - $container->expects($this->at(1))->method('has')->will($this->returnValue(true)); - $container->expects($this->at(2))->method('get')->will($this->returnValue($twig)); + $container->expects($this->at(0))->method('has')->willReturn(false); + $container->expects($this->at(1))->method('has')->willReturn(true); + $container->expects($this->at(2))->method('get')->willReturn($twig); $controller = new TemplateController(); $controller->setContainer($container); @@ -69,7 +69,7 @@ public function testLegacyTemplating() $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->willReturn(true); - $container->expects($this->at(1))->method('get')->will($this->returnValue($templating)); + $container->expects($this->at(1))->method('get')->willReturn($templating); $controller = new TemplateController(); $controller->setContainer($container); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php index c5252c0d5892e..2768b59a1c3f5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php @@ -28,9 +28,9 @@ public function testProfilerIsDisabled($insulate) // enable the profiler for the next request $client->enableProfiler(); - $crawler = $client->request('GET', '/profiler'); - $profile = $client->getProfile(); - $this->assertInternalType('object', $profile); + $this->assertFalse($client->getProfile()); + $client->request('GET', '/profiler'); + $this->assertInternalType('object', $client->getProfile()); $client->request('GET', '/profiler'); $this->assertFalse($client->getProfile()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php index aad3d77949ba4..bf1b76cdc743c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php @@ -71,7 +71,7 @@ public function testFlash($config, $insulate) /** * See if two separate insulated clients can run without - * polluting eachother's session data. + * polluting each other's session data. * * @dataProvider getConfigs */ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 8309090809759..9fe45527cffe8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -248,7 +248,7 @@ private function getServiceContainer(RouteCollection $routes) $loader ->expects($this->any()) ->method('load') - ->will($this->returnValue($routes)) + ->willReturn($routes) ; $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock(); @@ -256,7 +256,7 @@ private function getServiceContainer(RouteCollection $routes) $sc ->expects($this->once()) ->method('get') - ->will($this->returnValue($loader)) + ->willReturn($loader) ; return $sc; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php index 73983e47ce363..1fae0526d5d1b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php @@ -67,7 +67,7 @@ public function testRenderResponseWithFrameworkEngine() $engine->expects($this->once()) ->method('renderResponse') ->with('template.php', ['foo' => 'bar']) - ->will($this->returnValue($response)); + ->willReturn($response); $container = $this->getContainerMock(['engine' => $engine]); $delegatingEngine = new DelegatingEngine($container, ['engine']); @@ -91,7 +91,7 @@ private function getEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } @@ -103,7 +103,7 @@ private function getFrameworkEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } @@ -117,7 +117,7 @@ private function getContainerMock($services) $container->expects($this->at($i++)) ->method('get') ->with($id) - ->will($this->returnValue($service)); + ->willReturn($service); } return $container; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php index d6c6b299ebc62..46a581b9442e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -47,7 +47,7 @@ public function testGetToken() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue('token')); + ->willReturn('token'); $this->assertSame('token', $this->globals->getToken()); } @@ -77,12 +77,12 @@ public function testGetUser($user, $expectedUser) $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $this->assertSame($expectedUser, $this->globals->getUser()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php index 3317b15d90914..c78b7e5b2910f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -27,7 +27,7 @@ public function testLocateATemplate() ->expects($this->once()) ->method('locate') ->with($template->getPath()) - ->will($this->returnValue('/path/to/template')) + ->willReturn('/path/to/template') ; $locator = new TemplateLocator($fileLocator); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 85e4917548db0..4460d2ac2b525 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -26,13 +26,13 @@ protected function setUp() $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnCallback(function ($bundle) { + ->willReturnCallback(function ($bundle) { if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) { return true; } throw new \InvalidArgumentException(); - })) + }) ; $this->parser = new TemplateNameParser($kernel); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index bd02809dc0173..f3684529f24c4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -31,7 +31,7 @@ public function testThatRenderLogsTime() $stopwatch->expects($this->once()) ->method('start') ->with('template.php (index.php)', 'template') - ->will($this->returnValue($stopwatchEvent)); + ->willReturn($stopwatchEvent); $stopwatchEvent->expects($this->once())->method('stop'); @@ -56,7 +56,7 @@ private function getTemplateNameParser() $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $templateNameParser->expects($this->any()) ->method('parse') - ->will($this->returnValue($templateReference)); + ->willReturn($templateReference); return $templateNameParser; } @@ -91,7 +91,7 @@ private function getLoader($storage) $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader->expects($this->once()) ->method('load') - ->will($this->returnValue($storage)); + ->willReturn($storage); return $loader; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index aff109368b234..9dfd861dbeac0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -147,7 +147,7 @@ public function testGetDefaultLocaleOmittingLocale() ->expects($this->once()) ->method('getParameter') ->with('kernel.default_locale') - ->will($this->returnValue('en')) + ->willReturn('en') ; $translator = new Translator($container, new MessageFormatter()); @@ -357,53 +357,53 @@ protected function getLoader() $loader ->expects($this->at(0)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr', [ + ->willReturn($this->getCatalogue('fr', [ 'foo' => 'foo (FR)', - ]))) + ])) ; $loader ->expects($this->at(1)) ->method('load') - ->will($this->returnValue($this->getCatalogue('en', [ + ->willReturn($this->getCatalogue('en', [ 'foo' => 'foo (EN)', 'bar' => 'bar (EN)', 'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)', - ]))) + ])) ; $loader ->expects($this->at(2)) ->method('load') - ->will($this->returnValue($this->getCatalogue('es', [ + ->willReturn($this->getCatalogue('es', [ 'foobar' => 'foobar (ES)', - ]))) + ])) ; $loader ->expects($this->at(3)) ->method('load') - ->will($this->returnValue($this->getCatalogue('pt-PT', [ + ->willReturn($this->getCatalogue('pt-PT', [ 'foobarfoo' => 'foobarfoo (PT-PT)', - ]))) + ])) ; $loader ->expects($this->at(4)) ->method('load') - ->will($this->returnValue($this->getCatalogue('pt_BR', [ + ->willReturn($this->getCatalogue('pt_BR', [ 'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)', - ]))) + ])) ; $loader ->expects($this->at(5)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr.UTF-8', [ + ->willReturn($this->getCatalogue('fr.UTF-8', [ 'foobarbaz' => 'foobarbaz (fr.UTF-8)', - ]))) + ])) ; $loader ->expects($this->at(6)) ->method('load') - ->will($this->returnValue($this->getCatalogue('sr@latin', [ + ->willReturn($this->getCatalogue('sr@latin', [ 'foobarbax' => 'foobarbax (sr@latin)', - ]))) + ])) ; return $loader; @@ -415,7 +415,7 @@ protected function getContainer($loader) $container ->expects($this->any()) ->method('get') - ->will($this->returnValue($loader)) + ->willReturn($loader) ; return $container; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php index 864bd3c3bab75..8afe604c3a46d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php @@ -68,7 +68,7 @@ public function testGetInstanceInvalidValidatorClass() $constraint ->expects($this->exactly(2)) ->method('validatedBy') - ->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name')); + ->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name'); $factory = new ConstraintValidatorFactory(new Container()); $factory->getInstance($constraint); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php index ca82e805c3cd1..9eb9a08177700 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php @@ -132,17 +132,17 @@ protected function callFactory($id, $config, $userProviderId, $defaultEntryPoint $factory ->expects($this->once()) ->method('createAuthProvider') - ->will($this->returnValue('auth_provider')) + ->willReturn('auth_provider') ; $factory ->expects($this->atLeastOnce()) ->method('getListenerId') - ->will($this->returnValue('abstract_listener')) + ->willReturn('abstract_listener') ; $factory ->expects($this->any()) ->method('getKey') - ->will($this->returnValue('abstract_factory')) + ->willReturn('abstract_factory') ; $container = new ContainerBuilder(); diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 57d313d87142c..6faf93306230c 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^5.5.9|>=7.0.8", "ext-xml": "*", + "symfony/config": "~3.4|~4.0", "symfony/security": "~3.4.15|~4.0.15|^4.1.4", "symfony/dependency-injection": "^3.4.3|^4.0.3", "symfony/http-kernel": "~3.4|~4.0", diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php index 1ca5015a49fcd..ae740e1ab2f20 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php @@ -44,7 +44,7 @@ public function testForwardRequestToConfiguredController() }), $this->equalTo(HttpKernelInterface::SUB_REQUEST) ) - ->will($this->returnValue($response)); + ->willReturn($response); $controller = new PreviewErrorController($kernel, $logicalControllerName); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index a73921a8c7687..906a0bc10806c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -24,7 +24,7 @@ public function testGetSourceContext() $locator ->expects($this->once()) ->method('locate') - ->will($this->returnValue(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')) + ->willReturn(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') ; $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace'); @@ -44,7 +44,7 @@ public function testExists() $locator ->expects($this->once()) ->method('locate') - ->will($this->returnValue($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')) + ->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') ; $loader = new FilesystemLoader($locator, $parser); @@ -61,7 +61,7 @@ public function testTwigErrorIfLocatorThrowsInvalid() ->expects($this->once()) ->method('parse') ->with('name.format.engine') - ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) + ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) ; $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); @@ -85,14 +85,14 @@ public function testTwigErrorIfLocatorReturnsFalse() ->expects($this->once()) ->method('parse') ->with('name.format.engine') - ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) + ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) ; $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') - ->will($this->returnValue(false)) + ->willReturn(false) ; $loader = new FilesystemLoader($locator, $parser); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 33a873dba88d7..b9092af3ebd0c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -18,13 +18,13 @@ class TemplateIteratorTest extends TestCase public function testGetIterator() { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); - $bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle')); - $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); + $bundle->expects($this->any())->method('getName')->willReturn('BarBundle'); + $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); - $kernel->expects($this->any())->method('getBundles')->will($this->returnValue([ + $kernel->expects($this->any())->method('getBundles')->willReturn([ $bundle, - ])); + ]); $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates'); $sorted = iterator_to_array($iterator); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index d798c03214556..8021451601b38 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -140,9 +140,7 @@ public function toolbarAction(Request $request, $token) throw new NotFoundHttpException('The profiler must be enabled.'); } - $session = $request->getSession(); - - if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { + if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } @@ -199,7 +197,7 @@ public function searchBarAction(Request $request) $this->cspHandler->disableCsp(); } - if (null === $session = $request->getSession()) { + if (!$request->hasSession()) { $ip = $method = $statusCode = @@ -209,6 +207,8 @@ public function searchBarAction(Request $request) $limit = $token = null; } else { + $session = $request->getSession(); + $ip = $request->query->get('ip', $session->get('_profiler_search_ip')); $method = $request->query->get('method', $session->get('_profiler_search_method')); $statusCode = $request->query->get('status_code', $session->get('_profiler_search_status_code')); @@ -308,7 +308,9 @@ public function searchAction(Request $request) $limit = $request->query->get('limit'); $token = $request->query->get('token'); - if (null !== $session = $request->getSession()) { + if ($request->hasSession()) { + $session = $request->getSession(); + $session->set('_profiler_search_ip', $ip); $session->set('_profiler_search_method', $method); $session->set('_profiler_search_status_code', $statusCode); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index a507d36cf08a6..a1e23041f8aac 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -97,11 +97,11 @@ public function testReturns404onTokenNotFound($withCsp) $profiler ->expects($this->exactly(2)) ->method('loadProfile') - ->will($this->returnCallback(function ($token) { + ->willReturnCallback(function ($token) { if ('found' == $token) { return new Profile($token); } - })) + }) ; $controller = $this->createController($profiler, $twig, $withCsp); @@ -149,7 +149,7 @@ public function testSearchResult($withCsp) $profiler ->expects($this->once()) ->method('find') - ->will($this->returnValue($tokens)); + ->willReturn($tokens); $request = Request::create('/_profiler/empty/search/results', 'GET', [ 'limit' => 2, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php index bbf96c3b2b344..acccc7cbfb6d2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php @@ -200,7 +200,7 @@ private function mockNonceGenerator($value) $generator->expects($this->any()) ->method('generate') - ->will($this->returnValue($value)); + ->willReturn($value); return $generator; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 1260886f8df13..f8255f3894de3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -244,7 +244,7 @@ public function testXDebugUrlHeader() ->expects($this->once()) ->method('generate') ->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL) - ->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx')) + ->willReturn('http://mydomain.com/_profiler/xxxxxxxx') ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); @@ -302,10 +302,10 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('isXmlHttpRequest') - ->will($this->returnValue($isXmlHttpRequest)); + ->willReturn($isXmlHttpRequest); $request->expects($this->any()) ->method('getRequestFormat') - ->will($this->returnValue($requestFormat)); + ->willReturn($requestFormat); $request->headers = new HeaderBag(); @@ -313,7 +313,7 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('getSession') - ->will($this->returnValue($session)); + ->willReturn($session); } return $request; @@ -324,7 +324,7 @@ protected function getTwigMock($render = 'WDT') $templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $templating->expects($this->any()) ->method('render') - ->will($this->returnValue($render)); + ->willReturn($render); return $templating; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 18d4cc44b4021..c6bc1cdba36ed 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -69,7 +69,7 @@ public function testGetNameValidTemplate() $this->profiler->expects($this->any()) ->method('has') ->withAnyParameters() - ->will($this->returnCallback([$this, 'profilerHasCallback'])); + ->willReturnCallback([$this, 'profilerHasCallback']); $this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo')); } @@ -83,7 +83,7 @@ public function testGetTemplates() $this->profiler->expects($this->any()) ->method('has') ->withAnyParameters() - ->will($this->returnCallback([$this, 'profileHasCollectorCallback'])); + ->willReturnCallback([$this, 'profileHasCollectorCallback']); $result = $this->templateManager->getTemplates(new ProfileDummy()); $this->assertArrayHasKey('foo', $result); @@ -124,14 +124,14 @@ protected function mockTwigEnvironment() $this->twigEnvironment->expects($this->any()) ->method('loadTemplate') - ->will($this->returnValue('loadedTemplate')); + ->willReturn('loadedTemplate'); if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) { $loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock(); } else { $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); } - $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader)); + $this->twigEnvironment->expects($this->any())->method('getLoader')->willReturn($loader); return $this->twigEnvironment; } diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index c6edc8de61a7d..d00cc76c2a943 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -89,7 +89,7 @@ public function testVersionStrategyGivesAbsoluteURL() private function getContext($basePath) { $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); - $context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath)); + $context->expects($this->any())->method('getBasePath')->willReturn($basePath); return $context; } diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index 9b71d45bf31d7..a68c59a1249c1 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -107,7 +107,7 @@ public function testWrongBaseUrl() private function getContext($secure) { $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); - $context->expects($this->any())->method('isSecure')->will($this->returnValue($secure)); + $context->expects($this->any())->method('isSecure')->willReturn($secure); return $context; } diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 98553353d8ce3..6c3bcc1663981 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -361,7 +361,8 @@ protected function doRequestInProcess($request) unlink($deprecationsFile); foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { if ($deprecation[0]) { - @trigger_error($deprecation[1], E_USER_DEPRECATED); + // unsilenced on purpose + trigger_error($deprecation[1], E_USER_DEPRECATED); } else { @trigger_error($deprecation[1], E_USER_DEPRECATED); } diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 099c97a4da9d4..0868c16d47cf8 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -25,6 +25,11 @@ */ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface, ResettableInterface { + /** + * @internal + */ + const NS_SEPARATOR = ':'; + use AbstractTrait; private static $apcuSupported; @@ -39,7 +44,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface */ protected function __construct($namespace = '', $defaultLifetime = 0) { - $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; + $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).static::NS_SEPARATOR; if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace)); } diff --git a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php index bdb62a4bb3809..d3d0ede648a8a 100644 --- a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php @@ -20,6 +20,11 @@ */ class SimpleCacheAdapter extends AbstractAdapter implements PruneableInterface { + /** + * @internal + */ + const NS_SEPARATOR = '_'; + use ProxyTrait; private $miss; diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php index 0d715e48d2232..23b401c54be55 100644 --- a/src/Symfony/Component/Cache/Simple/AbstractCache.php +++ b/src/Symfony/Component/Cache/Simple/AbstractCache.php @@ -23,6 +23,11 @@ */ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, ResettableInterface { + /** + * @internal + */ + const NS_SEPARATOR = ':'; + use AbstractTrait { deleteItems as private; AbstractTrait::deleteItem as delete; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index 010f68b973e35..3b42697fe1385 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -80,7 +80,7 @@ private function getPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(true)); + ->willReturn(true); return $pruneable; } @@ -97,7 +97,7 @@ private function getFailingPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(false)); + ->willReturn(false); return $pruneable; } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php index 84713416cdea5..d8470a2e7d5a6 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\SimpleCacheAdapter; +use Symfony\Component\Cache\Simple\ArrayCache; use Symfony\Component\Cache\Simple\FilesystemCache; /** @@ -27,4 +28,14 @@ public function createCachePool($defaultLifetime = 0) { return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime); } + + public function testValidCacheKeyWithNamespace() + { + $cache = new SimpleCacheAdapter(new ArrayCache(), 'some_namespace', 0); + $item = $cache->getItem('my_key'); + $item->set('someValue'); + $cache->save($item); + + $this->assertTrue($cache->getItem('my_key')->isHit(), 'Stored item is successfully retrieved.'); + } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index d0a1e5daf77be..488127cc950ad 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -173,7 +173,7 @@ private function getPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(true)); + ->willReturn(true); return $pruneable; } @@ -190,7 +190,7 @@ private function getFailingPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(false)); + ->willReturn(false); return $pruneable; } diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php index e6f7c7cc63229..aa77887919b74 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php @@ -78,7 +78,7 @@ private function getPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(true)); + ->willReturn(true); return $pruneable; } @@ -95,7 +95,7 @@ private function getFailingPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(false)); + ->willReturn(false); return $pruneable; } diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php index be576098e45eb..cd1f204139186 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php @@ -106,9 +106,9 @@ public function clear() { $this->deferred = []; if ($cleared = $this->versioningIsEnabled) { - $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5); + $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), static::NS_SEPARATOR, 5); try { - $cleared = $this->doSave(['@'.$this->namespace => $namespaceVersion], 0); + $cleared = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0); } catch (\Exception $e) { $cleared = false; } @@ -235,14 +235,14 @@ private function getId($key) CacheItem::validateKey($key); if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { - $this->namespaceVersion = '1:'; + $this->namespaceVersion = '1'.static::NS_SEPARATOR; try { - foreach ($this->doFetch(['@'.$this->namespace]) as $v) { + foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) { $this->namespaceVersion = $v; } - if ('1:' === $this->namespaceVersion) { - $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5); - $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0); + if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) { + $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), static::NS_SEPARATOR, 5); + $this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0); } } catch (\Exception $e) { } @@ -252,7 +252,7 @@ private function getId($key) return $this->namespace.$this->namespaceVersion.$key; } if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) { - $id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), ':', -(\strlen($this->namespaceVersion) + 22)); + $id = $this->namespace.$this->namespaceVersion.substr_replace(base64_encode(hash('sha256', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 22)); } return $id; diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index e96462abf7e53..ea996a217cf13 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -90,7 +90,7 @@ public function warmUp(array $values) if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { $value = serialize($value); } - } elseif (!\is_scalar($value)) { + } elseif (!is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); } diff --git a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php index 36c614fe65bc6..3cc02b2428486 100644 --- a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php @@ -136,7 +136,7 @@ protected function doSave(array $values, $lifetime) if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { $value = serialize($value); } - } elseif (!\is_scalar($value)) { + } elseif (!is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); } diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php index 6e2a6ba2229d7..6556962d1f15c 100644 --- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php @@ -35,12 +35,12 @@ public function testGetSetResolver() public function testSupports() { $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader1->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader1->expects($this->once())->method('supports')->willReturn(true); $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader1->expects($this->once())->method('supports')->will($this->returnValue(false)); + $loader1->expects($this->once())->method('supports')->willReturn(false); $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); } @@ -48,7 +48,7 @@ public function testSupports() public function testLoad() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader->expects($this->once())->method('supports')->willReturn(true); $loader->expects($this->once())->method('load'); $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); @@ -62,7 +62,7 @@ public function testLoad() public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->once())->method('supports')->will($this->returnValue(false)); + $loader->expects($this->once())->method('supports')->willReturn(false); $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php index 487dc43adc310..aabc2a600d8dd 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php @@ -32,7 +32,7 @@ public function testResolve() $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader->expects($this->once())->method('supports')->willReturn(true); $resolver = new LoaderResolver([$loader]); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index 30167e3836f85..0c6e3fc025d19 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -34,7 +34,7 @@ public function testResolve() $resolver->expects($this->once()) ->method('resolve') ->with('foo.xml') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -52,7 +52,7 @@ public function testResolveWhenResolverCannotFindLoader() $resolver->expects($this->once()) ->method('resolve') ->with('FOOBAR') - ->will($this->returnValue(false)); + ->willReturn(false); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -66,13 +66,13 @@ public function testImport() $resolvedLoader->expects($this->once()) ->method('load') ->with('foo') - ->will($this->returnValue('yes')); + ->willReturn('yes'); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -86,13 +86,13 @@ public function testImportWithType() $resolvedLoader->expects($this->once()) ->method('load') ->with('foo', 'bar') - ->will($this->returnValue('yes')); + ->willReturn('yes'); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo', 'bar') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $loader = new ProjectLoader1(); $loader->setResolver($resolver); diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 197b843d4b76c..f5a143800b27c 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -97,7 +97,9 @@ protected function describeApplication(Application $application, array $options */ private function writeData(array $data, array $options) { - $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0)); + $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; + + $this->write(json_encode($data, $flags)); } /** diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index b920d211aaa8f..181e82593db76 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -660,7 +660,7 @@ public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock(); $application->expects($this->once()) ->method('getNamespaces') - ->will($this->returnValue(['foo:sublong', 'bar:sub'])); + ->willReturn(['foo:sublong', 'bar:sub']); $this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); } @@ -804,7 +804,7 @@ public function testRenderExceptionLineBreaks() $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') - ->will($this->returnValue(120)); + ->willReturn(120); $application->register('foo')->setCode(function () { throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); }); diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index b3ce402209a8e..9a135d325590a 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -321,7 +321,7 @@ public function testRunReturnsIntegerExitCode() $command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock(); $command->expects($this->once()) ->method('execute') - ->will($this->returnValue('2.3')); + ->willReturn('2.3'); $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); } diff --git a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php index 56dd65f6b456f..f12566dedd655 100644 --- a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php @@ -21,7 +21,7 @@ protected function createStreamableInputInterfaceMock($stream = null, $interacti $mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock(); $mock->expects($this->any()) ->method('isInteractive') - ->will($this->returnValue($interactive)); + ->willReturn($interactive); if ($stream) { $mock->expects($this->any()) diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php index 826bc51dcd62b..ffb12b3421f9a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -114,7 +114,7 @@ private function getGenericMockHelper($name, HelperSet $helperset = null) $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock(); $mock_helper->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)); + ->willReturn($name); if ($helperset) { $mock_helper->expects($this->any()) diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 3c030e04983d9..53819e4be70ed 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -1068,7 +1068,7 @@ protected function createInputInterfaceMock($interactive = true) $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock->expects($this->any()) ->method('isInteractive') - ->will($this->returnValue($interactive)); + ->willReturn($interactive); return $mock; } diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index cf7a78c34ecda..6f621db95448a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -154,7 +154,7 @@ protected function createInputInterfaceMock($interactive = true) $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock->expects($this->any()) ->method('isInteractive') - ->will($this->returnValue($interactive)); + ->willReturn($interactive); return $mock; } diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index efeec4234e952..c99eb839b7f31 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -166,7 +166,7 @@ public function testObjectCastToString() } else { $dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']); } - $dummy->method('__toString')->will($this->returnValue('DUMMY')); + $dummy->method('__toString')->willReturn('DUMMY'); $this->getLogger()->warning($dummy); diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index b728b9b90fee2..9ceac9af162b0 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -168,7 +168,7 @@ public function loadClass($class) private function checkClass($class, $file = null) { - $exists = null === $file || \class_exists($class, false) || \interface_exists($class, false) || \trait_exists($class, false); + $exists = null === $file || class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); if (null !== $file && $class && '\\' === $class[0]) { $class = substr($class, 1); @@ -186,13 +186,13 @@ private function checkClass($class, $file = null) } $name = $refl->getName(); - if ($name !== $class && 0 === \strcasecmp($name, $class)) { + if ($name !== $class && 0 === strcasecmp($name, $class)) { throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name)); } $deprecations = $this->checkAnnotations($refl, $name); - if (isset(self::$php7Reserved[\strtolower($refl->getShortName())])) { + if (isset(self::$php7Reserved[strtolower($refl->getShortName())])) { $deprecations[] = sprintf('The "%s" class uses the reserved name "%s", it will break on PHP 7 and higher', $name, $refl->getShortName()); } @@ -223,23 +223,23 @@ public function checkAnnotations(\ReflectionClass $refl, $class) $deprecations = []; // Don't trigger deprecations for classes in the same vendor - if (2 > $len = 1 + (\strpos($class, '\\') ?: \strpos($class, '_'))) { + if (2 > $len = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) { $len = 0; $ns = ''; } else { - $ns = \str_replace('_', '\\', \substr($class, 0, $len)); + $ns = str_replace('_', '\\', substr($class, 0, $len)); } // Detect annotations on the class if (false !== $doc = $refl->getDocComment()) { foreach (['final', 'deprecated', 'internal'] as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { + if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; } } } - $parent = \get_parent_class($class); + $parent = get_parent_class($class); $parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent); if ($parent) { $parentAndOwnInterfaces[$parent] = $parent; @@ -254,22 +254,22 @@ public function checkAnnotations(\ReflectionClass $refl, $class) } // Detect if the parent is annotated - foreach ($parentAndOwnInterfaces + \class_uses($class, false) as $use) { + foreach ($parentAndOwnInterfaces + class_uses($class, false) as $use) { if (!isset(self::$checkedClasses[$use])) { $this->checkClass($use); } - if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) { + if (isset(self::$deprecated[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) { $type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait'); $verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses'); $deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]); } - if (isset(self::$internal[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) { + if (isset(self::$internal[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len)) { $deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class); } } - if (\trait_exists($class)) { + if (trait_exists($class)) { return $deprecations; } @@ -296,7 +296,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class) if (isset(self::$internalMethods[$class][$method->name])) { list($declaringClass, $message) = self::$internalMethods[$class][$method->name]; - if (\strncmp($ns, $declaringClass, $len)) { + if (strncmp($ns, $declaringClass, $len)) { $deprecations[] = sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class); } } @@ -307,7 +307,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class) } foreach (['final', 'internal'] as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { + if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { $message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message]; } diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index d871b91538c22..c7dc3279d73af 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -382,6 +382,11 @@ private function reRegister($prev) */ public function handleError($type, $message, $file, $line) { + // @deprecated to be removed in Symfony 5.0 + if (\PHP_VERSION_ID >= 70300 && $message && '"' === $message[0] && 0 === strpos($message, '"continue') && preg_match('/^"continue(?: \d++)?" targeting switch is equivalent to "break(?: \d++)?"\. Did you mean to use "continue(?: \d++)?"\?$/', $message)) { + $type = E_DEPRECATED; + } + // Level is the current error reporting level to manage silent error. $level = error_reporting(); $silenced = 0 === ($level & $type); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 15de37c7b7808..bb82c63328b19 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -234,7 +234,7 @@ public function testHandleError() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($warnArgCheck)) + ->willReturnCallback($warnArgCheck) ; $handler = ErrorHandler::register(); @@ -262,7 +262,7 @@ public function testHandleError() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler = ErrorHandler::register(); @@ -318,7 +318,7 @@ public function testHandleDeprecation() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler = new ErrorHandler(); @@ -349,7 +349,7 @@ public function testHandleException() $logger ->expects($this->exactly(2)) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler->setDefaultLogger($logger, E_ERROR); @@ -503,7 +503,7 @@ public function testHandleFatalError() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler->setDefaultLogger($logger, E_PARSE); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php index 5bcb1234223a9..c5ba149aebea2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php @@ -31,13 +31,13 @@ public function testThrowsException() $autowireException = new AutowiringFailedException('foo_service_id', 'An autowiring exception message'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([])); + ->willReturn([]); $container = new ContainerBuilder(); $container->register('foo_service_id'); @@ -60,18 +60,18 @@ public function testThrowExceptionIfServiceInlined() $autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([ + ->willReturn([ // a_service inlined into b_service 'a_service' => ['b_service'], // b_service inlined into c_service 'b_service' => ['c_service'], - ])); + ]); $container = new ContainerBuilder(); // ONLY register c_service in the final container @@ -95,18 +95,18 @@ public function testDoNotThrowExceptionIfServiceInlinedButRemoved() $autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([ + ->willReturn([ // a_service inlined into b_service 'a_service' => ['b_service'], // b_service inlined into c_service 'b_service' => ['c_service'], - ])); + ]); // do NOT register c_service in the container $container = new ContainerBuilder(); @@ -126,13 +126,13 @@ public function testNoExceptionIfServiceRemoved() $autowireException = new AutowiringFailedException('non_existent_service'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([])); + ->willReturn([]); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index 667ae388648ae..1bef795f2b523 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -30,18 +30,18 @@ public function testExpressionLanguageProviderForwarding() $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension->expects($this->any()) ->method('getXsdValidationBasePath') - ->will($this->returnValue(false)); + ->willReturn(false); $extension->expects($this->any()) ->method('getNamespace') - ->will($this->returnValue('http://example.org/schema/dic/foo')); + ->willReturn('http://example.org/schema/dic/foo'); $extension->expects($this->any()) ->method('getAlias') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $extension->expects($this->once()) ->method('load') - ->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { + ->willReturnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { $tmpProviders = $container->getExpressionLanguageProviders(); - })); + }); $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock(); $container = new ContainerBuilder(new ParameterBag()); @@ -76,7 +76,7 @@ public function testExtensionConfigurationIsTrackedByDefault() $extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock(); $extension->expects($this->exactly(2)) ->method('getConfiguration') - ->will($this->returnValue(new FooConfiguration())); + ->willReturn(new FooConfiguration()); $container = new ContainerBuilder(new ParameterBag()); $container->registerExtension($extension); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php index fc2d85ecf9560..eb5fc5a99d2e1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php @@ -67,10 +67,10 @@ public function isFreshProvider() [$this->equalTo('locales')], [$this->equalTo('default_locale')] ) - ->will($this->returnValueMap([ + ->willReturnMap([ ['locales', ['fr', 'en']], ['default_locale', 'fr'], - ])) + ]) ; }, true]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 73cb670cdb121..b3bea30b749b9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -1059,7 +1059,7 @@ public function testExtension() public function testRegisteredButNotLoadedExtension() { $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); - $extension->expects($this->once())->method('getAlias')->will($this->returnValue('project')); + $extension->expects($this->once())->method('getAlias')->willReturn('project'); $extension->expects($this->never())->method('load'); $container = new ContainerBuilder(); @@ -1071,7 +1071,7 @@ public function testRegisteredButNotLoadedExtension() public function testRegisteredAndLoadedExtension() { $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); - $extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project')); + $extension->expects($this->exactly(2))->method('getAlias')->willReturn('project'); $extension->expects($this->once())->method('load')->with([['foo' => 'bar']]); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 2778fd075e3a5..2c0ee22c1fc45 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -862,13 +862,13 @@ protected function getFormFieldMock($name, $value = null) $field ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) + ->willReturn($name) ; $field ->expects($this->any()) ->method('getValue') - ->will($this->returnValue($value)) + ->willReturn($value) ; return $field; diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php index 7137d83b36f3f..97ae5090c9730 100644 --- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php +++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php @@ -209,7 +209,7 @@ public function testLoadDirectory() $dotenv->load(__DIR__); } - public function testServerSuperglobalIsNotOverriden() + public function testServerSuperglobalIsNotOverridden() { $originalValue = $_SERVER['argc']; @@ -219,7 +219,7 @@ public function testServerSuperglobalIsNotOverriden() $this->assertSame($originalValue, $_SERVER['argc']); } - public function testEnvVarIsNotOverriden() + public function testEnvVarIsNotOverridden() { putenv('TEST_ENV_VAR=original_value'); $_SERVER['TEST_ENV_VAR'] = 'original_value'; @@ -230,7 +230,7 @@ public function testEnvVarIsNotOverriden() $this->assertSame('original_value', getenv('TEST_ENV_VAR')); } - public function testHttpVarIsPartiallyOverriden() + public function testHttpVarIsPartiallyOverridden() { $_SERVER['HTTP_TEST_ENV_VAR'] = 'http_value'; diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index 752c8aa8293e6..017459723d92d 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -191,21 +191,18 @@ public function getNotCalledListeners() return []; } + $calledListeners = []; + + if (null !== $this->callStack) { + foreach ($this->callStack as $calledListener) { + $calledListeners[] = $calledListener->getWrappedListener(); + } + } + $notCalled = []; foreach ($allListeners as $eventName => $listeners) { foreach ($listeners as $listener) { - $called = false; - if (null !== $this->callStack) { - foreach ($this->callStack as $calledListener) { - if ($calledListener->getWrappedListener() === $listener) { - $called = true; - - break; - } - } - } - - if (!$called) { + if (!\in_array($listener, $calledListeners, true)) { if (!$listener instanceof WrappedListener) { $listener = new WrappedListener($listener, null, $this->stopwatch, $this); } diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index 04f2861e33193..c52fefe509ae9 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php @@ -43,7 +43,7 @@ public function testDispatchDelegates() $this->innerDispatcher->expects($this->once()) ->method('dispatch') ->with('event', $event) - ->will($this->returnValue('result')); + ->willReturn('result'); $this->assertSame('result', $this->dispatcher->dispatch('event', $event)); } @@ -53,7 +53,7 @@ public function testGetListenersDelegates() $this->innerDispatcher->expects($this->once()) ->method('getListeners') ->with('event') - ->will($this->returnValue('result')); + ->willReturn('result'); $this->assertSame('result', $this->dispatcher->getListeners('event')); } @@ -63,7 +63,7 @@ public function testHasListenersDelegates() $this->innerDispatcher->expects($this->once()) ->method('hasListeners') ->with('event') - ->will($this->returnValue('result')); + ->willReturn('result'); $this->assertSame('result', $this->dispatcher->hasListeners('event')); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index d2a660286da14..83b608b2b9956 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -36,18 +36,18 @@ public function testCachedParse() $cacheItemMock ->expects($this->exactly(2)) ->method('get') - ->will($this->returnCallback(function () use (&$savedParsedExpression) { + ->willReturnCallback(function () use (&$savedParsedExpression) { return $savedParsedExpression; - })) + }) ; $cacheItemMock ->expects($this->exactly(1)) ->method('set') ->with($this->isInstanceOf(ParsedExpression::class)) - ->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) { $savedParsedExpression = $parsedExpression; - })) + }) ; $cacheMock @@ -85,9 +85,9 @@ public function testCachedParseWithDeprecatedParserCacheInterface() ->expects($this->exactly(1)) ->method('save') ->with('1%20%2B%201%2F%2F', $this->isInstanceOf(ParsedExpression::class)) - ->will($this->returnCallback(function ($key, $expression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($key, $expression) use (&$savedParsedExpression) { $savedParsedExpression = $expression; - })) + }) ; $parsedExpression = $expressionLanguage->parse('1 + 1', []); @@ -213,18 +213,18 @@ public function testCachingWithDifferentNamesOrder() $cacheItemMock ->expects($this->exactly(2)) ->method('get') - ->will($this->returnCallback(function () use (&$savedParsedExpression) { + ->willReturnCallback(function () use (&$savedParsedExpression) { return $savedParsedExpression; - })) + }) ; $cacheItemMock ->expects($this->exactly(1)) ->method('set') ->with($this->isInstanceOf(ParsedExpression::class)) - ->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) { $savedParsedExpression = $parsedExpression; - })) + }) ; $cacheMock diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 3c61fc15048fe..a6e372ebf15a3 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -746,16 +746,16 @@ private function getSchemeAndHierarchy($filename) private static function box($func) { self::$lastError = null; - \set_error_handler(__CLASS__.'::handleError'); + set_error_handler(__CLASS__.'::handleError'); try { $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1)); - \restore_error_handler(); + restore_error_handler(); return $result; } catch (\Throwable $e) { } catch (\Exception $e) { } - \restore_error_handler(); + restore_error_handler(); throw $e; } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 8f2bde2e36eeb..186b2ef3642d5 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1348,6 +1348,22 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption() $this->assertFileNotExists($targetPath.'target'); } + public function testMirrorFromSubdirectoryInToParentDirectory() + { + $targetPath = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR; + $sourcePath = $targetPath.'bar'.\DIRECTORY_SEPARATOR; + $file1 = $sourcePath.'file1'; + $file2 = $sourcePath.'file2'; + + $this->filesystem->mkdir($sourcePath); + file_put_contents($file1, 'FILE1'); + file_put_contents($file2, 'FILE2'); + + $this->filesystem->mirror($sourcePath, $targetPath); + + $this->assertFileEquals($file1, $targetPath.'file1'); + } + /** * @dataProvider providePathsForIsAbsolutePath */ diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php index b26f7ba6bdd28..181b1464fcd9a 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php @@ -26,9 +26,9 @@ public function testFilterFilesystemIterators() $i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', [$i]); $i->expects($this->any()) ->method('accept') - ->will($this->returnCallback(function () use ($i) { + ->willReturnCallback(function () use ($i) { return (bool) preg_match('/\.php/', (string) $i->current()); - }) + } ); $c = 0; diff --git a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php index ab518dbfeed12..428586965ba64 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php @@ -82,6 +82,7 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; + $this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 36c19970f280c..6ca20106fa399 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -162,11 +162,8 @@ protected function getIntlDateFormatter($ignoreTimezone = false) { $dateFormat = $this->dateFormat; $timeFormat = $this->timeFormat; - $timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone; - if (class_exists('IntlTimeZone', false)) { - // see https://bugs.php.net/bug.php?id=66323 - $timezone = \IntlTimeZone::createTimeZone($timezone); - } + $timezone = new \DateTimeZone($ignoreTimezone ? 'UTC' : $this->outputTimezone); + $calendar = $this->calendar; $pattern = $this->pattern; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php index 841bd0d85f32f..acb8d02b8c5a9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php @@ -21,7 +21,7 @@ class BirthdayType extends AbstractType */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefault('years', range(date('Y') - 120, date('Y'))); + $resolver->setDefault('years', range((int) date('Y') - 120, date('Y'))); $resolver->setAllowedTypes('years', 'array'); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 09f5e1de5c872..8ab5e9cc8a57b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -256,7 +256,7 @@ public function configureOptions(OptionsResolver $resolver) }; $resolver->setDefaults([ - 'years' => range(date('Y') - 5, date('Y') + 5), + 'years' => range((int) date('Y') - 5, (int) date('Y') + 5), 'months' => range(1, 12), 'days' => range(1, 31), 'widget' => 'choice', diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index f8afce2ee5a4d..86f161307ba2b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -159,7 +159,7 @@ private function getFileUploadError($errorCode) } if (null !== $this->translator) { - $message = $this->translator->trans($messageTemplate, $messageParameters); + $message = $this->translator->trans($messageTemplate, $messageParameters, 'validators'); } else { $message = strtr($messageTemplate, $messageParameters); } diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 14adf123ec414..9e167c82155c9 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\Composite; use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintValidator; @@ -90,7 +91,9 @@ public function validate($form, Constraint $formConstraint) $validator->atPath('data')->validate($form->getData(), $constraint, $group); // Prevent duplicate validation - continue 2; + if (!$constraint instanceof Composite) { + continue 2; + } } } } diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 5f417d6d90901..3e8d632d939a0 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -89,7 +89,7 @@ class Form implements \IteratorAggregate, FormInterface private $submitted = false; /** - * @var ClickableInterface|null The button that was used to submit the form + * @var FormInterface|ClickableInterface|null The button that was used to submit the form */ private $clickedButton; @@ -749,7 +749,7 @@ public function isValid() /** * Returns the button that was used to submit the form. * - * @return ClickableInterface|null + * @return FormInterface|ClickableInterface|null */ public function getClickedButton() { diff --git a/src/Symfony/Component/Form/Resources/translations/validators.tr.xlf b/src/Symfony/Component/Form/Resources/translations/validators.tr.xlf new file mode 100644 index 0000000000000..70e8541ed909c --- /dev/null +++ b/src/Symfony/Component/Form/Resources/translations/validators.tr.xlf @@ -0,0 +1,19 @@ + + + + + + This form should not contain extra fields. + Form ekstra alanlar içeremez. + + + The uploaded file was too large. Please try to upload a smaller file. + Yüklenen dosya boyutu çok yüksek. Lütfen daha küçük bir dosya yüklemeyi deneyin. + + + The CSRF token is invalid. Please try to resubmit the form. + CSRF fişi geçersiz. Formu tekrar göndermeyi deneyin. + + + + diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index ab8444974959d..fe0d3e6629b26 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -473,7 +473,7 @@ public function testCsrf() { $this->csrfTokenManager->expects($this->any()) ->method('getToken') - ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); + ->willReturn(new CsrfToken('token_id', 'foo&bar')); $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index b470769344bb2..f2ee71b3424cd 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -312,10 +312,10 @@ public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $ { $this->serverParams->expects($this->once()) ->method('getContentLength') - ->will($this->returnValue($contentLength)); + ->willReturn($contentLength); $this->serverParams->expects($this->any()) ->method('getNormalizedIniPostMaxSize') - ->will($this->returnValue($iniMax)); + ->willReturn($iniMax); $options = ['post_max_size_message' => 'Max {{ max }}!']; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options); diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index 6c09ba8ead456..7cc68bd83d268 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -339,7 +339,7 @@ public function testCsrf() { $this->csrfTokenManager->expects($this->any()) ->method('getToken') - ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); + ->willReturn(new CsrfToken('token_id', 'foo&bar')); $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index ca5b67c817f2e..7277d49780d65 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -42,7 +42,7 @@ public function testCreateFromChoicesEmpty() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with([]) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices([])); $this->assertSame($list, $this->factory->createListFromChoices([])); @@ -58,7 +58,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices2) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices($choices1)); $this->assertSame($list, $this->factory->createListFromChoices($choices2)); @@ -74,11 +74,11 @@ public function testCreateFromChoicesGroupedChoices() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') ->with($choices1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromChoices') ->with($choices2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromChoices($choices1)); $this->assertSame($list2, $this->factory->createListFromChoices($choices2)); @@ -96,7 +96,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2) $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices1) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices($choices1)); $this->assertSame($list, $this->factory->createListFromChoices($choices2)); @@ -115,11 +115,11 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2) $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') ->with($choices1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromChoices') ->with($choices2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromChoices($choices1)); $this->assertSame($list2, $this->factory->createListFromChoices($choices2)); @@ -134,7 +134,7 @@ public function testCreateFromChoicesSameValueClosure() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $closure) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); @@ -151,11 +151,11 @@ public function testCreateFromChoicesDifferentValueClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') ->with($choices, $closure1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromChoices') ->with($choices, $closure2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1)); $this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2)); @@ -169,7 +169,7 @@ public function testCreateFromLoaderSameLoader() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromLoader($loader)); $this->assertSame($list, $this->factory->createListFromLoader($loader)); @@ -185,11 +185,11 @@ public function testCreateFromLoaderDifferentLoader() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromLoader') ->with($loader1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromLoader') ->with($loader2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromLoader($loader1)); $this->assertSame($list2, $this->factory->createListFromLoader($loader2)); @@ -204,7 +204,7 @@ public function testCreateFromLoaderSameValueClosure() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $closure) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); @@ -221,11 +221,11 @@ public function testCreateFromLoaderDifferentValueClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromLoader') ->with($loader, $closure1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromLoader') ->with($loader, $closure2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1)); $this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2)); @@ -240,7 +240,7 @@ public function testCreateViewSamePreferredChoices() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $preferred) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred)); @@ -257,11 +257,11 @@ public function testCreateViewDifferentPreferredChoices() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, $preferred1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, $preferred2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, $preferred1)); $this->assertSame($view2, $this->factory->createView($list, $preferred2)); @@ -276,7 +276,7 @@ public function testCreateViewSamePreferredChoicesClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $preferred) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred)); @@ -293,11 +293,11 @@ public function testCreateViewDifferentPreferredChoicesClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, $preferred1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, $preferred2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, $preferred1)); $this->assertSame($view2, $this->factory->createView($list, $preferred2)); @@ -312,7 +312,7 @@ public function testCreateViewSameLabelClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, $labels) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, $labels)); $this->assertSame($view, $this->factory->createView($list, null, $labels)); @@ -329,11 +329,11 @@ public function testCreateViewDifferentLabelClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, $labels1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, $labels2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, $labels1)); $this->assertSame($view2, $this->factory->createView($list, null, $labels2)); @@ -348,7 +348,7 @@ public function testCreateViewSameIndexClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, $index) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, $index)); $this->assertSame($view, $this->factory->createView($list, null, null, $index)); @@ -365,11 +365,11 @@ public function testCreateViewDifferentIndexClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, $index1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, $index2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, $index1)); $this->assertSame($view2, $this->factory->createView($list, null, null, $index2)); @@ -384,7 +384,7 @@ public function testCreateViewSameGroupByClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $groupBy) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); @@ -401,11 +401,11 @@ public function testCreateViewDifferentGroupByClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, null, $groupBy1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, null, $groupBy2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, null, $groupBy1)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy2)); @@ -420,7 +420,7 @@ public function testCreateViewSameAttributes() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $attr) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); @@ -437,11 +437,11 @@ public function testCreateViewDifferentAttributes() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, null, null, $attr1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, null, null, $attr2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); @@ -456,7 +456,7 @@ public function testCreateViewSameAttributesClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $attr) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); @@ -473,11 +473,11 @@ public function testCreateViewDifferentAttributesClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, null, null, $attr1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, null, null, $attr2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 1b943e81c1ec9..42893696db622 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -43,9 +43,9 @@ public function testCreateFromChoicesPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($choices, $callback) { + ->willReturnCallback(function ($choices, $callback) { return array_map($callback, $choices); - })); + }); $this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property')); } @@ -57,9 +57,9 @@ public function testCreateFromChoicesPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($choices, $callback) { + ->willReturnCallback(function ($choices, $callback) { return array_map($callback, $choices); - })); + }); $this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))); } @@ -86,9 +86,9 @@ public function testCreateFromLoaderPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($loader, $callback) { + ->willReturnCallback(function ($loader, $callback) { return $callback((object) ['property' => 'value']); - })); + }); $this->assertSame('value', $this->factory->createListFromLoader($loader, 'property')); } @@ -116,9 +116,9 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($choices, $callback) { + ->willReturnCallback(function ($choices, $callback) { return array_map($callback, $choices); - })); + }); $this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')); } @@ -131,9 +131,9 @@ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadabl $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($loader, $callback) { + ->willReturnCallback(function ($loader, $callback) { return $callback(null); - })); + }); $this->assertNull($this->factory->createListFromLoader($loader, 'property')); } @@ -145,9 +145,9 @@ public function testCreateFromLoaderPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($loader, $callback) { + ->willReturnCallback(function ($loader, $callback) { return $callback((object) ['property' => 'value']); - })); + }); $this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property'))); } @@ -159,9 +159,9 @@ public function testCreateViewPreferredChoicesAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred) { + ->willReturnCallback(function ($list, $preferred) { return $preferred((object) ['property' => true]); - })); + }); $this->assertTrue($this->factory->createView( $list, @@ -194,9 +194,9 @@ public function testCreateViewPreferredChoicesAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred) { + ->willReturnCallback(function ($list, $preferred) { return $preferred((object) ['property' => true]); - })); + }); $this->assertTrue($this->factory->createView( $list, @@ -212,9 +212,9 @@ public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred) { + ->willReturnCallback(function ($list, $preferred) { return $preferred((object) ['category' => null]); - })); + }); $this->assertFalse($this->factory->createView( $list, @@ -229,9 +229,9 @@ public function testCreateViewLabelsAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label) { + ->willReturnCallback(function ($list, $preferred, $label) { return $label((object) ['property' => 'label']); - })); + }); $this->assertSame('label', $this->factory->createView( $list, @@ -266,9 +266,9 @@ public function testCreateViewLabelsAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label) { + ->willReturnCallback(function ($list, $preferred, $label) { return $label((object) ['property' => 'label']); - })); + }); $this->assertSame('label', $this->factory->createView( $list, @@ -284,9 +284,9 @@ public function testCreateViewIndicesAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index) { + ->willReturnCallback(function ($list, $preferred, $label, $index) { return $index((object) ['property' => 'index']); - })); + }); $this->assertSame('index', $this->factory->createView( $list, @@ -323,9 +323,9 @@ public function testCreateViewIndicesAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index) { + ->willReturnCallback(function ($list, $preferred, $label, $index) { return $index((object) ['property' => 'index']); - })); + }); $this->assertSame('index', $this->factory->createView( $list, @@ -342,9 +342,9 @@ public function testCreateViewGroupsAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { return $groupBy((object) ['property' => 'group']); - })); + }); $this->assertSame('group', $this->factory->createView( $list, @@ -383,9 +383,9 @@ public function testCreateViewGroupsAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { return $groupBy((object) ['property' => 'group']); - })); + }); $this->assertSame('group', $this->factory->createView( $list, @@ -404,9 +404,9 @@ public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { return $groupBy((object) ['group' => null]); - })); + }); $this->assertNull($this->factory->createView( $list, @@ -424,9 +424,9 @@ public function testCreateViewAttrAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { return $attr((object) ['property' => 'attr']); - })); + }); $this->assertSame('attr', $this->factory->createView( $list, @@ -467,9 +467,9 @@ public function testCreateViewAttrAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { return $attr((object) ['property' => 'attr']); - })); + }); $this->assertSame('attr', $this->factory->createView( $list, diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 60795c4aae1d5..6854c43ef733f 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -50,12 +50,12 @@ public function testGetChoiceLoadersLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getChoices') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getChoices()); $this->assertSame('RESULT', $this->list->getChoices()); @@ -79,7 +79,7 @@ public function testGetChoicesUsesLoadedListWhenLoaderDoesNotCacheChoiceListOnFi // The same list is returned by the lazy choice list $this->loadedList->expects($this->exactly(2)) ->method('getChoices') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getChoices()); $this->assertSame('RESULT', $this->list->getChoices()); @@ -90,12 +90,12 @@ public function testGetValuesLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getValues') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getValues()); $this->assertSame('RESULT', $this->list->getValues()); @@ -106,12 +106,12 @@ public function testGetStructuredValuesLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getStructuredValues') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getStructuredValues()); $this->assertSame('RESULT', $this->list->getStructuredValues()); @@ -122,12 +122,12 @@ public function testGetOriginalKeysLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getOriginalKeys') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getOriginalKeys()); $this->assertSame('RESULT', $this->list->getOriginalKeys()); @@ -138,7 +138,7 @@ public function testGetChoicesForValuesForwardsCallIfListNotLoaded() $this->loader->expects($this->exactly(2)) ->method('loadChoicesForValues') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); @@ -151,7 +151,7 @@ public function testGetChoicesForValuesUsesLoadedList() ->with($this->value) // For BC, the same choice loaded list is returned 3 times // It should only twice in 4.0 - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); $this->loader->expects($this->never()) ->method('loadChoicesForValues'); @@ -159,7 +159,7 @@ public function testGetChoicesForValuesUsesLoadedList() $this->loadedList->expects($this->exactly(2)) ->method('getChoicesForValues') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); // load choice list $this->list->getChoices(); @@ -176,7 +176,7 @@ public function testGetValuesForChoicesForwardsCallIfListNotLoaded() $this->loader->expects($this->exactly(2)) ->method('loadValuesForChoices') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b'])); $this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b'])); @@ -189,7 +189,7 @@ public function testGetValuesForChoicesUsesLoadedList() ->with($this->value) // For BC, the same choice loaded list is returned 3 times // It should only twice in 4.0 - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); $this->loader->expects($this->never()) ->method('loadValuesForChoices'); @@ -197,7 +197,7 @@ public function testGetValuesForChoicesUsesLoadedList() $this->loadedList->expects($this->exactly(2)) ->method('getValuesForChoices') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); // load choice list $this->list->getChoices(); diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index edc3aeda14b2c..7657056b7ada1 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -179,7 +179,7 @@ public function testAddUsingNameAndType() 'bar' => 'baz', 'auto_initialize' => false, ]) - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); @@ -198,7 +198,7 @@ public function testAddUsingIntegerNameAndType() 'bar' => 'baz', 'auto_initialize' => false, ]) - ->will($this->returnValue($child)); + ->willReturn($child); // in order to make casting unnecessary $this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); @@ -215,7 +215,7 @@ public function testAddWithoutType() $this->factory->expects($this->once()) ->method('createNamed') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo'); @@ -236,7 +236,7 @@ public function testAddUsingNameButNoType() $this->factory->expects($this->once()) ->method('createForProperty') ->with('\stdClass', 'foo') - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo'); @@ -260,7 +260,7 @@ public function testAddUsingNameButNoTypeAndOptions() 'bar' => 'baz', 'auto_initialize' => false, ]) - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo', null, ['bar' => 'baz']); @@ -352,10 +352,10 @@ public function testAddMapsViewDataToFormIfInitialized() $mapper->expects($this->once()) ->method('mapDataToForms') ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { + ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame([$child->getName() => $child], iterator_to_array($iterator)); - })); + }); $form->initialize(); $form->add($child); @@ -442,10 +442,10 @@ public function testSetDataMapsViewDataToChildren() $mapper->expects($this->once()) ->method('mapDataToForms') ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { + ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); - })); + }); $form->setData('foo'); } @@ -517,12 +517,12 @@ public function testSubmitMapsSubmittedChildrenOntoExistingViewData() $mapper->expects($this->once()) ->method('mapFormsToData') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { + ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertEquals('Bernhard', $child1->getData()); $this->assertEquals('Schussek', $child2->getData()); - })); + }); $form->submit([ 'firstName' => 'Bernhard', @@ -589,10 +589,10 @@ public function testSubmitMapsSubmittedChildrenOntoEmptyData() $mapper->expects($this->once()) ->method('mapFormsToData') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { + ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame(['name' => $child], iterator_to_array($iterator)); - })); + }); $form->submit([ 'name' => 'Bernhard', @@ -912,11 +912,11 @@ public function testCreateViewWithChildren() $field1View = new FormView(); $type1 ->method('createView') - ->will($this->returnValue($field1View)); + ->willReturn($field1View); $field2View = new FormView(); $type2 ->method('createView') - ->will($this->returnValue($field2View)); + ->willReturn($field2View); $this->form = $this->getBuilder('form', null, null, $options) ->setCompound(true) @@ -935,13 +935,13 @@ public function testCreateViewWithChildren() // First create the view $type->expects($this->once()) ->method('createView') - ->will($this->returnValue($view)); + ->willReturn($view); // Then build it for the form itself $type->expects($this->once()) ->method('buildView') ->with($view, $this->form, $options) - ->will($this->returnCallback($assertChildViewsEqual([]))); + ->willReturnCallback($assertChildViewsEqual([])); $this->assertSame($view, $this->form->createView()); $this->assertSame(['foo' => $field1View, 'bar' => $field2View], $view->children); @@ -961,7 +961,7 @@ public function testNoClickedButton() $button->expects($this->any()) ->method('isClicked') - ->will($this->returnValue(false)); + ->willReturn(false); $parentForm = $this->getBuilder('parent')->getForm(); $nestedForm = $this->getBuilder('nested')->getForm(); @@ -983,7 +983,7 @@ public function testClickedButton() $button->expects($this->any()) ->method('isClicked') - ->will($this->returnValue(true)); + ->willReturn(true); $this->form->add($button); $this->form->submit([]); @@ -1002,7 +1002,7 @@ public function testClickedButtonFromNestedForm() $nestedForm->expects($this->any()) ->method('getClickedButton') - ->will($this->returnValue($button)); + ->willReturn($button); $this->form->add($nestedForm); $this->form->submit([]); @@ -1021,7 +1021,7 @@ public function testClickedButtonFromParentForm() $parentForm->expects($this->any()) ->method('getClickedButton') - ->will($this->returnValue($button)); + ->willReturn($button); $this->form->setParent($parentForm); $this->form->submit([]); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php index f62d3c52110f1..2c685a4197a95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php @@ -22,12 +22,12 @@ public function testTransform() $transformer1->expects($this->once()) ->method('transform') ->with($this->identicalTo('foo')) - ->will($this->returnValue('bar')); + ->willReturn('bar'); $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer2->expects($this->once()) ->method('transform') ->with($this->identicalTo('bar')) - ->will($this->returnValue('baz')); + ->willReturn('baz'); $chain = new DataTransformerChain([$transformer1, $transformer2]); @@ -40,12 +40,12 @@ public function testReverseTransform() $transformer2->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('foo')) - ->will($this->returnValue('bar')); + ->willReturn('bar'); $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer1->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('bar')) - ->will($this->returnValue('baz')); + ->willReturn('baz'); $chain = new DataTransformerChain([$transformer1, $transformer2]); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 4a7f006f6f2ec..bb7cc0ca7f757 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -725,10 +725,7 @@ public function testSubmitMultipleChoiceExpandedWithEmptyDataAndInitialData() $this->assertSame(['test'], $form->getData()); } - /** - * @group legacy - */ - public function testLegacyNullChoices() + public function testNullChoices() { $form = $this->factory->create(static::TESTED_TYPE, null, [ 'multiple' => false, diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index 083f1c956792d..665b700479735 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -122,7 +122,7 @@ public function testGenerateCsrfToken() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('TOKEN_ID') - ->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token'))); + ->willReturn(new CsrfToken('TOKEN_ID', 'token')); $view = $this->factory ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -141,7 +141,7 @@ public function testGenerateCsrfTokenUsesFormNameAsIntentionByDefault() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('FORM_NAME') - ->will($this->returnValue('token')); + ->willReturn('token'); $view = $this->factory ->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -159,7 +159,7 @@ public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('Symfony\Component\Form\Extension\Core\Type\FormType') - ->will($this->returnValue('token')); + ->willReturn('token'); $view = $this->factory ->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -188,7 +188,7 @@ public function testValidateTokenOnSubmitIfRootAndCompound($valid) $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('TOKEN_ID', 'token')) - ->will($this->returnValue($valid)); + ->willReturn($valid); $form = $this->factory ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -220,7 +220,7 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesFormNameAsIntentio $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('FORM_NAME', 'token')) - ->will($this->returnValue($valid)); + ->willReturn($valid); $form = $this->factory ->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -251,7 +251,7 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntenti $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token')) - ->will($this->returnValue($valid)); + ->willReturn($valid); $form = $this->factory ->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -366,12 +366,12 @@ public function testsTranslateCustomErrorMessage() $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('TOKEN_ID', 'token')) - ->will($this->returnValue(false)); + ->willReturn(false); $this->translator->expects($this->once()) ->method('trans') ->with('Foobar') - ->will($this->returnValue('[trans]Foobar[/trans]')); + ->willReturn('[trans]Foobar[/trans]'); $form = $this->factory ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index 2ca0f95f3c6e3..83d44167d5cf4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -84,29 +84,29 @@ public function testBuildPreliminaryFormTree() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(2)) ->method('extractDefaultData') ->with($this->form) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(3)) ->method('extractDefaultData') ->with($this->childForm) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($this->form) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($this->childForm) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectDefaultData($this->form); @@ -150,11 +150,11 @@ public function testBuildMultiplePreliminaryFormTrees() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($form1) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($form2) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectConfiguration($form2); @@ -200,12 +200,12 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractDefaultData') ->with($this->form) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); @@ -272,39 +272,39 @@ public function testBuildFinalFormTree() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(2)) ->method('extractDefaultData') ->with($this->form) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(3)) ->method('extractDefaultData') ->with($this->childForm) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($this->form) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($this->childForm) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataExtractor->expects($this->at(6)) ->method('extractViewVariables') ->with($this->view) - ->will($this->returnValue(['view_vars' => 'foo'])); + ->willReturn(['view_vars' => 'foo']); $this->dataExtractor->expects($this->at(7)) ->method('extractViewVariables') ->with($this->childView) - ->will($this->returnValue(['view_vars' => 'bar'])); + ->willReturn(['view_vars' => 'bar']); $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectDefaultData($this->form); @@ -365,76 +365,76 @@ public function testSerializeWithFormAddedMultipleTimes() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($form1) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($child1) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(2)) ->method('extractDefaultData') ->with($form1) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(3)) ->method('extractDefaultData') ->with($child1) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($form1) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($child1) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataExtractor->expects($this->at(6)) ->method('extractViewVariables') ->with($form1View) - ->will($this->returnValue(['view_vars' => 'foo'])); + ->willReturn(['view_vars' => 'foo']); $this->dataExtractor->expects($this->at(7)) ->method('extractViewVariables') ->with($child1View) - ->will($this->returnValue(['view_vars' => $child1View->vars])); + ->willReturn(['view_vars' => $child1View->vars]); $this->dataExtractor->expects($this->at(8)) ->method('extractConfiguration') ->with($form2) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(9)) ->method('extractConfiguration') ->with($child1) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(10)) ->method('extractDefaultData') ->with($form2) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(11)) ->method('extractDefaultData') ->with($child1) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(12)) ->method('extractSubmittedData') ->with($form2) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(13)) ->method('extractSubmittedData') ->with($child1) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataExtractor->expects($this->at(14)) ->method('extractViewVariables') ->with($form2View) - ->will($this->returnValue(['view_vars' => 'foo'])); + ->willReturn(['view_vars' => 'foo']); $this->dataExtractor->expects($this->at(15)) ->method('extractViewVariables') ->with($child1View) - ->will($this->returnValue(['view_vars' => $child1View->vars])); + ->willReturn(['view_vars' => $child1View->vars]); $this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectDefaultData($form1); @@ -518,11 +518,11 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); // explicitly call collectConfiguration(), since $this->childForm is not // contained in the form tree @@ -566,11 +566,11 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); // explicitly call collectConfiguration(), since $this->childForm is not // contained in the form tree @@ -611,22 +611,22 @@ public function testCollectSubmittedDataCountsErrors() $form1->add($childForm1); $this->dataExtractor ->method('extractConfiguration') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor ->method('extractDefaultData') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($form1) - ->will($this->returnValue(['errors' => ['foo']])); + ->willReturn(['errors' => ['foo']]); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($childForm1) - ->will($this->returnValue(['errors' => ['bar', 'bam']])); + ->willReturn(['errors' => ['bar', 'bam']]); $this->dataExtractor->expects($this->at(8)) ->method('extractSubmittedData') ->with($form2) - ->will($this->returnValue(['errors' => ['baz']])); + ->willReturn(['errors' => ['baz']]); $this->dataCollector->collectSubmittedData($form1); @@ -653,30 +653,30 @@ public function testCollectSubmittedDataExpandedFormsErrors() $this->dataExtractor ->method('extractConfiguration') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor ->method('extractDefaultData') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->at(10)) ->method('extractSubmittedData') ->with($this->form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataExtractor->expects($this->at(11)) ->method('extractSubmittedData') ->with($child1Form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataExtractor->expects($this->at(12)) ->method('extractSubmittedData') ->with($child11Form) - ->will($this->returnValue(['errors' => ['foo']])); + ->willReturn(['errors' => ['foo']]); $this->dataExtractor->expects($this->at(13)) ->method('extractSubmittedData') ->with($child2Form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataExtractor->expects($this->at(14)) ->method('extractSubmittedData') ->with($child21Form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataCollector->collectSubmittedData($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); @@ -701,14 +701,14 @@ public function testReset() $this->dataExtractor->expects($this->any()) ->method('extractConfiguration') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->any()) ->method('extractDefaultData') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->any()) ->method('extractSubmittedData') ->with($form) - ->will($this->returnValue(['errors' => ['baz']])); + ->willReturn(['errors' => ['baz']]); $this->dataCollector->buildPreliminaryFormTree($form); $this->dataCollector->collectSubmittedData($form); diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index 9bbfb0f4f11ee..860a96abcddfa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -56,7 +56,7 @@ public function testExtractConfiguration() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $form = $this->createBuilder('name') ->setType($type) @@ -77,7 +77,7 @@ public function testExtractConfigurationSortsPassedOptions() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $options = [ 'b' => 'foo', @@ -111,7 +111,7 @@ public function testExtractConfigurationSortsResolvedOptions() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $options = [ 'b' => 'foo', @@ -142,7 +142,7 @@ public function testExtractConfigurationBuildsIdRecursively() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $grandParent = $this->createBuilder('grandParent') ->setCompound(true) 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 4ab56f555a90e..8a8af9ed6809a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -24,6 +24,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\SubmitButtonBuilder; use Symfony\Component\Translation\IdentityTranslator; +use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; @@ -673,6 +674,63 @@ public function testCauseForNotAllowedExtraFieldsIsTheFormConstraint() $this->assertSame($constraint, $context->getViolations()->get(0)->getConstraint()); } + public function testNonCompositeConstraintValidatedOnce() + { + $form = $this + ->getBuilder('form', null, [ + 'constraints' => [new NotBlank(['groups' => ['foo', 'bar']])], + 'validation_groups' => ['foo', 'bar'], + ]) + ->setCompound(false) + ->getForm(); + $form->submit(''); + + $context = new ExecutionContext(Validation::createValidator(), $form, new IdentityTranslator()); + $this->validator->initialize($context); + $this->validator->validate($form, new Form()); + + $this->assertCount(1, $context->getViolations()); + $this->assertSame('This value should not be blank.', $context->getViolations()[0]->getMessage()); + $this->assertSame('data', $context->getViolations()[0]->getPropertyPath()); + } + + public function testCompositeConstraintValidatedInEachGroup() + { + $form = $this->getBuilder('form', null, [ + 'constraints' => [ + new Collection([ + 'field1' => new NotBlank([ + 'groups' => ['field1'], + ]), + 'field2' => new NotBlank([ + 'groups' => ['field2'], + ]), + ]), + ], + 'validation_groups' => ['field1', 'field2'], + ]) + ->setData([]) + ->setCompound(true) + ->setDataMapper(new PropertyPathMapper()) + ->getForm(); + $form->add($this->getForm('field1')); + $form->add($this->getForm('field2')); + $form->submit([ + 'field1' => '', + 'field2' => '', + ]); + + $context = new ExecutionContext(Validation::createValidator(), $form, new IdentityTranslator()); + $this->validator->initialize($context); + $this->validator->validate($form, new Form()); + + $this->assertCount(2, $context->getViolations()); + $this->assertSame('This value should not be blank.', $context->getViolations()[0]->getMessage()); + $this->assertSame('data[field1]', $context->getViolations()[0]->getPropertyPath()); + $this->assertSame('This value should not be blank.', $context->getViolations()[1]->getMessage()); + $this->assertSame('data[field2]', $context->getViolations()[1]->getPropertyPath()); + } + protected function createValidator() { return new FormValidator(); 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 53d29a19112c7..57f92b6574e3b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -42,7 +42,7 @@ public function testSubmitValidatesData() $this->validator->expects($this->once()) ->method('validate') ->with($this->equalTo($form)) - ->will($this->returnValue(new ConstraintViolationList())); + ->willReturn(new ConstraintViolationList()); // specific data is irrelevant $form->submit([]); diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index ecab2bb5d91ef..1247a80bbda30 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -91,7 +91,7 @@ public function testAll() $this->factory->expects($this->once()) ->method('createNamedBuilder') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); + ->willReturn(new FormBuilder('foo', null, $this->dispatcher, $this->factory)); $this->assertCount(0, $this->builder->all()); $this->assertFalse($this->builder->has('foo')); @@ -186,7 +186,7 @@ public function testGetExplicitType() $this->factory->expects($this->once()) ->method('createNamedBuilder') ->with($expectedName, $expectedType, null, $expectedOptions) - ->will($this->returnValue($this->getFormBuilder())); + ->willReturn($this->getFormBuilder()); $this->builder->add($expectedName, $expectedType, $expectedOptions); $builder = $this->builder->get($expectedName); @@ -202,7 +202,7 @@ public function testGetGuessedType() $this->factory->expects($this->once()) ->method('createBuilderForProperty') ->with('stdClass', $expectedName, null, $expectedOptions) - ->will($this->returnValue($this->getFormBuilder())); + ->willReturn($this->getFormBuilder()); $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); $this->builder->add($expectedName, null, $expectedOptions); @@ -236,7 +236,7 @@ private function getFormBuilder($name = 'name') $mock->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)); + ->willReturn($name); return $mock; } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index 27a5ca6e20f7c..4426310676538 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -58,10 +58,10 @@ protected function setUp() $this->registry->expects($this->any()) ->method('getTypeGuesser') - ->will($this->returnValue(new FormTypeGuesserChain([ + ->willReturn(new FormTypeGuesserChain([ $this->guesser1, $this->guesser2, - ]))); + ])); } public function testCreateNamedBuilderWithTypeName() @@ -73,16 +73,16 @@ public function testCreateNamedBuilderWithTypeName() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -101,16 +101,16 @@ public function testCreateNamedBuilderFillsDataOption() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $expectedOptions) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -128,16 +128,16 @@ public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -181,16 +181,16 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString() $this->registry->expects($this->any()) ->method('getType') ->with('TYPE') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'TYPE_PREFIX', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -198,7 +198,7 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString() $this->builder->expects($this->once()) ->method('getForm') - ->will($this->returnValue('FORM')); + ->willReturn('FORM'); $this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); } @@ -212,16 +212,16 @@ public function testCreateNamed() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -229,7 +229,7 @@ public function testCreateNamed() $this->builder->expects($this->once()) ->method('getForm') - ->will($this->returnValue('FORM')); + ->willReturn('FORM'); $this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options)); } @@ -245,7 +245,7 @@ public function testCreateBuilderForPropertyWithoutTypeGuesser() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, []) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -257,27 +257,27 @@ public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() $this->guesser1->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( + ->willReturn(new TypeGuess( 'Symfony\Component\Form\Extension\Core\Type\TextType', ['attr' => ['maxlength' => 10]], Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( + ->willReturn(new TypeGuess( 'Symfony\Component\Form\Extension\Core\Type\PasswordType', ['attr' => ['maxlength' => 7]], Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -289,14 +289,14 @@ public function testCreateBuilderCreatesTextFormIfNoGuess() $this->guesser1->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(null)); + ->willReturn(null); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -308,18 +308,18 @@ public function testOptionsCanBeOverridden() $this->guesser1->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( + ->willReturn(new TypeGuess( 'Symfony\Component\Form\Extension\Core\Type\TextType', ['attr' => ['class' => 'foo', 'maxlength' => 10]], Guess::MEDIUM_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -336,25 +336,25 @@ public function testCreateBuilderUsesMaxLengthIfFound() $this->guesser1->expects($this->once()) ->method('guessMaxLength') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( 15, Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessMaxLength') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( 20, Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -369,25 +369,25 @@ public function testCreateBuilderUsesMaxLengthAndPattern() $this->guesser1->expects($this->once()) ->method('guessMaxLength') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( 20, Guess::HIGH_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessPattern') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( '.{5,}', Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -404,25 +404,25 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() $this->guesser1->expects($this->once()) ->method('guessRequired') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( true, Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessRequired') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( false, Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -437,25 +437,25 @@ public function testCreateBuilderUsesPatternIfFound() $this->guesser1->expects($this->once()) ->method('guessPattern') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( '[a-z]', Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessPattern') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( '[a-zA-Z]', Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 32bb8bb788716..ba078ad1fd119 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -99,21 +99,21 @@ public function testGetOptionsResolver() // First the default options are generated for the super type $this->parentType->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default'))); + ->willReturnCallback($assertIndexAndAddOption(0, 'a', 'a_default')); // The form type itself $this->type->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default'))); + ->willReturnCallback($assertIndexAndAddOption(1, 'b', 'b_default')); // And its extensions $this->extension1->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default'))); + ->willReturnCallback($assertIndexAndAddOption(2, 'c', 'c_default')); $this->extension2->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default'))); + ->willReturnCallback($assertIndexAndAddOption(3, 'd', 'd_default')); $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; @@ -136,12 +136,12 @@ public function testCreateBuilder() $this->resolvedType->expects($this->once()) ->method('getOptionsResolver') - ->will($this->returnValue($optionsResolver)); + ->willReturn($optionsResolver); $optionsResolver->expects($this->once()) ->method('resolve') ->with($givenOptions) - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $factory = $this->getMockFormFactory(); $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); @@ -164,12 +164,12 @@ public function testCreateBuilderWithDataClassOption() $this->resolvedType->expects($this->once()) ->method('getOptionsResolver') - ->will($this->returnValue($optionsResolver)); + ->willReturn($optionsResolver); $optionsResolver->expects($this->once()) ->method('resolve') ->with($givenOptions) - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $factory = $this->getMockFormFactory(); $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); @@ -198,24 +198,24 @@ public function testBuildForm() $this->parentType->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(0))); + ->willReturnCallback($assertIndex(0)); // Then the type itself $this->type->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(1))); + ->willReturnCallback($assertIndex(1)); // Then its extensions $this->extension1->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(2))); + ->willReturnCallback($assertIndex(2)); $this->extension2->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(3))); + ->willReturnCallback($assertIndex(3)); $this->resolvedType->buildForm($builder, $options); } @@ -261,24 +261,24 @@ public function testBuildView() $this->parentType->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(0))); + ->willReturnCallback($assertIndex(0)); // Then the type itself $this->type->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(1))); + ->willReturnCallback($assertIndex(1)); // Then its extensions $this->extension1->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(2))); + ->willReturnCallback($assertIndex(2)); $this->extension2->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(3))); + ->willReturnCallback($assertIndex(3)); $this->resolvedType->buildView($view, $form, $options); } @@ -303,24 +303,24 @@ public function testFinishView() $this->parentType->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(0))); + ->willReturnCallback($assertIndex(0)); // Then the type itself $this->type->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(1))); + ->willReturnCallback($assertIndex(1)); // Then its extensions $this->extension1->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(2))); + ->willReturnCallback($assertIndex(2)); $this->extension2->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(3))); + ->willReturnCallback($assertIndex(3)); $this->resolvedType->finishView($view, $form, $options); } diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 32c21c8432b7a..f88902dc8ced6 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -731,7 +731,7 @@ public function testCreateView() $type->expects($this->once()) ->method('createView') ->with($form) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $form->createView()); } @@ -748,12 +748,12 @@ public function testCreateViewWithParent() $parentType->expects($this->once()) ->method('createView') - ->will($this->returnValue($parentView)); + ->willReturn($parentView); $type->expects($this->once()) ->method('createView') ->with($form, $parentView) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $form->createView()); } @@ -768,7 +768,7 @@ public function testCreateViewWithExplicitParent() $type->expects($this->once()) ->method('createView') ->with($form, $parentView) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $form->createView($parentView)); } diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index cf648dfe9d54f..6c9a995e9a316 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -227,13 +227,18 @@ public function prepare(Request $request) if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) { $path = $location.substr($path, \strlen($pathPrefix)); + // Only set X-Accel-Redirect header if a valid URI can be produced + // as nginx does not serve arbitrary file paths. + $this->headers->set($type, $path); + $this->maxlen = 0; break; } } } + } else { + $this->headers->set($type, $path); + $this->maxlen = 0; } - $this->headers->set($type, $path); - $this->maxlen = 0; } elseif ($request->headers->has('Range')) { // Process the range headers. if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) { diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 6fb32ee41bdac..a9bdac30f8956 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -18,7 +18,7 @@ * object. It is however recommended that you do return an object as it * protects yourself against XSSI and JSON-JavaScript Hijacking. * - * @see https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines#Always_return_JSON_with_an_Object_on_the_outside + * @see https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/AJAX_Security_Cheat_Sheet.md#always-return-json-with-an-object-on-the-outside * * @author Igor Wiedler */ @@ -55,10 +55,10 @@ public function __construct($data = null, $status = 200, $headers = [], $json = * * Example: * - * return JsonResponse::create($data, 200) + * return JsonResponse::create(['key' => 'value']) * ->setSharedMaxAge(300); * - * @param mixed $data The json response data + * @param mixed $data The JSON response data * @param int $status The response status code * @param array $headers An array of response headers * @@ -70,7 +70,18 @@ public static function create($data = null, $status = 200, $headers = []) } /** - * Make easier the creation of JsonResponse from raw json. + * Factory method for chainability. + * + * Example: + * + * return JsonResponse::fromJsonString('{"key": "value"}') + * ->setSharedMaxAge(300); + * + * @param string|null $data The JSON response string + * @param int $status The response status code + * @param array $headers An array of response headers + * + * @return static */ public static function fromJsonString($data = null, $status = 200, $headers = []) { @@ -161,6 +172,10 @@ public function setData($data = []) } throw $e; } + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) { + return $this->setJson($data); + } } } diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index 5e1dfe58507fb..51fd869abea25 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -42,7 +42,7 @@ public function __construct($url, $status = 302, $headers = []) throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); } - if (301 == $status && !\array_key_exists('cache-control', $headers)) { + if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) { $this->headers->remove('cache-control'); } } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index b7d116259d6f2..4ab05066f4745 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -707,7 +707,7 @@ public function getAge() return (int) $age; } - return max(time() - $this->getDate()->format('U'), 0); + return max(time() - (int) $this->getDate()->format('U'), 0); } /** @@ -788,7 +788,7 @@ public function getMaxAge() } if (null !== $this->getExpires()) { - return $this->getExpires()->format('U') - $this->getDate()->format('U'); + return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U'); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index 867ceba97f8db..db0b9aeb0b118 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -253,7 +253,9 @@ public function registerBag(SessionBagInterface $bag) */ public function getBag($name) { - return $this->storage->getBag($name)->getBag(); + $bag = $this->storage->getBag($name); + + return method_exists($bag, 'getBag') ? $bag->getBag() : $bag; } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index bc088e7740bc8..9369740eb6dd5 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -683,7 +683,7 @@ private function doAdvisoryLock($sessionId) switch ($this->driver) { case 'mysql': // MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced. - $lockId = \substr($sessionId, 0, 64); + $lockId = substr($sessionId, 0, 64); // should we handle the return value? 0 on timeout, null on error // we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout $stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index c89f20d05a498..853b4bb3dfe11 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -338,6 +338,7 @@ public function getSampleXAccelMappings() return [ ['/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'], ['/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'], + ['/tmp/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', null], ]; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index fb82dae768b4f..caf2029927008 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -172,7 +172,7 @@ protected function createMockGuesser($path, $mimeType) ->expects($this->once()) ->method('guess') ->with($this->equalTo($path)) - ->will($this->returnValue($mimeType)) + ->willReturn($mimeType) ; return $guesser; diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index 5425896dfa3b7..ef0346cbe6dae 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -52,7 +52,8 @@ public function testConstructorWithSimpleTypes() $this->assertSame('0', $response->getContent()); $response = new JsonResponse(0.1); - $this->assertSame('0.1', $response->getContent()); + $this->assertEquals('0.1', $response->getContent()); + $this->assertInternalType('string', $response->getContent()); $response = new JsonResponse(true); $this->assertSame('true', $response->getContent()); @@ -140,7 +141,8 @@ public function testStaticCreateWithSimpleTypes() $response = JsonResponse::create(0.1); $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); - $this->assertSame('0.1', $response->getContent()); + $this->assertEquals('0.1', $response->getContent()); + $this->assertInternalType('string', $response->getContent()); $response = JsonResponse::create(true); $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); diff --git a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php index 64c3e73ee21af..5f6a8ac0883f4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php @@ -91,6 +91,10 @@ public function testCacheHeaders() $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); $this->assertTrue($response->headers->hasCacheControlDirective('max-age')); + $response = new RedirectResponse('foo.bar', 301, ['Cache-Control' => 'max-age=86400']); + $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($response->headers->hasCacheControlDirective('max-age')); + $response = new RedirectResponse('foo.bar', 302); $this->assertTrue($response->headers->hasCacheControlDirective('no-cache')); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index afa00fc7c3046..acb129984edd1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Session; +use Symfony\Component\HttpFoundation\Session\SessionBagProxy; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; /** @@ -260,4 +261,28 @@ public function testIsEmpty() $flash->get('hello'); $this->assertTrue($this->session->isEmpty()); } + + public function testGetBagWithBagImplementingGetBag() + { + $bag = new AttributeBag(); + $bag->setName('foo'); + + $storage = new MockArraySessionStorage(); + $storage->registerBag($bag); + + $this->assertSame($bag, (new Session($storage))->getBag('foo')); + } + + public function testGetBagWithBagNotImplementingGetBag() + { + $data = []; + + $bag = new AttributeBag(); + $bag->setName('foo'); + + $storage = new MockArraySessionStorage(); + $storage->registerBag(new SessionBagProxy($bag, $data, $usageIndex)); + + $this->assertSame($bag, (new Session($storage))->getBag('foo')); + } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index 68daa4e5cb595..d7a324fc205bc 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -79,7 +79,7 @@ public function testWriteSession() ->expects($this->once()) ->method('set') ->with(self::PREFIX.'id', 'data', 0, $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->write('id', 'data')); @@ -91,7 +91,7 @@ public function testDestroySession() ->expects($this->once()) ->method('delete') ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->destroy('id')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index 813337349f225..c3deb7aed8fb5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -66,7 +66,7 @@ public function testCloseSession() $this->memcached ->expects($this->once()) ->method('quit') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->close()); @@ -89,7 +89,7 @@ public function testWriteSession() ->expects($this->once()) ->method('set') ->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->write('id', 'data')); @@ -101,7 +101,7 @@ public function testDestroySession() ->expects($this->once()) ->method('delete') ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->destroy('id')); 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 6f2742ca70e53..5ce6a9e5a6641 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -95,7 +95,7 @@ public function testRead() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); // defining the timeout before the actual method call // allows to test for "greater than" values in the $criteria @@ -103,7 +103,7 @@ public function testRead() $collection->expects($this->once()) ->method('findOne') - ->will($this->returnCallback(function ($criteria) use ($testTimeout) { + ->willReturnCallback(function ($criteria) use ($testTimeout) { $this->assertArrayHasKey($this->options['id_field'], $criteria); $this->assertEquals($criteria[$this->options['id_field']], 'foo'); @@ -131,7 +131,7 @@ public function testRead() } return $fields; - })); + }); $this->assertEquals('bar', $this->storage->read('foo')); } @@ -143,7 +143,7 @@ public function testWrite() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $data = []; @@ -151,7 +151,7 @@ public function testWrite() $collection->expects($this->once()) ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) { $this->assertEquals([$this->options['id_field'] => 'foo'], $criteria); if (phpversion('mongodb')) { @@ -161,7 +161,7 @@ public function testWrite() } $data = $updateData['$set']; - })); + }); $expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime'); $this->assertTrue($this->storage->write('foo', 'bar')); @@ -197,7 +197,7 @@ public function testWriteWhenUsingExpiresField() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $data = []; @@ -205,7 +205,7 @@ public function testWriteWhenUsingExpiresField() $collection->expects($this->once()) ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) { $this->assertEquals([$this->options['id_field'] => 'foo'], $criteria); if (phpversion('mongodb')) { @@ -215,7 +215,7 @@ public function testWriteWhenUsingExpiresField() } $data = $updateData['$set']; - })); + }); $this->assertTrue($this->storage->write('foo', 'bar')); @@ -237,7 +237,7 @@ public function testReplaceSessionData() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $data = []; @@ -245,9 +245,9 @@ public function testReplaceSessionData() $collection->expects($this->exactly(2)) ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) { $data = $updateData; - })); + }); $this->storage->write('foo', 'bar'); $this->storage->write('foo', 'foobar'); @@ -266,7 +266,7 @@ public function testDestroy() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $methodName = phpversion('mongodb') ? 'deleteOne' : 'remove'; @@ -284,13 +284,13 @@ public function testGc() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $methodName = phpversion('mongodb') ? 'deleteMany' : 'remove'; $collection->expects($this->once()) ->method($methodName) - ->will($this->returnCallback(function ($criteria) { + ->willReturnCallback(function ($criteria) { if (phpversion('mongodb')) { $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$this->options['expiry_field']]['$lt']); $this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000)); @@ -298,7 +298,7 @@ public function testGc() $this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$lt']); $this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['expiry_field']]['$lt']->sec); } - })); + }); $this->assertTrue($this->storage->gc(1)); } 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 901078478b4db..f0914eb43d080 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() $stream = $this->createStream($content); $pdo->prepareResult->expects($this->once())->method('fetchAll') - ->will($this->returnValue([[$stream, 42, time()]])); + ->willReturn([[$stream, 42, time()]]); $storage = new PdoSessionHandler($pdo); $result = $storage->read('foo'); @@ -177,14 +177,14 @@ public function testReadLockedConvertsStreamToString() $exception = null; $selectStmt->expects($this->atLeast(2))->method('fetchAll') - ->will($this->returnCallback(function () use (&$exception, $stream) { + ->willReturnCallback(function () use (&$exception, $stream) { return $exception ? [[$stream, 42, time()]] : []; - })); + }); $insertStmt->expects($this->once())->method('execute') - ->will($this->returnCallback(function () use (&$exception) { + ->willReturnCallback(function () use (&$exception) { throw $exception = new \PDOException('', '23'); - })); + }); $storage = new PdoSessionHandler($pdo); $result = $storage->read('foo'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php index 898a7d11a5ae2..b89454f87f4e7 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php @@ -30,7 +30,7 @@ public function test() ->expects($this->once()) ->method('close') ->with() - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($writeCheckSessionHandler->close()); @@ -45,7 +45,7 @@ public function testWrite() ->expects($this->once()) ->method('write') ->with('foo', 'bar') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); @@ -60,7 +60,7 @@ public function testSkippedWrite() ->expects($this->once()) ->method('read') ->with('foo') - ->will($this->returnValue('bar')) + ->willReturn('bar') ; $wrappedSessionHandlerMock @@ -81,14 +81,14 @@ public function testNonSkippedWrite() ->expects($this->once()) ->method('read') ->with('foo') - ->will($this->returnValue('bar')) + ->willReturn('bar') ; $wrappedSessionHandlerMock ->expects($this->once()) ->method('write') ->with('foo', 'baZZZ') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 0459a8ce97d50..b6e0da99ddd67 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -50,7 +50,7 @@ public function testOpenTrue() { $this->mock->expects($this->once()) ->method('open') - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); @@ -61,7 +61,7 @@ public function testOpenFalse() { $this->mock->expects($this->once()) ->method('open') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); @@ -72,7 +72,7 @@ public function testClose() { $this->mock->expects($this->once()) ->method('close') - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertFalse($this->proxy->isActive()); $this->proxy->close(); @@ -83,7 +83,7 @@ public function testCloseFalse() { $this->mock->expects($this->once()) ->method('close') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertFalse($this->proxy->isActive()); $this->proxy->close(); diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index f48db705686b6..7ab14b7cb856a 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -47,7 +47,7 @@ public function collect(Request $request, Response $response, \Exception $except 'token' => $response->headers->get('X-Debug-Token'), 'start_time' => $startTime * 1000, 'events' => [], - 'stopwatch_installed' => \class_exists(Stopwatch::class, false), + 'stopwatch_installed' => class_exists(Stopwatch::class, false), ]; } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php index 1efad607e8277..25c071c335a02 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php @@ -85,7 +85,7 @@ public function add(Response $response) $this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age); $expires = $response->getExpires(); - $expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null; + $expires = null !== $expires ? (int) $expires->format('U') - (int) $response->getDate()->format('U') : null; $this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0); } @@ -132,12 +132,12 @@ public function update(Response $response) $maxAge = null; $sMaxage = null; - if (\is_numeric($this->ageDirectives['max-age'])) { + if (is_numeric($this->ageDirectives['max-age'])) { $maxAge = $this->ageDirectives['max-age'] + $this->age; $response->headers->addCacheControlDirective('max-age', $maxAge); } - if (\is_numeric($this->ageDirectives['s-maxage'])) { + if (is_numeric($this->ageDirectives['s-maxage'])) { $sMaxage = $this->ageDirectives['s-maxage'] + $this->age; if ($maxAge !== $sMaxage) { @@ -145,7 +145,7 @@ public function update(Response $response) } } - if (\is_numeric($this->ageDirectives['expires'])) { + if (is_numeric($this->ageDirectives['expires'])) { $date = clone $response->getDate(); $date->modify('+'.($this->ageDirectives['expires'] + $this->age).' seconds'); $response->setExpires($date); diff --git a/src/Symfony/Component/HttpKernel/HttpCache/SubRequestHandler.php b/src/Symfony/Component/HttpKernel/HttpCache/SubRequestHandler.php index a701b235464ba..895207152bd19 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/SubRequestHandler.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/SubRequestHandler.php @@ -31,7 +31,7 @@ public static function handle(HttpKernelInterface $kernel, Request $request, $ty // save global state related to trusted headers and proxies $trustedProxies = Request::getTrustedProxies(); $trustedHeaderSet = Request::getTrustedHeaderSet(); - if (\method_exists(Request::class, 'getTrustedHeaderName')) { + if (method_exists(Request::class, 'getTrustedHeaderName')) { Request::setTrustedProxies($trustedProxies, -1); $trustedHeaders = [ Request::HEADER_FORWARDED => Request::getTrustedHeaderName(Request::HEADER_FORWARDED, false), diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 01a0224cd99d1..21d03f4ba5867 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -67,11 +67,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.28'; - const VERSION_ID = 30428; + const VERSION = '3.4.29'; + const VERSION_ID = 30429; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 28; + const RELEASE_VERSION = 29; const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php index de15c6f30ce0b..41fe28507c8f9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php @@ -87,7 +87,7 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa $warmer ->expects($this->once()) ->method('isOptional') - ->will($this->returnValue(true)); + ->willReturn(true); $warmer ->expects($this->never()) ->method('warmUp'); diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index ac1c55ad54d35..86a51ce7651a2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -157,7 +157,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $file->expects($this->once()) ->method('getSize') - ->will($this->returnValue(INF)) + ->willReturn(INF) ; $client->request('POST', '/', [], [$file]); diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php index 6265f0275560a..b20b12ab59ed6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php @@ -23,7 +23,7 @@ public function testLocate() ->expects($this->atLeastOnce()) ->method('locateResource') ->with('@BundleName/some/path', null, true) - ->will($this->returnValue('/bundle-name/some/path')); + ->willReturn('/bundle-name/some/path'); $locator = new FileLocator($kernel); $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php index 3f130db06500a..098b89f9e1255 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php @@ -26,11 +26,11 @@ public function testGetControllerService() $container->expects($this->once()) ->method('has') ->with('foo') - ->will($this->returnValue(true)); + ->willReturn(true); $container->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($this)) + ->willReturn($this) ; $resolver = $this->createControllerResolver(null, $container); @@ -51,12 +51,12 @@ public function testGetControllerInvokableService() $container->expects($this->once()) ->method('has') ->with('foo') - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($invokableController)) + ->willReturn($invokableController) ; $resolver = $this->createControllerResolver(null, $container); @@ -77,12 +77,12 @@ public function testGetControllerInvokableServiceWithClassNameAsName() $container->expects($this->once()) ->method('has') ->with($className) - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->once()) ->method('get') ->with($className) - ->will($this->returnValue($invokableController)) + ->willReturn($invokableController) ; $resolver = $this->createControllerResolver(null, $container); @@ -100,7 +100,7 @@ public function testNonInstantiableController() $container->expects($this->once()) ->method('has') ->with(NonInstantiableController::class) - ->will($this->returnValue(false)) + ->willReturn(false) ; $resolver = $this->createControllerResolver(null, $container); @@ -122,19 +122,19 @@ public function testNonConstructController() $container->expects($this->at(0)) ->method('has') ->with(ImpossibleConstructController::class) - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->at(1)) ->method('has') ->with(ImpossibleConstructController::class) - ->will($this->returnValue(false)) + ->willReturn(false) ; $container->expects($this->atLeastOnce()) ->method('getRemovedIds') ->with() - ->will($this->returnValue([ImpossibleConstructController::class => true])) + ->willReturn([ImpossibleConstructController::class => true]) ; $resolver = $this->createControllerResolver(null, $container); @@ -162,12 +162,12 @@ public function testNonInstantiableControllerWithCorrespondingService() $container->expects($this->atLeastOnce()) ->method('has') ->with(NonInstantiableController::class) - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->atLeastOnce()) ->method('get') ->with(NonInstantiableController::class) - ->will($this->returnValue($service)) + ->willReturn($service) ; $resolver = $this->createControllerResolver(null, $container); @@ -189,13 +189,13 @@ public function testExceptionWhenUsingRemovedControllerService() $container->expects($this->at(0)) ->method('has') ->with('app.my_controller') - ->will($this->returnValue(false)) + ->willReturn(false) ; $container->expects($this->atLeastOnce()) ->method('getRemovedIds') ->with() - ->will($this->returnValue(['app.my_controller' => true])) + ->willReturn(['app.my_controller' => true]) ; $resolver = $this->createControllerResolver(null, $container); @@ -215,12 +215,12 @@ public function testExceptionWhenUsingControllerWithoutAnInvokeMethod() $container->expects($this->once()) ->method('has') ->with('app.my_controller') - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->once()) ->method('get') ->with('app.my_controller') - ->will($this->returnValue(new ImpossibleConstructController('toto', 'controller'))) + ->willReturn(new ImpossibleConstructController('toto', 'controller')) ; $resolver = $this->createControllerResolver(null, $container); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 728382ad2b1ec..6a28eab26bb52 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -226,7 +226,7 @@ public function testGetVariadicArguments() public function testCreateControllerCanReturnAnyCallable() { $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(['createController'])->getMock(); - $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); + $mock->expects($this->once())->method('createController')->willReturn('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'); $request = Request::create('/'); $request->attributes->set('_controller', 'foobar'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 90151ae44afdf..ace4628e09f93 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -23,8 +23,8 @@ public function testCollectWithUnexpectedFormat() ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo')); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue([])); + $logger->expects($this->once())->method('countErrors')->willReturn('foo'); + $logger->expects($this->exactly(2))->method('getLogs')->willReturn([]); $c = new LoggerDataCollector($logger, __DIR__.'/'); $c->lateCollect(); @@ -50,8 +50,8 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); + $logger->expects($this->once())->method('countErrors')->willReturn($nb); + $logger->expects($this->exactly(2))->method('getLogs')->willReturn($logs); $c = new LoggerDataCollector($logger); $c->lateCollect(); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index 793fbd319f94d..e044e5e1add53 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -44,7 +44,7 @@ public function testCollect() $this->assertEquals(0, $c->getStartTime()); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456)); + $kernel->expects($this->once())->method('getStartTime')->willReturn(123456); $c = new TimeDataCollector($kernel); $request = new Request(); @@ -52,6 +52,6 @@ public function testCollect() $c->collect($request, new Response()); $this->assertEquals(123456000, $c->getStartTime()); - $this->assertSame(\class_exists(Stopwatch::class, false), $c->isStopwatchInstalled()); + $this->assertSame(class_exists(Stopwatch::class, false), $c->isStopwatchInstalled()); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index 8b8e91aeb474d..60ad1b89c4dfb 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -49,7 +49,7 @@ public function testStopwatchCheckControllerOnRequestEvent() ->getMock(); $stopwatch->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(false)); + ->willReturn(false); $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); @@ -65,7 +65,7 @@ public function testStopwatchStopControllerOnRequestEvent() ->getMock(); $stopwatch->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)); + ->willReturn(true); $stopwatch->expects($this->once()) ->method('stop'); $stopwatch->expects($this->once()) @@ -112,9 +112,9 @@ public function testListenerCanRemoveItselfWhenExecuted() protected function getHttpKernel($dispatcher, $controller) { $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); - $controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); + $controllerResolver->expects($this->once())->method('getController')->willReturn($controller); $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); - $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue([])); + $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 95baaa54c133c..953dc65cdf735 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -25,14 +25,14 @@ class LazyLoadingFragmentHandlerTest extends TestCase public function testRenderWithLegacyMapping() { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); - $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); + $renderer->expects($this->once())->method('getName')->willReturn('foo'); + $renderer->expects($this->any())->method('render')->willReturn(new Response()); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); + $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); + $container->expects($this->once())->method('get')->willReturn($renderer); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); $handler->addRendererService('foo', 'foo'); @@ -46,15 +46,15 @@ public function testRenderWithLegacyMapping() public function testRender() { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); - $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); + $renderer->expects($this->once())->method('getName')->willReturn('foo'); + $renderer->expects($this->any())->method('render')->willReturn(new Response()); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); + $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); $container->expects($this->once())->method('has')->with('foo')->willReturn(true); - $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); + $container->expects($this->once())->method('get')->willReturn($renderer); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index b4ea2f955bb53..4ab0a8fb1ea62 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -77,7 +77,7 @@ protected function getGetResponseEventMock(Request $request) $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); return $event; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index d9e261d35af5e..44af0149f738f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -94,7 +94,7 @@ public function testConsoleEvent() $dispatcher = new EventDispatcher(); $listener = new DebugHandlersListener(null); $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); - $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet())); + $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet()); $command = new Command(__FUNCTION__); $command->setApplication($app); $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index c4e8cd505cbff..fca60f1927a27 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -112,9 +112,9 @@ public function testSubRequestFormat() $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); - })); + }); $request = Request::create('/'); $request->setRequestFormat('xml'); @@ -130,9 +130,9 @@ public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); - })); + }); $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index 1cf4b72c69d78..5f96f7f7c660b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -55,7 +55,7 @@ public function testLocaleSetForRoutingContext() $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); + $router->expects($this->once())->method('getContext')->willReturn($context); $request = Request::create('/'); @@ -71,12 +71,12 @@ public function testRouterResetWithParentRequestOnKernelFinishRequest() $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); + $router->expects($this->once())->method('getContext')->willReturn($context); $parentRequest = Request::create('/'); $parentRequest->setLocale('es'); - $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); + $this->requestStack->expects($this->once())->method('getParentRequest')->willReturn($parentRequest); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 392aa2fc35816..7808578882fcd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -36,7 +36,7 @@ public function testKernelTerminate() $profiler->expects($this->once()) ->method('collect') - ->will($this->returnValue($profile)); + ->willReturn($profile); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 218af8d36e293..33f6ab9594a96 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -49,7 +49,7 @@ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHtt $context->setHttpsPort($defaultHttpsPort); $urlMatcher->expects($this->any()) ->method('getContext') - ->will($this->returnValue($context)); + ->willReturn($context); $listener = new RouterListener($urlMatcher, $this->requestStack); $event = $this->createGetResponseEventForUri($uri); @@ -102,7 +102,7 @@ public function testRequestMatcher() $requestMatcher->expects($this->once()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue([])); + ->willReturn([]); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener->onKernelRequest($event); @@ -118,7 +118,7 @@ public function testSubRequestWithDifferentMethod() $requestMatcher->expects($this->any()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue([])); + ->willReturn([]); $context = new RequestContext(); @@ -143,7 +143,7 @@ public function testLoggingParameter($parameter, $log, $parameters) $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') - ->will($this->returnValue($parameter)); + ->willReturn($parameter); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index f261f2ed15a66..7187c7d1f6251 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -47,7 +47,7 @@ protected function setUp() $this->session = $this->getSession(); $this->listener->expects($this->any()) ->method('getSession') - ->will($this->returnValue($this->session)); + ->willReturn($this->session); } public function testShouldSaveMasterRequestSession() @@ -183,28 +183,28 @@ private function sessionHasBeenStarted() { $this->session->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)); + ->willReturn(true); } private function sessionHasNotBeenStarted() { $this->session->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(false)); + ->willReturn(false); } private function sessionIsEmpty() { $this->session->expects($this->once()) ->method('isEmpty') - ->will($this->returnValue(true)); + ->willReturn(true); } private function fixSessionId($sessionId) { $this->session->expects($this->any()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); } private function getSession() @@ -214,7 +214,7 @@ private function getSession() ->getMock(); // set return value for getName() - $mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID')); + $mock->expects($this->any())->method('getName')->willReturn('MOCKSESSID'); return $mock; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php index c1d56ec85d728..77c2c1c694529 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php @@ -113,6 +113,6 @@ private function setMasterRequest($request) $this->requestStack ->expects($this->any()) ->method('getParentRequest') - ->will($this->returnValue($request)); + ->willReturn($request); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php deleted file mode 100644 index dc9c9166f9f25..0000000000000 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestEventDispatcher extends EventDispatcher implements TraceableEventDispatcherInterface -{ - public function getCalledListeners() - { - return ['foo']; - } - - public function getNotCalledListeners() - { - return ['bar']; - } - - public function reset() - { - } -} diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index 8829393ea4e5c..06ce785ea6094 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php @@ -32,7 +32,7 @@ protected function setUp() $this->requestStack ->expects($this->any()) ->method('getCurrentRequest') - ->will($this->returnValue(Request::create('/'))) + ->willReturn(Request::create('/')) ; } @@ -79,7 +79,7 @@ protected function getHandler($returnValue, $arguments = []) $renderer ->expects($this->any()) ->method('getName') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $e = $renderer ->expects($this->any()) diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index 11adf74c2931c..b2a2dcaef6305 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -64,9 +64,9 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerL $resolver ->expects($this->once()) ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { + ->willReturn(function (\stdClass $object, Bar $object1) { return new Response($object1->getBar()); - })) + }) ; $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack()); @@ -85,9 +85,9 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController( $resolver ->expects($this->once()) ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { + ->willReturn(function (\stdClass $object, Bar $object1) { return new Response($object1->getBar()); - })) + }) ; $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack(), new ArgumentResolver()); @@ -162,18 +162,18 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() $controllerResolver ->expects($this->once()) ->method('getController') - ->will($this->returnValue(function () { + ->willReturn(function () { ob_start(); echo 'bar'; throw new \RuntimeException(); - })) + }) ; $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); $argumentResolver ->expects($this->once()) ->method('getArguments') - ->will($this->returnValue([])) + ->willReturn([]) ; $kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index ccc3eecfaf8c2..1fc8da8e24530 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -229,7 +229,7 @@ protected function getCache($request, $response) $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; if (\is_array($response)) { $cache->expects($this->any()) @@ -239,7 +239,7 @@ protected function getCache($request, $response) } else { $cache->expects($this->any()) ->method('handle') - ->will($this->returnValue($response)) + ->willReturn($response) ; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php index 2fc0bb9660dd1..79ed48cd00f7d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php @@ -196,7 +196,7 @@ protected function getCache($request, $response) $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; if (\is_array($response)) { $cache->expects($this->any()) @@ -206,7 +206,7 @@ protected function getCache($request, $response) } else { $cache->expects($this->any()) ->method('handle') - ->will($this->returnValue($response)) + ->willReturn($response) ; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 939ecc0446359..01e32898e2971 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -363,13 +363,13 @@ private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $contr $controllerResolver ->expects($this->any()) ->method('getController') - ->will($this->returnValue($controller)); + ->willReturn($controller); $argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock(); $argumentResolver ->expects($this->any()) ->method('getArguments') - ->will($this->returnValue($arguments)); + ->willReturn($arguments); return new HttpKernel($eventDispatcher, $controllerResolver, $requestStack, $argumentResolver); } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 208e11e182d65..04d74ae0a3199 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -110,7 +110,7 @@ public function testBootSetsTheContainerToTheBundles() $kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'getBundles']); $kernel->expects($this->once()) ->method('getBundles') - ->will($this->returnValue([$bundle])); + ->willReturn([$bundle]); $kernel->boot(); } @@ -167,16 +167,16 @@ public function testEnvParametersResourceIsAdded() ->getMock(); $kernel->expects($this->any()) ->method('getContainerBuilder') - ->will($this->returnValue($container)); + ->willReturn($container); $kernel->expects($this->any()) ->method('prepareContainer') - ->will($this->returnValue(null)); + ->willReturn(null); $kernel->expects($this->any()) ->method('getCacheDir') - ->will($this->returnValue(sys_get_temp_dir())); + ->willReturn(sys_get_temp_dir()); $kernel->expects($this->any()) ->method('getLogDir') - ->will($this->returnValue(sys_get_temp_dir())); + ->willReturn(sys_get_temp_dir()); $reflection = new \ReflectionClass(\get_class($kernel)); $method = $reflection->getMethod('buildContainer'); @@ -226,7 +226,7 @@ public function testShutdownGivesNullContainerToAllBundles() $kernel = $this->getKernel(['getBundles']); $kernel->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([$bundle])); + ->willReturn([$bundle]); $kernel->boot(); $kernel->shutdown(); @@ -249,7 +249,7 @@ public function testHandleCallsHandleOnHttpKernel() $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->once()) ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); + ->willReturn($httpKernelMock); $kernel->handle($request, $type, $catch); } @@ -267,7 +267,7 @@ public function testHandleBootsTheKernel() $kernel = $this->getKernel(['getHttpKernel', 'boot']); $kernel->expects($this->once()) ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); + ->willReturn($httpKernelMock); $kernel->expects($this->once()) ->method('boot'); @@ -421,7 +421,7 @@ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')]) ; $kernel->locateResource('@Bundle1Bundle/config/routing.xml'); @@ -433,7 +433,7 @@ public function testLocateResourceReturnsTheFirstThatMatches() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')]) ; $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt')); @@ -451,7 +451,7 @@ public function testLocateResourceReturnsTheFirstThatMatchesWithParent() $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue([$child, $parent])) + ->willReturn([$child, $parent]) ; $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt')); @@ -470,7 +470,7 @@ public function testLocateResourceReturnsAllMatches() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$child, $parent])) + ->willReturn([$child, $parent]) ; $this->assertEquals([ @@ -488,10 +488,10 @@ public function testLocateResourceReturnsAllMatchesBis() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([ + ->willReturn([ $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), $this->getBundle(__DIR__.'/Foobar'), - ])) + ]) ; $this->assertEquals( @@ -506,7 +506,7 @@ public function testLocateResourceIgnoresDirOnNonResource() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')]) ; $this->assertEquals( @@ -521,7 +521,7 @@ public function testLocateResourceReturnsTheDirOneForResources() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')]) ; $this->assertEquals( @@ -539,7 +539,7 @@ public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')]) ; $this->assertEquals([ @@ -561,7 +561,7 @@ public function testLocateResourceOverrideBundleAndResourcesFolders() $kernel ->expects($this->exactly(4)) ->method('getBundle') - ->will($this->returnValue([$child, $parent])) + ->willReturn([$child, $parent]) ; $this->assertEquals([ @@ -596,7 +596,7 @@ public function testLocateResourceOnDirectories() $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')]) ; $this->assertEquals( @@ -612,7 +612,7 @@ public function testLocateResourceOnDirectories() $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')]) ; $this->assertEquals( @@ -638,7 +638,7 @@ public function testInitializeBundles() $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue([$parent, $child])) + ->willReturn([$parent, $child]) ; $kernel->boot(); @@ -660,7 +660,7 @@ public function testInitializeBundlesSupportInheritanceCascade() $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue([$grandparent, $parent, $child])) + ->willReturn([$grandparent, $parent, $child]) ; $kernel->boot(); @@ -696,7 +696,7 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue([$parent, $grandparent, $child])) + ->willReturn([$parent, $grandparent, $child]) ; $kernel->boot(); @@ -785,7 +785,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->exactly(2)) ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); + ->willReturn($httpKernelMock); $kernel->boot(); $kernel->terminate(Request::create('/'), new Response()); @@ -938,19 +938,19 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu $bundle ->expects($this->any()) ->method('getName') - ->will($this->returnValue(null === $bundleName ? \get_class($bundle) : $bundleName)) + ->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName) ; $bundle ->expects($this->any()) ->method('getPath') - ->will($this->returnValue($dir)) + ->willReturn($dir) ; $bundle ->expects($this->any()) ->method('getParent') - ->will($this->returnValue($parent)) + ->willReturn($parent) ; return $bundle; @@ -976,7 +976,7 @@ protected function getKernel(array $methods = [], array $bundles = []) ; $kernel->expects($this->any()) ->method('registerBundles') - ->will($this->returnValue($bundles)) + ->willReturn($bundles) ; $p = new \ReflectionProperty($kernel, 'rootDir'); $p->setAccessible(true); diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php index 17865203f2c96..3a5a8ade54156 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php @@ -149,7 +149,7 @@ public function testObjectCastToString() } $dummy->expects($this->atLeastOnce()) ->method('__toString') - ->will($this->returnValue('DUMMY')); + ->willReturn('DUMMY'); $this->logger->warning($dummy); diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php index 8b48371f60c6f..1443cc79ecb11 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php @@ -25,7 +25,7 @@ class DayOfYearTransformer extends Transformer */ public function format(\DateTime $dateTime, $length) { - $dayOfYear = $dateTime->format('z') + 1; + $dayOfYear = (int) $dateTime->format('z') + 1; return $this->padLeft($dayOfYear, $length); } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php index 9c0d86ef05bdc..13854ff719ef8 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php @@ -315,7 +315,7 @@ protected function calculateUnixTimestamp(\DateTime $dateTime, array $options) preg_match_all($this->regExp, $this->pattern, $matches); if (\in_array('yy', $matches[0])) { $dateTime->setTimestamp(time()); - $year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year; + $year = $year > (int) $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year; } $dateTime->setDate($year, $month, $day); diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php index 766611ed027d6..3357b039ea814 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php @@ -72,7 +72,7 @@ public function testForwardCallToRead() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->assertSame(self::$data, $this->reader->read(self::RES_DIR, 'root')); } @@ -82,12 +82,12 @@ public function testReadEntireDataFileIfNoIndicesGiven() $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$fallbackData)); + ->willReturn(self::$fallbackData); $this->assertSame(self::$mergedData, $this->reader->readEntry(self::RES_DIR, 'en', [])); } @@ -97,7 +97,7 @@ public function testReadExistingEntry() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'Foo'])); } @@ -110,7 +110,7 @@ public function testReadNonExistingEntry() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'NonExisting']); } @@ -120,12 +120,12 @@ public function testFallbackIfEntryDoesNotExist() $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(self::$fallbackData)); + ->willReturn(self::$fallbackData); $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'])); } @@ -138,7 +138,7 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'], false); } @@ -153,7 +153,7 @@ public function testFallbackIfLocaleDoesNotExist() $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(self::$fallbackData)); + ->willReturn(self::$fallbackData); $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'])); } @@ -193,17 +193,17 @@ public function testMergeDataWithFallbackData($childData, $parentData, $result) $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($childData)); + ->willReturn($childData); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue($parentData)); + ->willReturn($parentData); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($childData)); + ->willReturn($childData); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', [], true)); @@ -217,7 +217,7 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue($childData)); + ->willReturn($childData); $this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', [], false)); } @@ -231,17 +231,17 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', ['Foo', 'Bar'], true)); @@ -255,12 +255,12 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $ $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => 'Baz'])); + ->willReturn(['Foo' => 'Baz']); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); $this->assertSame($parentData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true)); } @@ -274,17 +274,17 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $ $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => 'Bar'])); + ->willReturn(['Foo' => 'Bar']); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true)); @@ -298,12 +298,12 @@ public function testFailIfEntryFoundNeitherInParentNorChild() $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => 'Baz'])); + ->willReturn(['Foo' => 'Baz']); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => 'Bar'])); + ->willReturn(['Foo' => 'Bar']); $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true); } @@ -320,17 +320,17 @@ public function testMergeTraversables($childData, $parentData, $result) $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true)); @@ -347,18 +347,18 @@ public function testFollowLocaleAliases($childData, $parentData, $result) $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'ro_MD') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); // Read fallback locale of aliased locale ("ro_MD" -> "ro") $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'ro') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'ro_MD') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'mo', ['Foo', 'Bar'], true)); diff --git a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php index 63b3379d25e13..95373e92b14e7 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php @@ -70,7 +70,7 @@ public function testLdapFind() $collection ->expects($this->once()) ->method('getIterator') - ->will($this->returnValue(new \ArrayIterator([ + ->willReturn(new \ArrayIterator([ new Entry('cn=qux,dc=foo,dc=com', [ 'cn' => ['qux'], 'dc' => ['com', 'foo'], @@ -81,13 +81,13 @@ public function testLdapFind() 'dc' => ['com', 'foo'], 'givenName' => ['Baz'], ]), - ]))) + ])) ; $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($collection)) + ->willReturn($collection) ; $this->ldap ->expects($this->once()) diff --git a/src/Symfony/Component/Ldap/Tests/LdapTest.php b/src/Symfony/Component/Ldap/Tests/LdapTest.php index acc845222587a..0d6961c267ac1 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapTest.php @@ -42,7 +42,7 @@ public function testLdapBind() $this->adapter ->expects($this->once()) ->method('getConnection') - ->will($this->returnValue($connection)) + ->willReturn($connection) ; $this->ldap->bind('foo', 'bar'); } diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index 1a6c0e26ee0c9..0d5714bde20c0 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -83,6 +83,11 @@ public function acquire($blocking = false) } if ($this->key->isExpired()) { + try { + $this->release(); + } catch (\Exception $e) { + // swallow exception to not hide the original issue + } throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key)); } @@ -117,6 +122,11 @@ public function refresh() $this->dirty = true; if ($this->key->isExpired()) { + try { + $this->release(); + } catch (\Exception $e) { + // swallow exception to not hide the original issue + } throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key)); } diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index 38f3f35e750e9..6038b3be93d31 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -16,7 +16,6 @@ use Psr\Log\NullLogger; use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\LockConflictedException; -use Symfony\Component\Lock\Exception\LockExpiredException; use Symfony\Component\Lock\Exception\NotSupportedException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\StoreInterface; @@ -30,6 +29,7 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface { use LoggerAwareTrait; + use ExpiringStoreTrait; /** @var StoreInterface[] */ private $stores; @@ -78,6 +78,8 @@ public function save(Key $key) } } + $this->checkNotExpired($key); + if ($this->strategy->isMet($successCount, $storesCount)) { return; } @@ -125,9 +127,7 @@ public function putOffExpiration(Key $key, $ttl) } } - if ($key->isExpired()) { - throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key)); - } + $this->checkNotExpired($key); if ($this->strategy->isMet($successCount, $storesCount)) { return; diff --git a/src/Symfony/Component/Lock/Store/ExpiringStoreTrait.php b/src/Symfony/Component/Lock/Store/ExpiringStoreTrait.php new file mode 100644 index 0000000000000..e22c4405e4151 --- /dev/null +++ b/src/Symfony/Component/Lock/Store/ExpiringStoreTrait.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Lock\Store; + +use Symfony\Component\Lock\Exception\LockExpiredException; +use Symfony\Component\Lock\Key; + +trait ExpiringStoreTrait +{ + private function checkNotExpired(Key $key) + { + if ($key->isExpired()) { + try { + $this->delete($key); + } catch (\Exception $e) { + // swallow exception to not hide the original issue + } + throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key)); + } + } +} diff --git a/src/Symfony/Component/Lock/Store/MemcachedStore.php b/src/Symfony/Component/Lock/Store/MemcachedStore.php index 9b795504c990f..7a51d6149b301 100644 --- a/src/Symfony/Component/Lock/Store/MemcachedStore.php +++ b/src/Symfony/Component/Lock/Store/MemcachedStore.php @@ -13,7 +13,6 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\LockConflictedException; -use Symfony\Component\Lock\Exception\LockExpiredException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\StoreInterface; @@ -24,6 +23,8 @@ */ class MemcachedStore implements StoreInterface { + use ExpiringStoreTrait; + private $memcached; private $initialTtl; /** @var bool */ @@ -64,9 +65,7 @@ public function save(Key $key) $this->putOffExpiration($key, $this->initialTtl); } - if ($key->isExpired()) { - throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key)); - } + $this->checkNotExpired($key); } public function waitAndSave(Key $key) @@ -110,9 +109,7 @@ public function putOffExpiration(Key $key, $ttl) throw new LockConflictedException(); } - if ($key->isExpired()) { - throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key)); - } + $this->checkNotExpired($key); } /** diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 2d7ba45366784..6070c2e74e760 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -14,7 +14,6 @@ use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Exception\LockConflictedException; -use Symfony\Component\Lock\Exception\LockExpiredException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\StoreInterface; @@ -25,6 +24,8 @@ */ class RedisStore implements StoreInterface { + use ExpiringStoreTrait; + private $redis; private $initialTtl; @@ -66,9 +67,7 @@ public function save(Key $key) throw new LockConflictedException(); } - if ($key->isExpired()) { - throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key)); - } + $this->checkNotExpired($key); } public function waitAndSave(Key $key) @@ -94,9 +93,7 @@ public function putOffExpiration(Key $key, $ttl) throw new LockConflictedException(); } - if ($key->isExpired()) { - throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key)); - } + $this->checkNotExpired($key); } /** diff --git a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php index f523780ce1444..bc96ff66f5dfb 100644 --- a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php +++ b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Lock\Tests\Store; +use Symfony\Component\Lock\Exception\LockExpiredException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\StoreInterface; @@ -105,4 +106,28 @@ public function testSetExpiration() $this->assertGreaterThanOrEqual(0, $key->getRemainingLifetime()); $this->assertLessThanOrEqual(1, $key->getRemainingLifetime()); } + + public function testExpiredLockCleaned() + { + $resource = uniqid(__METHOD__, true); + + $key1 = new Key($resource); + $key2 = new Key($resource); + + /** @var StoreInterface $store */ + $store = $this->getStore(); + $key1->reduceLifetime(0); + + $this->assertTrue($key1->isExpired()); + try { + $store->save($key1); + $this->fail('The store shouldn\'t have save an expired key'); + } catch (LockExpiredException $e) { + } + + $this->assertFalse($store->exists($key1)); + + $store->save($key2); + $this->assertTrue($store->exists($key2)); + } } diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 4b0376ff4ef5f..ff0ea508e50f0 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -27,7 +27,7 @@ public function testProcessFailedExceptionThrowsException() $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful'])->setConstructorArgs(['php'])->getMock(); $process->expects($this->once()) ->method('isSuccessful') - ->will($this->returnValue(true)); + ->willReturn(true); if (method_exists($this, 'expectException')) { $this->expectException(\InvalidArgumentException::class); @@ -55,31 +55,31 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([$cmd])->getMock(); $process->expects($this->once()) ->method('isSuccessful') - ->will($this->returnValue(false)); + ->willReturn(false); $process->expects($this->once()) ->method('getOutput') - ->will($this->returnValue($output)); + ->willReturn($output); $process->expects($this->once()) ->method('getErrorOutput') - ->will($this->returnValue($errorOutput)); + ->willReturn($errorOutput); $process->expects($this->once()) ->method('getExitCode') - ->will($this->returnValue($exitCode)); + ->willReturn($exitCode); $process->expects($this->once()) ->method('getExitCodeText') - ->will($this->returnValue($exitText)); + ->willReturn($exitText); $process->expects($this->once()) ->method('isOutputDisabled') - ->will($this->returnValue(false)); + ->willReturn(false); $process->expects($this->once()) ->method('getWorkingDirectory') - ->will($this->returnValue($workingDirectory)); + ->willReturn($workingDirectory); $exception = new ProcessFailedException($process); @@ -103,7 +103,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([$cmd])->getMock(); $process->expects($this->once()) ->method('isSuccessful') - ->will($this->returnValue(false)); + ->willReturn(false); $process->expects($this->never()) ->method('getOutput'); @@ -113,19 +113,19 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $process->expects($this->once()) ->method('getExitCode') - ->will($this->returnValue($exitCode)); + ->willReturn($exitCode); $process->expects($this->once()) ->method('getExitCodeText') - ->will($this->returnValue($exitText)); + ->willReturn($exitText); $process->expects($this->once()) ->method('isOutputDisabled') - ->will($this->returnValue(true)); + ->willReturn(true); $process->expects($this->once()) ->method('getWorkingDirectory') - ->will($this->returnValue($workingDirectory)); + ->willReturn($workingDirectory); $exception = new ProcessFailedException($process); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php index 51fa0cc76f7db..aa81bfc42d983 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php @@ -58,7 +58,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value); * * $propertyAccessor = PropertyAccess::createPropertyAccessor(); * - * echo $propertyAccessor->getValue($object, 'child.name); + * echo $propertyAccessor->getValue($object, 'child.name'); * // equals echo $object->getChild()->getName(); * * This method first tries to find a public getter for each property in the diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index 1aee259a76c8f..b91d1e62ebb95 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php @@ -128,11 +128,11 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections() $car->expects($this->any()) ->method('getStructure') - ->will($this->returnValue($structure)); + ->willReturn($structure); $structure->expects($this->at(0)) ->method('getAxes') - ->will($this->returnValue($axesBefore)); + ->willReturn($axesBefore); $structure->expects($this->at(1)) ->method('removeAxis') ->with('fourth'); @@ -158,7 +158,7 @@ public function testSetValueFailsIfNoAdderNorRemoverFound() $car->expects($this->any()) ->method('getAxes') - ->will($this->returnValue($axesBefore)); + ->willReturn($axesBefore); $this->propertyAccessor->setValue($car, 'axes', $axesAfter); } diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index b87f4bb5c45f7..3a826d86f60a9 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -222,16 +222,18 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa } } - if ((self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) && !empty($host)) { - $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { - $port = ':'.$this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { - $port = ':'.$this->context->getHttpsPort(); - } + if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) { + if ('' !== $host || ('' !== $scheme && 'http' !== $scheme && 'https' !== $scheme)) { + $port = ''; + if ('http' === $scheme && 80 !== $this->context->getHttpPort()) { + $port = ':'.$this->context->getHttpPort(); + } elseif ('https' === $scheme && 443 !== $this->context->getHttpsPort()) { + $port = ':'.$this->context->getHttpsPort(); + } - $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://"; - $schemeAuthority .= $host.$port; + $schemeAuthority = self::NETWORK_PATH === $referenceType || '' === $scheme ? '//' : "$scheme://"; + $schemeAuthority .= $host.$port; + } } if (self::RELATIVE_PATH === $referenceType) { diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index f7d37b2564b12..64714d354dba2 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -71,9 +71,9 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * * The special parameter _fragment will be used as the document fragment suffixed to the final URL. * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param int $referenceType The type of reference to be generated (one of the constants) + * @param string $name The name of the route + * @param mixed[] $parameters An array of parameters + * @param int $referenceType The type of reference to be generated (one of the constants) * * @return string The generated URL * diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 7f64a1f378326..a4d754cb14a6c 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -480,28 +480,27 @@ public function testHostIsCaseInsensitive() public function testDefaultHostIsUsedWhenContextHostIsEmpty() { - $routes = $this->getRoutes('test', new Route('/route', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}', ['http'])); + $routes = $this->getRoutes('test', new Route('/path', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}')); $generator = $this->getGenerator($routes); $generator->getContext()->setHost(''); - $this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); + $this->assertSame('http://my.fallback.host/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); } - public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot() + public function testDefaultHostIsUsedWhenContextHostIsEmptyAndPathReferenceType() { - $routes = $this->getRoutes('test', new Route('/route', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}', ['http', 'https'])); + $routes = $this->getRoutes('test', new Route('/path', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}')); $generator = $this->getGenerator($routes); $generator->getContext()->setHost(''); - $generator->getContext()->setScheme('https'); - $this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); + $this->assertSame('//my.fallback.host/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH)); } - public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot() + public function testAbsoluteUrlFallbackToPathIfHostIsEmptyAndSchemeIsHttp() { - $routes = $this->getRoutes('test', new Route('/route', [], [], [], '', ['http', 'https'])); + $routes = $this->getRoutes('test', new Route('/route')); $generator = $this->getGenerator($routes); $generator->getContext()->setHost(''); @@ -510,6 +509,39 @@ public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot() $this->assertSame('/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); } + public function testAbsoluteUrlFallbackToNetworkIfSchemeIsEmptyAndHostIsNot() + { + $routes = $this->getRoutes('test', new Route('/path')); + + $generator = $this->getGenerator($routes); + $generator->getContext()->setHost('example.com'); + $generator->getContext()->setScheme(''); + + $this->assertSame('//example.com/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); + } + + public function testAbsoluteUrlFallbackToPathIfSchemeAndHostAreEmpty() + { + $routes = $this->getRoutes('test', new Route('/path')); + + $generator = $this->getGenerator($routes); + $generator->getContext()->setHost(''); + $generator->getContext()->setScheme(''); + + $this->assertSame('/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); + } + + public function testAbsoluteUrlWithNonHttpSchemeAndEmptyHost() + { + $routes = $this->getRoutes('test', new Route('/path', [], [], [], '', ['file'])); + + $generator = $this->getGenerator($routes); + $generator->getContext()->setBaseUrl(''); + $generator->getContext()->setHost(''); + + $this->assertSame('file:///path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL)); + } + public function testGenerateNetworkPath() { $routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com', ['http'])); diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index 657f361b4035b..7726dc6fa89f1 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -119,7 +119,7 @@ public function testLoad($className, $routeData = [], $methodArgs = []) $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($routeData)])) + ->willReturn([$this->getAnnotatedRoute($routeData)]) ; $routeCollection = $this->loader->load($className); @@ -165,12 +165,12 @@ public function testClassRouteLoad() $this->reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) + ->willReturn($this->getAnnotatedRoute($classRouteData)) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)])) + ->willReturn([$this->getAnnotatedRoute($methodRouteData)]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass'); @@ -193,12 +193,12 @@ public function testInvokableClassRouteLoadWithMethodAnnotation() $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($classRouteData)])) + ->willReturn([$this->getAnnotatedRoute($classRouteData)]) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -221,19 +221,19 @@ public function testInvokableClassRouteLoadWithClassAnnotation() $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) + ->willReturn($this->getAnnotatedRoute($classRouteData)) ; $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($classRouteData)])) + ->willReturn([$this->getAnnotatedRoute($classRouteData)]) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -263,12 +263,12 @@ public function testInvokableClassMultipleRouteLoad() $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2)])) + ->willReturn([$this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2)]) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -304,12 +304,12 @@ public function testInvokableClassWithMethodRouteLoad() $this->reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) + ->willReturn($this->getAnnotatedRoute($classRouteData)) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)])) + ->willReturn([$this->getAnnotatedRoute($methodRouteData)]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -336,7 +336,7 @@ public function testDefaultRouteName() $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)])) + ->willReturn([$this->getAnnotatedRoute($methodRouteData)]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php index 9465ef05df23c..df96a679e40f9 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php @@ -34,13 +34,13 @@ public function testLoad() $this->reader ->expects($this->any()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->reader ->expects($this->any()) ->method('getClassAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); @@ -58,13 +58,13 @@ public function testLoadIgnoresHiddenDirectories() $this->reader ->expects($this->any()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->reader ->expects($this->any()) ->method('getClassAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); @@ -93,7 +93,7 @@ public function testLoadFileIfLocatedResourceIsFile() $this->reader ->expects($this->any()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index 43eb44e48df9e..066b7c45f54e3 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -62,7 +62,7 @@ public function testLoadVariadic() $route = new Route(['path' => '/path/to/{id}']); $this->reader->expects($this->once())->method('getClassAnnotation'); $this->reader->expects($this->once())->method('getMethodAnnotations') - ->will($this->returnValue([$route])); + ->willReturn([$route]); $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php'); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php index 89dcd5ba3f11d..774e1a1fe5752 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php @@ -89,7 +89,7 @@ public function testExceptionOnMethodNotReturningCollection() ->getMock(); $service->expects($this->once()) ->method('loadRoutes') - ->will($this->returnValue('NOT_A_COLLECTION')); + ->willReturn('NOT_A_COLLECTION'); $loader = new ObjectRouteLoaderForTest(); $loader->loaderMap = ['my_service' => $service]; diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php index e4336cdcac6c5..b14fe98d4d4d5 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php @@ -23,7 +23,7 @@ public function testMissingTrailingSlash() $coll->add('foo', new Route('/foo/')); $matcher = $this->getUrlMatcher($coll); - $matcher->expects($this->once())->method('redirect')->will($this->returnValue([])); + $matcher->expects($this->once())->method('redirect')->willReturn([]); $matcher->match('/foo'); } @@ -51,7 +51,7 @@ public function testSchemeRedirectRedirectsToFirstScheme() ->expects($this->once()) ->method('redirect') ->with('/foo', 'foo', 'ftp') - ->will($this->returnValue(['_route' => 'foo'])) + ->willReturn(['_route' => 'foo']) ; $matcher->match('/foo'); } @@ -78,7 +78,7 @@ public function testSchemeRedirectWithParams() ->expects($this->once()) ->method('redirect') ->with('/foo/baz', 'foo', 'https') - ->will($this->returnValue(['redirect' => 'value'])) + ->willReturn(['redirect' => 'value']) ; $this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz')); } @@ -93,7 +93,7 @@ public function testSlashRedirectWithParams() ->expects($this->once()) ->method('redirect') ->with('/foo/baz/', 'foo', null) - ->will($this->returnValue(['redirect' => 'value'])) + ->willReturn(['redirect' => 'value']) ; $this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz')); } @@ -124,7 +124,7 @@ public function testFallbackPage() $coll->add('bar', new Route('/{name}')); $matcher = $this->getUrlMatcher($coll); - $matcher->expects($this->once())->method('redirect')->with('/foo/')->will($this->returnValue(['_route' => 'foo'])); + $matcher->expects($this->once())->method('redirect')->with('/foo/')->willReturn(['_route' => 'foo']); $this->assertSame(['_route' => 'foo'], $matcher->match('/foo')); } diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index 20afdff484f8a..11d9453e09093 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -28,7 +28,7 @@ public function testImport() $resolver->expects($this->once()) ->method('resolve') ->with('admin_routing.yml', 'yaml') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $originalRoute = new Route('/foo/path'); $expectedCollection = new RouteCollection(); @@ -39,12 +39,12 @@ public function testImport() ->expects($this->once()) ->method('load') ->with('admin_routing.yml', 'yaml') - ->will($this->returnValue($expectedCollection)); + ->willReturn($expectedCollection); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->any()) ->method('getResolver') - ->will($this->returnValue($resolver)); + ->willReturn($resolver); // import the file! $routes = new RouteCollectionBuilder($loader); @@ -107,11 +107,11 @@ public function testFlushOrdering() // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); $loader ->expects($this->once()) ->method('load') - ->will($this->returnValue($importedCollection)); + ->willReturn($importedCollection); $routes = new RouteCollectionBuilder($loader); @@ -296,11 +296,11 @@ public function testFlushSetsPrefixedWithMultipleLevels() // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); $loader ->expects($this->any()) ->method('load') - ->will($this->returnValue($importedCollection)); + ->willReturn($importedCollection); // import this from the /admin route builder $adminRoutes->import('admin.yml', '/imported'); @@ -347,11 +347,11 @@ public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections() $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->any()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); $loader ->expects($this->any()) ->method('load') - ->will($this->returnValue([$firstCollection, $secondCollection])); + ->willReturn([$firstCollection, $secondCollection]); $routeCollectionBuilder = new RouteCollectionBuilder($loader); $routeCollectionBuilder->import('/directory/recurse/*', '/other/', 'glob'); diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php index 589ce5403ac2b..0f46e5317b68c 100644 --- a/src/Symfony/Component/Routing/Tests/RouterTest.php +++ b/src/Symfony/Component/Routing/Tests/RouterTest.php @@ -88,7 +88,7 @@ public function testThatRouteCollectionIsLoaded() $this->loader->expects($this->once()) ->method('load')->with('routing.yml', 'ResourceType') - ->will($this->returnValue($routeCollection)); + ->willReturn($routeCollection); $this->assertSame($routeCollection, $this->router->getRouteCollection()); } @@ -102,7 +102,7 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option) $this->loader->expects($this->once()) ->method('load')->with('routing.yml', null) - ->will($this->returnValue(new RouteCollection())); + ->willReturn(new RouteCollection()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); } @@ -124,7 +124,7 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) $this->loader->expects($this->once()) ->method('load')->with('routing.yml', null) - ->will($this->returnValue(new RouteCollection())); + ->willReturn(new RouteCollection()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index f3f5b4e51f1ad..83f85abda2a12 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -139,7 +139,7 @@ public function serialize() { $serialized = [$this->user, $this->authenticated, $this->roles, $this->attributes]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php index 1ee85363c4925..7677b90d274df 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php @@ -61,7 +61,7 @@ public function serialize() { $serialized = [$this->secret, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php index ddad0a539cd30..7ff0cfe8a5ba4 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php @@ -81,7 +81,7 @@ public function serialize() { $serialized = [$this->credentials, $this->providerKey, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php index 031e4c6b98c76..6e846dd27c18d 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php @@ -96,7 +96,7 @@ public function serialize() { $serialized = [$this->secret, $this->providerKey, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php index 3c052722bee38..9b71520a2b1c0 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php @@ -93,7 +93,7 @@ public function serialize() { $serialized = [$this->credentials, $this->providerKey, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php index 6f8a43b014531..dae682bf31028 100644 --- a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php @@ -26,10 +26,6 @@ public static function isSupported() return true; } - if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { - return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available(); - } - return \function_exists('sodium_crypto_pwhash_str') || \extension_loaded('libsodium'); } @@ -66,8 +62,8 @@ public function isPasswordValid($encoded, $raw, $salt) return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded); } if (\function_exists('sodium_crypto_pwhash_str_verify')) { - $valid = !$this->isPasswordTooLong($raw) && \sodium_crypto_pwhash_str_verify($encoded, $raw); - \sodium_memzero($raw); + $valid = !$this->isPasswordTooLong($raw) && sodium_crypto_pwhash_str_verify($encoded, $raw); + sodium_memzero($raw); return $valid; } @@ -88,12 +84,12 @@ private function encodePasswordNative($raw) private function encodePasswordSodiumFunction($raw) { - $hash = \sodium_crypto_pwhash_str( + $hash = sodium_crypto_pwhash_str( $raw, \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE ); - \sodium_memzero($raw); + sodium_memzero($raw); return $hash; } diff --git a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php index 3c3ea1aa17366..3a5c4f0c4ba81 100644 --- a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php @@ -48,8 +48,8 @@ protected function demergePasswordAndSalt($mergedPasswordSalt) /** * Merges a password and a salt. * - * @param string $password The password to be used - * @param string $salt The salt to be used + * @param string $password The password to be used + * @param string|null $salt The salt to be used * * @return string a merged password and salt * diff --git a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php index e0573051eb273..03cdaca44aef7 100644 --- a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php +++ b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php @@ -23,8 +23,8 @@ interface PasswordEncoderInterface /** * Encodes the raw password. * - * @param string $raw The password to encode - * @param string $salt The salt + * @param string $raw The password to encode + * @param string|null $salt The salt * * @return string The encoded password * @@ -36,9 +36,9 @@ public function encodePassword($raw, $salt); /** * Checks a raw password against an encoded password. * - * @param string $encoded An encoded password - * @param string $raw A raw password - * @param string $salt The salt + * @param string $encoded An encoded password + * @param string $raw A raw password + * @param string|null $salt The salt * * @return bool true if the password is valid, false otherwise * diff --git a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php index cb91b42364bc4..60aea70269a68 100644 --- a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php +++ b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php @@ -46,7 +46,7 @@ public function serialize() { $serialized = [$this->user, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php index 2c6c7344a467f..b34f7d72b9528 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php @@ -26,7 +26,7 @@ class AuthenticationException extends \RuntimeException implements \Serializable /** * Get the token. * - * @return TokenInterface + * @return TokenInterface|null */ public function getToken() { @@ -51,7 +51,7 @@ public function serialize() $this->line, ]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php index ed9fb1bd339b9..9cf253b309238 100644 --- a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php @@ -62,7 +62,7 @@ public function serialize() { $serialized = [parent::serialize(true), $this->messageKey, $this->messageData]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php index b4b8047f341f9..c5e517d01d612 100644 --- a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php +++ b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php @@ -56,7 +56,7 @@ public function serialize() { $serialized = [$this->username, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php index fd2de0ca25d4e..379da4bb61329 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php @@ -177,13 +177,13 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); $provider->expects($this->once()) ->method('supports') - ->will($this->returnValue($supports)) + ->willReturn($supports) ; if (null !== $token) { $provider->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; } elseif (null !== $exception) { $provider->expects($this->once()) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php index 92441ba5fc617..a888d2bf81b9d 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php @@ -58,7 +58,7 @@ protected function getSupportedToken($secret) $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(['getSecret'])->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getSecret') - ->will($this->returnValue($secret)) + ->willReturn($secret) ; return $token; diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php index 55814a994c577..53ff170554222 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -77,7 +77,7 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication() $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); @@ -95,7 +95,7 @@ public function testRetrieveUser() $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->returnValue($user)) + ->willReturn($user) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); @@ -124,7 +124,7 @@ public function testCheckAuthenticationWhenCredentialsAreEmpty() $token ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('')) + ->willReturn('') ; $method->invoke( @@ -140,7 +140,7 @@ public function testCheckAuthenticationWhenCredentialsAre0() $encoder ->expects($this->once()) ->method('isPasswordValid') - ->will($this->returnValue(true)) + ->willReturn(true) ; $provider = $this->getProvider(null, null, $encoder); @@ -151,7 +151,7 @@ public function testCheckAuthenticationWhenCredentialsAre0() $token ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('0')) + ->willReturn('0') ; $method->invoke( @@ -169,7 +169,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid() $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider = $this->getProvider(null, null, $encoder); @@ -179,7 +179,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid() $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token); @@ -193,18 +193,18 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('newFoo')) + ->willReturn('newFoo') ; $provider = $this->getProvider(); @@ -218,18 +218,18 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $provider = $this->getProvider(); @@ -243,7 +243,7 @@ public function testCheckAuthentication() $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') - ->will($this->returnValue(true)) + ->willReturn(true) ; $provider = $this->getProvider(null, null, $encoder); @@ -253,7 +253,7 @@ public function testCheckAuthentication() $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token); @@ -265,7 +265,7 @@ protected function getSupportedToken() $mock ->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue('key')) + ->willReturn('key') ; return $mock; @@ -277,7 +277,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->returnValue($user)) + ->willReturn($user) ; } @@ -293,7 +293,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod $encoderFactory ->expects($this->any()) ->method('getEncoder') - ->will($this->returnValue($passwordEncoder)) + ->willReturn($passwordEncoder) ; return new DaoAuthenticationProvider($userProvider, $userChecker, 'key', $encoderFactory); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php index ef19bc2c32739..bad3072f4a9af 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -113,7 +113,7 @@ public function testQueryForDn() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($collection)) + ->willReturn($collection) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); @@ -121,13 +121,13 @@ public function testQueryForDn() ->expects($this->once()) ->method('escape') ->with('foo', '') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') ->with('{username}', 'foobar') - ->will($this->returnValue($query)) + ->willReturn($query) ; $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); @@ -153,14 +153,14 @@ public function testEmptyQueryResultShouldThrowAnException() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($collection)) + ->willReturn($collection) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php index a101208d681cc..57bce20f5b20c 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php @@ -31,7 +31,7 @@ public function testSupports() $token ->expects($this->once()) ->method('getProviderKey') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $this->assertFalse($provider->supports($token)); } @@ -62,7 +62,7 @@ public function testAuthenticate() $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([])) + ->willReturn([]) ; $provider = $this->getProvider($user); @@ -99,20 +99,20 @@ protected function getSupportedToken($user = false, $credentials = false) if (false !== $user) { $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; } if (false !== $credentials) { $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue($credentials)) + ->willReturn($credentials) ; } $token ->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue('key')) + ->willReturn('key') ; $token->setAttributes(['foo' => 'bar']); @@ -126,7 +126,7 @@ protected function getProvider($user = null, $userChecker = null) if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->returnValue($user)) + ->willReturn($user) ; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 26287693d6b08..6ac7438a064a2 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -69,7 +69,7 @@ public function testAuthenticate() $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->exactly(2)) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])); + ->willReturn(['ROLE_FOO']); $provider = $this->getProvider(); @@ -89,14 +89,14 @@ protected function getSupportedToken($user = null, $secret = 'test') $user ->expects($this->any()) ->method('getRoles') - ->will($this->returnValue([])); + ->willReturn([]); } $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['getProviderKey'])->setConstructorArgs([$user, 'foo', $secret])->getMock(); $token ->expects($this->once()) ->method('getProviderKey') - ->will($this->returnValue('foo')); + ->willReturn('foo'); return $token; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php index 661d23a4e7e21..07c1618f214dd 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php @@ -29,7 +29,7 @@ public function testAuthenticateWhenPreChecksFails() $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) @@ -39,7 +39,7 @@ public function testAuthenticateWhenPreChecksFails() $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') - ->will($this->returnValue($token)); + ->willReturn($token); $provider = $this->getProvider($authenticator, null, $userChecker); @@ -56,7 +56,7 @@ public function testAuthenticateWhenPostChecksFails() $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) @@ -66,7 +66,7 @@ public function testAuthenticateWhenPostChecksFails() $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') - ->will($this->returnValue($token)); + ->willReturn($token); $provider = $this->getProvider($authenticator, null, $userChecker); @@ -78,11 +78,11 @@ public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects() $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue('string-user')); + ->willReturn('string-user'); $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') - ->will($this->returnValue($token)); + ->willReturn($token); $this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token)); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php index 7c306d2f1f0f6..e959d18c53409 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -76,7 +76,7 @@ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface() $provider = $this->getProvider(false, true); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue(null)) + ->willReturn(null) ; $provider->authenticate($this->getSupportedToken()); @@ -96,7 +96,7 @@ public function testAuthenticateWhenPreChecksFails() $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->authenticate($this->getSupportedToken()); @@ -116,7 +116,7 @@ public function testAuthenticateWhenPostChecksFails() $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->authenticate($this->getSupportedToken()); @@ -131,7 +131,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails() $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -150,7 +150,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse() $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -165,24 +165,24 @@ public function testAuthenticate() $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([])) + ->willReturn([]) ; $authToken = $provider->authenticate($token); @@ -199,25 +199,25 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole() $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([$switchUserRole])) + ->willReturn([$switchUserRole]) ; $authToken = $provider->authenticate($token); @@ -236,7 +236,7 @@ protected function getSupportedToken() $mock ->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue('key')) + ->willReturn('key') ; $mock->setAttributes(['foo' => 'bar']); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index 8280366d4af61..564ca872401a6 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -50,7 +50,7 @@ public function serialize() { $serialized = [$this->credentials, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } public function unserialize($serialized) @@ -77,7 +77,7 @@ public function testGetUsername() $this->assertEquals('fabien', $token->getUsername()); $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $user->expects($this->once())->method('getUsername')->will($this->returnValue('fabien')); + $user->expects($this->once())->method('getUsername')->willReturn('fabien'); $token->setUser($user); $this->assertEquals('fabien', $token->getUsername()); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index 0bdd54dc308bd..e1329e37430b6 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php @@ -59,7 +59,7 @@ protected function getUser($roles = ['ROLE_FOO']) $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue($roles)) + ->willReturn($roles) ; return $user; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php index 9ee86a079bc9a..c60a59b375d3e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -72,10 +72,10 @@ protected function getVoterFor2Roles($token, $vote1, $vote2) $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter->expects($this->any()) ->method('vote') - ->will($this->returnValueMap([ + ->willReturnMap([ [$token, null, ['ROLE_FOO'], $vote1], [$token, null, ['ROLE_BAR'], $vote2], - ])) + ]) ; return $voter; @@ -137,7 +137,7 @@ protected function getVoter($vote) $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter->expects($this->any()) ->method('vote') - ->will($this->returnValue($vote)); + ->willReturn($vote); return $voter; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php index 6a07c94f2039c..b4986b0177863 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php @@ -46,7 +46,7 @@ public function testVoteAuthenticatesTokenIfNecessary() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($token)) - ->will($this->returnValue($newToken)); + ->willReturn($newToken); // default with() isn't a strict check $tokenComparison = function ($value) use ($newToken) { @@ -58,7 +58,7 @@ public function testVoteAuthenticatesTokenIfNecessary() ->expects($this->once()) ->method('decide') ->with($this->callback($tokenComparison)) - ->will($this->returnValue(true)); + ->willReturn(true); // first run the token has not been re-authenticated yet, after isGranted is called, it should be equal $this->assertNotSame($newToken, $this->tokenStorage->getToken()); @@ -83,12 +83,12 @@ public function testIsGranted($decide) $token ->expects($this->once()) ->method('isAuthenticated') - ->will($this->returnValue(true)); + ->willReturn(true); $this->accessDecisionManager ->expects($this->once()) ->method('decide') - ->will($this->returnValue($decide)); + ->willReturn($decide); $this->tokenStorage->setToken($token); $this->assertSame($decide, $this->authorizationChecker->isGranted('ROLE_FOO')); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php index 7e435687c8c3c..ce368aa374f7e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -51,7 +51,7 @@ protected function getToken(array $roles, $tokenExpectsGetRoles = true) if ($tokenExpectsGetRoles) { $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue($roles)); + ->willReturn($roles); } return $token; @@ -64,7 +64,7 @@ protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = if ($expressionLanguageExpectsEvaluate) { $mock->expects($this->once()) ->method('evaluate') - ->will($this->returnValue(true)); + ->willReturn(true); } return $mock; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php index 5fb45e08b3925..955ab842e139f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -54,7 +54,7 @@ protected function getToken(array $roles) $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue($roles)); + ->willReturn($roles); return $token; } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php index 3328837ef1f74..41a602f976047 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php @@ -21,19 +21,19 @@ public function testEncodePassword() $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $userMock->expects($this->any()) ->method('getSalt') - ->will($this->returnValue('userSalt')); + ->willReturn('userSalt'); $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); $mockEncoder->expects($this->any()) ->method('encodePassword') ->with($this->equalTo('plainPassword'), $this->equalTo('userSalt')) - ->will($this->returnValue('encodedPassword')); + ->willReturn('encodedPassword'); $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) - ->will($this->returnValue($mockEncoder)); + ->willReturn($mockEncoder); $passwordEncoder = new UserPasswordEncoder($mockEncoderFactory); @@ -46,22 +46,22 @@ public function testIsPasswordValid() $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $userMock->expects($this->any()) ->method('getSalt') - ->will($this->returnValue('userSalt')); + ->willReturn('userSalt'); $userMock->expects($this->any()) ->method('getPassword') - ->will($this->returnValue('encodedPassword')); + ->willReturn('encodedPassword'); $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); $mockEncoder->expects($this->any()) ->method('isPasswordValid') ->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt')) - ->will($this->returnValue(true)); + ->willReturn(true); $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) - ->will($this->returnValue($mockEncoder)); + ->willReturn($mockEncoder); $passwordEncoder = new UserPasswordEncoder($mockEncoderFactory); diff --git a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php index 7a1b572fc7d02..fa3e416e55c15 100644 --- a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php +++ b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php @@ -29,7 +29,7 @@ public function testGetToken() $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $container = $this->createContainer('security.token_storage', $tokenStorage); @@ -45,12 +45,12 @@ public function testGetUser($userInToken, $expectedUser) $token = $this->getMockBuilder(TokenInterface::class)->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue($userInToken)); + ->willReturn($userInToken); $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $container = $this->createContainer('security.token_storage', $tokenStorage); @@ -75,7 +75,7 @@ public function testIsGranted() $authorizationChecker->expects($this->once()) ->method('isGranted') ->with('SOME_ATTRIBUTE', 'SOME_SUBJECT') - ->will($this->returnValue(true)); + ->willReturn(true); $container = $this->createContainer('security.authorization_checker', $authorizationChecker); @@ -90,7 +90,7 @@ private function createContainer($serviceId, $serviceObject) $container->expects($this->atLeastOnce()) ->method('get') ->with($serviceId) - ->will($this->returnValue($serviceObject)); + ->willReturn($serviceObject); return $container; } diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php index 067eef2497b83..05a7fbba19d88 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php @@ -33,7 +33,7 @@ public function testLoadUserByUsername() ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foo')) - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -78,7 +78,7 @@ public function testRefreshUser() $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -98,7 +98,7 @@ public function testRefreshUserAgain() $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -135,7 +135,7 @@ public function testSupportsClass() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider2 = $this->getProvider(); @@ -143,7 +143,7 @@ public function testSupportsClass() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)) + ->willReturn(true) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -157,7 +157,7 @@ public function testSupportsClassWhenNotSupported() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider2 = $this->getProvider(); @@ -165,7 +165,7 @@ public function testSupportsClassWhenNotSupported() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -185,7 +185,7 @@ public function testAcceptsTraversable() $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider(new \ArrayObject([$provider1, $provider2])); diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index 418475ac9381c..39a346433e463 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -50,23 +50,23 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(0)) + ->willReturn(0) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -83,23 +83,23 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(2)) + ->willReturn(2) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -116,33 +116,33 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], 'userpassword' => ['bar', 'baz'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword'); @@ -159,29 +159,29 @@ public function testLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', []))) + ->willReturn(new Entry('foo', [])) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})'); @@ -201,32 +201,32 @@ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword'); @@ -243,32 +243,32 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -285,32 +285,32 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttributeAndWro $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('Foo')) + ->willReturn('Foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -324,33 +324,33 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], 'userpassword' => ['bar'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword'); diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php index 8ec34843eaae0..16eea31c4f0ea 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php @@ -28,7 +28,7 @@ public function testCheckPostAuthPass() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true)); + $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(true); $this->assertNull($checker->checkPostAuth($account)); } @@ -41,7 +41,7 @@ public function testCheckPostAuthCredentialsExpired() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false)); + $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(false); $checker->checkPostAuth($account); } @@ -58,9 +58,9 @@ public function testCheckPreAuthPass() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); - $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); - $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); + $account->expects($this->once())->method('isEnabled')->willReturn(true); + $account->expects($this->once())->method('isAccountNonExpired')->willReturn(true); $this->assertNull($checker->checkPreAuth($account)); } @@ -73,7 +73,7 @@ public function testCheckPreAuthAccountLocked() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(false); $checker->checkPreAuth($account); } @@ -86,8 +86,8 @@ public function testCheckPreAuthDisabled() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); - $account->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); + $account->expects($this->once())->method('isEnabled')->willReturn(false); $checker->checkPreAuth($account); } @@ -100,9 +100,9 @@ public function testCheckPreAuthAccountExpired() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); - $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); - $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); + $account->expects($this->once())->method('isEnabled')->willReturn(true); + $account->expects($this->once())->method('isAccountNonExpired')->willReturn(false); $checker->checkPreAuth($account); } diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index 24c2c7adda187..305b665ea32c9 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -65,7 +65,7 @@ public function testPasswordIsValid() $this->encoder->expects($this->once()) ->method('isPasswordValid') ->with(static::PASSWORD, 'secret', static::SALT) - ->will($this->returnValue(true)); + ->willReturn(true); $this->validator->validate('secret', $constraint); @@ -81,7 +81,7 @@ public function testPasswordIsNotValid() $this->encoder->expects($this->once()) ->method('isPasswordValid') ->with(static::PASSWORD, 'secret', static::SALT) - ->will($this->returnValue(false)); + ->willReturn(false); $this->validator->validate('secret', $constraint); @@ -133,13 +133,13 @@ protected function createUser() $mock ->expects($this->any()) ->method('getPassword') - ->will($this->returnValue(static::PASSWORD)) + ->willReturn(static::PASSWORD) ; $mock ->expects($this->any()) ->method('getSalt') - ->will($this->returnValue(static::SALT)) + ->willReturn(static::SALT) ; return $mock; @@ -157,7 +157,7 @@ protected function createEncoderFactory($encoder = null) $mock ->expects($this->any()) ->method('getEncoder') - ->will($this->returnValue($encoder)) + ->willReturn($encoder) ; return $mock; @@ -171,7 +171,7 @@ protected function createTokenStorage($user = null) $mock ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; return $mock; @@ -183,7 +183,7 @@ protected function createAuthenticationToken($user = null) $mock ->expects($this->any()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; return $mock; diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index b954fc037b907..631c36a0db0ac 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -30,11 +30,11 @@ public function testGetNonExistingToken($namespace, $manager, $storage, $generat $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(false)); + ->willReturn(false); $generator->expects($this->once()) ->method('generateToken') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $storage->expects($this->once()) ->method('setToken') @@ -55,12 +55,12 @@ public function testUseExistingTokenIfAvailable($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(true)); + ->willReturn(true); $storage->expects($this->once()) ->method('getToken') ->with($namespace.'token_id') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $token = $manager->getToken('token_id'); @@ -79,7 +79,7 @@ public function testRefreshTokenAlwaysReturnsNewToken($namespace, $manager, $sto $generator->expects($this->once()) ->method('generateToken') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $storage->expects($this->once()) ->method('setToken') @@ -100,12 +100,12 @@ public function testMatchingTokenIsValid($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(true)); + ->willReturn(true); $storage->expects($this->once()) ->method('getToken') ->with($namespace.'token_id') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $this->assertTrue($manager->isTokenValid(new CsrfToken('token_id', 'TOKEN'))); } @@ -118,12 +118,12 @@ public function testNonMatchingTokenIsNotValid($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(true)); + ->willReturn(true); $storage->expects($this->once()) ->method('getToken') ->with($namespace.'token_id') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $this->assertFalse($manager->isTokenValid(new CsrfToken('token_id', 'FOOBAR'))); } @@ -136,7 +136,7 @@ public function testNonExistingTokenIsNotValid($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(false)); + ->willReturn(false); $storage->expects($this->never()) ->method('getToken'); @@ -152,7 +152,7 @@ public function testRemoveToken($namespace, $manager, $storage) $storage->expects($this->once()) ->method('removeToken') ->with($namespace.'token_id') - ->will($this->returnValue('REMOVED_TOKEN')); + ->willReturn('REMOVED_TOKEN'); $this->assertSame('REMOVED_TOKEN', $manager->removeToken('token_id')); } diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php index ca472f87bc5e8..c3983287fc42b 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -77,7 +77,7 @@ public function testAuthenticationSuccessWithSessionButEmpty() $this->requestWithSession->getSession() ->expects($this->once()) ->method('get') - ->will($this->returnValue(null)); + ->willReturn(null); $redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithSession, $token, 'providerkey'); @@ -96,7 +96,7 @@ public function testAuthenticationSuccessWithSessionAndTarget() $this->requestWithSession->getSession() ->expects($this->once()) ->method('get') - ->will($this->returnValue(self::CUSTOM_SUCCESS_URL)); + ->willReturn(self::CUSTOM_SUCCESS_URL); $redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithSession, $token, 'providerkey'); diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index fa4e9ef623122..7e4d2929b6388 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -51,7 +51,7 @@ public function testHandleSuccess() ->expects($this->once()) ->method('getCredentials') ->with($this->equalTo($this->request)) - ->will($this->returnValue($credentials)); + ->willReturn($credentials); // a clone of the token that should be created internally $uniqueGuardKey = 'my_firewall_0'; @@ -61,7 +61,7 @@ public function testHandleSuccess() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($nonAuthedToken)) - ->will($this->returnValue($authenticateToken)); + ->willReturn($authenticateToken); $this->guardAuthenticatorHandler ->expects($this->once()) @@ -139,18 +139,18 @@ public function testHandleSuccessWithRememberMe() ->expects($this->once()) ->method('getCredentials') ->with($this->equalTo($this->request)) - ->will($this->returnValue(['username' => 'anything_not_empty'])); + ->willReturn(['username' => 'anything_not_empty']); $this->authenticationManager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($authenticateToken)); + ->willReturn($authenticateToken); $successResponse = new Response('Success!'); $this->guardAuthenticatorHandler ->expects($this->once()) ->method('handleAuthenticationSuccess') - ->will($this->returnValue($successResponse)); + ->willReturn($successResponse); $listener = new GuardAuthenticationListener( $this->guardAuthenticatorHandler, @@ -163,7 +163,7 @@ public function testHandleSuccessWithRememberMe() $listener->setRememberMeServices($this->rememberMeServices); $authenticator->expects($this->once()) ->method('supportsRememberMe') - ->will($this->returnValue(true)); + ->willReturn(true); // should be called - we do have a success Response $this->rememberMeServices ->expects($this->once()) @@ -219,7 +219,7 @@ public function testLegacyInterfaceNullCredentials() $authenticatorA ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); // this is not called $this->authenticationManager @@ -256,7 +256,7 @@ public function testLegacyInterfaceKeepsWorking() ->expects($this->once()) ->method('getCredentials') ->with($this->equalTo($this->request)) - ->will($this->returnValue($credentials)); + ->willReturn($credentials); // a clone of the token that should be created internally $uniqueGuardKey = 'my_firewall_0'; @@ -266,7 +266,7 @@ public function testLegacyInterfaceKeepsWorking() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($nonAuthedToken)) - ->will($this->returnValue($authenticateToken)); + ->willReturn($authenticateToken); $this->guardAuthenticatorHandler ->expects($this->once()) @@ -307,11 +307,11 @@ public function testReturnNullToSkipAuth() $authenticatorA ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); $authenticatorB ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); // this is not called $this->authenticationManager @@ -341,7 +341,7 @@ public function testSupportsReturnFalseSkipAuth() $authenticator ->expects($this->once()) ->method('supports') - ->will($this->returnValue(false)); + ->willReturn(false); // this is not called $authenticator @@ -370,13 +370,13 @@ public function testReturnNullFromGetCredentials() $authenticator ->expects($this->once()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); // this will raise exception $authenticator ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); $listener = new GuardAuthenticationListener( $this->guardAuthenticatorHandler, @@ -401,13 +401,13 @@ public function testReturnNullFromGetCredentialsTriggersForAbstractGuardAuthenti $authenticator ->expects($this->once()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); // this will raise exception $authenticator ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); $listener = new GuardAuthenticationListener( $this->guardAuthenticatorHandler, @@ -439,7 +439,7 @@ protected function setUp() $this->event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->request)); + ->willReturn($this->request); $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php index 9950426de9e2f..3bf204ec7f5c0 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -54,7 +54,7 @@ public function testHandleAuthenticationSuccess() $this->guardAuthenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token, $providerKey) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher); $actualResponse = $handler->handleAuthenticationSuccess($this->token, $this->request, $this->guardAuthenticator, $providerKey); @@ -73,7 +73,7 @@ public function testHandleAuthenticationFailure() $this->guardAuthenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $authException) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher); $actualResponse = $handler->handleAuthenticationFailure($authException, $this->request, $this->guardAuthenticator, 'firewall_provider_key'); @@ -90,7 +90,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK ->getMock(); $token->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue($tokenProviderKey)); + ->willReturn($tokenProviderKey); $this->tokenStorage->expects($this->never()) ->method('setToken') @@ -101,7 +101,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK $this->guardAuthenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $authException) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher); $actualResponse = $handler->handleAuthenticationFailure($authException, $this->request, $this->guardAuthenticator, $actualProviderKey); diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index a6636dd2f7f36..26f830e500d4c 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -41,7 +41,7 @@ public function testAuthenticate() $this->preAuthenticationToken->expects($this->exactly(2)) ->method('getGuardProviderKey') // it will return the "1" index, which will match authenticatorB - ->will($this->returnValue('my_cool_firewall_1')); + ->willReturn('my_cool_firewall_1'); $enteredCredentials = [ 'username' => '_weaverryan_test_user', @@ -49,7 +49,7 @@ public function testAuthenticate() ]; $this->preAuthenticationToken->expects($this->atLeastOnce()) ->method('getCredentials') - ->will($this->returnValue($enteredCredentials)); + ->willReturn($enteredCredentials); // authenticators A and C are never called $authenticatorA->expects($this->never()) @@ -61,18 +61,18 @@ public function testAuthenticate() $authenticatorB->expects($this->once()) ->method('getUser') ->with($enteredCredentials, $this->userProvider) - ->will($this->returnValue($mockedUser)); + ->willReturn($mockedUser); // checkCredentials is called $authenticatorB->expects($this->once()) ->method('checkCredentials') ->with($enteredCredentials, $mockedUser) // authentication works! - ->will($this->returnValue(true)); + ->willReturn(true); $authedToken = $this->getMockBuilder(TokenInterface::class)->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) - ->will($this->returnValue($authedToken)); + ->willReturn($authedToken); // user checker should be called $this->userChecker->expects($this->once()) @@ -103,7 +103,7 @@ public function testLegacyAuthenticate() $this->preAuthenticationToken->expects($this->exactly(2)) ->method('getGuardProviderKey') // it will return the "1" index, which will match authenticatorB - ->will($this->returnValue('my_cool_firewall_1')); + ->willReturn('my_cool_firewall_1'); $enteredCredentials = [ 'username' => '_weaverryan_test_user', @@ -111,7 +111,7 @@ public function testLegacyAuthenticate() ]; $this->preAuthenticationToken->expects($this->atLeastOnce()) ->method('getCredentials') - ->will($this->returnValue($enteredCredentials)); + ->willReturn($enteredCredentials); // authenticators A and C are never called $authenticatorA->expects($this->never()) @@ -123,18 +123,18 @@ public function testLegacyAuthenticate() $authenticatorB->expects($this->once()) ->method('getUser') ->with($enteredCredentials, $this->userProvider) - ->will($this->returnValue($mockedUser)); + ->willReturn($mockedUser); // checkCredentials is called $authenticatorB->expects($this->once()) ->method('checkCredentials') ->with($enteredCredentials, $mockedUser) // authentication works! - ->will($this->returnValue(true)); + ->willReturn(true); $authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) - ->will($this->returnValue($authedToken)); + ->willReturn($authedToken); // user checker should be called $this->userChecker->expects($this->once()) @@ -162,21 +162,21 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() $this->preAuthenticationToken->expects($this->any()) ->method('getGuardProviderKey') // the 0 index, to match the only authenticator - ->will($this->returnValue('my_uncool_firewall_0')); + ->willReturn('my_uncool_firewall_0'); $this->preAuthenticationToken->expects($this->atLeastOnce()) ->method('getCredentials') - ->will($this->returnValue('non-null-value')); + ->willReturn('non-null-value'); $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $authenticator->expects($this->once()) ->method('getUser') - ->will($this->returnValue($mockedUser)); + ->willReturn($mockedUser); // checkCredentials is called $authenticator->expects($this->once()) ->method('checkCredentials') // authentication fails :( - ->will($this->returnValue(null)); + ->willReturn(null); $provider = new GuardAuthenticationProvider([$authenticator], $this->userProvider, $providerKey, $this->userChecker); $provider->authenticate($this->preAuthenticationToken); diff --git a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php index 00048226b6aa3..fbdcca1fe8312 100644 --- a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php +++ b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php @@ -78,7 +78,7 @@ public function serialize() { $serialized = [$this->providerKey, parent::serialize(true)]; - return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); + return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null); } /** diff --git a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php index 99c8fcab4e645..de985fb3155da 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php @@ -107,7 +107,7 @@ protected function attemptAuthentication(Request $request) $password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']); } - if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) { + if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) { throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username))); } diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php index 2f54156732948..37bdfdcafb327 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php @@ -85,7 +85,7 @@ protected function attemptAuthentication(Request $request) $password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']); } - if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) { + if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) { throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username))); } diff --git a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php index d17ef7464e7f3..76b1cad349bc2 100644 --- a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php @@ -44,7 +44,10 @@ protected function getPreAuthenticatedData(Request $request) $user = null; if ($request->server->has($this->userKey)) { $user = $request->server->get($this->userKey); - } elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) { + } elseif ( + $request->server->has($this->credentialKey) + && preg_match('#emailAddress=(.+\@.+\.[^,/]+)($|,|/)#', $request->server->get($this->credentialKey), $matches) + ) { $user = $matches[1]; } diff --git a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php index 8ae9581e2c848..1f5356ba9ee58 100644 --- a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php @@ -45,7 +45,7 @@ private function getRequestMatcher($request, $matches) $requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matches')->with($request) - ->will($this->returnValue($matches)); + ->willReturn($matches); return $requestMatcher; } diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index a9c18f3475d5c..a71ad179a3551 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -34,7 +34,7 @@ protected function setUp() $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session)); + $this->request->expects($this->any())->method('getSession')->willReturn($this->session); $this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(['getMessage'])->getMock(); } @@ -47,12 +47,12 @@ public function testForward() ->method('set')->with(Security::AUTHENTICATION_ERROR, $this->exception); $this->httpUtils->expects($this->once()) ->method('createRequest')->with($this->request, '/login') - ->will($this->returnValue($subRequest)); + ->willReturn($subRequest); $response = new Response(); $this->httpKernel->expects($this->once()) ->method('handle')->with($subRequest, HttpKernelInterface::SUB_REQUEST) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, $options, $this->logger); $result = $handler->onAuthenticationFailure($this->request, $this->exception); @@ -65,7 +65,7 @@ public function testRedirect() $response = new Response(); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/login') - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, [], $this->logger); $result = $handler->onAuthenticationFailure($this->request, $this->exception); @@ -92,7 +92,7 @@ public function testExceptionIsPassedInRequestOnForward() $this->httpUtils->expects($this->once()) ->method('createRequest')->with($this->request, '/login') - ->will($this->returnValue($subRequest)); + ->willReturn($subRequest); $this->session->expects($this->never())->method('set'); @@ -117,7 +117,7 @@ public function testForwardIsLogged() $this->httpUtils->expects($this->once()) ->method('createRequest')->with($this->request, '/login') - ->will($this->returnValue($this->getRequest())); + ->willReturn($this->getRequest()); $this->logger ->expects($this->once()) @@ -143,7 +143,7 @@ public function testFailurePathCanBeOverwrittenWithRequest() { $this->request->expects($this->once()) ->method('get')->with('_failure_path') - ->will($this->returnValue('/auth/login')); + ->willReturn('/auth/login'); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/auth/login'); @@ -156,7 +156,7 @@ public function testFailurePathCanBeOverwrittenWithNestedAttributeInRequest() { $this->request->expects($this->once()) ->method('get')->with('_failure_path') - ->will($this->returnValue(['value' => '/auth/login'])); + ->willReturn(['value' => '/auth/login']); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/auth/login'); @@ -171,7 +171,7 @@ public function testFailurePathParameterCanBeOverwritten() $this->request->expects($this->once()) ->method('get')->with('_my_failure_path') - ->will($this->returnValue('/auth/login')); + ->willReturn('/auth/login'); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/auth/login'); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index 531d49227f2c2..8f0ba0728c874 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -24,7 +24,7 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase public function testRequestRedirections(Request $request, $options, $redirectedUrl) { $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $urlGenerator->expects($this->any())->method('generate')->will($this->returnValue('http://localhost/login')); + $urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login'); $httpUtils = new HttpUtils($urlGenerator); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options); @@ -37,7 +37,7 @@ public function testRequestRedirections(Request $request, $options, $redirectedU public function getRequestRedirections() { $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); - $session->expects($this->once())->method('get')->with('_security.admin.target_path')->will($this->returnValue('/admin/dashboard')); + $session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard'); $session->expects($this->once())->method('remove')->with('_security.admin.target_path'); $requestWithSession = Request::create('/'); $requestWithSession->setSession($session); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php index 4f73e5f44cdfa..70923ae31806e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php @@ -53,7 +53,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNo $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationSuccess($this->request, $this->token); @@ -70,7 +70,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator() $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationSuccess($this->request, $this->token); @@ -91,7 +91,7 @@ public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsRetur $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $handler->onAuthenticationSuccess($this->request, $this->token); @@ -102,13 +102,13 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface'); $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue(null)); + ->willReturn(null); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationSuccess($this->request, $this->token); @@ -123,7 +123,7 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNo $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); @@ -140,7 +140,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator() $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); @@ -161,7 +161,7 @@ public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsRetur $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $handler->onAuthenticationFailure($this->request, $this->authenticationException); @@ -172,13 +172,13 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsRetu $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface'); $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue(null)); + ->willReturn(null); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php index 2e43f4ba63d65..999ff728bf461 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php @@ -29,7 +29,7 @@ public function testStart() ->expects($this->once()) ->method('createRedirectResponse') ->with($this->equalTo($request), $this->equalTo('/the/login/path')) - ->will($this->returnValue($response)) + ->willReturn($response) ; $entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', false); @@ -48,7 +48,7 @@ public function testStartWithUseForward() ->expects($this->once()) ->method('createRequest') ->with($this->equalTo($request), $this->equalTo('/the/login/path')) - ->will($this->returnValue($subRequest)) + ->willReturn($subRequest) ; $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); @@ -56,7 +56,7 @@ public function testStartWithUseForward() ->expects($this->once()) ->method('handle') ->with($this->equalTo($subRequest), $this->equalTo(HttpKernelInterface::SUB_REQUEST)) - ->will($this->returnValue($response)) + ->willReturn($response) ; $entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', true); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index 44bbf4423be5b..c4ccdd6a69b2e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -31,7 +31,7 @@ public function testHandleWithValidValues() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->once()) @@ -44,7 +44,7 @@ public function testHandleWithValidValues() ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) - ->will($this->returnValue($token)) + ->willReturn($token) ; $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ @@ -55,13 +55,13 @@ public function testHandleWithValidValues() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -77,7 +77,7 @@ public function testHandleWhenAuthenticationFails() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->never()) @@ -101,13 +101,13 @@ public function testHandleWhenAuthenticationFails() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -125,7 +125,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage ->expects($this->never()) @@ -149,13 +149,13 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -173,7 +173,7 @@ public function testHandleWithASimilarAuthenticatedToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); @@ -190,13 +190,13 @@ public function testHandleWithASimilarAuthenticatedToken() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -214,7 +214,7 @@ public function testHandleWithAnInvalidSimilarToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage ->expects($this->once()) @@ -239,13 +239,13 @@ public function testHandleWithAnInvalidSimilarToken() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php index 92b2270877fbc..0bb27258befe0 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php @@ -28,21 +28,21 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([['foo' => 'bar'], null])) + ->willReturn([['foo' => 'bar'], null]) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('isAuthenticated') - ->will($this->returnValue(true)) + ->willReturn(true) ; $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); @@ -50,7 +50,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() ->expects($this->once()) ->method('decide') ->with($this->equalTo($token), $this->equalTo(['foo' => 'bar']), $this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $listener = new AccessListener( @@ -64,7 +64,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -79,21 +79,21 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([['foo' => 'bar'], null])) + ->willReturn([['foo' => 'bar'], null]) ; $notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $notAuthenticatedToken ->expects($this->any()) ->method('isAuthenticated') - ->will($this->returnValue(false)) + ->willReturn(false) ; $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatedToken ->expects($this->any()) ->method('isAuthenticated') - ->will($this->returnValue(true)) + ->willReturn(true) ; $authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); @@ -101,14 +101,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($notAuthenticatedToken)) - ->will($this->returnValue($authenticatedToken)) + ->willReturn($authenticatedToken) ; $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($notAuthenticatedToken)) + ->willReturn($notAuthenticatedToken) ; $tokenStorage ->expects($this->once()) @@ -121,7 +121,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->expects($this->once()) ->method('decide') ->with($this->equalTo($authenticatedToken), $this->equalTo(['foo' => 'bar']), $this->equalTo($request)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $listener = new AccessListener( @@ -135,7 +135,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -150,7 +150,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([null, null])) + ->willReturn([null, null]) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); @@ -163,7 +163,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $listener = new AccessListener( @@ -177,7 +177,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -192,7 +192,7 @@ public function testHandleWhenTheSecurityTokenStorageHasNoToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $listener = new AccessListener( diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index f6f36415d37e1..15b151a5cf828 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -23,7 +23,7 @@ public function testHandleWithTokenStorageHavingAToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $tokenStorage ->expects($this->never()) @@ -46,7 +46,7 @@ public function testHandleWithTokenStorageHavingNoToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $anonymousToken = new AnonymousToken('TheSecret', 'anon.', []); @@ -58,7 +58,7 @@ public function testHandleWithTokenStorageHavingNoToken() ->with($this->callback(function ($token) { return 'TheSecret' === $token->getSecret(); })) - ->will($this->returnValue($anonymousToken)) + ->willReturn($anonymousToken) ; $tokenStorage diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php index 2eec46b1d16a6..e331542369f53 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php @@ -34,7 +34,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->once()) @@ -47,7 +47,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')) - ->will($this->returnValue($token)) + ->willReturn($token) ; $listener = new BasicAuthenticationListener( @@ -61,7 +61,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -80,7 +80,7 @@ public function testHandleWhenAuthenticationFails() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->never()) @@ -94,7 +94,7 @@ public function testHandleWhenAuthenticationFails() ->expects($this->any()) ->method('start') ->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException')) - ->will($this->returnValue($response)) + ->willReturn($response) ; $listener = new BasicAuthenticationListener( @@ -108,7 +108,7 @@ public function testHandleWhenAuthenticationFails() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) @@ -140,7 +140,7 @@ public function testHandleWithNoUsernameServerParameter() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -156,7 +156,7 @@ public function testHandleWithASimilarAuthenticatedToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); @@ -176,7 +176,7 @@ public function testHandleWithASimilarAuthenticatedToken() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -209,7 +209,7 @@ public function testHandleWithADifferentAuthenticatedToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage ->expects($this->never()) @@ -223,7 +223,7 @@ public function testHandleWithADifferentAuthenticatedToken() ->expects($this->any()) ->method('start') ->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException')) - ->will($this->returnValue($response)) + ->willReturn($response) ; $listener = new BasicAuthenticationListener( @@ -237,7 +237,7 @@ public function testHandleWithADifferentAuthenticatedToken() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php index 3740faec8ba8e..3511c629c1d4e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php @@ -23,7 +23,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(false)) + ->willReturn(false) ; $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); @@ -31,7 +31,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'http'])) + ->willReturn([[], 'http']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -44,7 +44,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->never()) @@ -61,7 +61,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(true)) + ->willReturn(true) ; $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); @@ -69,7 +69,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'https'])) + ->willReturn([[], 'https']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -82,7 +82,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->never()) @@ -99,7 +99,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(false)) + ->willReturn(false) ; $response = new Response(); @@ -109,7 +109,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'https'])) + ->willReturn([[], 'https']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -117,14 +117,14 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->expects($this->once()) ->method('start') ->with($this->equalTo($request)) - ->will($this->returnValue($response)) + ->willReturn($response) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) @@ -142,7 +142,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(true)) + ->willReturn(true) ; $response = new Response(); @@ -152,7 +152,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'http'])) + ->willReturn([[], 'http']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -160,14 +160,14 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->expects($this->once()) ->method('start') ->with($this->equalTo($request)) - ->will($this->returnValue($response)) + ->willReturn($response) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 8df2f40acd116..250b26cfef6ec 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -151,17 +151,17 @@ public function testInvalidTokenInSession($token) $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); $request->expects($this->any()) ->method('hasPreviousSession') - ->will($this->returnValue(true)); + ->willReturn(true); $request->expects($this->any()) ->method('getSession') - ->will($this->returnValue($session)); + ->willReturn($session); $session->expects($this->any()) ->method('get') ->with('_security_key123') - ->will($this->returnValue($token)); + ->willReturn($token); $tokenStorage->expects($this->once()) ->method('setToken') ->with(null); @@ -193,10 +193,10 @@ public function testHandleAddsKernelResponseListener() $event->expects($this->any()) ->method('isMasterRequest') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock())); + ->willReturn($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock()); $dispatcher->expects($this->once()) ->method('addListener') @@ -218,14 +218,14 @@ public function testOnKernelResponseListenerRemovesItself() $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->expects($this->any()) ->method('hasSession') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('isMasterRequest') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); $dispatcher->expects($this->once()) ->method('removeListener') @@ -237,12 +237,12 @@ public function testOnKernelResponseListenerRemovesItself() public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $request->expects($this->any())->method('hasPreviousSession')->will($this->returnValue(false)); + $request->expects($this->any())->method('hasPreviousSession')->willReturn(false); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); - $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); + $event->expects($this->any())->method('getRequest')->willReturn($request); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage->expects($this->once())->method('setToken')->with(null); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php index b5378902ea9f7..5dbd2cd0feb5a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php @@ -47,7 +47,7 @@ public function testHandleWithValidDigest() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->once()) @@ -64,7 +64,7 @@ public function testHandleWithValidDigest() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 53fedebcad705..1dda0ab968c78 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -77,7 +77,7 @@ public function testExceptionWhenEntryPointReturnsBadValue() $event = $this->createEvent(new AuthenticationException()); $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); - $entryPoint->expects($this->once())->method('start')->will($this->returnValue('NOT A RESPONSE')); + $entryPoint->expects($this->once())->method('start')->willReturn('NOT A RESPONSE'); $listener = $this->createExceptionListener(null, null, null, $entryPoint); $listener->onKernelException($event); @@ -106,12 +106,12 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null) { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('Unauthorized', 401))); + $kernel->expects($this->once())->method('handle')->willReturn(new Response('Unauthorized', 401)); $event = $this->createEvent($exception, $kernel); $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); - $httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error'))); + $httpUtils->expects($this->once())->method('createRequest')->willReturn(Request::create('/error')); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error'); $listener->onKernelException($event); @@ -131,7 +131,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn $event = $this->createEvent($exception); $accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock(); - $accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error'))); + $accessDeniedHandler->expects($this->once())->method('handle')->willReturn(new Response('error')); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler); $listener->onKernelException($event); @@ -148,7 +148,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \ $event = $this->createEvent($exception); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); + $tokenStorage->expects($this->once())->method('getToken')->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint()); $listener->onKernelException($event); @@ -171,7 +171,7 @@ public function getAccessDeniedExceptionProvider() private function createEntryPoint(Response $response = null) { $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); - $entryPoint->expects($this->once())->method('start')->will($this->returnValue($response ?: new Response('OK'))); + $entryPoint->expects($this->once())->method('start')->willReturn($response ?: new Response('OK')); return $entryPoint; } @@ -179,7 +179,7 @@ private function createEntryPoint(Response $response = null) private function createTrustResolver($fullFledged) { $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); - $trustResolver->expects($this->once())->method('isFullFledged')->will($this->returnValue($fullFledged)); + $trustResolver->expects($this->once())->method('isFullFledged')->willReturn($fullFledged); return $trustResolver; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index fbcea3d738e70..3796f871562c6 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -30,7 +30,7 @@ public function testHandleUnmatchedPath() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(false)); + ->willReturn(false); $listener->handle($event); } @@ -49,20 +49,20 @@ public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $tokenManager->expects($this->once()) ->method('isTokenValid') - ->will($this->returnValue(true)); + ->willReturn(true); $successHandler->expects($this->once()) ->method('onLogoutSuccess') ->with($request) - ->will($this->returnValue($response = new Response())); + ->willReturn($response = new Response()); $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token = $this->getToken())); + ->willReturn($token = $this->getToken()); $handler = $this->getHandler(); $handler->expects($this->once()) @@ -93,16 +93,16 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $successHandler->expects($this->once()) ->method('onLogoutSuccess') ->with($request) - ->will($this->returnValue($response = new Response())); + ->willReturn($response = new Response()); $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token = $this->getToken())); + ->willReturn($token = $this->getToken()); $handler = $this->getHandler(); $handler->expects($this->once()) @@ -136,12 +136,12 @@ public function testSuccessHandlerReturnsNonResponse() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $successHandler->expects($this->once()) ->method('onLogoutSuccess') ->with($request) - ->will($this->returnValue(null)); + ->willReturn(null); $listener->handle($event); } @@ -162,11 +162,11 @@ public function testCsrfValidationFails() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $tokenManager->expects($this->once()) ->method('isTokenValid') - ->will($this->returnValue(false)); + ->willReturn(false); $listener->handle($event); } @@ -189,7 +189,7 @@ private function getGetResponseEvent() $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request = new Request())); + ->willReturn($request = new Request()); return [$event, $request]; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index 686c7231e6899..57d297103ec80 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -26,7 +26,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $tokenStorage @@ -44,20 +44,20 @@ public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue(null)) + ->willReturn(null) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $this->assertNull($listener->handle($event)); @@ -72,13 +72,13 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $service @@ -97,7 +97,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -114,13 +114,13 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $service @@ -139,7 +139,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $listener->handle($event); @@ -152,7 +152,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $exception = new AuthenticationException('Authentication failed.'); @@ -176,7 +176,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $listener->handle($event); @@ -189,14 +189,14 @@ public function testOnCoreSecurity() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -208,14 +208,14 @@ public function testOnCoreSecurity() $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $listener->handle($event); @@ -228,14 +228,14 @@ public function testSessionStrategy() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -247,40 +247,40 @@ public function testSessionStrategy() $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)) + ->willReturn(true) ; $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->once()) ->method('hasSession') - ->will($this->returnValue(true)) + ->willReturn(true) ; $request ->expects($this->once()) ->method('getSession') - ->will($this->returnValue($session)) + ->willReturn($session) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $sessionStrategy ->expects($this->once()) ->method('onAuthentication') - ->will($this->returnValue(null)) + ->willReturn(null) ; $listener->handle($event); @@ -293,14 +293,14 @@ public function testSessionIsMigratedByDefault() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -312,14 +312,14 @@ public function testSessionIsMigratedByDefault() $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)) + ->willReturn(true) ; $session ->expects($this->once()) @@ -330,20 +330,20 @@ public function testSessionIsMigratedByDefault() $request ->expects($this->any()) ->method('hasSession') - ->will($this->returnValue(true)) + ->willReturn(true) ; $request ->expects($this->any()) ->method('getSession') - ->will($this->returnValue($session)) + ->willReturn($session) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -356,14 +356,14 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -375,7 +375,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $event = $this->getGetResponseEvent(); @@ -383,7 +383,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $dispatcher diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 8739e1b62abb3..1584b66ecee44 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -40,7 +40,7 @@ public function testHandle() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($this->token)) - ->will($this->returnValue($this->token)) + ->willReturn($this->token) ; $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); @@ -48,7 +48,7 @@ public function testHandle() ->expects($this->once()) ->method('createToken') ->with($this->equalTo($this->request), $this->equalTo('secured_area')) - ->will($this->returnValue($this->token)) + ->willReturn($this->token) ; $loginEvent = new InteractiveLoginEvent($this->request, $this->token); @@ -85,7 +85,7 @@ public function testHandlecatchAuthenticationException() ->expects($this->once()) ->method('createToken') ->with($this->equalTo($this->request), $this->equalTo('secured_area')) - ->will($this->returnValue($this->token)) + ->willReturn($this->token) ; $listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher); @@ -108,7 +108,7 @@ protected function setUp() $this->event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->request)) + ->willReturn($this->request) ; $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 709bc4c862f9e..2d22a91d6bdeb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -167,7 +167,7 @@ public function testSwitchUserIsDisallowed() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(false)); + ->willReturn(false); $listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager); $listener->handle($this->event); @@ -183,11 +183,11 @@ public function testSwitchUser() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->once()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $this->userChecker->expects($this->once()) ->method('checkPostAuth')->with($user); @@ -213,11 +213,11 @@ public function testSwitchUserKeepsOtherQueryStringParameters() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->once()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $this->userChecker->expects($this->once()) ->method('checkPostAuth')->with($user); @@ -241,11 +241,11 @@ public function testSwitchUserWithReplacedToken() $this->accessDecisionManager->expects($this->any()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->any()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher @@ -288,11 +288,11 @@ public function testSwitchUserStateless() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->once()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $this->userChecker->expects($this->once()) ->method('checkPostAuth')->with($user); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index f1536db6d25a6..61455745289df 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -38,21 +38,21 @@ public function testHandleWhenUsernameLength($username, $ok) $httpUtils ->expects($this->any()) ->method('checkRequestPath') - ->will($this->returnValue(true)) + ->willReturn(true) ; $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); $failureHandler ->expects($ok ? $this->never() : $this->once()) ->method('onAuthenticationFailure') - ->will($this->returnValue(new Response())) + ->willReturn(new Response()) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')->disableOriginalConstructor()->getMock(); $authenticationManager ->expects($ok ? $this->once() : $this->never()) ->method('authenticate') - ->will($this->returnValue(new Response())) + ->willReturn(new Response()) ; $listener = new UsernamePasswordFormAuthenticationListener( @@ -70,7 +70,7 @@ public function testHandleWhenUsernameLength($username, $ok) $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -154,7 +154,7 @@ public function testHandleNonStringUsernameWith__toString($postOnly) $usernameClass ->expects($this->atLeastOnce()) ->method('__toString') - ->will($this->returnValue('someUsername')); + ->willReturn('someUsername'); $request = Request::create('/login_check', 'POST', ['_username' => $usernameClass]); $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php index ed7acfbe5d7a7..7d2e55906b1d9 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php @@ -43,7 +43,7 @@ private function createListener(array $options = [], $success = true, $matchChec $httpUtils ->expects($this->any()) ->method('checkRequestPath') - ->will($this->returnValue($matchCheckPath)) + ->willReturn($matchCheckPath) ; $authenticationManager = $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock(); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php index c55eaae0f3157..577ca7c38f1b3 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php @@ -56,9 +56,8 @@ public static function dataProviderGetPreAuthenticatedData() /** * @dataProvider dataProviderGetPreAuthenticatedDataNoUser */ - public function testGetPreAuthenticatedDataNoUser($emailAddress) + public function testGetPreAuthenticatedDataNoUser($emailAddress, $credentials) { - $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress; $request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); @@ -76,10 +75,12 @@ public function testGetPreAuthenticatedDataNoUser($emailAddress) public static function dataProviderGetPreAuthenticatedDataNoUser() { - return [ - 'basicEmailAddress' => ['cert@example.com'], - 'emailAddressWithPlusSign' => ['cert+something@example.com'], - ]; + yield ['cert@example.com', 'CN=Sample certificate DN/emailAddress=cert@example.com']; + yield ['cert+something@example.com', 'CN=Sample certificate DN/emailAddress=cert+something@example.com']; + yield ['cert@example.com', 'CN=Sample certificate DN,emailAddress=cert@example.com']; + yield ['cert+something@example.com', 'CN=Sample certificate DN,emailAddress=cert+something@example.com']; + yield ['cert+something@example.com', 'emailAddress=cert+something@example.com,CN=Sample certificate DN']; + yield ['cert+something@example.com', 'emailAddress=cert+something@example.com']; } /** diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php index 04fe3b4ea3052..a8eb97192dc70 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php @@ -28,7 +28,7 @@ public function testGetListeners() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]); @@ -38,7 +38,7 @@ public function testGetListeners() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); @@ -70,7 +70,7 @@ public function testGetListenersWithAnEntryHavingNoRequestMatcher() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]); @@ -105,7 +105,7 @@ public function testGetListenersWithNoMatchingEntry() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]); diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php index 9113890b5e745..673a8be7139d0 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -37,7 +37,7 @@ public function testOnKernelRequestRegistersExceptionListener() ->expects($this->once()) ->method('getListeners') ->with($this->equalTo($request)) - ->will($this->returnValue([[], $listener])) + ->willReturn([[], $listener]) ; $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); @@ -66,7 +66,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() $map ->expects($this->once()) ->method('getListeners') - ->will($this->returnValue([[$first, $second], null])) + ->willReturn([[$first, $second], null]) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') @@ -81,7 +81,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() $event ->expects($this->at(0)) ->method('hasResponse') - ->will($this->returnValue(true)) + ->willReturn(true) ; $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php index 5368f4683c741..a4a76747e5a58 100644 --- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php @@ -92,12 +92,12 @@ public function testCreateRedirectResponseWithRouteName() ->expects($this->any()) ->method('generate') ->with('foobar', [], UrlGeneratorInterface::ABSOLUTE_URL) - ->will($this->returnValue('http://localhost/foo/bar')) + ->willReturn('http://localhost/foo/bar') ; $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()) ; $response = $utils->createRedirectResponse($this->getRequest(), 'foobar'); @@ -125,12 +125,12 @@ public function testCreateRequestWithRouteName() $urlGenerator ->expects($this->once()) ->method('generate') - ->will($this->returnValue('/foo/bar')) + ->willReturn('/foo/bar') ; $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()) ; $subRequest = $utils->createRequest($this->getRequest(), 'foobar'); @@ -229,7 +229,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl() ->expects($this->any()) ->method('match') ->with('/foo/bar') - ->will($this->returnValue(['_route' => 'foobar'])) + ->willReturn(['_route' => 'foobar']) ; $utils = new HttpUtils(null, $urlMatcher); @@ -244,7 +244,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest() ->expects($this->any()) ->method('matchRequest') ->with($request) - ->will($this->returnValue(['_route' => 'foobar'])) + ->willReturn(['_route' => 'foobar']) ; $utils = new HttpUtils(null, $urlMatcher); @@ -323,7 +323,7 @@ private function getUrlGenerator($generatedUrl = '/foo/bar') $urlGenerator ->expects($this->any()) ->method('generate') - ->will($this->returnValue($generatedUrl)) + ->willReturn($generatedUrl) ; return $urlGenerator; diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php index 9936fc933957b..926f8cc4b23af 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -26,7 +26,7 @@ public function testLogout() $httpUtils->expects($this->once()) ->method('createRedirectResponse') ->with($request, '/dashboard') - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new DefaultLogoutSuccessHandler($httpUtils, '/dashboard'); $result = $handler->onLogoutSuccess($request); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php index e32d46e3e577e..cf25d1f77c820 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php @@ -28,7 +28,7 @@ public function testLogout() $request ->expects($this->once()) ->method('getSession') - ->will($this->returnValue($session)) + ->willReturn($session) ; $session diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index 38b8474ffc38b..ade199c0b9224 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -51,7 +51,7 @@ public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserI $service ->expects($this->once()) ->method('processAutoLoginCookie') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service->autoLogin($request); @@ -67,13 +67,13 @@ public function testAutoLogin() $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([])) + ->willReturn([]) ; $service ->expects($this->once()) ->method('processAutoLoginCookie') - ->will($this->returnValue($user)) + ->willReturn($user) ; $returnedToken = $service->autoLogin($request); @@ -131,7 +131,7 @@ public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfa $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $service @@ -154,13 +154,13 @@ public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested() $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->never()) ->method('onLoginSuccess') - ->will($this->returnValue(null)) + ->willReturn(null) ; $this->assertFalse($request->request->has('foo')); @@ -178,13 +178,13 @@ public function testLoginSuccessWhenRememberMeAlwaysIsTrue() $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->once()) ->method('onLoginSuccess') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service->loginSuccess($request, $response, $token); @@ -205,13 +205,13 @@ public function testLoginSuccessWhenRememberMeParameterWithPathIsPositive($value $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->once()) ->method('onLoginSuccess') - ->will($this->returnValue(true)) + ->willReturn(true) ; $service->loginSuccess($request, $response, $token); @@ -232,13 +232,13 @@ public function testLoginSuccessWhenRememberMeParameterIsPositive($value) $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->once()) ->method('onLoginSuccess') - ->will($this->returnValue(true)) + ->willReturn(true) ; $service->loginSuccess($request, $response, $token); @@ -296,7 +296,7 @@ protected function getProvider() $provider ->expects($this->any()) ->method('supportsClass') - ->will($this->returnValue(true)) + ->willReturn(true) ; return $provider; diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index 529b050c40b3e..599a7e81c303b 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -84,7 +84,7 @@ public function testAutoLoginReturnsNullOnNonExistentUser() $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') - ->will($this->returnValue(new PersistentToken('fooclass', 'fooname', 'fooseries', 'foovalue', new \DateTime()))) + ->willReturn(new PersistentToken('fooclass', 'fooname', 'fooseries', 'foovalue', new \DateTime())) ; $service->setTokenProvider($tokenProvider); @@ -111,14 +111,14 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') - ->will($this->returnValue(new PersistentToken('fooclass', 'foouser', 'fooseries', 'anotherFooValue', new \DateTime()))) + ->willReturn(new PersistentToken('fooclass', 'foouser', 'fooseries', 'anotherFooValue', new \DateTime())) ; $tokenProvider ->expects($this->once()) ->method('deleteTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(null)) + ->willReturn(null) ; try { @@ -141,7 +141,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() ->expects($this->once()) ->method('loadTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(new PersistentToken('fooclass', 'username', 'fooseries', 'foovalue', new \DateTime('yesterday')))) + ->willReturn(new PersistentToken('fooclass', 'username', 'fooseries', 'foovalue', new \DateTime('yesterday'))) ; $service->setTokenProvider($tokenProvider); @@ -155,7 +155,7 @@ public function testAutoLogin() $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $userProvider = $this->getProvider(); @@ -163,7 +163,7 @@ public function testAutoLogin() ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foouser')) - ->will($this->returnValue($user)) + ->willReturn($user) ; $service = $this->getService($userProvider, ['name' => 'foo', 'path' => null, 'domain' => null, 'secure' => false, 'httponly' => false, 'always_remember_me' => true, 'lifetime' => 3600]); @@ -175,7 +175,7 @@ public function testAutoLogin() ->expects($this->once()) ->method('loadTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(new PersistentToken('fooclass', 'foouser', 'fooseries', 'foovalue', new \DateTime()))) + ->willReturn(new PersistentToken('fooclass', 'foouser', 'fooseries', 'foovalue', new \DateTime())) ; $service->setTokenProvider($tokenProvider); @@ -200,7 +200,7 @@ public function testLogout() ->expects($this->once()) ->method('deleteTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(null)) + ->willReturn(null) ; $service->setTokenProvider($tokenProvider); @@ -276,13 +276,13 @@ public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInte $account ->expects($this->once()) ->method('getUsername') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); @@ -331,7 +331,7 @@ protected function getProvider() $provider ->expects($this->any()) ->method('supportsClass') - ->will($this->returnValue(true)) + ->willReturn(true) ; return $provider; diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php index 501d3850fa649..465636eb9f77e 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php @@ -95,9 +95,9 @@ private function getEvent($request, $response, $type = HttpKernelInterface::MAST ->disableOriginalConstructor() ->getMock(); - $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); - $event->expects($this->any())->method('isMasterRequest')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST === $type)); - $event->expects($this->any())->method('getResponse')->will($this->returnValue($response)); + $event->expects($this->any())->method('getRequest')->willReturn($request); + $event->expects($this->any())->method('isMasterRequest')->willReturn(HttpKernelInterface::MASTER_REQUEST === $type); + $event->expects($this->any())->method('getResponse')->willReturn($response); return $event; } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index f0d938de84064..f24e4fff80805 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -67,14 +67,14 @@ public function testAutoLoginDoesNotAcceptCookieWithInvalidHash() $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $userProvider ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foouser')) - ->will($this->returnValue($user)) + ->willReturn($user) ; $this->assertNull($service->autoLogin($request)); @@ -92,14 +92,14 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $userProvider ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foouser')) - ->will($this->returnValue($user)) + ->willReturn($user) ; $this->assertNull($service->autoLogin($request)); @@ -117,12 +117,12 @@ public function testAutoLogin($username) $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $userProvider = $this->getProvider(); @@ -130,7 +130,7 @@ public function testAutoLogin($username) ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo($username)) - ->will($this->returnValue($user)) + ->willReturn($user) ; $service = $this->getService($userProvider, ['name' => 'foo', 'always_remember_me' => true, 'lifetime' => 3600]); @@ -191,7 +191,7 @@ public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImp $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $cookies = $response->headers->getCookies(); @@ -214,17 +214,17 @@ public function testLoginSuccess() $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $user ->expects($this->once()) ->method('getUsername') - ->will($this->returnValue('foouser')) + ->willReturn('foouser') ; $token ->expects($this->atLeastOnce()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $cookies = $response->headers->getCookies(); @@ -277,7 +277,7 @@ protected function getProvider() $provider ->expects($this->any()) ->method('supportsClass') - ->will($this->returnValue(true)) + ->willReturn(true) ; return $provider; diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php index 271bc99cc5ba3..6c0df8cb5f2cb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -61,7 +61,7 @@ private function getRequest($session = null) $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); if (null !== $session) { - $request->expects($this->any())->method('getSession')->will($this->returnValue($session)); + $request->expects($this->any())->method('getSession')->willReturn($session); } return $request; diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index 1e47d35f17c7f..2552e300941ce 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -189,7 +189,8 @@ private function flatten(array $array, array &$result, $keySeparator, $parentKey if (\is_array($value)) { $this->flatten($value, $result, $keySeparator, $parentKey.$key.$keySeparator); } else { - $result[$parentKey.$key] = $value; + // Ensures an actual value is used when dealing with true and false + $result[$parentKey.$key] = false === $value ? 0 : (true === $value ? 1 : $value); } } } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 1d0b86afc5d07..a55f1232e7e98 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -72,7 +72,15 @@ public function decode($data, $format, array $context = []) $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; - $decodedData = json_decode($data, $associative, $recursionDepth, $options); + try { + $decodedData = json_decode($data, $associative, $recursionDepth, $options); + } catch (\JsonException $e) { + throw new NotEncodableValueException($e->getMessage(), 0, $e); + } + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) { + return $decodedData; + } if (JSON_ERROR_NONE !== json_last_error()) { throw new NotEncodableValueException(json_last_error_msg()); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index 9b07d709b8cff..76e532c4b7a34 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -38,6 +38,10 @@ public function encode($data, $format, array $context = []) $encodedJson = json_encode($data, $context['json_encode_options']); + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $context['json_encode_options'])) { + return $encodedJson; + } + if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($context['json_encode_options'] & JSON_PARTIAL_OUTPUT_ON_ERROR))) { throw new NotEncodableValueException(json_last_error_msg()); } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 00bd8a2a52faf..b6aea185e789b 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -313,7 +313,7 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, string $format = null*/) { if (\func_num_args() >= 6) { - $format = \func_get_arg(5); + $format = func_get_arg(5); } else { if (__CLASS__ !== \get_class($this)) { $r = new \ReflectionMethod($this, __FUNCTION__); diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 38908a9323ba1..7201e5c095751 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -380,7 +380,7 @@ private function isMaxDepthReached(array $attributesMetadata, $class, $attribute protected function createChildContext(array $parentContext, $attribute/*, string $format = null */) { if (\func_num_args() >= 3) { - $format = \func_get_arg(2); + $format = func_get_arg(2); } else { // will be deprecated in version 4 $format = null; diff --git a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php index 0284ca6ebcc41..185b44be4eeaa 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php @@ -32,7 +32,7 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface ]; /** - * @var MimeTypeGuesserInterface + * @var MimeTypeGuesserInterface|null */ private $mimeTypeGuesser; diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index 854962da6c94d..c1b3dd260e243 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -30,7 +30,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null) { - if (!\class_exists(PropertyAccess::class)) { + if (!class_exists(PropertyAccess::class)) { throw new RuntimeException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.'); } diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 4528e385a7ff6..f63cf67bdf7ed 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -191,7 +191,7 @@ public function denormalize($data, $type, $format = null, array $context = []) public function supportsNormalization($data, $format = null/*, array $context = []*/) { if (\func_num_args() > 2) { - $context = \func_get_arg(2); + $context = func_get_arg(2); } else { if (__CLASS__ !== \get_class($this)) { $r = new \ReflectionMethod($this, __FUNCTION__); @@ -212,7 +212,7 @@ public function supportsNormalization($data, $format = null/*, array $context = public function supportsDenormalization($data, $type, $format = null/*, array $context = []*/) { if (\func_num_args() > 3) { - $context = \func_get_arg(3); + $context = func_get_arg(3); } else { if (__CLASS__ !== \get_class($this)) { $r = new \ReflectionMethod($this, __FUNCTION__); @@ -286,7 +286,7 @@ final public function decode($data, $format, array $context = []) public function supportsEncoding($format/*, array $context = []*/) { if (\func_num_args() > 1) { - $context = \func_get_arg(1); + $context = func_get_arg(1); } else { if (__CLASS__ !== \get_class($this)) { $r = new \ReflectionMethod($this, __FUNCTION__); @@ -307,7 +307,7 @@ public function supportsEncoding($format/*, array $context = []*/) public function supportsDecoding($format/*, array $context = []*/) { if (\func_num_args() > 1) { - $context = \func_get_arg(1); + $context = func_get_arg(1); } else { if (__CLASS__ !== \get_class($this)) { $r = new \ReflectionMethod($this, __FUNCTION__); diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php index 3a84d99dde286..22b86758a590a 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php @@ -32,12 +32,12 @@ protected function setUp() $this->decoder1 ->method('supportsDecoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], true], [self::FORMAT_2, [], false], [self::FORMAT_3, [], false], [self::FORMAT_3, ['foo' => 'bar'], true], - ])); + ]); $this->decoder2 = $this ->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface') @@ -45,11 +45,11 @@ protected function setUp() $this->decoder2 ->method('supportsDecoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], false], [self::FORMAT_2, [], true], [self::FORMAT_3, [], false], - ])); + ]); $this->chainDecoder = new ChainDecoder([$this->decoder1, $this->decoder2]); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php index 48ccbdca0aca6..d9b6251ed93c3 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php @@ -34,12 +34,12 @@ protected function setUp() $this->encoder1 ->method('supportsEncoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], true], [self::FORMAT_2, [], false], [self::FORMAT_3, [], false], [self::FORMAT_3, ['foo' => 'bar'], true], - ])); + ]); $this->encoder2 = $this ->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface') @@ -47,11 +47,11 @@ protected function setUp() $this->encoder2 ->method('supportsEncoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], false], [self::FORMAT_2, [], true], [self::FORMAT_3, [], false], - ])); + ]); $this->chainEncoder = new ChainEncoder([$this->encoder1, $this->encoder2]); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php index 1eb673e8e21ba..7b5131cb533a6 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php @@ -29,6 +29,24 @@ protected function setUp() $this->encoder = new CsvEncoder(); } + public function testTrueFalseValues() + { + $data = [ + 'string' => 'foo', + 'int' => 2, + 'false' => false, + 'true' => true, + ]; + + // Check that true and false are appropriately handled + $this->assertEquals(<<<'CSV' +string,int,false,true +foo,2,0,1 + +CSV + , $this->encoder->encode($data, 'csv')); + } + public function testSupportEncoding() { $this->assertTrue($this->encoder->supportsEncoding('csv')); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php index cac4367ca7995..067f16acf9c36 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php @@ -31,7 +31,7 @@ public function testGetMetadataFor() $decorated ->expects($this->once()) ->method('getMetadataFor') - ->will($this->returnValue($metadata)) + ->willReturn($metadata) ; $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); @@ -47,7 +47,7 @@ public function testHasMetadataFor() $decorated ->expects($this->once()) ->method('hasMetadataFor') - ->will($this->returnValue(true)) + ->willReturn(true) ; $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php index 3d2aaa4c7ccdd..4e32085c98454 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php @@ -55,7 +55,7 @@ public function testCacheExists() $cache ->expects($this->once()) ->method('fetch') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache); @@ -68,7 +68,7 @@ public function testCacheExists() public function testCacheNotExists() { $cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); - $cache->method('fetch')->will($this->returnValue(false)); + $cache->method('fetch')->willReturn(false); $cache->method('save'); $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php index fd456cb9dd4d8..132f3c0806350 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php @@ -39,12 +39,12 @@ public function testDenormalize() $this->serializer->expects($this->at(0)) ->method('denormalize') ->with(['foo' => 'one', 'bar' => 'two']) - ->will($this->returnValue(new ArrayDummy('one', 'two'))); + ->willReturn(new ArrayDummy('one', 'two')); $this->serializer->expects($this->at(1)) ->method('denormalize') ->with(['foo' => 'three', 'bar' => 'four']) - ->will($this->returnValue(new ArrayDummy('three', 'four'))); + ->willReturn(new ArrayDummy('three', 'four')); $result = $this->denormalizer->denormalize( [ @@ -68,7 +68,7 @@ public function testSupportsValidArray() $this->serializer->expects($this->once()) ->method('supportsDenormalization') ->with($this->anything(), __NAMESPACE__.'\ArrayDummy', $this->anything()) - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertTrue( $this->denormalizer->supportsDenormalization( @@ -85,7 +85,7 @@ public function testSupportsInvalidArray() { $this->serializer->expects($this->any()) ->method('supportsDenormalization') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertFalse( $this->denormalizer->supportsDenormalization( diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 894801747540c..d92fad3f80978 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -63,7 +63,7 @@ public function testNormalize() ->expects($this->once()) ->method('normalize') ->with($object, 'any') - ->will($this->returnValue('string_object')) + ->willReturn('string_object') ; $this->assertEquals( diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php index c6b167cbbe13e..4d9a53eeb9374 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php @@ -50,11 +50,11 @@ public function testNormalize() $this->serializer ->expects($this->once()) ->method('normalize') - ->will($this->returnCallback(function ($data) { + ->willReturnCallback(function ($data) { $this->assertArraySubset(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $data); return 'string_object'; - })) + }) ; $this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy())); @@ -70,11 +70,11 @@ public function testCircularNormalize() $this->serializer ->expects($this->once()) ->method('normalize') - ->will($this->returnCallback(function ($data, $format, $context) { + ->willReturnCallback(function ($data, $format, $context) { $this->normalizer->normalize($data['qux'], $format, $context); return 'string_object'; - })) + }) ; $this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy())); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index b30739714b663..fe9d0b8546096 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -65,7 +65,7 @@ public function testNormalize() ->expects($this->once()) ->method('normalize') ->with($object, 'any') - ->will($this->returnValue('string_object')) + ->willReturn('string_object') ; $this->assertEquals( diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index e6282b14debe1..964f1b7bfd6ba 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -44,7 +44,7 @@ "symfony/yaml": "For using the default YAML mapping loader.", "symfony/config": "For using the XML mapping loader.", "symfony/property-access": "For using the ObjectNormalizer.", - "symfony/http-foundation": "To use the DataUriNormalizer.", + "symfony/http-foundation": "For using a MIME type guesser within the DataUriNormalizer.", "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", "doctrine/cache": "For using the default cached annotation reader and metadata cache." }, diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php index 875672d27fff5..3d61ec2716b59 100644 --- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php @@ -26,7 +26,7 @@ public function testRenderDelegatesToSupportedEngine() $secondEngine->expects($this->once()) ->method('render') ->with('template.php', ['foo' => 'bar']) - ->will($this->returnValue('')); + ->willReturn(''); $delegatingEngine = new DelegatingEngine([$firstEngine, $secondEngine]); $result = $delegatingEngine->render('template.php', ['foo' => 'bar']); @@ -53,7 +53,7 @@ public function testStreamDelegatesToSupportedEngine() $streamingEngine->expects($this->once()) ->method('stream') ->with('template.php', ['foo' => 'bar']) - ->will($this->returnValue('')); + ->willReturn(''); $delegatingEngine = new DelegatingEngine([$streamingEngine]); $result = $delegatingEngine->stream('template.php', ['foo' => 'bar']); @@ -77,7 +77,7 @@ public function testExists() $engine->expects($this->once()) ->method('exists') ->with('template.php') - ->will($this->returnValue(true)); + ->willReturn(true); $delegatingEngine = new DelegatingEngine([$engine]); @@ -132,7 +132,7 @@ private function getEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } @@ -144,7 +144,7 @@ private function getStreamingEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } diff --git a/src/Symfony/Component/Translation/Resources/bin/translation-status.php b/src/Symfony/Component/Translation/Resources/bin/translation-status.php index 0d37c3e0aa38b..96ccc105741b7 100644 --- a/src/Symfony/Component/Translation/Resources/bin/translation-status.php +++ b/src/Symfony/Component/Translation/Resources/bin/translation-status.php @@ -73,7 +73,7 @@ $translationStatus = calculateTranslationStatus($originalFilePath, $translationFilePaths); $totalMissingTranslations += array_sum(array_map(function ($translation) { - return \count($translation['missingKeys']); + return count($translation['missingKeys']); }, array_values($translationStatus))); printTranslationStatus($originalFilePath, $translationStatus, $config['verbose_output']); @@ -113,8 +113,8 @@ function calculateTranslationStatus($originalFilePath, $translationFilePaths) $missingKeys = array_diff_key($allTranslationKeys, $translatedKeys); $translationStatus[$locale] = [ - 'total' => \count($allTranslationKeys), - 'translated' => \count($translatedKeys), + 'total' => count($allTranslationKeys), + 'translated' => count($translatedKeys), 'missingKeys' => $missingKeys, ]; } @@ -176,7 +176,7 @@ function printTable($translations, $verboseOutput) textColorNormal(); - if (true === $verboseOutput && \count($translation['missingKeys']) > 0) { + if (true === $verboseOutput && count($translation['missingKeys']) > 0) { echo str_repeat('-', 80).PHP_EOL; echo '| Missing Translations:'.PHP_EOL; diff --git a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php index b4d350ef862e5..bd97a2445c0a5 100644 --- a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php +++ b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php @@ -27,7 +27,7 @@ protected function setUp() public function testCollectEmptyMessages() { $translator = $this->getTranslator(); - $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue([])); + $translator->expects($this->any())->method('getCollectedMessages')->willReturn([]); $dataCollector = new TranslationDataCollector($translator); $dataCollector->lateCollect(); @@ -125,7 +125,7 @@ public function testCollect() ]; $translator = $this->getTranslator(); - $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages)); + $translator->expects($this->any())->method('getCollectedMessages')->willReturn($collectedMessages); $dataCollector = new TranslationDataCollector($translator); $dataCollector->lateCollect(); diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php index 433be2eeaf45c..0f9c8d684e3ba 100644 --- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php @@ -84,10 +84,10 @@ public function testReplace() public function testAddCatalogue() { $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); + $r->expects($this->any())->method('__toString')->willReturn('r'); $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); + $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]); $catalogue->addResource($r); @@ -106,13 +106,13 @@ public function testAddCatalogue() public function testAddFallbackCatalogue() { $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); + $r->expects($this->any())->method('__toString')->willReturn('r'); $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); + $r1->expects($this->any())->method('__toString')->willReturn('r1'); $r2 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r2->expects($this->any())->method('__toString')->will($this->returnValue('r2')); + $r2->expects($this->any())->method('__toString')->willReturn('r2'); $catalogue = new MessageCatalogue('fr_FR', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]); $catalogue->addResource($r); @@ -171,11 +171,11 @@ public function testGetAddResource() { $catalogue = new MessageCatalogue('en'); $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); + $r->expects($this->any())->method('__toString')->willReturn('r'); $catalogue->addResource($r); $catalogue->addResource($r); $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); + $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue->addResource($r1); $this->assertEquals([$r, $r1], $catalogue->getResources()); diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 6c94e14c54bac..0213e22254782 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -100,7 +100,7 @@ public function testCatalogueIsReloadedWhenResourcesAreNoLongerFresh() $loader ->expects($this->exactly(2)) ->method('load') - ->will($this->returnValue($catalogue)) + ->willReturn($catalogue) ; // 1st pass @@ -242,11 +242,11 @@ public function testRefreshCacheWhenResourcesAreNoLongerFresh() { $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); - $resource->method('isFresh')->will($this->returnValue(false)); + $resource->method('isFresh')->willReturn(false); $loader ->expects($this->exactly(2)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr', [], [$resource]))); + ->willReturn($this->getCatalogue('fr', [], [$resource])); // prime the cache $translator = new Translator('fr', null, $this->tmpDir, true); diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php index a39d712bf4be7..fc34ca1a458e2 100644 --- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -57,7 +57,7 @@ class GroupSequence /** * The groups in the sequence. * - * @var string[]|array[]|GroupSequence[] + * @var string[]|string[][]|GroupSequence[] */ public $groups; diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php index f045e62e2ca18..41da39ebd87bc 100644 --- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -120,7 +120,7 @@ public function validate($value, Constraint $constraint) for ($i = 0; $i < 7; ++$i) { // Multiply the first digit by 8, the second by 7, etc. - $checkSum += (8 - $i) * $canonical[$i]; + $checkSum += (8 - $i) * (int) $canonical[$i]; } if (0 !== $checkSum % 11) { diff --git a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php index 554fc6f48b10b..6e69f9ee74c23 100644 --- a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php @@ -83,7 +83,7 @@ public function validate($value, Constraint $constraint) // ^ ^ ^ ^ ^ // = 1+8 + 4 + 6 + 1+6 + 2 for ($i = $length - 2; $i >= 0; $i -= 2) { - $checkSum += array_sum(str_split($value[$i] * 2)); + $checkSum += array_sum(str_split((int) $value[$i] * 2)); } if (0 === $checkSum || 0 !== $checkSum % 10) { diff --git a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php index 5894397da4deb..1ce504331f7f3 100644 --- a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php +++ b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php @@ -22,7 +22,7 @@ interface GroupSequenceProviderInterface * Returns which validation groups should be used for a certain state * of the object. * - * @return string[]|GroupSequence An array of validation groups + * @return string[]|string[][]|GroupSequence An array of validation groups */ public function getGroupSequence(); } diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf index 60f02435f5f27..ccc0c0135a36d 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf @@ -334,6 +334,34 @@ This value should be valid JSON. Ova vrijednost treba biti validan JSON. + + This collection should contain only unique elements. + Ova kolekcija treba sadržavati samo unikatne elemente. + + + This value should be positive. + Ova vrijednost treba biti pozitivna. + + + This value should be either positive or zero. + Ova vrijednost treba biti pozitivna ili jednaka nuli. + + + This value should be negative. + Ova vrijednost treba biti negativna. + + + This value should be either negative or zero. + Ova vrijednost treba biti negativna ili jednaka nuli. + + + This value is not a valid timezone. + Ova vrijednost nije validna vremenska zona. + + + This password has been leaked in a data breach, it must not be used. Please use another password. + Ova lozinka je procurila u nekom od sigurnosnih propusta, te je potrebno koristiti drugu lozinku. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf index 235d44d1bbee9..f4c188d1dd3aa 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -330,6 +330,38 @@ This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. Questo codice identificativo bancario (BIC) non è associato all'IBAN {{ iban }}. + + This value should be valid JSON. + Questo valore dovrebbe essere un JSON valido. + + + This collection should contain only unique elements. + Questa collezione dovrebbe contenere solo elementi unici. + + + This value should be positive. + Questo valore dovrebbe essere positivo. + + + This value should be either positive or zero. + Questo valore dovrebbe essere positivo oppure zero. + + + This value should be negative. + Questo valore dovrebbe essere negativo. + + + This value should be either negative or zero. + Questo valore dovrebbe essere negativo oppure zero. + + + This value is not a valid timezone. + Questo valore non è un fuso orario valido. + + + This password has been leaked in a data breach, it must not be used. Please use another password. + Questa password è trapelata durante una compromissione di dati, non deve essere usata. Si prega di usare una password diversa. + diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index f07adb94238f5..0a11c4741385a 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -109,7 +109,7 @@ protected function createContext() $validator->expects($this->any()) ->method('inContext') ->with($context) - ->will($this->returnValue($contextualValidator)); + ->willReturn($contextualValidator); return $context; } @@ -174,7 +174,7 @@ protected function expectValidateAt($i, $propertyPath, $value, $group) $validator->expects($this->at(2 * $i)) ->method('atPath') ->with($propertyPath) - ->will($this->returnValue($validator)); + ->willReturn($validator); $validator->expects($this->at(2 * $i + 1)) ->method('validate') ->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group); @@ -186,7 +186,7 @@ protected function expectValidateValueAt($i, $propertyPath, $value, $constraints $contextualValidator->expects($this->at(2 * $i)) ->method('atPath') ->with($propertyPath) - ->will($this->returnValue($contextualValidator)); + ->willReturn($contextualValidator); $contextualValidator->expects($this->at(2 * $i + 1)) ->method('validate') ->with($value, $constraints, $group); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 5cffcefd52726..72ca333d3c0a3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -258,11 +258,11 @@ public function testExpressionLanguageUsage() $used = false; $expressionLanguage->method('evaluate') - ->will($this->returnCallback(function () use (&$used) { + ->willReturnCallback(function () use (&$used) { $used = true; return true; - })); + }); $validator = new ExpressionValidator(null, $expressionLanguage); $validator->initialize($this->createContext()); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index b3428e77828ce..65906c5539fee 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -291,11 +291,11 @@ public function testValidMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('image/jpg')); + ->willReturn('image/jpg'); $constraint = new File([ 'mimeTypes' => ['image/png', 'image/jpg'], @@ -315,11 +315,11 @@ public function testValidWildcardMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('image/jpg')); + ->willReturn('image/jpg'); $constraint = new File([ 'mimeTypes' => ['image/*'], @@ -339,11 +339,11 @@ public function testInvalidMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')); + ->willReturn('application/pdf'); $constraint = new File([ 'mimeTypes' => ['image/png', 'image/jpg'], @@ -369,11 +369,11 @@ public function testInvalidWildcardMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')); + ->willReturn('application/pdf'); $constraint = new File([ 'mimeTypes' => ['image/*', 'image/jpg'], diff --git a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php index 3782fba46c3b1..5178bc3b3060d 100644 --- a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php @@ -54,7 +54,7 @@ public function testGetInstanceInvalidValidatorClass() $constraint ->expects($this->once()) ->method('validatedBy') - ->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name')); + ->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name'); $factory = new ContainerConstraintValidatorFactory(new Container()); $factory->getInstance($constraint); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php index 4d0363fd717b4..bd088e0f093d7 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php @@ -31,7 +31,7 @@ public function testWrite() $meta->expects($this->once()) ->method('getClassName') - ->will($this->returnValue('Foo\\Bar')); + ->willReturn('Foo\\Bar'); $this->cache->write($meta); @@ -51,7 +51,7 @@ public function testHas() $meta->expects($this->once()) ->method('getClassName') - ->will($this->returnValue('Foo\\Bar')); + ->willReturn('Foo\\Bar'); $this->assertFalse($this->cache->has('Foo\\Bar'), 'has() returns false when there is no entry'); @@ -68,7 +68,7 @@ public function testRead() $meta->expects($this->once()) ->method('getClassName') - ->will($this->returnValue('Foo\\Bar')); + ->willReturn('Foo\\Bar'); $this->assertFalse($this->cache->read('Foo\\Bar'), 'read() returns false when there is no entry'); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index a7876d7f9168f..9ad85e3f904fe 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -97,7 +97,7 @@ public function testWriteMetadataToCache() [$this->equalTo(self::PARENT_CLASS)], [$this->equalTo(self::INTERFACE_A_CLASS)] ) - ->will($this->returnValue(false)); + ->willReturn(false); $cache->expects($this->exactly(2)) ->method('write') ->withConsecutive( @@ -172,12 +172,12 @@ public function testMetadataCacheWithRuntimeConstraint() $cache ->expects($this->any()) ->method('write') - ->will($this->returnCallback(function ($metadata) { serialize($metadata); })) + ->willReturnCallback(function ($metadata) { serialize($metadata); }) ; $cache->expects($this->any()) ->method('read') - ->will($this->returnValue(false)); + ->willReturn(false); $metadata = $factory->getMetadataFor(self::PARENT_CLASS); $metadata->addConstraint(new Callback(function () {})); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php index f9905386c9601..45b8576f0e16a 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php @@ -46,12 +46,12 @@ public function testReturnsTrueIfAnyLoaderReturnedTrue() $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(true)); + ->willReturn(true); $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(false)); + ->willReturn(false); $chain = new LoaderChain([ $loader1, @@ -68,12 +68,12 @@ public function testReturnsFalseIfNoLoaderReturnedTrue() $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(false)); + ->willReturn(false); $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(false)); + ->willReturn(false); $chain = new LoaderChain([ $loader1, diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php index 1df64de4d99c6..2bc3d11ef6d49 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php @@ -610,9 +610,9 @@ public function testInitializeObjectsOnFirstValidation() $initializer1->expects($this->once()) ->method('initialize') ->with($entity) - ->will($this->returnCallback(function ($object) { + ->willReturnCallback(function ($object) { $object->initialized = true; - })); + }); $initializer2->expects($this->once()) ->method('initialize') diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index 93d0ce2b41b73..ae8b40fa0eacd 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -53,13 +53,9 @@ public static function castObject($obj, $class, $hasDebugInfo = false) $hasDebugInfo = $class->hasMethod('__debugInfo'); $class = $class->name; } - if ($hasDebugInfo) { - $a = $obj->__debugInfo(); - } elseif ($obj instanceof \Closure) { - $a = []; - } else { - $a = (array) $obj; - } + + $a = $obj instanceof \Closure ? [] : (array) $obj; + if ($obj instanceof \__PHP_Incomplete_Class) { return $a; } @@ -93,6 +89,17 @@ public static function castObject($obj, $class, $hasDebugInfo = false) } } + if ($hasDebugInfo && \is_array($debugInfo = $obj->__debugInfo())) { + foreach ($debugInfo as $k => $v) { + if (!isset($k[0]) || "\0" !== $k[0]) { + $k = self::PREFIX_VIRTUAL.$k; + } + + unset($a[$k]); + $a[$k] = $v; + } + } + return $a; } diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index 3b030b734ae1d..40289a930b7be 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -95,7 +95,7 @@ public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNeste if (3 === $i) { $now = new \DateTimeImmutable(); $dates[] = sprintf('%s more', ($end = $p->getEndDate()) - ? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u'))) + ? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u'))) : $p->recurrences - $i ); break; diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index f418aa089488d..9e50f23501154 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -79,7 +79,7 @@ protected function doClone($var) } if ($gk !== $k) { $fromObjCast = true; - $refs = $vals = \array_values($queue[$i]); + $refs = $vals = array_values($queue[$i]); break; } } @@ -90,7 +90,7 @@ protected function doClone($var) if ($zvalIsRef = $vals[$k] === $cookie) { $vals[$k] = &$stub; // Break hard references to make $queue completely unset($stub); // independent from the original structure - if ($v instanceof Stub && isset($hardRefs[\spl_object_hash($v)])) { + if ($v instanceof Stub && isset($hardRefs[spl_object_hash($v)])) { $vals[$k] = $refs[$k] = $v; if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) { ++$v->value->refCount; @@ -100,7 +100,7 @@ protected function doClone($var) } $refs[$k] = $vals[$k] = new Stub(); $refs[$k]->value = $v; - $h = \spl_object_hash($refs[$k]); + $h = spl_object_hash($refs[$k]); $hardRefs[$h] = &$refs[$k]; $values[$h] = $v; $vals[$k]->handle = ++$refsCounter; @@ -118,22 +118,22 @@ protected function doClone($var) if ('' === $v) { continue 2; } - if (!\preg_match('//u', $v)) { + if (!preg_match('//u', $v)) { $stub = new Stub(); $stub->type = Stub::TYPE_STRING; $stub->class = Stub::STRING_BINARY; if (0 <= $maxString && 0 < $cut = \strlen($v) - $maxString) { $stub->cut = $cut; - $stub->value = \substr($v, 0, -$cut); + $stub->value = substr($v, 0, -$cut); } else { $stub->value = $v; } - } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = \mb_strlen($v, 'UTF-8') - $maxString) { + } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) { $stub = new Stub(); $stub->type = Stub::TYPE_STRING; $stub->class = Stub::STRING_UTF8; $stub->cut = $cut; - $stub->value = \mb_substr($v, 0, $maxString, 'UTF-8'); + $stub->value = mb_substr($v, 0, $maxString, 'UTF-8'); } else { continue 2; } @@ -179,7 +179,7 @@ protected function doClone($var) case \is_object($v): case $v instanceof \__PHP_Incomplete_Class: - if (empty($objRefs[$h = $hashMask ^ \hexdec(\substr(\spl_object_hash($v), $hashOffset, \PHP_INT_SIZE))])) { + if (empty($objRefs[$h = $hashMask ^ hexdec(substr(spl_object_hash($v), $hashOffset, \PHP_INT_SIZE))])) { $stub = new Stub(); $stub->type = Stub::TYPE_OBJECT; $stub->class = \get_class($v); @@ -190,7 +190,7 @@ protected function doClone($var) if (Stub::TYPE_OBJECT !== $stub->type || null === $stub->value) { break; } - $h = $hashMask ^ \hexdec(\substr(\spl_object_hash($stub->value), $hashOffset, \PHP_INT_SIZE)); + $h = $hashMask ^ hexdec(substr(spl_object_hash($stub->value), $hashOffset, \PHP_INT_SIZE)); $stub->handle = $h; } $stub->value = null; @@ -213,7 +213,7 @@ protected function doClone($var) if (empty($resRefs[$h = (int) $v])) { $stub = new Stub(); $stub->type = Stub::TYPE_RESOURCE; - if ('Unknown' === $stub->class = @\get_resource_type($v)) { + if ('Unknown' === $stub->class = @get_resource_type($v)) { $stub->class = 'Closed'; } $stub->value = $v; diff --git a/src/Symfony/Component/Workflow/Tests/RegistryTest.php b/src/Symfony/Component/Workflow/Tests/RegistryTest.php index 25d2e1cc3b5ea..adedfc93b74d0 100644 --- a/src/Symfony/Component/Workflow/Tests/RegistryTest.php +++ b/src/Symfony/Component/Workflow/Tests/RegistryTest.php @@ -92,9 +92,9 @@ private function createSupportStrategy($supportedClassName) { $strategy = $this->getMockBuilder(SupportStrategyInterface::class)->getMock(); $strategy->expects($this->any())->method('supports') - ->will($this->returnCallback(function ($workflow, $subject) use ($supportedClassName) { + ->willReturnCallback(function ($workflow, $subject) use ($supportedClassName) { return $subject instanceof $supportedClassName; - })); + }); return $strategy; }