diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6a3604dff7aad..72ea7cfa3e9c0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ | Q | A | ------------- | --- -| Branch? | 6.3 for features / 5.4, 6.0, 6.1, or 6.2 for bug fixes +| Branch? | 6.3 for features / 5.4 or 6.2 for bug fixes | Bug fix? | yes/no | New feature? | yes/no | Deprecations? | yes/no diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 7dc6fb938da19..49056fd7816eb 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -18,12 +18,13 @@ permissions: jobs: tests: - name: Tests + name: Integration runs-on: Ubuntu-20.04 strategy: matrix: php: ['7.2', '8.0'] + fail-fast: false services: postgres: @@ -44,11 +45,11 @@ jobs: LDAP_USERS: a LDAP_PASSWORDS: a redis: - image: redis:6.0.0 + image: redis:6.2.8 ports: - 16379:6379 redis-cluster: - image: grokzen/redis-cluster:latest + image: grokzen/redis-cluster:6.2.8 ports: - 7000:7000 - 7001:7001 @@ -60,7 +61,7 @@ jobs: env: STANDALONE: 1 redis-sentinel: - image: bitnami/redis-sentinel:6.0 + image: bitnami/redis-sentinel:6.2.8 ports: - 26379:26379 env: diff --git a/.github/workflows/intl-data-tests.yml b/.github/workflows/intl-data-tests.yml index fef1dd1140374..8c1b2d5e1f64f 100644 --- a/.github/workflows/intl-data-tests.yml +++ b/.github/workflows/intl-data-tests.yml @@ -21,7 +21,7 @@ permissions: jobs: tests: - name: Tests + name: Intl data runs-on: Ubuntu-20.04 steps: diff --git a/.github/workflows/package-tests.yml b/.github/workflows/package-tests.yml index f04bacd0170d3..a6955dbead472 100644 --- a/.github/workflows/package-tests.yml +++ b/.github/workflows/package-tests.yml @@ -1,4 +1,4 @@ -name: Package +name: Verify Packages on: pull_request: @@ -10,7 +10,7 @@ permissions: jobs: verify: - name: Verify + name: Verify Packages runs-on: Ubuntu-20.04 steps: - name: Checkout code @@ -42,7 +42,7 @@ jobs: } _correct_license_file() { - FIRST_LINE="Copyright (c) $(date +"%Y") Fabien Potencier" + FIRST_LINE="Copyright (c) $(date +"%Y")-present Fabien Potencier" PACKAGE_FIRST_LINE=$(head -1 ${1}) if [[ "$FIRST_LINE" != "$PACKAGE_FIRST_LINE" ]]; then echo "First line of the license file is wrong. Maybe it is the wrong year?" diff --git a/.github/workflows/phpunit-bridge.yml b/.github/workflows/phpunit-bridge.yml index 0c7bc859bb6ef..2229bbc866655 100644 --- a/.github/workflows/phpunit-bridge.yml +++ b/.github/workflows/phpunit-bridge.yml @@ -1,4 +1,4 @@ -name: PhpUnitBridge +name: Lint PhpUnitBridge on: push: @@ -21,7 +21,7 @@ permissions: jobs: lint: - name: Lint + name: Lint PhpUnitBridge runs-on: Ubuntu-20.04 steps: diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 532cf6b9033cd..f8f8f4d92db5e 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -1,4 +1,4 @@ -name: Static analysis +name: Psalm on: pull_request: ~ @@ -19,12 +19,30 @@ jobs: name: Psalm runs-on: Ubuntu-20.04 + env: + php-version: '8.1' + extensions: json,couchbase,memcached,mongodb,redis,xsl,ldap,dom steps: + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ env.php-version }} + extensions: ${{ env.extensions }} + key: cache-v1 # can be any string, change to clear the extension cache. + + - name: Cache extensions + uses: actions/cache@v3 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' - extensions: "json,couchbase,memcached,mongodb,redis,xsl,ldap,dom" + php-version: ${{ env.php-version }} + extensions: ${{ env.extensions }} ini-values: "memory_limit=-1" coverage: none @@ -42,7 +60,7 @@ jobs: ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev composer remove --dev --no-update --no-interaction symfony/phpunit-bridge - composer require --no-progress --ansi psalm/phar phpunit/phpunit:^9.5 php-http/discovery psr/event-dispatcher mongodb/mongodb + composer require --no-progress --ansi --no-plugins psalm/phar phpunit/phpunit:^9.5 php-http/discovery psr/event-dispatcher mongodb/mongodb - name: Generate Psalm baseline run: | diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7ffdbdb335f3b..69192939d066a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,4 +1,4 @@ -name: PHPUnit +name: Unit Tests on: push: @@ -18,7 +18,7 @@ permissions: jobs: tests: - name: Tests + name: Unit Tests env: extensions: amqp,apcu,igbinary,intl,mbstring,memcached,redis-5.3.4 @@ -28,7 +28,7 @@ jobs: include: - php: '7.2' - php: '7.4' - - php: '8.0' + - php: '8.1' mode: high-deps - php: '8.1' mode: low-deps @@ -124,7 +124,7 @@ jobs: echo SYMFONY_VERSION=$SYMFONY_VERSION >> $GITHUB_ENV echo COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev >> $GITHUB_ENV - echo SYMFONY_REQUIRE=">=$([ '${{ matrix.mode }}' = low-deps ] && echo 3.4 || echo $SYMFONY_VERSION)" >> $GITHUB_ENV + echo SYMFONY_REQUIRE=">=$([ '${{ matrix.mode }}' = low-deps ] && echo 4.4 || echo $SYMFONY_VERSION)" >> $GITHUB_ENV [[ "${{ matrix.mode }}" = *-deps ]] && mv composer.json.phpunit composer.json || true - name: Install dependencies diff --git a/CHANGELOG-5.4.md b/CHANGELOG-5.4.md index 98dbf9b1e7c86..ffa6be4840403 100644 --- a/CHANGELOG-5.4.md +++ b/CHANGELOG-5.4.md @@ -7,6 +7,47 @@ in 5.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/v5.4.0...v5.4.1 +* 5.4.21 (2023-02-28) + + * bug #49526 [Security] Migrate the session on login only when the user changes (nicolas-grekas) + * bug #49516 [Workflow] display label with new lines + colours properly when rendering a PUML dump (alexislefebvre) + * bug #48965 [TwigBridge] Allow floats in html5 input type number field (wimhendrikx) + * bug #48833 [Translation] Handle the translation of empty strings (javiereguiluz) + * bug #49292 [VarDumper] Fix error when reflected class has default Enum parameter in constructor (kapiwko) + * bug #49493 [FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes (delbertooo) + * bug #49484 [Validator] Fix translation of AtLeastOneOf constraint message (alexandre-daubois) + * bug #48998 [Validator] Sync IBAN formats with Swift IBAN registry (smelesh) + * bug #49405 [MonologBridge] FirePHPHandler::onKernelResponse throws PHP 8.1 deprecation when no user agent is set (juagarc4) + * bug #49421 [TwigBridge] do not drop embed label classes (xabbuh) + * bug #49422 [Cache][Messenger] fixed CallbackInterface support in async expiration handler (AdamKatzDev) + * bug #49441 [Contracts] Fix setting $container before calling parent::setContainer in ServiceSubscriberTrait (edsrzf) + * bug #49272 [Workflow] remove new lines from workflow metadata (alexislefebvre) + * bug #49427 [WebProfilerBundle] Render original (not encoded) email headers (1ed) + * bug #49368 [BC Break] Make data providers for abstract test cases static (OskarStark, alexandre-daubois) + * bug #49385 [Notifier] Make `TransportTestCase` data providers static (alexandre-daubois) + * bug #49395 fix trying to load Memcached before checking we can (nicolas-grekas) + * bug #49326 [Notifier] Fix notifier profiler when transport name is null (fabpot) + * bug #49265 [HttpKernel] Fix setting the session on the main request when it's started by a subrequest (nicolas-grekas) + * bug #49353 [Cache] Only validate dbindex parameter when applicable (loevgaard) + * bug #49346 [ErrorHandler] Do not patch return statements in closures (wouterj) + * bug #49334 [DependencyInjection] keep `proxy` tag on original definition when decorating (kbond) + * bug #47946 [FrameworkBundle] Fix checkboxes check assertions (MatTheCat) + * bug #49301 [HttpClient] Fix data collector (fancyweb) + * bug #49310 [Notifier][WebProfilerBundle] Ignore messages whose `getNotification` returns `null` (MatTheCat) + * bug #49299 [HttpClient] Fix over-encoding of URL parts to match browser's behavior (nicolas-grekas) + * bug #49214 [Mailer] add Sender to the list of bypassed headers (xabbuh) + * bug #49245 [Serializer] Fix CsvEncoder decode on empty data (cazak) + * bug #49249 [Dotenv] Fix phpdoc Dotenv (alamirault) + * bug #49248 [Config] Fix phpdoc nullable (alamirault) + * bug #48880 [Response] `getMaxAge()` returns non-negative integer (pkruithof, fabpot) + * bug #49207 [PropertyInfo] Add meaningful message when `phpstan/phpdoc-parser` is not installed when using `PhpStanExtractor` (alexandre-daubois) + * bug #49220 [Validator] Make ConstraintValidatorTestCase compatible with PHPUnit 10 (gjuric) + * bug #49226 [WebProfilerBundle] Disable Turbo for debug toolbar links (javiereguiluz) + * bug #49223 [WebProfilerBundle] Fix some minor HTML issues (javiereguiluz) + * bug #49146 [PropertyInfo] fail with a meaningful error when a needed package is missing (xabbuh) + * bug #49187 [Ldap] Allow multiple values on `extra_fields` (mvhirsch) + * bug #49128 [DependencyInjection] Fix combinatory explosion when autowiring union and intersection types (nicolas-grekas) + * 5.4.20 (2023-02-01) * bug #49141 [HttpFoundation] Fix bad return type in IpUtils::checkIp4() (tristankretzer) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 016a12f53a9c9..e9f3d759e500f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -48,19 +48,21 @@ The Symfony Connect username in parenthesis allows to get more information - Benjamin Eberlei (beberlei) - Igor Wiedler - HypeMC (hypemc) + - Alexandre Daubois (alexandre-daubois) - Valentin Udaltsov (vudaltsov) - Vasilij Duško (staff) - Matthias Pigulla (mpdude) - - Laurent VOULLEMIER (lvo) + - Gabriel Ostrolucký (gadelat) - Antoine Makdessi (amakdessi) + - Laurent VOULLEMIER (lvo) - Pierre du Plessis (pierredup) - Grégoire Paris (greg0ire) - - Gabriel Ostrolucký (gadelat) - Jonathan Wage (jwage) - - Alexandre Daubois (alexandre-daubois) - Titouan Galopin (tgalopin) + - Antoine Lamirault - David Maicher (dmaicher) - Alexander Schranz (alexander-schranz) + - Gábor Egyed (1ed) - Alexandre Salomé (alexandresalome) - William DURAND - ornicar @@ -70,18 +72,16 @@ The Symfony Connect username in parenthesis allows to get more information - Diego Saint Esteben (dosten) - stealth35 ‏ (stealth35) - Alexander Mols (asm89) - - Gábor Egyed (1ed) - Francis Besset (francisbesset) - Vasilij Dusko | CREATION - Bulat Shakirzyanov (avalanche123) + - Mathieu Lechat (mat_the_cat) - Iltar van der Berg - Miha Vrhovnik (mvrhov) - Mathieu Piot (mpiot) - Saša Stamenković (umpirsky) - - Antoine Lamirault - - Alex Pott - - Mathieu Lechat (mat_the_cat) - Vincent Langlet (deviling) + - Alex Pott - Guilhem N (guilhemn) - Vladimir Reznichenko (kalessil) - Sarah Khalil (saro0h) @@ -93,6 +93,7 @@ The Symfony Connect username in parenthesis allows to get more information - Peter Rehm (rpet) - Henrik Bjørnskov (henrikbjorn) - David Buchmann (dbu) + - Ruud Kamphuis (ruudk) - Konstantin Myakshin (koc) - Andrej Hudec (pulzarraider) - Julien Falque (julienfalque) @@ -116,7 +117,6 @@ The Symfony Connect username in parenthesis allows to get more information - Dariusz Górecki (canni) - Maxime Helias (maxhelias) - Ener-Getick - - Ruud Kamphuis (ruudk) - Sebastiaan Stok (sstok) - Jérôme Vasseur (jvasseur) - Ion Bazan (ionbazan) @@ -126,12 +126,12 @@ The Symfony Connect username in parenthesis allows to get more information - Daniel Holmes (dholmes) - Toni Uebernickel (havvg) - Bart van den Burg (burgov) + - Yanick Witschi (toflar) - Jordan Alliot (jalliot) - Smaine Milianni (ismail1432) - John Wards (johnwards) - Dariusz Ruminski - Lars Strojny (lstrojny) - - Yanick Witschi (toflar) - Antoine Hérault (herzult) - Konstantin.Myakshin - Rokas Mikalkėnas (rokasm) @@ -164,6 +164,7 @@ The Symfony Connect username in parenthesis allows to get more information - Włodzimierz Gajda (gajdaw) - Christian Scheb - Guillaume (guill) + - Christopher Hertel (chertel) - Tugdual Saunier (tucksaun) - Jacob Dreesen (jdreesen) - Joel Wurtz (brouznouf) @@ -172,7 +173,6 @@ The Symfony Connect username in parenthesis allows to get more information - zairig imad (zairigimad) - Hugo Alliaume (kocal) - Colin Frei - - Christopher Hertel (chertel) - Javier Spagnoletti (phansys) - excelwebzone - Phil Taylor (prazgod) @@ -189,6 +189,7 @@ The Symfony Connect username in parenthesis allows to get more information - Gabriel Caruso - Anthony GRASSIOT (antograssiot) - Jan Rosier (rosier) + - Andreas Möller (localheinz) - Daniel Wehner (dawehner) - Hugo Monteiro (monteiro) - Baptiste Leduc (korbeil) @@ -206,7 +207,6 @@ The Symfony Connect username in parenthesis allows to get more information - Valentine Boineau (valentineboineau) - Jeroen Noten (jeroennoten) - Gocha Ossinkine (ossinkine) - - Andreas Möller (localheinz) - OGAWA Katsuhiro (fivestar) - Jhonny Lidfors (jhonne) - Martin Hujer (martinhujer) @@ -224,6 +224,7 @@ The Symfony Connect username in parenthesis allows to get more information - Colin O'Dell (colinodell) - Sebastian Hörl (blogsh) - Ben Davies (bendavies) + - Alexis Lefebvre - Daniel Gomes (danielcsgomes) - Michael Käfer (michael_kaefer) - Hidenori Goto (hidenorigoto) @@ -271,6 +272,7 @@ The Symfony Connect username in parenthesis allows to get more information - Zmey - Clemens Tolboom - Oleg Voronkovich + - Alan Poulain (alanpoulain) - Helmer Aaviksoo - Michał (bambucha15) - Remon van de Kamp @@ -298,7 +300,7 @@ The Symfony Connect username in parenthesis allows to get more information - Yoann RENARD (yrenard) - Thomas Lallement (raziel057) - Timothée Barray (tyx) - - Alexis Lefebvre + - Sébastien Alfaiate (seb33300) - James Halsall (jaitsu) - Mikael Pajunen - Warnar Boekkooi (boekkooi) @@ -338,7 +340,6 @@ The Symfony Connect username in parenthesis allows to get more information - Islam Israfilov (islam93) - Oleg Andreyev (oleg.andreyev) - Daniel Gorgan - - Sébastien Alfaiate (seb33300) - Hendrik Luup (hluup) - Martin Herndl (herndlm) - Ruben Gonzalez (rubenrua) @@ -358,7 +359,6 @@ The Symfony Connect username in parenthesis allows to get more information - Stepan Anchugov (kix) - bronze1man - sun (sun) - - Alan Poulain (alanpoulain) - Larry Garfield (crell) - Fabien Villepinte - SiD (plbsid) @@ -413,6 +413,7 @@ The Symfony Connect username in parenthesis allows to get more information - Mantis Development - Pablo Lozano (arkadis) - quentin neyrat (qneyrat) + - Dane Powell - Antonio Jose Cerezo (ajcerezo) - Marcin Szepczynski (czepol) - Lescot Edouard (idetox) @@ -452,6 +453,7 @@ The Symfony Connect username in parenthesis allows to get more information - AnneKir - Tobias Weichart - Miro Michalicka + - Peter Kruithof (pkruithof) - M. Vondano - Xavier Perez - Arjen Brouwer (arjenjb) @@ -525,18 +527,17 @@ The Symfony Connect username in parenthesis allows to get more information - Jérôme Tanghe (deuchnord) - Kim Hemsø Rasmussen (kimhemsoe) - Maximilian Reichel (phramz) - - Dane Powell - jaugustin - Dmytro Borysovskyi (dmytr0) - Mathias STRASSER (roukmoute) - Pascal Luna (skalpa) - Wouter Van Hecke - - Peter Kruithof (pkruithof) - Michael Holm (hollo) - Giso Stallenberg (gisostallenberg) - Blanchon Vincent (blanchonvincent) - William Arslett (warslett) - Jérémy REYNAUD (babeuloula) + - Maximilian Beckers (maxbeckers) - Christian Schmidt - Gonzalo Vilaseca (gonzalovilaseca) - Vadim Borodavko (javer) @@ -576,6 +577,7 @@ The Symfony Connect username in parenthesis allows to get more information - Evert Harmeling (evertharmeling) - Jan Decavele (jandc) - Gustavo Piltcher + - Joachim Løvgaard (loevgaard) - Shakhobiddin - Grenier Kévin (mcsky_biig) - Stepan Tanasiychuk (stfalcon) @@ -620,6 +622,7 @@ The Symfony Connect username in parenthesis allows to get more information - Lorenzo Millucci (lmillucci) - Jérôme Tamarelle (jtamarelle-prismamedia) - Emil Masiakowski + - Sergey Melesh (sergex) - Alexandre Parent - Angelov Dejan (angelov) - DT Inier (gam6itko) @@ -775,7 +778,6 @@ The Symfony Connect username in parenthesis allows to get more information - Daniel Tschinder - Diego Agulló (aeoris) - Tomasz Ignatiuk - - Joachim Løvgaard (loevgaard) - vladimir.reznichenko - Kai - Lee Rowlands @@ -850,6 +852,7 @@ The Symfony Connect username in parenthesis allows to get more information - Matheo Daninos (mathdns) - Niklas Fiekas - Mark Challoner (markchalloner) + - Allison Guilhem (a_guilhem) - Markus Bachmann (baachi) - Roger Guasch (rogerguasch) - Luis Tacón (lutacon) @@ -862,6 +865,7 @@ The Symfony Connect username in parenthesis allows to get more information - Joost van Driel (j92) - ampaze - Arturs Vonda + - Michael Hirschler (mvhirsch) - Xavier Briand (xavierbriand) - Daniel Badura - vagrant @@ -907,7 +911,6 @@ The Symfony Connect username in parenthesis allows to get more information - ReenExe - Fabian Lange (codingfabian) - Yoshio HANAWA - - Sergey Melesh (sergex) - Toon Verwerft (veewee) - Jiri Barous - Gert de Pagter @@ -1076,7 +1079,6 @@ The Symfony Connect username in parenthesis allows to get more information - Arnaud Frézet - Nicolas Martin (cocorambo) - luffy1727 - - Allison Guilhem (a_guilhem) - LHommet Nicolas (nicolaslh) - Sebastian Blum - Amirreza Shafaat (amirrezashafaat) @@ -1138,7 +1140,6 @@ The Symfony Connect username in parenthesis allows to get more information - Maxime Douailin - Jean Pasdeloup - Laurent Moreau - - Michael Hirschler (mvhirsch) - Javier López (loalf) - tamar peled - Reinier Kip @@ -1152,6 +1153,7 @@ The Symfony Connect username in parenthesis allows to get more information - Karl Shea - dantleech - Valentin + - Jack Worman (jworman) - Sebastian Marek (proofek) - Łukasz Chruściel (lchrusciel) - Jan Vernieuwe (vernija) @@ -1234,6 +1236,7 @@ The Symfony Connect username in parenthesis allows to get more information - Oleg Mifle - Michael Devery (mickadoo) - Loïc Ovigne (oviglo) + - Gregor Nathanael Meyer (spackmat) - Antoine Corcy - Markkus Millend - Clément @@ -1301,7 +1304,6 @@ The Symfony Connect username in parenthesis allows to get more information - Konstantin Bogomolov - Mark Spink - Cesar Scur (cesarscur) - - Maximilian Beckers (maxbeckers) - Kevin (oxfouzer) - Paweł Wacławczyk (pwc) - Sagrario Meneses @@ -1986,9 +1988,11 @@ The Symfony Connect username in parenthesis allows to get more information - Antoine Bluchet (soyuka) - Patrick Kaufmann - Anton Dyshkant + - Ramunas Pabreza - Kirill Nesmeyanov (serafim) - Reece Fowell (reecefowell) - Muhammad Aakash + - Charly Goblet (_mocodo) - Guillaume Gammelin - Valérian Galliat - d-ph @@ -2041,7 +2045,6 @@ The Symfony Connect username in parenthesis allows to get more information - Anne-Sophie Bachelard - Marvin Butkereit - Ben Oman - - Jack Worman (jworman) - Chris de Kok - Andreas Kleemann (andesk) - Hubert Moreau (hmoreau) @@ -2110,7 +2113,9 @@ The Symfony Connect username in parenthesis allows to get more information - gr1ev0us - Léo VINCENT - mlazovla + - Markus Baumer - Max Beutel + - adnen chouibi - Nathan Sepulveda - Antanas Arvasevicius - Pierre Dudoret @@ -2137,12 +2142,14 @@ The Symfony Connect username in parenthesis allows to get more information - allison guilhem - benatespina (benatespina) - Denis Kop + - Kamil Szalewski (szal1k) - Jean-Guilhem Rouel (jean-gui) - Ivan Yivoff - EdgarPE - jfcixmedia - Dominic Tubach - Martijn Evers + - Dustin Wilson - Benjamin Paap (benjaminpaap) - Christian - ju1ius @@ -2154,6 +2161,7 @@ The Symfony Connect username in parenthesis allows to get more information - Martynas Narbutas - Bailey Parker - curlycarla2004 + - Kevin Auvinet - Antanas Arvasevicius - Kris Kelly - Eddie Abou-Jaoude (eddiejaoude) @@ -2180,6 +2188,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jonathan Hedstrom - Peter Smeets (darkspartan) - Julien Bianchi (jubianchi) + - Michael Dawart (mdawart) - Robert Meijers - Tijs Verkoyen - James Sansbury @@ -2230,6 +2239,7 @@ The Symfony Connect username in parenthesis allows to get more information - Mehrdad - Eduardo García Sanz (coma) - fduch (fduch) + - Takashi Kanemoto (ttskch) - David de Boer (ddeboer) - Eno Mullaraj (emullaraj) - Stephan Vock (glaubinix) @@ -2250,6 +2260,7 @@ The Symfony Connect username in parenthesis allows to get more information - John Espiritu (johnillo) - Oxan van Leeuwen - pkowalczyk + - Alexandre parent - Soner Sayakci - Max Voloshin (maxvoloshin) - Nicolas Fabre (nfabre) @@ -2274,6 +2285,7 @@ The Symfony Connect username in parenthesis allows to get more information - Alain Flaus (halundra) - tsufeki - Philipp Strube + - Wim Hendrikx - Petar Obradović - Clement Herreman (clemherreman) - Dan Ionut Dumitriu (danionut90) @@ -2287,6 +2299,7 @@ The Symfony Connect username in parenthesis allows to get more information - Alberto Aldegheri - Dalibor Karlović - Cyril Vermandé (cyve) + - Raul Garcia Canet (juagarc4) - Dmitri Petmanson - heccjj - Alexandre Melard @@ -2298,6 +2311,7 @@ The Symfony Connect username in parenthesis allows to get more information - Tobias Stöckler - Mario Young - martkop26 + - Evan Shaw - Sander Hagen - Ilia (aliance) - cilefen (cilefen) @@ -2322,6 +2336,7 @@ The Symfony Connect username in parenthesis allows to get more information - Rubén Calvo (rubencm) - Abdul.Mohsen B. A. A - Cédric Girard + - Robert Worgul - pthompson - Malaney J. Hill - Patryk Kozłowski @@ -2510,6 +2525,7 @@ The Symfony Connect username in parenthesis allows to get more information - Ergie Gonzaga - Matthew J Mucklo - AnrDaemon + - Tristan Kretzer - Charly Terrier (charlypoppins) - Emre Akinci (emre) - psampaz (psampaz) @@ -2563,6 +2579,7 @@ The Symfony Connect username in parenthesis allows to get more information - Antonio Peric-Mazar (antonioperic) - César Suárez (csuarez) - Bjorn Twachtmann (dotbjorn) + - Goran (gog) - Tobias Genberg (lorceroth) - Michael Simonson (mikes) - Nicolas Badey (nico-b) @@ -2663,7 +2680,9 @@ The Symfony Connect username in parenthesis allows to get more information - Kris Buist - Houziaux mike - Phobetor + - Yoann MOROCUTTI - Markus + - Zayan Goripov - Janusz Mocek - Thomas Chmielowiec - shdev @@ -2684,6 +2703,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jeremiah VALERIE - Mike Francis - Nil Borodulia + - Adam Katz - Almog Baku (almogbaku) - Arrakis (arrakis) - Benjamin Schultz (bschultz) @@ -2693,6 +2713,7 @@ The Symfony Connect username in parenthesis allows to get more information - Nicolas Tallefourtané (nicolab) - Botond Dani (picur) - Radek Wionczek (rwionczek) + - Florent Destremau - Nick Stemerdink - David Stone - Vincent Bouzeran @@ -2709,6 +2730,7 @@ The Symfony Connect username in parenthesis allows to get more information - Lorenzo Adinolfi (loru88) - Ahmed Shamim Hassan (me_shaon) - Michal Kurzeja (mkurzeja) + - Adrien Roches (neirda24) - Nicolas Bastien (nicolas_bastien) - Nikola Svitlica (thecelavi) - Andrew Zhilin (zhil) @@ -2894,6 +2916,7 @@ The Symfony Connect username in parenthesis allows to get more information - Matt Lehner - Helmut Januschka - Hein Zaw Htet™ + - Kieran - Ruben Kruiswijk - Cosmin-Romeo TANASE - Michael J @@ -2909,6 +2932,7 @@ The Symfony Connect username in parenthesis allows to get more information - Alessandro Loffredo - Ian Phillips - Remi Collet + - Nicolas Dousson - Haritz - Matthieu Prat - Brieuc Thomas @@ -2930,6 +2954,7 @@ The Symfony Connect username in parenthesis allows to get more information - Alan Chen - Maerlyn - Even André Fiskvik + - tourze - Erik van Wingerden - Valouleloup - Alexis MARQUIS @@ -2994,7 +3019,6 @@ The Symfony Connect username in parenthesis allows to get more information - Pablo Monterde Perez (plebs) - Jimmy Leger (redpanda) - Mokhtar Tlili (sf-djuba) - - Gregor Nathanael Meyer (spackmat) - Marcin Szepczynski (szepczynski) - Simone Di Maulo (toretto460) - Cyrille Jouineau (tuxosaurus) @@ -3138,6 +3162,7 @@ The Symfony Connect username in parenthesis allows to get more information - Wojciech Skorodecki - Kevin Frantz - Neophy7e + - Evert Jan Hakvoort - bokonet - Arrilot - andrey-tech @@ -3227,6 +3252,7 @@ The Symfony Connect username in parenthesis allows to get more information - Juan Ases García (ases) - Siragusa (asiragusa) - Daniel Basten (axhm3a) + - Albert Bakker (babbert) - Bernd Matzner (bmatzner) - Bram Tweedegolf (bram_tweedegolf) - Brandon Kelly (brandonkelly) @@ -3234,6 +3260,7 @@ The Symfony Connect username in parenthesis allows to get more information - Kousuke Ebihara (co3k) - Loïc Vernet (coil) - Christoph Vincent Schaefer (cvschaefer) + - Kamil Piwowarski (cyklista) - Damon Jones (damon__jones) - David Courtey (david-crty) - Łukasz Giza (destroyer) diff --git a/LICENSE b/LICENSE index 008370457251e..0138f8f071351 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/UPGRADE-5.2.md b/UPGRADE-5.2.md index a1c4a137cb72e..bf21fcaf105bf 100644 --- a/UPGRADE-5.2.md +++ b/UPGRADE-5.2.md @@ -1,6 +1,11 @@ UPGRADE FROM 5.1 to 5.2 ======================= +Console +------- + + * `Application` now runs `pcntl_async_signals(true)` when constucted; if the code of your CLI application depends on pcntl signals being synchronous, you should either call `pcntl_async_signals(false)` or implement `SignalableCommandInterface::handleSignal()` + DependencyInjection ------------------- diff --git a/UPGRADE-5.4.md b/UPGRADE-5.4.md index 97fda0a80e38f..f5ca02ba653d0 100644 --- a/UPGRADE-5.4.md +++ b/UPGRADE-5.4.md @@ -63,6 +63,12 @@ Lock * Deprecate usage of `PdoStore` with a `Doctrine\DBAL\Connection` or a DBAL url, use the new `DoctrineDbalStore` instead * Deprecate usage of `PostgreSqlStore` with a `Doctrine\DBAL\Connection` or a DBAL url, use the new `DoctrineDbalPostgreSqlStore` instead +Mailer +------ + + * The following data providers for `TransportFactoryTestCase` are now static: `supportsProvider()`, `createProvider()`, `unsupportedSchemeProvider()`and `incompleteDsnProvider()` + * The following data providers for `TransportTestCase` are now static: `toStringProvider()`, `supportedMessagesProvider()` and `unsupportedMessagesProvider()` + Messenger --------- @@ -75,6 +81,12 @@ Monolog * Deprecate `ResetLoggersWorkerSubscriber` to reset buffered logs in messenger workers, use `framework.messenger.reset_on_message` option in FrameworkBundle messenger configuration instead. +Notifier +-------- + + * The following data providers for `TransportTestCase` are now static: `toStringProvider()`, `supportedMessagesProvider()` and `unsupportedMessagesProvider()` + * The `TransportTestCase::createTransport()` method is now static + SecurityBundle -------------- @@ -102,6 +114,7 @@ SecurityBundle Security -------- + * `AccessDecisionStrategyTestCase::provideStrategyTests()` is now static * Deprecate `AuthenticationEvents::AUTHENTICATION_FAILURE`, use the `LoginFailureEvent` instead * Deprecate the `$authenticationEntryPoint` argument of `ChannelListener`, and add `$httpPort` and `$httpsPort` arguments * Deprecate `RetryAuthenticationEntryPoint`, this code is now inlined in the `ChannelListener` @@ -191,3 +204,9 @@ Security $token = new PreAuthenticatedToken($user, $firewallName, $roles); $token = new SwitchUserToken($user, $firewallName, $roles, $originalToken); ``` + +Translation +----------- + + * The following data providers for `ProviderFactoryTestCase` are now static: `supportsProvider()`, `createProvider()`, `unsupportedSchemeProvider()`and `incompleteDsnProvider()` + * `ProviderTestCase::toStringProvider()` is now static diff --git a/phpunit b/phpunit index e26fecd73cc9d..3ab931750e179 100755 --- a/phpunit +++ b/phpunit @@ -10,12 +10,10 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { exit(1); } if (!getenv('SYMFONY_PHPUNIT_VERSION')) { - if (\PHP_VERSION_ID < 70200) { - putenv('SYMFONY_PHPUNIT_VERSION=7.5'); - } elseif (\PHP_VERSION_ID < 70300) { + if (\PHP_VERSION_ID < 70300) { putenv('SYMFONY_PHPUNIT_VERSION=8.5.26'); } else { - putenv('SYMFONY_PHPUNIT_VERSION=9.5'); + putenv('SYMFONY_PHPUNIT_VERSION=9.6'); } } if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS') && \PHP_VERSION_ID >= 70300) { diff --git a/src/Symfony/Bridge/Doctrine/LICENSE b/src/Symfony/Bridge/Doctrine/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bridge/Doctrine/LICENSE +++ b/src/Symfony/Bridge/Doctrine/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 25cc33fb4ae9f..8146adb9f8e87 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -134,7 +134,7 @@ public function testSerialization($param, array $types, $expected) $this->assertTrue($collectedQueries['default'][0]['runnable']); } - public function paramProvider(): array + public static function paramProvider(): array { return [ ['some value', [], 'some value'], diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php index f0962eff3132d..64bee1203b781 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php @@ -107,7 +107,7 @@ public function testSerialization($param, array $types, $expected, $explainable, $this->assertSame($runnable, $collectedQueries['default'][0]['runnable']); } - public function paramProvider(): array + public static function paramProvider(): array { return [ ['some value', [], 'some value', true], diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index b6f415e2145f5..97cec26cf7ed7 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -84,7 +84,7 @@ public function testFixManagersAutoMappingsWithTwoAutomappings() $method->invoke($this->extension, $emConfigs, $bundles); } - public function getAutomappingData() + public static function getAutomappingData() { return [ [ @@ -197,7 +197,7 @@ public function testMappingTypeDetection() $this->assertSame($mappingType, \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute'); } - public function providerBasicDrivers() + public static function providerBasicDrivers() { return [ ['doctrine.orm.cache.apc.class', ['type' => 'apc']], @@ -276,7 +276,7 @@ public function testUnrecognizedCacheDriverException() $this->invokeLoadCacheDriver($objectManager, $container, $cacheName); } - public function providerBundles() + public static function providerBundles() { yield ['AnnotationsBundle', 'annotation', '/Entity']; yield ['AnnotationsOneLineBundle', 'annotation', '/Entity']; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index 7d253dc59b85d..50e083234d7cd 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -262,7 +262,7 @@ public function testEmbeddedIdentifierName() $loader->getEntitiesByIds('id.value', [1, '', 2, 3, 'foo']); } - public function provideGuidEntityClasses() + public static function provideGuidEntityClasses() { return [ ['Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'], @@ -270,7 +270,7 @@ public function provideGuidEntityClasses() ]; } - public function provideUidEntityClasses() + public static function provideUidEntityClasses() { return [ ['Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'], diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 652f9d67ebe18..f211f291f873a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -35,7 +35,7 @@ public function testTypeGuesser(string $type, $expected) $this->assertEquals($expected, $this->getGuesser($classMetadata)->guessType('TestEntity', 'field')); } - public function requiredType() + public static function requiredType() { yield [Types::DATE_IMMUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE)]; yield [Types::DATE_MUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE)]; @@ -49,66 +49,63 @@ public function requiredType() yield [Types::DATETIMETZ_MUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE)]; } - /** - * @dataProvider requiredProvider - */ - public function testRequiredGuesser($classMetadata, $expected) - { - $this->assertEquals($expected, $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); - } - - public function requiredProvider() + public function testRequiredGuesserSimpleFieldNotNullable() { - $return = []; - - // Simple field, not nullable $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false); - $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(true, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // Simple field, nullable + public function testRequiredGuesserSimpleFieldNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true); - $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(false, Guess::MEDIUM_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-one, nullable (by default) + public function testRequiredGuesserOneToOneNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [[]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); - $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(false, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-one, nullable (explicit) + public function testRequiredGuesserOneToOneExplicitNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => true]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); - $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(false, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-one, not nullable + public function testRequiredGuesserOneToOneNotNullable() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => false]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); - $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; + $this->assertEquals(new ValueGuess(true, Guess::HIGH_CONFIDENCE), $this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); + } - // One-to-many, no clue + public function testRequiredGuesserOneToMany() + { $classMetadata = $this->createMock(ClassMetadata::class); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false); - $return[] = [$classMetadata, null]; - - return $return; + $this->assertNull($this->getGuesser($classMetadata)->guessRequired('TestEntity', 'field')); } private function getGuesser(ClassMetadata $classMetadata) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 66eccf108c36a..d8491588fe357 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -35,12 +35,12 @@ use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Forms; -use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest; +use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTestCase; use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; -class EntityTypeTest extends BaseTypeTest +class EntityTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Bridge\Doctrine\Form\Type\EntityType'; @@ -158,7 +158,7 @@ public function testChoiceTranslationDomainIsDisabledByDefault($expanded) } } - public function choiceTranslationDomainProvider() + public static function choiceTranslationDomainProvider() { return [ [false], diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index 710e87a15e0b8..91061632815d8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -43,7 +43,7 @@ public function testLog($sql, $params, $logParams) $dbalLogger->startQuery($sql, $params); } - public function getLogFixtures() + public static function getLogFixtures() { return [ ['SQL', null, []], diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index dd7dabcc87db1..e524ebceff0b8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -44,7 +44,8 @@ public function testResetService() $registry->resetManager(); $this->assertSame($foo, $container->get('foo')); - $this->assertObjectNotHasAttribute('bar', $foo); + $this->assertInstanceOf(\stdClass::class, $foo); + $this->assertFalse(property_exists($foo, 'bar')); } /** diff --git a/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php b/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php index 2b8a25b4ee588..3e24f83f690f2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php @@ -79,7 +79,7 @@ private function getResourceFromString(string $str) return $res; } - public function provideExecuteMethod(): array + public static function provideExecuteMethod(): array { return [ 'executeStatement' => [ @@ -173,7 +173,7 @@ public function testWithParamBound(callable $executeMethod) $this->assertGreaterThan(0, $debug[1]['executionMS']); } - public function provideEndTransactionMethod(): array + public static function provideEndTransactionMethod(): array { return [ 'commit' => [ @@ -223,7 +223,7 @@ public function testTransaction(callable $endTransactionMethod, string $expected $this->assertGreaterThan(0, $debug[6]['executionMS']); } - public function provideExecuteAndEndTransactionMethods(): array + public static function provideExecuteAndEndTransactionMethods(): array { return [ 'commit and exec' => [ diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index 42a8d6560eb08..bbe4b6ab10019 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -146,7 +146,7 @@ public function testExtractEnum() $this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', [])); } - public function typesProvider() + public static function typesProvider() { $provider = [ ['id', [new Type(Type::BUILTIN_TYPE_INT)]], diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php index 8fd4b8b0a04b6..06114aeea0050 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php @@ -140,7 +140,7 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string $this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform)); } - public function provideSqlDeclarations(): array + public static function provideSqlDeclarations(): array { return [ [new PostgreSQLPlatform(), 'UUID'], diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php index 9b904b89d9d62..d49afc5f97ec4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php @@ -152,7 +152,7 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string $this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform)); } - public function provideSqlDeclarations(): array + public static function provideSqlDeclarations(): array { return [ [new PostgreSQLPlatform(), 'UUID'], diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 78d8ae01dc328..a4e928438cf0c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -186,7 +186,7 @@ public function testValidateUniqueness(UniqueEntity $constraint) ->assertRaised(); } - public function provideUniquenessConstraints(): iterable + public static function provideUniquenessConstraints(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -221,7 +221,7 @@ public function testValidateCustomErrorPath(UniqueEntity $constraint) ->assertRaised(); } - public function provideConstraintsWithCustomErrorPath(): iterable + public static function provideConstraintsWithCustomErrorPath(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -282,7 +282,7 @@ public function testValidateUniquenessWithIgnoreNullDisabled(UniqueEntity $const ->assertRaised(); } - public function provideConstraintsWithIgnoreNullDisabled(): iterable + public static function provideConstraintsWithIgnoreNullDisabled(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -331,7 +331,7 @@ public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored(Unique $this->assertNoViolation(); } - public function provideConstraintsWithIgnoreNullEnabled(): iterable + public static function provideConstraintsWithIgnoreNullEnabled(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -432,7 +432,7 @@ function () use ($entity) { $this->assertNoViolation(); } - public function provideConstraintsWithCustomRepositoryMethod(): iterable + public static function provideConstraintsWithCustomRepositoryMethod(): iterable { yield 'Doctrine style' => [new UniqueEntity([ 'message' => 'myMessage', @@ -473,7 +473,7 @@ public function testValidateResultTypes($entity1, $result) $this->assertNoViolation(); } - public function resultTypesProvider() + public static function resultTypesProvider() { $entity = new SingleIntIdEntity(1, 'foo'); @@ -886,7 +886,7 @@ public function testValueCanBeNull() $this->assertNoViolation(); } - public function resultWithEmptyIterator(): array + public static function resultWithEmptyIterator(): array { $entity = new SingleIntIdEntity(1, 'foo'); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index 034cd001aaebb..a72e78f6433ac 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -209,7 +209,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp $this->assertSame($expected, $doctrineLoader->loadClassMetadata($classMetadata)); } - public function regexpProvider() + public static function regexpProvider() { return [ [false, null], diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 923ee2dac2aae..a0dbbe9636adb 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -30,7 +30,7 @@ "symfony/cache": "^5.4|^6.0", "symfony/config": "^4.4|^5.0|^6.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/form": "^5.4.9|^6.0.9", + "symfony/form": "^5.4.21|^6.2.7", "symfony/http-kernel": "^5.0|^6.0", "symfony/messenger": "^4.4|^5.0|^6.0", "symfony/doctrine-messenger": "^5.1|^6.0", @@ -57,7 +57,7 @@ "phpunit/phpunit": "<5.4.3", "symfony/cache": "<5.4", "symfony/dependency-injection": "<4.4", - "symfony/form": "<5.1", + "symfony/form": "<5.4.21|>=6,<6.2.7", "symfony/http-kernel": "<5", "symfony/messenger": "<4.4", "symfony/property-info": "<5", diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index b5906b18c2be3..8a3bc7dc27263 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -41,7 +41,7 @@ public function onKernelResponse(ResponseEvent $event) } $request = $event->getRequest(); - if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent')) + if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent', '')) && !$request->headers->has('X-FirePHP-Version')) { self::$sendHeaders = false; $this->headers = []; diff --git a/src/Symfony/Bridge/Monolog/LICENSE b/src/Symfony/Bridge/Monolog/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bridge/Monolog/LICENSE +++ b/src/Symfony/Bridge/Monolog/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php b/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php index 89d5bee454548..36f0c5ce89216 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php @@ -26,7 +26,7 @@ public function testFormat(array $record, $expectedMessage) self::assertSame($expectedMessage, $formatter->format($record)); } - public function providerFormatTests(): array + public static function providerFormatTests(): array { $currentDateTime = new \DateTime(); diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index d61692ed76466..85cb1f8d74617 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -89,7 +89,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map $this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.'); } - public function provideVerbosityMappingTests() + public static function provideVerbosityMappingTests() { return [ [OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true], diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php index 0afb8eb4cfbe8..00aa6117c09a9 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php @@ -97,7 +97,7 @@ public function testIsActivated($url, $record, $expected) self::assertEquals($expected, $strategy->isHandlerActivated($record)); } - public function isActivatedProvider(): array + public static function isActivatedProvider(): array { return [ ['/test', ['level' => Logger::ERROR], true], diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php index 09e71e0b332ef..cd37c9e7a8b0a 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php @@ -49,7 +49,7 @@ public function testIsActivated(string $url, array $record, bool $expected) self::assertEquals($expected, $strategy->isHandlerActivated($record)); } - public function isActivatedProvider(): array + public static function isActivatedProvider(): array { return [ ['/test', ['level' => Logger::DEBUG], false], diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FirePHPHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FirePHPHandlerTest.php new file mode 100644 index 0000000000000..5cc29a6a354d6 --- /dev/null +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FirePHPHandlerTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Monolog\Tests\Handler; + +use PHPUnit\Framework\TestCase; +use Symfony\Bridge\Monolog\Handler\FirePHPHandler; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Event\ResponseEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; + +class FirePHPHandlerTest extends TestCase +{ + public function testOnKernelResponseShouldNotTriggerDeprecation() + { + $request = Request::create('/'); + $request->headers->remove('User-Agent'); + + $response = new Response('foo'); + $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, $response); + + $error = null; + set_error_handler(function ($type, $message) use (&$error) { $error = $message; }, \E_DEPRECATED); + + $listener = new FirePHPHandler(); + $listener->onKernelResponse($event); + restore_error_handler(); + + $this->assertNull($error); + } +} diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php index d01ca9f83ea1d..044c7e6172e31 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php @@ -32,7 +32,7 @@ public function testDatetimeFormat(array $record, $expectedTimestamp) self::assertSame($expectedTimestamp, $records[0]['timestamp']); } - public function providerDatetimeFormatTests(): array + public static function providerDatetimeFormatTests(): array { $record = self::getRecord(); @@ -56,7 +56,7 @@ public function testDatetimeRfc3339Format(array $record, $expectedTimestamp) self::assertSame($expectedTimestamp, $records[0]['timestamp_rfc3339']); } - public function providerDatetimeRfc3339FormatTests(): array + public static function providerDatetimeRfc3339FormatTests(): array { $record = self::getRecord(); diff --git a/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php b/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php index 9d0a1374c8cbc..b21d174d7f4bc 100644 --- a/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php +++ b/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php @@ -12,9 +12,8 @@ namespace Symfony\Bridge\PhpUnit; use PHPUnit\Framework\Constraint\Constraint; -use ReflectionClass; -$r = new ReflectionClass(Constraint::class); +$r = new \ReflectionClass(Constraint::class); if ($r->getProperty('exporter')->isProtected()) { trait ConstraintTrait { diff --git a/src/Symfony/Bridge/PhpUnit/LICENSE b/src/Symfony/Bridge/PhpUnit/LICENSE index 72412a62b2029..29f72d5e95920 100644 --- a/src/Symfony/Bridge/PhpUnit/LICENSE +++ b/src/Symfony/Bridge/PhpUnit/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2023 Fabien Potencier +Copyright (c) 2014-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php index 3e3a831308a43..9170605a5aa9a 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php @@ -179,7 +179,7 @@ public function testItCanTellWhetherToDisplayAStackTrace() $this->assertTrue($configuration->shouldDisplayStackTrace('interesting')); } - public function provideItCanBeDisabled(): array + public static function provideItCanBeDisabled(): array { return [ ['disabled', false], @@ -248,7 +248,7 @@ public function testToleratesForIndividualGroups(string $deprecationsHelper, arr } } - public function provideDataForToleratesForGroup() { + public static function provideDataForToleratesForGroup() { yield 'total threshold not reached' => ['max[total]=1', [ 'unsilenced' => 0, @@ -482,10 +482,24 @@ public function testBaselineFileWriteError() { $filename = $this->createFile(); chmod($filename, 0444); - $this->expectError(); - $this->expectErrorMessageMatches('/[Ff]ailed to open stream: Permission denied/'); $configuration = Configuration::fromUrlEncodedString('generateBaseline=true&baselineFile='.urlencode($filename)); - $configuration->writeBaseline(); + + $this->expectException(\ErrorException::class); + $this->expectExceptionMessageMatches('/[Ff]ailed to open stream: Permission denied/'); + + set_error_handler(static function (int $errno, string $errstr, string $errfile = null, int $errline = null): bool { + if ($errno & (E_WARNING | E_WARNING)) { + throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); + } + + return false; + }); + + try { + $configuration->writeBaseline(); + } finally { + restore_error_handler(); + } } protected function setUp(): void diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index a1d3c06ea668f..5c7cf991b3f2f 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -97,7 +97,7 @@ public function testItMutesOnlySpecificErrorMessagesWhenTheCallingCodeIsInPhpuni $this->assertSame($muted, $deprecation->isMuted()); } - public function mutedProvider() + public static function mutedProvider() { yield 'not from phpunit, and not a whitelisted message' => [ false, @@ -147,7 +147,7 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles() $this->assertTrue($deprecation->isMuted()); } - public function providerGetTypeDetectsSelf() + public static function providerGetTypeDetectsSelf() { return [ 'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__], @@ -182,7 +182,7 @@ public function testGetTypeDetectsSelf(string $expectedType, string $message, st $this->assertSame($expectedType, $deprecation->getType()); } - public function providerGetTypeUsesRightTrace() + public static function providerGetTypeUsesRightTrace() { $vendorDir = self::getVendorDir(); $fakeTrace = [ diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php index 5e6350e673101..224e9940b2583 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php @@ -33,6 +33,7 @@ public function testOne() * Do not remove this test in the next major version. * * @group legacy + * * @runInSeparateProcess */ public function testOneInIsolation() diff --git a/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php b/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php index ba35b268deebe..f2eb1b1bdecf5 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php @@ -39,6 +39,7 @@ public function testOne() * Do not remove this test in the next major version. * * @group legacy + * * @runInSeparateProcess */ public function testOneInIsolation() diff --git a/src/Symfony/Bridge/ProxyManager/LICENSE b/src/Symfony/Bridge/ProxyManager/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bridge/ProxyManager/LICENSE +++ b/src/Symfony/Bridge/ProxyManager/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php index 69b7239655944..cf3d2cdbd9f07 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\TestCase; use ProxyManager\Proxy\LazyLoadingInterface; -use ProxyManagerBridgeFooClass; use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -33,7 +32,7 @@ public function testCreateProxyServiceWithRuntimeInstantiator() $builder->setProxyInstantiator(new RuntimeInstantiator()); - $builder->register('foo1', ProxyManagerBridgeFooClass::class)->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true); + $builder->register('foo1', \ProxyManagerBridgeFooClass::class)->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true); $builder->getDefinition('foo1')->setLazy(true); $builder->compile(); @@ -45,7 +44,7 @@ public function testCreateProxyServiceWithRuntimeInstantiator() $this->assertSame(0, $foo1::$destructorCount); $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls'); - $this->assertInstanceOf(ProxyManagerBridgeFooClass::class, $foo1); + $this->assertInstanceOf(\ProxyManagerBridgeFooClass::class, $foo1); $this->assertInstanceOf(LazyLoadingInterface::class, $foo1); $this->assertFalse($foo1->isProxyInitialized()); @@ -53,7 +52,7 @@ public function testCreateProxyServiceWithRuntimeInstantiator() $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved after initialization'); $this->assertTrue($foo1->isProxyInitialized()); - $this->assertInstanceOf(ProxyManagerBridgeFooClass::class, $foo1->getWrappedValueHolderValue()); + $this->assertInstanceOf(\ProxyManagerBridgeFooClass::class, $foo1->getWrappedValueHolderValue()); $this->assertNotInstanceOf(LazyLoadingInterface::class, $foo1->getWrappedValueHolderValue()); $foo1->__destruct(); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index e787da909bbb3..65c74c0ff7697 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -93,7 +93,7 @@ public function testCorrectAssigning(Definition $definition, $access) $this->assertStringMatchesFormat('%A$this->'.$access.'[\'foo\'] = %A', $code); } - public function getPrivatePublicDefinitions() + public static function getPrivatePublicDefinitions() { return [ [ @@ -164,7 +164,7 @@ protected function createProxy(\$class, \Closure \$factory) $this->assertSame(123, @$foo->dynamicProp); } - public function getProxyCandidates(): array + public static function getProxyCandidates(): array { $definitions = [ [new Definition(__CLASS__), true], diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index c2797d837aa7f..d50348098e67a 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -116,6 +116,10 @@ public function trans($message, $arguments = [], string $domain = null, string $ throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a locale passed as a string when the message is a "%s", "%s" given.', __METHOD__, TranslatableInterface::class, get_debug_type($arguments))); } + if ($message instanceof TranslatableMessage && '' === $message->getMessage()) { + return ''; + } + return $message->trans($this->getTranslator(), $locale ?? (\is_string($arguments) ? $arguments : null)); } diff --git a/src/Symfony/Bridge/Twig/LICENSE b/src/Symfony/Bridge/Twig/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bridge/Twig/LICENSE +++ b/src/Symfony/Bridge/Twig/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php b/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php index b214ae8a743c2..853c01427da30 100644 --- a/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php @@ -36,7 +36,7 @@ public function toName(): string } /** - * @param string $image A Twig path to the image file. It's recommended to define + * @param string $image A Twig path to the image file. It's recommended to define * some Twig namespace for email images (e.g. '@email/images/logo.png'). * @param string|null $contentType The media type (i.e. MIME type) of the image file (e.g. 'image/png'). * Some email clients require this to display embedded images. @@ -54,9 +54,9 @@ public function image(string $image, string $contentType = null): string } /** - * @param string $file A Twig path to the file. It's recommended to define + * @param string $file A Twig path to the file. It's recommended to define * some Twig namespace for email files (e.g. '@email/files/contract.pdf'). - * @param string|null $name A custom file name that overrides the original name of the attached file. + * @param string|null $name A custom file name that overrides the original name of the attached file * @param string|null $contentType The media type (i.e. MIME type) of the file (e.g. 'application/pdf'). * Some email clients require this to display attached files. */ diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index 865f9078a9658..f4e313b4756c8 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -90,6 +90,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index 9aa6081e7e323..a7ce3e23fc96c 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -283,6 +283,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig index f8c51b83dd8ed..345695f62d684 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig @@ -253,6 +253,10 @@ {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {% if label is empty %} {%- if label_format is not empty -%} {% set label = label_format|replace({ diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index 84e9ea8ce0696..ea3fbfda3a659 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -43,7 +43,7 @@ public function testDebug($debugFlag) $this->assertEquals($debugFlag, $this->appVariable->getDebug()); } - public function debugDataProvider() + public static function debugDataProvider() { return [ 'debug on' => [true], diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 2488a27677af9..45591415e3312 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -84,7 +84,7 @@ public function testDebugTemplateName(array $input, string $output, array $paths $this->assertStringMatchesFormat($output, $tester->getDisplay(true)); } - public function getDebugTemplateNameTestData() + public static function getDebugTemplateNameTestData() { $defaultPaths = [ 'templates/' => null, @@ -315,7 +315,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'name' => [['email'], []]; yield 'option --format' => [['--format', ''], ['text', 'json']]; diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 6a3d640b2d5b2..a898680fdd3e3 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -150,7 +150,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option' => [['--format', ''], ['txt', 'json', 'github']]; } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php similarity index 98% rename from src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php rename to src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php index c4874c3407092..e79b0c3141e9e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; -abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3LayoutTest +abstract class AbstractBootstrap3HorizontalLayoutTestCase extends AbstractBootstrap3LayoutTestCase { public function testLabelOnForm() { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTestCase.php similarity index 99% rename from src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php rename to src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTestCase.php index 808352300adf4..16cb900b99522 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTestCase.php @@ -13,9 +13,9 @@ use Symfony\Component\Form\Extension\Core\Type\PercentType; use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Tests\AbstractLayoutTest; +use Symfony\Component\Form\Tests\AbstractLayoutTestCase; -abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest +abstract class AbstractBootstrap3LayoutTestCase extends AbstractLayoutTestCase { public function testLabelOnForm() { @@ -2154,6 +2154,25 @@ public function testRenderNumberWithHtml5NumberType() $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="number"] + [@step="any"] + [@name="name"] + [@class="my&class form-control"] + [@value="1234.56"] +' + ); + } + + public function testRenderNumberWithHtml5NumberTypeAndStepAttribute() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [ + 'html5' => true, + 'attr' => ['step' => '0.1'], + ]); + + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], + '/input + [@type="number"] + [@step="0.1"] [@name="name"] [@class="my&class form-control"] [@value="1234.56"] diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php similarity index 98% rename from src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php rename to src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php index 1ef14ecf4dc0f..ce8a733665854 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php @@ -18,7 +18,7 @@ * * @author Hidde Wieringa */ -abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4LayoutTest +abstract class AbstractBootstrap4HorizontalLayoutTestCase extends AbstractBootstrap4LayoutTestCase { public function testRow() { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php similarity index 99% rename from src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php rename to src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php index 8689df830b290..e329b5d49ec16 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php @@ -28,7 +28,7 @@ * * @author Hidde Wieringa */ -abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest +abstract class AbstractBootstrap4LayoutTestCase extends AbstractBootstrap3LayoutTestCase { public function testRow() { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php similarity index 99% rename from src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php rename to src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php index 863e6a50afada..ddaa4cdc521f4 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php @@ -24,7 +24,7 @@ * * @author Romain Monteil */ -abstract class AbstractBootstrap5HorizontalLayoutTest extends AbstractBootstrap5LayoutTest +abstract class AbstractBootstrap5HorizontalLayoutTestCase extends AbstractBootstrap5LayoutTestCase { public function testRow() { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTestCase.php similarity index 99% rename from src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTest.php rename to src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTestCase.php index ebeacf7045afc..25349e14fca05 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap5LayoutTestCase.php @@ -36,7 +36,7 @@ * * @author Romain Monteil */ -abstract class AbstractBootstrap5LayoutTest extends AbstractBootstrap4LayoutTest +abstract class AbstractBootstrap5LayoutTestCase extends AbstractBootstrap4LayoutTestCase { public function testRow() { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php index 33bb266cb6a2f..38983cbd697f1 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php @@ -44,7 +44,7 @@ public function testGettingMethodAbbreviation($method, $abbr) $this->assertEquals($this->getExtension()->abbrMethod($method), $abbr); } - public function getClassNameProvider(): array + public static function getClassNameProvider(): array { return [ ['F\Q\N\Foo', 'Foo'], @@ -52,7 +52,7 @@ public function getClassNameProvider(): array ]; } - public function getMethodNameProvider(): array + public static function getMethodNameProvider(): array { return [ ['F\Q\N\Foo::Method', 'Foo::Method()'], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index d0825221663ad..8fe455e5d5706 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -53,7 +53,7 @@ public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) $this->assertSame($expectedDumped, $dumped); } - public function getDumpTags() + public static function getDumpTags() { return [ ['A{% dump %}B', true, 'AB', []], @@ -88,7 +88,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true) $this->assertEquals($expectedOutput, $dump); } - public function getDumpArgs() + public static function getDumpArgs() { return [ [[], [], '', false], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index a0953a2d9f346..e746a267105e2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -21,7 +21,7 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest +class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index a3a6c751a0718..2b7e186c0d5cd 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -21,7 +21,7 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest +class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTestCase { use RuntimeLoaderProvider; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index 33e1862afd74a..f95e678440b4d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -26,7 +26,7 @@ * * @author Hidde Wieringa */ -class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTest +class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index 00fee10edb2fc..2d0ca9fabab21 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -26,7 +26,7 @@ * * @author Hidde Wieringa */ -class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest +class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTestCase { use RuntimeLoaderProvider; /** diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php index ef924884a4751..d6d2c3c2ecb06 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php @@ -26,7 +26,7 @@ * * @author Romain Monteil */ -class FormExtensionBootstrap5HorizontalLayoutTest extends AbstractBootstrap5HorizontalLayoutTest +class FormExtensionBootstrap5HorizontalLayoutTest extends AbstractBootstrap5HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php index ed69ca81c3375..94174615a0ce0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php @@ -28,7 +28,7 @@ * * @author Romain Monteil */ -class FormExtensionBootstrap5LayoutTest extends AbstractBootstrap5LayoutTest +class FormExtensionBootstrap5LayoutTest extends AbstractBootstrap5LayoutTestCase { use RuntimeLoaderProvider; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index e7991240f03f5..3809f3fa1f4cf 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -18,12 +18,12 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractDivLayoutTest; +use Symfony\Component\Form\Tests\AbstractDivLayoutTestCase; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionDivLayoutTest extends AbstractDivLayoutTest +class FormExtensionDivLayoutTest extends AbstractDivLayoutTestCase { use RuntimeLoaderProvider; @@ -100,7 +100,7 @@ public function testThemeBlockInheritanceUsingDynamicExtend() ); } - public function isSelectedChoiceProvider() + public static function isSelectedChoiceProvider() { return [ [true, '0', '0'], @@ -150,7 +150,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero() $this->assertSame('
', $html); } - public function isRootFormProvider() + public static function isRootFormProvider() { return [ [true, new FormView()], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 20b465418daea..25d595df7c9d3 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -17,12 +17,12 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractTableLayoutTest; +use Symfony\Component\Form\Tests\AbstractTableLayoutTestCase; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionTableLayoutTest extends AbstractTableLayoutTest +class FormExtensionTableLayoutTest extends AbstractTableLayoutTestCase { use RuntimeLoaderProvider; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index ea3bb17bb3038..28ddacd018e47 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -32,7 +32,7 @@ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlData() + public static function getGenerateAbsoluteUrlData() { return [ ['http://localhost/foo.png', '/foo.png', '/foo/bar.html'], @@ -84,7 +84,7 @@ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlRequestContextData() + public static function getGenerateAbsoluteUrlRequestContextData() { return [ ['/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'], @@ -129,7 +129,7 @@ public function testGenerateRelativePath($expected, $path, $pathinfo) $this->assertEquals($expected, $extension->generateRelativePath($path)); } - public function getGenerateRelativePathData() + public static function getGenerateRelativePathData() { return [ ['../foo.png', '/foo.png', '/foo/bar.html'], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php index 5a995c8eeb76c..742a74f325b91 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php @@ -34,7 +34,7 @@ public function testEscaping($template, $mustBeEscaped) $this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof FilterExpression); } - public function getEscapingTemplates() + public static function getEscapingTemplates() { return [ ['{{ path("foo") }}', false], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php index ef54ee2775f15..0c36c8c6b4b93 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php @@ -41,7 +41,7 @@ public function testSerializeFilter(string $template, string $expectedResult) self::assertSame($expectedResult, $twig->render('template', ['object' => new SerializerModelFixture()])); } - public function serializerDataProvider(): \Generator + public static function serializerDataProvider(): \Generator { yield ['{{ object|serialize }}', '{"name":"howdy","title":"fixture"}']; yield ['{{ object|serialize(\'yaml\') }}', '{ name: howdy, title: fixture }']; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index 65f1bd69bff7c..59a393744a9e2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php @@ -41,7 +41,7 @@ public function testTiming($template, $events) } } - public function getTimingTemplates() + public static function getTimingTemplates() { return [ ['{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index 86f50da0b7db8..7de52965b0ef7 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -61,7 +61,7 @@ public function testTransComplexBody() $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); } - public function getTransTests() + public static function getTransTests() { return [ // trans tag @@ -124,6 +124,7 @@ public function getTransTests() ['{{ foo|trans }}', '', ['foo' => null]], // trans object + ['{{ t("")|trans }}', ''], ['{{ t("Hello")|trans }}', 'Hello'], ['{{ t(name)|trans }}', 'Symfony', ['name' => 'Symfony']], ['{{ t(hello, { \'%name%\': \'Symfony\' })|trans }}', 'Hello Symfony', ['hello' => 'Hello %name%']], diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php index 77548fb119626..b21017193251d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php @@ -73,11 +73,9 @@ public function testSymfonySerialize() "html": null, "htmlCharset": null, "attachments": [ - { - "body": "Some Text file", - "name": "test.txt", - "content-type": null, - "inline": false + {%A + "body": "Some Text file",%A + "name": "test.txt",%A } ], "headers": { @@ -111,11 +109,11 @@ public function testSymfonySerialize() ], [new JsonEncoder()]); $serialized = $serializer->serialize($e, 'json', [ObjectNormalizer::IGNORED_ATTRIBUTES => ['cachedBody']]); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); + $this->assertStringMatchesFormat($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n = $serializer->deserialize($serialized, TemplatedEmail::class, 'json'); $serialized = $serializer->serialize($e, 'json', [ObjectNormalizer::IGNORED_ATTRIBUTES => ['cachedBody']]); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); + $this->assertStringMatchesFormat($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n->from('fabien@symfony.com'); $expected->from('fabien@symfony.com'); diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index cc2b6ef2ac39e..25b8166eae62a 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -76,7 +76,7 @@ public function testNewModuleWithoutDefaultDomainTag(Node $node) $this->assertEquals([[self::$message, null]], $visitor->getMessages()); } - public function getDefaultDomainAssignmentTestData() + public static function getDefaultDomainAssignmentTestData() { return [ [TwigNodeProvider::getTransFilter(self::$message)], diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 069914a4fc066..bf073602583f7 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -51,7 +51,7 @@ public function testMessageExtractionWithInvalidDomainNode() $this->testMessagesExtraction($node, [[$message, TranslationNodeVisitor::UNDEFINED_DOMAIN]]); } - public function getMessagesExtractionTestData() + public static function getMessagesExtractionTestData() { $message = 'new key'; $domain = 'domain'; diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index d404060091f83..41504050f74f8 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -40,7 +40,7 @@ public function testCompile($source, $expected) $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)); } - public function getTestsForFormTheme() + public static function getTestsForFormTheme() { return [ [ diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 4a8b4d19c066e..060a0578f2044 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -54,7 +54,7 @@ public function testExtract($template, $messages) } } - public function getExtractData() + public static function getExtractData() { return [ ['{{ "new key" | trans() }}', ['new key' => 'messages']], @@ -102,7 +102,7 @@ public function testExtractSyntaxError($resources, array $messages) $this->assertSame($messages, $catalogue->all()); } - public function resourcesWithSyntaxErrorsProvider(): array + public static function resourcesWithSyntaxErrorsProvider(): array { return [ [__DIR__.'/../Fixtures', ['messages' => ['Hi!' => 'Hi!']]], @@ -133,7 +133,7 @@ public function testExtractWithFiles($resource) $this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages')); } - public function resourceProvider(): array + public static function resourceProvider(): array { $directory = __DIR__.'/../Fixtures/extractor/'; diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index c67b92f79b83a..07275fe457320 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -28,7 +28,7 @@ "symfony/asset": "^4.4|^5.0|^6.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0", "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/form": "^5.3|^6.0", + "symfony/form": "^5.4.21|^6.2.7", "symfony/http-foundation": "^5.3|^6.0", "symfony/http-kernel": "^4.4|^5.0|^6.0", "symfony/intl": "^4.4|^5.0|^6.0", @@ -56,7 +56,7 @@ "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", "symfony/console": "<5.3", - "symfony/form": "<5.3", + "symfony/form": "<5.4.21|>=6,<6.2.7", "symfony/http-foundation": "<5.3", "symfony/http-kernel": "<4.4", "symfony/translation": "<5.2", diff --git a/src/Symfony/Bundle/DebugBundle/LICENSE b/src/Symfony/Bundle/DebugBundle/LICENSE index 72412a62b2029..29f72d5e95920 100644 --- a/src/Symfony/Bundle/DebugBundle/LICENSE +++ b/src/Symfony/Bundle/DebugBundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2023 Fabien Potencier +Copyright (c) 2014-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php index 31afae4d93acb..89dee3e889ee6 100644 --- a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php +++ b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php @@ -74,7 +74,7 @@ public function testUnsetClosureFileInfoShouldBeRegisteredInVarCloner() $this->assertTrue($called); } - public function provideServicesUsingDumpDestinationCreation(): array + public static function provideServicesUsingDumpDestinationCreation(): array { return [ ['tcp://localhost:1234', 'tcp://localhost:1234', null], diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index 12e501baa19a2..fe4b83a9b9c97 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -139,9 +139,9 @@ private function compileContainer(): ContainerBuilder /** * Iterate over configuration until the last step of the given path. * - * @throws LogicException If the configuration does not exist - * * @return mixed + * + * @throws LogicException If the configuration does not exist */ private function getConfigForPath(array $config, string $path, string $alias) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php index f6eff3f61c805..85220f1b568fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php @@ -239,7 +239,7 @@ protected function denyAccessUnlessGranted($attribute, $subject = null, string $ { if (!$this->isGranted($attribute, $subject)) { $exception = $this->createAccessDeniedException($message); - $exception->setAttributes($attribute); + $exception->setAttributes([$attribute]); $exception->setSubject($subject); throw $exception; diff --git a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php index c25f90d63c9ca..e448d2d8a4c0d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php @@ -213,6 +213,10 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection if ($configuratorClass && !is_a(RoutingConfigurator::class, $configuratorClass, true)) { trigger_deprecation('symfony/framework-bundle', '5.1', 'Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class); + if (!class_exists(RouteCollectionBuilder::class)) { + throw new \InvalidArgumentException(sprintf('Using type "%s" for argument 1 of method "%s:configureRoutes()" is not compatible with the installed "symfony/routing" version. Use "%s" instead, or run "composer require symfony/routing:^5.4".', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class)); + } + $routes = new RouteCollectionBuilder($loader); $this->configureRoutes($routes); diff --git a/src/Symfony/Bundle/FrameworkBundle/LICENSE b/src/Symfony/Bundle/FrameworkBundle/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bundle/FrameworkBundle/LICENSE +++ b/src/Symfony/Bundle/FrameworkBundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/DomCrawlerAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/DomCrawlerAssertionsTrait.php index 2a692d6f5a367..6e8247cbf54e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/DomCrawlerAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/DomCrawlerAssertionsTrait.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\Constraint\LogicalNot; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Test\Constraint as DomCrawlerConstraint; -use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorAttributeValueSame; use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorExists; /** @@ -87,18 +86,12 @@ public static function assertInputValueNotSame(string $fieldName, string $expect public static function assertCheckboxChecked(string $fieldName, string $message = ''): void { - self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( - new CrawlerSelectorExists("input[name=\"$fieldName\"]"), - new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked') - ), $message); + self::assertThat(self::getCrawler(), new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked"), $message); } public static function assertCheckboxNotChecked(string $fieldName, string $message = ''): void { - self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( - new CrawlerSelectorExists("input[name=\"$fieldName\"]"), - new LogicalNot(new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'checked', 'checked')) - ), $message); + self::assertThat(self::getCrawler(), new LogicalNot(new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked")), $message); } public static function assertFormValue(string $formSelector, string $fieldName, string $value, string $message = ''): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php index e64196f64d5c6..85dbd88104f57 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -40,7 +40,7 @@ public function testWarmUp(array $loaders) $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); } - public function loaderProvider() + public static function loaderProvider() { return [ [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php index 169fcd8c2d75d..cc4573fafdc62 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php @@ -44,7 +44,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'pool_name' => [ ['f'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php index f643bc1259901..7cd2366703c3b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php @@ -98,7 +98,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'pool_name' => [ ['f'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php index a506ac2d2915f..9bc054f22a942 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php @@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']]; yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php index c02bc91761084..88c247ec61ebc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php @@ -37,7 +37,7 @@ public function testComplete(bool $withLocalVault, array $input, array $expected $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'name' => [true, [''], ['SECRET', 'OTHER_SECRET']]; yield '--local name (with local vault)' => [true, ['--local', ''], ['SECRET']]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php index 135907b374d26..8e8e968c8f710 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php @@ -32,7 +32,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'name' => [[''], ['SECRET', 'OTHER_SECRET']]; yield '--local name (with local vault)' => [['--local', ''], ['SECRET', 'OTHER_SECRET']]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 70f94d6a34d48..846abd44500e0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -269,7 +269,7 @@ function ($path, $catalogue) use ($extractedMessagesWithDomains) { $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'locale' => [ [''], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php index 49ba74caf6a1b..91999d288266e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php @@ -42,7 +42,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { $bundle = new ExtensionPresentBundle(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php index 13a63b40d97fa..d28f53261c0de 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php @@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'option --dump-format' => [['--dump-format', ''], ['puml', 'mermaid', 'dot']]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php similarity index 77% rename from src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php index d761ca5387805..67c067841f110 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php @@ -24,7 +24,7 @@ use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -abstract class AbstractDescriptorTest extends TestCase +abstract class AbstractDescriptorTestCase extends TestCase { private $colSize; @@ -45,9 +45,9 @@ public function testDescribeRouteCollection(RouteCollection $routes, $expectedDe $this->assertDescription($expectedDescription, $routes); } - public function getDescribeRouteCollectionTestData() + public static function getDescribeRouteCollectionTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getRouteCollections()); + return static::getDescriptionTestData(ObjectsProvider::getRouteCollections()); } /** @dataProvider getDescribeRouteTestData */ @@ -56,9 +56,9 @@ public function testDescribeRoute(Route $route, $expectedDescription) $this->assertDescription($expectedDescription, $route); } - public function getDescribeRouteTestData() + public static function getDescribeRouteTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getRoutes()); + return static::getDescriptionTestData(ObjectsProvider::getRoutes()); } /** @dataProvider getDescribeContainerParametersTestData */ @@ -67,9 +67,9 @@ public function testDescribeContainerParameters(ParameterBag $parameters, $expec $this->assertDescription($expectedDescription, $parameters); } - public function getDescribeContainerParametersTestData() + public static function getDescribeContainerParametersTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerParameters()); + return static::getDescriptionTestData(ObjectsProvider::getContainerParameters()); } /** @dataProvider getDescribeContainerBuilderTestData */ @@ -78,9 +78,9 @@ public function testDescribeContainerBuilder(ContainerBuilder $builder, $expecte $this->assertDescription($expectedDescription, $builder, $options); } - public function getDescribeContainerBuilderTestData() + public static function getDescribeContainerBuilderTestData(): array { - return $this->getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders()); + return static::getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders()); } /** @@ -91,9 +91,9 @@ public function testDescribeContainerExistingClassDefinition(Definition $definit $this->assertDescription($expectedDescription, $definition); } - public function getDescribeContainerExistingClassDefinitionTestData() + public static function getDescribeContainerExistingClassDefinitionTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitionsWithExistingClasses()); + return static::getDescriptionTestData(ObjectsProvider::getContainerDefinitionsWithExistingClasses()); } /** @dataProvider getDescribeContainerDefinitionTestData */ @@ -102,9 +102,9 @@ public function testDescribeContainerDefinition(Definition $definition, $expecte $this->assertDescription($expectedDescription, $definition); } - public function getDescribeContainerDefinitionTestData() + public static function getDescribeContainerDefinitionTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitions()); + return static::getDescriptionTestData(ObjectsProvider::getContainerDefinitions()); } /** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */ @@ -113,7 +113,7 @@ public function testDescribeContainerDefinitionWithArgumentsShown(Definition $de $this->assertDescription($expectedDescription, $definition, ['show_arguments' => true]); } - public function getDescribeContainerDefinitionWithArgumentsShownTestData() + public static function getDescribeContainerDefinitionWithArgumentsShownTestData(): array { $definitions = ObjectsProvider::getContainerDefinitions(); $definitionsWithArgs = []; @@ -126,7 +126,7 @@ public function getDescribeContainerDefinitionWithArgumentsShownTestData() $definitionsWithArgs['definition_arguments_with_enum'] = (new Definition('definition_with_enum'))->setArgument(0, FooUnitEnum::FOO); } - return $this->getDescriptionTestData($definitionsWithArgs); + return static::getDescriptionTestData($definitionsWithArgs); } /** @dataProvider getDescribeContainerAliasTestData */ @@ -135,9 +135,9 @@ public function testDescribeContainerAlias(Alias $alias, $expectedDescription) $this->assertDescription($expectedDescription, $alias); } - public function getDescribeContainerAliasTestData() + public static function getDescribeContainerAliasTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerAliases()); + return static::getDescriptionTestData(ObjectsProvider::getContainerAliases()); } /** @dataProvider getDescribeContainerDefinitionWhichIsAnAliasTestData */ @@ -146,7 +146,7 @@ public function testDescribeContainerDefinitionWhichIsAnAlias(Alias $alias, $exp $this->assertDescription($expectedDescription, $builder, $options); } - public function getDescribeContainerDefinitionWhichIsAnAliasTestData() + public static function getDescribeContainerDefinitionWhichIsAnAliasTestData(): array { $builder = current(ObjectsProvider::getContainerBuilders()); $builder->setDefinition('service_1', $builder->getDefinition('definition_1')); @@ -159,7 +159,7 @@ public function getDescribeContainerDefinitionWhichIsAnAliasTestData() } $i = 0; - $data = $this->getDescriptionTestData($aliasesWithDefinitions); + $data = static::getDescriptionTestData($aliasesWithDefinitions); foreach ($aliases as $name => $alias) { $file = array_pop($data[$i]); $data[$i][] = $builder; @@ -177,9 +177,9 @@ public function testDescribeContainerParameter($parameter, $expectedDescription, $this->assertDescription($expectedDescription, $parameter, $options); } - public function getDescribeContainerParameterTestData() + public static function getDescribeContainerParameterTestData(): array { - $data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter()); + $data = static::getDescriptionTestData(ObjectsProvider::getContainerParameter()); $file = array_pop($data[0]); $data[0][] = ['parameter' => 'database_name']; @@ -197,9 +197,9 @@ public function testDescribeEventDispatcher(EventDispatcher $eventDispatcher, $e $this->assertDescription($expectedDescription, $eventDispatcher, $options); } - public function getDescribeEventDispatcherTestData() + public static function getDescribeEventDispatcherTestData(): array { - return $this->getEventDispatcherDescriptionTestData(ObjectsProvider::getEventDispatchers()); + return static::getEventDispatcherDescriptionTestData(ObjectsProvider::getEventDispatchers()); } /** @dataProvider getDescribeCallableTestData */ @@ -208,13 +208,14 @@ public function testDescribeCallable($callable, $expectedDescription) $this->assertDescription($expectedDescription, $callable); } - public function getDescribeCallableTestData(): array + public static function getDescribeCallableTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getCallables()); + return static::getDescriptionTestData(ObjectsProvider::getCallables()); } /** * @group legacy + * * @dataProvider getDescribeDeprecatedCallableTestData */ public function testDescribeDeprecatedCallable($callable, $expectedDescription) @@ -222,9 +223,9 @@ public function testDescribeDeprecatedCallable($callable, $expectedDescription) $this->assertDescription($expectedDescription, $callable); } - public function getDescribeDeprecatedCallableTestData(): array + public static function getDescribeDeprecatedCallableTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); + return static::getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); } /** @dataProvider getClassDescriptionTestData */ @@ -233,7 +234,7 @@ public function testGetClassDescription($object, $expectedDescription) $this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object)); } - public function getClassDescriptionTestData() + public static function getClassDescriptionTestData(): array { return [ [ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'], @@ -251,14 +252,14 @@ public function testGetDeprecations(ContainerBuilder $builder, $expectedDescript $this->assertDescription($expectedDescription, $builder, ['deprecations' => true]); } - public function getDeprecationsTestData() + public static function getDeprecationsTestData(): array { - return $this->getDescriptionTestData(ObjectsProvider::getContainerDeprecations()); + return static::getDescriptionTestData(ObjectsProvider::getContainerDeprecations()); } - abstract protected function getDescriptor(); + abstract protected static function getDescriptor(); - abstract protected function getFormat(); + abstract protected static function getFormat(); private function assertDescription($expectedDescription, $describedObject, array $options = []) { @@ -280,11 +281,11 @@ private function assertDescription($expectedDescription, $describedObject, array } } - private function getDescriptionTestData(iterable $objects) + private static function getDescriptionTestData(iterable $objects): array { $data = []; foreach ($objects as $name => $object) { - $file = sprintf('%s.%s', trim($name, '.'), $this->getFormat()); + $file = sprintf('%s.%s', trim($name, '.'), static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $file]; } @@ -292,7 +293,7 @@ private function getDescriptionTestData(iterable $objects) return $data; } - private function getContainerBuilderDescriptionTestData(array $objects) + private static function getContainerBuilderDescriptionTestData(array $objects): array { $variations = [ 'services' => ['show_hidden' => true], @@ -305,7 +306,7 @@ private function getContainerBuilderDescriptionTestData(array $objects) $data = []; foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { - $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, $this->getFormat()); + $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $options, $file]; } @@ -314,7 +315,7 @@ private function getContainerBuilderDescriptionTestData(array $objects) return $data; } - private function getEventDispatcherDescriptionTestData(array $objects) + private static function getEventDispatcherDescriptionTestData(array $objects): array { $variations = [ 'events' => [], @@ -324,7 +325,7 @@ private function getEventDispatcherDescriptionTestData(array $objects) $data = []; foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { - $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, $this->getFormat()); + $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $options, $file]; } @@ -339,13 +340,13 @@ public function testDescribeContainerBuilderWithPriorityTags(ContainerBuilder $b $this->assertDescription($expectedDescription, $builder, $options); } - public function getDescribeContainerBuilderWithPriorityTagsTestData(): array + public static function getDescribeContainerBuilderWithPriorityTagsTestData(): array { $variations = ['priority_tag' => ['tag' => 'tag1']]; $data = []; foreach (ObjectsProvider::getContainerBuildersWithPriorityTags() as $name => $object) { foreach ($variations as $suffix => $options) { - $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, $this->getFormat()); + $file = sprintf('%s_%s.%s', trim($name, '.'), $suffix, static::getFormat()); $description = file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file); $data[] = [$object, $description, $options]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php index ee03f65391f8a..296737a923547 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php @@ -13,14 +13,14 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\JsonDescriptor; -class JsonDescriptorTest extends AbstractDescriptorTest +class JsonDescriptorTest extends AbstractDescriptorTestCase { - protected function getDescriptor() + protected static function getDescriptor() { return new JsonDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'json'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/MarkdownDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/MarkdownDescriptorTest.php index fbb5aaa962689..1a653b835a3d9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/MarkdownDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/MarkdownDescriptorTest.php @@ -13,14 +13,14 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\MarkdownDescriptor; -class MarkdownDescriptorTest extends AbstractDescriptorTest +class MarkdownDescriptorTest extends AbstractDescriptorTestCase { - protected function getDescriptor() + protected static function getDescriptor() { return new MarkdownDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'md'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php index b844a60e7789b..55e410597344a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php @@ -15,23 +15,23 @@ use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\Routing\Route; -class TextDescriptorTest extends AbstractDescriptorTest +class TextDescriptorTest extends AbstractDescriptorTestCase { - private $fileLinkFormatter = null; + private static $fileLinkFormatter = null; - protected function getDescriptor() + protected static function getDescriptor() { - return new TextDescriptor($this->fileLinkFormatter); + return new TextDescriptor(static::$fileLinkFormatter); } - protected function getFormat() + protected static function getFormat() { return 'txt'; } - public function getDescribeRouteWithControllerLinkTestData() + public static function getDescribeRouteWithControllerLinkTestData() { - $getDescribeData = $this->getDescribeRouteTestData(); + $getDescribeData = static::getDescribeRouteTestData(); foreach ($getDescribeData as $key => &$data) { $routeStub = $data[0]; @@ -48,7 +48,7 @@ public function getDescribeRouteWithControllerLinkTestData() /** @dataProvider getDescribeRouteWithControllerLinkTestData */ public function testDescribeRouteWithControllerLink(Route $route, $expectedDescription) { - $this->fileLinkFormatter = new FileLinkFormatter('myeditor://open?file=%f&line=%l'); + static::$fileLinkFormatter = new FileLinkFormatter('myeditor://open?file=%f&line=%l'); parent::testDescribeRoute($route, str_replace('[:file:]', __FILE__, $expectedDescription)); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/XmlDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/XmlDescriptorTest.php index 8cb9a71697f6b..5b263b8171716 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/XmlDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/XmlDescriptorTest.php @@ -13,14 +13,14 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\XmlDescriptor; -class XmlDescriptorTest extends AbstractDescriptorTest +class XmlDescriptorTest extends AbstractDescriptorTestCase { - protected function getDescriptor() + protected static function getDescriptor() { return new XmlDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'xml'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 9a5c5510ce14e..d8dc199d8ae4b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -387,6 +387,40 @@ public function testdenyAccessUnlessGranted() $controller->denyAccessUnlessGranted('foo'); } + /** + * @dataProvider provideDenyAccessUnlessGrantedSetsAttributesAsArray + */ + public function testdenyAccessUnlessGrantedSetsAttributesAsArray($attribute, $exceptionAttributes) + { + $authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class); + $authorizationChecker->method('isGranted')->willReturn(false); + + $container = new Container(); + $container->set('security.authorization_checker', $authorizationChecker); + + $controller = $this->createController(); + $controller->setContainer($container); + + try { + $controller->denyAccessUnlessGranted($attribute); + $this->fail('there was no exception to check'); + } catch (AccessDeniedException $e) { + $this->assertSame($exceptionAttributes, $e->getAttributes()); + } + } + + public static function provideDenyAccessUnlessGrantedSetsAttributesAsArray() + { + $obj = new \stdClass(); + $obj->foo = 'bar'; + + return [ + 'string attribute' => ['foo', ['foo']], + 'array attribute' => [[1, 3, 3, 7], [[1, 3, 3, 7]]], + 'object attribute' => [$obj, [$obj]], + ]; + } + public function testRenderViewTwig() { $twig = $this->createMock(Environment::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 70ccf7c97cf5e..de72396df6ad5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -103,7 +103,7 @@ public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ign $this->assertEquals($expectedCode, $returnResponse->getStatusCode()); } - public function provider() + public static function provider() { return [ [true, false, false, false, 301, ['additional-parameter' => 'value']], @@ -210,7 +210,7 @@ public function testUrlRedirectDefaultPorts() $this->assertRedirectUrl($returnValue, $expectedUrl); } - public function urlRedirectProvider() + public static function urlRedirectProvider() { return [ // Standard ports @@ -262,7 +262,7 @@ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme, $this->assertRedirectUrl($returnValue, $expectedUrl); } - public function pathQueryParamsProvider() + public static function pathQueryParamsProvider() { return [ ['http://www.example.com/base/redirect-path', '/redirect-path', ''], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php index 0167f55101b7b..a5d58edbb4226 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php @@ -65,7 +65,7 @@ public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBag $this->assertTrue($this->container->hasDefinition('data_collector.translation')); } - public function getImplementingTranslatorBagInterfaceTranslatorClassNames() + public static function getImplementingTranslatorBagInterfaceTranslatorClassNames() { return [ ['Symfony\Component\Translation\Translator'], @@ -97,7 +97,7 @@ public function testProcessRemovesDataCollectorIfTranslatorDoesNotImplementTrans $this->assertFalse($this->container->hasDefinition('data_collector.translation')); } - public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() + public static function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() { return [ ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index 65f047426ae44..9792d2266050c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -62,7 +62,7 @@ public function testValidCollector() $this->assertEquals('add', $methodCalls[0][0]); // grab the method part of the first call } - public function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator + public static function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator { yield [new class() implements TemplateAwareDataCollectorInterface { public function collect(Request $request, Response $response, \Throwable $exception = null) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index d20f4e7b78554..47b66baf35861 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -60,7 +60,7 @@ public function testInvalidSessionName($sessionName) ); } - public function getTestInvalidSessionName() + public static function getTestInvalidSessionName() { return [ ['a.b'], @@ -113,7 +113,7 @@ public function testValidAssetsPackageNameConfiguration($packageName) $this->assertArrayHasKey($packageName, $config['assets']['packages']); } - public function provideValidAssetsPackageNameConfigurationTests() + public static function provideValidAssetsPackageNameConfigurationTests() { return [ ['foobar'], @@ -139,7 +139,7 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess ]); } - public function provideInvalidAssetConfigurationTests() + public static function provideInvalidAssetConfigurationTests() { // helper to turn config into embedded package config $createPackageConfig = function (array $packageConfig) { @@ -192,7 +192,7 @@ public function testValidLockConfiguration($lockConfig, $processedConfig) $this->assertEquals($processedConfig, $config['lock']); } - public function provideValidLockConfigurationTests() + public static function provideValidLockConfigurationTests() { yield [null, ['enabled' => true, 'resources' => ['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]]]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php index 5d6ed54d6739f..cfad547bd60a2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_not_valid.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'my_workflow' => [ 'type' => 'state_machine', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'places' => [ 'first', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php index 2037b5f904f69..1b4dbfefd915b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'article' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => ['draft'], 'places' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php index 35a9df3730b2a..aef7f50958708 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'article' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => ['draft'], 'places' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php index e4eefd4c28440..2870958957322 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php @@ -1,6 +1,6 @@ loadFromExtension('framework', [ 'workflows' => [ @@ -11,7 +11,7 @@ 'property' => 'state', ], 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'events_to_dispatch' => [], 'places' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php index 0fc5c29c8b43e..a0414cee2c146 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php @@ -1,6 +1,6 @@ loadFromExtension('framework', [ 'workflows' => [ @@ -11,7 +11,7 @@ 'property' => 'state', ], 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'events_to_dispatch' => [ 'workflow.leave', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php index 063755b130d34..c2acce1560dfa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'my_workflow' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'support_strategy' => 'foobar', 'places' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php index 995fabffe38b7..fd2d71459af83 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php @@ -1,13 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'article' => [ 'type' => 'workflow', 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => ['draft'], 'metadata' => [ @@ -43,7 +43,7 @@ ], 'pull_request' => [ 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'initial_marking' => 'start', 'metadata' => [ @@ -102,7 +102,7 @@ 'service' => 'workflow_service', ], 'supports' => [ - FrameworkExtensionTest::class, + FrameworkExtensionTestCase::class, ], 'places' => [ ['name' => 'first'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php index f048de1ceb5ad..53ce0ec076bdb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php @@ -1,11 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'enabled' => true, 'foo' => [ 'type' => 'workflow', - 'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'], + 'supports' => [FrameworkExtensionTestCase::class], 'initial_marking' => ['bar'], 'places' => ['bar', 'baz'], 'transitions' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php index f79a2d10e97f9..b954889b6aa0d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php @@ -1,11 +1,13 @@ loadFromExtension('framework', [ 'workflows' => [ 'enabled' => true, 'workflows' => [ 'type' => 'workflow', - 'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'], + 'supports' => [FrameworkExtensionTestCase::class], 'initial_marking' => ['bar'], 'places' => ['bar', 'baz'], 'transitions' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml index df299c89deb50..1aa7b099a8f84 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_not_valid.xml @@ -8,7 +8,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml index ffc12c4d0d420..6420f099b39c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml @@ -9,7 +9,7 @@ draft - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase draft wait_for_journalist approved_by_journalist diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml index db79f9323c47e..815c83aff2fb8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml @@ -9,7 +9,7 @@ draft - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml index 2f563da4bf96b..4842e54bf1b52 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_no_events_to_dispatch.xml @@ -10,7 +10,7 @@ one - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml index d442828f8cfbf..d154c91b5373d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_specified_events_to_dispatch.xml @@ -10,7 +10,7 @@ one - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase workflow.leave workflow.completed diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml index 54a346ebda198..c6170b6fe0f8b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml @@ -8,7 +8,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml index 79361af57a61f..ba373aad2863c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml @@ -11,7 +11,7 @@ draft - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase @@ -45,7 +45,7 @@ start - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase place start title @@ -96,7 +96,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase first last diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml index af93d44e18387..c27c51d0617f4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml @@ -7,7 +7,7 @@ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase bar baz diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml index 41fd29a1f27d9..34e58c86d41fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml @@ -8,7 +8,7 @@ bar - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase bar baz diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml index 123505de9754f..2228751bfec47 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_not_valid.yml @@ -3,7 +3,7 @@ framework: my_workflow: type: state_machine supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: [first, middle, last] transitions: go: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml index 80a85a307b738..d3012f77a2771 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml @@ -3,7 +3,7 @@ framework: article: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [draft] places: - draft diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml index 12df7b79e7c4f..d5e3f7feccbe4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml @@ -3,7 +3,7 @@ framework: article: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [draft] places: - draft diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml index e0a281f27db46..dadc418997ea7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_no_events_to_dispatch.yml @@ -8,7 +8,7 @@ framework: type: method property: state supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: - one - two diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml index d5ff3d5e5fe0d..98fe5d961a06a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_specified_events_to_dispatch.yml @@ -8,7 +8,7 @@ framework: type: method property: state supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: - one - two diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml index de0b36d8fa491..1b043700b5c2d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml @@ -3,7 +3,7 @@ framework: my_workflow: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase support_strategy: foobar places: - first diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml index e4ac9c01890e3..455ec72713553 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml @@ -3,7 +3,7 @@ framework: article: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [draft] metadata: title: article workflow @@ -31,7 +31,7 @@ framework: to: [published] pull_request: supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: start metadata: title: workflow title @@ -74,7 +74,7 @@ framework: marking_store: service: workflow_service supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase places: - { name: first } - { name: last } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml index bbecf4bfc420e..685ea9733094c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml @@ -5,7 +5,7 @@ framework: foo: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [bar] places: - bar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml index 786e3bcad292e..d97e72bb3e58a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml @@ -4,7 +4,7 @@ framework: workflows: type: workflow supports: - - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase initial_marking: [bar] places: - bar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php similarity index 99% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index f212a6db89ffa..a1c67eef1874c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -79,7 +79,7 @@ use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; -abstract class FrameworkExtensionTest extends TestCase +abstract class FrameworkExtensionTestCase extends TestCase { use ExpectDeprecationTrait; @@ -1751,7 +1751,7 @@ public function testAppRedisTagAwareAdapter(string $configFile) } } - public function appRedisTagAwareConfigProvider(): array + public static function appRedisTagAwareConfigProvider(): array { return [ ['cache_app_redis_tag_aware'], @@ -1930,7 +1930,7 @@ public function testHttpClientFullDefaultOptions() ], $defaultOptions['peer_fingerprint']); } - public function provideMailer(): array + public static function provideMailer(): array { return [ ['mailer_with_dsn', ['main' => 'smtp://example.com']], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index d9f4b1192f456..c763e2bd211b4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\Workflow\Exception\InvalidDefinitionException; -class PhpFrameworkExtensionTest extends FrameworkExtensionTest +class PhpFrameworkExtensionTest extends FrameworkExtensionTestCase { protected function loadFromFile(ContainerBuilder $container, $file) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php index 131bb07f0c657..944e19709e5b1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -class XmlFrameworkExtensionTest extends FrameworkExtensionTest +class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase { protected function loadFromFile(ContainerBuilder $container, $file) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php index 457467aa11d77..cb5a0a5e16f6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -class YamlFrameworkExtensionTest extends FrameworkExtensionTest +class YamlFrameworkExtensionTest extends FrameworkExtensionTestCase { protected function loadFromFile(ContainerBuilder $container, $file) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php index 20d3609c16a84..e8641eac8bbfb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php @@ -29,7 +29,7 @@ public function testAnnotatedController($path, $expectedValue) $this->assertSame('/annotated/create-transaction', $router->generate('symfony_framework_tests_functional_test_annotated_createtransaction')); } - public function getRoutes() + public static function getRoutes() { return [ ['/null_request', 'Symfony\Component\HttpFoundation\Request'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index 2bebd2d77a3e9..2608966586a78 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -26,6 +26,7 @@ public function testCachePools() /** * @requires extension redis + * * @group integration */ public function testRedisCachePools() @@ -49,6 +50,7 @@ public function testRedisCachePools() /** * @requires extension redis + * * @group integration */ public function testRedisCustomCachePools() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php index 463318af39f47..11afd0d8a5fdc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php @@ -138,7 +138,7 @@ public function testComplete(array $input, array $expectedSuggestions) } } - public function provideCompletionSuggestions(): \Generator + public static function provideCompletionSuggestions(): \Generator { yield 'name' => [[''], ['default_config_test', 'extension_without_config_test', 'framework', 'test']]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php index 4747b785f8149..e944960aea4e7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php @@ -103,7 +103,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'name' => [[''], ['DefaultConfigTestBundle', 'default_config_test', 'ExtensionWithoutConfigTestBundle', 'extension_without_config_test', 'FrameworkBundle', 'framework', 'TestBundle', 'test']]; yield 'option --format' => [['--format', ''], ['yaml', 'xml']]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php index ee56012d307ca..63c717b7b41b6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php @@ -204,7 +204,7 @@ public function testGetDeprecationNoFile() $this->assertStringContainsString('[WARNING] The deprecation file does not exist', $tester->getDisplay()); } - public function provideIgnoreBackslashWhenFindingService() + public static function provideIgnoreBackslashWhenFindingService() { return [ [BackslashClass::class], @@ -232,7 +232,7 @@ public function testComplete(array $input, array $expectedSuggestions, array $no } } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { $serviceId = 'console.command.container_debug'; $hiddenServiceId = '.console.command.container_debug.lazy'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php index c3110cc71dcbb..345589c1b6fc2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php @@ -129,7 +129,7 @@ public function testComplete(array $input, array $expectedSuggestions) } } - public function provideCompletionSuggestions(): \Generator + public static function provideCompletionSuggestions(): \Generator { yield 'search' => [[''], ['SessionHandlerInterface', 'Psr\\Log\\LoggerInterface', 'Psr\\Container\\ContainerInterface $parameterBag']]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php index b514ed3b8e042..6d8966a171ba2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php @@ -37,7 +37,7 @@ public function testFragment($insulate) , $client->getResponse()->getContent()); } - public function getConfigs() + public static function getConfigs() { return [ [false], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php index 7b65ca5c276e8..d7825979536e5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php @@ -57,7 +57,7 @@ public function testProfilerCollectParameter($insulate) $this->assertNull($client->getProfile()); } - public function getConfigs() + public static function getConfigs() { return [ [false], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php index 82e6bf8bb1505..6b8eb6b7f0cbf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php @@ -100,7 +100,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php index d97039562119c..c26fa717d9176 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php @@ -33,7 +33,7 @@ public function testLoginUser(string $username, array $roles, ?string $firewallC $this->assertEquals('Welcome '.$username.'!', $client->getResponse()->getContent()); } - public function getUsers() + public static function getUsers() { yield ['the-username', ['ROLE_FOO'], null]; yield ['the-username', ['ROLE_FOO'], 'main']; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php index aaf6ad49ccca1..9a6527b14dd62 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php @@ -52,7 +52,7 @@ public function testNormalizersAndEncodersUseDefaultContextConfigOption(string $ self::assertEquals('foo', $defaultContext['fake_context_option']); } - public function provideNormalizersAndEncodersWithDefaultContextOption(): array + public static function provideNormalizersAndEncodersWithDefaultContextOption(): array { return [ ['serializer.normalizer.constraint_violation_list.alias'], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php index 7d66ff1726657..6ec96bafe2826 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php @@ -77,6 +77,7 @@ public function testFlash($config, $insulate) * Tests flash messages work when flashbag service is injected to the constructor. * * @group legacy + * * @dataProvider getConfigs */ public function testFlashOnInjectedFlashbag($config, $insulate) @@ -101,6 +102,7 @@ public function testFlashOnInjectedFlashbag($config, $insulate) /** * @group legacy + * * @dataProvider getConfigs */ public function testSessionServiceTriggerDeprecation($config, $insulate) @@ -194,7 +196,7 @@ public function testCorrectCacheControlHeadersForCacheableAction($config, $insul $this->assertSame('public, s-maxage=100', $response->headers->get('cache-control')); } - public function getConfigs() + public static function getConfigs() { return [ // configfile, insulate diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index cdcaa490ac423..d8ad6e2cf6b89 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -511,7 +511,7 @@ public function testBooleanContainerParametersWithinRouteCondition() $this->assertSame('1 or 0', $route->getCondition()); } - public function getNonStringValues() + public static function getNonStringValues() { return [[null], [false], [true], [new \stdClass()], [['foo', 'bar']], [[[]]]]; } @@ -591,7 +591,7 @@ public function testResolvingMethods() $this->assertEquals(['GET', 'POST'], $route->getMethods()); } - public function getContainerParameterForRoute() + public static function getContainerParameterForRoute() { yield 'String' => ['"foo"']; yield 'Integer' => [0]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php index f6098ea6e8eca..8f0c8fb42b573 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php @@ -238,16 +238,18 @@ public function testAssertInputValueNotSame() public function testAssertCheckboxChecked() { $this->getCrawlerTester(new Crawler(''))->assertCheckboxChecked('rememberMe'); + $this->getCrawlerTester(new Crawler(''))->assertCheckboxChecked('rememberMe'); $this->expectException(AssertionFailedError::class); - $this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and has a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".'); + $this->expectExceptionMessage('matches selector "input[name="rememberMe"]:checked".'); $this->getCrawlerTester(new Crawler(''))->assertCheckboxChecked('rememberMe'); } public function testAssertCheckboxNotChecked() { $this->getCrawlerTester(new Crawler(''))->assertCheckboxNotChecked('rememberMe'); + $this->getCrawlerTester(new Crawler(''))->assertCheckboxNotChecked('rememberMe'); $this->expectException(AssertionFailedError::class); - $this->expectExceptionMessage('matches selector "input[name="rememberMe"]" and does not have a node matching selector "input[name="rememberMe"]" with attribute "checked" of value "checked".'); + $this->expectExceptionMessage('does not match selector "input[name="rememberMe"]:checked".'); $this->getCrawlerTester(new Crawler(''))->assertCheckboxNotChecked('rememberMe'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 8698de198fffc..583ebbb774666 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -177,7 +177,7 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e $translator->trans('some_message', [], null, 'some_locale'); } - public function getDebugModeAndCacheDirCombinations() + public static function getDebugModeAndCacheDirCombinations() { return [ [false, false], diff --git a/src/Symfony/Bundle/SecurityBundle/LICENSE b/src/Symfony/Bundle/SecurityBundle/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bundle/SecurityBundle/LICENSE +++ b/src/Symfony/Bundle/SecurityBundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.php b/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.php index a57add5e51c3d..4697e135d80c2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.php +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.php @@ -49,6 +49,7 @@ abstract_arg('Authenticators'), service('logger')->nullOnInvalid(), param('security.authentication.hide_user_not_found'), + service('security.token_storage'), ]) ->tag('monolog.logger', ['channel' => 'security']) ->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.') diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index b5ed1ad849276..b092b8a18d0e6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -24,6 +24,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter; @@ -32,6 +33,7 @@ use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; +use Symfony\Component\VarDumper\Caster\ClassStub; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class SecurityDataCollectorTest extends TestCase @@ -222,17 +224,36 @@ public function testGetListeners() $this->assertSame(1, $listenerCalled); } - public function providerCollectDecisionLog(): \Generator + public function testCollectCollectsDecisionLogWhenStrategyIsAffirmative() { - $voter1 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass(); - $voter2 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass(); + $voter1 = new DummyVoter(); + $voter2 = new DummyVoter(); - $eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass(); - $decoratedVoter1 = new TraceableVoter($voter1, $eventDispatcher); + $decoratedVoter1 = new TraceableVoter($voter1, new class() implements EventDispatcherInterface { + public function dispatch(object $event, string $eventName = null): object + { + return new \stdClass(); + } + }); - yield [ - MainConfiguration::STRATEGY_AFFIRMATIVE, - [[ + $strategy = MainConfiguration::STRATEGY_AFFIRMATIVE; + + $accessDecisionManager = $this->createMock(TraceableAccessDecisionManager::class); + + $accessDecisionManager + ->method('getStrategy') + ->willReturn($strategy); + + $accessDecisionManager + ->method('getVoters') + ->willReturn([ + $decoratedVoter1, + $decoratedVoter1, + ]); + + $accessDecisionManager + ->method('getDecisionLog') + ->willReturn([[ 'attributes' => ['view'], 'object' => new \stdClass(), 'result' => true, @@ -240,23 +261,74 @@ public function providerCollectDecisionLog(): \Generator ['voter' => $voter1, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], ['voter' => $voter2, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], ], - ]], - [$decoratedVoter1, $decoratedVoter1], - [\get_class($voter1), \get_class($voter2)], - [[ - 'attributes' => ['view'], - 'object' => new \stdClass(), - 'result' => true, - 'voter_details' => [ - ['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], - ['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], - ], - ]], + ]]); + + $dataCollector = new SecurityDataCollector(null, null, null, $accessDecisionManager, null, null, true); + + $dataCollector->collect(new Request(), new Response()); + + $actualDecisionLog = $dataCollector->getAccessDecisionLog(); + + $expectedDecisionLog = [[ + 'attributes' => ['view'], + 'object' => new \stdClass(), + 'result' => true, + 'voter_details' => [ + ['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], + ['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], + ], + ]]; + + $this->assertEquals($actualDecisionLog, $expectedDecisionLog, 'Wrong value returned by getAccessDecisionLog'); + + $actualVoterClasses = array_map(static function (ClassStub $classStub): string { + return (string) $classStub; + }, $dataCollector->getVoters()); + + $expectedVoterClasses = [ + \get_class($voter1), + \get_class($voter2), ]; - yield [ - MainConfiguration::STRATEGY_UNANIMOUS, - [ + $this->assertSame( + $actualVoterClasses, + $expectedVoterClasses, + 'Wrong value returned by getVoters' + ); + + $this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy'); + } + + public function testCollectCollectsDecisionLogWhenStrategyIsUnanimous() + { + $voter1 = new DummyVoter(); + $voter2 = new DummyVoter(); + + $decoratedVoter1 = new TraceableVoter($voter1, new class() implements EventDispatcherInterface { + public function dispatch(object $event, string $eventName = null): object + { + return new \stdClass(); + } + }); + + $strategy = MainConfiguration::STRATEGY_UNANIMOUS; + + $accessDecisionManager = $this->createMock(TraceableAccessDecisionManager::class); + + $accessDecisionManager + ->method('getStrategy') + ->willReturn($strategy); + + $accessDecisionManager + ->method('getVoters') + ->willReturn([ + $decoratedVoter1, + $decoratedVoter1, + ]); + + $accessDecisionManager + ->method('getDecisionLog') + ->willReturn([ [ 'attributes' => ['view', 'edit'], 'object' => new \stdClass(), @@ -277,82 +349,58 @@ public function providerCollectDecisionLog(): \Generator ['voter' => $voter2, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], ], ], - ], - [$decoratedVoter1, $decoratedVoter1], - [\get_class($voter1), \get_class($voter2)], + ]); + + $dataCollector = new SecurityDataCollector(null, null, null, $accessDecisionManager, null, null, true); + + $dataCollector->collect(new Request(), new Response()); + + $actualDecisionLog = $dataCollector->getAccessDecisionLog(); + + $expectedDecisionLog = [ [ - [ - 'attributes' => ['view', 'edit'], - 'object' => new \stdClass(), - 'result' => false, - 'voter_details' => [ - ['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED], - ['class' => \get_class($voter1), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED], - ['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED], - ['class' => \get_class($voter2), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED], - ], + 'attributes' => ['view', 'edit'], + 'object' => new \stdClass(), + 'result' => false, + 'voter_details' => [ + ['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED], + ['class' => \get_class($voter1), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED], + ['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => \get_class($voter2), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED], ], - [ - 'attributes' => ['update'], - 'object' => new \stdClass(), - 'result' => true, - 'voter_details' => [ - ['class' => \get_class($voter1), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], - ['class' => \get_class($voter2), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], - ], + ], + [ + 'attributes' => ['update'], + 'object' => new \stdClass(), + 'result' => true, + 'voter_details' => [ + ['class' => \get_class($voter1), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => \get_class($voter2), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], ], ], ]; - } - - /** - * Test the returned data when AccessDecisionManager is a TraceableAccessDecisionManager. - * - * @param string $strategy strategy returned by the AccessDecisionManager - * @param array $voters voters returned by AccessDecisionManager - * @param array $decisionLog log of the votes and final decisions from AccessDecisionManager - * @param array $expectedVoterClasses expected voter classes returned by the collector - * @param array $expectedDecisionLog expected decision log returned by the collector - * - * @dataProvider providerCollectDecisionLog - */ - public function testCollectDecisionLog(string $strategy, array $decisionLog, array $voters, array $expectedVoterClasses, array $expectedDecisionLog) - { - $accessDecisionManager = $this - ->getMockBuilder(TraceableAccessDecisionManager::class) - ->disableOriginalConstructor() - ->setMethods(['getStrategy', 'getVoters', 'getDecisionLog']) - ->getMock(); - $accessDecisionManager - ->expects($this->any()) - ->method('getStrategy') - ->willReturn($strategy); + $this->assertEquals($actualDecisionLog, $expectedDecisionLog, 'Wrong value returned by getAccessDecisionLog'); - $accessDecisionManager - ->expects($this->any()) - ->method('getVoters') - ->willReturn($voters); + $actualVoterClasses = array_map(static function (ClassStub $classStub): string { + return (string) $classStub; + }, $dataCollector->getVoters()); - $accessDecisionManager - ->expects($this->any()) - ->method('getDecisionLog') - ->willReturn($decisionLog); - - $dataCollector = new SecurityDataCollector(null, null, null, $accessDecisionManager, null, null, true); - $dataCollector->collect(new Request(), new Response()); - - $this->assertEquals($dataCollector->getAccessDecisionLog(), $expectedDecisionLog, 'Wrong value returned by getAccessDecisionLog'); + $expectedVoterClasses = [ + \get_class($voter1), + \get_class($voter2), + ]; $this->assertSame( - array_map(function ($classStub) { return (string) $classStub; }, $dataCollector->getVoters()), + $actualVoterClasses, $expectedVoterClasses, 'Wrong value returned by getVoters' ); + $this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy'); } - public function provideRoles() + public static function provideRoles() { return [ // Basic roles @@ -383,3 +431,10 @@ private function getRoleHierarchy() ]); } } + +final class DummyVoter implements VoterInterface +{ + public function vote(TokenInterface $token, $subject, array $attributes) + { + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php index bd0ea68520abe..0e45e2c89132a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php @@ -70,7 +70,7 @@ public function testEventIsPropagated(string $configuredEvent, string $registere ]); } - public function providePropagatedEvents(): array + public static function providePropagatedEvents(): array { return [ [CheckPassportEvent::class, CheckPassportEvent::class], diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTestCase.php similarity index 99% rename from src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php rename to src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTestCase.php index 155254729a808..9d44294a518d5 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTestCase.php @@ -31,7 +31,7 @@ use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge; -abstract class CompleteConfigurationTest extends TestCase +abstract class CompleteConfigurationTestCase extends TestCase { abstract protected function getLoader(ContainerBuilder $container); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/PhpCompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/PhpCompleteConfigurationTest.php index 846d01d5337ca..c4297c7b9c0e1 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/PhpCompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/PhpCompleteConfigurationTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -class PhpCompleteConfigurationTest extends CompleteConfigurationTest +class PhpCompleteConfigurationTest extends CompleteConfigurationTestCase { protected function getLoader(ContainerBuilder $container) { 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 8bb45f7cea2e2..e46a36a44fbe4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php @@ -86,7 +86,7 @@ public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection) } } - public function getFailureHandlers() + public static function getFailureHandlers() { return [ [null, true], @@ -135,7 +135,7 @@ public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection) } } - public function getSuccessHandlers() + public static function getSuccessHandlers() { return [ [null, true], diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php index f13f5c35a90df..1a2f77079575b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php @@ -54,7 +54,7 @@ public function testAddInvalidConfiguration(array $inputConfig) $node->finalize($normalizedConfig); } - public function getValidConfigurationTests() + public static function getValidConfigurationTests() { $tests = []; @@ -86,7 +86,7 @@ public function getValidConfigurationTests() return $tests; } - public function getInvalidConfigurationTests() + public static function getInvalidConfigurationTests() { $tests = []; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 684e43e28a503..71ca327ca40c6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -403,6 +403,7 @@ public function testFirewallWithNoUserProviderTriggerDeprecation() /** * @dataProvider sessionConfigurationProvider + * * @group legacy */ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $samesite, $secure) @@ -525,7 +526,7 @@ public function testSecretRememberMeHandler() $this->assertSame('very', $handler->getArgument(1)); } - public function sessionConfigurationProvider() + public static function sessionConfigurationProvider() { return [ [ @@ -546,7 +547,7 @@ public function sessionConfigurationProvider() ]; } - public function acceptableIpsProvider(): iterable + public static function acceptableIpsProvider(): iterable { yield [['127.0.0.1']]; yield ['127.0.0.1']; @@ -634,6 +635,7 @@ public function testValidAccessControlWithEmptyRow() /** * @group legacy + * * @dataProvider provideEntryPointFirewalls */ public function testAuthenticatorManagerEnabledEntryPoint(array $firewall, $entryPointId) @@ -657,7 +659,7 @@ public function testAuthenticatorManagerEnabledEntryPoint(array $firewall, $entr $this->assertEquals($entryPointId, (string) $container->getDefinition('security.exception_listener.main')->getArgument(4)); } - public function provideEntryPointFirewalls() + public static function provideEntryPointFirewalls() { // only one entry point available yield [['http_basic' => true], 'security.authenticator.http_basic.main']; @@ -697,7 +699,7 @@ public function testEntryPointRequired(array $firewall, $messageRegex) $container->compile(); } - public function provideEntryPointRequiredData() + public static function provideEntryPointRequiredData() { // more than one entry point available and not explicitly set yield [ @@ -747,7 +749,7 @@ public function testConfigureCustomAuthenticator(array $firewall, array $expecte $this->assertEquals($expectedAuthenticators, array_map('strval', $container->getDefinition('security.authenticator.manager.main')->getArgument(0))); } - public function provideConfigureCustomAuthenticatorData() + public static function provideConfigureCustomAuthenticatorData() { yield [ ['custom_authenticator' => TestAuthenticator::class], @@ -827,7 +829,7 @@ public function testUserCheckerWithAuthenticatorManager(array $config, string $e $this->assertEquals($expectedUserCheckerClass, $container->findDefinition($userCheckerId)->getClass()); } - public function provideUserCheckerConfig() + public static function provideUserCheckerConfig() { yield [[], InMemoryUserChecker::class]; yield [['user_checker' => TestUserChecker::class], TestUserChecker::class]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCompleteConfigurationTest.php index 00006a756a2ec..eccfabef77950 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCompleteConfigurationTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -class XmlCompleteConfigurationTest extends CompleteConfigurationTest +class XmlCompleteConfigurationTest extends CompleteConfigurationTestCase { protected function getLoader(ContainerBuilder $container) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/YamlCompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/YamlCompleteConfigurationTest.php index 8e3954a057daf..4fd2d44e117c1 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/YamlCompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/YamlCompleteConfigurationTest.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -class YamlCompleteConfigurationTest extends CompleteConfigurationTest +class YamlCompleteConfigurationTest extends CompleteConfigurationTestCase { protected function getLoader(ContainerBuilder $container) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php index 970a9dc9ae746..ca99dbf3eadab 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php @@ -60,7 +60,7 @@ public function testWithoutUserProvider($email) $this->assertJsonStringEqualsJsonString('{"email":"'.$email.'"}', $client->getResponse()->getContent()); } - public function provideEmails() + public static function provideEmails() { yield ['jane@example.org', true]; yield ['john@example.org', false]; @@ -84,7 +84,7 @@ public function testLoginUsersWithMultipleFirewalls(string $username, string $fi $this->assertEquals('Welcome '.$username.'!', $client->getResponse()->getContent()); } - public function provideEmailsWithFirewalls() + public static function provideEmailsWithFirewalls() { yield ['jane@example.org', 'main']; yield ['john@example.org', 'custom']; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php index 56022240e32dc..853fc1dc8d018 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php @@ -124,6 +124,7 @@ public function testFormLoginRedirectsToProtectedResourceAfterLogin($options) /** * @group legacy + * * @dataProvider provideLegacyClientOptions */ public function testLegacyFormLoginAndLogoutWithCsrfTokens($options) @@ -154,6 +155,7 @@ public function testLegacyFormLoginAndLogoutWithCsrfTokens($options) /** * @group legacy + * * @dataProvider provideLegacyClientOptions */ public function testLegacyFormLoginWithInvalidCsrfToken($options) @@ -172,6 +174,7 @@ public function testLegacyFormLoginWithInvalidCsrfToken($options) /** * @group legacy + * * @dataProvider provideLegacyClientOptions */ public function testFormLegacyLoginWithCustomTargetPath($options) @@ -193,6 +196,7 @@ public function testFormLegacyLoginWithCustomTargetPath($options) /** * @group legacy + * * @dataProvider provideLegacyClientOptions */ public function testLegacyFormLoginRedirectsToProtectedResourceAfterLogin($options) @@ -213,13 +217,13 @@ public function testLegacyFormLoginRedirectsToProtectedResourceAfterLogin($optio $this->assertStringContainsString('You\'re browsing to path "/protected-resource".', $text); } - public function provideClientOptions() + public static function provideClientOptions() { yield [['test_case' => 'CsrfFormLogin', 'root_config' => 'config.yml', 'enable_authenticator_manager' => true]]; yield [['test_case' => 'CsrfFormLogin', 'root_config' => 'routes_as_path.yml', 'enable_authenticator_manager' => true]]; } - public function provideLegacyClientOptions() + public static function provideLegacyClientOptions() { yield [['test_case' => 'CsrfFormLogin', 'root_config' => 'legacy_config.yml', 'enable_authenticator_manager' => false]]; yield [['test_case' => 'CsrfFormLogin', 'root_config' => 'legacy_routes_as_path.yml', 'enable_authenticator_manager' => false]]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php index b1d38f40ef1c8..9787047ac3d7d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php @@ -155,6 +155,7 @@ public function testLoginThrottling() /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyFormLogin(array $options) @@ -175,6 +176,7 @@ public function testLegacyFormLogin(array $options) /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyFormLogout(array $options) @@ -209,6 +211,7 @@ public function testLegacyFormLogout(array $options) /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyFormLoginWithCustomTargetPath(array $options) @@ -230,6 +233,7 @@ public function testLegacyFormLoginWithCustomTargetPath(array $options) /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyFormLoginRedirectsToProtectedResourceAfterLogin(array $options) @@ -296,13 +300,13 @@ public function testLegacyLoginThrottling() } } - public function provideClientOptions() + public static function provideClientOptions() { yield [['test_case' => 'StandardFormLogin', 'root_config' => 'base_config.yml', 'enable_authenticator_manager' => true]]; yield [['test_case' => 'StandardFormLogin', 'root_config' => 'routes_as_path.yml', 'enable_authenticator_manager' => true]]; } - public function provideLegacyClientOptions() + public static function provideLegacyClientOptions() { yield [['test_case' => 'StandardFormLogin', 'root_config' => 'legacy_config.yml', 'enable_authenticator_manager' => false]]; yield [['test_case' => 'StandardFormLogin', 'root_config' => 'legacy_routes_as_path.yml', 'enable_authenticator_manager' => false]]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php index a6efa746a372a..0563bb225b5ba 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php @@ -36,6 +36,7 @@ public function testLoginLogoutProcedure($locale, array $options) /** * @group issue-32995 + * * @dataProvider getLocalesAndClientConfig */ public function testLoginFailureWithLocalizedFailurePath($locale, array $options) @@ -75,6 +76,7 @@ public function testAccessRestrictedResourceWithForward($locale, array $options) /** * @group legacy + * * @dataProvider getLegacyLocalesAndClientConfig */ public function testLegacyLoginLogoutProcedure($locale, array $options) @@ -98,6 +100,7 @@ public function testLegacyLoginLogoutProcedure($locale, array $options) /** * @group issue-32995 * @group legacy + * * @dataProvider getLegacyLocalesAndClientConfig */ public function testLegacyLoginFailureWithLocalizedFailurePath($locale, array $options) @@ -115,6 +118,7 @@ public function testLegacyLoginFailureWithLocalizedFailurePath($locale, array $o /** * @group legacy + * * @dataProvider getLegacyLocalesAndClientConfig */ public function testLegacyAccessRestrictedResource($locale, array $options) @@ -127,6 +131,7 @@ public function testLegacyAccessRestrictedResource($locale, array $options) /** * @group legacy + * * @dataProvider getLegacyLocalesAndClientConfig */ public function testLegacyAccessRestrictedResourceWithForward($locale, array $options) @@ -137,13 +142,13 @@ public function testLegacyAccessRestrictedResourceWithForward($locale, array $op $this->assertCount(1, $crawler->selectButton('login'), (string) $client->getResponse()); } - public function getLocalesAndClientConfig() + public static function getLocalesAndClientConfig() { yield ['en', ['root_config' => 'localized_routes.yml']]; yield ['de', ['root_config' => 'localized_routes.yml']]; } - public function getLegacyLocalesAndClientConfig() + public static function getLegacyLocalesAndClientConfig() { yield ['en', ['root_config' => 'legacy_localized_routes.yml']]; yield ['de', ['root_config' => 'legacy_localized_routes.yml']]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php index d581238c7dab8..10dd7b6885baa 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php @@ -33,6 +33,7 @@ public function testSessionRememberMeSecureCookieFlagAuto($https, $expectedSecur /** * @dataProvider getSessionRememberMeSecureCookieFlagAutoHttpsMap + * * @group legacy */ public function testLegacySessionRememberMeSecureCookieFlagAuto($https, $expectedSecureFlag) @@ -50,7 +51,7 @@ public function testLegacySessionRememberMeSecureCookieFlagAuto($https, $expecte $this->assertSame($expectedSecureFlag, $cookies['']['/']['REMEMBERME']->isSecure()); } - public function getSessionRememberMeSecureCookieFlagAutoHttpsMap() + public static function getSessionRememberMeSecureCookieFlagAutoHttpsMap() { return [ [true, true], diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php index c1958c7dee3ff..26f963df21b35 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php @@ -95,6 +95,7 @@ public function testSessionLessRememberMeLogout() /** * @dataProvider provideLegacyConfigs + * * @group legacy */ public function testLegacyRememberMe(array $options) @@ -174,13 +175,13 @@ public function testLegacySessionLessRememberMeLogout() $this->assertNull($cookieJar->get('REMEMBERME')); } - public function provideConfigs() + public static function provideConfigs() { yield [['root_config' => 'config_session.yml']]; yield [['root_config' => 'config_persistent.yml']]; } - public function provideLegacyConfigs() + public static function provideLegacyConfigs() { yield [['root_config' => 'legacy_config_session.yml']]; yield [['root_config' => 'legacy_config_persistent.yml']]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index 788599224e47e..ab5977475b08e 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -141,6 +141,7 @@ public function testPublicHomepage() /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous(array $options) @@ -153,6 +154,7 @@ public function testLegacyRoutingErrorIsNotExposedForProtectedResourceWhenAnonym /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyRoutingErrorIsExposedWhenNotProtected(array $options) @@ -165,6 +167,7 @@ public function testLegacyRoutingErrorIsExposedWhenNotProtected(array $options) /** * @dataProvider provideLegacyClientOptions + * * @group legacy */ public function testLegacyRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights(array $options) @@ -183,6 +186,7 @@ public function testLegacyRoutingErrorIsNotExposedForProtectedResourceWhenLogged /** * @group legacy + * * @dataProvider provideLegacyClientOptions */ public function testLegacySecurityConfigurationForSingleIPAddress(array $options) @@ -199,6 +203,7 @@ public function testLegacySecurityConfigurationForSingleIPAddress(array $options /** * @group legacy + * * @dataProvider provideLegacyClientOptions */ public function testLegacySecurityConfigurationForMultipleIPAddresses(array $options) @@ -229,6 +234,7 @@ public function testLegacySecurityConfigurationForMultipleIPAddresses(array $opt /** * @group legacy + * * @dataProvider provideLegacyConfigs */ public function testLegacySecurityConfigurationForExpression(array $options) @@ -289,25 +295,25 @@ private function assertRestricted($client, $path) $this->assertEquals(302, $client->getResponse()->getStatusCode()); } - public function provideClientOptions() + public static function provideClientOptions() { yield [['test_case' => 'StandardFormLogin', 'root_config' => 'base_config.yml', 'enable_authenticator_manager' => true]]; yield [['test_case' => 'StandardFormLogin', 'root_config' => 'routes_as_path.yml', 'enable_authenticator_manager' => true]]; } - public function provideLegacyClientOptions() + public static function provideLegacyClientOptions() { yield [['test_case' => 'StandardFormLogin', 'root_config' => 'base_config.yml', 'enable_authenticator_manager' => true]]; yield [['test_case' => 'StandardFormLogin', 'root_config' => 'routes_as_path.yml', 'enable_authenticator_manager' => true]]; } - public function provideConfigs() + public static function provideConfigs() { yield [['test_case' => 'StandardFormLogin', 'root_config' => 'base_config.yml']]; yield [['test_case' => 'StandardFormLogin', 'root_config' => 'routes_as_path.yml']]; } - public function provideLegacyConfigs() + public static function provideLegacyConfigs() { yield [['test_case' => 'StandardFormLogin', 'root_config' => 'legacy_config.yml']]; yield [['test_case' => 'StandardFormLogin', 'root_config' => 'legacy_routes_as_path.yml']]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php index 418bb55f14454..8604f0b1f84c4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php @@ -66,6 +66,7 @@ public function testUserWillBeMarkedAsChangedIfRolesHasChanged(UserInterface $us /** * @dataProvider userWillBeMarkedAsChangedIfRolesHasChangedProvider + * * @group legacy */ public function testLegacyUserWillBeMarkedAsChangedIfRolesHasChanged(UserInterface $userWithAdminRole, UserInterface $userWithoutAdminRole) @@ -113,7 +114,7 @@ public function testLegacyServiceIsFunctional() $this->assertSame($token, $security->getToken()); } - public function userWillBeMarkedAsChangedIfRolesHasChangedProvider() + public static function userWillBeMarkedAsChangedIfRolesHasChangedProvider() { return [ [ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php index ac86e4815f601..da257be3f9b03 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php @@ -85,7 +85,7 @@ public function testSwitchUserStateless(array $options) $this->assertSame('dunglas', $client->getProfile()->getCollector('security')->getUser()); } - public function getTestParameters() + public static function getTestParameters() { return [ 'unauthorized_user_cannot_switch' => ['user_cannot_switch_1', 'user_cannot_switch_1', 'user_cannot_switch_1', 403], @@ -95,7 +95,7 @@ public function getTestParameters() ]; } - public function getLegacyTestParameters() + public static function getLegacyTestParameters() { return [ 'legacy_unauthorized_user_cannot_switch' => ['user_cannot_switch_1', 'user_cannot_switch_1', 'user_cannot_switch_1', 403], diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index f373fc14f52b4..cc856fb509fd9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -25,6 +25,7 @@ * Tests UserPasswordEncoderCommand. * * @author Sarah Khalil + * * @group legacy */ class UserPasswordEncoderCommandTest extends AbstractWebTestCase diff --git a/src/Symfony/Bundle/TwigBundle/LICENSE b/src/Symfony/Bundle/TwigBundle/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bundle/TwigBundle/LICENSE +++ b/src/Symfony/Bundle/TwigBundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 1cc9c0ebf3e5c..660c7fd07dcd1 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -199,7 +199,7 @@ public function testTwigLoaderPaths($format) ], $paths); } - public function getFormats() + public static function getFormats() { return [ ['php'], @@ -230,7 +230,7 @@ public function testStopwatchExtensionAvailability($debug, $stopwatchEnabled, $e $this->assertSame($expected, $stopwatchIsAvailable->getValue($tokenParsers[0])); } - public function stopwatchExtensionAvailabilityProvider() + public static function stopwatchExtensionAvailabilityProvider() { return [ 'debug-and-stopwatch-enabled' => [true, true, true], diff --git a/src/Symfony/Bundle/WebProfilerBundle/LICENSE b/src/Symfony/Bundle/WebProfilerBundle/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/LICENSE +++ b/src/Symfony/Bundle/WebProfilerBundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig index b1642d4e19d2e..9f94dde657fce 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig @@ -131,8 +131,10 @@ - Time - Message + + Time + Message + @@ -185,7 +187,7 @@

Container Compilation Logs ({{ compilerLogTotal }})

-

Log messages generated during the compilation of the service container.

+ Log messages generated during the compilation of the service container.
{% if collector.compilerLogs is empty %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig index dab2e9c6c0c67..f7ea5a1f42ace 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig @@ -121,18 +121,18 @@

Headers

Subject -

{{ message.headers.get('subject').bodyAsString() ?? '(empty)' }}

+

{{ message.getSubject() ?? '(empty)' }}

From -
{{ (message.headers.get('from').bodyAsString() ?? '(empty)')|replace({'From:': ''}) }}
+
{{ message.getFrom()|map(addr => addr.toString())|join(', ')|default('(empty)') }}
To -
{{ (message.headers.get('to').bodyAsString() ?? '(empty)')|replace({'To:': ''}) }}
+
{{ message.getTo()|map(addr => addr.toString())|join(', ')|default('(empty)') }}
Headers -
{% for header in message.headers.all|filter(header => (header.name ?? '') not in ['Subject', 'From', 'To']) %}
+                                                            
{% for header in message.headers.all|filter(header => (header.name ?? '')|lower not in ['subject', 'from', 'to']) %}
                                                                 {{- header.toString }}
                                                             {%~ endfor %}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig index dd17fab989a6b..f0ee1ba3c4274 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig @@ -17,7 +17,7 @@ {% for transport in events.transports %}
- {{ transport }} + {{ transport ?: 'Empty Transport Name' }} {{ events.messages(transport)|length }}
{% endfor %} @@ -100,7 +100,7 @@
{% for transport in events.transports %} -

{{ transport }}

+

{{ transport ?: 'Empty Transport Name' }}

@@ -114,24 +114,24 @@ Subject

{{ message.getSubject() ?? '(empty)' }}

- {% if message.getNotification is defined %} + {% set notification = message.notification ?? null %} + {% if notification %}
Content -
{{ message.getNotification().getContent() ?? '(empty)' }}
+
{{ notification.getContent() ?? '(empty)' }}
Importance -
{{ message.getNotification().getImportance() }}
+
{{ notification.getImportance() }}
{% endif %}
- {% if message.getNotification is defined %} + {% if notification %}

Notification

- {% set notification = event.message.getNotification() %}
                                                             {{- 'Subject: ' ~ notification.getSubject() }}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig index 236fc70da94b6..8d06534d6e073 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig @@ -1,5 +1,5 @@ -
+
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 86de485e031d1..67355d9030a15 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; @@ -135,7 +136,7 @@ public function testToolbarActionWithEmptyToken($token) $this->assertEquals(200, $response->getStatusCode()); } - public function getEmptyTokenCases() + public static function getEmptyTokenCases() { return [ [null], @@ -164,7 +165,7 @@ public function testOpeningDisallowedPaths($path, $isAllowed) } } - public function getOpenFileCases() + public static function getOpenFileCases() { return [ ['README.md', true], @@ -354,7 +355,7 @@ public function testPhpinfoAction() $this->assertStringContainsString('PHP License', $client->getResponse()->getContent()); } - public function provideCspVariants() + public static function provideCspVariants() { return [ [true], @@ -366,6 +367,99 @@ public function provideCspVariants() * @dataProvider defaultPanelProvider */ public function testDefaultPanel(string $expectedPanel, Profile $profile) + { + $this->assertDefaultPanel($expectedPanel, $profile); + } + + public static function defaultPanelProvider(): \Generator + { + // Test default behavior + $profile = new Profile('xxxxxx'); + $profile->addCollector($requestDataCollector = new RequestDataCollector()); + yield [$requestDataCollector->getName(), $profile]; + + // Test exception + $profile = new Profile('xxxxxx'); + $profile->addCollector($exceptionDataCollector = new ExceptionDataCollector()); + $exceptionDataCollector->collect(new Request(), new Response(), new \DomainException()); + yield [$exceptionDataCollector->getName(), $profile]; + } + + private function createController($profiler, $twig, $withCSP, array $templates = []): ProfilerController + { + $urlGenerator = $this->createMock(UrlGeneratorInterface::class); + + if ($withCSP) { + $nonceGenerator = $this->createMock(NonceGenerator::class); + $nonceGenerator->method('generate')->willReturn('dummy_nonce'); + + return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator)); + } + + return new ProfilerController($urlGenerator, $profiler, $twig, $templates); + } + + public function testDumpPanelExceptionPriority() + { + $exceptionDataCollector = new ExceptionDataCollector(); + $exceptionDataCollector->collect(new Request(), new Response(), new \DomainException()); + + $dumpDataCollector = $this->createDumpDataCollector(); + + $profile = new Profile('xxxxxx'); + $profile->setCollectors([$exceptionDataCollector, $dumpDataCollector]); + + $this->assertDefaultPanel($exceptionDataCollector->getName(), $profile); + } + + public function testDumpPanelWhenDefinedAfterwards() + { + $exceptionDataCollector = new ExceptionDataCollector(); + $exceptionDataCollector->collect(new Request(), new Response(), new \DomainException()); + + $dumpDataCollector = $this->createDumpDataCollector(); + $dumpDataCollector + ->expects($this->atLeastOnce()) + ->method('getDumpsCount') + ->willReturn(1) + ; + + $profile = new Profile('xxxxxx'); + $profile->setCollectors([$dumpDataCollector, $exceptionDataCollector]); + + $this->assertDefaultPanel($exceptionDataCollector->getName(), $profile); + } + + public function testDumpPanel() + { + $dumpDataCollector = $this->createDumpDataCollector(); + $dumpDataCollector + ->expects($this->atLeastOnce()) + ->method('getDumpsCount') + ->willReturn(1) + ; + + $profile = new Profile('xxxxxx'); + $profile->addCollector($dumpDataCollector); + + $this->assertDefaultPanel($dumpDataCollector->getName(), $profile); + } + + /** + * @return MockObject&DumpDataCollector + */ + private function createDumpDataCollector(): MockObject + { + $dumpDataCollector = $this->createMock(DumpDataCollector::class); + $dumpDataCollector + ->expects($this->atLeastOnce()) + ->method('getName') + ->willReturn('dump'); + + return $dumpDataCollector; + } + + private function assertDefaultPanel(string $expectedPanel, Profile $profile) { $profiler = $this->createMock(Profiler::class); $profiler @@ -415,56 +509,4 @@ public function testDefaultPanel(string $expectedPanel, Profile $profile) }, $collectorsNames)) ->panelAction(new Request(), $profile->getToken()); } - - public function defaultPanelProvider(): \Generator - { - // Test default behavior - $profile = new Profile('xxxxxx'); - $profile->addCollector($requestDataCollector = new RequestDataCollector()); - yield [$requestDataCollector->getName(), $profile]; - - // Test exception - $profile = new Profile('xxxxxx'); - $profile->addCollector($exceptionDataCollector = new ExceptionDataCollector()); - $exceptionDataCollector->collect(new Request(), new Response(), new \DomainException()); - yield [$exceptionDataCollector->getName(), $profile]; - - // Test exception priority - $dumpDataCollector = $this->createMock(DumpDataCollector::class); - $dumpDataCollector - ->expects($this->atLeastOnce()) - ->method('getName') - ->willReturn('dump'); - $dumpDataCollector - ->expects($this->atLeastOnce()) - ->method('getDumpsCount') - ->willReturn(1); - $profile = new Profile('xxxxxx'); - $profile->setCollectors([$exceptionDataCollector, $dumpDataCollector]); - yield [$exceptionDataCollector->getName(), $profile]; - - // Test exception priority when defined afterwards - $profile = new Profile('xxxxxx'); - $profile->setCollectors([$dumpDataCollector, $exceptionDataCollector]); - yield [$exceptionDataCollector->getName(), $profile]; - - // Test dump - $profile = new Profile('xxxxxx'); - $profile->addCollector($dumpDataCollector); - yield [$dumpDataCollector->getName(), $profile]; - } - - private function createController($profiler, $twig, $withCSP, array $templates = []): ProfilerController - { - $urlGenerator = $this->createMock(UrlGeneratorInterface::class); - - if ($withCSP) { - $nonceGenerator = $this->createMock(NonceGenerator::class); - $nonceGenerator->method('generate')->willReturn('dummy_nonce'); - - return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator)); - } - - return new ProfilerController($urlGenerator, $profiler, $twig, $templates); - } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php index c345b5fbb89c8..7d5c0761b1dcc 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php @@ -46,7 +46,7 @@ public function testOnKernelResponse($nonce, $expectedNonce, Request $request, R } } - public function provideRequestAndResponses() + public static function provideRequestAndResponses() { $nonce = bin2hex(random_bytes(16)); @@ -73,7 +73,7 @@ public function provideRequestAndResponses() ]; } - public function provideRequestAndResponsesForOnKernelResponse() + public static function provideRequestAndResponsesForOnKernelResponse() { $nonce = bin2hex(random_bytes(16)); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php index a0bc7f43c0668..d957cafc48616 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -29,7 +29,7 @@ public function testConfigTree(array $options, array $expectedResult) $this->assertEquals($expectedResult, $config); } - public function getDebugModes() + public static function getDebugModes() { return [ [ @@ -71,7 +71,7 @@ public function testConfigTreeUsingInterceptRedirects(bool $interceptRedirects, $this->assertEquals($expectedResult, $config); } - public function getInterceptRedirectsConfiguration() + public static function getInterceptRedirectsConfiguration() { return [ [ diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index f4d0f7e037939..2d9ae56f1efa6 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -22,6 +22,9 @@ use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector; use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\HttpKernel\Profiler\Profiler; +use Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface; +use Symfony\Component\Routing\RouterInterface; class WebProfilerExtensionTest extends TestCase { @@ -55,11 +58,15 @@ protected function setUp(): void $this->kernel = $this->createMock(KernelInterface::class); + $profiler = $this->createMock(Profiler::class); + $profilerStorage = $this->createMock(ProfilerStorageInterface::class); + $router = $this->createMock(RouterInterface::class); + $this->container = new ContainerBuilder(); $this->container->register('data_collector.dump', DumpDataCollector::class)->setPublic(true); $this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true); $this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true); - $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))->setPublic(true); + $this->container->register('router', \get_class($router))->setPublic(true); $this->container->register('twig', 'Twig\Environment')->setPublic(true); $this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument([])->setPublic(true); $this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader'))->setPublic(true); @@ -71,9 +78,9 @@ protected function setUp(): void $this->container->setParameter('kernel.charset', 'UTF-8'); $this->container->setParameter('debug.file_link_format', null); $this->container->setParameter('profiler.class', ['Symfony\\Component\\HttpKernel\\Profiler\\Profiler']); - $this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')) + $this->container->register('profiler', \get_class($profiler)) ->setPublic(true) - ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface'))); + ->addArgument(new Definition(\get_class($profilerStorage))); $this->container->setParameter('data_collector.templates', []); $this->container->set('kernel', $this->kernel); $this->container->addCompilerPass(new RegisterListenersPass()); @@ -103,7 +110,7 @@ public function testDefaultConfig($debug) self::assertSaneContainer($this->getCompiledContainer()); } - public function getDebugModes() + public static function getDebugModes() { return [ ['debug' => false], @@ -129,7 +136,7 @@ public function testToolbarConfig(bool $toolbarEnabled, bool $listenerInjected, } } - public function getToolbarConfig() + public static function getToolbarConfig() { return [ [ @@ -170,7 +177,7 @@ public function testToolbarConfigUsingInterceptRedirects( } } - public function getInterceptRedirectsToolbarConfig() + public static function getInterceptRedirectsToolbarConfig() { return [ [ diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index dd2de44bc350f..450802a38efef 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -40,7 +40,7 @@ public function testInjectToolbar($content, $expected) $this->assertEquals($expected, $response->getContent()); } - public function getInjectToolbarTests() + public static function getInjectToolbarTests() { return [ ['', "\nWDT\n"], @@ -134,6 +134,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() /** * @depends testToolbarIsInjected + * * @dataProvider provideRedirects */ public function testToolbarIsNotInjectedOnRedirection($statusCode) @@ -148,7 +149,7 @@ public function testToolbarIsNotInjectedOnRedirection($statusCode) $this->assertEquals('', $response->getContent()); } - public function provideRedirects() + public static function provideRedirects() { return [ [301], diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php index a690721ebc018..afbd6edff0f06 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php @@ -23,7 +23,7 @@ public function testIconFileContents($iconFilePath) $this->assertMatchesRegularExpression('~.*~s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath)); } - public function provideIconFilePaths() + public static function provideIconFilePaths() { return array_map(function ($filePath) { return (array) $filePath; }, glob(__DIR__.'/../../Resources/views/Icon/*.svg')); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php index 6b026bcc53385..1bb1296b09903 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php @@ -42,7 +42,7 @@ class_exists(EscaperExtension::class); // Load twig_escape_filter() self::assertSame($dump2HasHeader, str_contains($dump2, $needle)); } - public function provideMessages(): iterable + public static function provideMessages(): iterable { yield ['Some message', ['foo' => 'foo', 'bar' => 'bar'], false, true]; yield ['Some message {@see some text}', ['foo' => 'foo', 'bar' => 'bar'], false, true]; diff --git a/src/Symfony/Component/Asset/LICENSE b/src/Symfony/Component/Asset/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Asset/LICENSE +++ b/src/Symfony/Component/Asset/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Asset/Tests/PackageTest.php b/src/Symfony/Component/Asset/Tests/PackageTest.php index 8d7f7b8a26a71..45b0982182082 100644 --- a/src/Symfony/Component/Asset/Tests/PackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PackageTest.php @@ -27,7 +27,7 @@ public function testGetUrl($version, $format, $path, $expected) $this->assertSame($expected, $package->getUrl($path)); } - public function getConfigs() + public static function getConfigs() { return [ ['v1', '', 'http://example.com/foo', 'http://example.com/foo'], diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index 57bb80bcccf06..0784ac6fa89c0 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -28,7 +28,7 @@ public function testGetUrl($basePath, $format, $path, $expected) $this->assertSame($expected, $package->getUrl($path)); } - public function getConfigs() + public static function getConfigs() { return [ ['/foo', '', 'http://example.com/foo', 'http://example.com/foo'], @@ -60,7 +60,7 @@ public function testGetUrlWithContext($basePathRequest, $basePath, $format, $pat $this->assertSame($expected, $package->getUrl($path)); } - public function getContextConfigs() + public static function getContextConfigs() { return [ ['', '/foo', '', '/baz', '/baz?v1'], diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index 717c0687c9875..b6525d35cfe5e 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -31,7 +31,7 @@ public function testGetUrl($baseUrls, $format, $path, $expected) $this->assertSame($expected, $package->getUrl($path)); } - public function getConfigs() + public static function getConfigs() { return [ ['http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'], @@ -72,7 +72,7 @@ public function testGetUrlWithContext($secure, $baseUrls, $format, $path, $expec $this->assertSame($expected, $package->getUrl($path)); } - public function getContextConfigs() + public static function getContextConfigs() { return [ [false, 'http://example.com', '', 'foo', 'http://example.com/foo?v1'], @@ -114,7 +114,7 @@ public function testWrongBaseUrl($baseUrls) new UrlPackage($baseUrls, new EmptyVersionStrategy()); } - public function getWrongBaseUrlConfig() + public static function getWrongBaseUrlConfig() { return [ ['not-a-url'], diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php index d3748bb7532bc..46c7d05daafad 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php @@ -82,22 +82,22 @@ public function testRemoteManifestFileWithoutHttpClient() new JsonManifestVersionStrategy('https://cdn.example.com/manifest.json'); } - public function provideValidStrategies() + public static function provideValidStrategies(): \Generator { - yield from $this->provideStrategies('manifest-valid.json'); + yield from static::provideStrategies('manifest-valid.json'); } - public function provideInvalidStrategies() + public static function provideInvalidStrategies(): \Generator { - yield from $this->provideStrategies('manifest-invalid.json'); + yield from static::provideStrategies('manifest-invalid.json'); } - public function provideMissingStrategies() + public static function provideMissingStrategies(): \Generator { - yield from $this->provideStrategies('non-existent-file.json'); + yield from static::provideStrategies('non-existent-file.json'); } - public function provideStrategies(string $manifestPath) + public static function provideStrategies(string $manifestPath): \Generator { $httpClient = new MockHttpClient(function ($method, $url, $options) { $filename = __DIR__.'/../fixtures/'.basename($url); @@ -114,7 +114,7 @@ public function provideStrategies(string $manifestPath) yield [new JsonManifestVersionStrategy(__DIR__.'/../fixtures/'.$manifestPath)]; } - public function provideStrictStrategies() + public static function provideStrictStrategies(): \Generator { $strategy = new JsonManifestVersionStrategy(__DIR__.'/../fixtures/manifest-valid.json', null, true); diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php index d054e842f2c55..ec06ba6554de1 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php @@ -34,7 +34,7 @@ public function testApplyVersion($path, $version, $format) $this->assertSame($formatted, $staticVersionStrategy->applyVersion($path)); } - public function getConfigs() + public static function getConfigs() { return [ ['test-path', 'v1', null], diff --git a/src/Symfony/Component/BrowserKit/LICENSE b/src/Symfony/Component/BrowserKit/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/BrowserKit/LICENSE +++ b/src/Symfony/Component/BrowserKit/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index c714a2560d224..6944a3371e323 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -623,7 +623,7 @@ public function testFollowMetaRefresh(string $content, string $expectedEndingUrl $this->assertSame($expectedEndingUrl, $client->getRequest()->getUri()); } - public function getTestsForMetaRefresh() + public static function getTestsForMetaRefresh() { return [ ['', 'http://www.example.com/redirected'], diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 414f5dc62c5f3..bf9333de9baa0 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -130,7 +130,7 @@ public function testAllValues($uri, $values) $this->assertEquals($values, array_keys($cookieJar->allValues($uri)), '->allValues() returns the cookie for a given URI'); } - public function provideAllValuesValues() + public static function provideAllValuesValues() { return [ ['http://www.example.com', ['foo_nothing', 'foo_domain']], diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index a9b34139fbf0d..3fdb756019d4c 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -42,7 +42,7 @@ public function testToFromString($cookie, $url = null) $this->assertEquals($cookie, (string) Cookie::fromString($cookie, $url)); } - public function getTestsForToFromString() + public static function getTestsForToFromString() { return [ ['foo=bar; path=/'], @@ -71,7 +71,7 @@ public function testFromStringAcceptsSeveralExpiresDateFormats($cookie) $this->assertEquals(1596185377, Cookie::fromString($cookie)->getExpiresTime()); } - public function getExpireCookieStrings() + public static function getExpireCookieStrings() { return [ ['foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'], diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index c0254e7246689..44f61289d8d6a 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -40,7 +40,7 @@ public function testRequestHeaders(array $requestArguments, array $expectedArgum $browser->request(...$requestArguments); } - public function validContentTypes() + public static function validContentTypes() { $defaultHeaders = ['user-agent' => 'Symfony BrowserKit', 'host' => 'example.com']; yield 'GET/HEAD' => [ @@ -199,7 +199,7 @@ public function testMultipleForwardSlashesRequestPath(string $requestPath) $browser->request('GET', $requestPath); } - public function forwardSlashesRequestPathProvider() + public static function forwardSlashesRequestPathProvider() { return [ 'one slash' => ['/'], diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index 5c2933fcfd3f8..5eb36b80c78fc 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -32,13 +32,6 @@ class MemcachedAdapter extends AbstractAdapter protected $maxIdLength = 250; - private const DEFAULT_CLIENT_OPTIONS = [ - 'persistent_id' => null, - 'username' => null, - 'password' => null, - \Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP, - ]; - private $marshaller; private $client; private $lazyClient; @@ -106,10 +99,9 @@ public static function createConnection($servers, array $options = []) } set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); }); try { - $options += static::DEFAULT_CLIENT_OPTIONS; - $client = new \Memcached($options['persistent_id']); - $username = $options['username']; - $password = $options['password']; + $client = new \Memcached($options['persistent_id'] ?? null); + $username = $options['username'] ?? null; + $password = $options['password'] ?? null; // parse any DSN in $servers foreach ($servers as $i => $dsn) { @@ -199,7 +191,7 @@ public static function createConnection($servers, array $options = []) $options[\constant('Memcached::OPT_'.$name)] = $value; } } - $client->setOptions($options); + $client->setOptions($options + [\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP]); // set client's servers, taking care of persistent connections if (!$client->isPristine()) { diff --git a/src/Symfony/Component/Cache/LICENSE b/src/Symfony/Component/Cache/LICENSE index f2345234aa9ea..0223acd4a01f4 100644 --- a/src/Symfony/Component/Cache/LICENSE +++ b/src/Symfony/Component/Cache/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2023 Fabien Potencier +Copyright (c) 2016-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Cache/Messenger/EarlyExpirationHandler.php b/src/Symfony/Component/Cache/Messenger/EarlyExpirationHandler.php index 1f0bd565ce5ea..9e53f5d2fd654 100644 --- a/src/Symfony/Component/Cache/Messenger/EarlyExpirationHandler.php +++ b/src/Symfony/Component/Cache/Messenger/EarlyExpirationHandler.php @@ -73,7 +73,8 @@ function (CacheItem $item, float $startTime) { $startTime = microtime(true); $pool = $message->findPool($this->reverseContainer); $callback = $message->findCallback($this->reverseContainer); - $value = $callback($item); + $save = true; + $value = $callback($item, $save); $setMetadata($item, $startTime); $pool->save($item->set($value)); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php similarity index 96% rename from src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php rename to src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php index a1e8d19edc5cc..10382178c8375 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php @@ -15,7 +15,7 @@ use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisAdapter; -abstract class AbstractRedisAdapterTest extends AdapterTestCase +abstract class AbstractRedisAdapterTestCase extends AdapterTestCase { protected $skippedTests = [ 'testExpiration' => 'Testing expiration slows down the test suite', diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index 0734e9818cc47..10924914cd47b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -25,6 +25,7 @@ /** * @author Kévin Dunglas + * * @group time-sensitive */ class ChainAdapterTest extends AdapterTestCase diff --git a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php index 8862e54cb2bd3..99acc838e532e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php @@ -19,6 +19,7 @@ /** * @requires extension couchbase <3.0.0 * @requires extension couchbase >=2.6.0 + * * @group integration * * @author Antonio Jose Cerezo Aranda diff --git a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php index bae6a27d4c725..619dac5fd2863 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php @@ -19,6 +19,7 @@ /** * @requires extension couchbase <4.0.0 * @requires extension couchbase >=3.0.0 + * * @group integration * * @author Antonio Jose Cerezo Aranda diff --git a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php index cf8a60a598ae9..656b84ab63ba2 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php @@ -124,7 +124,7 @@ public function testDsn(string $dsn, string $file = null) } } - public function provideDsn() + public static function provideDsn() { $dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); yield ['sqlite://localhost/'.$dbFile.'1', $dbFile.'1']; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index 29d692e3489ca..180ce6f3d0dab 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -84,7 +84,7 @@ public function testBadOptions($name, $value) MemcachedAdapter::createConnection([], [$name => $value]); } - public function provideBadOptions(): array + public static function provideBadOptions(): array { return [ ['hash', 'zyx'], @@ -135,7 +135,7 @@ public function testServersSetting(string $dsn, string $host, int $port) $this->assertSame([$expect], array_map($f, $client3->getServerList())); } - public function provideServersSetting(): iterable + public static function provideServersSetting(): iterable { yield [ 'memcached://127.0.0.1/50', @@ -185,7 +185,7 @@ public function testDsnWithOptions(string $dsn, array $options, array $expectedO } } - public function provideDsnWithOptions(): iterable + public static function provideDsnWithOptions(): iterable { if (!class_exists(\Memcached::class)) { self::markTestSkipped('Extension memcached required.'); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php index 27429f33c9022..6bed9285c59ac 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php @@ -89,7 +89,7 @@ public function testDsn(string $dsn, string $file = null) } } - public function provideDsn() + public static function provideDsn() { $dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); yield ['sqlite:'.$dbFile.'2', $dbFile.'2']; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index 0c7a9fde07007..8c8f25ee60355 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -134,7 +134,7 @@ public function testDsn(string $dsn, string $file = null) } } - public function provideDsn() + public static function provideDsn() { $dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); yield ['sqlite://localhost/'.$dbFile.'1', $dbFile.'1']; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php index a3d0cf36253c4..c3145b9e27f71 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php @@ -17,7 +17,7 @@ /** * @group integration */ -class PredisAdapterSentinelTest extends AbstractRedisAdapterTest +class PredisAdapterSentinelTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php index f785499a7b733..e326dba76b5f3 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php @@ -17,7 +17,7 @@ /** * @group integration */ -class PredisAdapterTest extends AbstractRedisAdapterTest +class PredisAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php index 936c04aad49fb..c64384bb7a293 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php @@ -14,7 +14,7 @@ /** * @group integration */ -class PredisClusterAdapterTest extends AbstractRedisAdapterTest +class PredisClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php index 4367ce0bfa510..3337272a34ad1 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php @@ -17,7 +17,7 @@ /** * @group integration */ -class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest +class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php index 37282e8fceee8..1f800e19d1cdf 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php @@ -20,7 +20,7 @@ /** * @group integration */ -class ProxyAdapterAndRedisAdapterTest extends AbstractRedisAdapterTest +class ProxyAdapterAndRedisAdapterTest extends AbstractRedisAdapterTestCase { protected $skippedTests = [ 'testPrune' => 'RedisAdapter does not implement PruneableInterface.', diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php index 521c5dc4a5579..601715645a8db 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php @@ -19,7 +19,7 @@ /** * @group integration */ -class RedisAdapterSentinelTest extends AbstractRedisAdapterTest +class RedisAdapterSentinelTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php index aa2ce75a4555d..71fa5b0a6d568 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php @@ -20,7 +20,7 @@ /** * @group integration */ -class RedisAdapterTest extends AbstractRedisAdapterTest +class RedisAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { @@ -66,6 +66,9 @@ private function doTestCreateConnection(string $uri) $this->assertTrue($redis->isConnected()); $this->assertSame(0, $redis->getDbNum()); + $redis = RedisAdapter::createConnection('redis://'.$uri.'/'); + $this->assertSame(0, $redis->getDbNum()); + $redis = RedisAdapter::createConnection('redis://'.$uri.'/2'); $this->assertSame(2, $redis->getDbNum()); @@ -102,7 +105,7 @@ public function testFailedCreateConnection(string $dsn) RedisAdapter::createConnection($dsn); } - public function provideFailedCreateConnection(): array + public static function provideFailedCreateConnection(): array { return [ ['redis://localhost:1234'], @@ -122,7 +125,7 @@ public function testInvalidCreateConnection(string $dsn) RedisAdapter::createConnection($dsn); } - public function provideInvalidCreateConnection(): array + public static function provideInvalidCreateConnection(): array { return [ ['redis://localhost/foo'], diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php index f9d481dba781f..58ca31441f5fb 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -16,7 +16,7 @@ /** * @group integration */ -class RedisArrayAdapterTest extends AbstractRedisAdapterTest +class RedisArrayAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php index fca50690aef5e..cdfa4f43e1a5a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -21,7 +21,7 @@ /** * @group integration */ -class RedisClusterAdapterTest extends AbstractRedisAdapterTest +class RedisClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void { @@ -58,7 +58,7 @@ public function testFailedCreateConnection(string $dsn) RedisAdapter::createConnection($dsn); } - public function provideFailedCreateConnection(): array + public static function provideFailedCreateConnection(): array { return [ ['redis://localhost:1234?redis_cluster=1'], diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php index bcb3c01532377..4af199dc417cd 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php @@ -58,7 +58,7 @@ public function testIntegrationUsingProxiedAdapterForTagsPool() $this->assertFalse($cache->getItem('foo')->isHit()); } - public function dataProvider(): array + public static function dataProvider(): array { return [ [new ArrayAdapter()], diff --git a/src/Symfony/Component/Cache/Tests/CacheItemTest.php b/src/Symfony/Component/Cache/Tests/CacheItemTest.php index bf9afc56c2702..e8f3ebb4939f9 100644 --- a/src/Symfony/Component/Cache/Tests/CacheItemTest.php +++ b/src/Symfony/Component/Cache/Tests/CacheItemTest.php @@ -34,7 +34,7 @@ public function testInvalidKey($key) CacheItem::validateKey($key); } - public function provideInvalidKey(): array + public static function provideInvalidKey(): array { return [ [''], diff --git a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php index f42bca5525aff..8c63224491266 100644 --- a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php +++ b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php @@ -12,14 +12,15 @@ namespace Symfony\Component\Cache\Tests\Messenger; use PHPUnit\Framework\TestCase; +use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; -use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Messenger\EarlyExpirationHandler; use Symfony\Component\Cache\Messenger\EarlyExpirationMessage; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ReverseContainer; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Contracts\Cache\CallbackInterface; /** * @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct @@ -40,8 +41,8 @@ public function testHandle() $item = $pool->getItem('foo'); $item->set(234); - $computationService = new class() { - public function __invoke(CacheItem $item) + $computationService = new class() implements CallbackInterface { + public function __invoke(CacheItemInterface $item, bool &$save) { usleep(30000); $item->expiresAfter(3600); diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index a6814b5fe9e08..c1a850877ff3d 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -297,7 +297,7 @@ public function saveDeferred(CacheItemInterface $item) * When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed, * but old keys may need garbage collection and extra round-trips to the back-end are required. * - * Calling this method also clears the memoized namespace version and thus forces a resynchonization of it. + * Calling this method also clears the memoized namespace version and thus forces a resynchronization of it. * * @return bool the previous state of versioning */ diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index d452ee4cfc4d8..2cec78ed42239 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -149,8 +149,8 @@ public static function createConnection(string $dsn, array $options = []) if (isset($params['host']) || isset($params['path'])) { if (!isset($params['dbindex']) && isset($params['path'])) { - if (preg_match('#/(\d+)$#', $params['path'], $m)) { - $params['dbindex'] = $m[1]; + if (preg_match('#/(\d+)?$#', $params['path'], $m)) { + $params['dbindex'] = $m[1] ?? '0'; $params['path'] = substr($params['path'], 0, -\strlen($m[0])); } elseif (isset($params['host'])) { throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s", the "dbindex" parameter must be a number.', $dsn)); diff --git a/src/Symfony/Component/Config/Definition/Processor.php b/src/Symfony/Component/Config/Definition/Processor.php index c431408e19633..312783f555bd5 100644 --- a/src/Symfony/Component/Config/Definition/Processor.php +++ b/src/Symfony/Component/Config/Definition/Processor.php @@ -63,9 +63,9 @@ public function processConfiguration(ConfigurationInterface $configuration, arra * * extensions: ['twig.extension.foo', 'twig.extension.bar'] * - * @param array $config A config array - * @param string $key The key to normalize - * @param string $plural The plural form of the key if it is irregular + * @param array $config A config array + * @param string $key The key to normalize + * @param string|null $plural The plural form of the key if it is irregular */ public static function normalizeConfig(array $config, string $key, string $plural = null): array { diff --git a/src/Symfony/Component/Config/LICENSE b/src/Symfony/Component/Config/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Config/LICENSE +++ b/src/Symfony/Component/Config/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index 6aff151cc8bb8..661603692c2ba 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -32,7 +32,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface /** * @param string $resource The fully-qualified class name - * @param bool|null $exists Boolean when the existency check has already been done + * @param bool|null $exists Boolean when the existence check has already been done */ public function __construct(string $resource, bool $exists = null) { diff --git a/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php b/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php index 03f5cd43db87d..5f20ca6ac9f7f 100644 --- a/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php +++ b/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php @@ -53,7 +53,7 @@ protected function tearDown(): void parent::tearDown(); } - public function fixtureNames() + public static function fixtureNames() { $array = [ 'ScalarNormalizedTypes' => 'scalar_normalized_types', diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php index 79de702224e0a..d7099fb970ca0 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php @@ -98,7 +98,7 @@ public function testStaleResourceInDebug() $this->assertFalse($cache->isFresh()); } - public function debugModes(): array + public static function debugModes(): array { return [ [true], diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 469b12f87f6f1..264404dfb174d 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -58,7 +58,7 @@ public function testNormalizeWithoutProposals() $node->normalize(['beta' => 'foo']); } - public function ignoreAndRemoveMatrixProvider(): array + public static function ignoreAndRemoveMatrixProvider(): array { $unrecognizedOptionException = new InvalidConfigurationException('Unrecognized option "foo" under "root"'); @@ -100,7 +100,7 @@ public function testPreNormalize(array $denormalized, array $normalized) $this->assertSame($normalized, $r->invoke($node, $denormalized)); } - public function getPreNormalizationTests(): array + public static function getPreNormalizationTests(): array { return [ [ @@ -142,7 +142,7 @@ public function testNodeNameCanBeZero(array $denormalized, array $normalized) $this->assertSame($normalized, $r->invoke($rootNode, $denormalized)); } - public function getZeroNamedNodeExamplesData(): array + public static function getZeroNamedNodeExamplesData(): array { return [ [ @@ -189,7 +189,7 @@ public function testChildrenOrderIsMaintainedOnNormalizeValue(array $prenormaliz $this->assertSame($normalized, $r->invoke($node, $prenormalized)); } - public function getPreNormalizedNormalizedOrderedData(): array + public static function getPreNormalizedNormalizedOrderedData(): array { return [ [ @@ -353,7 +353,7 @@ public function testMergeWithIgnoringExtraKeys(array $prenormalizeds, array $mer $this->assertEquals($merged, $r->invoke($node, ...$prenormalizeds)); } - public function getDataWithIncludedExtraKeys(): array + public static function getDataWithIncludedExtraKeys(): array { return [ [ diff --git a/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php index afe3cdf691a90..4ea8469ef3c14 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php @@ -41,7 +41,7 @@ public function testGetPathForChildNode(string $expected, array $params) $this->assertSame($expected, $node->getPath()); } - public function providePath(): array + public static function providePath(): array { return [ 'name only' => ['root', ['root']], diff --git a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php index bec3b5996dd08..e29e047ef0fb4 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php @@ -37,7 +37,7 @@ public function testValidNonEmptyValues(bool $value) $this->assertSame($value, $node->finalize($value)); } - public function getValidValues(): array + public static function getValidValues(): array { return [ [false], @@ -55,7 +55,7 @@ public function testNormalizeThrowsExceptionOnInvalidValues($value) $node->normalize($value); } - public function getInvalidValues(): array + public static function getInvalidValues(): array { return [ [null], diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index 10b54aa143757..dd7b5e444afb2 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -55,7 +55,7 @@ public function testPrototypeNodeSpecificOption(string $method, array $args) $node->getNode(); } - public function providePrototypeNodeSpecificCalls(): array + public static function providePrototypeNodeSpecificCalls(): array { return [ ['defaultValue', [[]]], @@ -137,7 +137,7 @@ public function testPrototypedArrayNodeDefault($args, bool $shouldThrowWhenUsing } } - public function providePrototypedArrayNodeDefaults(): array + public static function providePrototypedArrayNodeDefaults(): array { return [ [null, true, false, [[]]], @@ -298,7 +298,7 @@ public function testPrototypeEnum() $this->assertEquals($node->prototype('enum'), $node->enumPrototype()); } - public function getEnableableNodeFixtures(): array + public static function getEnableableNodeFixtures(): array { return [ [['enabled' => true, 'foo' => 'bar'], [true], 'true enables an enableable node'], diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index e96c57c409f8f..64b5d8d7456fa 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -159,7 +159,7 @@ public function testCastToArrayExpression($configValue, array $expectedValue) $this->assertFinalizedValueIs($expectedValue, $test, ['key' => $configValue]); } - public function castToArrayValues(): iterable + public static function castToArrayValues(): iterable { yield ['value', ['value']]; yield [-3.14, [-3.14]]; diff --git a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php index 7d8c2d951897f..3f198ca9d6607 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php @@ -26,7 +26,7 @@ public function testDumper() $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); } - public function provideDumpAtPath(): array + public static function provideDumpAtPath(): array { return [ 'Regular node' => ['scalar_true', <<assertSame($value, $node->finalize($value)); } - public function getValidValues(): array + public static function getValidValues(): array { return [ [1798.0], @@ -65,7 +65,7 @@ public function testNormalizeThrowsExceptionOnInvalidValues($value) $node->normalize($value); } - public function getInvalidValues(): array + public static function getInvalidValues(): array { return [ [null], diff --git a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php index 7c843b38f3716..132b6b43b654d 100644 --- a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php @@ -37,7 +37,7 @@ public function testValidNonEmptyValues(int $value) $this->assertSame($value, $node->finalize($value)); } - public function getValidValues(): array + public static function getValidValues(): array { return [ [1798], @@ -56,7 +56,7 @@ public function testNormalizeThrowsExceptionOnInvalidValues($value) $node->normalize($value); } - public function getInvalidValues(): array + public static function getInvalidValues(): array { return [ [null], diff --git a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php index 0b497707e4604..5945b48e55189 100644 --- a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php @@ -51,7 +51,7 @@ public function testNormalizeEncoders($denormalized) $this->assertNormalized($tree, $denormalized, $normalized); } - public function getEncoderTests(): array + public static function getEncoderTests(): array { $configs = []; @@ -120,7 +120,7 @@ public function testAnonymousKeysArray($denormalized) $this->assertNormalized($tree, $denormalized, $normalized); } - public function getAnonymousKeysTests(): array + public static function getAnonymousKeysTests(): array { $configs = []; @@ -151,7 +151,7 @@ public function testNumericKeysAsAttributes($denormalized) $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, $normalized); } - public function getNumericKeysTests(): array + public static function getNumericKeysTests(): array { $configs = []; diff --git a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php index e68d9a68a8703..abf0de7771627 100644 --- a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php @@ -280,7 +280,7 @@ public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, array $chil $this->assertEquals($expected, $normalized); } - public function getDataForKeyRemovedLeftValueOnly(): array + public static function getDataForKeyRemovedLeftValueOnly(): array { $scalarValue = new ScalarNode('value'); @@ -354,7 +354,7 @@ public function testPrototypedArrayNodeMerge(array $left, array $right, array $e self::assertSame($result, $expected); } - public function getPrototypedArrayNodeDataToMerge(): array + public static function getPrototypedArrayNodeDataToMerge(): array { return [ // data to merged is a plain array diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index 84e76c46df79c..bd116b69593cd 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -28,7 +28,7 @@ public function testNormalize($value) $this->assertSame($value, $node->normalize($value)); } - public function getValidValues(): array + public static function getValidValues(): array { return [ [false], @@ -93,7 +93,7 @@ public function testNormalizeThrowsExceptionOnInvalidValues($value) $node->normalize($value); } - public function getInvalidValues(): array + public static function getInvalidValues(): array { return [ [[]], @@ -136,7 +136,7 @@ public function testValidNonEmptyValues($value) $this->assertSame($value, $node->finalize($value)); } - public function getValidNonEmptyValues(): array + public static function getValidNonEmptyValues(): array { return [ [false], @@ -162,7 +162,7 @@ public function testNotAllowedEmptyValuesThrowException($value) $node->finalize($value); } - public function getEmptyValues(): array + public static function getEmptyValues(): array { return [ [null], diff --git a/src/Symfony/Component/Config/Tests/FileLocatorTest.php b/src/Symfony/Component/Config/Tests/FileLocatorTest.php index ced35690990b1..7a6ea6bf38470 100644 --- a/src/Symfony/Component/Config/Tests/FileLocatorTest.php +++ b/src/Symfony/Component/Config/Tests/FileLocatorTest.php @@ -30,7 +30,7 @@ public function testIsAbsolutePath(string $path) $this->assertTrue($m->invoke($loader, $path), '->isAbsolutePath() returns true for an absolute path'); } - public function getIsAbsolutePathTests(): array + public static function getIsAbsolutePathTests(): array { return [ ['/foo.xml'], diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 5d18103f2ecd3..9aa991ecc5b5e 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -139,7 +139,7 @@ public function testExcludeTrailingSlashConsistency(string $exclude) $this->assertNotContains('baz.txt', $loadedFiles); } - public function excludeTrailingSlashConsistencyProvider(): iterable + public static function excludeTrailingSlashConsistencyProvider(): iterable { yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo/']; yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo']; diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 1f3425787c0e9..875baf9f7f370 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -117,7 +117,7 @@ public function testHashedSignature(bool $changeExpected, int $changedLine, ?str } } - public function provideHashedSignature(): iterable + public static function provideHashedSignature(): iterable { yield [false, 0, "// line change\n\n"]; yield [true, 0, '/** class docblock */']; diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index c622d606bc303..8c1cd8543be19 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -124,7 +124,7 @@ public function testConvertDomToArray($expected, string $xml, bool $root = false $this->assertSame($expected, XmlUtils::convertDomElementToArray($dom->documentElement, $checkPrefix)); } - public function getDataForConvertDomToArray(): array + public static function getDataForConvertDomToArray(): array { return [ [null, ''], @@ -155,7 +155,7 @@ public function testPhpize($expected, string $value) $this->assertSame($expected, XmlUtils::phpize($value)); } - public function getDataForPhpize(): array + public static function getDataForPhpize(): array { return [ ['', ''], diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index e0593e17a7dab..cfa18361ea980 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -429,9 +429,9 @@ public function getNativeDefinition() * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) * - * @throws InvalidArgumentException When argument mode is not valid - * * @return $this + * + * @throws InvalidArgumentException When argument mode is not valid */ public function addArgument(string $name, int $mode = null, string $description = '', $default = null) { @@ -450,9 +450,9 @@ public function addArgument(string $name, int $mode = null, string $description * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * - * @throws InvalidArgumentException If option mode is invalid or incompatible - * * @return $this + * + * @throws InvalidArgumentException If option mode is invalid or incompatible */ public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) { diff --git a/src/Symfony/Component/Console/LICENSE b/src/Symfony/Component/Console/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Console/LICENSE +++ b/src/Symfony/Component/Console/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Console/Tester/TesterTrait.php b/src/Symfony/Component/Console/Tester/TesterTrait.php index 40bc581771f02..f454bbf9d75f9 100644 --- a/src/Symfony/Component/Console/Tester/TesterTrait.php +++ b/src/Symfony/Component/Console/Tester/TesterTrait.php @@ -35,9 +35,9 @@ trait TesterTrait /** * Gets the display returned by the last execution of the command or application. * - * @throws \RuntimeException If it's called before the execute method - * * @return string + * + * @throws \RuntimeException If it's called before the execute method */ public function getDisplay(bool $normalize = false) { @@ -103,9 +103,9 @@ public function getOutput() /** * Gets the status code returned by the last execution of the command or application. * - * @throws \RuntimeException If it's called before the execute method - * * @return int + * + * @throws \RuntimeException If it's called before the execute method */ public function getStatusCode() { diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index d438c3fc95852..698a9679bf764 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -64,6 +64,16 @@ protected function tearDown(): void putenv('SHELL_VERBOSITY'); unset($_ENV['SHELL_VERBOSITY']); unset($_SERVER['SHELL_VERBOSITY']); + + if (\function_exists('pcntl_signal')) { + // We reset all signals to their default value to avoid side effects + for ($i = 1; $i <= 15; ++$i) { + if (9 === $i) { + continue; + } + pcntl_signal($i, SIG_DFL); + } + } } public static function setUpBeforeClass(): void @@ -431,7 +441,7 @@ public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExcep $application->find($abbreviation); } - public function provideAmbiguousAbbreviations() + public static function provideAmbiguousAbbreviations() { return [ ['f', 'Command "f" is not defined.'], @@ -508,15 +518,7 @@ public function testDontRunAlternativeNamespaceName() $application->setAutoExit(false); $tester = new ApplicationTester($application); $tester->run(['command' => 'foos:bar1'], ['decorated' => false]); - $this->assertSame(' - - There are no commands defined in the "foos" namespace. - - Did you mean this? - foo - - -', $tester->getDisplay(true)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application.dont_run_alternative_namespace_name.txt', $tester->getDisplay(true)); } public function testCanRunAlternativeCommandName() @@ -547,7 +549,7 @@ public function testDontRunAlternativeCommandName() $this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display); } - public function provideInvalidCommandNamesSingle() + public static function provideInvalidCommandNamesSingle() { return [ ['foo3:barr'], @@ -1239,7 +1241,7 @@ public function testAddingAlreadySetDefinitionElementData($def) $application->run($input, $output); } - public function getAddingAlreadySetDefinitionElementData() + public static function getAddingAlreadySetDefinitionElementData() { return [ [new InputArgument('command', InputArgument::REQUIRED)], @@ -1956,15 +1958,38 @@ public function testSetSignalsToDispatchEvent() $dispatcher = new EventDispatcher(); $dispatcher->addSubscriber($subscriber); + // Since there is no signal handler, and by default PHP will stop even + // on SIGUSR1, we need to register a blank handler to avoid the process + // being stopped. + $blankHandlerSignaled = false; + pcntl_signal(\SIGUSR1, function () use (&$blankHandlerSignaled) { + $blankHandlerSignaled = true; + }); + $application = $this->createSignalableApplication($command, $dispatcher); $application->setSignalsToDispatchEvent(\SIGUSR2); $this->assertSame(0, $application->run(new ArrayInput(['signal']))); $this->assertFalse($subscriber->signaled); + $this->assertTrue($blankHandlerSignaled); + + // We reset the blank handler to false to make sure it is called again + $blankHandlerSignaled = false; + + $application = $this->createSignalableApplication($command, $dispatcher); + $application->setSignalsToDispatchEvent(\SIGUSR1); + $this->assertSame(1, $application->run(new ArrayInput(['signal']))); + $this->assertTrue($subscriber->signaled); + $this->assertTrue($blankHandlerSignaled); + + // And now we test without the blank handler + $blankHandlerSignaled = false; + pcntl_signal(\SIGUSR1, SIG_DFL); $application = $this->createSignalableApplication($command, $dispatcher); $application->setSignalsToDispatchEvent(\SIGUSR1); $this->assertSame(1, $application->run(new ArrayInput(['signal']))); $this->assertTrue($subscriber->signaled); + $this->assertFalse($blankHandlerSignaled); } public function testSignalableCommandInterfaceWithoutSignals() @@ -2118,7 +2143,7 @@ public function __construct(bool $emitsSignal = true) protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->emitsSignal) { - posix_kill(posix_getpid(), SIGUSR1); + posix_kill(posix_getpid(), \SIGUSR1); } for ($i = 0; $i < $this->loop; ++$i) { diff --git a/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php b/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php index 6ef190f162f09..23f7a3bd9ddbd 100644 --- a/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php +++ b/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php @@ -43,7 +43,7 @@ public function testAnnotationsFormat(string $type, string $message, string $fil self::assertSame($expected.\PHP_EOL, $buffer->fetch()); } - public function annotationsFormatProvider(): iterable + public static function annotationsFormatProvider(): iterable { yield 'warning' => ['warning', 'A warning', null, null, null, '::warning::A warning']; yield 'error' => ['error', 'An error', null, null, null, '::error::An error']; diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 81d4b9bba95e3..63a5ea85321e8 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -124,7 +124,7 @@ public function testInvalidCommandNames($name) $command->setName($name); } - public function provideInvalidCommandNames() + public static function provideInvalidCommandNames() { return [ [''], @@ -338,7 +338,7 @@ public function testSetCode() $this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay()); } - public function getSetCodeBindToClosureTests() + public static function getSetCodeBindToClosureTests() { return [ [true, 'not bound to the command'], diff --git a/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php b/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php index e6c74a7361d08..30b22c967e7d8 100644 --- a/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php @@ -81,7 +81,7 @@ public function testInputAndCurrentOptionValidation(array $input, ?string $excep } } - public function provideInputAndCurrentOptionValues() + public static function provideInputAndCurrentOptionValues() { yield [[], 'The "--current" option must be set and it must be an integer']; yield [['--current' => 'a'], 'The "--current" option must be set and it must be an integer']; @@ -100,7 +100,7 @@ public function testCompleteCommandName(array $input, array $suggestions) $this->assertEquals(implode("\n", $suggestions).\PHP_EOL, $this->tester->getDisplay()); } - public function provideCompleteCommandNameInputs() + public static function provideCompleteCommandNameInputs() { yield 'empty' => [['bin/console'], ['help', 'list', 'completion', 'hello', 'ahoy']]; yield 'partial' => [['bin/console', 'he'], ['help', 'list', 'completion', 'hello', 'ahoy']]; @@ -117,7 +117,7 @@ public function testCompleteCommandInputDefinition(array $input, array $suggesti $this->assertEquals(implode("\n", $suggestions).\PHP_EOL, $this->tester->getDisplay()); } - public function provideCompleteCommandInputDefinitionInputs() + public static function provideCompleteCommandInputDefinitionInputs() { yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction']]; yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']]; diff --git a/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php b/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php index 21df4287312a0..8d0fb45537509 100644 --- a/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php @@ -28,7 +28,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'shell' => [ [''], diff --git a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php index 0e8a7f4f7fd1a..d61c912fcec44 100644 --- a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php @@ -83,7 +83,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index 0f78cf7ee3202..7ed9d3d5da25f 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -127,7 +127,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php b/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php index ee370076c17ac..d98da682cd90d 100644 --- a/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php +++ b/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php @@ -39,7 +39,7 @@ public function testBind(CompletionInput $input, string $expectedType, ?string $ $this->assertEquals($expectedValue, $input->getCompletionValue(), 'Unexpected value'); } - public function provideBindData() + public static function provideBindData() { // option names yield 'optname-minimal-input' => [CompletionInput::fromTokens(['bin/console', '-'], 1), CompletionInput::TYPE_OPTION_NAME, null, '-']; @@ -90,7 +90,7 @@ public function testBindWithLastArrayArgument(CompletionInput $input, ?string $e $this->assertEquals($expectedValue, $input->getCompletionValue(), 'Unexpected value'); } - public function provideBindWithLastArrayArgumentData() + public static function provideBindWithLastArrayArgumentData() { yield [CompletionInput::fromTokens(['bin/console'], 1), null]; yield [CompletionInput::fromTokens(['bin/console', 'symfony', 'sensiolabs'], 3), null]; @@ -124,7 +124,7 @@ public function testFromString($inputStr, array $expectedTokens) $this->assertEquals($expectedTokens, $tokensProperty->getValue($input)); } - public function provideFromStringData() + public static function provideFromStringData() { yield ['bin/console cache:clear', ['bin/console', 'cache:clear']]; yield ['bin/console --env prod', ['bin/console', '--env', 'prod']]; diff --git a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php index eec4eff438eef..1556617fb8a64 100644 --- a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php +++ b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php @@ -112,7 +112,7 @@ public function testProcessFallsBackToDefaultName() $this->assertSame(['new-name' => 'with-default-name'], $container->getDefinition('console.command_loader')->getArgument(1)); } - public function visibilityProvider() + public static function visibilityProvider() { return [ [true], diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php similarity index 75% rename from src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php rename to src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php index 97199fb34573e..6e0caab542fb7 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php @@ -19,7 +19,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\BufferedOutput; -abstract class AbstractDescriptorTest extends TestCase +abstract class AbstractDescriptorTestCase extends TestCase { /** @dataProvider getDescribeInputArgumentTestData */ public function testDescribeInputArgument(InputArgument $argument, $expectedDescription) @@ -51,40 +51,40 @@ public function testDescribeApplication(Application $application, $expectedDescr $this->assertDescription($expectedDescription, $application); } - public function getDescribeInputArgumentTestData() + public static function getDescribeInputArgumentTestData() { - return $this->getDescriptionTestData(ObjectsProvider::getInputArguments()); + return static::getDescriptionTestData(ObjectsProvider::getInputArguments()); } - public function getDescribeInputOptionTestData() + public static function getDescribeInputOptionTestData() { - return $this->getDescriptionTestData(ObjectsProvider::getInputOptions()); + return static::getDescriptionTestData(ObjectsProvider::getInputOptions()); } - public function getDescribeInputDefinitionTestData() + public static function getDescribeInputDefinitionTestData() { - return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions()); + return static::getDescriptionTestData(ObjectsProvider::getInputDefinitions()); } - public function getDescribeCommandTestData() + public static function getDescribeCommandTestData() { - return $this->getDescriptionTestData(ObjectsProvider::getCommands()); + return static::getDescriptionTestData(ObjectsProvider::getCommands()); } - public function getDescribeApplicationTestData() + public static function getDescribeApplicationTestData() { - return $this->getDescriptionTestData(ObjectsProvider::getApplications()); + return static::getDescriptionTestData(ObjectsProvider::getApplications()); } abstract protected function getDescriptor(); - abstract protected function getFormat(); + abstract protected static function getFormat(); - protected function getDescriptionTestData(array $objects) + protected static function getDescriptionTestData(array $objects) { $data = []; foreach ($objects as $name => $object) { - $description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this->getFormat())); + $description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, static::getFormat())); $data[] = [$object, $description]; } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php b/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php index da64dca00b949..989521ebb6aa6 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php @@ -31,7 +31,7 @@ public function testGetNamespaces(array $expected, array $names) $this->assertSame($expected, array_keys((new ApplicationDescription($application))->getNamespaces())); } - public function getNamespacesProvider() + public static function getNamespacesProvider() { return [ [['_global'], ['foobar']], diff --git a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php index 60ef029777778..648476dc458f8 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php @@ -13,14 +13,14 @@ use Symfony\Component\Console\Descriptor\JsonDescriptor; -class JsonDescriptorTest extends AbstractDescriptorTest +class JsonDescriptorTest extends AbstractDescriptorTestCase { protected function getDescriptor() { return new JsonDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'json'; } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php index a8f11cb4aeb46..295c7acea6fe0 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php @@ -15,19 +15,19 @@ use Symfony\Component\Console\Tests\Fixtures\DescriptorApplicationMbString; use Symfony\Component\Console\Tests\Fixtures\DescriptorCommandMbString; -class MarkdownDescriptorTest extends AbstractDescriptorTest +class MarkdownDescriptorTest extends AbstractDescriptorTestCase { - public function getDescribeCommandTestData() + public static function getDescribeCommandTestData() { - return $this->getDescriptionTestData(array_merge( + return self::getDescriptionTestData(array_merge( ObjectsProvider::getCommands(), ['command_mbstring' => new DescriptorCommandMbString()] )); } - public function getDescribeApplicationTestData() + public static function getDescribeApplicationTestData() { - return $this->getDescriptionTestData(array_merge( + return self::getDescriptionTestData(array_merge( ObjectsProvider::getApplications(), ['application_mbstring' => new DescriptorApplicationMbString()] )); @@ -38,7 +38,7 @@ protected function getDescriptor() return new MarkdownDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'md'; } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php index 26bbd907a73dd..c576ac2d792b7 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php @@ -16,19 +16,19 @@ use Symfony\Component\Console\Tests\Fixtures\DescriptorApplicationMbString; use Symfony\Component\Console\Tests\Fixtures\DescriptorCommandMbString; -class TextDescriptorTest extends AbstractDescriptorTest +class TextDescriptorTest extends AbstractDescriptorTestCase { - public function getDescribeCommandTestData() + public static function getDescribeCommandTestData() { - return $this->getDescriptionTestData(array_merge( + return self::getDescriptionTestData(array_merge( ObjectsProvider::getCommands(), ['command_mbstring' => new DescriptorCommandMbString()] )); } - public function getDescribeApplicationTestData() + public static function getDescribeApplicationTestData() { - return $this->getDescriptionTestData(array_merge( + return self::getDescriptionTestData(array_merge( ObjectsProvider::getApplications(), ['application_mbstring' => new DescriptorApplicationMbString()] )); @@ -46,7 +46,7 @@ protected function getDescriptor() return new TextDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'txt'; } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php index 59a5d1ed8a2a5..98f92991a0640 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php @@ -13,14 +13,14 @@ use Symfony\Component\Console\Descriptor\XmlDescriptor; -class XmlDescriptorTest extends AbstractDescriptorTest +class XmlDescriptorTest extends AbstractDescriptorTestCase { protected function getDescriptor() { return new XmlDescriptor(); } - protected function getFormat() + protected static function getFormat() { return 'xml'; } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application.dont_run_alternative_namespace_name.txt b/src/Symfony/Component/Console/Tests/Fixtures/application.dont_run_alternative_namespace_name.txt new file mode 100644 index 0000000000000..430edde204529 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application.dont_run_alternative_namespace_name.txt @@ -0,0 +1,8 @@ + + + There are no commands defined in the "foos" namespace. + + Did you mean this? + foo + + diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index c6d2184e974f1..84eb8d87f1fd9 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -185,7 +185,7 @@ public function testInlineStyleOptions(string $tag, string $expected = null, str } } - public function provideInlineStyleOptionsCases() + public static function provideInlineStyleOptionsCases() { return [ [''], @@ -258,7 +258,7 @@ public function testNotDecoratedFormatter(string $input, string $expectedNonDeco } } - public function provideDecoratedAndNonDecoratedOutput() + public static function provideDecoratedAndNonDecoratedOutput() { return [ ['some error', 'some error', "\033[37;41msome error\033[39;49m"], diff --git a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTestCase.php similarity index 93% rename from src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php rename to src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTestCase.php index 3da1216244432..66f45c27f0a4c 100644 --- a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTestCase.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\StreamableInputInterface; -abstract class AbstractQuestionHelperTest extends TestCase +abstract class AbstractQuestionHelperTestCase extends TestCase { protected function createStreamableInputInterfaceMock($stream = null, $interactive = true) { diff --git a/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php b/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php index 906d322b665d2..1b37e4e9390c0 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php @@ -42,7 +42,7 @@ public function testInvoke($variable, $primitiveString) $this->assertSame($primitiveString, $dumper($variable)); } - public function provideVariables() + public static function provideVariables() { return [ [null, 'null'], diff --git a/src/Symfony/Component/Console/Tests/Helper/DumperTest.php b/src/Symfony/Component/Console/Tests/Helper/DumperTest.php index e491422b0fbb8..0a30c6ec34642 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DumperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DumperTest.php @@ -45,7 +45,7 @@ public function testInvoke($variable) $this->assertDumpMatchesFormat($dumper($variable), $variable); } - public function provideVariables() + public static function provideVariables() { return [ [null], diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperTest.php index b8c8910874ed8..9f59aa2ff1a76 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperTest.php @@ -17,7 +17,7 @@ class HelperTest extends TestCase { - public function formatTimeProvider() + public static function formatTimeProvider() { return [ [0, '< 1 sec'], @@ -43,7 +43,7 @@ public function formatTimeProvider() ]; } - public function decoratedTextProvider() + public static function decoratedTextProvider() { return [ ['abc', 'abc'], diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php index e2880f22f4317..b4d7b0bbcd484 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php @@ -49,7 +49,7 @@ public function testPassedCallbackIsExecuted() $this->assertTrue($executed); } - public function provideCommandsAndOutput() + public static function provideCommandsAndOutput() { $successOutputVerbose = <<<'EOT' RUN php -r "echo 42;" diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index c9b9c9d535956..a0c6ee129fac2 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -954,7 +954,7 @@ public function testFormatsWithoutMax($format) /** * Provides each defined format. */ - public function provideFormat(): array + public static function provideFormat(): array { return [ ['normal'], diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php index cd97d406eb1f5..ffb3472eca11c 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php @@ -158,7 +158,7 @@ public function testFormats($format) /** * Provides each defined format. */ - public function provideFormat(): array + public static function provideFormat(): array { return [ ['normal'], diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 1297b92f98a87..9761e8f979345 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -30,7 +30,7 @@ /** * @group tty */ -class QuestionHelperTest extends AbstractQuestionHelperTest +class QuestionHelperTest extends AbstractQuestionHelperTestCase { public function testAskChoice() { @@ -340,7 +340,7 @@ public function testAskWithAutocompleteWithExactMatch() $this->assertSame('b', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question)); } - public function getInputs() + public static function getInputs() { return [ ['$'], // 1 byte character @@ -536,7 +536,7 @@ public function testAskConfirmation($question, $expected, $default = true) $this->assertEquals($expected, $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question), 'confirmation question should '.($expected ? 'pass' : 'cancel')); } - public function getAskConfirmationData() + public static function getAskConfirmationData() { return [ ['', true], @@ -612,7 +612,7 @@ public function testSelectChoiceFromSimpleChoices($providedAnswer, $expectedValu $this->assertSame($expectedValue, $answer); } - public function simpleAnswerProvider() + public static function simpleAnswerProvider() { return [ [0, 'My environment 1'], @@ -647,7 +647,7 @@ public function testSpecialCharacterChoiceFromMultipleChoiceList($providedAnswer $this->assertSame($expectedValue, $answer); } - public function specialCharacterInMultipleChoice() + public static function specialCharacterInMultipleChoice() { return [ ['.', ['.']], @@ -697,7 +697,7 @@ public function testAmbiguousChoiceFromChoicelist() $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("My environment\n")), $this->createOutputInterface(), $question); } - public function answerProvider() + public static function answerProvider() { return [ ['env_1', 'env_1'], diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index 72c3f879f2c69..c6a5bf88abc58 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -23,7 +23,7 @@ /** * @group tty */ -class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest +class SymfonyQuestionHelperTest extends AbstractQuestionHelperTestCase { public function testAskChoice() { diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 2d70bd271f589..d10289c66a09b 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -88,7 +88,7 @@ public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected, $d $this->assertEquals($expected, $this->getOutputContent($output)); } - public function renderProvider() + public static function renderProvider() { $books = [ ['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'], @@ -1268,7 +1268,7 @@ public function testSetTitle($headerTitle, $footerTitle, $style, $expected) $this->assertEquals($expected, $this->getOutputContent($output)); } - public function renderSetTitle() + public static function renderSetTitle() { return [ [ @@ -1481,7 +1481,7 @@ public function testBoxedStyleWithColspan() $this->assertSame($expected, $this->getOutputContent($output)); } - public function provideRenderHorizontalTests() + public static function provideRenderHorizontalTests() { $headers = ['foo', 'bar', 'baz']; $rows = [['one', 'two', 'tree'], ['1', '2', '3']]; diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 23333327027dd..b5289fa0185d2 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -61,7 +61,7 @@ public function testParseOptionsNegatable($input, $options, $expectedOptions, $m $this->assertEquals($expectedOptions, $input->getOptions(), $message); } - public function provideOptions() + public static function provideOptions() { return [ [ @@ -187,7 +187,7 @@ public function provideOptions() ]; } - public function provideNegatableOptions() + public static function provideNegatableOptions() { return [ [ @@ -259,7 +259,7 @@ public function testInvalidInputNegatable($argv, $definition, $expectedException $input->bind($definition); } - public function provideInvalidInput() + public static function provideInvalidInput() { return [ [ @@ -330,7 +330,7 @@ public function provideInvalidInput() ]; } - public function provideInvalidNegatableInput() + public static function provideInvalidNegatableInput() { return [ [ @@ -516,7 +516,7 @@ public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyPara $this->assertEquals($expected, $input->getParameterOption($key, $default, $onlyParams), '->getParameterOption() returns the expected value'); } - public function provideGetParameterOptionValues() + public static function provideGetParameterOptionValues() { return [ [['app/console', 'foo:bar'], '-e', 'default', false, 'default'], diff --git a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php index 5777c44b7269a..733322490d00b 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -74,7 +74,7 @@ public function testParseOptions($input, $options, $expectedOptions, $message) $this->assertEquals($expectedOptions, $input->getOptions(), $message); } - public function provideOptions() + public static function provideOptions() { return [ [ @@ -133,7 +133,7 @@ public function testParseInvalidInput($parameters, $definition, $expectedExcepti new ArrayInput($parameters, $definition); } - public function provideInvalidInput() + public static function provideInvalidInput() { return [ [ diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index 11c6ae165eb7c..39157af8f41d8 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -367,7 +367,7 @@ public function testGetSynopsis(InputDefinition $definition, $expectedSynopsis, $this->assertEquals($expectedSynopsis, $definition->getSynopsis(), $message ? '->getSynopsis() '.$message : ''); } - public function getGetSynopsisData() + public static function getGetSynopsisData() { return [ [new InputDefinition([new InputOption('foo')]), '[--foo]', 'puts optional options in square brackets'], diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 2bd40dec9c365..c55256c037196 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -43,7 +43,7 @@ public function testInputOptionWithGivenString() $this->assertEquals('bar', $input->getOption('foo')); } - public function getTokenizeData() + public static function getTokenizeData() { return [ ['', [], '->tokenize() parses an empty string'], diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index 3585bde63a123..4a96ddb154051 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -69,7 +69,7 @@ public function testOutputMapping($logLevel, $outputVerbosity, $isOutput, $addVe $this->assertEquals($isOutput ? "[$logLevel] foo bar".\PHP_EOL : '', $logs); } - public function provideOutputMappingParams() + public static function provideOutputMappingParams() { $quietMap = [LogLevel::EMERGENCY => OutputInterface::VERBOSITY_QUIET]; @@ -123,7 +123,7 @@ public function testLogsAtAllLevels($level, $message) $this->assertEquals($expected, $this->getLogs()); } - public function provideLevelsAndMessages() + public static function provideLevelsAndMessages() { return [ LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], diff --git a/src/Symfony/Component/Console/Tests/Output/OutputTest.php b/src/Symfony/Component/Console/Tests/Output/OutputTest.php index 330064973baa0..f337c4ddd5471 100644 --- a/src/Symfony/Component/Console/Tests/Output/OutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/OutputTest.php @@ -104,7 +104,7 @@ public function testWriteRawMessage($message, $type, $expectedOutput) $this->assertEquals($expectedOutput, $output->output); } - public function provideWriteArguments() + public static function provideWriteArguments() { return [ ['foo', Output::OUTPUT_RAW, "foo\n"], @@ -161,7 +161,7 @@ public function testWriteWithVerbosityOption($verbosity, $expected, $msg) $this->assertEquals($expected, $output->output, $msg); } - public function verbosityProvider() + public static function verbosityProvider() { return [ [Output::VERBOSITY_QUIET, '2', '->write() in QUIET mode only outputs when an explicit QUIET verbosity is passed'], diff --git a/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php b/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php index a7a2dfba487a6..d8b1f10ec217d 100644 --- a/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php @@ -39,7 +39,7 @@ public function testSelectUseCases($multiSelect, $answers, $expected, $message, } } - public function selectUseCases() + public static function selectUseCases() { return [ [ @@ -119,7 +119,7 @@ public function testSelectAssociativeChoices($providedAnswer, $expectedValue) $this->assertSame($expectedValue, $question->getValidator()($providedAnswer)); } - public function selectAssociativeChoicesProvider() + public static function selectAssociativeChoicesProvider() { return [ 'select "0" choice by key' => ['0', '0'], diff --git a/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php b/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php index 83899772a82db..44f4c870bb2e1 100644 --- a/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php @@ -30,7 +30,7 @@ public function testDefaultRegexUsecases($default, $answers, $expected, $message } } - public function normalizerUsecases() + public static function normalizerUsecases() { return [ [ diff --git a/src/Symfony/Component/Console/Tests/Question/QuestionTest.php b/src/Symfony/Component/Console/Tests/Question/QuestionTest.php index 55e9d58d4a2c7..e6b6fbee0ed10 100644 --- a/src/Symfony/Component/Console/Tests/Question/QuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/QuestionTest.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->question = new Question('Test question'); } - public function providerTrueFalse() + public static function providerTrueFalse() { return [[true], [false]]; } @@ -104,7 +104,7 @@ public function testIsHiddenFallbackDefault() self::assertTrue($this->question->isHiddenFallback()); } - public function providerGetSetAutocompleterValues() + public static function providerGetSetAutocompleterValues() { return [ 'array' => [ @@ -135,7 +135,7 @@ public function testGetSetAutocompleterValues($values, $expectValues) ); } - public function providerSetAutocompleterValuesInvalid() + public static function providerSetAutocompleterValuesInvalid() { return [ ['Potato'], @@ -229,7 +229,7 @@ function (string $input): array { return []; } $this->assertNull($exception); } - public function providerGetSetValidator() + public static function providerGetSetValidator() { return [ [function ($input) { return $input; }], @@ -251,7 +251,7 @@ public function testGetValidatorDefault() self::assertNull($this->question->getValidator()); } - public function providerGetSetMaxAttempts() + public static function providerGetSetMaxAttempts() { return [[1], [5], [null]]; } @@ -265,7 +265,7 @@ public function testGetSetMaxAttempts($attempts) self::assertSame($attempts, $this->question->getMaxAttempts()); } - public function providerSetMaxAttemptsInvalid() + public static function providerSetMaxAttemptsInvalid() { return [[0], [-1]]; } diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php index 74c24034095b1..621767bf73f0c 100644 --- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php @@ -69,14 +69,14 @@ public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath) $this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true)); } - public function inputInteractiveCommandToOutputFilesProvider() + public static function inputInteractiveCommandToOutputFilesProvider() { $baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle'; return array_map(null, glob($baseDir.'/command/interactive_command_*.php'), glob($baseDir.'/output/interactive_output_*.txt')); } - public function inputCommandToOutputFilesProvider() + public static function inputCommandToOutputFilesProvider() { $baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle'; @@ -151,7 +151,7 @@ public function testCreateTableWithoutConsoleOutput() $style = new SymfonyStyle($input, $output); $this->expectException(RuntimeException::class); - $this->expectDeprecationMessage('Output should be an instance of "Symfony\Component\Console\Output\ConsoleSectionOutput"'); + $this->expectExceptionMessage('Output should be an instance of "Symfony\Component\Console\Output\ConsoleSectionOutput"'); $style->createTable()->appendRow(['row']); } diff --git a/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php b/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php index 2de8ac3458160..7a2b4c7193e1a 100644 --- a/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php @@ -47,7 +47,7 @@ public function testUnsuccessfulCommand(string $expectedException, int $exitCode $this->fail(); } - public function providesUnsuccessful(): iterable + public static function providesUnsuccessful(): iterable { yield 'Failed' => ['Command failed.', Command::FAILURE]; yield 'Invalid' => ['Command was invalid.', Command::INVALID]; diff --git a/src/Symfony/Component/CssSelector/LICENSE b/src/Symfony/Component/CssSelector/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/CssSelector/LICENSE +++ b/src/Symfony/Component/CssSelector/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php index 5fca6939daf0c..36d39f39d7cd5 100644 --- a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php +++ b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php @@ -60,7 +60,7 @@ public function testCssToXPathWithoutPrefix($css, $xpath) $this->assertEquals($xpath, $converter->toXPath($css, ''), '->parse() parses an input string and returns a node'); } - public function getCssToXPathWithoutPrefixTestData() + public static function getCssToXPathWithoutPrefixTestData() { return [ ['h1', 'h1'], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php similarity index 80% rename from src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php rename to src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php index 595551338061e..521e6d8bce7ce 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\NodeInterface; -abstract class AbstractNodeTest extends TestCase +abstract class AbstractNodeTestCase extends TestCase { /** @dataProvider getToStringConversionTestData */ public function testToStringConversion(NodeInterface $node, $representation) @@ -28,7 +28,7 @@ public function testSpecificityValue(NodeInterface $node, $value) $this->assertEquals($value, $node->getSpecificity()->getValue()); } - abstract public function getToStringConversionTestData(); + abstract public static function getToStringConversionTestData(); - abstract public function getSpecificityValueTestData(); + abstract public static function getSpecificityValueTestData(); } diff --git a/src/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php index 4d60074061f07..62364c45b78e6 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Node\AttributeNode; use Symfony\Component\CssSelector\Node\ElementNode; -class AttributeNodeTest extends AbstractNodeTest +class AttributeNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Attribute[Element[*][attribute]]'], @@ -25,7 +25,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php index aa80c92792f39..3c0c67a1c879a 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php @@ -14,16 +14,16 @@ use Symfony\Component\CssSelector\Node\ClassNode; use Symfony\Component\CssSelector\Node\ElementNode; -class ClassNodeTest extends AbstractNodeTest +class ClassNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new ClassNode(new ElementNode(), 'class'), 10], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php index 435eaa6aa6981..bf9ed06c50a9d 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Node\CombinedSelectorNode; use Symfony\Component\CssSelector\Node\ElementNode; -class CombinedSelectorNodeTest extends AbstractNodeTest +class CombinedSelectorNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'], @@ -24,7 +24,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php index e0797ff09cf5a..e864eec8c9f91 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php @@ -13,9 +13,9 @@ use Symfony\Component\CssSelector\Node\ElementNode; -class ElementNodeTest extends AbstractNodeTest +class ElementNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new ElementNode(), 'Element[*]'], @@ -24,7 +24,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new ElementNode(), 0], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php index 0932393e1aa10..b8d2e7a602663 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php @@ -15,9 +15,9 @@ use Symfony\Component\CssSelector\Node\FunctionNode; use Symfony\Component\CssSelector\Parser\Token; -class FunctionNodeTest extends AbstractNodeTest +class FunctionNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'], @@ -31,7 +31,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new FunctionNode(new ElementNode(), 'function'), 10], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php index ad6765b8625c4..a33cdd9e751d0 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php @@ -14,16 +14,16 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\HashNode; -class HashNodeTest extends AbstractNodeTest +class HashNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new HashNode(new ElementNode(), 'id'), 100], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php index 90b684ceec8b4..f90fa36c0c418 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php @@ -15,16 +15,16 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\NegationNode; -class NegationNodeTest extends AbstractNodeTest +class NegationNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php index 4e78776c02a41..f4c74047b4fff 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php @@ -14,16 +14,16 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\PseudoNode; -class PseudoNodeTest extends AbstractNodeTest +class PseudoNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new PseudoNode(new ElementNode(), 'pseudo'), 10], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php index 85e3bdac3fdef..3bf66665f9580 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\SelectorNode; -class SelectorNodeTest extends AbstractNodeTest +class SelectorNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new SelectorNode(new ElementNode()), 'Selector[Element[*]]'], @@ -24,7 +24,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new SelectorNode(new ElementNode()), 0], diff --git a/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php b/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php index bf48d49ffdbd4..8802e0c40ee1b 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php @@ -28,7 +28,7 @@ public function testPlusValue(Specificity $specificity, $value) $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); } - public function getValueTestData() + public static function getValueTestData() { return [ [new Specificity(0, 0, 0), 0], @@ -45,7 +45,7 @@ public function testCompareTo(Specificity $a, Specificity $b, $result) $this->assertEquals($result, $a->compareTo($b)); } - public function getCompareTestData() + public static function getCompareTestData() { return [ [new Specificity(0, 0, 0), new Specificity(0, 0, 0), 0], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php similarity index 91% rename from src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php rename to src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php index aaed55c205a9a..69291e5e18c14 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php @@ -19,7 +19,7 @@ /** * @author Jean-François Simon */ -abstract class AbstractHandlerTest extends TestCase +abstract class AbstractHandlerTestCase extends TestCase { /** @dataProvider getHandleValueTestData */ public function testHandleValue($value, Token $expectedToken, $remainingContent) @@ -43,9 +43,9 @@ public function testDontHandleValue($value) $this->assertRemainingContent($reader, $value); } - abstract public function getHandleValueTestData(); + abstract public static function getHandleValueTestData(); - abstract public function getDontHandleValueTestData(); + abstract public static function getDontHandleValueTestData(); abstract protected function generateHandler(); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php index de400478d8a0e..c3be7f486b0d3 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php @@ -16,7 +16,7 @@ use Symfony\Component\CssSelector\Parser\Token; use Symfony\Component\CssSelector\Parser\TokenStream; -class CommentHandlerTest extends AbstractHandlerTest +class CommentHandlerTest extends AbstractHandlerTestCase { /** @dataProvider getHandleValueTestData */ public function testHandleValue($value, Token $unusedArgument, $remainingContent) @@ -30,7 +30,7 @@ public function testHandleValue($value, Token $unusedArgument, $remainingContent $this->assertRemainingContent($reader, $remainingContent); } - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ // 2nd argument only exists for inherited method compatibility @@ -39,7 +39,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['>'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php index 9444f5106f33d..c2ad0319300bd 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php @@ -16,9 +16,9 @@ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class HashHandlerTest extends AbstractHandlerTest +class HashHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['#id', new Token(Token::TYPE_HASH, 'id', 0), ''], @@ -29,7 +29,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['id'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php index c54ba537b8a27..a39abb67e4317 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php @@ -16,9 +16,9 @@ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class IdentifierHandlerTest extends AbstractHandlerTest +class IdentifierHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''], @@ -29,7 +29,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['>'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php index b43d369421840..7087a6be01a16 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php @@ -15,9 +15,9 @@ use Symfony\Component\CssSelector\Parser\Token; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class NumberHandlerTest extends AbstractHandlerTest +class NumberHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['12', new Token(Token::TYPE_NUMBER, '12', 0), ''], @@ -30,7 +30,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['hello'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php index baa72735ff165..9a984ed38790d 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php @@ -16,9 +16,9 @@ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class StringHandlerTest extends AbstractHandlerTest +class StringHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''], @@ -31,7 +31,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['hello'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php index 67509ef135473..81dd761b33bce 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler; use Symfony\Component\CssSelector\Parser\Token; -class WhitespaceHandlerTest extends AbstractHandlerTest +class WhitespaceHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ [' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''], @@ -28,7 +28,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['>'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php index 77ce5d58258a2..e36731b3fe542 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -93,7 +93,7 @@ public function testParseSeriesException($series) Parser::parseSeries($function->getArguments()); } - public function getParserTestData() + public static function getParserTestData() { return [ ['*', ['Element[*]']], @@ -151,7 +151,7 @@ public function getParserTestData() ]; } - public function getParserExceptionTestData() + public static function getParserExceptionTestData() { return [ ['attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()], @@ -181,7 +181,7 @@ public function getParserExceptionTestData() ]; } - public function getPseudoElementsTestData() + public static function getPseudoElementsTestData() { return [ ['foo', 'Element[foo]', ''], @@ -203,7 +203,7 @@ public function getPseudoElementsTestData() ]; } - public function getSpecificityTestData() + public static function getSpecificityTestData() { return [ ['*', 0], @@ -231,7 +231,7 @@ public function getSpecificityTestData() ]; } - public function getParseSeriesTestData() + public static function getParseSeriesTestData() { return [ ['1n+3', 1, 3], @@ -253,7 +253,7 @@ public function getParseSeriesTestData() ]; } - public function getParseSeriesExceptionTestData() + public static function getParseSeriesExceptionTestData() { return [ ['foo'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php index 29d9d5f16b240..ded92ea3c2d20 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php @@ -32,7 +32,7 @@ public function testParse($source, $representation) $this->assertEquals($representation, (string) $selector->getTree()); } - public function getParseTestData() + public static function getParseTestData() { return [ ['.testclass', 'Class[Element[*].testclass]'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php index 79cc2270324f6..4c1002959df1b 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php @@ -32,7 +32,7 @@ public function testParse($source, $representation) $this->assertEquals($representation, (string) $selector->getTree()); } - public function getParseTestData() + public static function getParseTestData() { return [ ['*', 'Element[*]'], diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php index a7c79d69a547a..c8bfdef9f7369 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php @@ -32,7 +32,7 @@ public function testParse($source, $representation) $this->assertEquals($representation, (string) $selector->getTree()); } - public function getParseTestData() + public static function getParseTestData() { return [ ['#testid', 'Hash[Element[*]#testid]'], diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index 0a1ba4dcdcc2c..d3306001352f3 100644 --- a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -165,7 +165,7 @@ public function testOnlyOfTypeFindsSingleChildrenOfGivenType() $this->assertSame('A', $nodeList->item(0)->textContent); } - public function getXpathLiteralTestData() + public static function getXpathLiteralTestData() { return [ ['foo', "'foo'"], @@ -175,7 +175,7 @@ public function getXpathLiteralTestData() ]; } - public function getCssToXPathTestData() + public static function getCssToXPathTestData() { return [ ['*', '*'], @@ -222,7 +222,7 @@ public function getCssToXPathTestData() ]; } - public function getXmlLangTestData() + public static function getXmlLangTestData() { return [ [':lang("EN")', ['first', 'second', 'third', 'fourth']], @@ -237,7 +237,7 @@ public function getXmlLangTestData() ]; } - public function getHtmlIdsTestData() + public static function getHtmlIdsTestData() { return [ ['div', ['outer-div', 'li-div', 'foobar-div']], @@ -362,7 +362,7 @@ public function getHtmlIdsTestData() ]; } - public function getHtmlShakespearTestData() + public static function getHtmlShakespearTestData() { return [ ['*', 246], diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php index 362c5f5718298..f7a2176ebcece 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php @@ -175,9 +175,9 @@ protected function getConstructor(Definition $definition, bool $required) } /** - * @throws RuntimeException - * * @return \ReflectionFunctionAbstract + * + * @throws RuntimeException */ protected function getReflectionMethod(Definition $definition, string $method) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 5418268756fe6..6c3cf82cac072 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -45,7 +45,6 @@ class AutowirePass extends AbstractRecursivePass private $decoratedMethodIndex; private $decoratedMethodArgumentIndex; private $typesClone; - private $combinedAliases; public function __construct(bool $throwOnAutowireException = true) { @@ -61,8 +60,6 @@ public function __construct(bool $throwOnAutowireException = true) */ public function process(ContainerBuilder $container) { - $this->populateCombinedAliases($container); - try { $this->typesClone = clone $this; parent::process($container); @@ -75,7 +72,6 @@ public function process(ContainerBuilder $container) $this->decoratedMethodIndex = null; $this->decoratedMethodArgumentIndex = null; $this->typesClone = null; - $this->combinedAliases = []; } } @@ -375,12 +371,12 @@ private function getAutowiredReference(TypedReference $reference, bool $filterTy return new TypedReference($alias, $type, $reference->getInvalidBehavior()); } - if (null !== ($alias = $this->combinedAliases[$alias] ?? null) && !$this->container->findDefinition($alias)->isAbstract()) { + if (null !== ($alias = $this->getCombinedAlias($type, $name) ?? null) && !$this->container->findDefinition($alias)->isAbstract()) { return new TypedReference($alias, $type, $reference->getInvalidBehavior()); } if ($this->container->has($name) && !$this->container->findDefinition($name)->isAbstract()) { - foreach ($this->container->getAliases() + $this->combinedAliases as $id => $alias) { + foreach ($this->container->getAliases() as $id => $alias) { if ($name === (string) $alias && str_starts_with($id, $type.' $')) { return new TypedReference($name, $type, $reference->getInvalidBehavior()); } @@ -392,7 +388,7 @@ private function getAutowiredReference(TypedReference $reference, bool $filterTy return new TypedReference($type, $type, $reference->getInvalidBehavior()); } - if (null !== ($alias = $this->combinedAliases[$type] ?? null) && !$this->container->findDefinition($alias)->isAbstract()) { + if (null !== ($alias = $this->getCombinedAlias($type) ?? null) && !$this->container->findDefinition($alias)->isAbstract()) { return new TypedReference($alias, $type, $reference->getInvalidBehavior()); } @@ -586,44 +582,31 @@ private function populateAutowiringAlias(string $id): void } } - private function populateCombinedAliases(ContainerBuilder $container): void + private function getCombinedAlias(string $type, string $name = null): ?string { - $this->combinedAliases = []; - $reverseAliases = []; - - foreach ($container->getAliases() as $id => $alias) { - if (!preg_match('/(?(DEFINE)(?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+))^((?&V)(?:\\\\(?&V))*+)(?: \$((?&V)))?$/', $id, $m)) { - continue; - } - - $type = $m[2]; - $name = $m[3] ?? ''; - $reverseAliases[(string) $alias][$name][] = $type; + if (str_contains($type, '&')) { + $types = explode('&', $type); + } elseif (str_contains($type, '|')) { + $types = explode('|', $type); + } else { + return null; } - foreach ($reverseAliases as $alias => $names) { - foreach ($names as $name => $types) { - if (2 > $count = \count($types)) { - continue; - } - sort($types); - $i = 1 << $count; - - // compute the powerset of the list of types - while ($i--) { - $set = []; - for ($j = 0; $j < $count; ++$j) { - if ($i & (1 << $j)) { - $set[] = $types[$j]; - } - } + $alias = null; + $suffix = $name ? ' $'.$name : ''; - if (2 <= \count($set)) { - $this->combinedAliases[implode('&', $set).('' === $name ? '' : ' $'.$name)] = $alias; - $this->combinedAliases[implode('|', $set).('' === $name ? '' : ' $'.$name)] = $alias; - } - } + foreach ($types as $type) { + if (!$this->container->hasAlias($type.$suffix)) { + return null; + } + + if (null === $alias) { + $alias = (string) $this->container->getAlias($type.$suffix); + } elseif ((string) $this->container->getAlias($type.$suffix) !== $alias) { + return null; } } + + return $alias; } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php index 6b7a034d631d0..8ca86c1110fbf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php @@ -53,7 +53,7 @@ public function process(ContainerBuilder $container) $tagsToKeep = $container->hasParameter('container.behavior_describing_tags') ? $container->getParameter('container.behavior_describing_tags') - : ['container.do_not_inline', 'container.service_locator', 'container.service_subscriber', 'container.service_subscriber.locator']; + : ['proxy', 'container.do_not_inline', 'container.service_locator', 'container.service_subscriber', 'container.service_subscriber.locator']; foreach ($definitions as [$id, $definition]) { $decoratedService = $definition->getDecoratedService(); diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 6f61eb869171f..838756d47edba 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -36,11 +36,12 @@ class_exists(ArgumentServiceLocator::class); * The container can have four possible behaviors when a service * does not exist (or is not initialized for the last case): * - * * EXCEPTION_ON_INVALID_REFERENCE: Throws an exception (the default) + * * EXCEPTION_ON_INVALID_REFERENCE: Throws an exception at compilation time (the default) * * NULL_ON_INVALID_REFERENCE: Returns null * * IGNORE_ON_INVALID_REFERENCE: Ignores the wrapping command asking for the reference * (for instance, ignore a setter if the service does not exist) * * IGNORE_ON_UNINITIALIZED_REFERENCE: Ignores/returns null for uninitialized services or invalid references + * * RUNTIME_EXCEPTION_ON_INVALID_REFERENCE: Throws an exception at runtime * * @author Fabien Potencier * @author Johannes M. Schmitt diff --git a/src/Symfony/Component/DependencyInjection/LICENSE b/src/Symfony/Component/DependencyInjection/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/DependencyInjection/LICENSE +++ b/src/Symfony/Component/DependencyInjection/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 8756e89ed16c6..2d9137cb5e40f 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -707,9 +707,9 @@ private function parseDefinition(string $id, $service, string $file, array $defa * * @param string|array $callable A callable reference * - * @throws InvalidArgumentException When errors occur - * * @return string|array|Reference + * + * @throws InvalidArgumentException When errors occur */ private function parseCallable($callable, string $parameter, string $id, string $file) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php index e2e6f0a0b67a2..7d5521ddb85db 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php @@ -128,7 +128,7 @@ public function testCannotDeprecateWithAnInvalidTemplate($message) $def->setDeprecated('package', '1.1', $message); } - public function invalidDeprecationMessageProvider() + public static function invalidDeprecationMessageProvider() { return [ "With \rs" => ["invalid \r message %alias_id%"], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php b/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php index fbeb0238aa8a3..dcc38dde7fb19 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php @@ -67,7 +67,7 @@ public function testDefaultIndexMethod(?string $indexAttribute, ?string $default $this->assertSame($expectedDefaultIndexMethod, $taggedIteratorArgument->getDefaultIndexMethod()); } - public function defaultIndexMethodProvider() + public static function defaultIndexMethodProvider() { yield 'No indexAttribute and no defaultIndexMethod' => [ null, @@ -116,7 +116,7 @@ public function testDefaultPriorityIndexMethod(?string $indexAttribute, ?string $this->assertSame($expectedDefaultPriorityMethod, $taggedIteratorArgument->getDefaultPriorityMethod()); } - public function defaultPriorityMethodProvider() + public static function defaultPriorityMethodProvider() { yield 'No indexAttribute and no defaultPriorityMethod' => [ null, diff --git a/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php index 5c7e187590b69..8340c3e63507d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php @@ -40,7 +40,7 @@ public function testSetProperty($property, $changeKey) $this->assertSame([$changeKey => true], $def->getChanges()); } - public function getPropertyTests() + public static function getPropertyTests() { return [ ['class', 'class'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php index 406beebce9120..9baff5e6fe190 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php @@ -58,7 +58,7 @@ public function testProcessWithMissingAttribute(string $attribute, array $attrib (new AliasDeprecatedPublicServicesPass())->process($container); } - public function processWithMissingAttributeProvider() + public static function processWithMissingAttributeProvider() { return [ ['package', ['version' => '1.2']], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 6dcc9d220efde..e61e2d45fc41f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -954,7 +954,7 @@ public function testNotWireableCalls($method, $expectedMsg) } } - public function provideNotWireableCalls() + public static function provideNotWireableCalls() { return [ ['setNotAutowireable', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setNotAutowireable()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotARealClass" but this class was not found.'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php index 322dcd2583fbe..6d0a2edd083e5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php @@ -56,7 +56,7 @@ public function testException(array $arguments, array $methodCalls) $pass->process($container); } - public function definitionProvider() + public static function definitionProvider() { return [ [['a' => 'a', null], []], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php index 7f548492b1fea..cac0460841105 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php @@ -262,6 +262,25 @@ public function testProcessLeavesServiceSubscriberTagOnOriginalDefinition() $this->assertEquals(['bar' => ['attr' => 'baz'], 'foobar' => ['attr' => 'bar']], $container->getDefinition('baz')->getTags()); } + public function testProcessLeavesProxyTagOnOriginalDefinition() + { + $container = new ContainerBuilder(); + $container + ->register('foo') + ->setTags(['proxy' => 'foo', 'bar' => ['attr' => 'baz']]) + ; + $container + ->register('baz') + ->setTags(['foobar' => ['attr' => 'bar']]) + ->setDecoratedService('foo') + ; + + $this->process($container); + + $this->assertEquals(['proxy' => 'foo'], $container->getDefinition('baz.inner')->getTags()); + $this->assertEquals(['bar' => ['attr' => 'baz'], 'foobar' => ['attr' => 'bar']], $container->getDefinition('baz')->getTags()); + } + public function testCannotDecorateSyntheticService() { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php index 0c1fe4d141958..fae8772193b32 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php @@ -264,7 +264,7 @@ public function testYamlContainerCompiles($directory, $actualServiceId, $expecte $this->assertEquals($expectedService, $actualService); } - public function getYamlCompileTests() + public static function getYamlCompileTests() { $container = new ContainerBuilder(); $container->registerForAutoconfiguration(IntegrationTestStub::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php index 4f4b2a69468af..4d5ee1fb41b3d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php @@ -182,7 +182,7 @@ public function testTheIndexedTagsByDefaultIndexMethodFailure(string $defaultInd $priorityTaggedServiceTraitImplementation->test($tag, $container); } - public function provideInvalidDefaultMethods(): iterable + public static function provideInvalidDefaultMethods(): iterable { yield ['getMethodShouldBeStatic', null, sprintf('Method "%s::getMethodShouldBeStatic()" should be static.', FooTaggedForInvalidDefaultMethodClass::class)]; yield ['getMethodShouldBeStatic', 'foo', sprintf('Either method "%s::getMethodShouldBeStatic()" should be static or tag "my_custom_tag" on service "service1" is missing attribute "foo".', FooTaggedForInvalidDefaultMethodClass::class)]; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php index 89e5fa2ea2abd..6678b6c5d8972 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php @@ -33,7 +33,7 @@ public function testResolveClassFromId($serviceId) $this->assertSame($serviceId, $def->getClass()); } - public function provideValidClassId() + public static function provideValidClassId() { yield ['Acme\UnknownClass']; yield [CaseSensitiveClass::class]; @@ -52,7 +52,7 @@ public function testWontResolveClassFromId($serviceId) $this->assertNull($def->getClass()); } - public function provideInvalidClassId() + public static function provideInvalidClassId() { yield [\stdClass::class]; yield ['bar']; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php index 6b69e0bf2151d..8d93eeb9cbff3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php @@ -46,7 +46,7 @@ public function testInlinedDefinitionFactoryIsProcessed() $this->assertSame(['Baz\Qux', 'getInstance'], $factory->getFactory()[0]->getFactory()); } - public function provideFulfilledFactories() + public static function provideFulfilledFactories() { return [ [['Foo\Bar', 'create']], diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 5fa9c5dfbd813..bf35ba135dfd4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -227,7 +227,7 @@ public function testBadDefinitionId($id) $builder->setDefinition($id, new Definition('Foo')); } - public function provideBadId() + public static function provideBadId() { return [ [''], @@ -1490,7 +1490,7 @@ public function testAlmostCircular($visibility) $this->assertInstanceOf(\stdClass::class, $listener4); } - public function provideAlmostCircular() + public static function provideAlmostCircular() { yield ['public']; yield ['private']; diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 497dc99385834..d9fa0f3790cf0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -40,7 +40,7 @@ public function testCamelize($id, $expected) $this->assertEquals($expected, Container::camelize($id), sprintf('Container::camelize("%s")', $id)); } - public function dataForTestCamelize() + public static function dataForTestCamelize() { return [ ['foo_bar', 'FooBar'], @@ -64,7 +64,7 @@ public function testUnderscore($id, $expected) $this->assertEquals($expected, Container::underscore($id), sprintf('Container::underscore("%s")', $id)); } - public function dataForTestUnderscore() + public static function dataForTestUnderscore() { return [ ['FooBar', 'foo_bar'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php index 2b0a1301697a9..699080d6bdb82 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php @@ -71,7 +71,7 @@ public function testCrossCheck($fixture, $type) $this->assertEquals($services2, $services1, 'Iterator on the containers returns the same services'); } - public function crossCheckLoadersDumpers() + public static function crossCheckLoadersDumpers() { return [ ['services1.xml', 'xml'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index ae6d5bd948c0a..73bae605917a7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -213,7 +213,7 @@ public function testSetDeprecatedWithInvalidDeprecationTemplate($message) $def->setDeprecated('vendor/package', '1.1', $message); } - public function invalidDeprecationMessageProvider() + public static function invalidDeprecationMessageProvider() { return [ "With \rs" => ["invalid \r message %service_id%"], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 4c05bc49a2a62..9763d2c158731 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -398,7 +398,7 @@ public function testInvalidFactories($factory) $dumper->dump(); } - public function provideInvalidFactories() + public static function provideInvalidFactories() { return [ [['', 'method']], @@ -1105,7 +1105,7 @@ public function testAlmostCircular($visibility) $this->assertInstanceOf(\stdClass::class, $listener4); } - public function provideAlmostCircular() + public static function provideAlmostCircular() { yield ['public']; yield ['private']; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 4149198fabc13..9e2547cc244e6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -127,7 +127,7 @@ public function testDumpDecoratedServices($expectedXmlDump, $container) $this->assertEquals($expectedXmlDump, $dumper->dump()); } - public function provideDecoratedServicesData() + public static function provideDecoratedServicesData() { $fixturesPath = realpath(__DIR__.'/../Fixtures/'); @@ -191,7 +191,7 @@ public function testCompiledContainerCanBeDumped($containerFile) $this->addToAssertionCount(1); } - public function provideCompiledContainerData() + public static function provideCompiledContainerData() { return [ ['container8'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php index 248f6313b7588..e14fb6ae2449f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php @@ -43,7 +43,7 @@ public function testGetEnvString($value, $processed) $this->assertSame($processed, $result); } - public function validStrings() + public static function validStrings() { return [ ['hello', 'hello'], @@ -89,7 +89,7 @@ public function testGetEnvNot($value, $processed) $this->assertSame(!$processed, $result); } - public function validBools() + public static function validBools() { return [ ['true', true], @@ -118,7 +118,7 @@ public function testGetEnvInt($value, $processed) $this->assertSame($processed, $result); } - public function validInts() + public static function validInts() { return [ ['1', 1], @@ -143,7 +143,7 @@ public function testGetEnvIntInvalid($value) }); } - public function invalidInts() + public static function invalidInts() { return [ ['foo'], @@ -168,7 +168,7 @@ public function testGetEnvFloat($value, $processed) $this->assertSame($processed, $result); } - public function validFloats() + public static function validFloats() { return [ ['1', 1.0], @@ -193,7 +193,7 @@ public function testGetEnvFloatInvalid($value) }); } - public function invalidFloats() + public static function invalidFloats() { return [ ['foo'], @@ -218,7 +218,7 @@ public function testGetEnvConst($value, $processed) $this->assertSame($processed, $result); } - public function validConsts() + public static function validConsts() { return [ ['Symfony\Component\DependencyInjection\Tests\EnvVarProcessorTest::TEST_CONST', self::TEST_CONST], @@ -242,7 +242,7 @@ public function testGetEnvConstInvalid($value) }); } - public function invalidConsts() + public static function invalidConsts() { return [ ['Symfony\Component\DependencyInjection\Tests\EnvVarProcessorTest::UNDEFINED_CONST'], @@ -298,7 +298,7 @@ public function testGetEnvJson($value, $processed) $this->assertSame($processed, $result); } - public function validJson() + public static function validJson() { return [ ['[1]', [1]], @@ -336,7 +336,7 @@ public function testGetEnvJsonOther($value) }); } - public function otherJsonValues() + public static function otherJsonValues() { return [ [1], @@ -387,7 +387,7 @@ public function testGetEnvKeyNoArrayResult($value) }); } - public function noArrayValues() + public static function noArrayValues() { return [ [null], @@ -413,7 +413,7 @@ public function testGetEnvKeyArrayKeyNotFound($value) }); } - public function invalidArrayValues() + public static function invalidArrayValues() { return [ [[]], @@ -436,7 +436,7 @@ public function testGetEnvKey($value) })); } - public function arrayValues() + public static function arrayValues() { return [ [['index' => 'password']], @@ -478,7 +478,7 @@ public function testGetEnvNullable($value, $processed) $this->assertSame($processed, $result); } - public function validNullables() + public static function validNullables() { return [ ['hello', 'hello'], @@ -533,7 +533,7 @@ public function testGetEnvResolve($value, $processed) $this->assertSame($processed, $result); } - public function validResolve() + public static function validResolve() { return [ ['string', 'string'], @@ -574,7 +574,7 @@ public function testGetEnvResolveNotScalar($value) }); } - public function notScalarResolve() + public static function notScalarResolve() { return [ [null], @@ -634,7 +634,7 @@ public function testGetEnvCsv($value, $processed) $this->assertSame($processed, $result); } - public function validCsv() + public static function validCsv() { $complex = <<<'CSV' ,"""","foo""","\""",\,foo\ @@ -749,7 +749,7 @@ public function testGetEnvUrlPath(?string $expected, string $url) })['path']); } - public function provideGetEnvUrlPath() + public static function provideGetEnvUrlPath() { return [ ['', 'https://symfony.com'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php index d61388ea2dd72..ef88c71cad9c7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php @@ -26,7 +26,7 @@ public function testExceptionMessage(\ReflectionParameter $parameter, string $ex self::assertSame($expectedMessage, $exception->getMessage()); } - public function provideReflectionParameters(): iterable + public static function provideReflectionParameters(): iterable { yield 'static method' => [ new \ReflectionParameter([MyClass::class, 'doSomething'], 0), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index 37fa0ad9d9132..48d8b0078688e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -32,7 +32,7 @@ public function testIsConfigEnabledReturnsTheResolvedValue($enabled) $this->assertSame($enabled, $extension->isConfigEnabled(new ContainerBuilder(), ['enabled' => $enabled])); } - public function getResolvedEnabledFixtures() + public static function getResolvedEnabledFixtures() { return [ [true], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php index 0b354e7615635..10f8e6f5af165 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php @@ -24,7 +24,7 @@ public function test(string $expected, EnvConfigurator $envConfigurator) $this->assertSame($expected, (string) $envConfigurator); } - public function provide() + public static function provide() { yield ['%env(FOO)%', new EnvConfigurator('FOO')]; yield ['%env(string:FOO)%', new EnvConfigurator('string:FOO')]; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index 6c2743e860344..02e34fc13e376 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -262,7 +262,7 @@ public function testExcludeTrailingSlashConsistency(string $exclude) $this->assertFalse($container->has(DeeperBaz::class)); } - public function excludeTrailingSlashConsistencyProvider(): iterable + public static function excludeTrailingSlashConsistencyProvider(): iterable { yield ['Prototype/OtherDir/AnotherSub/']; yield ['Prototype/OtherDir/AnotherSub']; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 07f23f3137af5..e81f7fbb2d310 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -58,7 +58,7 @@ public function testTypeConversionsWithNativePhp($key, $value, $supported) $this->assertSame($value, $expected['parameters'][$key], '->load() converts values to PHP types'); } - public function getTypeConversions() + public static function getTypeConversions() { return [ ['true_comment', true, true], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php index cfd8aa3cf69f4..5980a3c636393 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php @@ -42,7 +42,7 @@ protected function setUp(): void ]); } - public function provideResourcesToLoad() + public static function provideResourcesToLoad() { return [ ['ini_with_wrong_ext.xml', 'ini', IniFileLoader::class], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php index c324e9c13308a..8b141d2577ee3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php @@ -85,7 +85,7 @@ public function testConfig($file) $this->assertStringMatchesFormatFile($fixtures.'/config/'.$file.'.expected.yml', $dumper->dump()); } - public function provideConfig() + public static function provideConfig() { yield ['basic']; yield ['object']; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 67f389ddc4ffb..cffed2c4c3286 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -93,7 +93,7 @@ public function testLoadInvalidFile($file) $loader->load($file.'.yml'); } - public function provideInvalidFiles() + public static function provideInvalidFiles() { return [ ['bad_parameters'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index 8bdabb7bb8e8d..f8db1cd211682 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -84,7 +84,7 @@ public function testGetThrowParameterNotFoundException($parameterKey, $exception $bag->get($parameterKey); } - public function provideGetThrowParameterNotFoundExceptionData() + public static function provideGetThrowParameterNotFoundExceptionData() { return [ ['foo1', 'You have requested a non-existent parameter "foo1". Did you mean this: "foo"?'], @@ -244,7 +244,7 @@ public function testResolveStringWithSpacesReturnsString($expected, $test, $desc } } - public function stringsWithSpacesProvider() + public static function stringsWithSpacesProvider() { return [ ['bar', '%foo%', 'Parameters must be wrapped by %.'], diff --git a/src/Symfony/Component/DomCrawler/LICENSE b/src/Symfony/Component/DomCrawler/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/DomCrawler/LICENSE +++ b/src/Symfony/Component/DomCrawler/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php similarity index 99% rename from src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php rename to src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php index a816650c26827..55178ca0e4538 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php @@ -18,7 +18,7 @@ use Symfony\Component\DomCrawler\Image; use Symfony\Component\DomCrawler\Link; -abstract class AbstractCrawlerTest extends TestCase +abstract class AbstractCrawlerTestCase extends TestCase { use ExpectDeprecationTrait; @@ -912,7 +912,7 @@ public function testSiblings() } } - public function provideMatchTests() + public static function provideMatchTests() { yield ['#foo', true, '#foo']; yield ['#foo', true, '.foo']; @@ -1160,7 +1160,7 @@ public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri = $this->assertEquals($expectedUri, $crawler->filterXPath('//a')->link()->getUri(), $description); } - public function getBaseTagData() + public static function getBaseTagData() { return [ ['http://base.com', 'link', 'http://base.com/link'], @@ -1180,7 +1180,7 @@ public function testBaseTagWithForm($baseValue, $actionValue, $expectedUri, $cur $this->assertEquals($expectedUri, $crawler->filterXPath('//button')->form()->getUri(), $description); } - public function getBaseTagWithFormData() + public static function getBaseTagWithFormData() { return [ ['https://base.com/', 'link/', 'https://base.com/link/', 'https://base.com/link/', ' tag does work with a path and relative form action'], diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php index dc665f1546f9f..793440258c65d 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php @@ -78,7 +78,7 @@ public function testSetValue($method) ); } - public function getSetValueMethods() + public static function getSetValueMethods() { return [ ['setValue'], diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 3b29b0f588ffe..7248a31a6be05 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -78,7 +78,7 @@ public function testConstructorThrowsExceptionIfNoRelatedForm(\DOMElement $node) new Form($node, 'http://example.com'); } - public function constructorThrowsExceptionIfNoRelatedFormProvider() + public static function constructorThrowsExceptionIfNoRelatedFormProvider() { $dom = new \DOMDocument(); $dom->loadHTML(' @@ -217,7 +217,7 @@ function ($field) { ); } - public function provideInitializeValues() + public static function provideInitializeValues() { return [ [ @@ -585,7 +585,7 @@ public function testGetUriWithActionOverride() $this->assertEquals('http://localhost/bar', $form->getUri(), '->getUri() returns absolute URIs'); } - public function provideGetUriValues() + public static function provideGetUriValues() { return [ [ diff --git a/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php index 92370616598b0..2b1e6f3e776b2 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Html5ParserCrawlerTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\DomCrawler\Tests; -class Html5ParserCrawlerTest extends AbstractCrawlerTest +class Html5ParserCrawlerTest extends AbstractCrawlerTestCase { public static function getDoctype(): string { @@ -50,9 +50,9 @@ public function testHtml5ParserWithInvalidHeadedContent(string $content) self::assertEmpty($crawler->filterXPath('//h1')->text(), '->addHtmlContent failed as expected'); } - public function validHtml5Provider(): iterable + public static function validHtml5Provider(): iterable { - $html = static::getDoctype().'

Foo

'; + $html = self::getDoctype().'

Foo

'; $BOM = \chr(0xEF).\chr(0xBB).\chr(0xBF); yield 'BOM first' => [$BOM.$html]; @@ -63,9 +63,9 @@ public function validHtml5Provider(): iterable yield 'All together' => [$BOM.' '.$html]; } - public function invalidHtml5Provider(): iterable + public static function invalidHtml5Provider(): iterable { - $html = static::getDoctype().'

Foo

'; + $html = self::getDoctype().'

Foo

'; yield 'Text' => ['hello world'.$html]; yield 'Text between comments' => [' test '.$html]; diff --git a/src/Symfony/Component/DomCrawler/Tests/ImageTest.php b/src/Symfony/Component/DomCrawler/Tests/ImageTest.php index c8c3b0a72382c..4fdf7a9501ba2 100644 --- a/src/Symfony/Component/DomCrawler/Tests/ImageTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/ImageTest.php @@ -56,7 +56,7 @@ public function testGetUri($url, $currentUri, $expected) $this->assertEquals($expected, $image->getUri()); } - public function getGetUriTests() + public static function getGetUriTests() { return [ ['/foo.png', 'http://localhost/bar/foo/', 'http://localhost/foo.png'], diff --git a/src/Symfony/Component/DomCrawler/Tests/LinkTest.php b/src/Symfony/Component/DomCrawler/Tests/LinkTest.php index 084a6efd77c28..93490885a7bd2 100644 --- a/src/Symfony/Component/DomCrawler/Tests/LinkTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/LinkTest.php @@ -105,7 +105,7 @@ public function testGetUriOnLink($url, $currentUri, $expected) $this->assertEquals($expected, $link->getUri()); } - public function getGetUriTests() + public static function getGetUriTests() { return [ ['/foo', 'http://localhost/bar/foo/', 'http://localhost/foo'], diff --git a/src/Symfony/Component/DomCrawler/Tests/NativeParserCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/NativeParserCrawlerTest.php index c0cac9e8b603f..c61d9354b0371 100644 --- a/src/Symfony/Component/DomCrawler/Tests/NativeParserCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/NativeParserCrawlerTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\DomCrawler\Tests; -class NativeParserCrawlerTest extends AbstractCrawlerTest +class NativeParserCrawlerTest extends AbstractCrawlerTestCase { public static function getDoctype(): string { diff --git a/src/Symfony/Component/DomCrawler/Tests/UriResolverTest.php b/src/Symfony/Component/DomCrawler/Tests/UriResolverTest.php index c62d7d3811338..06a4d30c06a46 100644 --- a/src/Symfony/Component/DomCrawler/Tests/UriResolverTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/UriResolverTest.php @@ -24,7 +24,7 @@ public function testResolver(string $uri, string $baseUri, string $expected) $this->assertEquals($expected, UriResolver::resolve($uri, $baseUri)); } - public function provideResolverTests() + public static function provideResolverTests() { return [ ['/foo', 'http://localhost/bar/foo/', 'http://localhost/foo'], diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index 2c76d52c809e8..4091c673432fa 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -81,8 +81,8 @@ public function usePutenv(bool $usePutenv = true): self /** * Loads one or several .env files. * - * @param string $path A file to load - * @param string[] ...$extraPaths A list of additional files to load + * @param string $path A file to load + * @param string ...$extraPaths A list of additional files to load * * @throws FormatException when a file has a syntax error * @throws PathException when a file does not exist or is not readable @@ -98,10 +98,10 @@ public function load(string $path, string ...$extraPaths): void * .env.local is always ignored in test env because tests should produce the same results for everyone. * .env.dist is loaded when it exists and .env is not found. * - * @param string $path A file to load - * @param string $envKey|null The name of the env vars that defines the app env - * @param string $defaultEnv The app env to use when none is defined - * @param array $testEnvs A list of app envs for which .env.local should be ignored + * @param string $path A file to load + * @param string|null $envKey The name of the env vars that defines the app env + * @param string $defaultEnv The app env to use when none is defined + * @param array $testEnvs A list of app envs for which .env.local should be ignored * * @throws FormatException when a file has a syntax error * @throws PathException when a file does not exist or is not readable @@ -167,8 +167,8 @@ public function bootEnv(string $path, string $defaultEnv = 'dev', array $testEnv /** * Loads one or several .env files and enables override existing vars. * - * @param string $path A file to load - * @param string[] ...$extraPaths A list of additional files to load + * @param string $path A file to load + * @param string ...$extraPaths A list of additional files to load * * @throws FormatException when a file has a syntax error * @throws PathException when a file does not exist or is not readable diff --git a/src/Symfony/Component/Dotenv/LICENSE b/src/Symfony/Component/Dotenv/LICENSE index f2345234aa9ea..0223acd4a01f4 100644 --- a/src/Symfony/Component/Dotenv/LICENSE +++ b/src/Symfony/Component/Dotenv/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2023 Fabien Potencier +Copyright (c) 2016-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php index 47c9bfba137ac..2089e4bca336c 100644 --- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php +++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php @@ -33,7 +33,7 @@ public function testParseWithFormatError($data, $error) } } - public function getEnvDataWithFormatErrors() + public static function getEnvDataWithFormatErrors() { $tests = [ ['FOO=BAR BAZ', "A value containing spaces must be surrounded by quotes in \".env\" at line 1.\n...FOO=BAR BAZ...\n ^ line 1 offset 11"], @@ -71,7 +71,7 @@ public function testParse($data, $expected) $this->assertSame($expected, $dotenv->parse($data)); } - public function getEnvData() + public static function getEnvData() { putenv('LOCAL=local'); $_ENV['LOCAL'] = 'local'; diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 746e8d44a548e..2d82c31682729 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -1090,7 +1090,20 @@ private function fixReturnStatements(\ReflectionMethod $method, string $returnTy } $end = $method->isGenerator() ? $i : $method->getEndLine(); + $inClosure = false; + $braces = 0; for (; $i < $end; ++$i) { + if (!$inClosure) { + $inClosure = str_contains($code[$i], 'function ('); + } + + if ($inClosure) { + $braces += substr_count($code[$i], '{') - substr_count($code[$i], '}'); + $inClosure = $braces > 0; + + continue; + } + if ('void' === $returnType) { $fixedCode[$i] = str_replace(' return null;', ' return;', $code[$i]); } elseif ('mixed' === $returnType || '?' === $returnType[0]) { diff --git a/src/Symfony/Component/ErrorHandler/LICENSE b/src/Symfony/Component/ErrorHandler/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/ErrorHandler/LICENSE +++ b/src/Symfony/Component/ErrorHandler/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/ErrorHandler/Resources/views/error.html.php b/src/Symfony/Component/ErrorHandler/Resources/views/error.html.php index 5416d03c8c159..dcd30c295f56c 100644 --- a/src/Symfony/Component/ErrorHandler/Resources/views/error.html.php +++ b/src/Symfony/Component/ErrorHandler/Resources/views/error.html.php @@ -1,5 +1,5 @@ - + diff --git a/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php index 83d7793d89592..66409ddc98efa 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php @@ -141,7 +141,7 @@ class_exists('Test\\'.__NAMESPACE__.'\\'.$class, true); $this->assertSame($xError, $lastError); } - public function provideDeprecatedSuper(): array + public static function provideDeprecatedSuper(): array { return [ ['DeprecatedInterfaceClass', 'DeprecatedInterface', 'implements'], diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php index 1ca2f162b9eb1..72ee19985e00c 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php @@ -72,7 +72,7 @@ public function testEnhance(string $originalMessage, string $enhancedMessage, $a $this->assertSame($expectedLine, $error->getLine()); } - public function provideClassNotFoundData() + public static function provideClassNotFoundData() { $autoloader = new ComposerClassLoader(); $autoloader->add('Symfony\Component\ErrorHandler\Error\\', realpath(__DIR__.'/../../Error')); diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php index fe7d5371a11ae..547e33373720b 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php @@ -34,7 +34,7 @@ public function testEnhance(string $originalMessage, string $enhancedMessage) $this->assertSame($expectedLine, $error->getLine()); } - public function provideUndefinedFunctionData() + public static function provideUndefinedFunctionData() { return [ [ diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php index b31c6c292a8f4..f417200242608 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedMethodErrorEnhancerTest.php @@ -33,7 +33,7 @@ public function testEnhance(string $originalMessage, string $enhancedMessage) $this->assertSame($expectedLine, $error->getLine()); } - public function provideUndefinedMethodData() + public static function provideUndefinedMethodData() { return [ [ diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php index 9688579d79a32..8f57bb53b8cb5 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php @@ -448,7 +448,7 @@ public function testHandleException(string $expectedMessage, \Throwable $excepti } } - public function handleExceptionProvider(): array + public static function handleExceptionProvider(): array { return [ ['Uncaught Exception: foo', new \Exception('foo')], @@ -648,7 +648,7 @@ public function testErrorHandlerWhenLogging(bool $previousHandlerWasDefined, boo } } - public function errorHandlerWhenLoggingProvider(): iterable + public static function errorHandlerWhenLoggingProvider(): iterable { foreach ([false, true] as $previousHandlerWasDefined) { foreach ([false, true] as $loggerSetsAnotherHandler) { diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorRenderer/HtmlErrorRendererTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorRenderer/HtmlErrorRendererTest.php index f292d0f79618f..6680b95a0cc3d 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorRenderer/HtmlErrorRendererTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorRenderer/HtmlErrorRendererTest.php @@ -24,7 +24,7 @@ public function testRender(\Throwable $exception, HtmlErrorRenderer $errorRender $this->assertStringMatchesFormat($expected, $errorRenderer->render($exception)->getAsString()); } - public function getRenderData(): iterable + public static function getRenderData(): iterable { $expectedDebug = << @@ -37,7 +37,7 @@ public function getRenderData(): iterable $expectedNonDebug = << - + %AAn Error Occurred: Internal Server Error %A

The server returned a "500 Internal Server Error".

%A HTML; diff --git a/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php index da4fba3b3d3d8..6262656fd839d 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php @@ -226,7 +226,7 @@ public function testCreate() ); } - public function flattenDataProvider(): array + public static function flattenDataProvider(): array { return [ [new \Exception('test', 123), 'Exception'], @@ -234,7 +234,7 @@ public function flattenDataProvider(): array ]; } - public function stringAndIntDataProvider(): array + public static function stringAndIntDataProvider(): array { return [ [new \Exception('test1', 123)], diff --git a/src/Symfony/Component/EventDispatcher/LICENSE b/src/Symfony/Component/EventDispatcher/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/EventDispatcher/LICENSE +++ b/src/Symfony/Component/EventDispatcher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php index 6564d23f3220f..68db87db73bf7 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php @@ -28,7 +28,7 @@ public function testListenerDescription($listener, $expected) $this->assertStringMatchesFormat($expected, $wrappedListener->getPretty()); } - public function provideListenersToDescribe() + public static function provideListenersToDescribe() { return [ [new FooListener(), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::__invoke'], diff --git a/src/Symfony/Component/ExpressionLanguage/LICENSE b/src/Symfony/Component/ExpressionLanguage/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/ExpressionLanguage/LICENSE +++ b/src/Symfony/Component/ExpressionLanguage/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index c4c98dd88006b..309472c4321b0 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -119,7 +119,7 @@ public function testParseThrowsInsteadOfNotice() $expressionLanguage->parse('node.', ['node']); } - public function shortCircuitProviderEvaluate() + public static function shortCircuitProviderEvaluate() { $object = new class(\Closure::fromCallable([static::class, 'fail'])) { private $fail; @@ -143,7 +143,7 @@ public function foo() ]; } - public function shortCircuitProviderCompile() + public static function shortCircuitProviderCompile() { return [ ['false and foo', ['foo' => 'foo'], false], @@ -267,7 +267,7 @@ public function testRegisterAfterCompile($registerCallback) $registerCallback($el); } - public function getRegisterCallbacks() + public static function getRegisterCallbacks() { return [ [ diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php index 67e551f587eb7..8441e52a230eb 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php @@ -54,7 +54,7 @@ public function testTokenizeThrowsErrorOnUnclosedBrace() $this->lexer->tokenize($expression); } - public function getTokenizeData() + public static function getTokenizeData() { return [ [ diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTestCase.php similarity index 83% rename from src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTest.php rename to src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTestCase.php index 297503746e002..7521788835144 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/AbstractNodeTestCase.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\ExpressionLanguage\Compiler; -abstract class AbstractNodeTest extends TestCase +abstract class AbstractNodeTestCase extends TestCase { /** * @dataProvider getEvaluateData @@ -24,7 +24,7 @@ public function testEvaluate($expected, $node, $variables = [], $functions = []) $this->assertSame($expected, $node->evaluate($functions, $variables)); } - abstract public function getEvaluateData(); + abstract public static function getEvaluateData(); /** * @dataProvider getCompileData @@ -36,7 +36,7 @@ public function testCompile($expected, $node, $functions = []) $this->assertSame($expected, $compiler->getSource()); } - abstract public function getCompileData(); + abstract public static function getCompileData(); /** * @dataProvider getDumpData @@ -46,5 +46,5 @@ public function testDump($expected, $node) $this->assertSame($expected, $node->dump()); } - abstract public function getDumpData(); + abstract public static function getDumpData(); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArgumentsNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArgumentsNodeTest.php index 9d88b4ae75d6a..2b25073e83dcf 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArgumentsNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArgumentsNodeTest.php @@ -15,21 +15,21 @@ class ArgumentsNodeTest extends ArrayNodeTest { - public function getCompileData() + public static function getCompileData(): array { return [ - ['"a", "b"', $this->getArrayNode()], + ['"a", "b"', static::getArrayNode()], ]; } - public function getDumpData() + public static function getDumpData(): \Generator { - return [ - ['"a", "b"', $this->getArrayNode()], + yield from [ + ['"a", "b"', static::getArrayNode()], ]; } - protected function createArrayNode() + protected static function createArrayNode(): \Symfony\Component\ExpressionLanguage\Node\ArrayNode { return new ArgumentsNode(); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArrayNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArrayNodeTest.php index 3d03d837e9600..fcd76364c38e7 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArrayNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ArrayNodeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\ExpressionLanguage\Node\ArrayNode; use Symfony\Component\ExpressionLanguage\Node\ConstantNode; -class ArrayNodeTest extends AbstractNodeTest +class ArrayNodeTest extends AbstractNodeTestCase { public function testSerialization() { @@ -28,45 +28,45 @@ public function testSerialization() $this->assertNotEquals($this->createArrayNode(), $unserializedNode); } - public function getEvaluateData() + public static function getEvaluateData(): array { return [ - [['b' => 'a', 'b'], $this->getArrayNode()], + [['b' => 'a', 'b'], static::getArrayNode()], ]; } - public function getCompileData() + public static function getCompileData(): array { return [ - ['["b" => "a", 0 => "b"]', $this->getArrayNode()], + ['["b" => "a", 0 => "b"]', static::getArrayNode()], ]; } - public function getDumpData() + public static function getDumpData(): \Generator { - yield ['{"b": "a", 0: "b"}', $this->getArrayNode()]; + yield ['{"b": "a", 0: "b"}', static::getArrayNode()]; - $array = $this->createArrayNode(); + $array = static::createArrayNode(); $array->addElement(new ConstantNode('c'), new ConstantNode('a"b')); $array->addElement(new ConstantNode('d'), new ConstantNode('a\b')); yield ['{"a\\"b": "c", "a\\\\b": "d"}', $array]; - $array = $this->createArrayNode(); + $array = static::createArrayNode(); $array->addElement(new ConstantNode('c')); $array->addElement(new ConstantNode('d')); yield ['["c", "d"]', $array]; } - protected function getArrayNode() + protected static function getArrayNode(): ArrayNode { - $array = $this->createArrayNode(); + $array = static::createArrayNode(); $array->addElement(new ConstantNode('a'), new ConstantNode('b')); $array->addElement(new ConstantNode('b')); return $array; } - protected function createArrayNode() + protected static function createArrayNode(): ArrayNode { return new ArrayNode(); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php index fe3115a225df9..a44a6854ca918 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php @@ -18,9 +18,9 @@ use Symfony\Component\ExpressionLanguage\Node\NameNode; use Symfony\Component\ExpressionLanguage\SyntaxError; -class BinaryNodeTest extends AbstractNodeTest +class BinaryNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { $array = new ArrayNode(); $array->addElement(new ConstantNode('a')); @@ -71,7 +71,7 @@ public function getEvaluateData() ]; } - public function getCompileData() + public static function getCompileData(): array { $array = new ArrayNode(); $array->addElement(new ConstantNode('a')); @@ -120,7 +120,7 @@ public function getCompileData() ]; } - public function getDumpData() + public static function getDumpData(): array { $array = new ArrayNode(); $array->addElement(new ConstantNode('a')); diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConditionalNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConditionalNodeTest.php index 13b7cbdec125d..4555429bfee59 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConditionalNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConditionalNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\ExpressionLanguage\Node\ConditionalNode; use Symfony\Component\ExpressionLanguage\Node\ConstantNode; -class ConditionalNodeTest extends AbstractNodeTest +class ConditionalNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { return [ [1, new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))], @@ -24,7 +24,7 @@ public function getEvaluateData() ]; } - public function getCompileData() + public static function getCompileData(): array { return [ ['((true) ? (1) : (2))', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))], @@ -32,7 +32,7 @@ public function getCompileData() ]; } - public function getDumpData() + public static function getDumpData(): array { return [ ['(true ? 1 : 2)', new ConditionalNode(new ConstantNode(true), new ConstantNode(1), new ConstantNode(2))], diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConstantNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConstantNodeTest.php index fee9f5bff430d..f1b10041d0e44 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConstantNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/ConstantNodeTest.php @@ -13,9 +13,9 @@ use Symfony\Component\ExpressionLanguage\Node\ConstantNode; -class ConstantNodeTest extends AbstractNodeTest +class ConstantNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { return [ [false, new ConstantNode(false)], @@ -28,7 +28,7 @@ public function getEvaluateData() ]; } - public function getCompileData() + public static function getCompileData(): array { return [ ['false', new ConstantNode(false)], @@ -41,7 +41,7 @@ public function getCompileData() ]; } - public function getDumpData() + public static function getDumpData(): array { return [ ['false', new ConstantNode(false)], diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/FunctionNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/FunctionNodeTest.php index c6cb02c1b9a43..2ae6f954fd119 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/FunctionNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/FunctionNodeTest.php @@ -15,30 +15,30 @@ use Symfony\Component\ExpressionLanguage\Node\FunctionNode; use Symfony\Component\ExpressionLanguage\Node\Node; -class FunctionNodeTest extends AbstractNodeTest +class FunctionNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { return [ - ['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => $this->getCallables()]], + ['bar', new FunctionNode('foo', new Node([new ConstantNode('bar')])), [], ['foo' => static::getCallables()]], ]; } - public function getCompileData() + public static function getCompileData(): array { return [ - ['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]], + ['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => static::getCallables()]], ]; } - public function getDumpData() + public static function getDumpData(): array { return [ - ['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => $this->getCallables()]], + ['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => static::getCallables()]], ]; } - protected function getCallables() + protected static function getCallables(): array { return [ 'compiler' => function ($arg) { diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/GetAttrNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/GetAttrNodeTest.php index c790f33acc337..6d81a2b606a60 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/GetAttrNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/GetAttrNodeTest.php @@ -16,48 +16,48 @@ use Symfony\Component\ExpressionLanguage\Node\GetAttrNode; use Symfony\Component\ExpressionLanguage\Node\NameNode; -class GetAttrNodeTest extends AbstractNodeTest +class GetAttrNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { return [ - ['b', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]], - ['a', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]], + ['b', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), self::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]], + ['a', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), self::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b']]], - ['bar', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]], + ['bar', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), self::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]], - ['baz', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]], - ['a', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b'], 'index' => 'b']], + ['baz', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), self::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]], + ['a', new GetAttrNode(new NameNode('foo'), new NameNode('index'), self::getArrayNode(), GetAttrNode::ARRAY_CALL), ['foo' => ['b' => 'a', 'b'], 'index' => 'b']], ]; } - public function getCompileData() + public static function getCompileData(): array { return [ - ['$foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)], - ['$foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)], + ['$foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), self::getArrayNode(), GetAttrNode::ARRAY_CALL)], + ['$foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), self::getArrayNode(), GetAttrNode::ARRAY_CALL)], - ['$foo->foo', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]], + ['$foo->foo', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), self::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]], - ['$foo->foo(["b" => "a", 0 => "b"])', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]], - ['$foo[$index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)], + ['$foo->foo(["b" => "a", 0 => "b"])', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo'), self::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]], + ['$foo[$index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), self::getArrayNode(), GetAttrNode::ARRAY_CALL)], ]; } - public function getDumpData() + public static function getDumpData(): array { return [ - ['foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)], - ['foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)], + ['foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), self::getArrayNode(), GetAttrNode::ARRAY_CALL)], + ['foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), self::getArrayNode(), GetAttrNode::ARRAY_CALL)], - ['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), $this->getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]], + ['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), self::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]], - ['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), $this->getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]], - ['foo[index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), $this->getArrayNode(), GetAttrNode::ARRAY_CALL)], + ['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), self::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]], + ['foo[index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), self::getArrayNode(), GetAttrNode::ARRAY_CALL)], ]; } - protected function getArrayNode() + protected static function getArrayNode(): ArrayNode { $array = new ArrayNode(); $array->addElement(new ConstantNode('a'), new ConstantNode('b')); diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/NameNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/NameNodeTest.php index a30c27b80489b..661466f7fd2e9 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/NameNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/NameNodeTest.php @@ -13,23 +13,23 @@ use Symfony\Component\ExpressionLanguage\Node\NameNode; -class NameNodeTest extends AbstractNodeTest +class NameNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { return [ ['bar', new NameNode('foo'), ['foo' => 'bar']], ]; } - public function getCompileData() + public static function getCompileData(): array { return [ ['$foo', new NameNode('foo')], ]; } - public function getDumpData() + public static function getDumpData(): array { return [ ['foo', new NameNode('foo')], diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Node/UnaryNodeTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/Node/UnaryNodeTest.php index bac75d24dc278..7da4be718201a 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Node/UnaryNodeTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Node/UnaryNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\ExpressionLanguage\Node\ConstantNode; use Symfony\Component\ExpressionLanguage\Node\UnaryNode; -class UnaryNodeTest extends AbstractNodeTest +class UnaryNodeTest extends AbstractNodeTestCase { - public function getEvaluateData() + public static function getEvaluateData(): array { return [ [-1, new UnaryNode('-', new ConstantNode(1))], @@ -26,7 +26,7 @@ public function getEvaluateData() ]; } - public function getCompileData() + public static function getCompileData(): array { return [ ['(-1)', new UnaryNode('-', new ConstantNode(1))], @@ -36,7 +36,7 @@ public function getCompileData() ]; } - public function getDumpData() + public static function getDumpData(): array { return [ ['(- 1)', new UnaryNode('-', new ConstantNode(1))], diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php index 3cec3e2cebdee..d98091adea460 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php @@ -47,7 +47,7 @@ public function testParse($node, $expression, $names = []) $this->assertEquals($node, $parser->parse($lexer->tokenize($expression), $names)); } - public function getParseData() + public static function getParseData() { $arguments = new Node\ArgumentsNode(); $arguments->addElement(new Node\ConstantNode('arg1')); @@ -139,10 +139,10 @@ public function getParseData() // chained calls [ - $this->createGetAttrNode( - $this->createGetAttrNode( - $this->createGetAttrNode( - $this->createGetAttrNode(new Node\NameNode('foo'), 'bar', Node\GetAttrNode::METHOD_CALL), + self::createGetAttrNode( + self::createGetAttrNode( + self::createGetAttrNode( + self::createGetAttrNode(new Node\NameNode('foo'), 'bar', Node\GetAttrNode::METHOD_CALL), 'foo', Node\GetAttrNode::METHOD_CALL), 'baz', Node\GetAttrNode::PROPERTY_CALL), '3', Node\GetAttrNode::ARRAY_CALL), @@ -192,7 +192,7 @@ public function getParseData() ]; } - private function createGetAttrNode($node, $item, $type) + private static function createGetAttrNode($node, $item, $type) { return new Node\GetAttrNode($node, new Node\ConstantNode($item, Node\GetAttrNode::ARRAY_CALL !== $type), new Node\ArgumentsNode(), $type); } @@ -208,7 +208,7 @@ public function testParseWithInvalidPostfixData($expr, $names = []) $parser->parse($lexer->tokenize($expr), $names); } - public function getInvalidPostfixData() + public static function getInvalidPostfixData() { return [ [ @@ -258,7 +258,7 @@ public function testLint($expression, $names, string $exception = null) $this->expectNotToPerformAssertions(); } - public function getLintData(): array + public static function getLintData(): array { return [ 'valid expression' => [ diff --git a/src/Symfony/Component/ExpressionLanguage/Token.php b/src/Symfony/Component/ExpressionLanguage/Token.php index 8399f70e72156..3df869f07147b 100644 --- a/src/Symfony/Component/ExpressionLanguage/Token.php +++ b/src/Symfony/Component/ExpressionLanguage/Token.php @@ -32,7 +32,7 @@ class Token /** * @param string $type The type of the token (self::*_TYPE) * @param string|int|float|null $value The token value - * @param int $cursor The cursor position in the source + * @param int|null $cursor The cursor position in the source */ public function __construct(string $type, $value, ?int $cursor) { diff --git a/src/Symfony/Component/Filesystem/LICENSE b/src/Symfony/Component/Filesystem/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Filesystem/LICENSE +++ b/src/Symfony/Component/Filesystem/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 164c11b947850..768b9db6f97b5 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1146,7 +1146,7 @@ public function testMakePathRelative($endPath, $startPath, $expectedPath) $this->assertEquals($expectedPath, $path); } - public function providePathsForMakePathRelative() + public static function providePathsForMakePathRelative() { $paths = [ ['/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component', '../'], @@ -1434,7 +1434,7 @@ public function testIsAbsolutePath($path, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function providePathsForIsAbsolutePath() + public static function providePathsForIsAbsolutePath() { return [ ['/var/lib', true], diff --git a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php index 9aa9f3e2f1c00..cb8ed6a775140 100644 --- a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php +++ b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php @@ -22,11 +22,11 @@ class MockStream /** * Opens file or URL. * - * @param string $path Specifies the URL that was passed to the original function - * @param string $mode The mode used to open the file, as detailed for fopen() - * @param int $options Holds additional flags set by the streams API - * @param string $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options, - * opened_path should be set to the full path of the file/resource that was actually opened + * @param string $path Specifies the URL that was passed to the original function + * @param string $mode The mode used to open the file, as detailed for fopen() + * @param int $options Holds additional flags set by the streams API + * @param string|null $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options, + * opened_path should be set to the full path of the file/resource that was actually opened */ public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool { diff --git a/src/Symfony/Component/Filesystem/Tests/PathTest.php b/src/Symfony/Component/Filesystem/Tests/PathTest.php index 3d0f2beb11087..77b9f2a2d0576 100644 --- a/src/Symfony/Component/Filesystem/Tests/PathTest.php +++ b/src/Symfony/Component/Filesystem/Tests/PathTest.php @@ -41,7 +41,7 @@ protected function tearDown(): void putenv('HOMEPATH='.$this->storedEnv['HOMEPATH']); } - public function provideCanonicalizationTests(): \Generator + public static function provideCanonicalizationTests(): \Generator { // relative paths (forward slash) yield ['css/./style.css', 'css/style.css']; @@ -172,7 +172,7 @@ public function testCanonicalize(string $path, string $canonicalized) $this->assertSame($canonicalized, Path::canonicalize($path)); } - public function provideGetDirectoryTests(): \Generator + public static function provideGetDirectoryTests(): \Generator { yield ['/webmozart/symfony/style.css', '/webmozart/symfony']; yield ['/webmozart/symfony', '/webmozart']; @@ -235,7 +235,7 @@ public function testGetDirectory(string $path, string $directory) $this->assertSame($directory, Path::getDirectory($path)); } - public function provideGetFilenameWithoutExtensionTests(): \Generator + public static function provideGetFilenameWithoutExtensionTests(): \Generator { yield ['/webmozart/symfony/style.css.twig', null, 'style.css']; yield ['/webmozart/symfony/style.css.', null, 'style.css']; @@ -266,7 +266,7 @@ public function testGetFilenameWithoutExtension(string $path, ?string $extension $this->assertSame($filename, Path::getFilenameWithoutExtension($path, $extension)); } - public function provideGetExtensionTests(): \Generator + public static function provideGetExtensionTests(): \Generator { yield ['/webmozart/symfony/style.css.twig', false, 'twig']; yield ['/webmozart/symfony/style.css', false, 'css']; @@ -291,7 +291,7 @@ public function testGetExtension(string $path, bool $forceLowerCase, string $ext $this->assertSame($extension, Path::getExtension($path, $forceLowerCase)); } - public function provideHasExtensionTests(): \Generator + public static function provideHasExtensionTests(): \Generator { yield [true, '/webmozart/symfony/style.css.twig', null, false]; yield [true, '/webmozart/symfony/style.css', null, false]; @@ -338,7 +338,7 @@ public function testHasExtension(bool $hasExtension, string $path, $extension, b $this->assertSame($hasExtension, Path::hasExtension($path, $extension, $ignoreCase)); } - public function provideChangeExtensionTests(): \Generator + public static function provideChangeExtensionTests(): \Generator { yield ['/webmozart/symfony/style.css.twig', 'html', '/webmozart/symfony/style.css.html']; yield ['/webmozart/symfony/style.css', 'sass', '/webmozart/symfony/style.sass']; @@ -362,7 +362,7 @@ public function testChangeExtension(string $path, string $extension, string $pat $this->assertSame($pathExpected, Path::changeExtension($path, $extension)); } - public function provideIsAbsolutePathTests(): \Generator + public static function provideIsAbsolutePathTests(): \Generator { yield ['/css/style.css', true]; yield ['/', true]; @@ -405,7 +405,7 @@ public function testIsRelative(string $path, bool $isAbsolute) $this->assertSame(!$isAbsolute, Path::isRelative($path)); } - public function provideGetRootTests(): \Generator + public static function provideGetRootTests(): \Generator { yield ['/css/style.css', '/']; yield ['/', '/']; @@ -439,25 +439,6 @@ public function testGetRoot(string $path, string $root) $this->assertSame($root, Path::getRoot($path)); } - public function providePathTests(): \Generator - { - // relative to absolute path - yield ['css/style.css', '/webmozart/symfony', '/webmozart/symfony/css/style.css']; - yield ['../css/style.css', '/webmozart/symfony', '/webmozart/css/style.css']; - yield ['../../css/style.css', '/webmozart/symfony', '/css/style.css']; - - // relative to root - yield ['css/style.css', '/', '/css/style.css']; - yield ['css/style.css', 'C:', 'C:/css/style.css']; - yield ['css/style.css', 'C:/', 'C:/css/style.css']; - - // same sub directories in different base directories - yield ['../../symfony/css/style.css', '/webmozart/css', '/symfony/css/style.css']; - - yield ['', '/webmozart/symfony', '/webmozart/symfony']; - yield ['..', '/webmozart/symfony', '/webmozart']; - } - private static function getPathTests(): \Generator { yield from [ @@ -479,9 +460,9 @@ private static function getPathTests(): \Generator ]; } - public function provideMakeAbsoluteTests(): \Generator + public static function provideMakeAbsoluteTests(): \Generator { - yield from static::getPathTests(); + yield from self::getPathTests(); // collapse dots yield ['css/./style.css', '/webmozart/symfony', '/webmozart/symfony/css/style.css']; @@ -570,7 +551,7 @@ public function testMakeAbsoluteFailsIfBasePathEmpty() Path::makeAbsolute('css/style.css', ''); } - public function provideAbsolutePathsWithDifferentRoots(): \Generator + public static function provideAbsolutePathsWithDifferentRoots(): \Generator { yield ['C:/css/style.css', '/webmozart/symfony']; yield ['C:/css/style.css', '\\webmozart\\symfony']; @@ -606,9 +587,9 @@ public function testMakeAbsoluteDoesNotFailIfDifferentRoot(string $basePath, str $this->assertSame(Path::canonicalize($absolutePath), Path::makeAbsolute($absolutePath, $basePath)); } - public function provideMakeRelativeTests(): \Generator + public static function provideMakeRelativeTests(): \Generator { - foreach (static::getPathTests() as $set) { + foreach (self::getPathTests() as $set) { yield [$set[2], $set[1], $set[0]]; } @@ -732,7 +713,7 @@ public function testMakeRelativeFailsIfDifferentRoot(string $absolutePath, strin Path::makeRelative($absolutePath, $basePath); } - public function provideIsLocalTests(): \Generator + public static function provideIsLocalTests(): \Generator { yield ['/bg.png', true]; yield ['bg.png', true]; @@ -749,7 +730,7 @@ public function testIsLocal(string $path, bool $isLocal) $this->assertSame($isLocal, Path::isLocal($path)); } - public function provideGetLongestCommonBasePathTests(): \Generator + public static function provideGetLongestCommonBasePathTests(): \Generator { // same paths yield [['/base/path', '/base/path'], '/base/path']; @@ -869,7 +850,7 @@ public function testGetLongestCommonBasePath(array $paths, ?string $basePath) $this->assertSame($basePath, Path::getLongestCommonBasePath(...$paths)); } - public function provideIsBasePathTests(): \Generator + public static function provideIsBasePathTests(): \Generator { // same paths yield ['/base/path', '/base/path', true]; @@ -958,7 +939,7 @@ public function testIsBasePath(string $path, string $ofPath, bool $result) $this->assertSame($result, Path::isBasePath($path, $ofPath)); } - public function provideJoinTests(): \Generator + public static function provideJoinTests(): \Generator { yield [['', ''], '']; yield [['/path/to/test', ''], '/path/to/test']; diff --git a/src/Symfony/Component/Finder/Comparator/NumberComparator.php b/src/Symfony/Component/Finder/Comparator/NumberComparator.php index ff85d9677b1a9..dd3082077a891 100644 --- a/src/Symfony/Component/Finder/Comparator/NumberComparator.php +++ b/src/Symfony/Component/Finder/Comparator/NumberComparator.php @@ -35,7 +35,7 @@ class NumberComparator extends Comparator { /** - * @param string|int $test A comparison string or an integer + * @param string|null $test A comparison string or null * * @throws \InvalidArgumentException If the test is not understood */ diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index d9e182c17af99..39797c82cab28 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -17,6 +17,7 @@ * @author Fabien Potencier * * @extends \FilterIterator + * * @implements \RecursiveIterator */ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator diff --git a/src/Symfony/Component/Finder/LICENSE b/src/Symfony/Component/Finder/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Finder/LICENSE +++ b/src/Symfony/Component/Finder/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php index a04cc62f34585..aee5925142be6 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php @@ -65,7 +65,7 @@ public function testTestSucceeds(string $operator, string $target, string $teste $this->assertTrue($c->test($testedValue)); } - public function provideMatches(): array + public static function provideMatches(): array { return [ ['<', '1000', '500'], @@ -91,7 +91,7 @@ public function testTestFails(string $operator, string $target, string $testedVa $this->assertFalse($c->test($testedValue)); } - public function provideNonMatches(): array + public static function provideNonMatches(): array { return [ ['>', '1000', '500'], diff --git a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php index f89a1a283d8e0..47bcc4838bd26 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php @@ -49,7 +49,7 @@ public function testTest($test, $match, $noMatch) } } - public function getTestData() + public static function getTestData() { return [ ['< 2005-10-10', [strtotime('2005-10-09')], [strtotime('2005-10-15')]], diff --git a/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php index 6458133ebd80d..60c5f1c6cd355 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php @@ -51,7 +51,7 @@ public function testTest($test, $match, $noMatch) } } - public function getTestData() + public static function getTestData() { return [ ['< 1000', ['500', '999'], ['1000', '1500']], @@ -81,7 +81,7 @@ public function getTestData() ]; } - public function getConstructorTestData() + public static function getConstructorTestData() { return [ [ diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 7a79c5e89274f..183a09cff190a 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -1274,7 +1274,7 @@ public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartF $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); } - public function getContainsTestData() + public static function getContainsTestData() { return [ ['', '', []], @@ -1292,7 +1292,7 @@ public function getContainsTestData() ]; } - public function getRegexNameTestData() + public static function getRegexNameTestData() { return [ ['~.*t\\.p.+~i'], @@ -1313,7 +1313,7 @@ public function testPath($matchPatterns, $noMatchPatterns, array $expected) $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); } - public function getTestPathData() + public static function getTestPathData() { return [ ['', '', []], diff --git a/src/Symfony/Component/Finder/Tests/GitignoreTest.php b/src/Symfony/Component/Finder/Tests/GitignoreTest.php index 65b52057937b9..574e9f32d294a 100644 --- a/src/Symfony/Component/Finder/Tests/GitignoreTest.php +++ b/src/Symfony/Component/Finder/Tests/GitignoreTest.php @@ -392,7 +392,7 @@ public static function provider(): array return $cases; } - public function providerExtended(): array + public static function providerExtended(): array { $basicCases = self::provider(); @@ -479,7 +479,7 @@ public function testToRegexMatchingNegatedPatterns(array $gitignoreLines, array } } - public function provideNegatedPatternsCases(): iterable + public static function provideNegatedPatternsCases(): iterable { yield [ [''], diff --git a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php index 7c3c65ce5ee81..3b1f662e2fe05 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php @@ -33,7 +33,7 @@ public function testAccept($filters, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { return [ [[function (\SplFileInfo $fileinfo) { return false; }], []], diff --git a/src/Symfony/Component/Finder/Tests/Iterator/DateRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/DateRangeFilterIteratorTest.php index 2d8cfb30bd90f..b02d8f4f0d2b2 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/DateRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/DateRangeFilterIteratorTest.php @@ -22,7 +22,7 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase public function testAccept($size, $expected) { $files = self::$files; - $files[] = self::toAbsolute('doesnotexist'); + $files[] = static::toAbsolute('doesnotexist'); $inner = new Iterator($files); $iterator = new DateRangeFilterIterator($inner, $size); @@ -30,7 +30,7 @@ public function testAccept($size, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $since20YearsAgo = [ '.git', @@ -84,9 +84,9 @@ public function getAcceptData() ]; return [ - [[new DateComparator('since 20 years ago')], $this->toAbsolute($since20YearsAgo)], - [[new DateComparator('since 2 months ago')], $this->toAbsolute($since2MonthsAgo)], - [[new DateComparator('until last month')], $this->toAbsolute($untilLastMonth)], + [[new DateComparator('since 20 years ago')], static::toAbsolute($since20YearsAgo)], + [[new DateComparator('since 2 months ago')], static::toAbsolute($since2MonthsAgo)], + [[new DateComparator('until last month')], static::toAbsolute($untilLastMonth)], ]; } } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php index a66e50287e74f..c90df8ec53205 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -30,7 +30,7 @@ public function testAccept($minDepth, $maxDepth, $expected) $this->assertEquals($expected, $actual); } - public function getAcceptData() + public static function getAcceptData() { $lessThan1 = [ '.git', @@ -93,11 +93,11 @@ public function getAcceptData() ]; return [ - [0, 0, static::toAbsolute($lessThan1)], - [0, 1, static::toAbsolute($lessThanOrEqualTo1)], + [0, 0, self::toAbsolute($lessThan1)], + [0, 1, self::toAbsolute($lessThanOrEqualTo1)], [2, \PHP_INT_MAX, []], - [1, \PHP_INT_MAX, static::toAbsolute($graterThanOrEqualTo1)], - [1, 1, static::toAbsolute($equalTo1)], + [1, \PHP_INT_MAX, self::toAbsolute($graterThanOrEqualTo1)], + [1, 1, self::toAbsolute($equalTo1)], ]; } } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php index 572029a17f8fa..9b5ed98ad5a72 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php @@ -28,7 +28,7 @@ public function testAccept($directories, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $foo = [ '.bar', @@ -99,9 +99,9 @@ public function getAcceptData() ]; return [ - [['foo'], static::toAbsolute($foo)], - [['fo'], static::toAbsolute($fo)], - [['toto/'], static::toAbsolute($toto)], + [['foo'], self::toAbsolute($foo)], + [['fo'], self::toAbsolute($fo)], + [['toto/'], self::toAbsolute($toto)], ]; } } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php index be7beb1d146ad..3ed1cc062f5d1 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php @@ -27,7 +27,7 @@ public function testAccept($mode, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $onlyFiles = [ 'test.py', @@ -57,8 +57,8 @@ public function getAcceptData() ]; return [ - [FileTypeFilterIterator::ONLY_FILES, static::toAbsolute($onlyFiles)], - [FileTypeFilterIterator::ONLY_DIRECTORIES, static::toAbsolute($onlyDirectories)], + [FileTypeFilterIterator::ONLY_FILES, self::toAbsolute($onlyFiles)], + [FileTypeFilterIterator::ONLY_DIRECTORIES, self::toAbsolute($onlyDirectories)], ]; } } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php index f4f70c8e8c738..34ba50ddcf0d0 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php @@ -45,7 +45,7 @@ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatc $this->assertIterator($resultArray, $iterator); } - public function getTestFilterData() + public static function getTestFilterData() { $inner = new MockFileListIterator(); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilenameFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilenameFilterIteratorTest.php index a12072c62720a..db4eb2b947198 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilenameFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilenameFilterIteratorTest.php @@ -27,7 +27,7 @@ public function testAccept($matchPatterns, $noMatchPatterns, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { return [ [['test.*'], [], ['test.php', 'test.py']], diff --git a/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php index e1bd835b4cdb8..e6abf94404543 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php @@ -25,7 +25,7 @@ public function testIsRegex($string, $isRegex, $message) $this->assertEquals($isRegex, $testIterator->isRegex($string), $message); } - public function getIsRegexFixtures() + public static function getIsRegexFixtures() { yield ['foo', false, 'string']; yield [' foo ', false, '" " is not a valid delimiter']; diff --git a/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php index e2c1325276d95..5c0663e530183 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php @@ -24,7 +24,7 @@ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatc $this->assertIterator($resultArray, $iterator); } - public function getTestFilterData() + public static function getTestFilterData() { $inner = new MockFileListIterator(); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php index 25a6b8a2d75a2..e5f3b6a1ddebb 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php @@ -28,7 +28,7 @@ public function testAccept($size, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $lessThan1KGreaterThan05K = [ '.foo', diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index 049961452b183..a4f13feef69a8 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -68,7 +68,7 @@ public function testAccept($mode, $expected) } } - public function getAcceptData() + public static function getAcceptData() { $sortByName = [ '.bar', @@ -247,13 +247,13 @@ public function getAcceptData() ]; return [ - [SortableIterator::SORT_BY_NAME, static::toAbsolute($sortByName)], - [SortableIterator::SORT_BY_TYPE, static::toAbsolute($sortByType)], - [SortableIterator::SORT_BY_ACCESSED_TIME, static::toAbsolute($sortByAccessedTime)], - [SortableIterator::SORT_BY_CHANGED_TIME, static::toAbsolute($sortByChangedTime)], - [SortableIterator::SORT_BY_MODIFIED_TIME, static::toAbsolute($sortByModifiedTime)], - [SortableIterator::SORT_BY_NAME_NATURAL, static::toAbsolute($sortByNameNatural)], - [function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, static::toAbsolute($customComparison)], + [SortableIterator::SORT_BY_NAME, self::toAbsolute($sortByName)], + [SortableIterator::SORT_BY_TYPE, self::toAbsolute($sortByType)], + [SortableIterator::SORT_BY_ACCESSED_TIME, self::toAbsolute($sortByAccessedTime)], + [SortableIterator::SORT_BY_CHANGED_TIME, self::toAbsolute($sortByChangedTime)], + [SortableIterator::SORT_BY_MODIFIED_TIME, self::toAbsolute($sortByModifiedTime)], + [SortableIterator::SORT_BY_NAME_NATURAL, self::toAbsolute($sortByNameNatural)], + [function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, self::toAbsolute($customComparison)], ]; } } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/VcsIgnoredFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/VcsIgnoredFilterIteratorTest.php index 14cb3c4443ff4..61da148dc9c40 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/VcsIgnoredFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/VcsIgnoredFilterIteratorTest.php @@ -59,7 +59,7 @@ public function testAccept(array $gitIgnoreFiles, array $otherFileNames, array $ $this->assertIterator($this->toAbsolute($expectedResult), $iterator); } - public function getAcceptData(): iterable + public static function getAcceptData(): iterable { yield 'simple file' => [ [ diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php index 1ba9140626e58..36bc131887805 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php @@ -25,7 +25,7 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo * Constructs a transformer. * * @param bool $grouping Whether thousands should be grouped - * @param int $roundingMode One of the ROUND_ constants in this class + * @param int|null $roundingMode One of the ROUND_ constants in this class * @param string|null $locale locale used for transforming */ public function __construct(?bool $grouping = false, ?int $roundingMode = \NumberFormatter::ROUND_DOWN, string $locale = null) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php b/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php index 2f6ac6cc2a86c..f9c8b35c68506 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php @@ -47,6 +47,10 @@ public function buildView(FormView $view, FormInterface $form, array $options) { if ($options['html5']) { $view->vars['type'] = 'number'; + + if (!isset($view->vars['attr']['step'])) { + $view->vars['attr']['step'] = 'any'; + } } } diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 24470bad52b32..57930aa31b8b0 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -45,8 +45,8 @@ public function guessRequired(string $class, string $property) { return $this->guess($class, $property, function (Constraint $constraint) { return $this->guessRequiredForConstraint($constraint); - // If we don't find any constraint telling otherwise, we can assume - // that a field is not required (with LOW_CONFIDENCE) + // If we don't find any constraint telling otherwise, we can assume + // that a field is not required (with LOW_CONFIDENCE) }, false); } diff --git a/src/Symfony/Component/Form/FormInterface.php b/src/Symfony/Component/Form/FormInterface.php index 6cc6b4ed7a544..016d2ccfb1f74 100644 --- a/src/Symfony/Component/Form/FormInterface.php +++ b/src/Symfony/Component/Form/FormInterface.php @@ -211,9 +211,9 @@ public function addError(FormError $error); /** * Returns whether the form and all children are valid. * - * @throws Exception\LogicException if the form is not submitted - * * @return bool + * + * @throws Exception\LogicException if the form is not submitted */ public function isValid(); diff --git a/src/Symfony/Component/Form/LICENSE b/src/Symfony/Component/Form/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Form/LICENSE +++ b/src/Symfony/Component/Form/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTestCase.php similarity index 99% rename from src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php rename to src/Symfony/Component/Form/Tests/AbstractDivLayoutTestCase.php index 6a38a77017dba..db6054ad85fce 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTestCase.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Security\Csrf\CsrfToken; -abstract class AbstractDivLayoutTest extends AbstractLayoutTest +abstract class AbstractDivLayoutTestCase extends AbstractLayoutTestCase { public function testRow() { diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTestCase.php similarity index 99% rename from src/Symfony/Component/Form/Tests/AbstractLayoutTest.php rename to src/Symfony/Component/Form/Tests/AbstractLayoutTestCase.php index be8a8ccb9bd45..aa55bc74314d8 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTestCase.php @@ -21,7 +21,7 @@ use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Translation\TranslatableMessage; -abstract class AbstractLayoutTest extends FormIntegrationTestCase +abstract class AbstractLayoutTestCase extends FormIntegrationTestCase { use VersionAwareTest; @@ -1877,6 +1877,26 @@ public function testRenderNumberWithHtml5NumberType() $this->assertWidgetMatchesXpath($form->createView(), [], '/input [@type="number"] + [@step="any"] + [@name="name"] + [@value="1234.56"] +' + ); + } + + public function testRenderNumberWithHtml5NumberTypeAndStepAttribute() + { + $this->requiresFeatureSet(403); + + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [ + 'html5' => true, + 'attr' => ['step' => '0.1'], + ]); + + $this->assertWidgetMatchesXpath($form->createView(), [], + '/input + [@type="number"] + [@step="0.1"] [@name="name"] [@value="1234.56"] ' @@ -2770,7 +2790,7 @@ public function testSubmitFormNoValidate(bool $validate) $this->assertMatchesXpath($html, $xpath); } - public function submitFormNoValidateProvider() + public static function submitFormNoValidateProvider() { return [ [false], diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php similarity index 98% rename from src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php rename to src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php index 1d33451d45293..becf3504c3183 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTestCase.php @@ -27,7 +27,7 @@ /** * @author Bernhard Schussek */ -abstract class AbstractRequestHandlerTest extends TestCase +abstract class AbstractRequestHandlerTestCase extends TestCase { /** * @var RequestHandlerInterface @@ -75,7 +75,7 @@ public static function methodExceptGetProvider() ]; } - public function methodProvider() + public static function methodProvider() { return array_merge([ ['GET'], @@ -348,7 +348,7 @@ public function testAddFormErrorIfPostMaxSizeExceeded(?int $contentLength, strin } } - public function getPostMaxSizeFixtures() + public static function getPostMaxSizeFixtures() { return [ [1024 ** 3 + 1, '1G', true, ['{{ max }}' => '1G']], @@ -381,7 +381,7 @@ public function testFailedFileUploadIsTurnedIntoFormError($errorCode, $expectedE $this->assertSame($expectedErrorCode, $this->requestHandler->getUploadFileError($this->getFailedUploadedFile($errorCode))); } - public function uploadFileErrorCodes() + public static function uploadFileErrorCodes() { return [ 'no error' => [\UPLOAD_ERR_OK, null], diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTestCase.php similarity index 99% rename from src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php rename to src/Symfony/Component/Form/Tests/AbstractTableLayoutTestCase.php index 5ce77a7f8aec4..09d669129fce9 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTestCase.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Security\Csrf\CsrfToken; -abstract class AbstractTableLayoutTest extends AbstractLayoutTest +abstract class AbstractTableLayoutTestCase extends AbstractLayoutTestCase { public function testRow() { diff --git a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php index c6f58a50a1840..71668dd028493 100644 --- a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php @@ -20,7 +20,7 @@ */ class ButtonBuilderTest extends TestCase { - public function getValidNames() + public static function getValidNames() { return [ ['reset'], @@ -47,7 +47,7 @@ public function testNameContainingIllegalCharacters() $this->assertInstanceOf(ButtonBuilder::class, new ButtonBuilder('button[]')); } - public function getInvalidNames() + public static function getInvalidNames() { return [ [''], diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php index 0113acab24939..9431328e2f797 100644 --- a/src/Symfony/Component/Form/Tests/ButtonTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonTest.php @@ -57,7 +57,7 @@ public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $this->assertSame($result, $button->isDisabled()); } - public function getDisabledStates() + public static function getDisabledStates() { return [ // parent, button, result diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTestCase.php similarity index 98% rename from src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php rename to src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTestCase.php index d2aac23e3afaf..dd55bfcff0555 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTestCase.php @@ -17,7 +17,7 @@ /** * @author Bernhard Schussek */ -abstract class AbstractChoiceListTest extends TestCase +abstract class AbstractChoiceListTestCase extends TestCase { /** * @var ChoiceListInterface diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index ce5f2e933f00d..a156ca5b41147 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -17,7 +17,7 @@ /** * @author Bernhard Schussek */ -class ArrayChoiceListTest extends AbstractChoiceListTest +class ArrayChoiceListTest extends AbstractChoiceListTestCase { private $object; diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index 4f5c4eb0e342f..893af48593ebf 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -555,7 +555,7 @@ public function testCreateViewDifferentAttributesClosure() $this->assertEquals(new ChoiceListView(), $view2); } - public function provideSameChoices() + public static function provideSameChoices() { $object = (object) ['foo' => 'bar']; @@ -568,7 +568,7 @@ public function provideSameChoices() ]; } - public function provideDistinguishedChoices() + public static function provideDistinguishedChoices() { return [ [0, false], diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index 73750380385f8..b9b2ef03aca55 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -206,7 +206,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index f45c2617389b1..b23dab0c48801 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -574,7 +574,7 @@ public function testSubmitMapsSubmittedChildrenOntoEmptyData() $this->assertSame('Bernhard', $object['name']); } - public function requestMethodProvider() + public static function requestMethodProvider() { return [ ['POST'], diff --git a/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTestCase.php similarity index 96% rename from src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php rename to src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTestCase.php index bc870494e6461..f11cb8c5056a8 100644 --- a/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTestCase.php @@ -26,7 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Csrf\CsrfTokenManager; -abstract class AbstractDescriptorTest extends TestCase +abstract class AbstractDescriptorTestCase extends TestCase { private $colSize; @@ -80,7 +80,7 @@ public function testDescribeOption(OptionsResolver $optionsResolver, array $opti } } - public function getDescribeDefaultsTestData() + public static function getDescribeDefaultsTestData() { $options['core_types'] = ['Symfony\Component\Form\Extension\Core\Type\FormType']; $options['service_types'] = ['Symfony\Bridge\Doctrine\Form\Type\EntityType']; @@ -96,7 +96,7 @@ public function getDescribeDefaultsTestData() yield [null, $options, 'types_with_deprecated_options']; } - public function getDescribeResolvedFormTypeTestData() + public static function getDescribeResolvedFormTypeTestData() { $typeExtensions = [new FormTypeCsrfExtension(new CsrfTokenManager())]; $parent = new ResolvedFormType(new FormType(), $typeExtensions); @@ -106,7 +106,7 @@ public function getDescribeResolvedFormTypeTestData() yield [new ResolvedFormType(new FooType(), [], $parent), ['decorated' => false, 'show_deprecated' => true], 'deprecated_options_of_type']; } - public function getDescribeOptionTestData() + public static function getDescribeOptionTestData() { $parent = new ResolvedFormType(new FormType()); $options['decorated'] = false; diff --git a/src/Symfony/Component/Form/Tests/Console/Descriptor/JsonDescriptorTest.php b/src/Symfony/Component/Form/Tests/Console/Descriptor/JsonDescriptorTest.php index c035be6bcd9cf..4545ee2b01659 100644 --- a/src/Symfony/Component/Form/Tests/Console/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Component/Form/Tests/Console/Descriptor/JsonDescriptorTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Form\Console\Descriptor\JsonDescriptor; -class JsonDescriptorTest extends AbstractDescriptorTest +class JsonDescriptorTest extends AbstractDescriptorTestCase { protected function getDescriptor() { diff --git a/src/Symfony/Component/Form/Tests/Console/Descriptor/TextDescriptorTest.php b/src/Symfony/Component/Form/Tests/Console/Descriptor/TextDescriptorTest.php index c970eba96e62f..575783c74ace4 100644 --- a/src/Symfony/Component/Form/Tests/Console/Descriptor/TextDescriptorTest.php +++ b/src/Symfony/Component/Form/Tests/Console/Descriptor/TextDescriptorTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Form\Console\Descriptor\TextDescriptor; -class TextDescriptorTest extends AbstractDescriptorTest +class TextDescriptorTest extends AbstractDescriptorTestCase { protected function getDescriptor() { diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php index 6c73abe370d7e..c2beee8747127 100644 --- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php +++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php @@ -118,7 +118,7 @@ public function testAddTaggedTypeExtensions(array $extensions, array $expectedRe $this->assertEquals($expectedRegisteredExtensions, $extDefinition->getArgument(1)); } - public function addTaggedTypeExtensionsDataProvider() + public static function addTaggedTypeExtensionsDataProvider() { return [ [ @@ -275,7 +275,7 @@ public function testPrivateTaggedServices($id, $class, $tagName, callable $asser $assertion($container); } - public function privateTaggedServicesProvider() + public static function privateTaggedServicesProvider() { return [ [ diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php index 0a9a73ca5ba81..c119d665b85f1 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php @@ -351,7 +351,7 @@ public function testMapFormsToDataDoesNotChangeEqualDateTimeInstance($date) self::assertSame($publishedAtValue, $article['publishedAt']); } - public function provideDate(): array + public static function provideDate(): array { return [ [new \DateTime()], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php index 5db2a674821e5..3b2ce0015bbd3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php @@ -360,7 +360,7 @@ public function testMapFormsToDataDoesNotChangeEqualDateTimeInstance($date) $this->assertSame($publishedAtValue, $article['publishedAt']); } - public function provideDate() + public static function provideDate() { return [ [new \DateTime()], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTestCase.php similarity index 95% rename from src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php rename to src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTestCase.php index e3f101a8aac96..7e86f2c069118 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTestCase.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; -abstract class BaseDateTimeTransformerTest extends TestCase +abstract class BaseDateTimeTransformerTestCase extends TestCase { public function testConstructFailsIfInputTimezoneIsInvalid() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php index 7711fcb7f0592..5253058527516 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php @@ -36,7 +36,7 @@ protected function tearDown(): void $this->transformerWithNull = null; } - public function transformProvider() + public static function transformProvider() { return [ // more extensive test set can be found in FormUtilTest @@ -56,7 +56,7 @@ public function testTransform($in, $out, $inWithNull, $outWithNull) $this->assertSame($outWithNull, $this->transformerWithNull->transform($inWithNull)); } - public function reverseTransformProvider() + public static function reverseTransformProvider() { return [ // values are expected to be valid choice keys already and stay @@ -77,7 +77,7 @@ public function testReverseTransform($in, $out, $inWithNull, $outWithNull) $this->assertSame($outWithNull, $this->transformerWithNull->reverseTransform($inWithNull)); } - public function reverseTransformExpectsStringOrNullProvider() + public static function reverseTransformExpectsStringOrNullProvider() { return [ [0], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateIntervalToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateIntervalToStringTransformerTest.php index f3127349cb580..81e1885aa57fb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateIntervalToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateIntervalToStringTransformerTest.php @@ -20,7 +20,7 @@ */ class DateIntervalToStringTransformerTest extends DateIntervalTestCase { - public function dataProviderISO() + public static function dataProviderISO() { $data = [ ['P%YY%MM%DDT%HH%IM%SS', 'P00Y00M00DT00H00M00S', 'PT0S'], @@ -34,7 +34,7 @@ public function dataProviderISO() return $data; } - public function dataProviderDate() + public static function dataProviderDate() { $data = [ [ diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php index 7aa18d924e5d9..800120ae98daa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php @@ -30,7 +30,7 @@ public function testTransform(\DateTime $expectedOutput, \DateTimeImmutable $inp $this->assertEquals($expectedOutput->getTimezone(), $actualOutput->getTimezone()); } - public function provider() + public static function provider() { return [ [ diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php index 3aafbec88a4ec..08e05c58405f2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; -class DateTimeToArrayTransformerTest extends BaseDateTimeTransformerTest +class DateTimeToArrayTransformerTest extends BaseDateTimeTransformerTestCase { public function testTransform() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php index 6e6e66afb1861..8dffb13e2f927 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php @@ -16,11 +16,11 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer; use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait; -class DateTimeToHtml5LocalDateTimeTransformerTest extends BaseDateTimeTransformerTest +class DateTimeToHtml5LocalDateTimeTransformerTest extends BaseDateTimeTransformerTestCase { use DateTimeEqualsTrait; - public function transformProvider() + public static function transformProvider() { return [ ['UTC', 'UTC', '2010-02-03 04:05:06 UTC', '2010-02-03T04:05:06'], @@ -32,7 +32,7 @@ public function transformProvider() ]; } - public function reverseTransformProvider() + public static function reverseTransformProvider() { return [ // format without seconds, as appears in some browsers diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index 2212bcf99ef7e..098deb7065608 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait; use Symfony\Component\Intl\Util\IntlTestHelper; -class DateTimeToLocalizedStringTransformerTest extends BaseDateTimeTransformerTest +class DateTimeToLocalizedStringTransformerTest extends BaseDateTimeTransformerTestCase { use DateTimeEqualsTrait; @@ -52,7 +52,7 @@ protected function tearDown(): void \Locale::setDefault($this->defaultLocale); } - public function dataProvider() + public static function dataProvider() { return [ [\IntlDateFormatter::SHORT, null, null, '03.02.10, 04:05', '2010-02-03 04:05:00 UTC'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php index 0412dc321a0f6..18005e0ed5559 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait; -class DateTimeToRfc3339TransformerTest extends BaseDateTimeTransformerTest +class DateTimeToRfc3339TransformerTest extends BaseDateTimeTransformerTestCase { use DateTimeEqualsTrait; @@ -49,12 +49,12 @@ public static function allProvider() ]; } - public function transformProvider() + public static function transformProvider() { return self::allProvider(); } - public function reverseTransformProvider() + public static function reverseTransformProvider() { return array_merge(self::allProvider(), [ // format without seconds, as appears in some browsers @@ -132,7 +132,7 @@ public function testReverseTransformExpectsValidDateString($date) $transformer->reverseTransform($date); } - public function invalidDateStringProvider() + public static function invalidDateStringProvider() { return [ 'invalid month' => ['2010-2010-01'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index 4bdfff1ed053b..56ff98117aee9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -15,9 +15,9 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; -class DateTimeToStringTransformerTest extends BaseDateTimeTransformerTest +class DateTimeToStringTransformerTest extends BaseDateTimeTransformerTestCase { - public function dataProvider(): array + public static function dataProvider(): array { return [ ['Y-m-d H:i:s', '2010-02-03 16:05:06', '2010-02-03 16:05:06 UTC'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php index 7a84153a73834..bf662d6464bef 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; -class DateTimeToTimestampTransformerTest extends BaseDateTimeTransformerTest +class DateTimeToTimestampTransformerTest extends BaseDateTimeTransformerTestCase { public function testTransform() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index fc8cce0cc242d..837717670a8cd 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -31,7 +31,7 @@ protected function tearDown(): void \Locale::setDefault($this->defaultLocale); } - public function transformWithRoundingProvider() + public static function transformWithRoundingProvider() { return [ // towards positive infinity (1.6 -> 2, -1.6 -> -1) @@ -127,7 +127,7 @@ public function testReverseTransformWithGrouping() $this->assertEquals(12345, $transformer->reverseTransform('12345')); } - public function reverseTransformWithRoundingProvider() + public static function reverseTransformWithRoundingProvider() { return [ // towards positive infinity (1.6 -> 2, -1.6 -> -1) @@ -219,7 +219,7 @@ public function testReverseTransformExpectsInteger($number, $locale) $transformer->reverseTransform($number); } - public function floatNumberProvider() + public static function floatNumberProvider() { return [ ['12345.912', 'en'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 8de48b745a049..9c2e3bcae3d13 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -31,7 +31,7 @@ protected function tearDown(): void \Locale::setDefault($this->defaultLocale); } - public function provideTransformations() + public static function provideTransformations() { return [ [null, '', 'de_AT'], @@ -59,7 +59,7 @@ public function testTransform($from, $to, $locale) $this->assertSame($to, $transformer->transform($from)); } - public function provideTransformationsWithGrouping() + public static function provideTransformationsWithGrouping() { return [ [1234.5, '1.234,5', 'de_DE'], @@ -98,7 +98,7 @@ public function testTransformWithScale() $this->assertEquals('678,92', $transformer->transform(678.916)); } - public function transformWithRoundingProvider() + public static function transformWithRoundingProvider() { return [ // towards positive infinity (1.6 -> 2, -1.6 -> -1) @@ -273,7 +273,7 @@ public function testReverseTransformWithGroupingButWithoutGroupSeparator() $this->assertEquals(12345.912, $transformer->reverseTransform('12345,912')); } - public function reverseTransformWithRoundingProvider() + public static function reverseTransformWithRoundingProvider() { return [ // towards positive infinity (1.6 -> 2, -1.6 -> -1) @@ -518,7 +518,7 @@ public function testReverseTransformDisallowsNaN($nan) $transformer->reverseTransform($nan); } - public function nanRepresentationProvider() + public static function nanRepresentationProvider() { return [ ['nan'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php index c9d89e8e27a2e..34fbd9571cfce 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -95,7 +95,7 @@ public function testReverseTransform() $this->assertEquals(2, $transformer->reverseTransform('200')); } - public function reverseTransformWithRoundingProvider() + public static function reverseTransformWithRoundingProvider() { return [ // towards positive infinity (1.6 -> 2, -1.6 -> -1) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php index 29b70c9bec4d8..0ffb0b0ea8941 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php @@ -17,7 +17,7 @@ class StringToFloatTransformerTest extends TestCase { - public function provideTransformations(): array + public static function provideTransformations(): array { return [ [null, null], @@ -52,7 +52,7 @@ public function testFailIfTransformingANonNumericString() $transformer->transform('foobar'); } - public function provideReverseTransformations(): array + public static function provideReverseTransformations(): array { return [ [null, null], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/UlidToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/UlidToStringTransformerTest.php index 87a1592e25fc1..7978941b5d026 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/UlidToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/UlidToStringTransformerTest.php @@ -18,7 +18,7 @@ class UlidToStringTransformerTest extends TestCase { - public function provideValidUlid() + public static function provideValidUlid() { return [ ['01D85PP1982GF6KTVFHQ7W78FB', new Ulid('01d85pp1982gf6ktvfhq7w78fb')], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php index 5c855bb868b1a..67e7f7a360f45 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php @@ -43,7 +43,7 @@ public function testTransformationFailures($input, string $message) $transformer->transform($input); } - public function transformationFailuresProvider(): array + public static function transformationFailuresProvider(): array { return [ 'malformed string' => ['lorem', 'Given data does not follow the date format "Y-\WW".'], @@ -101,7 +101,7 @@ public function testReverseTransformFailures($input, string $message) $transformer->reverseTransform($input); } - public function reverseTransformationFailuresProvider(): array + public static function reverseTransformationFailuresProvider(): array { return [ 'missing year' => [['week' => 1], 'Key "year" is missing.'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php index 87f79439f94c7..038ca9c2ea3ab 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php @@ -34,7 +34,7 @@ public function testFixUrl($data) $this->assertSame('http://'.$data, $event->getData()); } - public function provideUrlToFix() + public static function provideUrlToFix() { return [ ['www.symfony.com'], @@ -60,7 +60,7 @@ public function testSkipUrl($url) $this->assertSame($url, $event->getData()); } - public function provideUrlToSkip() + public static function provideUrlToSkip() { return [ ['http://www.symfony.com'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php index 5de0ea607a7d6..47db5a0acddce 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormFactoryBuilder; -class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTest +class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTestCase { protected function getData(array $data) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php index 4f19a3ff8e777..df382a0b50f81 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormFactoryBuilder; -class MergeCollectionListenerArrayTest extends MergeCollectionListenerTest +class MergeCollectionListenerArrayTest extends MergeCollectionListenerTestCase { protected function getData(array $data) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php index 4be3b4babae98..a13a6c071a956 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\FormFactoryBuilder; use Symfony\Component\Form\Tests\Fixtures\CustomArrayObject; -class MergeCollectionListenerCustomArrayObjectTest extends MergeCollectionListenerTest +class MergeCollectionListenerCustomArrayObjectTest extends MergeCollectionListenerTestCase { protected function getData(array $data) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTestCase.php similarity index 97% rename from src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php rename to src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTestCase.php index 0be62fa1532f1..039108f4eb7bc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTestCase.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener; use Symfony\Component\Form\FormEvent; -abstract class MergeCollectionListenerTest extends TestCase +abstract class MergeCollectionListenerTestCase extends TestCase { protected $form; @@ -39,7 +39,7 @@ protected function getForm($name = 'name', $propertyPath = null) return $this->getBuilder($name)->setAttribute('property_path', $propertyPath)->getForm(); } - public function getBooleanMatrix1() + public static function getBooleanMatrix1() { return [ [true], @@ -47,7 +47,7 @@ public function getBooleanMatrix1() ]; } - public function getBooleanMatrix2() + public static function getBooleanMatrix2() { return [ [true, true], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTestCase.php similarity index 99% rename from src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php rename to src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTestCase.php index 3303e6a5c78ce..e86bf9e41ed13 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTestCase.php @@ -17,7 +17,7 @@ /** * @author Bernhard Schussek */ -abstract class BaseTypeTest extends TypeTestCase +abstract class BaseTypeTestCase extends TypeTestCase { use VersionAwareTest; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php index dcff028026482..0125631c582c6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php @@ -19,7 +19,7 @@ /** * @author Bernhard Schussek */ -class ButtonTypeTest extends BaseTypeTest +class ButtonTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\ButtonType'; @@ -72,7 +72,7 @@ public function testFormAttrOnChild() public function testFormAttrAsBoolWithNoId() { $this->expectException(LogicException::class); - $this->expectErrorMessage('form_attr'); + $this->expectExceptionMessage('form_attr'); $this->factory ->createNamedBuilder('', FormType::class, null, [ 'form_attr' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php index 93ca921b7c650..2cb20e1cbb6c5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -class CheckboxTypeTest extends BaseTypeTest +class CheckboxTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CheckboxType'; @@ -166,7 +166,7 @@ function ($value) { $this->assertEquals($checked, $view->vars['checked']); } - public function provideCustomModelTransformerData() + public static function provideCustomModelTransformerData() { return [ ['checked', true], @@ -186,7 +186,7 @@ public function testCustomFalseValues($falseValue) $this->assertFalse($form->getData()); } - public function provideCustomFalseValues() + public static function provideCustomFalseValues() { return [ [''], 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 207d52d14db5f..ccb6b78222ecf 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -21,7 +21,7 @@ use Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -class ChoiceTypeTest extends BaseTypeTest +class ChoiceTypeTest extends BaseTypeTestCase { use ExpectDeprecationTrait; @@ -1707,7 +1707,7 @@ public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded $this->assertTrue($view->vars['placeholder_in_choices']); } - public function getOptionsWithPlaceholder() + public static function getOptionsWithPlaceholder() { return [ // single non-expanded @@ -1963,7 +1963,7 @@ public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionDa } } - public function invalidNestedValueTestMatrix() + public static function invalidNestedValueTestMatrix() { return [ 'non-multiple, non-expanded' => [false, false, [[]]], @@ -2158,7 +2158,7 @@ public function testSubmitValueWithWhiteSpace($multiple, $expanded) $this->assertSame($multiple ? (array) $valueWhitWhiteSpace : $valueWhitWhiteSpace, $form->getData()); } - public function provideTrimCases() + public static function provideTrimCases() { return [ 'Simple' => [false, false], @@ -2193,7 +2193,7 @@ public function testExpandedIsEmptyWhenNoRealChoiceIsSelected($expected, $submit $this->assertSame($expected, $form->isEmpty()); } - public function expandedIsEmptyWhenNoRealChoiceIsSelectedProvider() + public static function expandedIsEmptyWhenNoRealChoiceIsSelectedProvider() { // Some invalid cases are voluntarily not tested: // - multiple with placeholder diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index b7e68ba0d08d8..eea9b60551516 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\Tests\Fixtures\AuthorType; use Symfony\Component\Form\Tests\Fixtures\BlockPrefixedFooTextType; -class CollectionTypeTest extends BaseTypeTest +class CollectionTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CollectionType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ColorTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ColorTypeTest.php index cfe7f0c527ce3..dbbc1579ff521 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ColorTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ColorTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\Extension\Core\Type\ColorType; use Symfony\Component\Form\FormError; -final class ColorTypeTest extends BaseTypeTest +final class ColorTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = ColorType::class; @@ -33,7 +33,7 @@ public function testValidationShouldPass(bool $html5, ?string $submittedValue) $this->assertEmpty($form->getErrors()); } - public function validationShouldPassProvider() + public static function validationShouldPassProvider() { return [ [false, 'foo'], @@ -71,7 +71,7 @@ public function testValidationShouldFail(string $expectedValueParameterValue, ?s $this->assertEquals([$expectedFormError], iterator_to_array($form->getErrors())); } - public function validationShouldFailProvider() + public static function validationShouldFailProvider() { return [ ['foo', 'foo'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php index 9572f3418c418..57146e1ecfa28 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Intl\Util\IntlTestHelper; -class CountryTypeTest extends BaseTypeTest +class CountryTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CountryType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php index 8cccfd32bd3db..51aaf6b372af0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Intl\Util\IntlTestHelper; -class CurrencyTypeTest extends BaseTypeTest +class CurrencyTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CurrencyType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php index efbb47bea5014..cabb5ea5f5f35 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormInterface; -class DateIntervalTypeTest extends BaseTypeTest +class DateIntervalTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = DateIntervalType::class; @@ -440,7 +440,7 @@ public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedDa $this->assertEquals($expectedData, $form->getData()); } - public function provideEmptyData() + public static function provideEmptyData() { $expectedData = new \DateInterval('P6Y4M'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index 71edd6afc7d61..5a35abb453662 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormInterface; -class DateTimeTypeTest extends BaseTypeTest +class DateTimeTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateTimeType'; @@ -706,7 +706,7 @@ public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedDa $this->assertEquals($expectedData, $form->getData()); } - public function provideEmptyData() + public static function provideEmptyData() { $expectedData = \DateTime::createFromFormat('Y-m-d H:i', '2018-11-11 21:23'); $lazyEmptyData = static function (FormInterface $form) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index 74e0a8d35524f..32bf613037992 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -17,7 +17,7 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -class DateTypeTest extends BaseTypeTest +class DateTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateType'; @@ -385,7 +385,7 @@ public function testDatePatternWithFormatOption($format, $pattern) $this->assertEquals($pattern, $view->vars['date_pattern']); } - public function provideDateFormats() + public static function provideDateFormats() { return [ ['dMy', '{{ day }}{{ month }}{{ year }}'], @@ -900,7 +900,7 @@ public function testDontPassHtml5TypeIfNotSingleText() $this->assertArrayNotHasKey('type', $view->vars); } - public function provideCompoundWidgets() + public static function provideCompoundWidgets() { return [ ['text'], @@ -1054,7 +1054,7 @@ public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedDa $this->assertEquals($expectedData, $form->getData()); } - public function provideEmptyData() + public static function provideEmptyData() { $expectedData = \DateTime::createFromFormat('Y-m-d H:i:s', '2018-11-11 00:00:00'); $lazyEmptyData = static function (FormInterface $form) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/EnumTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/EnumTypeTest.php index 083952a3326a3..77c1c62b041a5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/EnumTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/EnumTypeTest.php @@ -12,7 +12,7 @@ namespace Extension\Core\Type; use Symfony\Component\Form\Extension\Core\Type\EnumType; -use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest; +use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTestCase; use Symfony\Component\Form\Tests\Fixtures\Answer; use Symfony\Component\Form\Tests\Fixtures\Number; use Symfony\Component\Form\Tests\Fixtures\Suit; @@ -22,7 +22,7 @@ /** * @requires PHP 8.1 */ -final class EnumTypeTest extends BaseTypeTest +class EnumTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = EnumType::class; @@ -84,7 +84,7 @@ public function testSubmitSingleExpanded(string $class, string $submittedData, \ $this->assertTrue($form->isSynchronized()); } - public function provideSingleSubmitData(): iterable + public static function provideSingleSubmitData(): iterable { yield 'unbacked' => [ Answer::class, @@ -226,7 +226,7 @@ public function testSubmitMultipleExpanded(string $class, array $submittedValues $this->assertTrue($form->isSynchronized()); } - public function provideMultiSubmitData(): iterable + public static function provideMultiSubmitData(): iterable { yield 'unbacked' => [ Answer::class, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php index 4d883908751c8..246864bdfde0d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php @@ -58,7 +58,7 @@ public function testChoiceLoaderIsOverridden($type) $this->assertSame('lazy_b', $choices[1]->value); } - public function provideTestedTypes() + public static function provideTestedTypes() { yield [CountryTypeTest::TESTED_TYPE]; yield [CurrencyTypeTest::TESTED_TYPE]; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php index 5ca5267430681..e39a96c25f5d7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php @@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\Translation\IdentityTranslator; -class FileTypeTest extends BaseTypeTest +class FileTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\FileType'; @@ -183,7 +183,7 @@ public function testSubmitNonArrayValueWhenMultiple(RequestHandlerInterface $req $this->assertSame([], $form->getViewData()); } - public function requestHandlerProvider() + public static function requestHandlerProvider() { return [ [new HttpFoundationRequestHandler()], @@ -301,7 +301,7 @@ public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsin } } - public function uploadFileErrorCodes() + public static function uploadFileErrorCodes() { return [ 'no error' => [\UPLOAD_ERR_OK, null], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 3701b653f855e..1d2ff4ff12003 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -62,7 +62,7 @@ public function setReferenceCopy($reference) } } -class FormTypeTest extends BaseTypeTest +class FormTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\FormType'; @@ -809,7 +809,7 @@ public function testFormAttrOnChild() public function testFormAttrAsBoolWithNoId() { $this->expectException(LogicException::class); - $this->expectErrorMessage('form_attr'); + $this->expectExceptionMessage('form_attr'); $this->factory ->createNamedBuilder('', self::TESTED_TYPE, null, [ 'form_attr' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php index 15cf308d990dd..6d03ebf6cf284 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Intl\Util\IntlTestHelper; -class IntegerTypeTest extends BaseTypeTest +class IntegerTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\IntegerType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php index 4946aca29e7f9..e214e0afd4346 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\Intl\Util\IntlTestHelper; -class LanguageTypeTest extends BaseTypeTest +class LanguageTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\LanguageType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php index 8d3eaea363a58..8486b6656bd6f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Intl\Util\IntlTestHelper; -class LocaleTypeTest extends BaseTypeTest +class LocaleTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\LocaleType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php index 94f47706ab1c6..c65629d946818 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Intl\Util\IntlTestHelper; -class MoneyTypeTest extends BaseTypeTest +class MoneyTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\MoneyType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php index 4aa86db62b15c..d3a5420847ab4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Intl\Util\IntlTestHelper; -class NumberTypeTest extends BaseTypeTest +class NumberTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\NumberType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php index 29756f17b9abc..8d428a26a52b1 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; -class PasswordTypeTest extends BaseTypeTest +class PasswordTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\PasswordType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php index 60d565787699a..b2a295b276f48 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Tests\Fixtures\NotMappedType; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -class RepeatedTypeTest extends BaseTypeTest +class RepeatedTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'; @@ -107,7 +107,7 @@ public function testNotMappedInnerIsOverridden($configurationKey) $this->assertTrue($form['second']->getConfig()->getMapped()); } - public function notMappedConfigurationKeys() + public static function notMappedConfigurationKeys() { return [ ['first_options'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TextTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TextTypeTest.php index 3f8fbe7725ffc..7e565c7c9fcef 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TextTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TextTypeTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; -class TextTypeTest extends BaseTypeTest +class TextTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TextType'; @@ -32,7 +32,7 @@ public function testSubmitNullReturnsNullWithEmptyDataAsString() $this->assertSame('', $form->getViewData()); } - public function provideZeros() + public static function provideZeros() { return [ [0, '0'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index 08284dbbf00e7..9b3bbbfd00ee0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -class TimeTypeTest extends BaseTypeTest +class TimeTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TimeType'; @@ -874,7 +874,7 @@ public function testPassPlaceholderAsPartialArrayAddNullIfRequired() $this->assertSame('Empty second', $view['second']->vars['placeholder']); } - public function provideCompoundWidgets() + public static function provideCompoundWidgets() { return [ ['text'], @@ -1110,7 +1110,7 @@ public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedDa $this->assertEquals($expectedData, $form->getData()); } - public function provideEmptyData() + public static function provideEmptyData() { $expectedData = \DateTime::createFromFormat('Y-m-d H:i', '1970-01-01 21:23'); $lazyEmptyData = static function (FormInterface $form) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php index 669f0d9e5725d..9966b40438aa2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\Intl\Util\IntlTestHelper; -class TimezoneTypeTest extends BaseTypeTest +class TimezoneTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TimezoneType'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UlidTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UlidTypeTest.php index 4f61992cb64a6..5ed324e8239fc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UlidTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UlidTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\Extension\Core\Type\UlidType; use Symfony\Component\Uid\Ulid; -final class UlidTypeTest extends BaseTypeTest +final class UlidTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = UlidType::class; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UuidTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UuidTypeTest.php index 9b9bfb2d2a14e..90043356dab47 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UuidTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UuidTypeTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\Extension\Core\Type\UuidType; use Symfony\Component\Uid\Uuid; -final class UuidTypeTest extends BaseTypeTest +final class UuidTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = UuidType::class; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/WeekTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/WeekTypeTest.php index 7d0dc1958ba92..b093513b75f4c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/WeekTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/WeekTypeTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Form\FormError; -class WeekTypeTest extends BaseTypeTest +class WeekTypeTest extends BaseTypeTestCase { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\WeekType'; @@ -313,7 +313,7 @@ public function testSubmitNullUsesDateEmptyDataString($widget, $emptyData, $expe $this->assertSame($expectedData, $form->getData()); } - public function provideEmptyData() + public static function provideEmptyData() { return [ 'Compound text field' => ['text', ['year' => '2019', 'week' => '1'], ['year' => 2019, 'week' => 1]], 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 b8e2cf7bcacc6..7fcc80fee7de5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -161,7 +161,7 @@ public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName() $this->assertEquals('token', $view['csrf']->vars['value']); } - public function provideBoolean() + public static function provideBoolean() { return [ [true], diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php index 69be3777cca37..4aacf904d5a5c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php @@ -13,14 +13,14 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; -use Symfony\Component\Form\Tests\AbstractRequestHandlerTest; +use Symfony\Component\Form\Tests\AbstractRequestHandlerTestCase; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Request; /** * @author Bernhard Schussek */ -class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest +class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTestCase { public function testRequestShouldNotBeNull() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTestCase.php similarity index 97% rename from src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php rename to src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTestCase.php index 7062ed53d3686..47fc264fc74e9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTestCase.php @@ -18,7 +18,7 @@ /** * @author Bernhard Schussek */ -abstract class BaseValidatorExtensionTest extends TypeTestCase +abstract class BaseValidatorExtensionTestCase extends TypeTestCase { public function testValidationGroupNullByDefault() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BirthdayTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BirthdayTypeValidatorExtensionTest.php index 68c7ad7b7703b..5d4a204376c0d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BirthdayTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BirthdayTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\BirthdayType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class BirthdayTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class BirthdayTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CheckboxTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CheckboxTypeValidatorExtensionTest.php index cdb648a19d1a2..7cbf318cc824a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CheckboxTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CheckboxTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class CheckboxTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class CheckboxTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ChoiceTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ChoiceTypeValidatorExtensionTest.php index d09b292bcc7e6..ee75e73292650 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ChoiceTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ChoiceTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class ChoiceTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class ChoiceTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CollectionTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CollectionTypeValidatorExtensionTest.php index 41c606c87be38..89a573d53b760 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CollectionTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CollectionTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class CollectionTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class CollectionTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ColorTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ColorTypeValidatorExtensionTest.php index 9ba71f1c029cb..64d0480868b95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ColorTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/ColorTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\ColorType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class ColorTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class ColorTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CountryTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CountryTypeValidatorExtensionTest.php index cfcc2a1e31ab4..5b62d95044a9a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CountryTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CountryTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\CountryType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class CountryTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class CountryTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CurrencyTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CurrencyTypeValidatorExtensionTest.php index 67d5763878814..1c7660052a230 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CurrencyTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/CurrencyTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\CurrencyType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class CurrencyTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class CurrencyTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateIntervalTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateIntervalTypeValidatorExtensionTest.php index 8469d2bc5dc92..a0f3580e2d845 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateIntervalTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateIntervalTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\DateIntervalType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class DateIntervalTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class DateIntervalTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTimeTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTimeTypeValidatorExtensionTest.php index a1590d521130a..67312e0a57801 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTimeTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTimeTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\DateTimeType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class DateTimeTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class DateTimeTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTypeValidatorExtensionTest.php index b90be94d45eb0..aa6336ca792a5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/DateTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class DateTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class DateTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/EmailTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/EmailTypeValidatorExtensionTest.php index c478070a67f92..29fdf24965873 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/EmailTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/EmailTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class EmailTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class EmailTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FileTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FileTypeValidatorExtensionTest.php index c905b5d3e753a..5d7130f2993dc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FileTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FileTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class FileTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class FileTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; 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 455d55b2dbee0..87de70e3c5783 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -29,7 +29,7 @@ use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\Validation; -class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/HiddenTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/HiddenTypeValidatorExtensionTest.php index 38fd4bb859a4e..090d940e77f0e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/HiddenTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/HiddenTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class HiddenTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class HiddenTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/IntegerTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/IntegerTypeValidatorExtensionTest.php index fbfede91563ab..0402a234b844d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/IntegerTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/IntegerTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class IntegerTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class IntegerTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LanguageTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LanguageTypeValidatorExtensionTest.php index 3ac1177375e13..e3cf797d17820 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LanguageTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LanguageTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\LanguageType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class LanguageTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class LanguageTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LocaleTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LocaleTypeValidatorExtensionTest.php index 427db032fcad3..39dfa1f1a8dd8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LocaleTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/LocaleTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\LocaleType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class LocaleTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class LocaleTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/MoneyTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/MoneyTypeValidatorExtensionTest.php index b030ed47ab720..e6dadefcd31b4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/MoneyTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/MoneyTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class MoneyTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class MoneyTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/NumberTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/NumberTypeValidatorExtensionTest.php index a417dc1af61a8..262c9c1d52e69 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/NumberTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/NumberTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class NumberTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class NumberTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PasswordTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PasswordTypeValidatorExtensionTest.php index 629e016d39b3e..3bc242f8c31c7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PasswordTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PasswordTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class PasswordTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class PasswordTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PercentTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PercentTypeValidatorExtensionTest.php index 80fc502c29552..2be9abe3c6f1d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PercentTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/PercentTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\PercentType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class PercentTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class PercentTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RadioTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RadioTypeValidatorExtensionTest.php index 508eb38599f09..074c336c22a71 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RadioTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RadioTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\RadioType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class RadioTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class RadioTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RangeTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RangeTypeValidatorExtensionTest.php index 3b33dde9a5aef..4f8555a132f5f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RangeTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RangeTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\RangeType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class RangeTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class RangeTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RepeatedTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RepeatedTypeValidatorExtensionTest.php index 584dcd9265fa9..43e2aa4da3b6c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RepeatedTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/RepeatedTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class RepeatedTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class RepeatedTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SearchTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SearchTypeValidatorExtensionTest.php index af57e23dc8b61..b5429d8931137 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SearchTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SearchTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\SearchType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class SearchTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class SearchTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php index c347c89bce3b9..42aeb609bf184 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TelTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TelTypeValidatorExtensionTest.php index 87dc2d76d545c..b1eb1b1ffcb07 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TelTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TelTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class TelTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class TelTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimeTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimeTypeValidatorExtensionTest.php index 7f5b938475b41..c7213603d354e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimeTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimeTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\TimeType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class TimeTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class TimeTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimezoneTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimezoneTypeValidatorExtensionTest.php index 833602989d4ff..0c013f053c095 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimezoneTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TimezoneTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\TimezoneType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class TimezoneTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class TimezoneTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UrlTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UrlTypeValidatorExtensionTest.php index 927891ba42e1e..574cb1d62e941 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UrlTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UrlTypeValidatorExtensionTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\UrlType; use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; -class UrlTypeValidatorExtensionTest extends BaseValidatorExtensionTest +class UrlTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase { use ExpectDeprecationTrait; use ValidatorExtensionTrait; diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index 760f8da14e51f..8648dc3d4906a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -78,7 +78,7 @@ public function testGuessType(Constraint $constraint, TypeGuess $guess) $this->assertEquals($guess, $this->guesser->guessType(self::TEST_CLASS, self::TEST_PROPERTY)); } - public function guessTypeProvider() + public static function guessTypeProvider() { return [ [new Type('array'), new TypeGuess(CollectionType::class, [], Guess::MEDIUM_CONFIDENCE)], @@ -97,7 +97,7 @@ public function guessTypeProvider() ]; } - public function guessRequiredProvider() + public static function guessRequiredProvider() { return [ [new NotNull(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)], @@ -182,7 +182,7 @@ public function testGuessMimeTypesForConstraintWithMimeTypesEmptyStringValue() $this->assertArrayNotHasKey('attr', $typeGuess->getOptions()); } - public function maxLengthTypeProvider() + public static function maxLengthTypeProvider() { return [ ['double'], diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index 08b8caaedd5f5..5a9658a74cc2b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -280,7 +280,7 @@ public function testDotRuleMappingIfNotSubmitted() $this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error'); } - public function provideDefaultTests() + public static function provideDefaultTests() { // The mapping must be deterministic! If a child has the property path "[street]", // "data[street]" should be mapped, but "data.street" should not! @@ -838,7 +838,7 @@ public function testDefaultErrorMapping($target, $childName, $childPath, $grandC } } - public function provideCustomDataErrorTests() + public static function provideCustomDataErrorTests() { return [ // mapping target, error mapping, child name, its property path, grand child name, its property path, violation path @@ -1312,7 +1312,7 @@ public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName } } - public function provideCustomFormErrorTests() + public static function provideCustomFormErrorTests() { // This case is different than the data errors, because here the // left side of the mapping refers to the property path of the actual @@ -1503,7 +1503,7 @@ public function testCustomFormErrorMapping($target, $mapFrom, $mapTo, $errorName } } - public function provideErrorTestsForFormInheritingParentData() + public static function provideErrorTestsForFormInheritingParentData() { return [ // mapping target, child name, its property path, grand child name, its property path, violation path diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php index 7b9dec34c28aa..eba3210abd3e5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php @@ -19,7 +19,7 @@ */ class ViolationPathTest extends TestCase { - public function providePaths() + public static function providePaths() { return [ ['children[address]', [ @@ -107,7 +107,7 @@ public function testCreatePath($string, $entries, $slicedPath = null) } } - public function provideParents() + public static function provideParents() { return [ ['children[address]', null], diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt index 043a1dbc27399..cedca25a606e6 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt +++ b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt @@ -14,7 +14,7 @@ Symfony\Component\Form\Tests\Console\Descriptor\FooType (empty_data) line: %s }, %s Closure%s{%A - file: "%s%eTests%eConsole%eDescriptor%eAbstractDescriptorTest.php"%w + file: "%s%eTests%eConsole%eDescriptor%eAbstractDescriptorTestCase.php"%w line: %s } %s ] %s diff --git a/src/Symfony/Component/Form/Tests/FormConfigTest.php b/src/Symfony/Component/Form/Tests/FormConfigTest.php index 239ffbc99a611..6de3e9416f493 100644 --- a/src/Symfony/Component/Form/Tests/FormConfigTest.php +++ b/src/Symfony/Component/Form/Tests/FormConfigTest.php @@ -21,7 +21,7 @@ */ class FormConfigTest extends TestCase { - public function getHtml4Ids() + public static function getHtml4Ids() { return [ ['z0'], diff --git a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php index 44c304558b837..10f8766c52037 100644 --- a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php +++ b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php @@ -55,7 +55,7 @@ public function testFindByCodes($code, $violationsCount) $this->assertCount($violationsCount, $specificFormErrors); } - public function findByCodesProvider() + public static function findByCodesProvider() { return [ ['code1', 2], diff --git a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php index 8bbf0793ff89d..e698138376b6f 100644 --- a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php @@ -17,7 +17,7 @@ /** * @author Bernhard Schussek */ -class NativeRequestHandlerTest extends AbstractRequestHandlerTest +class NativeRequestHandlerTest extends AbstractRequestHandlerTestCase { private static $serverBackup; diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index c841f505ac0ac..ca943fed53a0b 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -192,7 +192,7 @@ public function testBlockPrefixDefaultsToFQCNIfNoName($typeClass, $blockPrefix) $this->assertSame($blockPrefix, $resolvedType->getBlockPrefix()); } - public function provideTypeClassBlockPrefixTuples() + public static function provideTypeClassBlockPrefixTuples() { return [ [Fixtures\FooType::class, 'foo'], diff --git a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php index 4d59b7358321a..1093fc4d4c527 100644 --- a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php @@ -31,6 +31,7 @@ public function testTranslationFileIsValid($filePath) /** * @dataProvider provideTranslationFiles + * * @group Legacy */ public function testTranslationFileIsValidWithoutEntityLoader($filePath) @@ -46,7 +47,7 @@ public function testTranslationFileIsValidWithoutEntityLoader($filePath) $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message')))); } - public function provideTranslationFiles() + public static function provideTranslationFiles() { return array_map( function ($filePath) { return (array) $filePath; }, diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 3d8b0b20d83f1..0f9556b1a572e 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -86,7 +86,7 @@ public function testGetPropertyPath($name, $propertyPath) $this->assertEquals($propertyPath, $form->getPropertyPath()); } - public function provideFormNames() + public static function provideFormNames() { yield [null, null]; yield ['', null]; @@ -243,7 +243,7 @@ public function testAlwaysDisabledIfParentDisabled($parentDisabled, $disabled, $ $this->assertSame($result, $child->isDisabled()); } - public function getDisabledStates() + public static function getDisabledStates() { return [ // parent, button, result diff --git a/src/Symfony/Component/Form/Tests/Util/ServerParamsTest.php b/src/Symfony/Component/Form/Tests/Util/ServerParamsTest.php index 56994760884d4..ebe680e71083b 100644 --- a/src/Symfony/Component/Form/Tests/Util/ServerParamsTest.php +++ b/src/Symfony/Component/Form/Tests/Util/ServerParamsTest.php @@ -48,7 +48,7 @@ public function testGetPostMaxSize($size, $bytes) $this->assertEquals($bytes, $serverParams->getPostMaxSize()); } - public function getGetPostMaxSizeTestData() + public static function getGetPostMaxSizeTestData() { return [ ['2k', 2048], diff --git a/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php b/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php index 3058a2e25d84d..353e3c9667285 100644 --- a/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php +++ b/src/Symfony/Component/Form/Tests/Util/StringUtilTest.php @@ -16,7 +16,7 @@ class StringUtilTest extends TestCase { - public function trimProvider() + public static function trimProvider() { return [ [' Foo! ', 'Foo!'], @@ -49,7 +49,7 @@ public function testTrimUtf8Separators($hex) $this->assertSame("ab\ncd", StringUtil::trim($symbol)); } - public function spaceProvider() + public static function spaceProvider() { return [ // separators @@ -97,7 +97,7 @@ public function testFqcnToBlockPrefix($fqcn, $expectedBlockPrefix) $this->assertSame($expectedBlockPrefix, $blockPrefix); } - public function fqcnToBlockPrefixProvider() + public static function fqcnToBlockPrefixProvider() { return [ ['TYPE', 'type'], diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index e6be770b8b277..6b02d77e29dff 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -47,13 +47,13 @@ "phpunit/phpunit": "<5.4.3", "symfony/console": "<4.4", "symfony/dependency-injection": "<4.4", - "symfony/doctrine-bridge": "<4.4", + "symfony/doctrine-bridge": "<5.4.21|>=6,<6.2.7", "symfony/error-handler": "<4.4.5", "symfony/framework-bundle": "<4.4", "symfony/http-kernel": "<4.4", "symfony/translation": "<4.4", "symfony/translation-contracts": "<1.1.7", - "symfony/twig-bridge": "<4.4" + "symfony/twig-bridge": "<5.4.21|>=6,<6.2.7" }, "suggest": { "symfony/validator": "For form validation.", diff --git a/src/Symfony/Component/HttpClient/AmpHttpClient.php b/src/Symfony/Component/HttpClient/AmpHttpClient.php index 7d79de3a23f34..2ab7e27f77c53 100644 --- a/src/Symfony/Component/HttpClient/AmpHttpClient.php +++ b/src/Symfony/Component/HttpClient/AmpHttpClient.php @@ -54,11 +54,11 @@ final class AmpHttpClient implements HttpClientInterface, LoggerAwareInterface, private $multi; /** - * @param array $defaultOptions Default requests' options - * @param callable $clientConfigurator A callable that builds a {@see DelegateHttpClient} from a {@see PooledHttpClient}; - * passing null builds an {@see InterceptedHttpClient} with 2 retries on failures - * @param int $maxHostConnections The maximum number of connections to a single host - * @param int $maxPendingPushes The maximum number of pushed responses to accept in the queue + * @param array $defaultOptions Default requests' options + * @param callable|null $clientConfigurator A callable that builds a {@see DelegateHttpClient} from a {@see PooledHttpClient}; + * passing null builds an {@see InterceptedHttpClient} with 2 retries on failures + * @param int $maxHostConnections The maximum number of connections to a single host + * @param int $maxPendingPushes The maximum number of pushed responses to accept in the queue * * @see HttpClientInterface::OPTIONS_DEFAULTS for available options */ diff --git a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php index edd9d1c201be7..1925786369159 100644 --- a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php +++ b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php @@ -43,8 +43,8 @@ public function collect(Request $request, Response $response, \Throwable $except public function lateCollect() { - $this->data['request_count'] = 0; - $this->data['error_count'] = 0; + $this->data['request_count'] = $this->data['request_count'] ?? 0; + $this->data['error_count'] = $this->data['error_count'] ?? 0; $this->data += ['clients' => []]; foreach ($this->clients as $name => $client) { @@ -59,7 +59,8 @@ public function lateCollect() $this->data['clients'][$name]['traces'] = array_merge($this->data['clients'][$name]['traces'], $traces); $this->data['request_count'] += \count($traces); - $this->data['error_count'] += $this->data['clients'][$name]['error_count'] += $errorCount; + $this->data['error_count'] += $errorCount; + $this->data['clients'][$name]['error_count'] += $errorCount; $client->reset(); } diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 57ffc51352566..20c2cebbe9113 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -547,7 +547,7 @@ private static function parseUrl(string $url, array $query = [], array $allowedS } // https://tools.ietf.org/html/rfc3986#section-3.3 - $parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()*+,;=:@%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]); + $parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()[\]*+,;=:@\\\\^`{|}%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]); } return [ @@ -621,6 +621,31 @@ private static function mergeQueryString(?string $queryString, array $queryArray $queryArray = []; if ($queryString) { + if (str_contains($queryString, '%')) { + // https://tools.ietf.org/html/rfc3986#section-2.3 + some chars not encoded by browsers + $queryString = strtr($queryString, [ + '%21' => '!', + '%24' => '$', + '%28' => '(', + '%29' => ')', + '%2A' => '*', + '%2B' => '+', + '%2C' => ',', + '%2F' => '/', + '%3A' => ':', + '%3B' => ';', + '%40' => '@', + '%5B' => '[', + '%5C' => '\\', + '%5D' => ']', + '%5E' => '^', + '%60' => '`', + '%7B' => '{', + '%7C' => '|', + '%7D' => '}', + ]); + } + foreach (explode('&', $queryString) as $v) { $queryArray[rawurldecode(explode('=', $v, 2)[0])] = $v; } diff --git a/src/Symfony/Component/HttpClient/LICENSE b/src/Symfony/Component/HttpClient/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/HttpClient/LICENSE +++ b/src/Symfony/Component/HttpClient/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/HttpClient/Tests/EventSourceHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/EventSourceHttpClientTest.php index b738c15a18399..72eb74fb9f289 100644 --- a/src/Symfony/Component/HttpClient/Tests/EventSourceHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/EventSourceHttpClientTest.php @@ -152,7 +152,7 @@ public function testContentType($contentType, $expected) } } - public function contentTypeProvider() + public static function contentTypeProvider() { return [ ['text/event-stream', true], diff --git a/src/Symfony/Component/HttpClient/Tests/Exception/HttpExceptionTraitTest.php b/src/Symfony/Component/HttpClient/Tests/Exception/HttpExceptionTraitTest.php index f7b4ce59e9f9d..f2df403b32845 100644 --- a/src/Symfony/Component/HttpClient/Tests/Exception/HttpExceptionTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/Exception/HttpExceptionTraitTest.php @@ -20,7 +20,7 @@ */ class HttpExceptionTraitTest extends TestCase { - public function provideParseError(): iterable + public static function provideParseError(): iterable { $errorWithoutMessage = 'HTTP/1.1 400 Bad Request returned for "http://example.com".'; diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php index b811626c0c670..baa97dd360236 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php @@ -37,7 +37,7 @@ public function testPrepareRequestUrl(string $expected, string $url, array $quer $this->assertSame($expected, implode('', $url)); } - public function providePrepareRequestUrl(): iterable + public static function providePrepareRequestUrl(): iterable { yield ['http://example.com/', 'http://example.com/']; yield ['http://example.com/?a=1&b=b', '.']; @@ -60,7 +60,7 @@ public function testResolveUrl(string $base, string $url, string $expected) /** * From https://github.com/guzzle/psr7/blob/master/tests/UriResoverTest.php. */ - public function provideResolveUrl(): array + public static function provideResolveUrl(): array { return [ [self::RFC3986_BASE, 'http:h', 'http:h'], @@ -148,7 +148,7 @@ public function testParseUrl(array $expected, string $url, array $query = []) $this->assertSame($expected, self::parseUrl($url, $query)); } - public function provideParseUrl(): iterable + public static function provideParseUrl(): iterable { yield [['http:', '//example.com', null, null, null], 'http://Example.coM:80']; yield [['https:', '//xn--dj-kia8a.example.com:8000', '/', null, null], 'https://DÉjà.Example.com:8000/']; @@ -157,12 +157,12 @@ public function provideParseUrl(): iterable yield [['http:', null, null, null, null], 'http:']; yield [['http:', null, 'bar', null, null], 'http:bar']; yield [[null, null, 'bar', '?a=1&c=c', null], 'bar?a=a&b=b', ['b' => null, 'c' => 'c', 'a' => 1]]; - yield [[null, null, 'bar', '?a=b+c&b=b', null], 'bar?a=b+c', ['b' => 'b']]; - yield [[null, null, 'bar', '?a=b%2B%20c', null], 'bar?a=b+c', ['a' => 'b+ c']]; - yield [[null, null, 'bar', '?a%5Bb%5D=c', null], 'bar', ['a' => ['b' => 'c']]]; - yield [[null, null, 'bar', '?a%5Bb%5Bc%5D=d', null], 'bar?a[b[c]=d', []]; - yield [[null, null, 'bar', '?a%5Bb%5D%5Bc%5D=dd', null], 'bar?a[b][c]=d&e[f]=g', ['a' => ['b' => ['c' => 'dd']], 'e[f]' => null]]; - yield [[null, null, 'bar', '?a=b&a%5Bb%20c%5D=d&e%3Df=%E2%9C%93', null], 'bar?a=b', ['a' => ['b c' => 'd'], 'e=f' => '✓']]; + yield [[null, null, 'bar', '?a=b+c&b=b-._~!$%26/%27()[]*+,;%3D:@%25\\^`{|}', null], 'bar?a=b+c', ['b' => 'b-._~!$&/\'()[]*+,;=:@%\\^`{|}']]; + yield [[null, null, 'bar', '?a=b+%20c', null], 'bar?a=b+c', ['a' => 'b+ c']]; + yield [[null, null, 'bar', '?a[b]=c', null], 'bar', ['a' => ['b' => 'c']]]; + yield [[null, null, 'bar', '?a[b[c]=d', null], 'bar?a[b[c]=d', []]; + yield [[null, null, 'bar', '?a[b][c]=dd', null], 'bar?a[b][c]=d&e[f]=g', ['a' => ['b' => ['c' => 'dd']], 'e[f]' => null]]; + yield [[null, null, 'bar', '?a=b&a[b%20c]=d&e%3Df=%E2%9C%93', null], 'bar?a=b', ['a' => ['b c' => 'd'], 'e=f' => '✓']]; // IDNA 2008 compliance yield [['https:', '//xn--fuball-cta.test', null, null, null], 'https://fußball.test']; } @@ -175,7 +175,7 @@ public function testRemoveDotSegments($expected, $url) $this->assertSame($expected, self::removeDotSegments($url)); } - public function provideRemoveDotSegments() + public static function provideRemoveDotSegments() { yield ['', '']; yield ['', '.']; @@ -224,7 +224,7 @@ public function testSetJSONAndBodyOptions() self::prepareRequest('POST', 'http://example.com', ['json' => ['foo' => 'bar'], 'body' => ''], HttpClientInterface::OPTIONS_DEFAULTS); } - public function providePrepareAuthBasic() + public static function providePrepareAuthBasic() { yield ['foo:bar', 'Zm9vOmJhcg==']; yield [['foo', 'bar'], 'Zm9vOmJhcg==']; @@ -241,7 +241,7 @@ public function testPrepareAuthBasic($arg, $result) $this->assertSame('Authorization: Basic '.$result, $options['normalized_headers']['authorization'][0]); } - public function provideFingerprints() + public static function provideFingerprints() { foreach (['md5', 'sha1', 'sha256'] as $algo) { $hash = hash($algo, $algo); diff --git a/src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php b/src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php index df5cb394dfec7..9dbbff7dd9364 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php @@ -19,7 +19,7 @@ */ class HttpOptionsTest extends TestCase { - public function provideSetAuthBasic(): iterable + public static function provideSetAuthBasic(): iterable { yield ['user:password', 'user', 'password']; yield ['user:password', 'user:password']; diff --git a/src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php index e06575cfc763f..8c697b4ee22c2 100644 --- a/src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php @@ -42,7 +42,7 @@ public function testMocking($factory, array $expectedResponses) $this->assertSame(2, $client->getRequestsCount()); } - public function mockingProvider(): iterable + public static function mockingProvider(): iterable { yield 'callable' => [ static function (string $method, string $url, array $options = []) { @@ -112,7 +112,7 @@ public function testValidResponseFactory($responseFactory) $this->addToAssertionCount(1); } - public function validResponseFactoryProvider() + public static function validResponseFactoryProvider() { return [ [static function (): MockResponse { return new MockResponse(); }], @@ -138,7 +138,7 @@ public function testTransportExceptionThrowsIfPerformedMoreRequestsThanConfigure $client->request('POST', '/foo'); } - public function transportExceptionProvider(): iterable + public static function transportExceptionProvider(): iterable { yield 'array of callable' => [ [ @@ -179,7 +179,7 @@ public function testInvalidResponseFactory($responseFactory, string $expectedExc (new MockHttpClient($responseFactory))->request('GET', 'https://foo.bar'); } - public function invalidResponseFactoryProvider() + public static function invalidResponseFactoryProvider() { return [ [static function (): \Generator { yield new MockResponse(); }, 'The response factory passed to MockHttpClient must return/yield an instance of ResponseInterface, "Generator" given.'], diff --git a/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php index aabfe38c01692..8c51e9eaa891c 100755 --- a/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php @@ -22,7 +22,7 @@ class NoPrivateNetworkHttpClientTest extends TestCase { - public function getExcludeData(): array + public static function getExcludeData(): array { return [ // private diff --git a/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php b/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php index d6839fbcfeb86..6b172b1589ac1 100644 --- a/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php +++ b/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php @@ -74,7 +74,7 @@ public function testUrlHttpMethodMockResponse() $this->assertSame($url, $responseMock->getRequestUrl()); } - public function toArrayErrors() + public static function toArrayErrors() { yield [ 'content' => '', diff --git a/src/Symfony/Component/HttpClient/Tests/Retry/GenericRetryStrategyTest.php b/src/Symfony/Component/HttpClient/Tests/Retry/GenericRetryStrategyTest.php index 98b6578f0b62f..79fc37588bd0f 100644 --- a/src/Symfony/Component/HttpClient/Tests/Retry/GenericRetryStrategyTest.php +++ b/src/Symfony/Component/HttpClient/Tests/Retry/GenericRetryStrategyTest.php @@ -41,14 +41,14 @@ public function testShouldNotRetry(string $method, int $code, ?TransportExceptio self::assertFalse($strategy->shouldRetry($this->getContext(0, $method, 'http://example.com/', $code), null, $exception)); } - public function provideRetryable(): iterable + public static function provideRetryable(): iterable { yield ['GET', 200, new TransportException()]; yield ['GET', 500, null]; yield ['POST', 429, null]; } - public function provideNotRetryable(): iterable + public static function provideNotRetryable(): iterable { yield ['POST', 200, null]; yield ['POST', 200, new TransportException()]; @@ -65,7 +65,7 @@ public function testGetDelay(int $delay, int $multiplier, int $maxDelay, int $pr self::assertSame($expectedDelay, $strategy->getDelay($this->getContext($previousRetries, 'GET', 'http://example.com/', 200), null, null)); } - public function provideDelay(): iterable + public static function provideDelay(): iterable { // delay, multiplier, maxDelay, retries, expectedDelay yield [1000, 1, 5000, 0, 1000]; diff --git a/src/Symfony/Component/HttpClient/Tests/ScopingHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/ScopingHttpClientTest.php index 078475bf1010c..3e02111c32131 100644 --- a/src/Symfony/Component/HttpClient/Tests/ScopingHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/ScopingHttpClientTest.php @@ -49,7 +49,7 @@ public function testMatchingUrls(string $regexp, string $url, array $options) $this->assertSame($options[$regexp]['case'], $requestedOptions['case']); } - public function provideMatchingUrls() + public static function provideMatchingUrls() { $defaultOptions = [ '.*/foo-bar' => ['case' => 1], diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index b4b26c0151b10..91024535b2c68 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -80,7 +80,7 @@ public static function create(string $name, string $value = null, $expire = 0, ? * @param string $name The name of the cookie * @param string|null $value The value of the cookie * @param int|string|\DateTimeInterface $expire The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on + * @param string|null $path The path on the server in which the cookie will be available on * @param string|null $domain The domain that the cookie is available to * @param bool|null $secure Whether the client should send back the cookie only over HTTPS or null to auto-enable this when the request is already using HTTPS * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol diff --git a/src/Symfony/Component/HttpFoundation/HeaderUtils.php b/src/Symfony/Component/HttpFoundation/HeaderUtils.php index 1d56be08050f0..46b1e6aed60fb 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderUtils.php +++ b/src/Symfony/Component/HttpFoundation/HeaderUtils.php @@ -138,7 +138,7 @@ public static function quote(string $s): string * Decodes a quoted string. * * If passed an unquoted string that matches the "token" construct (as - * defined in the HTTP specification), it is passed through verbatimly. + * defined in the HTTP specification), it is passed through verbatim. */ public static function unquote(string $s): string { diff --git a/src/Symfony/Component/HttpFoundation/LICENSE b/src/Symfony/Component/HttpFoundation/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/HttpFoundation/LICENSE +++ b/src/Symfony/Component/HttpFoundation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 10f779d279ec0..28cebad1608ff 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -191,7 +191,7 @@ class Request protected $session; /** - * @var string + * @var string|null */ protected $locale; @@ -439,12 +439,12 @@ public static function setFactory(?callable $callable) /** * Clones a request and overrides some of its parameters. * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters + * @param array|null $query The GET parameters + * @param array|null $request The POST parameters + * @param array|null $attributes The request attributes (parameters parsed from the PATH_INFO, ...) + * @param array|null $cookies The COOKIE parameters + * @param array|null $files The FILES parameters + * @param array|null $server The SERVER parameters * * @return static */ @@ -1452,7 +1452,7 @@ public function setLocale(string $locale) */ public function getLocale() { - return null === $this->locale ? $this->defaultLocale : $this->locale; + return $this->locale ?? $this->defaultLocale; } /** @@ -1573,9 +1573,9 @@ public function getContent(bool $asResource = false) /** * Gets the request body decoded as array, typically from a JSON payload. * - * @throws JsonException When the body cannot be decoded to an array - * * @return array + * + * @throws JsonException When the body cannot be decoded to an array */ public function toArray() { diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index d5c8cb45cd4be..59e974d62d557 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -774,8 +774,10 @@ public function getMaxAge(): ?int return (int) $this->headers->getCacheControlDirective('max-age'); } - if (null !== $this->getExpires()) { - return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U'); + if (null !== $expires = $this->getExpires()) { + $maxAge = (int) $expires->format('U') - (int) $this->getDate()->format('U'); + + return max($maxAge, 0); } return null; @@ -819,7 +821,7 @@ public function setSharedMaxAge(int $value): object * * It returns null when no freshness information is present in the response. * - * When the responses TTL is <= 0, the response may not be served from cache without first + * When the response's TTL is 0, the response may not be served from cache without first * revalidating with the origin. * * @final @@ -828,7 +830,7 @@ public function getTtl(): ?int { $maxAge = $this->getMaxAge(); - return null !== $maxAge ? $maxAge - $this->getAge() : null; + return null !== $maxAge ? max($maxAge - $this->getAge(), 0) : null; } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php b/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php index b2f09fd0dc713..e673383372e75 100644 --- a/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php @@ -59,10 +59,10 @@ public function setName(string $name); * Clears all session attributes and flashes and regenerates the * session and deletes the old session from persistence. * - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. + * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value + * will leave the system settings unchanged, 0 sets the cookie + * to expire with browser session. Time is in seconds, and is + * not a Unix timestamp. * * @return bool */ @@ -72,11 +72,11 @@ public function invalidate(int $lifetime = null); * Migrates the current session to a new session id while maintaining all * session attributes. * - * @param bool $destroy Whether to delete the old session or leave it to garbage collection - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. + * @param bool $destroy Whether to delete the old session or leave it to garbage collection + * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value + * will leave the system settings unchanged, 0 sets the cookie + * to expire with browser session. Time is in seconds, and is + * not a Unix timestamp. * * @return bool */ diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php index 1ca4bfeb08335..a446c0c415806 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php @@ -19,9 +19,9 @@ class NativeFileSessionHandler extends \SessionHandler { /** - * @param string $savePath Path of directory to save session files - * Default null will leave setting as defined by PHP. - * '/path', 'N;/path', or 'N;octal-mode;/path + * @param string|null $savePath Path of directory to save session files + * Default null will leave setting as defined by PHP. + * '/path', 'N;/path', or 'N;octal-mode;/path * * @see https://php.net/session.configuration#ini.session.save-path for further details. * diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 24c98940dcf77..2d830200b03f5 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -530,8 +530,8 @@ private function buildDsnFromUrl(string $dsnOrUrl): string return $dsn; } } - // If "unix_socket" is not in the query, we continue with the same process as pgsql - // no break + // If "unix_socket" is not in the query, we continue with the same process as pgsql + // no break case 'pgsql': $dsn ?? $dsn = 'pgsql:'; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php index 595a9e23c2c64..52d3320942fa0 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php @@ -95,10 +95,10 @@ public function getLifetime() /** * Stamps a new session's metadata. * - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. + * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value + * will leave the system settings unchanged, 0 sets the cookie + * to expire with browser session. Time is in seconds, and is + * not a Unix timestamp. */ public function stampNew(int $lifetime = null) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php b/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php index b7f66e7c7370d..705374552d343 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php @@ -80,11 +80,11 @@ public function setName(string $name); * Otherwise session data could get lost again for concurrent requests with the * new ID. One result could be that you get logged out after just logging in. * - * @param bool $destroy Destroy session when regenerating? - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. + * @param bool $destroy Destroy session when regenerating? + * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value + * will leave the system settings unchanged, 0 sets the cookie + * to expire with browser session. Time is in seconds, and is + * not a Unix timestamp. * * @return bool * diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 676cd66875fcf..0599bd1e4c2b6 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -114,9 +114,9 @@ public function sendContent() /** * {@inheritdoc} * - * @throws \LogicException when the content is not null - * * @return $this + * + * @throws \LogicException when the content is not null */ public function setContent(?string $content) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php b/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php index 516bd5551a0f3..7ec8c30fbc9be 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php @@ -26,7 +26,7 @@ public function testFromString($string, $value, array $attributes) $this->assertEquals($attributes, $item->getAttributes()); } - public function provideFromStringData() + public static function provideFromStringData() { return [ [ @@ -57,7 +57,7 @@ public function testToString($value, array $attributes, $string) $this->assertEquals($string, (string) $item); } - public function provideToStringData() + public static function provideToStringData() { return [ [ diff --git a/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php b/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php index 1987e97fb8bc7..bf4582430503e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php @@ -37,7 +37,7 @@ public function testFromString($string, array $items) $this->assertEquals($items, $parsed); } - public function provideFromStringData() + public static function provideFromStringData() { return [ ['', []], @@ -57,7 +57,7 @@ public function testToString(array $items, $string) $this->assertEquals($string, (string) $header); } - public function provideToStringData() + public static function provideToStringData() { return [ [[], ''], @@ -76,7 +76,7 @@ public function testFilter($string, $filter, array $values) $this->assertEquals($values, array_keys($header->all())); } - public function provideFilterData() + public static function provideFilterData() { return [ ['fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4', '/fr.*/', ['fr-FR', 'fr']], @@ -92,7 +92,7 @@ public function testSorting($string, array $values) $this->assertEquals($values, array_keys($header->all())); } - public function provideSortingData() + public static function provideSortingData() { return [ 'quality has priority' => ['*;q=0.3,ISO-8859-1,utf-8;q=0.7', ['ISO-8859-1', 'utf-8', '*']], @@ -110,7 +110,7 @@ public function testDefaultValue($acceptHeader, $value, $expectedQuality) $this->assertSame($expectedQuality, $header->get($value)->getQuality()); } - public function provideDefaultValueData() + public static function provideDefaultValueData() { yield ['text/plain;q=0.5, text/html, text/x-dvi;q=0.8, *;q=0.3', 'text/xml', 0.3]; yield ['text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */*;q=0.3', 'text/xml', 0.3]; diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 65d6fe0854ab0..222b5f2987294 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -165,7 +165,7 @@ public function testRequestsWithoutEtag($requestRange, $offset, $length, $respon $this->assertEquals($responseRange, $response->headers->get('Content-Range')); } - public function provideRanges() + public static function provideRanges() { return [ ['bytes=1-4', 1, 4, 'bytes 1-4/35'], @@ -219,7 +219,7 @@ public function testFullFileRequests($requestRange) $this->assertEquals(200, $response->getStatusCode()); } - public function provideFullFileRanges() + public static function provideFullFileRanges() { return [ ['bytes=0-'], @@ -285,7 +285,7 @@ public function testInvalidRequests($requestRange) $this->assertEquals('bytes */35', $response->headers->get('Content-Range')); } - public function provideInvalidRanges() + public static function provideInvalidRanges() { return [ ['bytes=-40'], @@ -311,7 +311,7 @@ public function testXSendfile($file) $this->assertStringContainsString('README.md', $response->headers->get('X-Sendfile')); } - public function provideXSendfileFiles() + public static function provideXSendfileFiles() { return [ [__DIR__.'/../README.md'], @@ -378,7 +378,7 @@ public function testAcceptRangeNotOverriden() $this->assertEquals('foo', $response->headers->get('Accept-Ranges')); } - public function getSampleXAccelMappings() + public static function getSampleXAccelMappings() { return [ ['/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'], diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index cd65e0eaacc9d..ec5a4e28f406a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -24,7 +24,7 @@ */ class CookieTest extends TestCase { - public function namesWithSpecialCharacters() + public static function namesWithSpecialCharacters() { return [ [',MyName'], diff --git a/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php b/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php index aab5f739cc06e..918ea08cca854 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php @@ -51,7 +51,7 @@ public function testMatchesWhenParentMatchesIsFalse($expression) $this->assertFalse($expressionRequestMatcher->matches($request)); } - public function provideExpressions() + public static function provideExpressions() { return [ ['request.getMethod() == method', true], diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index 868c53af96845..fc806e95147c4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -93,7 +93,7 @@ public function testGetContent() $this->assertStringEqualsFile(__FILE__, $file->getContent()); } - public function getFilenameFixtures() + public static function getFilenameFixtures() { return [ ['original.gif', 'original.gif'], diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index 9a48a424a986c..8c7fe45b56cd1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -156,7 +156,7 @@ public function testMoveLocalFileIsNotAllowed() $file->move(__DIR__.'/Fixtures/directory'); } - public function failedUploadedFile() + public static function failedUploadedFile() { foreach ([\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_EXTENSION, -1] as $error) { yield [new UploadedFile( @@ -298,7 +298,7 @@ public function testIsInvalidOnUploadError($error) $this->assertFalse($file->isValid()); } - public function uploadedFileErrorProvider() + public static function uploadedFileErrorProvider() { return [ [\UPLOAD_ERR_INI_SIZE], diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php index 2b585a95d488d..73d3f150c7a8e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php @@ -24,7 +24,7 @@ public function testSplit(array $expected, string $header, string $separator) $this->assertSame($expected, HeaderUtils::split($header, $separator)); } - public function provideHeaderToSplit(): array + public static function provideHeaderToSplit(): array { return [ [['foo=123', 'bar'], 'foo=123,bar', ','], @@ -111,7 +111,7 @@ public function testMakeDisposition($disposition, $filename, $filenameFallback, $this->assertEquals($expected, HeaderUtils::makeDisposition($disposition, $filename, $filenameFallback)); } - public function provideMakeDisposition() + public static function provideMakeDisposition() { return [ ['attachment', 'foo.html', 'foo.html', 'attachment; filename=foo.html'], @@ -132,7 +132,7 @@ public function testMakeDispositionFail($disposition, $filename) HeaderUtils::makeDisposition($disposition, $filename); } - public function provideMakeDispositionFail() + public static function provideMakeDispositionFail() { return [ ['attachment', 'foo%20bar.html'], @@ -152,7 +152,7 @@ public function testParseQuery(string $query, string $expected = null) $this->assertSame($expected ?? $query, http_build_query(HeaderUtils::parseQuery($query), '', '&')); } - public function provideParseQuery() + public static function provideParseQuery() { return [ ['a=b&c=d'], diff --git a/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php b/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php index 33d67303a831d..085790cf606a8 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php @@ -27,7 +27,7 @@ public function testIpv4($matches, $remoteAddr, $cidr) $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr)); } - public function getIpv4Data() + public static function getIpv4Data() { return [ [true, '192.168.1.1', '192.168.1.1'], @@ -58,7 +58,7 @@ public function testIpv6($matches, $remoteAddr, $cidr) $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr)); } - public function getIpv6Data() + public static function getIpv6Data() { return [ [true, '2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'], @@ -130,7 +130,7 @@ public function testInvalidIpAddressesDoNotMatch($requestIp, $proxyIp) $this->assertFalse(IpUtils::checkIp4($requestIp, $proxyIp)); } - public function invalidIpAddressData() + public static function invalidIpAddressData() { return [ 'invalid proxy wildcard' => ['192.168.20.13', '*'], @@ -147,7 +147,7 @@ public function testAnonymize($ip, $expected) $this->assertSame($expected, IpUtils::anonymize($ip)); } - public function anonymizedIpData() + public static function anonymizedIpData() { return [ ['192.168.1.1', '192.168.1.0'], @@ -173,7 +173,7 @@ public function testIp4SubnetMaskZero($matches, $remoteAddr, $cidr) $this->assertSame($matches, IpUtils::checkIp4($remoteAddr, $cidr)); } - public function getIp4SubnetMaskZeroData() + public static function getIp4SubnetMaskZeroData() { return [ [true, '1.2.3.4', '0.0.0.0/0'], diff --git a/src/Symfony/Component/HttpFoundation/Tests/RateLimiter/AbstractRequestRateLimiterTest.php b/src/Symfony/Component/HttpFoundation/Tests/RateLimiter/AbstractRequestRateLimiterTest.php index 4790eae183802..4e102777a45c6 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RateLimiter/AbstractRequestRateLimiterTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RateLimiter/AbstractRequestRateLimiterTest.php @@ -33,7 +33,7 @@ public function testConsume(array $rateLimits, ?RateLimit $expected) $this->assertSame($expected, $rateLimiter->consume(new Request())); } - public function provideRateLimits() + public static function provideRateLimits() { $now = new \DateTimeImmutable(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php index 18e269693e1a2..c0e640421e407 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php @@ -32,7 +32,7 @@ public function testMethod($requestMethod, $matcherMethod, $isMatch) $this->assertSame($isMatch, $matcher->matches($request)); } - public function getMethodData() + public static function getMethodData() { return [ ['get', 'get', true], @@ -93,7 +93,7 @@ public function testPort() $this->assertTrue($matcher->matches($request)); } - public function getHostData() + public static function getHostData() { return [ ['.*\.example\.com', true], diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 058b5419a87f9..e5360807ba54d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -309,7 +309,7 @@ public function testGetRequestUri($serverRequestUri, $expected, $message) $this->assertSame($expected, $request->server->get('REQUEST_URI'), 'Normalize the request URI.'); } - public function getRequestUriData() + public static function getRequestUriData() { $message = 'Do not modify the path.'; yield ['/foo', '/foo', $message]; @@ -490,7 +490,7 @@ public function testGetFormatWithCustomMimeType() $this->assertEquals('custom', $request->getFormat('application/vnd.foo.api;myversion=2.3')); } - public function getFormatToMimeTypeMapProvider() + public static function getFormatToMimeTypeMapProvider() { return [ ['txt', ['text/plain']], @@ -735,7 +735,7 @@ public function testGetRelativeUriForPath($expected, $pathinfo, $path) $this->assertEquals($expected, Request::create($pathinfo)->getRelativeUriForPath($path)); } - public function getRelativeUriForPathData() + public static function getRelativeUriForPathData() { return [ ['me.png', '/foo', '/me.png'], @@ -798,7 +798,7 @@ public function testGetQueryString($query, $expectedQuery, $msg) $this->assertSame($expectedQuery, $request->getQueryString(), $msg); } - public function getQueryStringNormalizationData() + public static function getQueryStringNormalizationData() { return [ ['foo', 'foo=', 'works with valueless parameters'], @@ -1015,7 +1015,7 @@ public function testGetClientIpsForwarded($expected, $remoteAddr, $httpForwarded $this->assertEquals($expected, $request->getClientIps()); } - public function getClientIpsForwardedProvider() + public static function getClientIpsForwardedProvider() { // $expected $remoteAddr $httpForwarded $trustedProxies return [ @@ -1028,7 +1028,7 @@ public function getClientIpsForwardedProvider() ]; } - public function getClientIpsProvider() + public static function getClientIpsProvider() { // $expected $remoteAddr $httpForwardedFor $trustedProxies return [ @@ -1124,7 +1124,7 @@ public function testGetClientIpsOnlyXHttpForwardedForTrusted($httpForwarded, $ht $this->assertSame(array_reverse(explode(',', $httpXForwardedFor)), $request->getClientIps()); } - public function getClientIpsWithConflictingHeadersProvider() + public static function getClientIpsWithConflictingHeadersProvider() { // $httpForwarded $httpXForwardedFor return [ @@ -1158,7 +1158,7 @@ public function testGetClientIpsWithAgreeingHeaders($httpForwarded, $httpXForwar $this->assertSame($expectedIps, $clientIps); } - public function getClientIpsWithAgreeingHeadersProvider() + public static function getClientIpsWithAgreeingHeadersProvider() { // $httpForwarded $httpXForwardedFor return [ @@ -1235,7 +1235,7 @@ public function testGetContentCanBeCalledTwiceWithResources($first, $second) $this->assertSame($a, $b); } - public function getContentCanBeCalledTwiceWithResourcesProvider() + public static function getContentCanBeCalledTwiceWithResourcesProvider() { return [ 'Fetch then fetch' => [false, false], @@ -1245,7 +1245,7 @@ public function getContentCanBeCalledTwiceWithResourcesProvider() ]; } - public function provideOverloadedMethods() + public static function provideOverloadedMethods() { return [ ['PUT'], @@ -1668,10 +1668,7 @@ public function testGetSession() $request->setSession(new Session(new MockArraySessionStorage())); $this->assertTrue($request->hasSession()); - $session = $request->getSession(); - $this->assertObjectHasAttribute('storage', $session); - $this->assertObjectHasAttribute('flashName', $session); - $this->assertObjectHasAttribute('attributeName', $session); + $this->assertInstanceOf(Session::class, $request->getSession()); } public function testHasPreviousSession() @@ -1737,7 +1734,7 @@ public function testGetBaseUrl($uri, $server, $expectedBaseUrl, $expectedPathInf $this->assertSame($expectedPathInfo, $request->getPathInfo(), 'pathInfo'); } - public function getBaseUrlData() + public static function getBaseUrlData() { return [ [ @@ -1866,7 +1863,7 @@ public function testUrlencodedStringPrefix($string, $prefix, $expect) $this->assertSame($expect, $me->invoke($request, $string, $prefix)); } - public function urlencodedStringPrefixData() + public static function urlencodedStringPrefixData() { return [ ['foo', 'foo', 'foo'], @@ -2042,7 +2039,7 @@ public function testIISRequestUri($headers, $server, $expectedRequestUri) $this->assertEquals($subRequestUri, $subRequest->getRequestUri(), '->getRequestUri() is correct in sub request'); } - public function iisRequestUriProvider() + public static function iisRequestUriProvider() { return [ [ @@ -2165,7 +2162,7 @@ public function testHostValidity($host, $isValid, $expectedHost = null, $expecte } } - public function getHostValidities() + public static function getHostValidities() { return [ ['.a', false], @@ -2178,7 +2175,7 @@ public function getHostValidities() ]; } - public function getLongHostNames() + public static function getLongHostNames() { return [ ['a'.str_repeat('.a', 40000)], @@ -2196,7 +2193,7 @@ public function testMethodIdempotent($method, $idempotent) $this->assertEquals($idempotent, $request->isMethodIdempotent()); } - public function methodIdempotentProvider() + public static function methodIdempotentProvider() { return [ ['HEAD', true], @@ -2222,7 +2219,7 @@ public function testMethodSafe($method, $safe) $this->assertEquals($safe, $request->isMethodSafe()); } - public function methodSafeProvider() + public static function methodSafeProvider() { return [ ['HEAD', true], @@ -2248,7 +2245,7 @@ public function testMethodCacheable($method, $cacheable) $this->assertEquals($cacheable, $request->isMethodCacheable()); } - public function methodCacheableProvider() + public static function methodCacheableProvider() { return [ ['HEAD', true], @@ -2284,7 +2281,7 @@ public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expec $this->assertSame($expected, $request->getProtocolVersion()); } - public function protocolVersionProvider() + public static function protocolVersionProvider() { return [ 'untrusted with empty via' => ['HTTP/2.0', false, '', 'HTTP/2.0'], @@ -2299,7 +2296,7 @@ public function protocolVersionProvider() ]; } - public function nonstandardRequestsData() + public static function nonstandardRequestsData() { return [ ['', '', '/', 'http://host:8080/', ''], @@ -2470,7 +2467,7 @@ public function testTrustedProxiesRemoteAddr($serverRemoteAddr, $trustedProxies, $this->assertSame($result, Request::getTrustedProxies()); } - public function trustedProxiesRemoteAddr() + public static function trustedProxiesRemoteAddr() { return [ ['1.1.1.1', ['REMOTE_ADDR'], ['1.1.1.1']], @@ -2490,7 +2487,7 @@ public function testPreferSafeContent($server, bool $safePreferenceExpected) $this->assertEquals($safePreferenceExpected, $request->preferSafeContent()); } - public function preferSafeContentData() + public static function preferSafeContentData() { return [ [[], false], diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php index aa24291eda5dc..ed88ff5743524 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php @@ -52,7 +52,7 @@ public function testCookie($fixture) $this->assertStringMatchesFormatFile(__DIR__.sprintf('/Fixtures/response-functional/%s.expected', $fixture), $result); } - public function provideCookie() + public static function provideCookie() { foreach (glob(__DIR__.'/Fixtures/response-functional/*.php') as $file) { yield [pathinfo($file, \PATHINFO_FILENAME)]; diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 5885ab4b1f356..50198c2d7612b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -51,24 +51,14 @@ public function testSendHeaders() { $response = new Response(); $headers = $response->sendHeaders(); - $this->assertObjectHasAttribute('headers', $headers); - $this->assertObjectHasAttribute('content', $headers); - $this->assertObjectHasAttribute('version', $headers); - $this->assertObjectHasAttribute('statusCode', $headers); - $this->assertObjectHasAttribute('statusText', $headers); - $this->assertObjectHasAttribute('charset', $headers); + $this->assertSame($response, $headers); } public function testSend() { $response = new Response(); $responseSend = $response->send(); - $this->assertObjectHasAttribute('headers', $responseSend); - $this->assertObjectHasAttribute('content', $responseSend); - $this->assertObjectHasAttribute('version', $responseSend); - $this->assertObjectHasAttribute('statusCode', $responseSend); - $this->assertObjectHasAttribute('statusText', $responseSend); - $this->assertObjectHasAttribute('charset', $responseSend); + $this->assertSame($response, $responseSend); } public function testGetCharset() @@ -132,12 +122,7 @@ public function testSetNotModified() { $response = new Response('foo'); $modified = $response->setNotModified(); - $this->assertObjectHasAttribute('headers', $modified); - $this->assertObjectHasAttribute('content', $modified); - $this->assertObjectHasAttribute('version', $modified); - $this->assertObjectHasAttribute('statusCode', $modified); - $this->assertObjectHasAttribute('statusText', $modified); - $this->assertObjectHasAttribute('charset', $modified); + $this->assertSame($response, $modified); $this->assertEquals(304, $modified->getStatusCode()); ob_start(); @@ -353,9 +338,8 @@ public function testGetMaxAge() $this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); $response = new Response(); - $response->headers->set('Cache-Control', 'must-revalidate'); $response->headers->set('Expires', -1); - $this->assertLessThanOrEqual(time() - 2 * 86400, $response->getExpires()->format('U')); + $this->assertSame(0, $response->getMaxAge()); $response = new Response(); $this->assertNull($response->getMaxAge(), '->getMaxAge() returns null if no freshness information available'); @@ -436,7 +420,7 @@ public function testGetTtl() $response = new Response(); $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)); - $this->assertLessThan(0, $response->getTtl(), '->getTtl() returns negative values when Expires is in past'); + $this->assertSame(0, $response->getTtl(), '->getTtl() returns zero when Expires is in past'); $response = new Response(); $response->headers->set('Expires', $response->getDate()->format(\DATE_RFC2822)); @@ -863,7 +847,7 @@ public function testSetStatusCode($code, $text, $expectedText) $this->assertEquals($expectedText, $statusText->getValue($response)); } - public function getStatusCodeFixtures() + public static function getStatusCodeFixtures() { return [ ['200', null, 'OK'], @@ -1017,7 +1001,7 @@ public function testNoDeprecationsAreTriggered() $this->addToAssertionCount(1); } - public function validContentProvider() + public static function validContentProvider() { return [ 'obj' => [new StringableObject()], @@ -1062,7 +1046,7 @@ protected function provideResponse() * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com) * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License */ - public function ianaCodesReasonPhrasesProvider() + public static function ianaCodesReasonPhrasesProvider() { // XML taken from https://www.iana.org/assignments/http-status-codes/http-status-codes.xml // (might not be up-to-date for older Symfony versions) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php index 6313967afa405..273efddf16591 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php @@ -153,7 +153,7 @@ public function testClear() $this->assertEquals([], $this->bag->all()); } - public function attributesProvider() + public static function attributesProvider() { return [ ['hello', 'world', true], diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php index fe7838408d941..4df76926b1039 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php @@ -182,7 +182,7 @@ public function testClear() $this->assertEquals([], $this->bag->all()); } - public function attributesProvider() + public static function attributesProvider() { return [ ['hello', 'world', true], diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 8efb535490b0d..56011ddb558fb 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -156,7 +156,7 @@ public function testClear($key, $value) $this->assertEquals([], $this->session->all()); } - public function setProvider() + public static function setProvider() { return [ ['foo', 'bar', ['foo' => 'bar']], diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php index 2ac7a99eacd95..cd8b31c60d240 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php @@ -16,6 +16,7 @@ /** * @requires extension redis + * * @group time-sensitive */ abstract class AbstractRedisSessionHandlerTestCase extends TestCase @@ -140,7 +141,7 @@ public function testSupportedParam(array $options, bool $supported) } } - public function getOptionFixtures(): array + public static function getOptionFixtures(): array { return [ [['prefix' => 'session'], true], @@ -169,7 +170,7 @@ public function testUseTtlOption(int $ttl) $this->assertGreaterThan($redisTtl, $ttl + 5); } - public function getTtlFixtures(): array + public static function getTtlFixtures(): array { return [ ['ttl' => 5000], diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php index aca2bfd882b20..8e42f84276e58 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php @@ -51,7 +51,7 @@ public function testSession($fixture) $this->assertStringEqualsFile(__DIR__.sprintf('/Fixtures/%s.expected', $fixture), $result); } - public function provideSession() + public static function provideSession() { foreach (glob(__DIR__.'/Fixtures/*.php') as $file) { yield [pathinfo($file, \PATHINFO_FILENAME)]; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/IdentityMarshallerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/IdentityMarshallerTest.php index b26bc7e60a6bb..8019bd2e989c4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/IdentityMarshallerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/IdentityMarshallerTest.php @@ -49,7 +49,7 @@ public function testUnmarshall() $this->assertEquals('data', $marshaller->unmarshall('data')); } - public function invalidMarshallDataProvider(): iterable + public static function invalidMarshallDataProvider(): iterable { return [ [['object' => new \stdClass()]], 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 6abdf4eb05f5c..2e2ec3647656a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -147,7 +147,7 @@ public function testSupportedOptions($options, $supported) } } - public function getOptionFixtures() + public static function getOptionFixtures() { return [ [['prefix' => 'session'], true], 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 ff9eabb092b0d..1e6a05df2ef84 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -18,7 +18,9 @@ /** * @author Markus Bachmann + * * @group time-sensitive + * * @requires extension mongodb */ class MongoDbSessionHandlerTest extends TestCase diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index ffb2e25bb8f28..e93ed2d096bf2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -21,6 +21,7 @@ * @author Drak * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class NativeFileSessionHandlerTest extends TestCase @@ -47,7 +48,7 @@ public function testConstructSavePath($savePath, $expectedSavePath, $path) rmdir($path); } - public function savePathDataProvider() + public static function savePathDataProvider() { $base = sys_get_temp_dir(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php index 76a8594b3118a..27704b909b658 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php @@ -22,6 +22,7 @@ * @author Drak * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class NullSessionHandlerTest extends TestCase 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 867a6692eda84..4403cda3df8b2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -16,6 +16,7 @@ /** * @requires extension pdo_sqlite + * * @group time-sensitive */ class PdoSessionHandlerTest extends TestCase @@ -329,7 +330,7 @@ public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPa } } - public function provideUrlDsnPairs() + public static function provideUrlDsnPairs() { yield ['mysql://localhost/test', 'mysql:host=localhost;dbname=test;']; yield ['mysql://localhost/test?charset=utf8mb4', 'mysql:charset=utf8mb4;host=localhost;dbname=test;']; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php index 4d2a7dd0c4b84..cecee7b47df53 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php @@ -22,6 +22,7 @@ * @author Simon * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class SessionHandlerFactoryTest extends TestCase @@ -37,7 +38,7 @@ public function testCreateFileHandler(string $connectionDSN, string $expectedPat $this->assertEquals($expectedPath, \ini_get('session.save_path')); } - public function provideConnectionDSN(): array + public static function provideConnectionDSN(): array { $base = sys_get_temp_dir(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index b7714b9b87c12..adf074e36a03c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -27,6 +27,7 @@ * These tests require separate processes. * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class NativeSessionStorageTest extends TestCase diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index c0c667545243b..e2fb93ebcc000 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -23,6 +23,7 @@ * These tests require separate processes. * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class PhpBridgeSessionStorageTest extends TestCase diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index c500829811ff5..fde7a4a0aef71 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -56,6 +56,7 @@ public function testIsWrapper() /** * @runInSeparateProcess + * * @preserveGlobalState disabled */ public function testIsActive() @@ -67,6 +68,7 @@ public function testIsActive() /** * @runInSeparateProcess + * * @preserveGlobalState disabled */ public function testName() @@ -79,6 +81,7 @@ public function testName() /** * @runInSeparateProcess + * * @preserveGlobalState disabled */ public function testNameException() @@ -90,6 +93,7 @@ public function testNameException() /** * @runInSeparateProcess + * * @preserveGlobalState disabled */ public function testId() @@ -102,6 +106,7 @@ public function testId() /** * @runInSeparateProcess + * * @preserveGlobalState disabled */ public function testIdException() 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 a4f45fec68708..eed23fe0b25a2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -22,6 +22,7 @@ * @author Drak * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class SessionHandlerProxyTest extends TestCase @@ -170,7 +171,7 @@ public function testNativeSessionStorageSaveHandlerName($handler) $this->assertSame('files', (new NativeSessionStorage([], $handler))->getSaveHandler()->getSaveHandlerName()); } - public function provideNativeSessionStorageHandler() + public static function provideNativeSessionStorageHandler() { return [ [new \SessionHandler()], diff --git a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php index 4a58bca442d15..8f76371e08046 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php @@ -127,12 +127,7 @@ public function testSetNotModified() { $response = new StreamedResponse(function () { echo 'foo'; }); $modified = $response->setNotModified(); - $this->assertObjectHasAttribute('headers', $modified); - $this->assertObjectHasAttribute('content', $modified); - $this->assertObjectHasAttribute('version', $modified); - $this->assertObjectHasAttribute('statusCode', $modified); - $this->assertObjectHasAttribute('statusText', $modified); - $this->assertObjectHasAttribute('charset', $modified); + $this->assertSame($response, $modified); $this->assertEquals(304, $modified->getStatusCode()); ob_start(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php index 7d96f730d7eae..2057dd7097cc8 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php @@ -31,7 +31,7 @@ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) $this->assertEquals($expected, $helper->getAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlData() + public static function getGenerateAbsoluteUrlData() { return [ ['http://localhost/foo.png', '/foo.png', '/foo/bar.html'], @@ -83,7 +83,7 @@ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) $this->assertEquals($path, $helper->getAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlRequestContextData() + public static function getGenerateAbsoluteUrlRequestContextData() { return [ ['/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'], @@ -128,7 +128,7 @@ public function testGenerateRelativePath($expected, $path, $pathinfo) $this->assertEquals($expected, $urlHelper->getRelativePath($path)); } - public function getGenerateRelativePathData() + public static function getGenerateRelativePathData() { return [ ['../foo.png', '/foo.png', '/foo/bar.html'], diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php index 1a9ebc0c3a5d1..0c5b1da36dad4 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php @@ -107,9 +107,9 @@ public function isNullable() /** * Returns the default value of the argument. * - * @throws \LogicException if no default value is present; {@see self::hasDefaultValue()} - * * @return mixed + * + * @throws \LogicException if no default value is present; {@see self::hasDefaultValue()} */ public function getDefaultValue() { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php index 53a1f9e4486b8..3affae298c7c9 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php @@ -100,11 +100,11 @@ private function convertToBytes(string $memoryLimit) switch (substr($memoryLimit, -1)) { case 't': $max *= 1024; - // no break + // no break case 'g': $max *= 1024; - // no break + // no break case 'm': $max *= 1024; - // no break + // no break case 'k': $max *= 1024; } diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 9ac688cc5698f..39d4d3b501653 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -41,7 +41,7 @@ class FileLinkFormatter /** * @param string|array|null $fileLinkFormat - * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand + * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) { diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php index 27749b24b2504..cb994cd77d6f7 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php @@ -72,6 +72,7 @@ public function onKernelRequest(RequestEvent $event) $request->setSessionFactory(function () use (&$sess, $request) { if (!$sess) { $sess = $this->getSession(); + $request->setSession($sess); /* * For supporting sessions in php runtime with runners like roadrunner or swoole, the session diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 446ce2d9df5e4..bd3eb5cd54f19 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -30,7 +30,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer private $charset; /** - * @param string $globalDefaultTemplate The global default content (it can be a template name or the content) + * @param string|null $globalDefaultTemplate The global default content (it can be a template name or the content) */ public function __construct(Environment $twig = null, UriSigner $signer = null, string $globalDefaultTemplate = null, string $charset = 'utf-8') { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 28be364c17bfa..5688fc0c13ccd 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -718,7 +718,11 @@ private function mayServeStaleWhileRevalidate(Response $entry): bool $timeout = $this->options['stale_while_revalidate']; } - return abs($entry->getTtl() ?? 0) < $timeout; + $age = $entry->getAge(); + $maxAge = $entry->getMaxAge() ?? 0; + $ttl = $maxAge - $age; + + return abs($ttl) < $timeout; } /** diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 8087e0cb185f8..5db94f73d68c2 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -197,7 +197,7 @@ public function write(Request $request, Response $response) if ($this->getPath($digest) !== $response->headers->get('X-Body-File')) { throw new \RuntimeException('X-Body-File and X-Content-Digest do not match.'); } - // Everything seems ok, omit writing content to disk + // Everything seems ok, omit writing content to disk } else { $digest = $this->generateContentDigest($response); $response->headers->set('X-Content-Digest', $digest); diff --git a/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php b/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php index 3f3c74a97a64b..557f4e959e4bd 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php @@ -59,8 +59,8 @@ public function needsParsing(Response $response); /** * Renders a Surrogate tag. * - * @param string $alt An alternate URI - * @param string $comment A comment to add as an esi:include tag + * @param string|null $alt An alternate URI + * @param string $comment A comment to add as an esi:include tag * * @return string */ diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index b2ccc7d95a6b8..5f79ffbfbf98b 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,11 +78,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.20'; - public const VERSION_ID = 50420; + public const VERSION = '5.4.21'; + public const VERSION_ID = 50421; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 20; + public const RELEASE_VERSION = 21; public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; @@ -404,9 +404,9 @@ protected function build(ContainerBuilder $container) /** * Gets the container class. * - * @throws \InvalidArgumentException If the generated classname is invalid - * * @return string + * + * @throws \InvalidArgumentException If the generated classname is invalid */ protected function getContainerClass() { diff --git a/src/Symfony/Component/HttpKernel/LICENSE b/src/Symfony/Component/HttpKernel/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/HttpKernel/LICENSE +++ b/src/Symfony/Component/HttpKernel/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php index 9ce7ec467ca8e..9d127436cfe02 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php @@ -149,7 +149,7 @@ public function testInstantiateControllerWhenControllerStartsWithABackslash($con $this->assertSame('action', $controller[1]); } - public function getControllers() + public static function getControllers() { return [ ['\\'.ControllerTestService::class.'::action'], @@ -204,7 +204,7 @@ public function testExceptionWhenUsingRemovedControllerService() $resolver->getController($request); } - public function getUndefinedControllers() + public static function getUndefinedControllers(): array { $tests = parent::getUndefinedControllers(); $tests[0] = ['foo', \InvalidArgumentException::class, 'Controller "foo" does neither exist as service nor as class']; diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 2afcfe4b4edc4..621d948197cb4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -141,7 +141,7 @@ public function testGetControllerWithStaticController($staticController, $return $this->assertSame($returnValue, $controller()); } - public function getStaticControllers() + public static function getStaticControllers() { return [ [TestAbstractController::class.'::staticAction', 'foo'], @@ -165,7 +165,7 @@ public function testGetControllerWithUndefinedController($controller, $exception $resolver->getController($request); } - public function getUndefinedControllers() + public static function getUndefinedControllers() { $controller = new ControllerTest(); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ErrorControllerTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ErrorControllerTest.php index 1b3a833578f4d..12b84aaf9f931 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ErrorControllerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ErrorControllerTest.php @@ -36,7 +36,7 @@ public function testInvokeController(Request $request, \Exception $exception, in self::assertStringContainsString($content, strtr($response->getContent(), ["\n" => '', ' ' => ''])); } - public function getInvokeControllerDataProvider() + public static function getInvokeControllerDataProvider() { yield 'default status code and HTML format' => [ new Request(), diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index bf3fb6552299d..44b740c98b167 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -179,7 +179,7 @@ public function testReset() $c->reset(); } - public function getCollectTestData() + public static function getCollectTestData() { yield 'simple log' => [ 1, diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php index 63dd62ce70392..240f29a88f4f8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php @@ -37,7 +37,7 @@ public function testBytesConversion($limit, $bytes) $this->assertEquals($bytes, $method->invoke($collector, $limit)); } - public function getBytesConversionTestData() + public static function getBytesConversionTestData() { return [ ['2k', 2048], diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index d7c8b302b628a..becb9b01bfd0a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -31,6 +31,7 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector\DummyController; class RequestDataCollectorTest extends TestCase { @@ -91,22 +92,24 @@ public function testControllerInspection($name, $callable, $expected) $this->assertSame($expected, $c->getController()->getValue(true), sprintf('Testing: %s', $name)); } - public function provideControllerCallables() + public static function provideControllerCallables(): array { // make sure we always match the line number - $r1 = new \ReflectionMethod($this, 'testControllerInspection'); - $r2 = new \ReflectionMethod($this, 'staticControllerMethod'); - $r3 = new \ReflectionClass($this); + $controller = new DummyController(); + + $r1 = new \ReflectionMethod($controller, 'regularCallable'); + $r2 = new \ReflectionMethod($controller, 'staticControllerMethod'); + $r3 = new \ReflectionClass($controller); // test name, callable, expected return [ [ '"Regular" callable', - [$this, 'testControllerInspection'], + [$controller, 'regularCallable'], [ - 'class' => self::class, - 'method' => 'testControllerInspection', - 'file' => __FILE__, + 'class' => DummyController::class, + 'method' => 'regularCallable', + 'file' => $r1->getFileName(), 'line' => $r1->getStartLine(), ], ], @@ -122,44 +125,55 @@ function () { return 'foo'; }, ], ], + [ + 'First-class callable closure', + \PHP_VERSION_ID >= 80100 ? eval('return $controller->regularCallable(...);') : [$controller, 'regularCallable'], + [ + 'class' => DummyController::class, + 'method' => 'regularCallable', + 'file' => $r1->getFileName(), + 'line' => $r1->getStartLine(), + ], + ], + [ 'Static callback as string', - __NAMESPACE__.'\RequestDataCollectorTest::staticControllerMethod', + DummyController::class.'::staticControllerMethod', [ - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'class' => DummyController::class, 'method' => 'staticControllerMethod', - 'file' => __FILE__, + 'file' => $r2->getFileName(), 'line' => $r2->getStartLine(), ], ], [ 'Static callable with instance', - [$this, 'staticControllerMethod'], + [$controller, 'staticControllerMethod'], [ - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'class' => DummyController::class, 'method' => 'staticControllerMethod', - 'file' => __FILE__, + 'file' => $r2->getFileName(), 'line' => $r2->getStartLine(), ], ], [ 'Static callable with class name', - ['Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'staticControllerMethod'], + [DummyController::class, 'staticControllerMethod'], [ - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'class' => DummyController::class, 'method' => 'staticControllerMethod', - 'file' => __FILE__, + 'file' => $r2->getFileName(), 'line' => $r2->getStartLine(), ], ], [ 'Callable with instance depending on __call()', - [$this, 'magicMethod'], + [$controller, 'magicMethod'], [ - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'class' => DummyController::class, 'method' => 'magicMethod', 'file' => 'n/a', 'line' => 'n/a', @@ -168,9 +182,9 @@ function () { return 'foo'; }, [ 'Callable with class name depending on __callStatic()', - ['Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'magicMethod'], + [DummyController::class, 'magicMethod'], [ - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'class' => DummyController::class, 'method' => 'magicMethod', 'file' => 'n/a', 'line' => 'n/a', @@ -179,11 +193,11 @@ function () { return 'foo'; }, [ 'Invokable controller', - $this, + $controller, [ - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', + 'class' => DummyController::class, 'method' => null, - 'file' => __FILE__, + 'file' => $r3->getFileName(), 'line' => $r3->getStartLine(), ], ], @@ -390,35 +404,6 @@ protected function injectController($collector, $controller, $request) $collector->onKernelController($event); } - /** - * Dummy method used as controller callable. - */ - public static function staticControllerMethod() - { - throw new \LogicException('Unexpected method call'); - } - - /** - * Magic method to allow non existing methods to be called and delegated. - */ - public function __call(string $method, array $args) - { - throw new \LogicException('Unexpected method call'); - } - - /** - * Magic method to allow non existing methods to be called and delegated. - */ - public static function __callStatic(string $method, array $args) - { - throw new \LogicException('Unexpected method call'); - } - - public function __invoke() - { - throw new \LogicException('Unexpected method call'); - } - private function getCookieByName(Response $response, $name) { foreach ($response->headers->getCookies() as $cookie) { @@ -445,7 +430,7 @@ public function testIsJson($contentType, $expected) $this->assertSame($expected, $c->isJsonRequest()); } - public function provideJsonContentTypes() + public static function provideJsonContentTypes(): array { return [ ['text/csv', false], @@ -472,7 +457,7 @@ public function testGetPrettyJsonValidity($content, $expected) $this->assertSame($expected, $c->getPrettyJson()); } - public function providePrettyJson() + public static function providePrettyJson(): array { return [ ['null', 'null'], diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index a8fdd7975beba..69e1cc8cd6ce2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -308,7 +308,7 @@ public function testBindings($bindingName) $this->assertEquals($expected, $locator->getArgument(0)); } - public function provideBindings() + public static function provideBindings() { return [ [ControllerDummy::class.'$bar'], @@ -343,7 +343,7 @@ public function testBindScalarValueToControllerArgument($bindingKey) $this->assertSame('foo_val', $locator->get('foo::fooAction')->get('someArg')); } - public function provideBindScalarValueToControllerArgument() + public static function provideBindScalarValueToControllerArgument() { yield ['$someArg']; yield ['string $someArg']; diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index c8581927a86a5..81a84e92f17ee 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -157,7 +157,7 @@ public function testReplaceExistingExceptionHandler() $this->assertSame($userHandler, $eHandler->setExceptionHandler('var_dump')); } - public function provideLevelsAssignedToLoggers(): array + public static function provideLevelsAssignedToLoggers(): array { return [ [false, false, '0', null, null], diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php index 8ceb910b5b372..b0263f8f29a0b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php @@ -36,7 +36,7 @@ public function testInvoke(?string $expected, array $responseArgs) $this->assertSame($expected, $response->headers->get('X-Robots-Tag'), 'Header doesn\'t match expectations'); } - public function provideResponses(): iterable + public static function provideResponses(): iterable { yield 'No header' => ['noindex', []]; diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php index 73cc19afc8c6b..b97737218c1b2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php @@ -119,7 +119,7 @@ public function testHandleWithLoggerAndCustomConfiguration() $this->assertCount(1, $logger->getLogs('warning')); } - public function provider() + public static function provider() { if (!class_exists(Request::class)) { return [[null, null]]; @@ -202,7 +202,7 @@ public function testOnControllerArguments(callable $controller) $this->assertSame('OK: foo', $event->getResponse()->getContent()); } - public function controllerProvider() + public static function controllerProvider() { yield [function (FlattenException $exception) { return new Response('OK: '.$exception->getMessage()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 45272ceb026cd..57f8f53b1e9f7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -87,7 +87,7 @@ public function testCollectParameter(Request $request, ?bool $enable) $listener->onKernelResponse(new ResponseEvent($kernel, $request, Kernel::MAIN_REQUEST, $response)); } - public function collectRequestProvider(): iterable + public static function collectRequestProvider(): iterable { yield [Request::create('/'), null]; yield [Request::create('/', 'GET', ['profile' => '1']), true]; diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index e61414bd041f6..886fe497f3b63 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -67,7 +67,7 @@ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHtt $this->assertEquals(str_starts_with($uri, 'https') ? 'https' : 'http', $context->getScheme()); } - public function getPortData() + public static function getPortData() { return [ [80, 443, 'http://localhost/', 80, 443], @@ -157,7 +157,7 @@ public function testLoggingParameter($parameter, $log, $parameters) $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); } - public function getLoggingParameterData() + public static function getLoggingParameterData() { return [ [['_route' => 'foo'], 'Matched route "{route}".', ['route' => 'foo', 'route_parameters' => ['_route' => 'foo'], 'request_uri' => 'http://localhost/', 'method' => 'GET']], diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php index 96f66354ba7e4..f3265823a5765 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php @@ -82,7 +82,7 @@ public function testSessionCookieOptions(array $phpSessionOptions, array $sessio } } - public function provideSessionOptions(): \Generator + public static function provideSessionOptions(): \Generator { if (\PHP_VERSION_ID > 70300) { yield 'set_samesite_by_php' => [ @@ -590,6 +590,30 @@ public function testResponseHeadersMaxAgeAndExpiresDefaultValuesIfSessionStarted $this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER)); } + public function testPrivateResponseMaxAgeIsRespectedIfSessionStarted() + { + $kernel = $this->createMock(HttpKernelInterface::class); + + $session = $this->createMock(Session::class); + $session->expects($this->once())->method('getUsageIndex')->willReturn(1); + $request = new Request([], [], [], [], [], ['SERVER_PROTOCOL' => 'HTTP/1.0']); + $request->setSession($session); + + $response = new Response(); + $response->headers->set('Cache-Control', 'no-cache'); + $response->prepare($request); + + $listener = new SessionListener(new Container()); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response)); + + $this->assertSame(0, $response->getMaxAge()); + $this->assertFalse($response->headers->hasCacheControlDirective('public')); + $this->assertTrue($response->headers->hasCacheControlDirective('private')); + $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate')); + $this->assertLessThanOrEqual(new \DateTimeImmutable('now', new \DateTimeZone('UTC')), new \DateTimeImmutable($response->headers->get('Expires'))); + $this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER)); + } + public function testSurrogateMainRequestIsPublic() { $session = $this->createMock(Session::class); @@ -667,6 +691,27 @@ public function testGetSessionIsCalledOnce() $subRequest->getSession(); } + public function testGetSessionSetsSessionOnMainRequest() + { + $mainRequest = new Request(); + $listener = $this->createListener($mainRequest, new NativeSessionStorageFactory()); + + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $mainRequest, HttpKernelInterface::MAIN_REQUEST); + $listener->onKernelRequest($event); + + $this->assertFalse($mainRequest->hasSession(true)); + + $subRequest = $mainRequest->duplicate(); + + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); + $listener->onKernelRequest($event); + + $session = $subRequest->getSession(); + + $this->assertTrue($mainRequest->hasSession(true)); + $this->assertSame($session, $mainRequest->getSession()); + } + public function testSessionUsageExceptionIfStatelessAndSessionUsed() { $session = $this->createMock(Session::class); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index 3bb76970621c3..bb989b33023eb 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -28,6 +28,7 @@ * Tests SessionListener. * * @author Bulat Shakirzyanov + * * @group legacy */ class TestSessionListenerTest extends TestCase @@ -130,7 +131,7 @@ public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie( $this->assertSame($expected, $response->headers->all()['set-cookie']); } - public function anotherCookieProvider() + public static function anotherCookieProvider() { return [ 'same' => ['MOCKSESSID=789; path=/', ['MOCKSESSID=789; path=/']], diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php index feaec807fd95c..fad9e796f439b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php @@ -16,7 +16,7 @@ class HttpExceptionTest extends TestCase { - public function headerDataProvider() + public static function headerDataProvider() { return [ [['X-Test' => 'Test']], diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/DummyController.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/DummyController.php new file mode 100644 index 0000000000000..611c41d3e8c77 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/DummyController.php @@ -0,0 +1,49 @@ + + * + * 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\DataCollector; + +class DummyController +{ + /** + * Dummy method used as controller callable. + */ + public static function staticControllerMethod() + { + throw new \LogicException('Unexpected method call'); + } + + /** + * Magic method to allow non existing methods to be called and delegated. + */ + public function __call(string $method, array $args) + { + throw new \LogicException('Unexpected method call'); + } + + /** + * Magic method to allow non existing methods to be called and delegated. + */ + public static function __callStatic(string $method, array $args) + { + throw new \LogicException('Unexpected method call'); + } + + public function __invoke() + { + throw new \LogicException('Unexpected method call'); + } + + public function regularCallable() + { + throw new \LogicException('Unexpected method call'); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php index d17643c18675d..937c23d869d8c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php @@ -34,7 +34,7 @@ public function testGenerateAbsoluteFragmentUri($uri, $controller) $this->assertEquals('http://localhost'.$uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'), true)); } - public function getGenerateFragmentUriData() + public static function getGenerateFragmentUriData() { return [ ['/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', [], [])], @@ -65,7 +65,7 @@ public function testGenerateFragmentUriWithNonScalar($controller) $this->callGenerateFragmentUriMethod($controller, Request::create('/')); } - public function getGenerateFragmentUriDataWithNonScalar() + public static function getGenerateFragmentUriDataWithNonScalar() { return [ [new ControllerReference('controller', ['foo' => new Foo(), 'bar' => 'bar'], [])], diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 7d8ef79187412..22cf88daa2b51 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1378,7 +1378,7 @@ public function testHttpCacheIsSetAsATrustedProxy(array $existing) Request::setTrustedProxies([], -1); } - public function getTrustedProxyData() + public static function getTrustedProxyData() { return [ [[]], @@ -1407,7 +1407,7 @@ public function testForwarderHeaderForForwardedRequests($forwarded, $expected) Request::setTrustedProxies([], -1); } - public function getForwardedData() + public static function getForwardedData() { return [ [null, 'for="10.0.0.1";host="localhost";proto=http'], @@ -1599,7 +1599,7 @@ public function testResponsesThatMayBeUsedStaleIfError($responseHeaders, $sleepB $this->assertTraceContains('stale-if-error'); } - public function getResponseDataThatMayBeServedStaleIfError() + public static function getResponseDataThatMayBeServedStaleIfError() { // All data sets assume that a 10s stale-if-error grace period has been configured yield 'public, max-age expired' => [['Cache-Control' => 'public, max-age=60'], 65]; @@ -1641,7 +1641,7 @@ public function testResponsesThatMustNotBeUsedStaleIfError($responseHeaders, $sl $this->assertEquals(500, $this->response->getStatusCode()); } - public function getResponseDataThatMustNotBeServedStaleIfError() + public static function getResponseDataThatMustNotBeServedStaleIfError() { // All data sets assume that a 10s stale-if-error grace period has been configured yield 'public, no TTL but beyond grace period' => [['Cache-Control' => 'public'], 15]; diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php index fa0ad5d311ed5..c5c510f85832e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -240,6 +240,7 @@ public function testResponseIsExpirableButNotValidateableWhenMainResponseCombine /** * @group time-sensitive + * * @dataProvider cacheControlMergingProvider */ public function testCacheControlMerging(array $expects, array $master, array $surrogates) @@ -309,7 +310,7 @@ public function testCacheControlMerging(array $expects, array $master, array $su } } - public function cacheControlMergingProvider() + public static function cacheControlMergingProvider() { yield 'result is public if all responses are public' => [ ['private' => false, 'public' => true], diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php index 157c4d7455b5a..8dfc472d23213 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php @@ -107,7 +107,7 @@ public function testProcess() $response = new Response('foo '); $ssi->process($request, $response); - $this->assertEquals("foo surrogate->handle(\$this, 'foo\\'', '', false) ?>"."\n", $response->getContent()); + $this->assertEquals("foo surrogate->handle(\$this, 'foo\\'', '', false) ?>\n", $response->getContent()); } public function testProcessEscapesPhpTags() diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 38a09ef2d2f8b..0a1dc60e4a39d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -175,7 +175,7 @@ public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($expec $this->assertEquals($expectedStatusCode, $response->getStatusCode()); } - public function getSpecificStatusCodes() + public static function getSpecificStatusCodes() { return [ [200], diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 2dab2ec01d9f1..fa2074694ee99 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -256,7 +256,7 @@ public function testStripComments(string $source, string $expected) $this->assertEquals($expected, $output); } - public function getStripCommentsCodes(): array + public static function getStripCommentsCodes(): array { return [ ['assertLogsMatch($expected, $this->getLogs()); } - public function provideLevelsAndMessages() + public static function provideLevelsAndMessages() { return [ LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 09682db49d2e6..180a79b336adc 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -20,7 +20,7 @@ "symfony/deprecation-contracts": "^2.1|^3", "symfony/error-handler": "^4.4|^5.0|^6.0", "symfony/event-dispatcher": "^5.0|^6.0", - "symfony/http-foundation": "^5.3.7|^6.0", + "symfony/http-foundation": "^5.4.21|^6.2.7", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.16", diff --git a/src/Symfony/Component/Inflector/LICENSE b/src/Symfony/Component/Inflector/LICENSE index 7c46c8b000078..790e02ecd4ebc 100644 --- a/src/Symfony/Component/Inflector/LICENSE +++ b/src/Symfony/Component/Inflector/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012-2023 Fabien Potencier +Copyright (c) 2012-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Inflector/Tests/InflectorTest.php b/src/Symfony/Component/Inflector/Tests/InflectorTest.php index 1f8cf4467455c..0702c717e3495 100644 --- a/src/Symfony/Component/Inflector/Tests/InflectorTest.php +++ b/src/Symfony/Component/Inflector/Tests/InflectorTest.php @@ -19,7 +19,7 @@ */ class InflectorTest extends TestCase { - public function singularizeProvider() + public static function singularizeProvider() { // see http://english-zone.com/spelling/plurals.html // see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English @@ -169,7 +169,7 @@ public function singularizeProvider() ]; } - public function pluralizeProvider() + public static function pluralizeProvider() { // see http://english-zone.com/spelling/plurals.html // see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php index 54dcbfe25d24d..a9734ac0a960e 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php @@ -25,8 +25,8 @@ abstract class HourTransformer extends Transformer /** * Returns a normalized hour value suitable for the hour transformer type. * - * @param int $hour The hour value - * @param string $marker An optional AM/PM marker + * @param int $hour The hour value + * @param string|null $marker An optional AM/PM marker * * @return int The normalized hour value */ diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 5b683c4c7cabf..86257898c1d81 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -124,7 +124,7 @@ abstract class IntlDateFormatter * @param int|null $datetype Type of date formatting, one of the format type constants * @param int|null $timetype Type of time formatting, one of the format type constants * @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier - * @param int $calendar Calendar to use for formatting or parsing. The only currently + * @param int|null $calendar Calendar to use for formatting or parsing. The only currently * supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN") * @param string|null $pattern Optional pattern to use when formatting * @@ -418,11 +418,11 @@ public function localtime(string $value, int &$position = 0) /** * Parse string to a timestamp value. * - * @param string $value String to convert to a time value - * @param int $position Not supported. Position at which to start the parsing in $value (zero-based) - * If no error occurs before $value is consumed, $parse_pos will - * contain -1 otherwise it will contain the position at which parsing - * ended. If $parse_pos > strlen($value), the parse fails immediately. + * @param string $value String to convert to a time value + * @param int|null $position Not supported. Position at which to start the parsing in $value (zero-based) + * If no error occurs before $value is consumed, $parse_pos will + * contain -1 otherwise it will contain the position at which parsing + * ended. If $parse_pos > strlen($value), the parse fails immediately. * * @return int|false Parsed value as a timestamp * @@ -494,7 +494,7 @@ public function setLenient(bool $lenient) /** * Set the formatter's pattern. * - * @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation + * @param string|null $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation * * @return bool true on success or false on failure * diff --git a/src/Symfony/Component/Intl/LICENSE b/src/Symfony/Component/Intl/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Intl/LICENSE +++ b/src/Symfony/Component/Intl/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Intl/Locale/Locale.php b/src/Symfony/Component/Intl/Locale/Locale.php index 79d2f079491fa..d8066714a017d 100644 --- a/src/Symfony/Component/Intl/Locale/Locale.php +++ b/src/Symfony/Component/Intl/Locale/Locale.php @@ -152,8 +152,8 @@ public static function getDefault() /** * Not supported. Returns the localized display name for the locale language. * - * @param string $locale The locale code to return the display language from - * @param string $inLocale Optional format locale code to use to display the language name + * @param string $locale The locale code to return the display language from + * @param string|null $inLocale Optional format locale code to use to display the language name * * @return string * @@ -169,8 +169,8 @@ public static function getDisplayLanguage(string $locale, string $inLocale = nul /** * Not supported. Returns the localized display name for the locale. * - * @param string $locale The locale code to return the display locale name from - * @param string $inLocale Optional format locale code to use to display the locale name + * @param string $locale The locale code to return the display locale name from + * @param string|null $inLocale Optional format locale code to use to display the locale name * * @return string * @@ -186,8 +186,8 @@ public static function getDisplayName(string $locale, string $inLocale = null) /** * Not supported. Returns the localized display name for the locale region. * - * @param string $locale The locale code to return the display region from - * @param string $inLocale Optional format locale code to use to display the region name + * @param string $locale The locale code to return the display region from + * @param string|null $inLocale Optional format locale code to use to display the region name * * @return string * @@ -203,8 +203,8 @@ public static function getDisplayRegion(string $locale, string $inLocale = null) /** * Not supported. Returns the localized display name for the locale script. * - * @param string $locale The locale code to return the display script from - * @param string $inLocale Optional format locale code to use to display the script name + * @param string $locale The locale code to return the display script from + * @param string|null $inLocale Optional format locale code to use to display the script name * * @return string * @@ -220,8 +220,8 @@ public static function getDisplayScript(string $locale, string $inLocale = null) /** * Not supported. Returns the localized display name for the locale variant. * - * @param string $locale The locale code to return the display variant from - * @param string $inLocale Optional format locale code to use to display the variant name + * @param string $locale The locale code to return the display variant from + * @param string|null $inLocale Optional format locale code to use to display the variant name * * @return string * @@ -301,10 +301,10 @@ public static function getScript(string $locale) /** * Not supported. Returns the closest language tag for the locale. * - * @param array $langtag A list of the language tags to compare to locale - * @param string $locale The locale to use as the language range when matching - * @param bool $canonicalize If true, the arguments will be converted to canonical form before matching - * @param string $default The locale to use if no match is found + * @param array $langtag A list of the language tags to compare to locale + * @param string $locale The locale to use as the language range when matching + * @param bool $canonicalize If true, the arguments will be converted to canonical form before matching + * @param string|null $default The locale to use if no match is found * * @see https://php.net/locale.lookup * diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 2a369c2726434..b573f639308e3 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -244,10 +244,10 @@ abstract class NumberFormatter /** * @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en") - * @param int $style Style of the formatting, one of the format style constants. + * @param int|null $style Style of the formatting, one of the format style constants. * The only supported styles are NumberFormatter::DECIMAL * and NumberFormatter::CURRENCY. - * @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or + * @param string|null $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or * NumberFormat::PATTERN_RULEBASED. It must conform to the syntax * described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation * @@ -281,10 +281,10 @@ public function __construct(?string $locale = 'en', int $style = null, string $p * Static constructor. * * @param string|null $locale The locale code. The only supported locale is "en" (or null using the default locale, i.e. "en") - * @param int $style Style of the formatting, one of the format style constants. + * @param int|null $style Style of the formatting, one of the format style constants. * The only currently supported styles are NumberFormatter::DECIMAL * and NumberFormatter::CURRENCY. - * @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or + * @param string|null $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or * NumberFormat::PATTERN_RULEBASED. It must conform to the syntax * described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation * @@ -485,9 +485,9 @@ public function getTextAttribute(int $attr) /** * Not supported. Parse a currency number. * - * @param string $value The value to parse - * @param string $currency Parameter to receive the currency name (reference) - * @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended + * @param string $value The value to parse + * @param string $currency Parameter to receive the currency name (reference) + * @param int|null $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended * * @return float|false The parsed numeric value or false on error * diff --git a/src/Symfony/Component/Intl/ResourceBundle.php b/src/Symfony/Component/Intl/ResourceBundle.php index 4f2ee32d2ed2d..c0ef5d1e8e7d1 100644 --- a/src/Symfony/Component/Intl/ResourceBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle.php @@ -32,13 +32,13 @@ abstract protected static function getPath(): string; * * @see BundleEntryReaderInterface::readEntry() * - * @param string[] $indices The indices to read from the bundle - * @param string $locale The locale to read - * @param bool $fallback Whether to merge the value with the value from - * the fallback locale (e.g. "en" for "en_GB"). - * Only applicable if the result is multivalued - * (i.e. array or \ArrayAccess) or cannot be found - * in the requested locale. + * @param string[] $indices The indices to read from the bundle + * @param string|null $locale The locale to read + * @param bool $fallback Whether to merge the value with the value from + * the fallback locale (e.g. "en" for "en_GB"). + * Only applicable if the result is multivalued + * (i.e. array or \ArrayAccess) or cannot be found + * in the requested locale. * * @return mixed returns an array or {@link \ArrayAccess} instance for * complex data and a scalar value for simple data diff --git a/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTestCase.php similarity index 93% rename from src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php rename to src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTestCase.php index b2931f65e111d..11180c00e3325 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTestCase.php @@ -19,7 +19,7 @@ * * @author Bernhard Schussek */ -abstract class AbstractCollatorTest extends TestCase +abstract class AbstractCollatorTestCase extends TestCase { /** * @dataProvider asortProvider @@ -31,7 +31,7 @@ public function testAsort($array, $sortFlag, $expected) $this->assertSame($expected, $array); } - public function asortProvider() + public static function asortProvider() { return [ /* array, sortFlag, expected */ diff --git a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php index 495b01a983dae..b09ef560e395c 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php @@ -19,7 +19,7 @@ /** * @group legacy */ -class CollatorTest extends AbstractCollatorTest +class CollatorTest extends AbstractCollatorTestCase { public function testConstructorWithUnsupportedLocale() { diff --git a/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php index bb376e504e130..5b598f5e6c430 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php @@ -11,16 +11,16 @@ namespace Symfony\Component\Intl\Tests\Collator\Verification; -use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest; +use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTestCase; use Symfony\Component\Intl\Util\IntlTestHelper; /** - * Verifies that {@link AbstractCollatorTest} matches the behavior of the + * Verifies that {@link AbstractCollatorTestCase} matches the behavior of the * {@link \Collator} class in a specific version of ICU. * * @author Bernhard Schussek */ -class CollatorTest extends AbstractCollatorTest +class CollatorTest extends AbstractCollatorTestCase { protected function setUp(): void { diff --git a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php index 94453f3278731..5cbf0aeb87c65 100644 --- a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php +++ b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php @@ -674,7 +674,7 @@ public function testGetSymbol($displayLocale) } } - public function provideCurrencies() + public static function provideCurrencies() { return array_map( function ($currency) { return [$currency]; }, @@ -701,7 +701,7 @@ public function testGetRoundingIncrement($currency) $this->assertIsNumeric(Currencies::getRoundingIncrement($currency)); } - public function provideCurrenciesWithNumericEquivalent() + public static function provideCurrenciesWithNumericEquivalent() { return array_map( function ($value) { return [$value]; }, @@ -717,7 +717,7 @@ public function testGetNumericCode($currency) $this->assertSame(self::ALPHA3_TO_NUMERIC[$currency], Currencies::getNumericCode($currency)); } - public function provideCurrenciesWithoutNumericEquivalent() + public static function provideCurrenciesWithoutNumericEquivalent() { return array_map( function ($value) { return [$value]; }, @@ -734,7 +734,7 @@ public function testGetNumericCodeFailsIfNoNumericEquivalent($currency) Currencies::getNumericCode($currency); } - public function provideValidNumericCodes() + public static function provideValidNumericCodes() { $numericToAlpha3 = $this->getNumericToAlpha3Mapping(); @@ -759,7 +759,7 @@ public function testForNumericCode($numeric, $expected) $this->assertSame($expected, $actual); } - public function provideInvalidNumericCodes() + public static function provideInvalidNumericCodes() { $validNumericCodes = array_keys($this->getNumericToAlpha3Mapping()); $invalidNumericCodes = array_diff(range(0, 1000), $validNumericCodes); 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 bd1ba59f21937..267857bc78c0e 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php @@ -165,7 +165,7 @@ public function testDontFallbackIfLocaleDoesNotExistAndFallbackDisabled() $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'], false); } - public function provideMergeableValues() + public static function provideMergeableValues() { return [ ['foo', null, 'foo'], diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php index 2861c91bc8711..6b3a461a9c5f3 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -18,6 +18,7 @@ /** * @author Bernhard Schussek + * * @requires extension intl */ class IntlBundleReaderTest extends TestCase diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTestCase.php similarity index 93% rename from src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php rename to src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTestCase.php index c6328ab20e24e..02f8264752d53 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTestCase.php @@ -24,7 +24,7 @@ * * @group legacy */ -abstract class AbstractIntlDateFormatterTest extends TestCase +abstract class AbstractIntlDateFormatterTestCase extends TestCase { private $defaultLocale; @@ -91,7 +91,7 @@ public function testFormat($pattern, $timestamp, $expected) $this->assertIsIntlSuccess($formatter, $errorMessage, $errorCode); } - public function formatProvider() + public static function formatProvider() { $dateTime = new \DateTime('@0'); $dateTimeImmutable = new \DateTimeImmutable('@0'); @@ -316,7 +316,7 @@ public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessa $this->assertIsIntlFailure($formatter, $errorMessage, $errorCode); } - public function formatErrorProvider() + public static function formatErrorProvider() { return [ ['y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR'], @@ -333,7 +333,7 @@ public function testFormatWithTimezone($timestamp, $timezone, $expected) $this->assertSame($expected, $formatter->format($timestamp)); } - public function formatWithTimezoneProvider() + public static function formatWithTimezoneProvider() { $data = [ [0, 'UTC', '1970-01-01 00:00:00'], @@ -379,7 +379,7 @@ public function testFormatTimezone($pattern, $timezone, $expected) $this->assertEquals($expected, $formatter->format(0)); } - public function formatTimezoneProvider() + public static function formatTimezoneProvider() { return [ ['z', 'GMT', 'GMT'], @@ -528,7 +528,7 @@ public function testDateAndTimeType($timestamp, $datetype, $timetype, $expected) $this->assertSame($expected, $formatter->format($timestamp)); } - public function dateAndTimeTypeProvider() + public static function dateAndTimeTypeProvider() { return [ [0, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Thursday, January 1, 1970'], @@ -585,32 +585,32 @@ public function testParse($pattern, $value, $expected) $this->assertIsIntlSuccess($formatter, $errorMessage, $errorCode); } - public function parseProvider() + public static function parseProvider() { return array_merge( - $this->parseYearProvider(), - $this->parseQuarterProvider(), - $this->parseMonthProvider(), - $this->parseStandaloneMonthProvider(), - $this->parseDayProvider(), - $this->parseDayOfWeekProvider(), - $this->parseDayOfYearProvider(), - $this->parseHour12ClockOneBasedProvider(), - $this->parseHour12ClockZeroBasedProvider(), - $this->parseHour24ClockOneBasedProvider(), - $this->parseHour24ClockZeroBasedProvider(), - $this->parseMinuteProvider(), - $this->parseSecondProvider(), - $this->parseTimezoneProvider(), - $this->parseAmPmProvider(), - $this->parseStandaloneAmPmProvider(), - $this->parseRegexMetaCharsProvider(), - $this->parseQuoteCharsProvider(), - $this->parseDashSlashProvider() + static::parseYearProvider(), + static::parseQuarterProvider(), + static::parseMonthProvider(), + static::parseStandaloneMonthProvider(), + static::parseDayProvider(), + static::parseDayOfWeekProvider(), + static::parseDayOfYearProvider(), + static::parseHour12ClockOneBasedProvider(), + static::parseHour12ClockZeroBasedProvider(), + static::parseHour24ClockOneBasedProvider(), + static::parseHour24ClockZeroBasedProvider(), + static::parseMinuteProvider(), + static::parseSecondProvider(), + static::parseTimezoneProvider(), + static::parseAmPmProvider(), + static::parseStandaloneAmPmProvider(), + static::parseRegexMetaCharsProvider(), + static::parseQuoteCharsProvider(), + static::parseDashSlashProvider() ); } - public function parseYearProvider() + public static function parseYearProvider() { return [ ['y-M-d', '1970-1-1', 0], @@ -618,7 +618,7 @@ public function parseYearProvider() ]; } - public function parseQuarterProvider() + public static function parseQuarterProvider() { return [ ['Q', '1', 0], @@ -641,7 +641,7 @@ public function parseQuarterProvider() ]; } - public function parseMonthProvider() + public static function parseMonthProvider() { return [ ['y-M-d', '1970-1-1', 0], @@ -651,7 +651,7 @@ public function parseMonthProvider() ]; } - public function parseStandaloneMonthProvider() + public static function parseStandaloneMonthProvider() { return [ ['y-L-d', '1970-1-1', 0], @@ -660,7 +660,7 @@ public function parseStandaloneMonthProvider() ]; } - public function parseDayProvider() + public static function parseDayProvider() { return [ ['y-M-d', '1970-1-1', 0], @@ -670,7 +670,7 @@ public function parseDayProvider() ]; } - public function parseDayOfWeekProvider() + public static function parseDayOfWeekProvider() { return [ ['E', 'Thu', 0], @@ -682,7 +682,7 @@ public function parseDayOfWeekProvider() ]; } - public function parseDayOfYearProvider() + public static function parseDayOfYearProvider() { return [ ['D', '1', 0], @@ -690,7 +690,7 @@ public function parseDayOfYearProvider() ]; } - public function parseHour12ClockOneBasedProvider() + public static function parseHour12ClockOneBasedProvider() { return [ // 12 hours (1-12) @@ -715,7 +715,7 @@ public function parseHour12ClockOneBasedProvider() ]; } - public function parseHour12ClockZeroBasedProvider() + public static function parseHour12ClockZeroBasedProvider() { return [ // 12 hours (0-11) @@ -740,7 +740,7 @@ public function parseHour12ClockZeroBasedProvider() ]; } - public function parseHour24ClockOneBasedProvider() + public static function parseHour24ClockOneBasedProvider() { return [ // 24 hours (1-24) @@ -767,7 +767,7 @@ public function parseHour24ClockOneBasedProvider() ]; } - public function parseHour24ClockZeroBasedProvider() + public static function parseHour24ClockZeroBasedProvider() { return [ // 24 hours (0-23) @@ -794,7 +794,7 @@ public function parseHour24ClockZeroBasedProvider() ]; } - public function parseMinuteProvider() + public static function parseMinuteProvider() { return [ ['y-M-d HH:m', '1970-1-1 0:1', 60], @@ -802,7 +802,7 @@ public function parseMinuteProvider() ]; } - public function parseSecondProvider() + public static function parseSecondProvider() { return [ ['y-M-d HH:mm:s', '1970-1-1 00:01:1', 61], @@ -810,7 +810,7 @@ public function parseSecondProvider() ]; } - public function parseTimezoneProvider() + public static function parseTimezoneProvider() { if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) { return [['y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0]]; @@ -830,7 +830,7 @@ public function parseTimezoneProvider() ]; } - public function parseAmPmProvider() + public static function parseAmPmProvider() { return [ // AM/PM (already covered by hours tests) @@ -839,7 +839,7 @@ public function parseAmPmProvider() ]; } - public function parseStandaloneAmPmProvider() + public static function parseStandaloneAmPmProvider() { return [ ['a', 'AM', 0], @@ -847,7 +847,7 @@ public function parseStandaloneAmPmProvider() ]; } - public function parseRegexMetaCharsProvider() + public static function parseRegexMetaCharsProvider() { return [ // regexp meta chars in the pattern string @@ -856,7 +856,7 @@ public function parseRegexMetaCharsProvider() ]; } - public function parseQuoteCharsProvider() + public static function parseQuoteCharsProvider() { return [ ["'M'", 'M', 0], @@ -867,7 +867,7 @@ public function parseQuoteCharsProvider() ]; } - public function parseDashSlashProvider() + public static function parseDashSlashProvider() { return [ ['y-M-d', '1970/1/1', 0], @@ -890,7 +890,7 @@ public function testParseError($pattern, $value) $this->assertIsIntlFailure($formatter, $errorMessage, $errorCode); } - public function parseErrorProvider() + public static function parseErrorProvider() { return [ // 1 char month @@ -945,7 +945,7 @@ public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId) $this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId()); } - public function setTimeZoneIdProvider() + public static function setTimeZoneIdProvider() { return [ ['UTC', 'UTC'], diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 9113403fa1128..8f5299a9ba7c0 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -21,7 +21,7 @@ /** * @group legacy */ -class IntlDateFormatterTest extends AbstractIntlDateFormatterTest +class IntlDateFormatterTest extends AbstractIntlDateFormatterTestCase { public function testConstructor() { @@ -153,24 +153,24 @@ public function testFormatWithNonStandardTimezone() parent::testFormatWithNonStandardTimezone(); } - public function parseStandaloneAmPmProvider() + public static function parseStandaloneAmPmProvider() { - return $this->notImplemented(parent::parseStandaloneAmPmProvider()); + return self::notImplemented(parent::parseStandaloneAmPmProvider()); } - public function parseDayOfWeekProvider() + public static function parseDayOfWeekProvider() { - return $this->notImplemented(parent::parseDayOfWeekProvider()); + return self::notImplemented(parent::parseDayOfWeekProvider()); } - public function parseDayOfYearProvider() + public static function parseDayOfYearProvider() { - return $this->notImplemented(parent::parseDayOfYearProvider()); + return self::notImplemented(parent::parseDayOfYearProvider()); } - public function parseQuarterProvider() + public static function parseQuarterProvider() { - return $this->notImplemented(parent::parseQuarterProvider()); + return self::notImplemented(parent::parseQuarterProvider()); } public function testParseThreeDigitsYears() @@ -221,7 +221,7 @@ protected function isIntlFailure($errorCode): bool * + 10 seconds) are added, then we have 86,400 seconds (24h * 60min * 60s) * + 10 seconds */ - private function notImplemented(array $dataSets): array + private static function notImplemented(array $dataSets): array { return array_map(function (array $row) { return [$row[0], $row[1], 0]; diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php index ff8e9971ce5de..062aed754bc1e 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php @@ -12,16 +12,16 @@ namespace Symfony\Component\Intl\Tests\DateFormatter\Verification; use Symfony\Component\Intl\DateFormatter\IntlDateFormatter; -use Symfony\Component\Intl\Tests\DateFormatter\AbstractIntlDateFormatterTest; +use Symfony\Component\Intl\Tests\DateFormatter\AbstractIntlDateFormatterTestCase; use Symfony\Component\Intl\Util\IntlTestHelper; /** - * Verifies that {@link AbstractIntlDateFormatterTest} matches the behavior of + * Verifies that {@link AbstractIntlDateFormatterTestCase} matches the behavior of * the {@link \IntlDateFormatter} class in a specific version of ICU. * * @author Bernhard Schussek */ -class IntlDateFormatterTest extends AbstractIntlDateFormatterTest +class IntlDateFormatterTest extends AbstractIntlDateFormatterTestCase { protected function setUp(): void { diff --git a/src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php b/src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTestCase.php similarity index 89% rename from src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php rename to src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTestCase.php index 5c4731babd8d2..f28f8d44e17f7 100644 --- a/src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php +++ b/src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTestCase.php @@ -20,9 +20,9 @@ * * @group legacy */ -abstract class AbstractIntlGlobalsTest extends TestCase +abstract class AbstractIntlGlobalsTestCase extends TestCase { - public function errorNameProvider() + public static function errorNameProvider() { return [ [-129, '[BOGUS UErrorCode]'], diff --git a/src/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php b/src/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php index 27400e65fd74c..5ce1c5ef63ce7 100644 --- a/src/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php +++ b/src/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php @@ -16,7 +16,7 @@ /** * @group legacy */ -class IntlGlobalsTest extends AbstractIntlGlobalsTest +class IntlGlobalsTest extends AbstractIntlGlobalsTestCase { protected function getIntlErrorName($errorCode) { diff --git a/src/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php b/src/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php index c7bc125b2e7c4..79854ef71b266 100644 --- a/src/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php +++ b/src/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php @@ -11,18 +11,18 @@ namespace Symfony\Component\Intl\Tests\Globals\Verification; -use Symfony\Component\Intl\Tests\Globals\AbstractIntlGlobalsTest; +use Symfony\Component\Intl\Tests\Globals\AbstractIntlGlobalsTestCase; use Symfony\Component\Intl\Util\IntlTestHelper; /** - * Verifies that {@link AbstractIntlGlobalsTest} matches the behavior of the + * Verifies that {@link AbstractIntlGlobalsTestCase} matches the behavior of the * intl functions with a specific version of ICU. * * @author Bernhard Schussek * * @group legacy */ -class IntlGlobalsTest extends AbstractIntlGlobalsTest +class IntlGlobalsTest extends AbstractIntlGlobalsTestCase { protected function setUp(): void { diff --git a/src/Symfony/Component/Intl/Tests/LanguagesTest.php b/src/Symfony/Component/Intl/Tests/LanguagesTest.php index bc0641e40c97f..1bf86f86b6012 100644 --- a/src/Symfony/Component/Intl/Tests/LanguagesTest.php +++ b/src/Symfony/Component/Intl/Tests/LanguagesTest.php @@ -1742,7 +1742,7 @@ public function testGetNameDefaultLocale() } } - public function provideLanguagesWithAlpha3Equivalent() + public static function provideLanguagesWithAlpha3Equivalent() { return array_map( function ($value) { return [$value]; }, @@ -1758,7 +1758,7 @@ public function testGetAlpha3Code($language) $this->assertSame(self::ALPHA2_TO_ALPHA3[$language], Languages::getAlpha3Code($language)); } - public function provideLanguagesWithoutAlpha3Equivalent() + public static function provideLanguagesWithoutAlpha3Equivalent() { return array_map( function ($value) { return [$value]; }, @@ -1792,7 +1792,7 @@ public function testGetAlpha3Codes() $this->assertSame(self::ALPHA3_CODES, Languages::getAlpha3Codes()); } - public function provideLanguagesWithAlpha2Equivalent() + public static function provideLanguagesWithAlpha2Equivalent() { return array_map( function ($value) { return [$value]; }, @@ -1808,7 +1808,7 @@ public function testGetAlpha2Code($language) $this->assertSame(self::ALPHA3_TO_ALPHA2[$language], Languages::getAlpha2Code($language)); } - public function provideLanguagesWithoutAlpha2Equivalent() + public static function provideLanguagesWithoutAlpha2Equivalent() { return array_map( function ($value) { return [$value]; }, diff --git a/src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTestCase.php similarity index 92% rename from src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php rename to src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTestCase.php index a3daecb59e018..aab9bc9229352 100644 --- a/src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTestCase.php @@ -18,7 +18,7 @@ * * @author Bernhard Schussek */ -abstract class AbstractLocaleTest extends TestCase +abstract class AbstractLocaleTestCase extends TestCase { public function testSetDefault() { diff --git a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php index 05ba7106ebc43..754d179935258 100644 --- a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Intl\Exception\MethodNotImplementedException; use Symfony\Component\Intl\Locale\Locale; -class LocaleTest extends AbstractLocaleTest +class LocaleTest extends AbstractLocaleTestCase { public function testAcceptFromHttp() { diff --git a/src/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php index c0b1b26b623d4..7fadd6a6cd883 100644 --- a/src/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php @@ -11,16 +11,16 @@ namespace Symfony\Component\Intl\Tests\Locale\Verification; -use Symfony\Component\Intl\Tests\Locale\AbstractLocaleTest; +use Symfony\Component\Intl\Tests\Locale\AbstractLocaleTestCase; use Symfony\Component\Intl\Util\IntlTestHelper; /** - * Verifies that {@link AbstractLocaleTest} matches the behavior of the + * Verifies that {@link AbstractLocaleTestCase} matches the behavior of the * {@link Locale} class with a specific version of ICU. * * @author Bernhard Schussek */ -class LocaleTest extends AbstractLocaleTest +class LocaleTest extends AbstractLocaleTestCase { protected function setUp(): void { diff --git a/src/Symfony/Component/Intl/Tests/LocaleTest.php b/src/Symfony/Component/Intl/Tests/LocaleTest.php index fce214242a47a..35db0a97a05ed 100644 --- a/src/Symfony/Component/Intl/Tests/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/LocaleTest.php @@ -16,7 +16,7 @@ class LocaleTest extends TestCase { - public function provideGetFallbackTests() + public static function provideGetFallbackTests() { $tests = [ ['sl_Latn_IT', 'sl_Latn_IT_nedis'], diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTestCase.php similarity index 81% rename from src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php rename to src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTestCase.php index 96b36f97e2a80..fc4bdc28df0eb 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTestCase.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Intl\Tests\NumberFormatter; -use PHPUnit\Framework\Error\Warning; use PHPUnit\Framework\TestCase; use Symfony\Component\Intl\Globals\IntlGlobals; use Symfony\Component\Intl\NumberFormatter\NumberFormatter; @@ -23,18 +22,18 @@ * * @group legacy */ -abstract class AbstractNumberFormatterTest extends TestCase +abstract class AbstractNumberFormatterTestCase extends TestCase { /** * @dataProvider formatCurrencyWithDecimalStyleProvider */ public function testFormatCurrencyWithDecimalStyle($value, $currency, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $this->assertEquals($expected, $formatter->formatCurrency($value, $currency)); } - public function formatCurrencyWithDecimalStyleProvider() + public static function formatCurrencyWithDecimalStyleProvider() { return [ [100, 'ALL', '100'], @@ -62,11 +61,11 @@ public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected { IntlTestHelper::requireIntl($this, '63.1'); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals($expected, $formatter->formatCurrency($value, $currency)); } - public function formatCurrencyWithCurrencyStyleProvider() + public static function formatCurrencyWithCurrencyStyleProvider() { return [ [100, 'ALL', "ALL\xc2\xa0100"], @@ -90,11 +89,11 @@ public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($val { IntlTestHelper::requireIntl($this, '63.1'); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } - public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider() + public static function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider() { return [ [100, 'CRC', 'CRC', "%s\xc2\xa0100.00"], @@ -108,11 +107,11 @@ public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider( */ public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } - public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider() + public static function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider() { return [ [100, 'BRL', 'R', '%s$100.00'], @@ -137,11 +136,11 @@ public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $curren { IntlTestHelper::requireIntl($this, '62.1'); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } - public function formatCurrencyWithCurrencyStyleSwissRoundingProvider() + public static function formatCurrencyWithCurrencyStyleSwissRoundingProvider() { return [ [100, 'CHF', 'CHF', "%s\xc2\xa0100.00"], @@ -168,7 +167,7 @@ public function testFormat() $errorCode = IntlGlobals::U_ZERO_ERROR; $errorMessage = 'U_ZERO_ERROR'; - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $this->assertSame('9.555', $formatter->format(9.555)); $this->assertSame($errorMessage, $this->getIntlErrorMessage()); @@ -183,7 +182,7 @@ public function testFormatWithCurrencyStyle() { IntlTestHelper::requireIntl($this, '63.1'); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals('¤1.00', $formatter->format(1)); } @@ -196,9 +195,9 @@ public function testFormatTypeInt32($formatter, $value, $expected, $message = '' $this->assertEquals($expected, $formattedValue, $message); } - public function formatTypeInt32Provider() + public static function formatTypeInt32Provider() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.'; @@ -221,9 +220,9 @@ public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expect $this->assertEquals($expected, $formattedValue, $message); } - public function formatTypeInt32WithCurrencyStyleProvider() + public static function formatTypeInt32WithCurrencyStyleProvider() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.'; @@ -246,9 +245,9 @@ public function testFormatTypeInt64($formatter, $value, $expected) $this->assertEquals($expected, $formattedValue); } - public function formatTypeInt64Provider() + public static function formatTypeInt64Provider() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); return [ [$formatter, 1, '1'], @@ -269,9 +268,9 @@ public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expect $this->assertEquals($expected, $formattedValue); } - public function formatTypeInt64WithCurrencyStyleProvider() + public static function formatTypeInt64WithCurrencyStyleProvider() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); return [ [$formatter, 1, '¤1.00'], @@ -290,9 +289,9 @@ public function testFormatTypeDouble($formatter, $value, $expected) $this->assertEquals($expected, $formattedValue); } - public function formatTypeDoubleProvider() + public static function formatTypeDoubleProvider() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); return [ [$formatter, 1, '1'], @@ -311,9 +310,9 @@ public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expec $this->assertEquals($expected, $formattedValue); } - public function formatTypeDoubleWithCurrencyStyleProvider() + public static function formatTypeDoubleWithCurrencyStyleProvider() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $formatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); return [ [$formatter, 1, '¤1.00'], @@ -328,13 +327,17 @@ public function testFormatTypeCurrency($formatter, $value) { if (\PHP_VERSION_ID >= 80000) { $this->expectException(\ValueError::class); - } elseif (method_exists($this, 'expectWarning')) { - $this->expectWarning(); } else { - $this->expectException(Warning::class); + $this->expectException(\ErrorException::class); } - $formatter->format($value, NumberFormatter::TYPE_CURRENCY); + set_error_handler([self::class, 'throwOnWarning']); + + try { + $formatter->format($value, NumberFormatter::TYPE_CURRENCY); + } finally { + restore_error_handler(); + } } /** @@ -349,10 +352,10 @@ public function testFormatTypeCurrencyReturn($formatter, $value) $this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY)); } - public function formatTypeCurrencyProvider() + public static function formatTypeCurrencyProvider() { - $df = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); - $cf = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $df = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + $cf = static::getNumberFormatter('en', NumberFormatter::CURRENCY); return [ [$df, 1], @@ -367,7 +370,7 @@ public function testFormatFractionDigits($value, $expected, $fractionDigits = nu { IntlTestHelper::requireIntl($this, '62.1'); - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $attributeRet = null; if (null !== $fractionDigits) { @@ -383,7 +386,7 @@ public function testFormatFractionDigits($value, $expected, $fractionDigits = nu } } - public function formatFractionDigitsProvider() + public static function formatFractionDigitsProvider() { yield [1.123, '1.123', null, 0]; yield [1.123, '1', 0, 0]; @@ -397,7 +400,7 @@ public function formatFractionDigitsProvider() */ public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $attributeRet = null; if (null !== $groupingUsed) { @@ -413,7 +416,7 @@ public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, } } - public function formatGroupingUsedProvider() + public static function formatGroupingUsedProvider() { yield [1000, '1,000', null, 1]; yield [1000, '1000', 0, 0]; @@ -427,14 +430,14 @@ public function formatGroupingUsedProvider() */ public function testFormatRoundingModeHalfUp($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFUP); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFUP rounding mode.'); } - public function formatRoundingModeRoundHalfUpProvider() + public static function formatRoundingModeRoundHalfUpProvider() { // The commented value is differently rounded by intl's NumberFormatter in 32 and 64 bit architectures return [ @@ -452,14 +455,14 @@ public function formatRoundingModeRoundHalfUpProvider() */ public function testFormatRoundingModeHalfDown($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFDOWN); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFDOWN rounding mode.'); } - public function formatRoundingModeRoundHalfDownProvider() + public static function formatRoundingModeRoundHalfDownProvider() { return [ [1.121, '1.12'], @@ -476,14 +479,14 @@ public function formatRoundingModeRoundHalfDownProvider() */ public function testFormatRoundingModeHalfEven($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFEVEN); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFEVEN rounding mode.'); } - public function formatRoundingModeRoundHalfEvenProvider() + public static function formatRoundingModeRoundHalfEvenProvider() { return [ [1.121, '1.12'], @@ -500,14 +503,14 @@ public function formatRoundingModeRoundHalfEvenProvider() */ public function testFormatRoundingModeCeiling($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_CEILING); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_CEILING rounding mode.'); } - public function formatRoundingModeRoundCeilingProvider() + public static function formatRoundingModeRoundCeilingProvider() { return [ [1.123, '1.13'], @@ -525,14 +528,14 @@ public function formatRoundingModeRoundCeilingProvider() */ public function testFormatRoundingModeFloor($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_FLOOR); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_FLOOR rounding mode.'); } - public function formatRoundingModeRoundFloorProvider() + public static function formatRoundingModeRoundFloorProvider() { return [ [1.123, '1.12'], @@ -550,14 +553,14 @@ public function formatRoundingModeRoundFloorProvider() */ public function testFormatRoundingModeDown($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_DOWN); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_DOWN rounding mode.'); } - public function formatRoundingModeRoundDownProvider() + public static function formatRoundingModeRoundDownProvider() { return [ [1.123, '1.12'], @@ -575,14 +578,14 @@ public function formatRoundingModeRoundDownProvider() */ public function testFormatRoundingModeUp($value, $expected) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_UP); $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_UP rounding mode.'); } - public function formatRoundingModeRoundUpProvider() + public static function formatRoundingModeRoundUpProvider() { return [ [1.123, '1.13'], @@ -597,14 +600,14 @@ public function formatRoundingModeRoundUpProvider() public function testGetLocale() { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $this->assertEquals('en', $formatter->getLocale()); } public function testGetSymbol() { - $decimalFormatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); - $currencyFormatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $decimalFormatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + $currencyFormatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $r = new \ReflectionClassConstant(NumberFormatter::class, 'EN_SYMBOLS'); $expected = $r->getValue(); @@ -619,8 +622,8 @@ public function testGetTextAttribute() { IntlTestHelper::requireIntl($this, '63.1'); - $decimalFormatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); - $currencyFormatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); + $decimalFormatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + $currencyFormatter = static::getNumberFormatter('en', NumberFormatter::CURRENCY); $r = new \ReflectionClassConstant(NumberFormatter::class, 'EN_TEXT_ATTRIBUTES'); $expected = $r->getValue(); @@ -639,7 +642,7 @@ public function testParse($value, $expected, $message, $expectedPosition, $group IntlTestHelper::requireIntl($this, '62.1'); $position = 0; - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::GROUPING_USED, $groupingUsed); $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE, $position); $this->assertSame($expected, $parsedValue, $message); @@ -661,7 +664,7 @@ public function testParse($value, $expected, $message, $expectedPosition, $group $this->assertSame(0 !== $errorCode, $this->isIntlFailure($formatter->getErrorCode())); } - public function parseProvider() + public static function parseProvider() { return [ ['prefix1', false, '->parse() does not parse a number with a string prefix.', 0], @@ -705,16 +708,21 @@ public function parseProvider() public function testParseTypeDefault() { + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + if (\PHP_VERSION_ID >= 80000) { $this->expectException(\ValueError::class); - } elseif (method_exists($this, 'expectWarning')) { - $this->expectWarning(); } else { - $this->expectException(Warning::class); + $this->expectException(\ErrorException::class); } - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); - $formatter->parse('1', NumberFormatter::TYPE_DEFAULT); + set_error_handler([self::class, 'throwOnWarning']); + + try { + $formatter->parse('1', NumberFormatter::TYPE_DEFAULT); + } finally { + restore_error_handler(); + } } /** @@ -722,12 +730,12 @@ public function testParseTypeDefault() */ public function testParseTypeInt32($value, $expected, $message = '') { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_INT32); $this->assertSame($expected, $parsedValue, $message); } - public function parseTypeInt32Provider() + public static function parseTypeInt32Provider() { return [ ['1', 1], @@ -744,7 +752,7 @@ public function testParseTypeInt64With32BitIntegerInPhp32Bit() { IntlTestHelper::require32Bit($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64); $this->assertIsInt($parsedValue); @@ -759,7 +767,7 @@ public function testParseTypeInt64With32BitIntegerInPhp64Bit() { IntlTestHelper::require64Bit($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64); $this->assertIsInt($parsedValue); @@ -777,7 +785,7 @@ public function testParseTypeInt64With64BitIntegerInPhp32Bit() { IntlTestHelper::require32Bit($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); // int 64 using only 32 bit range strangeness $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64); @@ -796,7 +804,7 @@ public function testParseTypeInt64With64BitIntegerInPhp64Bit() { IntlTestHelper::require64Bit($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64); $this->assertIsInt($parsedValue); @@ -814,12 +822,12 @@ public function testParseTypeInt64With64BitIntegerInPhp64Bit() */ public function testParseTypeDouble($value, $expectedValue) { - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE); $this->assertEqualsWithDelta($expectedValue, $parsedValue, 0.001); } - public function parseTypeDoubleProvider() + public static function parseTypeDoubleProvider() { return [ ['1', (float) 1], @@ -831,22 +839,27 @@ public function parseTypeDoubleProvider() public function testParseTypeCurrency() { + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + if (\PHP_VERSION_ID >= 80000) { $this->expectException(\ValueError::class); - } elseif (method_exists($this, 'expectWarning')) { - $this->expectWarning(); } else { - $this->expectException(Warning::class); + $this->expectException(\ErrorException::class); } - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); - $formatter->parse('1', NumberFormatter::TYPE_CURRENCY); + set_error_handler([self::class, 'throwOnWarning']); + + try { + $formatter->parse('1', NumberFormatter::TYPE_CURRENCY); + } finally { + restore_error_handler(); + } } public function testParseWithNotNullPositionValue() { $position = 1; - $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->parse('123', NumberFormatter::TYPE_DOUBLE, $position); $this->assertEquals(3, $position); } @@ -854,7 +867,7 @@ public function testParseWithNotNullPositionValue() /** * @return NumberFormatter|\NumberFormatter */ - abstract protected function getNumberFormatter(string $locale = 'en', string $style = null, string $pattern = null); + abstract protected static function getNumberFormatter(string $locale = 'en', string $style = null, string $pattern = null); abstract protected function getIntlErrorMessage(): string; @@ -864,4 +877,13 @@ abstract protected function getIntlErrorCode(): int; * @param int $errorCode */ abstract protected function isIntlFailure($errorCode): bool; + + public static function throwOnWarning(int $errno, string $errstr, string $errfile = null, int $errline = null): bool + { + if ($errno & (\E_WARNING | \E_USER_WARNING)) { + throw new \ErrorException($errstr, 0, $errno, $errfile ?? __FILE__, $errline ?? __LINE__); + } + + return false; + } } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php index 6635ca92ef064..3f889b7a611bc 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php @@ -24,7 +24,7 @@ * * @group legacy */ -class NumberFormatterTest extends AbstractNumberFormatterTest +class NumberFormatterTest extends AbstractNumberFormatterTestCase { public function testConstructorWithUnsupportedLocale() { @@ -171,7 +171,7 @@ public function testSetTextAttribute() $formatter->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, '-'); } - protected function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): NumberFormatter + protected static function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): NumberFormatter { return new class($locale, $style, $pattern) extends NumberFormatter { }; diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php index c062deacebf2f..5cef6efb1578f 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php @@ -11,14 +11,14 @@ namespace Symfony\Component\Intl\Tests\NumberFormatter\Verification; -use Symfony\Component\Intl\Tests\NumberFormatter\AbstractNumberFormatterTest; +use Symfony\Component\Intl\Tests\NumberFormatter\AbstractNumberFormatterTestCase; use Symfony\Component\Intl\Util\IntlTestHelper; /** * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known * behavior of PHP. */ -class NumberFormatterTest extends AbstractNumberFormatterTest +class NumberFormatterTest extends AbstractNumberFormatterTestCase { protected function setUp(): void { @@ -39,7 +39,7 @@ public function testGetTextAttribute() parent::testGetTextAttribute(); } - protected function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): \NumberFormatter + protected static function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): \NumberFormatter { return new \NumberFormatter($locale, $style, $pattern); } diff --git a/src/Symfony/Component/Intl/Tests/TimezonesTest.php b/src/Symfony/Component/Intl/Tests/TimezonesTest.php index f47af2105af12..6f0163895ffd2 100644 --- a/src/Symfony/Component/Intl/Tests/TimezonesTest.php +++ b/src/Symfony/Component/Intl/Tests/TimezonesTest.php @@ -639,7 +639,7 @@ public function testGetCountryCodeAvailability(string $timezone) } } - public function provideTimezones(): iterable + public static function provideTimezones(): iterable { return array_map(function ($timezone) { return [$timezone]; @@ -657,7 +657,7 @@ public function testForCountryCodeAvailability(string $country) $this->addToAssertionCount(1); } - public function provideCountries(): iterable + public static function provideCountries(): iterable { return array_map(function ($country) { return [$country]; diff --git a/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php b/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php index 665bea91f0f6f..ad5818c6a4674 100644 --- a/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php +++ b/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php @@ -27,6 +27,7 @@ class GitRepositoryTest extends TestCase /** * @before + * * @after */ protected function cleanup() diff --git a/src/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php b/src/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php index b037c33231ab5..7027874dfa368 100644 --- a/src/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php +++ b/src/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php @@ -19,7 +19,7 @@ */ class IcuVersionTest extends TestCase { - public function normalizeProvider() + public static function normalizeProvider() { return [ [null, '1', '10'], @@ -49,7 +49,7 @@ public function testNormalize($precision, $version, $result) $this->assertSame($result, IcuVersion::normalize($version, $precision)); } - public function compareProvider() + public static function compareProvider() { return [ [null, '1', '==', '1', true], diff --git a/src/Symfony/Component/Intl/Tests/Util/VersionTest.php b/src/Symfony/Component/Intl/Tests/Util/VersionTest.php index e3bb07ee5a802..b41edb0d11e02 100644 --- a/src/Symfony/Component/Intl/Tests/Util/VersionTest.php +++ b/src/Symfony/Component/Intl/Tests/Util/VersionTest.php @@ -19,7 +19,7 @@ */ class VersionTest extends TestCase { - public function normalizeProvider() + public static function normalizeProvider() { return [ [null, '1', '1'], @@ -53,7 +53,7 @@ public function testNormalize($precision, $version, $result) $this->assertSame($result, Version::normalize($version, $precision)); } - public function compareProvider() + public static function compareProvider() { return [ [null, '1', '==', '1', true], diff --git a/src/Symfony/Component/Ldap/LICENSE b/src/Symfony/Component/Ldap/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Ldap/LICENSE +++ b/src/Symfony/Component/Ldap/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php index bbb9731c389cc..79ee17daef376 100644 --- a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php +++ b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php @@ -187,6 +187,9 @@ private function getAttributeValue(Entry $entry, string $attribute) } $values = $entry->getAttribute($attribute); + if (!\in_array($attribute, [$this->uidKey, $this->passwordAttribute])) { + return $values; + } if (1 !== \count($values)) { throw new InvalidArgumentException(sprintf('Attribute "%s" has multiple values.', $attribute)); diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php index 280b11f293d74..8cc30411a0078 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php @@ -22,6 +22,7 @@ /** * @requires extension ldap + * * @group integration */ class AdapterTest extends LdapTestCase diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php index 519fe9bd47337..f32daec2c5160 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php @@ -68,7 +68,7 @@ public function testMoveWithRFC4514DistinguishedName(string $dn, string $expecte $this->assertSame($expectedRdn, $cn); } - public function moveWithRFC4514DistinguishedNameProvider(): array + public static function moveWithRFC4514DistinguishedNameProvider(): array { return [ ['CN=Simple,DC=example,DC=net', 'CN=Simple'], diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php index e43373dd580e5..f849b4bf25f23 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php @@ -22,6 +22,7 @@ /** * @requires extension ldap + * * @group integration */ class LdapManagerTest extends LdapTestCase diff --git a/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php b/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php index 7de5e394c2660..b9a63138250a2 100644 --- a/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php @@ -59,10 +59,10 @@ public function testShouldNotCheckPassport($authenticator, $passport) $listener->onCheckPassport(new CheckPassportEvent($authenticator, $passport)); } - public function provideShouldNotCheckPassport() + public static function provideShouldNotCheckPassport() { if (!interface_exists(AuthenticatorInterface::class)) { - $this->markTestSkipped('This test requires symfony/security-http:^5.1'); + self::markTestSkipped('This test requires symfony/security-http:^5.1'); } // no LdapBadge @@ -108,10 +108,10 @@ public function testWrongPassport($passport) $listener->onCheckPassport(new CheckPassportEvent(new TestAuthenticator(), $passport)); } - public function provideWrongPassportData() + public static function provideWrongPassportData() { if (!interface_exists(AuthenticatorInterface::class)) { - $this->markTestSkipped('This test requires symfony/security-http:^5.1'); + self::markTestSkipped('This test requires symfony/security-http:^5.1'); } // no password credentials diff --git a/src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php b/src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php index 32f6d60d5df3b..5327540b86e95 100644 --- a/src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php +++ b/src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php @@ -333,6 +333,52 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute() $this->assertInstanceOf(LdapUser::class, $provider->loadUserByIdentifier('foo')); } + public function testLoadUserByIdentifierIsSuccessfulWithMultipleExtraAttributes() + { + $result = $this->createMock(CollectionInterface::class); + $query = $this->createMock(QueryInterface::class); + $query + ->expects($this->once()) + ->method('execute') + ->willReturn($result) + ; + $ldap = $this->createMock(LdapInterface::class); + $memberOf = [ + 'cn=foo,ou=MyBusiness,dc=symfony,dc=com', + 'cn=bar,ou=MyBusiness,dc=symfony,dc=com', + ]; + $result + ->expects($this->once()) + ->method('offsetGet') + ->with(0) + ->willReturn(new Entry('foo', [ + 'sAMAccountName' => ['foo'], + 'userpassword' => ['bar'], + 'memberOf' => $memberOf, + ])) + ; + $result + ->expects($this->once()) + ->method('count') + ->willReturn(1) + ; + $ldap + ->expects($this->once()) + ->method('escape') + ->willReturn('foo') + ; + $ldap + ->expects($this->once()) + ->method('query') + ->willReturn($query) + ; + + $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={user_identifier})', 'userpassword', ['memberOf']); + $user = $provider->loadUserByIdentifier('foo'); + $this->assertInstanceOf(LdapUser::class, $user); + $this->assertSame(['memberOf' => $memberOf], $user->getExtraFields()); + } + public function testRefreshUserShouldReturnUserWithSameProperties() { $ldap = $this->createMock(LdapInterface::class); diff --git a/src/Symfony/Component/Lock/LICENSE b/src/Symfony/Component/Lock/LICENSE index f2345234aa9ea..0223acd4a01f4 100644 --- a/src/Symfony/Component/Lock/LICENSE +++ b/src/Symfony/Component/Lock/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2023 Fabien Potencier +Copyright (c) 2016-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Lock/Store/MongoDbStore.php b/src/Symfony/Component/Lock/Store/MongoDbStore.php index 4dc127202f14e..d645a01932416 100644 --- a/src/Symfony/Component/Lock/Store/MongoDbStore.php +++ b/src/Symfony/Component/Lock/Store/MongoDbStore.php @@ -351,7 +351,7 @@ private function createMongoDateTime(float $seconds): UTCDateTime /** * Retrieves an unique token for the given key namespaced to this store. * - * @param Key lock state container + * @param Key $key lock state container */ private function getUniqueToken(Key $key): string { diff --git a/src/Symfony/Component/Lock/Tests/LockTest.php b/src/Symfony/Component/Lock/Tests/LockTest.php index 565ef529a46ed..ee019a1d8db51 100644 --- a/src/Symfony/Component/Lock/Tests/LockTest.php +++ b/src/Symfony/Component/Lock/Tests/LockTest.php @@ -404,7 +404,7 @@ public function testExpirationStoreInterface($ttls, $expected) $this->assertSame($expected, $lock->isExpired()); } - public function provideExpiredDates() + public static function provideExpiredDates() { yield [[-0.1], true]; yield [[0.1, -0.1], true]; diff --git a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTestCase.php similarity index 98% rename from src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php rename to src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTestCase.php index 6f3eb47125006..266addf619157 100644 --- a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTestCase.php @@ -22,7 +22,7 @@ /** * @author Jérémy Derussé */ -abstract class AbstractRedisStoreTest extends AbstractStoreTest +abstract class AbstractRedisStoreTestCase extends AbstractStoreTestCase { use ExpiringStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTestCase.php similarity index 98% rename from src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php rename to src/Symfony/Component/Lock/Tests/Store/AbstractStoreTestCase.php index 4ac11e00da790..fdd3e39a6a371 100644 --- a/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTestCase.php @@ -19,7 +19,7 @@ /** * @author Jérémy Derussé */ -abstract class AbstractStoreTest extends TestCase +abstract class AbstractStoreTestCase extends TestCase { abstract protected function getStore(): PersistingStoreInterface; diff --git a/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php index 27c86681c135b..c26d71e37fb53 100644 --- a/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php +++ b/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php @@ -21,7 +21,7 @@ trait BlockingStoreTestTrait { /** - * @see AbstractStoreTest::getStore() + * @see AbstractStoreTestCase::getStore() * * @return PersistingStoreInterface */ diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index 1b912c0139f96..29034fc7ce0fa 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -24,9 +24,10 @@ /** * @author Jérémy Derussé + * * @group integration */ -class CombinedStoreTest extends AbstractStoreTest +class CombinedStoreTest extends AbstractStoreTestCase { use ExpiringStoreTestTrait; use SharedLockStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalPostgreSqlStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalPostgreSqlStoreTest.php index eaf9f7b7b5cb9..7fcffa99e5c7e 100644 --- a/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalPostgreSqlStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalPostgreSqlStoreTest.php @@ -24,9 +24,10 @@ * @author Jérémy Derussé * * @requires extension pdo_pgsql + * * @group integration */ -class DoctrineDbalPostgreSqlStoreTest extends AbstractStoreTest +class DoctrineDbalPostgreSqlStoreTest extends AbstractStoreTestCase { use BlockingStoreTestTrait; use SharedLockStoreTestTrait; @@ -52,6 +53,7 @@ public function getStore(): PersistingStoreInterface /** * @requires extension pdo_sqlite + * * @dataProvider getInvalidDrivers */ public function testInvalidDriver($connOrDsn) @@ -63,7 +65,7 @@ public function testInvalidDriver($connOrDsn) $store->exists(new Key('foo')); } - public function getInvalidDrivers() + public static function getInvalidDrivers() { yield ['sqlite:///tmp/foo.db']; yield [DriverManager::getConnection(['url' => 'sqlite:///tmp/foo.db'])]; diff --git a/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php index 3f46311ffe9ce..1bd70d5aa8d4d 100644 --- a/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php @@ -26,7 +26,7 @@ class_exists(\Doctrine\DBAL\Platforms\PostgreSqlPlatform::class); * * @requires extension pdo_sqlite */ -class DoctrineDbalStoreTest extends AbstractStoreTest +class DoctrineDbalStoreTest extends AbstractStoreTestCase { use ExpiringStoreTestTrait; @@ -85,7 +85,7 @@ public function testDsn(string $dsn, string $file = null) } } - public function provideDsn() + public static function provideDsn() { $dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); yield ['sqlite://localhost/'.$dbFile.'1', $dbFile.'1']; @@ -133,7 +133,7 @@ public function testCreatesTableInTransaction(string $platform) $store->save($key); } - public function providePlatforms() + public static function providePlatforms() { yield [\Doctrine\DBAL\Platforms\PostgreSQLPlatform::class]; yield [\Doctrine\DBAL\Platforms\PostgreSQL94Platform::class]; diff --git a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php index bf75d69c169c8..27a8406f768e4 100644 --- a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php +++ b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php @@ -30,7 +30,7 @@ trait ExpiringStoreTestTrait abstract protected function getClockDelay(); /** - * @see AbstractStoreTest::getStore() + * @see AbstractStoreTestCase::getStore() */ abstract protected function getStore(); diff --git a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php index 79cf6b0cd4e55..cbd234d88b5f5 100644 --- a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php @@ -19,7 +19,7 @@ /** * @author Jérémy Derussé */ -class FlockStoreTest extends AbstractStoreTest +class FlockStoreTest extends AbstractStoreTestCase { use BlockingStoreTestTrait; use SharedLockStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/InMemoryStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/InMemoryStoreTest.php index 2d25dab81c0c1..bb4a24d3457d1 100644 --- a/src/Symfony/Component/Lock/Tests/Store/InMemoryStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/InMemoryStoreTest.php @@ -17,7 +17,7 @@ /** * @author Jérémy Derussé */ -class InMemoryStoreTest extends AbstractStoreTest +class InMemoryStoreTest extends AbstractStoreTestCase { use SharedLockStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php index 2f94ee4f3a4b4..a928424da1b8c 100644 --- a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php @@ -21,9 +21,10 @@ * @author Jérémy Derussé * * @requires extension memcached + * * @group integration */ -class MemcachedStoreTest extends AbstractStoreTest +class MemcachedStoreTest extends AbstractStoreTestCase { use ExpiringStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreFactoryTest.php b/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreFactoryTest.php new file mode 100644 index 0000000000000..8256381c45b32 --- /dev/null +++ b/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreFactoryTest.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Lock\Tests\Store; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Lock\Store\MongoDbStore; +use Symfony\Component\Lock\Store\StoreFactory; + +/** + * @author Alexandre Daubois + * + * @requires extension mongo + */ +class MongoDbStoreFactoryTest extends TestCase +{ + public function testCreateMongoDbCollectionStore() + { + $store = StoreFactory::createStore($this->createMock(\MongoDB\Collection::class)); + + $this->assertInstanceOf(MongoDbStore::class, $store); + } + + public function testCreateMongoDbCollectionStoreAsDsn() + { + $store = StoreFactory::createStore('mongodb://localhost/test?collection=lock'); + + $this->assertInstanceOf(MongoDbStore::class, $store); + } +} diff --git a/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php index 49227783742e2..a5c0233d48344 100644 --- a/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php @@ -23,9 +23,10 @@ * @author Joe Bennett * * @requires extension mongodb + * * @group integration */ -class MongoDbStoreTest extends AbstractStoreTest +class MongoDbStoreTest extends AbstractStoreTestCase { use ExpiringStoreTestTrait; @@ -97,7 +98,7 @@ public function testConstructionMethods($mongo, array $options) $this->assertFalse($store->exists($key)); } - public function provideConstructorArgs() + public static function provideConstructorArgs() { $client = self::getMongoClient(); yield [$client, ['database' => 'test', 'collection' => 'lock']]; @@ -138,7 +139,7 @@ public function testInvalidConstructionMethods($mongo, array $options) new MongoDbStore($mongo, $options); } - public function provideInvalidConstructorArgs() + public static function provideInvalidConstructorArgs() { $client = self::getMongoClient(); yield [$client, ['collection' => 'lock']]; @@ -165,7 +166,7 @@ public function testUriCollectionStrip(string $uri, array $options, string $driv $this->assertSame($driverUri, $uri); } - public function provideUriCollectionStripArgs() + public static function provideUriCollectionStripArgs() { yield ['mongodb://localhost/?collection=lock', ['database' => 'test'], 'mongodb://localhost/']; yield ['mongodb://localhost/', ['database' => 'test', 'collection' => 'lock'], 'mongodb://localhost/']; diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php index 4d9ec4c0fe7ef..877412882ea76 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php @@ -23,9 +23,10 @@ * @author Jérémy Derussé * * @requires extension pdo_sqlite + * * @group legacy */ -class PdoDbalStoreTest extends AbstractStoreTest +class PdoDbalStoreTest extends AbstractStoreTestCase { use ExpectDeprecationTrait; use ExpiringStoreTestTrait; @@ -99,7 +100,7 @@ public function testDsn(string $dsn, string $file = null) } } - public function provideDsn() + public static function provideDsn() { $dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); yield ['sqlite://localhost/'.$dbFile.'1', $dbFile.'1']; diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php index 8b8cf43381862..0dc4eb015bafd 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php @@ -20,9 +20,10 @@ * @author Jérémy Derussé * * @requires extension pdo_sqlite + * * @group integration */ -class PdoStoreTest extends AbstractStoreTest +class PdoStoreTest extends AbstractStoreTestCase { use ExpiringStoreTestTrait; @@ -95,7 +96,7 @@ public function testDsn(string $dsn, string $file = null) } } - public function provideDsn() + public static function provideDsn() { $dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); yield ['sqlite:'.$dbFile.'2', $dbFile.'2']; diff --git a/src/Symfony/Component/Lock/Tests/Store/PostgreSqlDbalStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PostgreSqlDbalStoreTest.php index b5b1194dd2109..4196fbe5ad375 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PostgreSqlDbalStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PostgreSqlDbalStoreTest.php @@ -19,10 +19,11 @@ * @author Jérémy Derussé * * @requires extension pdo_pgsql + * * @group integration * @group legacy */ -class PostgreSqlDbalStoreTest extends AbstractStoreTest +class PostgreSqlDbalStoreTest extends AbstractStoreTestCase { use BlockingStoreTestTrait; use ExpectDeprecationTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/PostgreSqlStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PostgreSqlStoreTest.php index a9cbf4d1eeed8..6205c6797da34 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PostgreSqlStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PostgreSqlStoreTest.php @@ -21,9 +21,10 @@ * @author Jérémy Derussé * * @requires extension pdo_pgsql + * * @group integration */ -class PostgreSqlStoreTest extends AbstractStoreTest +class PostgreSqlStoreTest extends AbstractStoreTestCase { use BlockingStoreTestTrait; use SharedLockStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php index 6a820767300ea..433523cb4f5c2 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php @@ -15,9 +15,10 @@ /** * @author Jérémy Derussé + * * @group integration */ -class PredisStoreTest extends AbstractRedisStoreTest +class PredisStoreTest extends AbstractRedisStoreTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php index f1fd4dce8fd47..e3e3af3f14362 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php @@ -17,9 +17,10 @@ * @author Jérémy Derussé * * @requires extension redis + * * @group integration */ -class RedisArrayStoreTest extends AbstractRedisStoreTest +class RedisArrayStoreTest extends AbstractRedisStoreTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php index 387a9033ada50..6cca54acd9eda 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php @@ -17,9 +17,10 @@ * @author Jérémy Derussé * * @requires extension redis + * * @group integration */ -class RedisClusterStoreTest extends AbstractRedisStoreTest +class RedisClusterStoreTest extends AbstractRedisStoreTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisProxyStoreFactoryTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisProxyStoreFactoryTest.php new file mode 100644 index 0000000000000..e96c27e0c034f --- /dev/null +++ b/src/Symfony/Component/Lock/Tests/Store/RedisProxyStoreFactoryTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Lock\Tests\Store; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Traits\RedisProxy; +use Symfony\Component\Lock\Store\RedisStore; +use Symfony\Component\Lock\Store\StoreFactory; + +/** + * @requires extension redis + */ +class RedisProxyStoreFactoryTest extends TestCase +{ + public function testCreateStore() + { + if (!class_exists(RedisProxy::class)) { + $this->markTestSkipped(); + } + + $store = StoreFactory::createStore($this->createMock(RedisProxy::class)); + + $this->assertInstanceOf(RedisStore::class, $store); + } +} diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php index 6442dae62699a..a773570821307 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php @@ -19,9 +19,10 @@ * @author Jérémy Derussé * * @requires extension redis + * * @group integration */ -class RedisStoreTest extends AbstractRedisStoreTest +class RedisStoreTest extends AbstractRedisStoreTestCase { use SharedLockStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php index 5b10d4310a27e..01712945203b5 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php @@ -20,7 +20,7 @@ * * @group legacy */ -class RetryTillSaveStoreTest extends AbstractStoreTest +class RetryTillSaveStoreTest extends AbstractStoreTestCase { use BlockingStoreTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php index a94c7686180f5..55f5df87cc1ed 100644 --- a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php @@ -20,7 +20,7 @@ * * @requires extension sysvsem */ -class SemaphoreStoreTest extends AbstractStoreTest +class SemaphoreStoreTest extends AbstractStoreTestCase { use BlockingStoreTestTrait; use UnserializableTestTrait; diff --git a/src/Symfony/Component/Lock/Tests/Store/SharedLockStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/SharedLockStoreTestTrait.php index 498191beea9c3..c6e0ce66acf46 100644 --- a/src/Symfony/Component/Lock/Tests/Store/SharedLockStoreTestTrait.php +++ b/src/Symfony/Component/Lock/Tests/Store/SharedLockStoreTestTrait.php @@ -21,7 +21,7 @@ trait SharedLockStoreTestTrait { /** - * @see AbstractStoreTest::getStore() + * @see AbstractStoreTestCase::getStore() * * @return PersistingStoreInterface */ diff --git a/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php b/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php index daf3430fe4be3..6d2319c8d760e 100644 --- a/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php @@ -15,19 +15,16 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\MemcachedAdapter; -use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Lock\Store\DoctrineDbalPostgreSqlStore; use Symfony\Component\Lock\Store\DoctrineDbalStore; use Symfony\Component\Lock\Store\FlockStore; use Symfony\Component\Lock\Store\InMemoryStore; use Symfony\Component\Lock\Store\MemcachedStore; -use Symfony\Component\Lock\Store\MongoDbStore; use Symfony\Component\Lock\Store\PdoStore; use Symfony\Component\Lock\Store\PostgreSqlStore; use Symfony\Component\Lock\Store\RedisStore; use Symfony\Component\Lock\Store\SemaphoreStore; use Symfony\Component\Lock\Store\StoreFactory; -use Symfony\Component\Lock\Store\ZookeeperStore; /** * @author Jérémy Derussé @@ -44,26 +41,15 @@ public function testCreateStore($connection, string $expectedStoreClass) $this->assertInstanceOf($expectedStoreClass, $store); } - public function validConnections() + public static function validConnections(): \Generator { if (class_exists(\Redis::class)) { yield [new \Redis(), RedisStore::class]; } - if (class_exists(RedisProxy::class)) { - yield [$this->createMock(RedisProxy::class), RedisStore::class]; - } yield [new \Predis\Client(), RedisStore::class]; if (class_exists(\Memcached::class)) { yield [new \Memcached(), MemcachedStore::class]; } - if (class_exists(\MongoDB\Collection::class)) { - yield [$this->createMock(\MongoDB\Collection::class), MongoDbStore::class]; - yield ['mongodb://localhost/test?collection=lock', MongoDbStore::class]; - } - if (class_exists(\Zookeeper::class)) { - yield [$this->createMock(\Zookeeper::class), ZookeeperStore::class]; - yield ['zookeeper://localhost:2181', ZookeeperStore::class]; - } if (\extension_loaded('sysvsem')) { yield ['semaphore', SemaphoreStore::class]; } diff --git a/src/Symfony/Component/Lock/Tests/Store/UnserializableTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/UnserializableTestTrait.php index 6a9cf0bd49477..0c5569b3dcdab 100644 --- a/src/Symfony/Component/Lock/Tests/Store/UnserializableTestTrait.php +++ b/src/Symfony/Component/Lock/Tests/Store/UnserializableTestTrait.php @@ -21,7 +21,7 @@ trait UnserializableTestTrait { /** - * @see AbstractStoreTest::getStore() + * @see AbstractStoreTestCase::getStore() * * @return PersistingStoreInterface */ diff --git a/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreFactoryTest.php b/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreFactoryTest.php new file mode 100644 index 0000000000000..97357b8485c20 --- /dev/null +++ b/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreFactoryTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Lock\Tests\Store; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Lock\Store\StoreFactory; +use Symfony\Component\Lock\Store\ZookeeperStore; + +/** + * @author Alexandre Daubois + * + * @requires extension zookeeper + */ +class ZookeeperStoreFactoryTest extends TestCase +{ + public function testCreateZooKeeperStore() + { + $store = StoreFactory::createStore($this->createMock(\Zookeeper::class)); + + $this->assertInstanceOf(ZookeeperStore::class, $store); + } + + public function testCreateZooKeeperStoreAsDsn() + { + $store = StoreFactory::createStore('zookeeper://localhost:2181'); + + $this->assertInstanceOf(ZookeeperStore::class, $store); + } + + public function testCreateZooKeeperStoreWithMultipleHosts() + { + $store = StoreFactory::createStore('zookeeper://localhost01,localhost02:2181'); + + $this->assertInstanceOf(ZookeeperStore::class, $store); + } +} diff --git a/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php index 95589a61a06be..76083de8661ee 100644 --- a/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php @@ -20,9 +20,10 @@ * @author Ganesh Chandrasekaran * * @requires extension zookeeper + * * @group integration */ -class ZookeeperStoreTest extends AbstractStoreTest +class ZookeeperStoreTest extends AbstractStoreTestCase { use UnserializableTestTrait; @@ -46,7 +47,7 @@ public function testCreateConnection(string $connectionString) $this->assertInstanceOf(\Zookeeper::class, ZookeeperStore::createConnection($connectionString)); } - public function provideValidConnectionString(): iterable + public static function provideValidConnectionString(): iterable { yield 'single host' => ['zookeeper://localhost:2181']; yield 'single multiple host' => ['zookeeper://localhost:2181,localhost:2181']; diff --git a/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php b/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php index c9333e26d5055..36691b4680dee 100644 --- a/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php +++ b/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->strategy = new ConsensusStrategy(); } - public function provideMetResults() + public static function provideMetResults() { // success, failure, total, isMet yield [3, 0, 3, true]; @@ -49,7 +49,7 @@ public function provideMetResults() yield [0, 0, 2, false]; } - public function provideIndeterminate() + public static function provideIndeterminate() { // success, failure, total, canBeMet yield [3, 0, 3, true]; diff --git a/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php b/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php index 6953d3311c09e..69bb511add2ae 100644 --- a/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php +++ b/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->strategy = new UnanimousStrategy(); } - public function provideMetResults() + public static function provideMetResults() { // success, failure, total, isMet yield [3, 0, 3, true]; @@ -49,7 +49,7 @@ public function provideMetResults() yield [0, 0, 2, false]; } - public function provideIndeterminate() + public static function provideIndeterminate() { // success, failure, total, canBeMet yield [3, 0, 3, true]; diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/LICENSE b/src/Symfony/Component/Mailer/Bridge/Amazon/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php index 517c112fa6193..3ad8603790236 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php @@ -33,7 +33,7 @@ public function testToString(SesApiAsyncAwsTransport $transport, string $expecte $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiTransportTest.php index 2df22ed67c644..f266a917629b9 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiTransportTest.php @@ -33,7 +33,7 @@ public function testToString(SesApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php index c64a5218eb673..b08e5daccdb2e 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php @@ -33,7 +33,7 @@ public function testToString(SesHttpAsyncAwsTransport $transport, string $expect $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpTransportTest.php index bd5babdadd0e3..7431ee3263b4c 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpTransportTest.php @@ -33,7 +33,7 @@ public function testToString(SesHttpTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesTransportFactoryTest.php index b7fa43fc26870..2e745dda7a4db 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesTransportFactoryTest.php @@ -13,6 +13,8 @@ use AsyncAws\Core\Configuration; use AsyncAws\Ses\SesClient; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesApiAsyncAwsTransport; use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesHttpAsyncAwsTransport; use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesSmtpTransport; @@ -25,10 +27,10 @@ class SesTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new SesTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new SesTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('ses+api', 'default'), @@ -61,104 +63,103 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $client = $this->getClient(); - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $client = new MockHttpClient(); + $logger = new NullLogger(); yield [ new Dsn('ses+api', 'default', self::USER, self::PASSWORD), - new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), $dispatcher, $logger), + new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+api', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-2']), - new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2']), null, $client, $logger), $dispatcher, $logger), + new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+api', 'example.com', self::USER, self::PASSWORD, 8080), - new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080']), null, $client, $logger), $dispatcher, $logger), + new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+api', 'default', self::USER, self::PASSWORD, null, ['session_token' => 'se$sion']), - new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+api', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-2', 'session_token' => 'se$sion']), - new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+api', 'example.com', self::USER, self::PASSWORD, 8080, ['session_token' => 'se$sion']), - new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+https', 'default', self::USER, self::PASSWORD), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses', 'default', self::USER, self::PASSWORD), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+https', 'example.com', self::USER, self::PASSWORD, 8080), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+https', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-2']), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+https', 'default', self::USER, self::PASSWORD, null, ['session_token' => 'se$sion']), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses', 'default', self::USER, self::PASSWORD, null, ['session_token' => 'se$sion']), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+https', 'example.com', self::USER, self::PASSWORD, 8080, ['session_token' => 'se$sion']), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+https', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-2', 'session_token' => 'se$sion']), - new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2', 'sessionToken' => 'se$sion']), null, $client, $logger), $dispatcher, $logger), + new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2', 'sessionToken' => 'se$sion']), null, $client, $logger), null, $logger), ]; yield [ new Dsn('ses+smtp', 'default', self::USER, self::PASSWORD), - new SesSmtpTransport(self::USER, self::PASSWORD, null, $dispatcher, $logger), + new SesSmtpTransport(self::USER, self::PASSWORD, null, null, $logger), ]; yield [ new Dsn('ses+smtp', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1']), - new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger), + new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', null, $logger), ]; yield [ new Dsn('ses+smtps', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1']), - new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger), + new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', null, $logger), ]; yield [ new Dsn('ses+smtps', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1', 'ping_threshold' => '10']), - (new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger))->setPingThreshold(10), + (new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', null, $logger))->setPingThreshold(10), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('ses+foo', 'default', self::USER, self::PASSWORD), @@ -166,7 +167,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('ses+smtp', 'default', self::USER)]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json index aad87e370e290..4e6ab2f397bdd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json @@ -20,7 +20,7 @@ "async-aws/ses": "^1.0", "psr/event-dispatcher": "^1", "symfony/deprecation-contracts": "^2.1|^3", - "symfony/mailer": "^4.4.21|^5.2.6|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/Google/LICENSE b/src/Symfony/Component/Mailer/Bridge/Google/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Google/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Google/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Google/Tests/Transport/GmailTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Google/Tests/Transport/GmailTransportFactoryTest.php index 33866373f405a..f8e58d393eddf 100644 --- a/src/Symfony/Component/Mailer/Bridge/Google/Tests/Transport/GmailTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Google/Tests/Transport/GmailTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Google\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Google\Transport\GmailSmtpTransport; use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; @@ -21,10 +23,10 @@ class GmailTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new GmailTransportFactory($this->getDispatcher(), null, $this->getLogger()); + return new GmailTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('gmail', 'default'), @@ -47,25 +49,25 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ new Dsn('gmail', 'default', self::USER, self::PASSWORD), - new GmailSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + new GmailSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()), ]; yield [ new Dsn('gmail+smtp', 'default', self::USER, self::PASSWORD), - new GmailSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + new GmailSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()), ]; yield [ new Dsn('gmail+smtps', 'default', self::USER, self::PASSWORD), - new GmailSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + new GmailSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('gmail+foo', 'default', self::USER, self::PASSWORD), @@ -73,7 +75,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('gmail+smtp', 'default', self::USER)]; diff --git a/src/Symfony/Component/Mailer/Bridge/Google/composer.json b/src/Symfony/Component/Mailer/Bridge/Google/composer.json index d08d66043bf9c..927b4ca7cb7b2 100644 --- a/src/Symfony/Component/Mailer/Bridge/Google/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Google/composer.json @@ -18,7 +18,10 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^4.4|^5.0|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" + }, + "require-dev": { + "symfony/http-client": "^4.4|^5.0|^6.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Google\\": "" }, diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/LICENSE b/src/Symfony/Component/Mailer/Bridge/Mailchimp/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillApiTransportTest.php index 152e198309dc3..3747bd58acad4 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillApiTransportTest.php @@ -33,7 +33,7 @@ public function testToString(MandrillApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillHttpTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillHttpTransportTest.php index 8f5eeb1f02012..1436fcbcad3a5 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillHttpTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillHttpTransportTest.php @@ -32,7 +32,7 @@ public function testToString(MandrillHttpTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillTransportFactoryTest.php index c905266756d52..78ca4e3acd25f 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Mailchimp\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillApiTransport; use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillHttpTransport; use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillSmtpTransport; @@ -23,10 +25,10 @@ class MandrillTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new MandrillTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new MandrillTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('mandrill', 'default'), @@ -59,49 +61,48 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $client = $this->getClient(); - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $client = new MockHttpClient(); + $logger = new NullLogger(); yield [ new Dsn('mandrill+api', 'default', self::USER), - new MandrillApiTransport(self::USER, $client, $dispatcher, $logger), + new MandrillApiTransport(self::USER, $client, null, $logger), ]; yield [ new Dsn('mandrill+api', 'example.com', self::USER, '', 8080), - (new MandrillApiTransport(self::USER, $client, $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new MandrillApiTransport(self::USER, $client, null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('mandrill', 'default', self::USER), - new MandrillHttpTransport(self::USER, $client, $dispatcher, $logger), + new MandrillHttpTransport(self::USER, $client, null, $logger), ]; yield [ new Dsn('mandrill+https', 'default', self::USER), - new MandrillHttpTransport(self::USER, $client, $dispatcher, $logger), + new MandrillHttpTransport(self::USER, $client, null, $logger), ]; yield [ new Dsn('mandrill+https', 'example.com', self::USER, '', 8080), - (new MandrillHttpTransport(self::USER, $client, $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new MandrillHttpTransport(self::USER, $client, null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('mandrill+smtp', 'default', self::USER, self::PASSWORD), - new MandrillSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger), + new MandrillSmtpTransport(self::USER, self::PASSWORD, null, $logger), ]; yield [ new Dsn('mandrill+smtps', 'default', self::USER, self::PASSWORD), - new MandrillSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger), + new MandrillSmtpTransport(self::USER, self::PASSWORD, null, $logger), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('mandrill+foo', 'default', self::USER), @@ -109,7 +110,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('mandrill+api', 'default')]; diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json index 2bb1f52f58857..aef41664ce962 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^5.1|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/LICENSE b/src/Symfony/Component/Mailer/Bridge/Mailgun/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunApiTransportTest.php index 5e15332f60779..42d16171102a1 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunApiTransportTest.php @@ -33,7 +33,7 @@ public function testToString(MailgunApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunHttpTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunHttpTransportTest.php index c5ec436315c65..0b0c11612425a 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunHttpTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunHttpTransportTest.php @@ -32,7 +32,7 @@ public function testToString(MailgunHttpTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunTransportFactoryTest.php index 118964995028a..a88f1e153a8ff 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Mailgun\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunApiTransport; use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunHttpTransport; use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunSmtpTransport; @@ -23,10 +25,10 @@ class MailgunTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new MailgunTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new MailgunTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('mailgun+api', 'default'), @@ -59,54 +61,53 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $client = $this->getClient(); - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $client = new MockHttpClient(); + $logger = new NullLogger(); yield [ new Dsn('mailgun+api', 'default', self::USER, self::PASSWORD), - new MailgunApiTransport(self::USER, self::PASSWORD, null, $client, $dispatcher, $logger), + new MailgunApiTransport(self::USER, self::PASSWORD, null, $client, null, $logger), ]; yield [ new Dsn('mailgun+api', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu']), - new MailgunApiTransport(self::USER, self::PASSWORD, 'eu', $client, $dispatcher, $logger), + new MailgunApiTransport(self::USER, self::PASSWORD, 'eu', $client, null, $logger), ]; yield [ new Dsn('mailgun+api', 'example.com', self::USER, self::PASSWORD, 8080), - (new MailgunApiTransport(self::USER, self::PASSWORD, null, $client, $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new MailgunApiTransport(self::USER, self::PASSWORD, null, $client, null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('mailgun', 'default', self::USER, self::PASSWORD), - new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, $dispatcher, $logger), + new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, null, $logger), ]; yield [ new Dsn('mailgun+https', 'default', self::USER, self::PASSWORD), - new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, $dispatcher, $logger), + new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, null, $logger), ]; yield [ new Dsn('mailgun+https', 'example.com', self::USER, self::PASSWORD, 8080), - (new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('mailgun+smtp', 'default', self::USER, self::PASSWORD), - new MailgunSmtpTransport(self::USER, self::PASSWORD, null, $dispatcher, $logger), + new MailgunSmtpTransport(self::USER, self::PASSWORD, null, null, $logger), ]; yield [ new Dsn('mailgun+smtps', 'default', self::USER, self::PASSWORD), - new MailgunSmtpTransport(self::USER, self::PASSWORD, null, $dispatcher, $logger), + new MailgunSmtpTransport(self::USER, self::PASSWORD, null, null, $logger), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('mailgun+foo', 'default', self::USER, self::PASSWORD), @@ -114,7 +115,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('mailgun+api', 'default', self::USER)]; diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json index d8fc4bcde3b81..0b8d5a7b2080a 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^5.2.6|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/Mailjet/LICENSE b/src/Symfony/Component/Mailer/Bridge/Mailjet/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailjet/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Mailjet/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetApiTransportTest.php index e2fdaed75e38c..703b01dc34e31 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetApiTransportTest.php @@ -34,7 +34,7 @@ public function testToString(MailjetApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ @@ -254,7 +254,7 @@ public function testSendWithMalformedResponse(array $body) $transport->send($email); } - public function getMalformedResponse(): \Generator + public static function getMalformedResponse(): \Generator { yield 'Missing Messages key' => [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetTransportFactoryTest.php index 5ecd964949a72..224ef14eef907 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailjet/Tests/Transport/MailjetTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Mailjet\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetApiTransport; use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetSmtpTransport; use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory; @@ -22,10 +24,10 @@ class MailjetTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new MailjetTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new MailjetTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('mailjet+api', 'default'), @@ -53,38 +55,37 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $logger = new NullLogger(); yield [ new Dsn('mailjet+api', 'default', self::USER, self::PASSWORD), - new MailjetApiTransport(self::USER, self::PASSWORD, $this->getClient(), $dispatcher, $logger), + new MailjetApiTransport(self::USER, self::PASSWORD, new MockHttpClient(), null, $logger), ]; yield [ new Dsn('mailjet+api', 'example.com', self::USER, self::PASSWORD), - (new MailjetApiTransport(self::USER, self::PASSWORD, $this->getClient(), $dispatcher, $logger))->setHost('example.com'), + (new MailjetApiTransport(self::USER, self::PASSWORD, new MockHttpClient(), null, $logger))->setHost('example.com'), ]; yield [ new Dsn('mailjet', 'default', self::USER, self::PASSWORD), - new MailjetSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger), + new MailjetSmtpTransport(self::USER, self::PASSWORD, null, $logger), ]; yield [ new Dsn('mailjet+smtp', 'default', self::USER, self::PASSWORD), - new MailjetSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger), + new MailjetSmtpTransport(self::USER, self::PASSWORD, null, $logger), ]; yield [ new Dsn('mailjet+smtps', 'default', self::USER, self::PASSWORD), - new MailjetSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger), + new MailjetSmtpTransport(self::USER, self::PASSWORD, null, $logger), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('mailjet+foo', 'mailjet', self::USER, self::PASSWORD), @@ -92,7 +93,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('mailjet+smtp', 'default')]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Mailjet/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailjet/composer.json index 59e9204e28b3a..195ba77e87db0 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailjet/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailjet/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^4.4|^5.0|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/LICENSE b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpApiTransportTest.php index 941f288e6fd4e..20caf7491915c 100644 --- a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpApiTransportTest.php @@ -32,7 +32,7 @@ public function testToString(OhMySmtpApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData(): array + public static function getTransportData(): array { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpTransportFactoryTest.php index 10445a1176234..d8b8a6a3fa991 100644 --- a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/Tests/Transport/OhMySmtpTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\OhMySmtp\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\OhMySmtp\Transport\OhMySmtpApiTransport; use Symfony\Component\Mailer\Bridge\OhMySmtp\Transport\OhMySmtpSmtpTransport; use Symfony\Component\Mailer\Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory; @@ -22,10 +24,10 @@ final class OhMySmtpTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new OhMySmtpTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new OhMySmtpTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('ohmysmtp+api', 'default'), @@ -53,38 +55,37 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $logger = new NullLogger(); yield [ new Dsn('ohmysmtp+api', 'default', self::USER), - new OhMySmtpApiTransport(self::USER, $this->getClient(), $dispatcher, $logger), + new OhMySmtpApiTransport(self::USER, new MockHttpClient(), null, $logger), ]; yield [ new Dsn('ohmysmtp+api', 'example.com', self::USER, '', 8080), - (new OhMySmtpApiTransport(self::USER, $this->getClient(), $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new OhMySmtpApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('ohmysmtp', 'default', self::USER), - new OhMySmtpSmtpTransport(self::USER, $dispatcher, $logger), + new OhMySmtpSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('ohmysmtp+smtp', 'default', self::USER), - new OhMySmtpSmtpTransport(self::USER, $dispatcher, $logger), + new OhMySmtpSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('ohmysmtp+smtps', 'default', self::USER), - new OhMySmtpSmtpTransport(self::USER, $dispatcher, $logger), + new OhMySmtpSmtpTransport(self::USER, null, $logger), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('ohmysmtp+foo', 'default', self::USER), @@ -92,7 +93,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('ohmysmtp+api', 'default')]; } diff --git a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/composer.json b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/composer.json index bdf80d6f61296..31dbbe35aeacd 100644 --- a/src/Symfony/Component/Mailer/Bridge/OhMySmtp/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/OhMySmtp/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^5.3.0|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/LICENSE b/src/Symfony/Component/Mailer/Bridge/Postmark/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkApiTransportTest.php index 4f89cc2fe94e8..7ffe6920099df 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkApiTransportTest.php @@ -35,7 +35,7 @@ public function testToString(PostmarkApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkTransportFactoryTest.php index d6d3263c5c760..33a6b66ab1d89 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/Tests/Transport/PostmarkTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Postmark\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkApiTransport; use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkSmtpTransport; use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory; @@ -22,10 +24,10 @@ class PostmarkTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new PostmarkTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new PostmarkTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('postmark+api', 'default'), @@ -53,48 +55,47 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $logger = new NullLogger(); yield [ new Dsn('postmark+api', 'default', self::USER), - new PostmarkApiTransport(self::USER, $this->getClient(), $dispatcher, $logger), + new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger), ]; yield [ new Dsn('postmark+api', 'example.com', self::USER, '', 8080), - (new PostmarkApiTransport(self::USER, $this->getClient(), $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('postmark+api', 'example.com', self::USER, '', 8080, ['message_stream' => 'broadcasts']), - (new PostmarkApiTransport(self::USER, $this->getClient(), $dispatcher, $logger))->setHost('example.com')->setPort(8080)->setMessageStream('broadcasts'), + (new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080)->setMessageStream('broadcasts'), ]; yield [ new Dsn('postmark', 'default', self::USER), - new PostmarkSmtpTransport(self::USER, $dispatcher, $logger), + new PostmarkSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('postmark+smtp', 'default', self::USER), - new PostmarkSmtpTransport(self::USER, $dispatcher, $logger), + new PostmarkSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('postmark+smtps', 'default', self::USER), - new PostmarkSmtpTransport(self::USER, $dispatcher, $logger), + new PostmarkSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('postmark+smtps', 'default', self::USER, null, null, ['message_stream' => 'broadcasts']), - (new PostmarkSmtpTransport(self::USER, $dispatcher, $logger))->setMessageStream('broadcasts'), + (new PostmarkSmtpTransport(self::USER, null, $logger))->setMessageStream('broadcasts'), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('postmark+foo', 'default', self::USER), @@ -102,7 +103,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('postmark+api', 'default')]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json index 94b6c04b40006..840d53656f328 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^5.2.6|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/LICENSE b/src/Symfony/Component/Mailer/Bridge/Sendgrid/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php index 6c4a48be3574d..99b0799ea5215 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php @@ -31,7 +31,7 @@ public function testToString(SendgridApiTransport $transport, string $expected) $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { return [ [ diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridTransportFactoryTest.php index cb4f775e2a5b4..433e905add6c5 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Sendgrid\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridApiTransport; use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridSmtpTransport; use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory; @@ -22,10 +24,10 @@ class SendgridTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new SendgridTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new SendgridTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('sendgrid+api', 'default'), @@ -53,38 +55,37 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $dispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $logger = new NullLogger(); yield [ new Dsn('sendgrid+api', 'default', self::USER), - new SendgridApiTransport(self::USER, $this->getClient(), $dispatcher, $logger), + new SendgridApiTransport(self::USER, new MockHttpClient(), null, $logger), ]; yield [ new Dsn('sendgrid+api', 'example.com', self::USER, '', 8080), - (new SendgridApiTransport(self::USER, $this->getClient(), $dispatcher, $logger))->setHost('example.com')->setPort(8080), + (new SendgridApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080), ]; yield [ new Dsn('sendgrid', 'default', self::USER), - new SendgridSmtpTransport(self::USER, $dispatcher, $logger), + new SendgridSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('sendgrid+smtp', 'default', self::USER), - new SendgridSmtpTransport(self::USER, $dispatcher, $logger), + new SendgridSmtpTransport(self::USER, null, $logger), ]; yield [ new Dsn('sendgrid+smtps', 'default', self::USER), - new SendgridSmtpTransport(self::USER, $dispatcher, $logger), + new SendgridSmtpTransport(self::USER, null, $logger), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('sendgrid+foo', 'sendgrid', self::USER), @@ -92,7 +93,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('sendgrid+api', 'default')]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json index 1fd5575c0f027..0aa4efa1ee1bd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^4.4|^5.0|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/Bridge/Sendinblue/LICENSE b/src/Symfony/Component/Mailer/Bridge/Sendinblue/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendinblue/LICENSE +++ b/src/Symfony/Component/Mailer/Bridge/Sendinblue/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueApiTransportTest.php b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueApiTransportTest.php index 94228dbca47d2..18953db88c604 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueApiTransportTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueApiTransportTest.php @@ -34,7 +34,7 @@ public function testToString(SendinblueApiTransport $transport, string $expected $this->assertSame($expected, (string) $transport); } - public function getTransportData() + public static function getTransportData() { yield [ new SendinblueApiTransport('ACCESS_KEY'), diff --git a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueTransportFactoryTest.php b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueTransportFactoryTest.php index f2da4a69051d1..08a5048c53d9e 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Tests/Transport/SendinblueTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Bridge\Sendinblue\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueApiTransport; use Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueSmtpTransport; use Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueTransportFactory; @@ -22,10 +24,10 @@ class SendinblueTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new SendinblueTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new SendinblueTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('sendinblue', 'default'), @@ -48,30 +50,30 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ new Dsn('sendinblue', 'default', self::USER, self::PASSWORD), - new SendinblueSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + new SendinblueSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()), ]; yield [ new Dsn('sendinblue+smtp', 'default', self::USER, self::PASSWORD), - new SendinblueSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + new SendinblueSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()), ]; yield [ new Dsn('sendinblue+smtp', 'default', self::USER, self::PASSWORD, 465), - new SendinblueSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + new SendinblueSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()), ]; yield [ new Dsn('sendinblue+api', 'default', self::USER), - new SendinblueApiTransport(self::USER, $this->getClient(), $this->getDispatcher(), $this->getLogger()), + new SendinblueApiTransport(self::USER, new MockHttpClient(), null, new NullLogger()), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('sendinblue+foo', 'default', self::USER, self::PASSWORD), @@ -79,7 +81,7 @@ public function unsupportedSchemeProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield [new Dsn('sendinblue+smtp', 'default', self::USER)]; diff --git a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueApiTransport.php index eca54c2fd660d..0a43deb97f65d 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueApiTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueApiTransport.php @@ -136,7 +136,7 @@ private function prepareAttachments(Email $email): array private function prepareHeadersAndTags(Headers $headers): array { $headersAndTags = []; - $headersToBypass = ['from', 'to', 'cc', 'bcc', 'subject', 'reply-to', 'content-type', 'accept', 'api-key']; + $headersToBypass = ['from', 'sender', 'to', 'cc', 'bcc', 'subject', 'reply-to', 'content-type', 'accept', 'api-key']; foreach ($headers->all() as $name => $header) { if (\in_array($name, $headersToBypass, true)) { continue; diff --git a/src/Symfony/Component/Mailer/Bridge/Sendinblue/composer.json b/src/Symfony/Component/Mailer/Bridge/Sendinblue/composer.json index a97a19392b547..42f547947e4de 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendinblue/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Sendinblue/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", - "symfony/mailer": "^5.1|^6.0" + "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" diff --git a/src/Symfony/Component/Mailer/CHANGELOG.md b/src/Symfony/Component/Mailer/CHANGELOG.md index cc6cd6f19845c..bdeffe4d23598 100644 --- a/src/Symfony/Component/Mailer/CHANGELOG.md +++ b/src/Symfony/Component/Mailer/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +5.4.21 +------ + + * [BC BREAK] The following data providers for `TransportFactoryTestCase` are now static: + `supportsProvider()`, `createProvider()`, `unsupportedSchemeProvider()`and `incompleteDsnProvider()` + 5.4 --- diff --git a/src/Symfony/Component/Mailer/LICENSE b/src/Symfony/Component/Mailer/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Mailer/LICENSE +++ b/src/Symfony/Component/Mailer/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php b/src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php index c2426a0bf27db..121643f01a158 100644 --- a/src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php +++ b/src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php @@ -37,16 +37,16 @@ abstract class TransportFactoryTestCase extends TestCase abstract public function getFactory(): TransportFactoryInterface; - abstract public function supportsProvider(): iterable; + abstract public static function supportsProvider(): iterable; - abstract public function createProvider(): iterable; + abstract public static function createProvider(): iterable; - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { return []; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { return []; } @@ -102,7 +102,7 @@ public function testIncompleteDsnException(Dsn $dsn) protected function getDispatcher(): EventDispatcherInterface { - return $this->dispatcher ?? $this->dispatcher = $this->createMock(EventDispatcherInterface::class); + return $this->dispatcher ?? $this->dispatcher = $this->createMock(EventDispatcherInterface::class); } protected function getClient(): HttpClientInterface diff --git a/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php b/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php index 2b2e5dfe8e561..5f5def704bf33 100644 --- a/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php +++ b/src/Symfony/Component/Mailer/Tests/EventListener/MessageListenerTest.php @@ -36,7 +36,7 @@ public function testHeaders(Headers $initialHeaders, Headers $defaultHeaders, He $this->assertEquals($expectedHeaders, $event->getMessage()->getHeaders()); } - public function provideHeaders(): iterable + public static function provideHeaders(): iterable { $initialHeaders = new Headers(); $defaultHeaders = (new Headers()) diff --git a/src/Symfony/Component/Mailer/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Mailer/Tests/Exception/UnsupportedSchemeExceptionTest.php index 54ce6dbe5a38c..9a7abadd00070 100644 --- a/src/Symfony/Component/Mailer/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Mailer/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -59,7 +59,7 @@ public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme, ); } - public function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator { yield ['gmail', 'symfony/google-mailer']; yield ['mailgun', 'symfony/mailgun-mailer']; @@ -83,7 +83,7 @@ public function testMessageWhereSchemeIsNotPartOfSchemeToPackageMap(string $expe ); } - public function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator { yield [ 'The "somethingElse" scheme is not supported.', diff --git a/src/Symfony/Component/Mailer/Tests/Transport/DsnTest.php b/src/Symfony/Component/Mailer/Tests/Transport/DsnTest.php index 2816333ff3981..f3c0a0bc7f804 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/DsnTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/DsnTest.php @@ -45,7 +45,7 @@ public function testInvalidDsn(string $dsn, string $exceptionMessage) Dsn::fromString($dsn); } - public function fromStringProvider(): iterable + public static function fromStringProvider(): iterable { yield 'simple smtp without user and pass' => [ 'smtp://example.com', @@ -88,7 +88,7 @@ public function fromStringProvider(): iterable ]; } - public function invalidDsnProvider(): iterable + public static function invalidDsnProvider(): iterable { yield [ 'some://', diff --git a/src/Symfony/Component/Mailer/Tests/Transport/NativeTransportFactoryTest.php b/src/Symfony/Component/Mailer/Tests/Transport/NativeTransportFactoryTest.php index 556a01acf2338..c253b4c7cb503 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/NativeTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/NativeTransportFactoryTest.php @@ -47,7 +47,7 @@ function ini_get(\$key) public function testCreateWithNotSupportedScheme() { $this->expectException(UnsupportedSchemeException::class); - $this->expectErrorMessageMatches('#The ".*" scheme is not supported#'); + $this->expectExceptionMessage('The "sendmail" scheme is not supported'); $sut = new NativeTransportFactory(); $sut->create(Dsn::fromString('sendmail://default')); @@ -66,7 +66,7 @@ public function testCreateSendmailWithNoSendmailPath() $sut->create(Dsn::fromString('native://default')); } - public function provideCreateSendmailWithNoHostOrNoPort(): \Generator + public static function provideCreateSendmailWithNoHostOrNoPort(): \Generator { yield ['native://default', '', '', '']; yield ['native://default', '', 'localhost', '']; @@ -95,7 +95,7 @@ public function testCreateSendmailWithNoHostOrNoPort(string $dsn, string $sendma $sut->create(Dsn::fromString($dsn)); } - public function provideCreate(): \Generator + public static function provideCreate(): \Generator { yield ['native://default', '/usr/sbin/sendmail -t -i', '', '', new SendmailTransport('/usr/sbin/sendmail -t -i')]; diff --git a/src/Symfony/Component/Mailer/Tests/Transport/NullTransportFactoryTest.php b/src/Symfony/Component/Mailer/Tests/Transport/NullTransportFactoryTest.php index 9b39a6140b6c3..b28935a75d4f5 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/NullTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/NullTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\NullTransport; @@ -21,10 +23,10 @@ class NullTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new NullTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new NullTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('null', ''), @@ -32,11 +34,11 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ new Dsn('null', 'null'), - new NullTransport($this->getDispatcher(), $this->getLogger()), + new NullTransport(null, new NullLogger()), ]; } } diff --git a/src/Symfony/Component/Mailer/Tests/Transport/SendmailTransportFactoryTest.php b/src/Symfony/Component/Mailer/Tests/Transport/SendmailTransportFactoryTest.php index 55f893b0ad987..a3d08f5933359 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/SendmailTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/SendmailTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\SendmailTransport; @@ -21,10 +23,10 @@ class SendmailTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new SendmailTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new SendmailTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('sendmail+smtp', 'default'), @@ -32,20 +34,20 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ new Dsn('sendmail+smtp', 'default'), - new SendmailTransport(null, $this->getDispatcher(), $this->getLogger()), + new SendmailTransport(null, null, new NullLogger()), ]; yield [ new Dsn('sendmail+smtp', 'default', null, null, null, ['command' => '/usr/sbin/sendmail -oi -t']), - new SendmailTransport('/usr/sbin/sendmail -oi -t', $this->getDispatcher(), $this->getLogger()), + new SendmailTransport('/usr/sbin/sendmail -oi -t', null, new NullLogger()), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('sendmail+http', 'default'), diff --git a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php index 5d75f15d17d49..4978935bcd451 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Tests\Transport\Smtp; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; @@ -22,10 +24,10 @@ class EsmtpTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new EsmtpTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new EsmtpTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('smtp', 'example.com'), @@ -43,19 +45,18 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $eventDispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $logger = new NullLogger(); - $transport = new EsmtpTransport('localhost', 25, false, $eventDispatcher, $logger); + $transport = new EsmtpTransport('localhost', 25, false, null, $logger); yield [ new Dsn('smtp', 'localhost'), $transport, ]; - $transport = new EsmtpTransport('example.com', 99, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 99, true, null, $logger); $transport->setUsername(self::USER); $transport->setPassword(self::PASSWORD); @@ -64,21 +65,21 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); yield [ new Dsn('smtps', 'example.com'), $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); yield [ new Dsn('smtps', 'example.com', '', '', 465), $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); /** @var SocketStream $stream */ $stream = $transport->getStream(); $streamOptions = $stream->getStreamOptions(); @@ -101,14 +102,14 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); yield [ Dsn::fromString('smtps://:@example.com?verify_peer='), $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setLocalDomain('example.com'); yield [ @@ -116,7 +117,7 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setRestartThreshold(10, 1); yield [ @@ -124,7 +125,7 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setPingThreshold(10); yield [ diff --git a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/AbstractStreamTest.php b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/AbstractStreamTest.php index cc901ccb7ceab..aeb2834c01922 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/AbstractStreamTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/AbstractStreamTest.php @@ -29,7 +29,7 @@ public function testReplace(string $expected, string $from, string $to, array $c $this->assertSame($expected, $result); } - public function provideReplace() + public static function provideReplace() { yield ['ca', 'ab', 'c', ['a', 'b', 'a']]; yield ['ac', 'ab', 'c', ['a', 'ab']]; diff --git a/src/Symfony/Component/Mailer/Tests/TransportTest.php b/src/Symfony/Component/Mailer/Tests/TransportTest.php index 690b0eed766fc..3ffd706cfaea0 100644 --- a/src/Symfony/Component/Mailer/Tests/TransportTest.php +++ b/src/Symfony/Component/Mailer/Tests/TransportTest.php @@ -34,7 +34,7 @@ public function testFromString(string $dsn, TransportInterface $transport) $this->assertEquals($transport, $transportFactory->fromString($dsn)); } - public function fromStringProvider(): iterable + public static function fromStringProvider(): iterable { $transportA = new DummyTransport('a'); $transportB = new DummyTransport('b'); @@ -68,7 +68,7 @@ public function testFromDsn(string $dsn, TransportInterface $transport) $this->assertEquals($transport, Transport::fromDsn($dsn)); } - public function fromDsnProvider(): iterable + public static function fromDsnProvider(): iterable { yield 'multiple transports' => [ 'failover(smtp://a smtp://b)', @@ -88,7 +88,7 @@ public function testFromWrongString(string $dsn, string $error) $transportFactory->fromString($dsn); } - public function fromWrongStringProvider(): iterable + public static function fromWrongStringProvider(): iterable { yield 'garbage at the end' => ['dummy://a some garbage here', 'The DSN has some garbage at the end: " some garbage here".']; diff --git a/src/Symfony/Component/Mailer/composer.json b/src/Symfony/Component/Mailer/composer.json index 86093d875feee..42416e1a91dfa 100644 --- a/src/Symfony/Component/Mailer/composer.json +++ b/src/Symfony/Component/Mailer/composer.json @@ -27,7 +27,7 @@ "symfony/service-contracts": "^1.1|^2|^3" }, "require-dev": { - "symfony/http-client-contracts": "^1.1|^2|^3", + "symfony/http-client": "^4.4|^5.0|^6.0", "symfony/messenger": "^4.4|^5.0|^6.0" }, "conflict": { diff --git a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/LICENSE b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/LICENSE +++ b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php index 6f3b906a5a188..b36f02a8850d0 100644 --- a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php @@ -277,7 +277,7 @@ public function testInjectQueueUrl(string $dsn, string $queueUrl) $this->assertSame($queueUrl, $queueProperty->getValue($connection)); } - public function provideQueueUrl() + public static function provideQueueUrl() { yield ['https://sqs.us-east-2.amazonaws.com/123456/queue', 'https://sqs.us-east-2.amazonaws.com/123456/queue']; yield ['https://KEY:SECRET@sqs.us-east-2.amazonaws.com/123456/queue', 'https://sqs.us-east-2.amazonaws.com/123456/queue']; @@ -298,7 +298,7 @@ public function testNotInjectQueueUrl(string $dsn) $this->assertNull($queueProperty->getValue($connection)); } - public function provideNotQueueUrl() + public static function provideNotQueueUrl() { yield ['https://sqs.us-east-2.amazonaws.com/queue']; yield ['https://us-east-2/123456/ab1-MyQueue-A2BCDEF3GHI4']; diff --git a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php index 686fd40a4cbd8..20aef2cc0b421 100644 --- a/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php @@ -26,6 +26,7 @@ * @author Jérémy Derussé * * @internal + * * @final */ class Connection diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/LICENSE b/src/Symfony/Component/Messenger/Bridge/Amqp/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/LICENSE +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpExtIntegrationTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpExtIntegrationTest.php index aa551e4e85080..fe9cfa3cfa885 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpExtIntegrationTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpExtIntegrationTest.php @@ -33,6 +33,7 @@ /** * @requires extension amqp + * * @group integration */ class AmqpExtIntegrationTest extends TestCase diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php index f2f2ac0c06843..1f98b4a725a3b 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php @@ -209,7 +209,7 @@ public function testSetsParametersOnTheQueueAndExchange() $connection->publish('body'); } - public function invalidQueueArgumentsDataProvider(): iterable + public static function invalidQueueArgumentsDataProvider(): iterable { $baseDsn = 'amqp://localhost/%2f/messages'; diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index 0595b573e8776..ab8d6f980d519 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -412,7 +412,7 @@ private function createDelayQueue(int $delay, ?string $routingKey, bool $isRetry // delete the delay queue 10 seconds after the message expires // publishing another message redeclares the queue which renews the lease 'x-expires' => $delay + 10000, - // message should be broadcasted to all consumers during delay, but to only one queue during retry + // message should be broadcast to all consumers during delay, but to only one queue during retry // empty name is default direct exchange 'x-dead-letter-exchange' => $isRetryAttempt ? '' : $this->exchangeOptions['name'], // after being released from to DLX, make sure the original routing key will be used diff --git a/src/Symfony/Component/Messenger/Bridge/Beanstalkd/LICENSE b/src/Symfony/Component/Messenger/Bridge/Beanstalkd/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/Messenger/Bridge/Beanstalkd/LICENSE +++ b/src/Symfony/Component/Messenger/Bridge/Beanstalkd/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php index 274b64478a237..4c135cd879a4d 100644 --- a/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Messenger\Bridge\Beanstalkd\Tests\Transport; -use InvalidArgumentException; use Pheanstalk\Contract\PheanstalkInterface; use Pheanstalk\Exception; use Pheanstalk\Exception\ClientException; @@ -30,7 +29,7 @@ final class ConnectionTest extends TestCase { public function testFromInvalidDsn() { - $this->expectException(InvalidArgumentException::class); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The given Beanstalkd DSN "beanstalkd://" is invalid.'); Connection::fromDsn('beanstalkd://'); diff --git a/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php index 49900cd83d32b..a8aaeae34264e 100644 --- a/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php @@ -23,6 +23,7 @@ * @author Antonio Pauletich * * @internal + * * @final */ class Connection diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/LICENSE b/src/Symfony/Component/Messenger/Bridge/Doctrine/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/LICENSE +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php index 7e576a5580dff..57690b8b1c56d 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php @@ -178,7 +178,7 @@ public function testBuildConfiguration(string $dsn, array $options, string $expe $this->assertEquals($expectedAutoSetup, $config['auto_setup']); } - public function buildConfigurationProvider(): iterable + public static function buildConfigurationProvider(): iterable { yield 'no options' => [ 'dsn' => 'doctrine://default', @@ -387,7 +387,7 @@ public function testGeneratedSql(AbstractPlatform $platform, string $expectedSql $connection->get(); } - public function providePlatformSql(): iterable + public static function providePlatformSql(): iterable { yield 'MySQL' => [ new MySQL57Platform(), diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php index a53505f6f2d11..5b4f8a248e30a 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrinePostgreSqlIntegrationTest.php @@ -20,6 +20,7 @@ /** * @requires extension pdo_pgsql + * * @group integration */ class DoctrinePostgreSqlIntegrationTest extends TestCase diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/LICENSE b/src/Symfony/Component/Messenger/Bridge/Redis/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/LICENSE +++ b/src/Symfony/Component/Messenger/Bridge/Redis/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php index 54fa7bfe7a946..c27931227eb26 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php @@ -179,7 +179,7 @@ public function testAuth($expected, string $dsn) Connection::fromDsn($dsn, ['delete_after_ack' => true], $redis); } - public function provideAuthDsn(): \Generator + public static function provideAuthDsn(): \Generator { yield 'Password only' => ['password', 'redis://password@localhost/queue']; yield 'User and password' => [['user', 'password'], 'redis://user:password@localhost/queue']; diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php index 1bfc79657ba9a..eccf4d07a3a8b 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php @@ -18,6 +18,7 @@ /** * @requires extension redis + * * @group time-sensitive * @group integration */ diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisReceiverTest.php b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisReceiverTest.php index c1f39ea31f557..903428ab3772c 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisReceiverTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisReceiverTest.php @@ -59,7 +59,7 @@ public function testItRejectTheMessageIfThereIsAMessageDecodingFailedException(a $receiver->get(); } - public function redisEnvelopeProvider(): \Generator + public static function redisEnvelopeProvider(): \Generator { yield [ [ @@ -96,7 +96,7 @@ public function redisEnvelopeProvider(): \Generator ]; } - public function rejectedRedisEnvelopeProvider(): \Generator + public static function rejectedRedisEnvelopeProvider(): \Generator { yield [ [ diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php index ffcac3e2a96b2..064c939ba4a1b 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php @@ -23,6 +23,7 @@ * @author Robin Chalas * * @internal + * * @final */ class Connection diff --git a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php index ff2f5df7e7721..b9292dd41ff70 100644 --- a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php @@ -263,11 +263,11 @@ private function convertToBytes(string $memoryLimit): int switch (substr(rtrim($memoryLimit, 'b'), -1)) { case 't': $max *= 1024; - // no break + // no break case 'g': $max *= 1024; - // no break + // no break case 'm': $max *= 1024; - // no break + // no break case 'k': $max *= 1024; } diff --git a/src/Symfony/Component/Messenger/Handler/Acknowledger.php b/src/Symfony/Component/Messenger/Handler/Acknowledger.php index a2317b78369fe..eca1609abd354 100644 --- a/src/Symfony/Component/Messenger/Handler/Acknowledger.php +++ b/src/Symfony/Component/Messenger/Handler/Acknowledger.php @@ -24,7 +24,7 @@ class Acknowledger private $result = null; /** - * @param null|\Closure(\Throwable|null, mixed):void $ack + * @param \Closure(\Throwable|null, mixed):void|null $ack */ public function __construct(string $handlerClass, \Closure $ack = null) { diff --git a/src/Symfony/Component/Messenger/LICENSE b/src/Symfony/Component/Messenger/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/Messenger/LICENSE +++ b/src/Symfony/Component/Messenger/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php b/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php index 62abf23423ddd..6d7f08bdeaa24 100644 --- a/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php +++ b/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php @@ -13,7 +13,6 @@ use Symfony\Component\ErrorHandler\Exception\FlattenException; use Symfony\Component\Messenger\Exception\HandlerFailedException; -use Throwable; /** * Stamp applied when a messages fails due to an exception in the handler. @@ -43,7 +42,7 @@ public function __construct(string $exceptionClass, $exceptionCode, string $exce $this->flattenException = $flattenException; } - public static function create(Throwable $throwable): self + public static function create(\Throwable $throwable): self { if ($throwable instanceof HandlerFailedException) { $throwable = $throwable->getPrevious(); diff --git a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php index 91a191de31498..0173052290047 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php @@ -105,7 +105,7 @@ public function testRunWithBusOption() $this->assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver"', $tester->getDisplay()); } - public function provideRunWithResetServicesOption(): iterable + public static function provideRunWithResetServicesOption(): iterable { yield [true]; yield [false]; @@ -174,7 +174,7 @@ public function testRunWithInvalidOption(string $option, string $value, string $ ]); } - public function getInvalidOptions() + public static function getInvalidOptions() { yield 'Zero message limit' => ['--limit', '0', 'Option "limit" must be a positive integer, "0" passed.']; yield 'Non-numeric message limit' => ['--limit', 'whatever', 'Option "limit" must be a positive integer, "whatever" passed.']; @@ -227,7 +227,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'receiver' => [[''], ['async', 'async_high', 'failed']]; yield 'receiver (value)' => [['async'], ['async', 'async_high', 'failed']]; diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index af2d0e3e9fa78..1aad6fcf714de 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -185,7 +185,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'bus' => [ [''], diff --git a/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php index cfe9eca20b40d..e0a57563915a4 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php @@ -101,7 +101,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'transport' => [[''], ['amqp', 'other_transport']]; } diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/ResetServicesListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/ResetServicesListenerTest.php index 12f86ec6c83cb..0e1273d6bd88b 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/ResetServicesListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/ResetServicesListenerTest.php @@ -20,7 +20,7 @@ class ResetServicesListenerTest extends TestCase { - public function provideResetServices(): iterable + public static function provideResetServices(): iterable { yield [true]; yield [false]; diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnCustomStopExceptionListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnCustomStopExceptionListenerTest.php index 9450567bedb7f..c9e6c6d5db887 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnCustomStopExceptionListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnCustomStopExceptionListenerTest.php @@ -23,7 +23,7 @@ class StopWorkerOnCustomStopExceptionListenerTest extends TestCase { - public function provideTests(): \Generator + public static function provideTests(): \Generator { yield 'it should not stop (1)' => [new \Exception(), false]; yield 'it should not stop (2)' => [new HandlerFailedException(new Envelope(new \stdClass()), [new \Exception()]), false]; diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnFailureLimitListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnFailureLimitListenerTest.php index a713a2820acb6..9d776a39e53b4 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnFailureLimitListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnFailureLimitListenerTest.php @@ -19,7 +19,6 @@ use Symfony\Component\Messenger\EventListener\StopWorkerOnFailureLimitListener; use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage; use Symfony\Component\Messenger\Worker; -use Throwable; class StopWorkerOnFailureLimitListenerTest extends TestCase { @@ -45,7 +44,7 @@ public function testWorkerStopsWhenMaximumCountReached(int $max, bool $shouldSto $failureLimitListener->onWorkerRunning($runningEvent); } - public function countProvider(): iterable + public static function countProvider(): iterable { yield [1, true]; yield [2, true]; @@ -74,6 +73,6 @@ private function createFailedEvent(): WorkerMessageFailedEvent { $envelope = new Envelope(new DummyMessage('hello')); - return new WorkerMessageFailedEvent($envelope, 'default', $this->createMock(Throwable::class)); + return new WorkerMessageFailedEvent($envelope, 'default', $this->createMock(\Throwable::class)); } } diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMemoryLimitListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMemoryLimitListenerTest.php index 81c21a4faf95c..b39278b1be04a 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMemoryLimitListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMemoryLimitListenerTest.php @@ -36,7 +36,7 @@ public function testWorkerStopsWhenMemoryLimitExceeded(int $memoryUsage, int $me $memoryLimitListener->onWorkerRunning($event); } - public function memoryProvider(): iterable + public static function memoryProvider(): iterable { yield [2048, 1024, true]; yield [1024, 1024, false]; diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMessageLimitListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMessageLimitListenerTest.php index 7db3154f71efe..8ce9a198f08c1 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMessageLimitListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnMessageLimitListenerTest.php @@ -35,7 +35,7 @@ public function testWorkerStopsWhenMaximumCountExceeded(int $max, bool $shouldSt $maximumCountListener->onWorkerRunning($event); } - public function countProvider(): iterable + public static function countProvider(): iterable { yield [1, true]; yield [2, true]; diff --git a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnRestartSignalListenerTest.php b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnRestartSignalListenerTest.php index a9b01fbe9dddd..3b83f04268ce5 100644 --- a/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnRestartSignalListenerTest.php +++ b/src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnRestartSignalListenerTest.php @@ -43,7 +43,7 @@ public function testWorkerStopsWhenMemoryLimitExceeded(?int $lastRestartTimeOffs $stopOnSignalListener->onWorkerRunning($event); } - public function restartTimeProvider() + public static function restartTimeProvider() { yield [null, false]; // no cached restart time, do not restart yield [+10, true]; // 10 seconds after starting, a restart was requested diff --git a/src/Symfony/Component/Messenger/Tests/Handler/HandleDescriptorTest.php b/src/Symfony/Component/Messenger/Tests/Handler/HandleDescriptorTest.php index 16ad906930c59..d2ca8126873de 100644 --- a/src/Symfony/Component/Messenger/Tests/Handler/HandleDescriptorTest.php +++ b/src/Symfony/Component/Messenger/Tests/Handler/HandleDescriptorTest.php @@ -27,7 +27,7 @@ public function testDescriptorNames(callable $handler, ?string $expectedHandlerS $this->assertStringMatchesFormat($expectedHandlerString, $descriptor->getName()); } - public function provideHandlers(): iterable + public static function provideHandlers(): iterable { yield [function () {}, 'Closure']; yield ['var_dump', 'var_dump']; diff --git a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php index fc0d638bb1ca3..b0eb3ec12afcf 100644 --- a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php +++ b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php @@ -141,7 +141,7 @@ public function testItAddsTheStampsToEnvelope() $this->assertCount(2, $finalEnvelope->all()); } - public function provideConstructorDataStucture(): iterable + public static function provideConstructorDataStucture(): iterable { yield 'iterator' => [new \ArrayObject([ new SimpleMiddleware(), diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php index eb0beaa8a5848..015ba74406b7a 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php @@ -67,7 +67,7 @@ public function testItAddsHandledStamps(array $handlers, array $expectedStamps, $this->assertEquals($expectedStamps, $envelope->all(HandledStamp::class)); } - public function itAddsHandledStampsProvider(): iterable + public static function itAddsHandledStampsProvider(): iterable { $first = new class() extends HandleMessageMiddlewareTestCallable { public function __invoke() diff --git a/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php b/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php index e2fdb4b2a82f3..5c37aa6bf547c 100644 --- a/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php +++ b/src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php @@ -60,7 +60,7 @@ public function testGetWaitTime(int $delay, float $multiplier, int $maxDelay, in $this->assertSame($expectedDelay, $strategy->getWaitingTime($envelope)); } - public function getWaitTimeTests(): iterable + public static function getWaitTimeTests(): iterable { // delay, multiplier, maxDelay, retries, expectedDelay yield [1000, 1, 5000, 0, 1000]; diff --git a/src/Symfony/Component/Messenger/Tests/Transport/InMemoryTransportFactoryTest.php b/src/Symfony/Component/Messenger/Tests/Transport/InMemoryTransportFactoryTest.php index d29ab10639da2..51ebc2f0a27ff 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/InMemoryTransportFactoryTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/InMemoryTransportFactoryTest.php @@ -89,7 +89,7 @@ public function testResetCreatedTransports() $this->assertCount(0, $transport->get()); } - public function provideDSN(): array + public static function provideDSN(): array { return [ 'Supported' => ['in-memory://foo'], diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php index 971b0c487ee44..87967140b3c26 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php @@ -63,7 +63,7 @@ public function testNormalize(FlattenException $exception) $this->assertSame($exception->getStatusText(), $normalized['status_text']); } - public function provideFlattenException(): array + public static function provideFlattenException(): array { return [ 'instance from exception' => [FlattenException::createFromThrowable(new \RuntimeException('foo', 42))], diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php index 6f4d3bad313d1..d749d2d17fb7f 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php @@ -164,7 +164,7 @@ public function testDecodingFailsWithMissingKeys(array $data, string $expectedMe $serializer->decode($data); } - public function getMissingKeyTests(): iterable + public static function getMissingKeyTests(): iterable { yield 'no_body' => [ ['headers' => ['type' => 'bar']], diff --git a/src/Symfony/Component/Messenger/Transport/Receiver/ReceiverInterface.php b/src/Symfony/Component/Messenger/Transport/Receiver/ReceiverInterface.php index 68f72c5021167..01e1ca9f2cb83 100644 --- a/src/Symfony/Component/Messenger/Transport/Receiver/ReceiverInterface.php +++ b/src/Symfony/Component/Messenger/Transport/Receiver/ReceiverInterface.php @@ -39,9 +39,9 @@ interface ReceiverInterface * be retried again (e.g. if there's a queue, it should be removed) * and a MessageDecodingFailedException should be thrown. * - * @throws TransportException If there is an issue communicating with the transport - * * @return Envelope[] + * + * @throws TransportException If there is an issue communicating with the transport */ public function get(): iterable; diff --git a/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php b/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php index c6c7559af1004..7964aa1cf7118 100644 --- a/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php +++ b/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php @@ -24,7 +24,7 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface private $magicFile; /** - * @param string $magicFile A magic file to use with the finfo instance + * @param string|null $magicFile A magic file to use with the finfo instance * * @see http://www.php.net/manual/en/function.finfo-open.php */ diff --git a/src/Symfony/Component/Mime/Header/MailboxListHeader.php b/src/Symfony/Component/Mime/Header/MailboxListHeader.php index 1d00fdb12c3da..ee2a26cf2f799 100644 --- a/src/Symfony/Component/Mime/Header/MailboxListHeader.php +++ b/src/Symfony/Component/Mime/Header/MailboxListHeader.php @@ -44,9 +44,9 @@ public function setBody($body) } /** - * @throws RfcComplianceException - * * @return Address[] + * + * @throws RfcComplianceException */ public function getBody(): array { @@ -99,9 +99,9 @@ public function getAddresses(): array /** * Gets the full mailbox list of this Header as an array of valid RFC 2822 strings. * - * @throws RfcComplianceException - * * @return string[] + * + * @throws RfcComplianceException */ public function getAddressStrings(): array { diff --git a/src/Symfony/Component/Mime/LICENSE b/src/Symfony/Component/Mime/LICENSE index 58b42bc8a98fe..4dd83ce0f173e 100644 --- a/src/Symfony/Component/Mime/LICENSE +++ b/src/Symfony/Component/Mime/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2023 Fabien Potencier +Copyright (c) 2010-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php similarity index 98% rename from src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php rename to src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php index fb9ad1ef1458c..ed12d6df67efd 100644 --- a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php +++ b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Mime\MimeTypeGuesserInterface; -abstract class AbstractMimeTypeGuesserTest extends TestCase +abstract class AbstractMimeTypeGuesserTestCase extends TestCase { public static function tearDownAfterClass(): void { diff --git a/src/Symfony/Component/Mime/Tests/AddressTest.php b/src/Symfony/Component/Mime/Tests/AddressTest.php index a0f2164b5547b..fe10c73910bde 100644 --- a/src/Symfony/Component/Mime/Tests/AddressTest.php +++ b/src/Symfony/Component/Mime/Tests/AddressTest.php @@ -87,13 +87,14 @@ public function testNameEmpty(string $name) $this->assertSame($mail, (new Address($mail, $name))->toString()); } - public function nameEmptyDataProvider(): array + public static function nameEmptyDataProvider(): array { return [[''], [' '], [" \r\n "]]; } /** * @dataProvider fromStringProvider + * * @group legacy */ public function testFromString($string, $displayName, $addrSpec) @@ -115,7 +116,7 @@ public function testFromStringFailure() Address::fromString('Jane Doe assertEquals($header, $signedMessage->getHeaders()->get('DKIM-Signature')->getBody()); } - public function getSignData() + public static function getSignData() { yield 'simple/simple' => [ 1591597074, DkimSigner::CANON_SIMPLE, DkimSigner::CANON_SIMPLE, @@ -132,7 +133,7 @@ public function testCanonicalizeHeader(string $bodyCanon, string $canonBody, str $this->assertEquals(\strlen($canonBody), $l); } - public function getCanonicalizeHeaderData() + public static function getCanonicalizeHeaderData() { yield 'simple_empty' => [ DkimSigner::CANON_SIMPLE, "\r\n", '', \PHP_INT_MAX, diff --git a/src/Symfony/Component/Mime/Tests/FileBinaryMimeTypeGuesserTest.php b/src/Symfony/Component/Mime/Tests/FileBinaryMimeTypeGuesserTest.php index 5d225038d4336..eae27fd517681 100644 --- a/src/Symfony/Component/Mime/Tests/FileBinaryMimeTypeGuesserTest.php +++ b/src/Symfony/Component/Mime/Tests/FileBinaryMimeTypeGuesserTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Mime\FileBinaryMimeTypeGuesser; use Symfony\Component\Mime\MimeTypeGuesserInterface; -class FileBinaryMimeTypeGuesserTest extends AbstractMimeTypeGuesserTest +class FileBinaryMimeTypeGuesserTest extends AbstractMimeTypeGuesserTestCase { protected function getGuesser(): MimeTypeGuesserInterface { diff --git a/src/Symfony/Component/Mime/Tests/FileinfoMimeTypeGuesserTest.php b/src/Symfony/Component/Mime/Tests/FileinfoMimeTypeGuesserTest.php index d2e6930a4b9c3..0d7815c99d362 100644 --- a/src/Symfony/Component/Mime/Tests/FileinfoMimeTypeGuesserTest.php +++ b/src/Symfony/Component/Mime/Tests/FileinfoMimeTypeGuesserTest.php @@ -17,7 +17,7 @@ /** * @requires extension fileinfo */ -class FileinfoMimeTypeGuesserTest extends AbstractMimeTypeGuesserTest +class FileinfoMimeTypeGuesserTest extends AbstractMimeTypeGuesserTestCase { protected function getGuesser(): MimeTypeGuesserInterface { diff --git a/src/Symfony/Component/Mime/Tests/MimeTypesTest.php b/src/Symfony/Component/Mime/Tests/MimeTypesTest.php index 50d99ae5159a7..0351a4d293876 100644 --- a/src/Symfony/Component/Mime/Tests/MimeTypesTest.php +++ b/src/Symfony/Component/Mime/Tests/MimeTypesTest.php @@ -18,7 +18,7 @@ /** * @requires extension fileinfo */ -class MimeTypesTest extends AbstractMimeTypeGuesserTest +class MimeTypesTest extends AbstractMimeTypeGuesserTestCase { protected function getGuesser(): MimeTypeGuesserInterface { diff --git a/src/Symfony/Component/Mime/Tests/RawMessageTest.php b/src/Symfony/Component/Mime/Tests/RawMessageTest.php index 41503451bb1da..264e465dea666 100644 --- a/src/Symfony/Component/Mime/Tests/RawMessageTest.php +++ b/src/Symfony/Component/Mime/Tests/RawMessageTest.php @@ -29,7 +29,7 @@ public function testToString($messageParameter) $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable()))); } - public function provideMessages(): array + public static function provideMessages(): array { return [ 'string' => ['some string'], diff --git a/src/Symfony/Component/Notifier/Bridge/AllMySms/LICENSE b/src/Symfony/Component/Notifier/Bridge/AllMySms/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/AllMySms/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/AllMySms/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportFactoryTest.php index a523d3ae24c68..9f35fa3d31443 100644 --- a/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new AllMySmsTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'allmysms://host.test', @@ -38,13 +38,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'allmysms://login:apiKey@default']; yield [false, 'somethingElse://login:apiKey@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://login:apiKey@default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportTest.php index 2cafefca79f68..118860c772baa 100644 --- a/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\AllMySms\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\AllMySms\AllMySmsTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,25 +25,25 @@ final class AllMySmsTransportTest extends TransportTestCase /** * @return AllMySmsTransport */ - public function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface { - return new AllMySmsTransport('login', 'apiKey', $from, $client ?? $this->createMock(HttpClientInterface::class)); + return new AllMySmsTransport('login', 'apiKey', $from, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['allmysms://api.allmysms.com', $this->createTransport()]; - yield ['allmysms://api.allmysms.com?from=TEST', $this->createTransport(null, 'TEST')]; + yield ['allmysms://api.allmysms.com', self::createTransport()]; + yield ['allmysms://api.allmysms.com?from=TEST', self::createTransport(null, 'TEST')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/AllMySms/composer.json b/src/Symfony/Component/Notifier/Bridge/AllMySms/composer.json index 0cb25fcf9af40..130466341fcc0 100644 --- a/src/Symfony/Component/Notifier/Bridge/AllMySms/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/AllMySms/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\AllMySms\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/AmazonSns/LICENSE b/src/Symfony/Component/Notifier/Bridge/AmazonSns/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/AmazonSns/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/AmazonSns/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportFactoryTest.php index 0fe0e72061c2d..ffbfc5e383f95 100644 --- a/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportFactoryTest.php @@ -22,20 +22,20 @@ public function createFactory(): TransportFactoryInterface return new AmazonSnsTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield ['sns://host.test?region=us-east-1', 'sns://host.test']; yield ['sns://host.test?region=us-east-1', 'sns://accessId:accessKey@host.test']; yield ['sns://host.test?region=eu-west-3', 'sns://host.test?region=eu-west-3']; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'sns://default']; yield [false, 'somethingElse://default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportTest.php index 346a7eb5de299..53c2711106f5b 100644 --- a/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportTest.php @@ -13,38 +13,39 @@ use AsyncAws\Sns\Result\PublishResponse; use AsyncAws\Sns\SnsClient; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\AmazonSns\AmazonSnsOptions; use Symfony\Component\Notifier\Bridge\AmazonSns\AmazonSnsTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; -use Symfony\Component\Notifier\Message\MessageOptionsInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Fixtures\TestOptions; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; class AmazonSnsTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new AmazonSnsTransport(new SnsClient(['region' => 'eu-west-3']), $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new AmazonSnsTransport(new SnsClient(['region' => 'eu-west-3']), $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['sns://host.test?region=eu-west-3', $this->createTransport()]; + yield ['sns://host.test?region=eu-west-3', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0601020304', 'Hello!')]; yield [new ChatMessage('Hello', new AmazonSnsOptions('my-topic'))]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { - yield [$this->createMock(MessageInterface::class)]; - yield [new ChatMessage('hello', $this->createMock(MessageOptionsInterface::class))]; + yield [new DummyMessage()]; + yield [new ChatMessage('hello', new TestOptions())]; } public function testSmsMessageOptions() diff --git a/src/Symfony/Component/Notifier/Bridge/AmazonSns/composer.json b/src/Symfony/Component/Notifier/Bridge/AmazonSns/composer.json index 58b853974163c..3f81032ff2fb7 100644 --- a/src/Symfony/Component/Notifier/Bridge/AmazonSns/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/AmazonSns/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.4|^6.0", + "symfony/notifier": "^5.4.21|^6.2.7", "async-aws/sns": "^1.0" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/Clickatell/LICENSE b/src/Symfony/Component/Notifier/Bridge/Clickatell/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Clickatell/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Clickatell/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportFactoryTest.php index 55b5277162837..bb8dc00af4106 100644 --- a/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new ClickatellTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'clickatell://host.test?from=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'clickatell://authtoken@default?from=0611223344']; yield [false, 'somethingElse://authtoken@default?from=0611223344']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing auth token' => ['clickatell://host?from=FROM']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://authtoken@default?from=FROM']; yield ['somethingElse://authtoken@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportTest.php index a27339450a606..376b890a27f60 100644 --- a/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Clickatell/Tests/ClickatellTransportTest.php @@ -19,6 +19,7 @@ use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -28,31 +29,31 @@ final class ClickatellTransportTest extends TransportTestCase /** * @return ClickatellTransport */ - public function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface { - return new ClickatellTransport('authToken', $from, $client ?? $this->createMock(HttpClientInterface::class)); + return new ClickatellTransport('authToken', $from, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['clickatell://api.clickatell.com', $this->createTransport()]; - yield ['clickatell://api.clickatell.com?from=TEST', $this->createTransport(null, 'TEST')]; + yield ['clickatell://api.clickatell.com', self::createTransport()]; + yield ['clickatell://api.clickatell.com?from=TEST', self::createTransport(null, 'TEST')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('+33612345678', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testExceptionIsThrownWhenNonMessageIsSend() { - $transport = $this->createTransport(); + $transport = self::createTransport(); $this->expectException(LogicException::class); @@ -77,7 +78,7 @@ public function testExceptionIsThrownWhenHttpSendFailed() $client = new MockHttpClient($response); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessage('Unable to send SMS with Clickatell: Error code 105 with message "Invalid Account Reference EX0000000" (https://documentation-page).'); diff --git a/src/Symfony/Component/Notifier/Bridge/Clickatell/composer.json b/src/Symfony/Component/Notifier/Bridge/Clickatell/composer.json index 2d7d60a68e1e5..8f4faf6e4e2cb 100644 --- a/src/Symfony/Component/Notifier/Bridge/Clickatell/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Clickatell/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Clickatell\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/LICENSE b/src/Symfony/Component/Notifier/Bridge/Discord/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Discord/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportFactoryTest.php index 24dc1049c276e..ca0ef4fa34a03 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new DiscordTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'discord://host.test?webhook_id=testWebhookId', @@ -33,23 +33,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'discord://host?webhook_id=testWebhookId']; yield [false, 'somethingElse://host?webhook_id=testWebhookId']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['discord://host.test?webhook_id=testWebhookId']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: webhook_id' => ['discord://token@host']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@host?webhook_id=testWebhookId']; yield ['somethingElse://token@host']; // missing "webhook_id" option diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php index 97e76d00cd288..819d24bb45f27 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php @@ -16,9 +16,9 @@ use Symfony\Component\Notifier\Exception\LengthException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -28,30 +28,30 @@ final class DiscordTransportTest extends TransportTestCase /** * @return DiscordTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new DiscordTransport('testToken', 'testWebhookId', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new DiscordTransport('testToken', 'testWebhookId', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['discord://host.test?webhook_id=testWebhookId', $this->createTransport()]; + yield ['discord://host.test?webhook_id=testWebhookId', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendChatMessageWithMoreThan2000CharsThrowsLogicException() { - $transport = $this->createTransport(); + $transport = self::createTransport(); $this->expectException(LengthException::class); $this->expectExceptionMessage('The subject length of a Discord message must not exceed 2000 characters.'); @@ -73,7 +73,7 @@ public function testSendWithErrorResponseThrows() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessageMatches('/testDescription.+testErrorCode/'); diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/composer.json b/src/Symfony/Component/Notifier/Bridge/Discord/composer.json index 63bc7997575f3..60932df16b78e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Discord/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0", + "symfony/notifier": "^5.4.21|^6.2.7", "symfony/polyfill-mbstring": "^1.0" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/LICENSE b/src/Symfony/Component/Notifier/Bridge/Esendex/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php index 5a7645b7cdda3..6cea260124252 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new EsendexTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'esendex://host.test?accountreference=ACCOUNTREFERENCE&from=FROM', @@ -33,26 +33,26 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'esendex://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM']; yield [false, 'somethingElse://email:password@default']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing credentials' => ['esendex://host?accountreference=ACCOUNTREFERENCE&from=FROM']; yield 'missing email' => ['esendex://:password@host?accountreference=ACCOUNTREFERENCE&from=FROM']; yield 'missing password' => ['esendex://email:@host?accountreference=ACCOUNTREFERENCE&from=FROM']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['esendex://email:password@host?accountreference=ACCOUNTREFERENCE']; yield 'missing option: accountreference' => ['esendex://email:password@host?from=FROM']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://email:password@default?accountreference=ACCOUNTREFERENCE&from=FROM']; yield ['somethingElse://email:password@host?accountreference=ACCOUNTREFERENCE']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php index d7b49371ab293..7f30a2118efc6 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php @@ -15,9 +15,9 @@ use Symfony\Component\Notifier\Bridge\Esendex\EsendexTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -28,25 +28,25 @@ final class EsendexTransportTest extends TransportTestCase /** * @return EsendexTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new EsendexTransport('email', 'password', 'testAccountReference', 'testFrom', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new EsendexTransport('email', 'password', 'testAccountReference', 'testFrom', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['esendex://host.test?accountreference=testAccountReference&from=testFrom', $this->createTransport()]; + yield ['esendex://host.test?accountreference=testAccountReference&from=testFrom', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithErrorResponseThrowsTransportException() @@ -60,7 +60,7 @@ public function testSendWithErrorResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessage('Unable to send the SMS: error 500.'); @@ -82,7 +82,7 @@ public function testSendWithErrorResponseContainingDetailsThrowsTransportExcepti return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessage('Unable to send the SMS: error 500. Details from Esendex: accountreference_invalid: "Invalid Account Reference EX0000000".'); @@ -105,7 +105,7 @@ public function testSendWithSuccessfulResponseDispatchesMessageEvent() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send(new SmsMessage('phone', 'testMessage')); diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json b/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json index 6fbe13a12905b..5df251a479736 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/uid": "^5.4|^6.0" diff --git a/src/Symfony/Component/Notifier/Bridge/Expo/LICENSE b/src/Symfony/Component/Notifier/Bridge/Expo/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Expo/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Expo/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportFactoryTest.php index c78d9f4fe3594..31dbc5736995f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new ExpoTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'expo://exp.host/--/api/v2/push/send', @@ -36,13 +36,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'expo://default?accessToken=test']; yield [false, 'somethingElse://username:password@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://username:password@default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportTest.php index 4445d9a67cfb2..4694537cdbc8f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Expo/Tests/ExpoTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Expo\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Expo\ExpoTransport; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,24 +28,24 @@ final class ExpoTransportTest extends TransportTestCase /** * @return ExpoTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new ExpoTransport('token', $client ?? $this->createMock(HttpClientInterface::class)); + return new ExpoTransport('token', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['expo://exp.host/--/api/v2/push/send', $this->createTransport()]; + yield ['expo://exp.host/--/api/v2/push/send', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new PushMessage('Hello!', 'Symfony Notifier')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0670802161', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Expo/composer.json b/src/Symfony/Component/Notifier/Bridge/Expo/composer.json index 08599881c4bcd..5bf96aa6d6f50 100644 --- a/src/Symfony/Component/Notifier/Bridge/Expo/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Expo/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.4|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Expo\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/FakeChat/LICENSE b/src/Symfony/Component/Notifier/Bridge/FakeChat/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeChat/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/FakeChat/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatEmailTransportTest.php b/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatEmailTransportTest.php index 35fbd57fad8e8..a0048e84baa0b 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatEmailTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatEmailTransportTest.php @@ -11,23 +11,23 @@ namespace Symfony\Component\Notifier\Bridge\FakeChat\Tests; -use Symfony\Component\Mailer\MailerInterface; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mime\Email; use Symfony\Component\Notifier\Bridge\FakeChat\FakeChatEmailTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; use Symfony\Component\Notifier\Tests\Fixtures\TestOptions; use Symfony\Component\Notifier\Tests\Mailer\DummyMailer; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; final class FakeChatEmailTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null, string $transportName = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $transportName = null): TransportInterface { - $transport = (new FakeChatEmailTransport($this->createMock(MailerInterface::class), 'recipient@email.net', 'sender@email.net', $client ?? $this->createMock(HttpClientInterface::class))); + $transport = (new FakeChatEmailTransport(new DummyMailer(), 'recipient@email.net', 'sender@email.net', $client ?? new MockHttpClient())); if (null !== $transportName) { $transport->setHost($transportName); @@ -36,21 +36,21 @@ public function createTransport(HttpClientInterface $client = null, string $tran return $transport; } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['fakechat+email://default?to=recipient@email.net&from=sender@email.net', $this->createTransport()]; - yield ['fakechat+email://mailchimp?to=recipient@email.net&from=sender@email.net', $this->createTransport(null, 'mailchimp')]; + yield ['fakechat+email://default?to=recipient@email.net&from=sender@email.net', self::createTransport()]; + yield ['fakechat+email://mailchimp?to=recipient@email.net&from=sender@email.net', self::createTransport(null, 'mailchimp')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithDefaultTransportAndWithRecipient() diff --git a/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatLoggerTransportTest.php b/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatLoggerTransportTest.php index ee93ec333421d..9e8cb4b2a391a 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatLoggerTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatLoggerTransportTest.php @@ -12,36 +12,38 @@ namespace Symfony\Component\Notifier\Bridge\FakeChat\Tests; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\FakeChat\FakeChatLoggerTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; use Symfony\Component\Notifier\Tests\Fixtures\TestOptions; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; final class FakeChatLoggerTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface { - return new FakeChatLoggerTransport($logger ?? $this->createMock(LoggerInterface::class), $client ?? $this->createMock(HttpClientInterface::class)); + return new FakeChatLoggerTransport($logger ?? new NullLogger(), $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['fakechat+logger://default', $this->createTransport()]; + yield ['fakechat+logger://default', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithDefaultTransport() @@ -51,7 +53,7 @@ public function testSendWithDefaultTransport() $logger = new TestLogger(); - $transport = $this->createTransport(null, $logger); + $transport = self::createTransport(null, $logger); $transport->send($message1); $transport->send($message2); diff --git a/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatTransportFactoryTest.php index a83d035cae707..17b18628d700f 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FakeChat/Tests/FakeChatTransportFactoryTest.php @@ -27,7 +27,7 @@ public function createFactory(): TransportFactoryInterface return new FakeChatTransportFactory($this->createMock(MailerInterface::class), $this->createMock(LoggerInterface::class)); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'fakechat+email://default?to=recipient@email.net&from=sender@email.net', @@ -45,25 +45,25 @@ public function createProvider(): iterable ]; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['fakechat+email://default?to=recipient@email.net']; yield 'missing option: to' => ['fakechat+email://default?from=sender@email.net']; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'fakechat+email://default?to=recipient@email.net&from=sender@email.net']; yield [false, 'somethingElse://default?to=recipient@email.net&from=sender@email.net']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing from' => ['fakechat+email://default?to=recipient@email.net']; yield 'missing to' => ['fakechat+email://default?from=recipient@email.net']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://default?to=recipient@email.net&from=sender@email.net']; } diff --git a/src/Symfony/Component/Notifier/Bridge/FakeChat/composer.json b/src/Symfony/Component/Notifier/Bridge/FakeChat/composer.json index 905f54b2dd7a8..486c9c8849713 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeChat/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/FakeChat/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0", + "symfony/notifier": "^5.4.21|^6.2.7", "symfony/mailer": "^5.2|^6.0" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/FakeSms/LICENSE b/src/Symfony/Component/Notifier/Bridge/FakeSms/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeSms/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/FakeSms/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsEmailTransportTest.php b/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsEmailTransportTest.php index 28506b9352458..1539b71778b45 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsEmailTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsEmailTransportTest.php @@ -11,22 +11,22 @@ namespace Symfony\Component\Notifier\Bridge\FakeSms\Tests; -use Symfony\Component\Mailer\MailerInterface; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mime\Email; use Symfony\Component\Notifier\Bridge\FakeSms\FakeSmsEmailTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; use Symfony\Component\Notifier\Tests\Mailer\DummyMailer; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; final class FakeSmsEmailTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null, string $transportName = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $transportName = null): TransportInterface { - $transport = (new FakeSmsEmailTransport($this->createMock(MailerInterface::class), 'recipient@email.net', 'sender@email.net', $client ?? $this->createMock(HttpClientInterface::class))); + $transport = (new FakeSmsEmailTransport(new DummyMailer(), 'recipient@email.net', 'sender@email.net', $client ?? new MockHttpClient())); if (null !== $transportName) { $transport->setHost($transportName); @@ -35,22 +35,22 @@ public function createTransport(HttpClientInterface $client = null, string $tran return $transport; } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['fakesms+email://default?to=recipient@email.net&from=sender@email.net', $this->createTransport()]; - yield ['fakesms+email://mailchimp?to=recipient@email.net&from=sender@email.net', $this->createTransport(null, 'mailchimp')]; + yield ['fakesms+email://default?to=recipient@email.net&from=sender@email.net', self::createTransport()]; + yield ['fakesms+email://mailchimp?to=recipient@email.net&from=sender@email.net', self::createTransport(null, 'mailchimp')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; yield [new SmsMessage('+33611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithDefaultTransport() diff --git a/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsLoggerTransportTest.php b/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsLoggerTransportTest.php index 443f9cb4ee047..1f5707d230073 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsLoggerTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsLoggerTransportTest.php @@ -12,38 +12,40 @@ namespace Symfony\Component\Notifier\Bridge\FakeSms\Tests; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\FakeSms\FakeSmsLoggerTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; final class FakeSmsLoggerTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface { - $transport = (new FakeSmsLoggerTransport($logger ?? $this->createMock(LoggerInterface::class), $client ?? $this->createMock(HttpClientInterface::class))); + $transport = (new FakeSmsLoggerTransport($logger ?? new NullLogger(), $client ?? new MockHttpClient())); return $transport; } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['fakesms+logger://default', $this->createTransport()]; + yield ['fakesms+logger://default', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; yield [new SmsMessage('+33611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithDefaultTransport() @@ -52,7 +54,7 @@ public function testSendWithDefaultTransport() $logger = new TestLogger(); - $transport = $this->createTransport(null, $logger); + $transport = self::createTransport(null, $logger); $transport->send($message); diff --git a/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsTransportFactoryTest.php index 603da742f2f5c..a9834eaad1c93 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FakeSms/Tests/FakeSmsTransportFactoryTest.php @@ -27,7 +27,7 @@ public function createFactory(): TransportFactoryInterface return new FakeSmsTransportFactory($this->createMock(MailerInterface::class), $this->createMock(LoggerInterface::class)); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'fakesms+email://default?to=recipient@email.net&from=sender@email.net', @@ -45,25 +45,25 @@ public function createProvider(): iterable ]; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['fakesms+email://default?to=recipient@email.net']; yield 'missing option: to' => ['fakesms+email://default?from=sender@email.net']; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'fakesms+email://default?to=recipient@email.net&from=sender@email.net']; yield [false, 'somethingElse://default?to=recipient@email.net&from=sender@email.net']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing from' => ['fakesms+email://default?to=recipient@email.net']; yield 'missing to' => ['fakesms+email://default?from=recipient@email.net']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://default?to=recipient@email.net&from=sender@email.net']; } diff --git a/src/Symfony/Component/Notifier/Bridge/FakeSms/composer.json b/src/Symfony/Component/Notifier/Bridge/FakeSms/composer.json index 7008743675e13..0baedea3a5e5c 100644 --- a/src/Symfony/Component/Notifier/Bridge/FakeSms/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/FakeSms/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0", + "symfony/notifier": "^5.4.21|^6.2.7", "symfony/mailer": "^5.2|^6.0" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/LICENSE b/src/Symfony/Component/Notifier/Bridge/Firebase/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportFactoryTest.php index 77e69348dc0b2..17db87b7307e0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new FirebaseTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'firebase://host.test', @@ -36,13 +36,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'firebase://username:password@default']; yield [false, 'somethingElse://username:password@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://username:password@default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportTest.php index 5f8d52aa6440a..338dd8696414f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportTest.php @@ -17,9 +17,9 @@ use Symfony\Component\Notifier\Bridge\Firebase\FirebaseTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -32,25 +32,25 @@ final class FirebaseTransportTest extends TransportTestCase /** * @return FirebaseTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new FirebaseTransport('username:password', $client ?? $this->createMock(HttpClientInterface::class)); + return new FirebaseTransport('username:password', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['firebase://fcm.googleapis.com/fcm/send', $this->createTransport()]; + yield ['firebase://fcm.googleapis.com/fcm/send', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } /** @@ -65,12 +65,12 @@ public function testSendWithErrorThrowsTransportException(ResponseInterface $res }); $options = new class('recipient-id', []) extends FirebaseOptions {}; - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage('Hello!', $options)); } - public function sendWithErrorThrowsExceptionProvider(): iterable + public static function sendWithErrorThrowsExceptionProvider(): iterable { yield [new MockResponse( json_encode(['results' => [['error' => 'testErrorCode']]]), diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json b/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json index b0df576a26221..04c2578218529 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Firebase\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/LICENSE b/src/Symfony/Component/Notifier/Bridge/FreeMobile/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php index bb9698cd98e51..538a30811342d 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new FreeMobileTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'freemobile://host.test?phone=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'freemobile://login:pass@default?phone=0611223344']; yield [false, 'somethingElse://login:pass@default?phone=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: phone' => ['freemobile://login:pass@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://login:pass@default?phone=0611223344']; yield ['somethingElse://login:pass@default']; // missing "phone" option diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php index 2035102daa1fd..bdaa6152ca252 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\FreeMobile\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\FreeMobile\FreeMobileTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,26 +25,26 @@ final class FreeMobileTransportTest extends TransportTestCase /** * @return FreeMobileTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new FreeMobileTransport('login', 'pass', '0611223344', $client ?? $this->createMock(HttpClientInterface::class)); + return new FreeMobileTransport('login', 'pass', '0611223344', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['freemobile://smsapi.free-mobile.fr/sendmsg?phone=0611223344', $this->createTransport()]; + yield ['freemobile://smsapi.free-mobile.fr/sendmsg?phone=0611223344', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; yield [new SmsMessage('+33611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0699887766', 'Hello!')]; // because this phone number is not configured on the transport! yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json b/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json index 104e443f4248e..963d1f6efe012 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.1|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\FreeMobile\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/GatewayApi/LICENSE b/src/Symfony/Component/Notifier/Bridge/GatewayApi/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/GatewayApi/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/GatewayApi/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportFactoryTest.php index 7e1736b5b20d3..90787234556e1 100644 --- a/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportFactoryTest.php @@ -29,7 +29,7 @@ public function createFactory(): TransportFactoryInterface return new GatewayApiTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'gatewayapi://gatewayapi.com?from=Symfony', @@ -37,18 +37,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'gatewayapi://token@host.test?from=Symfony']; yield [false, 'somethingElse://token@default?from=Symfony']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['gatewayapi://host.test?from=Symfony']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['gatewayapi://token@host.test']; } diff --git a/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportTest.php b/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportTest.php index 4e72655905e46..fd5225f0b0d2d 100644 --- a/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/GatewayApi/Tests/GatewayApiTransportTest.php @@ -14,10 +14,10 @@ use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\GatewayApi\GatewayApiTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -31,25 +31,25 @@ final class GatewayApiTransportTest extends TransportTestCase /** * @return GatewayApiTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new GatewayApiTransport('authtoken', 'Symfony', $client ?? $this->createMock(HttpClientInterface::class)); + return new GatewayApiTransport('authtoken', 'Symfony', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['gatewayapi://gatewayapi.com?from=Symfony', $this->createTransport()]; + yield ['gatewayapi://gatewayapi.com?from=Symfony', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSend() @@ -68,7 +68,7 @@ public function testSend() $message = new SmsMessage('3333333333', 'Hello!'); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send($message); $this->assertInstanceOf(SentMessage::class, $sentMessage); diff --git a/src/Symfony/Component/Notifier/Bridge/GatewayApi/composer.json b/src/Symfony/Component/Notifier/Bridge/GatewayApi/composer.json index 2ec3caddfbc42..690a6c69c08ea 100644 --- a/src/Symfony/Component/Notifier/Bridge/GatewayApi/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/GatewayApi/composer.json @@ -3,7 +3,7 @@ "type": "symfony-notifier-bridge", "description": "Symfony GatewayApi Notifier Bridge", "keywords": ["sms", "gatewayapi", "notifier"], - "homepage": "https://gatewayapi.com", + "homepage": "https://symfony.com", "license": "MIT", "authors": [ { @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\GatewayApi\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE b/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportFactoryTest.php index 345d9aa38e7e5..d400a7a7a7680 100644 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new GitterTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef', @@ -33,23 +33,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'gitter://token@host?room_id=5539a3ee5etest0d3255bfef']; yield [false, 'somethingElse://token@host?room_id=5539a3ee5etest0d3255bfef']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: room_id' => ['gitter://token@host']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@host?room_id=5539a3ee5etest0d3255bfef']; yield ['somethingElse://token@host']; diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php index c8ae860d86cc7..a59fdeca5f670 100644 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Gitter\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Gitter\GitterTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ */ final class GitterTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new GitterTransport('token', '5539a3ee5etest0d3255bfef', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('api.gitter.im'); + return (new GitterTransport('token', '5539a3ee5etest0d3255bfef', $client ?? new MockHttpClient()))->setHost('api.gitter.im'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef', $this->createTransport()]; + yield ['gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json b/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json index 0cc63ebc74308..30b249a2d319c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Gitter\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/LICENSE b/src/Symfony/Component/Notifier/Bridge/GoogleChat/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportFactoryTest.php index 52bcc95d99fd1..8346e4a4f9815 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new GoogleChatTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'googlechat://chat.googleapis.com/AAAAA_YYYYY', @@ -38,18 +38,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'googlechat://host/path']; yield [false, 'somethingElse://host/path']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing credentials' => ['googlechat://chat.googleapis.com/v1/spaces/AAAAA_YYYYY/messages']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://host/path']; } diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php b/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php index ce033f31ff712..9c532eef3faba 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php @@ -17,11 +17,11 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -31,26 +31,26 @@ final class GoogleChatTransportTest extends TransportTestCase /** * @return GoogleChatTransport */ - public function createTransport(HttpClientInterface $client = null, string $threadKey = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $threadKey = null): TransportInterface { - return new GoogleChatTransport('My-Space', 'theAccessKey', 'theAccessToken=', $threadKey, $client ?? $this->createMock(HttpClientInterface::class)); + return new GoogleChatTransport('My-Space', 'theAccessKey', 'theAccessToken=', $threadKey, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['googlechat://chat.googleapis.com/My-Space', $this->createTransport()]; - yield ['googlechat://chat.googleapis.com/My-Space?thread_key=abcdefg', $this->createTransport(null, 'abcdefg')]; + yield ['googlechat://chat.googleapis.com/My-Space', self::createTransport()]; + yield ['googlechat://chat.googleapis.com/My-Space?thread_key=abcdefg', self::createTransport(null, 'abcdefg')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithEmptyArrayResponseThrowsTransportException() @@ -71,7 +71,7 @@ public function testSendWithEmptyArrayResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send(new ChatMessage('testMessage')); @@ -95,7 +95,7 @@ public function testSendWithErrorResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send(new ChatMessage('testMessage')); @@ -126,7 +126,7 @@ public function testSendWithOptions() return $response; }); - $transport = $this->createTransport($client, 'My-Thread'); + $transport = self::createTransport($client, 'My-Thread'); $sentMessage = $transport->send(new ChatMessage('testMessage')); @@ -158,7 +158,7 @@ public function testSendWithNotification() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send($chatMessage); @@ -174,7 +174,7 @@ public function testSendWithInvalidOptions() return $this->createMock(ResponseInterface::class); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage('testMessage', $this->createMock(MessageOptionsInterface::class))); } @@ -203,7 +203,7 @@ public function testSendWith200ResponseButNotOk() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send(new ChatMessage('testMessage')); diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json b/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json index 760a2c6d41fab..20db7219d4641 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\GoogleChat\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Infobip/LICENSE b/src/Symfony/Component/Notifier/Bridge/Infobip/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Infobip/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Infobip/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportFactoryTest.php index 06a6ff586ed3d..4cb92cbe16025 100644 --- a/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new InfobipTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'infobip://host.test?from=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'infobip://authtoken@default?from=0611223344']; yield [false, 'somethingElse://authtoken@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['infobip://authtoken@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://authtoken@default?from=FROM']; yield ['somethingElse://authtoken@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportTest.php index 80bd35fdf4ce4..e60c8bbc88931 100644 --- a/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Infobip/Tests/InfobipTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Infobip\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Infobip\InfobipTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class InfobipTransportTest extends TransportTestCase /** * @return InfobipTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new InfobipTransport('authtoken', '0611223344', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new InfobipTransport('authtoken', '0611223344', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['infobip://host.test?from=0611223344', $this->createTransport()]; + yield ['infobip://host.test?from=0611223344', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json b/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json index 48537126ff0d4..fb6672c91c380 100644 --- a/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Infobip\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Iqsms/LICENSE b/src/Symfony/Component/Notifier/Bridge/Iqsms/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Notifier/Bridge/Iqsms/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Iqsms/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportFactoryTest.php index a71e3bf5a7cc8..f83057185d884 100644 --- a/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new IqsmsTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'iqsms://host.test?from=FROM', @@ -33,25 +33,25 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'iqsms://login:password@default?from=FROM']; yield [false, 'somethingElse://login:password@default?from=FROM']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing login' => ['iqsms://:password@host.test?from=FROM']; yield 'missing password' => ['iqsms://login:@host.test?from=FROM']; yield 'missing credentials' => ['iqsms://@host.test?from=FROM']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['iqsms://login:password@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://login:password@default?from=FROM']; yield ['somethingElse://login:password@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportTest.php index 83d957176a19d..a5049c77794b0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Iqsms/Tests/IqsmsTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Iqsms\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Iqsms\IqsmsTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class IqsmsTransportTest extends TransportTestCase /** * @return IqsmsTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new IqsmsTransport('login', 'password', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); + return new IqsmsTransport('login', 'password', 'sender', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['iqsms://api.iqsms.ru?from=sender', $this->createTransport()]; + yield ['iqsms://api.iqsms.ru?from=sender', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Iqsms/composer.json b/src/Symfony/Component/Notifier/Bridge/Iqsms/composer.json index 140a29ebd7650..4f7361e95ea24 100644 --- a/src/Symfony/Component/Notifier/Bridge/Iqsms/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Iqsms/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Iqsms\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/LightSms/LICENSE b/src/Symfony/Component/Notifier/Bridge/LightSms/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/LightSms/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/LightSms/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php index 01b206882f549..6d74aceef450a 100644 --- a/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new LightSmsTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'lightsms://host.test?from=0611223344', @@ -33,13 +33,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'lightsms://login:token@default?from=37061234567']; yield [false, 'somethingElse://login:token@default?from=37061234567']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://login:token@default?from=37061234567']; yield ['somethingElse://login:token@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php index ea7508bc018eb..26a906ab02d77 100644 --- a/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\LightSms\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\LightSms\LightSmsTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class LightSmsTransportTest extends TransportTestCase /** * @return LightSmsTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new LightSmsTransport('accountSid', 'authToken', 'from', $client ?? $this->createMock(HttpClientInterface::class)); + return new LightSmsTransport('accountSid', 'authToken', 'from', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['lightsms://www.lightsms.com?from=from', $this->createTransport()]; + yield ['lightsms://www.lightsms.com?from=from', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/LightSms/composer.json b/src/Symfony/Component/Notifier/Bridge/LightSms/composer.json index d042ceadc4751..fad9ac0213c3c 100644 --- a/src/Symfony/Component/Notifier/Bridge/LightSms/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/LightSms/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\LightSms\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/LICENSE b/src/Symfony/Component/Notifier/Bridge/LinkedIn/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportFactoryTest.php index 180238e78eb0b..d79f683ef63b3 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new LinkedInTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'linkedin://host.test', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'linkedin://host']; yield [false, 'somethingElse://host']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing account or user_id' => ['linkedin://AccessTokenOrUserId@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://accessToken:UserId@default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php b/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php index 820343e38f7ab..810db1fc28849 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php @@ -16,11 +16,11 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -30,25 +30,25 @@ final class LinkedInTransportTest extends TransportTestCase /** * @return LinkedInTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new LinkedInTransport('AuthToken', 'AccountId', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new LinkedInTransport('AuthToken', 'AccountId', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['linkedin://host.test', $this->createTransport()]; + yield ['linkedin://host.test', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithEmptyArrayResponseThrowsTransportException() @@ -65,7 +65,7 @@ public function testSendWithEmptyArrayResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); @@ -90,7 +90,7 @@ public function testSendWithErrorResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage('testMessage')); } @@ -134,7 +134,7 @@ public function testSendWithOptions() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage($message)); } @@ -182,7 +182,7 @@ public function testSendWithNotification() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send($chatMessage); } @@ -195,7 +195,7 @@ public function testSendWithInvalidOptions() return $this->createMock(ResponseInterface::class); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage('testMessage', $this->createMock(MessageOptionsInterface::class))); } diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json b/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json index f0e690b072fa0..6781cab809cf6 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\LinkedIn\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Mailjet/LICENSE b/src/Symfony/Component/Notifier/Bridge/Mailjet/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mailjet/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Mailjet/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportFactoryTest.php index b24a15a67e52d..959550a4d9fdf 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new MailjetTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'mailjet://Mailjet@host.test', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'mailjet://Mailjet:authtoken@default']; yield [false, 'somethingElse://Mailjet:authtoken@default']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing from' => ['mailjet://authtoken@default', 'Invalid "mailjet://authtoken@default" notifier DSN: Password is not set.']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://default']; // missing "from" and "token" option yield ['somethingElse://authtoken@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportTest.php index b6e3bb750294e..970286f8195bd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mailjet/Tests/MailjetTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Mailjet\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Mailjet\MailjetTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class MailjetTransportTest extends TransportTestCase /** * @return MailjetTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new MailjetTransport('authtoken', 'Mailjet', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new MailjetTransport('authtoken', 'Mailjet', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['mailjet://Mailjet@host.test', $this->createTransport()]; + yield ['mailjet://Mailjet@host.test', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Mailjet/composer.json b/src/Symfony/Component/Notifier/Bridge/Mailjet/composer.json index 1574eaab8c3db..b99a6ef1dbf69 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mailjet/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Mailjet/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3.4|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Mailjet\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/LICENSE b/src/Symfony/Component/Notifier/Bridge/Mattermost/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportFactoryTest.php index 5f75994ce133a..a5123ca1ddc5e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new MattermostTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'mattermost://host.test?channel=testChannel', @@ -51,23 +51,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'mattermost://token@host?channel=testChannel']; yield [false, 'somethingElse://token@host?channel=testChannel']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['mattermost://host.test?channel=testChannel']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: channel' => ['mattermost://token@host']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@host?channel=testChannel']; yield ['somethingElse://token@host']; // missing "channel" option diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php index 48e77f1fcf2f6..0cca6e735e41e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Mattermost\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Mattermost\MattermostTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,24 +28,24 @@ final class MattermostTransportTest extends TransportTestCase /** * @return MattermostTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new MattermostTransport('testAccessToken', 'testChannel', null, $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new MattermostTransport('testAccessToken', 'testChannel', null, $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['mattermost://host.test?channel=testChannel', $this->createTransport()]; + yield ['mattermost://host.test?channel=testChannel', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json b/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json index 3de3a9bbb7880..0e68068fdca21 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Mattermost\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/LICENSE b/src/Symfony/Component/Notifier/Bridge/Mercure/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/Fixtures/DummyHub.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/Fixtures/DummyHub.php new file mode 100644 index 0000000000000..985c75d73b044 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/Fixtures/DummyHub.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Mercure\Tests\Fixtures; + +use Symfony\Component\Mercure\HubInterface; +use Symfony\Component\Mercure\Jwt\TokenFactoryInterface; +use Symfony\Component\Mercure\Jwt\TokenProviderInterface; +use Symfony\Component\Mercure\Update; + +class DummyHub implements HubInterface +{ + public function getUrl(): string + { + } + + public function getPublicUrl(): string + { + } + + public function getProvider(): TokenProviderInterface + { + } + + public function getFactory(): ?TokenFactoryInterface + { + return null; + } + + public function publish(Update $update): string + { + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php index 74e82929e4af4..7503f9e40456f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php @@ -13,7 +13,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Notifier\Bridge\Mercure\MercureOptions; -use TypeError; final class MercureOptionsTest extends TestCase { @@ -43,7 +42,7 @@ public function testConstructWithParameters() public function testConstructWithWrongTopicsThrows() { - $this->expectException(TypeError::class); + $this->expectException(\TypeError::class); new MercureOptions(new \stdClass()); } } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportFactoryTest.php index 37825f49438dc..8605449d24371 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportFactoryTest.php @@ -32,13 +32,13 @@ public function createFactory(): TransportFactoryInterface return new MercureTransportFactory($hubRegistry); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'mercure://hubId?topic=topic']; yield [false, 'somethingElse://hubId?topic=topic']; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'mercure://hubId?topic=%2Ftopic%2F1', @@ -56,7 +56,7 @@ public function createProvider(): iterable ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://hubId?topic=topic']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php index bdc36383df649..7ea005c47636a 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php @@ -19,45 +19,45 @@ use Symfony\Component\Mercure\Update; use Symfony\Component\Notifier\Bridge\Mercure\MercureOptions; use Symfony\Component\Notifier\Bridge\Mercure\MercureTransport; +use Symfony\Component\Notifier\Bridge\Mercure\Tests\Fixtures\DummyHub; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\RuntimeException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -use TypeError; /** * @author Mathias Arlaud */ final class MercureTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null, HubInterface $hub = null, string $hubId = 'hubId', $topics = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, HubInterface $hub = null, string $hubId = 'hubId', $topics = null): TransportInterface { - $hub = $hub ?? $this->createMock(HubInterface::class); + $hub = $hub ?? new DummyHub(); return new MercureTransport($hub, $hubId, $topics); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['mercure://hubId?topic=https%3A%2F%2Fsymfony.com%2Fnotifier', $this->createTransport()]; - yield ['mercure://customHubId?topic=%2Ftopic', $this->createTransport(null, null, 'customHubId', '/topic')]; - yield ['mercure://customHubId?topic%5B0%5D=%2Ftopic%2F1&topic%5B1%5D%5B0%5D=%2Ftopic%2F2', $this->createTransport(null, null, 'customHubId', ['/topic/1', ['/topic/2']])]; + yield ['mercure://hubId?topic=https%3A%2F%2Fsymfony.com%2Fnotifier', self::createTransport()]; + yield ['mercure://customHubId?topic=%2Ftopic', self::createTransport(null, null, 'customHubId', '/topic')]; + yield ['mercure://customHubId?topic%5B0%5D=%2Ftopic%2F1&topic%5B1%5D%5B0%5D=%2Ftopic%2F2', self::createTransport(null, null, 'customHubId', ['/topic/1', ['/topic/2']])]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testCanSetCustomPort() @@ -77,14 +77,14 @@ public function testCanSetCustomHostAndPort() public function testConstructWithWrongTopicsThrows() { - $this->expectException(TypeError::class); - $this->createTransport(null, null, 'publisherId', new \stdClass()); + $this->expectException(\TypeError::class); + self::createTransport(null, null, 'publisherId', new \stdClass()); } public function testSendWithNonMercureOptionsThrows() { $this->expectException(LogicException::class); - $this->createTransport()->send(new ChatMessage('testMessage', $this->createMock(MessageOptionsInterface::class))); + self::createTransport()->send(new ChatMessage('testMessage', $this->createMock(MessageOptionsInterface::class))); } public function testSendWithTransportFailureThrows() @@ -96,7 +96,7 @@ public function testSendWithTransportFailureThrows() $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unable to post the Mercure message: Cannot connect to mercure'); - $this->createTransport(null, $hub)->send(new ChatMessage('subject')); + self::createTransport(null, $hub)->send(new ChatMessage('subject')); } public function testSendWithWrongTokenThrows() @@ -108,7 +108,7 @@ public function testSendWithWrongTokenThrows() $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unable to post the Mercure message: The provided JWT is not valid'); - $this->createTransport(null, $hub)->send(new ChatMessage('subject')); + self::createTransport(null, $hub)->send(new ChatMessage('subject')); } public function testSendWithMercureOptions() @@ -124,7 +124,7 @@ public function testSendWithMercureOptions() return 'id'; }); - $this->createTransport(null, $hub)->send(new ChatMessage('subject', new MercureOptions(['/topic/1', '/topic/2'], true, 'id', 'type', 1))); + self::createTransport(null, $hub)->send(new ChatMessage('subject', new MercureOptions(['/topic/1', '/topic/2'], true, 'id', 'type', 1))); } public function testSendWithMercureOptionsButWithoutOptionTopic() @@ -140,7 +140,7 @@ public function testSendWithMercureOptionsButWithoutOptionTopic() return 'id'; }); - $this->createTransport(null, $hub)->send(new ChatMessage('subject', new MercureOptions(null, true, 'id', 'type', 1))); + self::createTransport(null, $hub)->send(new ChatMessage('subject', new MercureOptions(null, true, 'id', 'type', 1))); } public function testSendWithoutMercureOptions() @@ -153,7 +153,7 @@ public function testSendWithoutMercureOptions() return 'id'; }); - $this->createTransport(null, $hub)->send(new ChatMessage('subject')); + self::createTransport(null, $hub)->send(new ChatMessage('subject')); } public function testSendSuccessfully() @@ -164,7 +164,7 @@ public function testSendSuccessfully() return $messageId; }); - $sentMessage = $this->createTransport(null, $hub)->send(new ChatMessage('subject')); + $sentMessage = self::createTransport(null, $hub)->send(new ChatMessage('subject')); $this->assertSame($messageId, $sentMessage->getMessageId()); } } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/composer.json b/src/Symfony/Component/Notifier/Bridge/Mercure/composer.json index ed13323a28166..e6691191408f4 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/mercure": "^0.5.2|^0.6", - "symfony/notifier": "^5.3|^6.0", + "symfony/notifier": "^5.4.21|^6.2.7", "symfony/service-contracts": "^1.10|^2|^3" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/MessageBird/LICENSE b/src/Symfony/Component/Notifier/Bridge/MessageBird/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageBird/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/MessageBird/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportFactoryTest.php index 55d26b2a91797..8d1602a237390 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new MessageBirdTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'messagebird://host.test?from=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'messagebird://token@default?from=0611223344']; yield [false, 'somethingElse://token@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['messagebird://token@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@default?from=0611223344']; yield ['somethingElse://token@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportTest.php b/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportTest.php index 3154fc98a391a..b7a6a054ef709 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MessageBird/Tests/MessageBirdTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\MessageBird\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\MessageBird\MessageBirdTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class MessageBirdTransportTest extends TransportTestCase /** * @return MessageBirdTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new MessageBirdTransport('token', 'from', $client ?? $this->createMock(HttpClientInterface::class)); + return new MessageBirdTransport('token', 'from', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['messagebird://rest.messagebird.com?from=from', $this->createTransport()]; + yield ['messagebird://rest.messagebird.com?from=from', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/MessageBird/composer.json b/src/Symfony/Component/Notifier/Bridge/MessageBird/composer.json index d6fd6c8b7769c..001ae39e5aec7 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageBird/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/MessageBird/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\MessageBird\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/MessageMedia/LICENSE b/src/Symfony/Component/Notifier/Bridge/MessageMedia/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageMedia/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/MessageMedia/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportFactoryTest.php index 2dbb5ce4b03b1..ef60fb4d10b95 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new MessageMediaTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'messagemedia://host.test', @@ -38,13 +38,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'messagemedia://apiKey:apiSecret@default']; yield [false, 'somethingElse://apiKey:apiSecret@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://apiKey:apiSecret@default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportTest.php b/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportTest.php index 147078e64aa5c..aff1b64c938cd 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaTransportTest.php @@ -16,9 +16,9 @@ use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Exception\TransportExceptionInterface; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -28,26 +28,26 @@ final class MessageMediaTransportTest extends TransportTestCase /** * @return MessageMediaTransport */ - public function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface { - return new MessageMediaTransport('apiKey', 'apiSecret', $from, $client ?? $this->createMock(HttpClientInterface::class)); + return new MessageMediaTransport('apiKey', 'apiSecret', $from, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['messagemedia://api.messagemedia.com', $this->createTransport()]; - yield ['messagemedia://api.messagemedia.com?from=TEST', $this->createTransport(null, 'TEST')]; + yield ['messagemedia://api.messagemedia.com', self::createTransport()]; + yield ['messagemedia://api.messagemedia.com?from=TEST', self::createTransport(null, 'TEST')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0491570156', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } /** @@ -72,7 +72,7 @@ public function testExceptionIsThrownWhenHttpSendFailed(int $statusCode, string $transport->send(new SmsMessage('+61491570156', 'Hello!')); } - public function exceptionIsThrownWhenHttpSendFailedProvider(): iterable + public static function exceptionIsThrownWhenHttpSendFailedProvider(): iterable { yield [503, '', 'Unable to send the SMS: "Unknown reason".']; yield [500, '{"details": ["Something went wrong."]}', 'Unable to send the SMS: "Something went wrong.".']; diff --git a/src/Symfony/Component/Notifier/Bridge/MessageMedia/composer.json b/src/Symfony/Component/Notifier/Bridge/MessageMedia/composer.json index 2410b712a7402..ae4005b34f14c 100644 --- a/src/Symfony/Component/Notifier/Bridge/MessageMedia/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/MessageMedia/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\MessageMedia\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/LICENSE b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/ActionCardTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/ActionCardTest.php index 0d8d412e8ff3b..4fcc9c55d674a 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/ActionCardTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/ActionCardTest.php @@ -43,7 +43,7 @@ public function testInput(array $expected, InputInterface $input) $this->assertSame($expected, $action->toArray()['inputs']); } - public function availableInputs(): \Generator + public static function availableInputs(): \Generator { yield [[['@type' => 'DateInput']], new DateInput()]; yield [[['@type' => 'TextInput']], new TextInput()]; @@ -62,7 +62,7 @@ public function testAction(array $expected, ActionCardCompatibleActionInterface $this->assertSame($expected, $section->toArray()['actions']); } - public function compatibleActions(): \Generator + public static function compatibleActions(): \Generator { yield [[['@type' => 'HttpPOST']], new HttpPostAction()]; yield [[['@type' => 'OpenUri']], new OpenUriAction()]; diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/Input/MultiChoiceInputTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/Input/MultiChoiceInputTest.php index e8ce2327277cd..1da07be6a1c6e 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/Input/MultiChoiceInputTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/Input/MultiChoiceInputTest.php @@ -69,7 +69,7 @@ public function testStyle(string $value) /** * @return \Generator */ - public function styles(): \Generator + public static function styles(): \Generator { yield 'style-expanded' => ['expanded']; yield 'style-normal' => ['normal']; diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/OpenUriActionTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/OpenUriActionTest.php index a67eaf5e03a4b..63c2e45629927 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/OpenUriActionTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Action/OpenUriActionTest.php @@ -57,7 +57,7 @@ public function testTarget(string $os) /** * @return \Generator */ - public function operatingSystems(): \Generator + public static function operatingSystems(): \Generator { yield 'os-android' => ['android']; yield 'os-default' => ['default']; diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsOptionsTest.php index ccd8064254b8a..1aaeffd7d333e 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsOptionsTest.php @@ -146,7 +146,7 @@ public function testThemeColorViaSetter(string $themeColor) $this->assertSame($themeColor, $options->toArray()['themeColor']); } - public function validThemeColors(): \Generator + public static function validThemeColors(): \Generator { yield ['#333']; yield ['#333333']; @@ -181,7 +181,7 @@ public function testThemeColorViaSetterThrowsInvalidArgumentException(string $th ->themeColor($themeColor); } - public function invalidThemeColors(): \Generator + public static function invalidThemeColors(): \Generator { yield ['']; yield [' ']; diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportFactoryTest.php index cbf6c48e407ab..b0934bcdc9e22 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportFactoryTest.php @@ -22,7 +22,7 @@ public function createFactory(): TransportFactoryInterface return new MicrosoftTeamsTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'microsoftteams://host/webhook', @@ -30,13 +30,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'microsoftteams://host/webhook']; yield [false, 'somethingElse://host/webhook']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://host/webhook']; } diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportTest.php index d1229803dd864..0864c0717fcc1 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/MicrosoftTeamsTransportTest.php @@ -17,10 +17,10 @@ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -30,25 +30,25 @@ final class MicrosoftTeamsTransportTest extends TransportTestCase /** * @return MicrosoftTeamsTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new MicrosoftTeamsTransport('/testPath', $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new MicrosoftTeamsTransport('/testPath', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['microsoftteams://host.test/testPath', $this->createTransport()]; + yield ['microsoftteams://host.test/testPath', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithErrorResponseThrows() @@ -57,7 +57,7 @@ public function testSendWithErrorResponseThrows() return new MockResponse('testErrorMessage', ['response_headers' => ['request-id' => ['testRequestId']], 'http_code' => 400]); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessageMatches('/testErrorMessage/'); @@ -69,7 +69,7 @@ public function testSendWithErrorRequestIdThrows() { $client = new MockHttpClient(new MockResponse()); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessageMatches('/request-id not found/'); @@ -91,7 +91,7 @@ public function testSend() return new MockResponse('1', ['response_headers' => ['request-id' => ['testRequestId']], 'http_code' => 200]); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage($message)); } @@ -113,7 +113,7 @@ public function testSendWithOptionsAndTextOverwritesChatMessage() return new MockResponse('1', ['response_headers' => ['request-id' => ['testRequestId']], 'http_code' => 200]); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage($message, $options)); } @@ -140,7 +140,7 @@ public function testSendWithOptionsAsMessageCard() return new MockResponse('1', ['response_headers' => ['request-id' => ['testRequestId']], 'http_code' => 200]); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage($message, $options)); } @@ -160,7 +160,7 @@ public function testSendFromNotification() return new MockResponse('1', ['response_headers' => ['request-id' => ['testRequestId']], 'http_code' => 200]); }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send($chatMessage); } diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Section/SectionTest.php b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Section/SectionTest.php index e037efea19d5f..fde246a54ec65 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Section/SectionTest.php +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/Tests/Section/SectionTest.php @@ -52,7 +52,7 @@ public function testAction(array $expected, ActionInterface $action) $this->assertSame($expected, $section->toArray()['potentialAction']); } - public function allowedActions(): \Generator + public static function allowedActions(): \Generator { yield [[['@type' => 'ActionCard']], new ActionCard()]; yield [[['@type' => 'HttpPOST']], new HttpPostAction()]; diff --git a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/composer.json b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/composer.json index 4417eae36804c..aafc59f306440 100644 --- a/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\MicrosoftTeams\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/LICENSE b/src/Symfony/Component/Notifier/Bridge/Mobyt/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytOptionsTest.php index 23f1d0dfbf286..40af3e310fe62 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytOptionsTest.php @@ -33,7 +33,7 @@ public function testFromNotification(string $importance, string $expectedMessage /** * @return \Generator */ - public function fromNotificationDataProvider(): \Generator + public static function fromNotificationDataProvider(): \Generator { yield [Notification::IMPORTANCE_URGENT, MobytOptions::MESSAGE_TYPE_QUALITY_HIGH]; yield [Notification::IMPORTANCE_HIGH, MobytOptions::MESSAGE_TYPE_QUALITY_HIGH]; @@ -85,7 +85,7 @@ public function testMessageType(string $type) $this->assertSame(['message_type' => $type], $mobytOptions->toArray()); } - public function validMessageTypes(): iterable + public static function validMessageTypes(): iterable { yield [MobytOptions::MESSAGE_TYPE_QUALITY_HIGH]; yield [MobytOptions::MESSAGE_TYPE_QUALITY_MEDIUM]; diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportFactoryTest.php index 9b47e9c55f99f..2811ef86555ae 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new MobytTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'mobyt://host.test?from=FROM&type_quality=LL', @@ -41,19 +41,19 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'mobyt://accountSid:authToken@host.test?from=FROM']; yield [false, 'somethingElse://accountSid:authToken@host.test?from=FROM']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['mobyt://host.test?from=FROM']; yield 'missing option: from' => ['mobyt://accountSid:authToken@host']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://accountSid:authToken@host.test?from=FROM']; yield ['somethingElse://accountSid:authToken@host.test']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportTest.php index ea1aac62491a1..4d54df6387d36 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/Tests/MobytTransportTest.php @@ -11,12 +11,13 @@ namespace Symfony\Component\Notifier\Bridge\Mobyt\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Mobyt\MobytOptions; use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -28,25 +29,25 @@ final class MobytTransportTest extends TransportTestCase /** * @return MobytTransport */ - public function createTransport(HttpClientInterface $client = null, string $messageType = MobytOptions::MESSAGE_TYPE_QUALITY_LOW): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $messageType = MobytOptions::MESSAGE_TYPE_QUALITY_LOW): TransportInterface { - return (new MobytTransport('accountSid', 'authToken', 'from', $messageType, $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new MobytTransport('accountSid', 'authToken', 'from', $messageType, $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['mobyt://host.test?from=from&type_quality=LL', $this->createTransport()]; - yield ['mobyt://host.test?from=from&type_quality=N', $this->createTransport(null, MobytOptions::MESSAGE_TYPE_QUALITY_HIGH)]; + yield ['mobyt://host.test?from=from&type_quality=LL', self::createTransport()]; + yield ['mobyt://host.test?from=from&type_quality=N', self::createTransport(null, MobytOptions::MESSAGE_TYPE_QUALITY_HIGH)]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json b/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json index e0a1fc91899b7..ec9e4f3f6935b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Mobyt\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE b/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php index 907b98e1ccf70..bf6fb8275b04b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new NexmoTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'nexmo://host.test?from=0611223344', @@ -36,18 +36,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'nexmo://apiKey:apiSecret@default?from=0611223344']; yield [false, 'somethingElse://apiKey:apiSecret@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['nexmo://apiKey:apiSecret@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://apiKey:apiSecret@default?from=0611223344']; yield ['somethingElse://apiKey:apiSecret@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php index d52014957b1c6..bb0fe4c552e4e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Nexmo\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,24 +28,24 @@ final class NexmoTransportTest extends TransportTestCase /** * @return NexmoTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new NexmoTransport('apiKey', 'apiSecret', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); + return new NexmoTransport('apiKey', 'apiSecret', 'sender', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['nexmo://rest.nexmo.com?from=sender', $this->createTransport()]; + yield ['nexmo://rest.nexmo.com?from=sender', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json index 8550289e8542d..4889aa58e9fed 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1|^3", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Nexmo\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Octopush/LICENSE b/src/Symfony/Component/Notifier/Bridge/Octopush/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Octopush/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Octopush/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportFactoryTest.php index 714f76bc94828..c09e805143bac 100644 --- a/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new OctopushTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'octopush://host.test?from=Heyliot&type=FR', @@ -33,19 +33,19 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'octopush://userLogin:apiKey@default?from=Heyliot&type=FR']; yield [false, 'somethingElse://userLogin:apiKet@default?from=Heyliot&type=FR']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['octopush://userLogin:apiKey@default?type=FR']; yield 'missing option: type' => ['octopush://userLogin:apiKey@default?from=Heyliot']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://userLogin:apiKey@default?from=0611223344']; yield ['somethingElse://userLogin:apiKey@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportTest.php index d528a8582a459..c24cd9f272bd7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Octopush/Tests/OctopushTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Octopush\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class OctopushTransportTest extends TransportTestCase /** * @return OctopushTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new OctopushTransport('userLogin', 'apiKey', 'from', 'type', $client ?? $this->createMock(HttpClientInterface::class)); + return new OctopushTransport('userLogin', 'apiKey', 'from', 'type', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['octopush://www.octopush-dm.com?from=from&type=type', $this->createTransport()]; + yield ['octopush://www.octopush-dm.com?from=from&type=type', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('33611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Octopush/composer.json b/src/Symfony/Component/Notifier/Bridge/Octopush/composer.json index 456f351cf496a..197b1c408379d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Octopush/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Octopush/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Octopush\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/OneSignal/LICENSE b/src/Symfony/Component/Notifier/Bridge/OneSignal/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/OneSignal/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/OneSignal/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportFactoryTest.php index adb66e13c51e9..01cecd318712a 100644 --- a/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new OneSignalTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'onesignal://app_id@host.test', @@ -36,19 +36,19 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'onesignal://token@host']; yield [false, 'somethingElse://token@host']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing app_id' => ['onesignal://:api_key@host.test']; yield 'missing api_key' => ['onesignal://app_id:@host.test']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@host']; } diff --git a/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportTest.php b/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportTest.php index e942fe0dca780..f0d88e7383b65 100644 --- a/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/OneSignal/Tests/OneSignalTransportTest.php @@ -17,10 +17,10 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -33,14 +33,14 @@ final class OneSignalTransportTest extends TransportTestCase /** * @return OneSignalTransport */ - public function createTransport(HttpClientInterface $client = null, string $recipientId = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $recipientId = null): TransportInterface { - return new OneSignalTransport('9fb175f0-0b32-4e99-ae97-bd228b9eb246', 'api_key', $recipientId, $client ?? $this->createMock(HttpClientInterface::class)); + return new OneSignalTransport('9fb175f0-0b32-4e99-ae97-bd228b9eb246', 'api_key', $recipientId, $client ?? new MockHttpClient()); } public function testCanSetCustomHost() { - $transport = $this->createTransport(); + $transport = self::createTransport(); $transport->setHost($customHost = self::CUSTOM_HOST); @@ -49,7 +49,7 @@ public function testCanSetCustomHost() public function testCanSetCustomHostAndPort() { - $transport = $this->createTransport(); + $transport = self::createTransport(); $transport->setHost($customHost = self::CUSTOM_HOST); $transport->setPort($customPort = self::CUSTOM_PORT); @@ -57,33 +57,33 @@ public function testCanSetCustomHostAndPort() $this->assertSame(sprintf('onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@%s:%d', $customHost, $customPort), (string) $transport); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@onesignal.com', $this->createTransport()]; - yield ['onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@onesignal.com?recipientId=ea345989-d273-4f21-a33b-0c006efc5edb', $this->createTransport(null, 'ea345989-d273-4f21-a33b-0c006efc5edb')]; + yield ['onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@onesignal.com', self::createTransport()]; + yield ['onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@onesignal.com?recipientId=ea345989-d273-4f21-a33b-0c006efc5edb', self::createTransport(null, 'ea345989-d273-4f21-a33b-0c006efc5edb')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { - yield [new PushMessage('Hello', 'World'), $this->createTransport(null, 'ea345989-d273-4f21-a33b-0c006efc5edb')]; + yield [new PushMessage('Hello', 'World'), self::createTransport(null, 'ea345989-d273-4f21-a33b-0c006efc5edb')]; yield [new PushMessage('Hello', 'World', (new OneSignalOptions())->recipient('ea345989-d273-4f21-a33b-0c006efc5edb'))]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testUnsupportedWithoutRecipientId() { - $this->assertFalse($this->createTransport()->supports(new PushMessage('Hello', 'World'))); + $this->assertFalse(self::createTransport()->supports(new PushMessage('Hello', 'World'))); } public function testSendThrowsWithoutRecipient() { - $transport = $this->createTransport(); + $transport = self::createTransport(); $this->expectException(LogicException::class); $this->expectExceptionMessage('The "Symfony\Component\Notifier\Bridge\OneSignal\OneSignalTransport" transport should have configured `defaultRecipientId` via DSN or provided with message options.'); @@ -105,7 +105,7 @@ public function testSendWithErrorResponseThrows() return $response; }); - $transport = $this->createTransport($client, 'ea345989-d273-4f21-a33b-0c006efc5edb'); + $transport = self::createTransport($client, 'ea345989-d273-4f21-a33b-0c006efc5edb'); $this->expectException(TransportException::class); $this->expectExceptionMessageMatches('/Message Notifications must have English language content/'); @@ -127,7 +127,7 @@ public function testSendWithErrorResponseThrowsWhenAllUnsubscribed() return $response; }); - $transport = $this->createTransport($client, 'ea345989-d273-4f21-a33b-0c006efc5edb'); + $transport = self::createTransport($client, 'ea345989-d273-4f21-a33b-0c006efc5edb'); $this->expectException(TransportException::class); $this->expectExceptionMessageMatches('/All included players are not subscribed/'); @@ -153,7 +153,7 @@ public function testSend() return $response; }); - $transport = $this->createTransport($client, 'ea345989-d273-4f21-a33b-0c006efc5edb'); + $transport = self::createTransport($client, 'ea345989-d273-4f21-a33b-0c006efc5edb'); $sentMessage = $transport->send(new PushMessage('Hello', 'World')); diff --git a/src/Symfony/Component/Notifier/Bridge/OneSignal/composer.json b/src/Symfony/Component/Notifier/Bridge/OneSignal/composer.json index af19fde7917d4..240d8f2de9419 100644 --- a/src/Symfony/Component/Notifier/Bridge/OneSignal/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/OneSignal/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.4|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\OneSignal\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/LICENSE b/src/Symfony/Component/Notifier/Bridge/OvhCloud/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportFactoryTest.php index abf6f40343fdc..9ea6e40e7decb 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new OvhCloudTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'ovhcloud://host.test?consumer_key=consumerKey&service_name=serviceName', @@ -38,19 +38,19 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'ovhcloud://key:secret@default?consumer_key=consumerKey&service_name=serviceName&sender=sender']; yield [false, 'somethingElse://key:secret@default?consumer_key=consumerKey&service_name=serviceName&sender=sender']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: consumer_key' => ['ovhcloud://key:secret@default?service_name=serviceName']; yield 'missing option: service_name' => ['ovhcloud://key:secret@default?consumer_key=consumerKey']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://key:secret@default?consumer_key=consumerKey&service_name=serviceName&sender=sender']; yield ['somethingElse://key:secret@default?service_name=serviceName']; diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php index c3fdbbb047067..b36cdd0557771 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php @@ -16,9 +16,9 @@ use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,29 +27,29 @@ final class OvhCloudTransportTest extends TransportTestCase /** * @return OvhCloudTransport */ - public function createTransport(HttpClientInterface $client = null, string $sender = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $sender = null): TransportInterface { - return (new OvhCloudTransport('applicationKey', 'applicationSecret', 'consumerKey', 'serviceName', $client ?? $this->createMock(HttpClientInterface::class)))->setSender($sender); + return (new OvhCloudTransport('applicationKey', 'applicationSecret', 'consumerKey', 'serviceName', $client ?? new MockHttpClient()))->setSender($sender); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['ovhcloud://eu.api.ovh.com?consumer_key=consumerKey&service_name=serviceName', $this->createTransport()]; - yield ['ovhcloud://eu.api.ovh.com?consumer_key=consumerKey&service_name=serviceName&sender=sender', $this->createTransport(null, 'sender')]; + yield ['ovhcloud://eu.api.ovh.com?consumer_key=consumerKey&service_name=serviceName', self::createTransport()]; + yield ['ovhcloud://eu.api.ovh.com?consumer_key=consumerKey&service_name=serviceName&sender=sender', self::createTransport(null, 'sender')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } - public function validMessagesProvider(): iterable + public static function validMessagesProvider(): iterable { yield 'without a slash' => ['hello']; yield 'including a slash' => ['hel/lo']; @@ -82,7 +82,7 @@ public function testValidSignature(string $message) $lastResponse, ]; - $transport = $this->createTransport(new MockHttpClient($responses)); + $transport = self::createTransport(new MockHttpClient($responses)); $transport->send($smsMessage); $body = $lastResponse->getRequestOptions()['body']; @@ -109,7 +109,7 @@ public function testInvalidReceiver() new MockResponse($data), ]; - $transport = $this->createTransport(new MockHttpClient($responses)); + $transport = self::createTransport(new MockHttpClient($responses)); $this->expectException(TransportException::class); $this->expectExceptionMessage('Attempt to send the SMS to invalid receivers: "invalid_receiver"'); diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json b/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json index 1185524e5d72b..bdb314b37f69c 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\OvhCloud\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/LICENSE b/src/Symfony/Component/Notifier/Bridge/RocketChat/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportFactoryTest.php index d9fb2bcb27e19..e44d3157a5cf8 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportFactoryTest.php @@ -28,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new RocketChatTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'rocketchat://host.test?channel=testChannel', @@ -36,18 +36,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'rocketchat://token@host?channel=testChannel']; yield [false, 'somethingElse://token@host?channel=testChannel']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['rocketchat://host.test?channel=testChannel']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@host?channel=testChannel']; } diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php b/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php index fc45fe4f9215c..9be71200444ab 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\RocketChat\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\RocketChat\RocketChatTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,25 +28,25 @@ final class RocketChatTransportTest extends TransportTestCase /** * @return RocketChatTransport */ - public function createTransport(HttpClientInterface $client = null, string $channel = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $channel = null): TransportInterface { - return new RocketChatTransport('testAccessToken', $channel, $client ?? $this->createMock(HttpClientInterface::class)); + return new RocketChatTransport('testAccessToken', $channel, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['rocketchat://rocketchat.com', $this->createTransport()]; - yield ['rocketchat://rocketchat.com?channel=testChannel', $this->createTransport(null, 'testChannel')]; + yield ['rocketchat://rocketchat.com', self::createTransport()]; + yield ['rocketchat://rocketchat.com?channel=testChannel', self::createTransport(null, 'testChannel')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json b/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json index f2812d02cdac1..cfcd159d0c10c 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\RocketChat\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/LICENSE b/src/Symfony/Component/Notifier/Bridge/Sendinblue/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportFactoryTest.php index c9b2cb5c0bbb3..d46e9047f1128 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new SendinblueTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'sendinblue://host.test?sender=0611223344', @@ -33,23 +33,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'sendinblue://apiKey@default?sender=0611223344']; yield [false, 'somethingElse://apiKey@default?sender=0611223344']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing api_key' => ['sendinblue://default?sender=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: sender' => ['sendinblue://apiKey@host.test']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://apiKey@default?sender=0611223344']; yield ['somethingElse://apiKey@host']; // missing "sender" option diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php index adde5b17d4157..13dcd1ec14783 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php @@ -15,9 +15,9 @@ use Symfony\Component\Notifier\Bridge\Sendinblue\SendinblueTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -27,25 +27,25 @@ final class SendinblueTransportTest extends TransportTestCase /** * @return SendinblueTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new SendinblueTransport('api-key', '0611223344', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new SendinblueTransport('api-key', '0611223344', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['sendinblue://host.test?sender=0611223344', $this->createTransport()]; + yield ['sendinblue://host.test?sender=0611223344', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithErrorResponseThrowsTransportException() @@ -62,7 +62,7 @@ public function testSendWithErrorResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessage('Unable to send the SMS: bad request'); diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json b/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json index ae5af27081ad8..890e71ba9b924 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Sendinblue\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/LICENSE b/src/Symfony/Component/Notifier/Bridge/Sinch/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportFactoryTest.php index 5139f236dd67e..9c71d3918d413 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new SinchTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'sinch://host.test?from=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'sinch://accountSid:authToken@default?from=0611223344']; yield [false, 'somethingElse://accountSid:authToken@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['sinch://accountSid:authToken@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://accountSid:authToken@default?from=0611223344']; yield ['somethingElse://accountSid:authToken@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportTest.php index c9464848f203b..4940bb71986e6 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/Tests/SinchTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Sinch\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Sinch\SinchTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class SinchTransportTest extends TransportTestCase /** * @return SinchTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new SinchTransport('accountSid', 'authToken', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); + return new SinchTransport('accountSid', 'authToken', 'sender', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['sinch://sms.api.sinch.com?from=sender', $this->createTransport()]; + yield ['sinch://sms.api.sinch.com?from=sender', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json b/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json index 65578eee1bdc1..1fc29806e5f70 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Sinch\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/LICENSE b/src/Symfony/Component/Notifier/Bridge/Slack/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Slack/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackOptionsTest.php index b162a2401500a..899f2cdbe440c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackOptionsTest.php @@ -35,7 +35,7 @@ public function testToArray(array $options, array $expected = null) $this->assertSame($expected ?? $options, (new SlackOptions($options))->toArray()); } - public function toArrayProvider(): iterable + public static function toArrayProvider(): iterable { yield 'empty is allowed' => [ [], @@ -61,7 +61,7 @@ public function toArrayProvider(): iterable ]; } - public function toArraySimpleOptionsProvider(): iterable + public static function toArraySimpleOptionsProvider(): iterable { yield [['as_user' => true]]; yield [['icon_emoji' => 'foo']]; @@ -83,7 +83,7 @@ public function testGetRecipientId(?string $expected, SlackOptions $options) $this->assertSame($expected, $options->getRecipientId()); } - public function getRecipientIdProvider(): iterable + public static function getRecipientIdProvider(): iterable { yield [null, new SlackOptions()]; yield [null, new SlackOptions(['recipient_id' => null])]; @@ -103,7 +103,7 @@ public function testSet(string $method, string $optionsKey, $value) $this->assertSame($value, $options->toArray()[$optionsKey]); } - public function setProvider(): iterable + public static function setProvider(): iterable { yield ['asUser', 'as_user', true]; yield ['iconEmoji', 'icon_emoji', 'foo']; @@ -144,7 +144,7 @@ public function testFromNotification(array $expected, Notification $notification $this->assertSame($expected, $options->toArray()); } - public function fromNotificationProvider(): iterable + public static function fromNotificationProvider(): iterable { $subject = 'Hi!'; $emoji = '🌧️'; diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportFactoryTest.php index 11f78bade6653..04aa7780e6146 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportFactoryTest.php @@ -27,7 +27,7 @@ public function createFactory(): TransportFactoryInterface return new SlackTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'slack://host.test', @@ -55,18 +55,18 @@ public function testCreateWithDeprecatedDsn() $factory->create(new Dsn('slack://default/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX')); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'slack://xoxb-TestToken@host?channel=testChannel']; yield [false, 'somethingElse://xoxb-TestToken@host?channel=testChannel']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['slack://host.test?channel=testChannel']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://xoxb-TestToken@host?channel=testChannel']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php index 2b3e96e6b4414..2a82a6303ce3c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php @@ -18,11 +18,11 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -32,26 +32,26 @@ final class SlackTransportTest extends TransportTestCase /** * @return SlackTransport */ - public function createTransport(HttpClientInterface $client = null, string $channel = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $channel = null): TransportInterface { - return new SlackTransport('xoxb-TestToken', $channel, $client ?? $this->createMock(HttpClientInterface::class)); + return new SlackTransport('xoxb-TestToken', $channel, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['slack://slack.com', $this->createTransport()]; - yield ['slack://slack.com?channel=test+Channel', $this->createTransport(null, 'test Channel')]; + yield ['slack://slack.com', self::createTransport()]; + yield ['slack://slack.com?channel=test+Channel', self::createTransport(null, 'test Channel')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testInstatiatingWithAnInvalidSlackTokenThrowsInvalidArgumentException() @@ -78,7 +78,7 @@ public function testSendWithEmptyArrayResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $transport->send(new ChatMessage('testMessage')); } @@ -101,7 +101,7 @@ public function testSendWithErrorResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $transport->send(new ChatMessage('testMessage')); } @@ -129,7 +129,7 @@ public function testSendWithOptions() return $response; }); - $transport = $this->createTransport($client, $channel); + $transport = self::createTransport($client, $channel); $sentMessage = $transport->send(new ChatMessage('testMessage')); @@ -167,7 +167,7 @@ public function testSendWithNotification() return $response; }); - $transport = $this->createTransport($client, $channel); + $transport = self::createTransport($client, $channel); $sentMessage = $transport->send($chatMessage); @@ -182,7 +182,7 @@ public function testSendWithInvalidOptions() return $this->createMock(ResponseInterface::class); }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $transport->send(new ChatMessage('testMessage', $this->createMock(MessageOptionsInterface::class))); } @@ -212,7 +212,7 @@ public function testSendWith200ResponseButNotOk() return $response; }); - $transport = $this->createTransport($client, $channel); + $transport = self::createTransport($client, $channel); $transport->send(new ChatMessage('testMessage')); } @@ -235,7 +235,7 @@ public function testSendIncludesContentTypeWithCharset() return $response; }); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $transport->send(new ChatMessage('testMessage')); } @@ -260,7 +260,7 @@ public function testSendWithErrorsIncluded() return $response; }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $this->expectException(TransportException::class); $this->expectExceptionMessage('Unable to post the Slack message: "invalid_blocks" (no more than 50 items allowed [json-pointer:/blocks]).'); diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/composer.json b/src/Symfony/Component/Notifier/Bridge/Slack/composer.json index 70cd75bdc354b..d0d92f1d51e1e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Slack/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1|^3", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Slack\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Sms77/LICENSE b/src/Symfony/Component/Notifier/Bridge/Sms77/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sms77/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Sms77/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportFactoryTest.php index be1768bae841a..510046dac82fd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new Sms77TransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'sms77://host.test', @@ -38,18 +38,18 @@ public function createProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing api key' => ['sms77://host?from=TEST']; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'sms77://apiKey@default?from=TEST']; yield [false, 'somethingElse://apiKey@default?from=TEST']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://apiKey@default?from=FROM']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportTest.php b/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportTest.php index cce992b9abef7..c028df2b12be5 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sms77/Tests/Sms77TransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Sms77\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Sms77\Sms77Transport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,25 +25,25 @@ final class Sms77TransportTest extends TransportTestCase /** * @return Sms77Transport */ - public function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $from = null): TransportInterface { - return new Sms77Transport('apiKey', $from, $client ?? $this->createMock(HttpClientInterface::class)); + return new Sms77Transport('apiKey', $from, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['sms77://gateway.sms77.io', $this->createTransport()]; - yield ['sms77://gateway.sms77.io?from=TEST', $this->createTransport(null, 'TEST')]; + yield ['sms77://gateway.sms77.io', self::createTransport()]; + yield ['sms77://gateway.sms77.io?from=TEST', self::createTransport(null, 'TEST')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Sms77/composer.json b/src/Symfony/Component/Notifier/Bridge/Sms77/composer.json index f5116efbd9f2e..782d6216146e3 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sms77/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Sms77/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Sms77\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/LICENSE b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportFactoryTest.php index abb1dd3eb0042..c201a4793e8a5 100644 --- a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new SmsBiurasTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'smsbiuras://host.test?from=0611223344', @@ -38,18 +38,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'smsbiuras://uid:api_key@default?from=0611223344']; yield [false, 'somethingElse://uid:api_key@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['smsbiuras://uid:api_key@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://uid:api_key@default?from=0611223344']; yield ['somethingElse://uid:api_key@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportTest.php b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportTest.php index 51c15c56d4a08..5bec5cd016453 100644 --- a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportTest.php @@ -14,9 +14,9 @@ use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\SmsBiuras\SmsBiurasTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -26,25 +26,25 @@ final class SmsBiurasTransportTest extends TransportTestCase /** * @return SmsBiurasTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new SmsBiurasTransport('uid', 'api_key', 'from', true, $client ?? $this->createMock(HttpClientInterface::class)); + return new SmsBiurasTransport('uid', 'api_key', 'from', true, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['smsbiuras://savitarna.smsbiuras.lt?from=from&test_mode=1', $this->createTransport()]; + yield ['smsbiuras://savitarna.smsbiuras.lt?from=from&test_mode=1', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } /** @@ -52,7 +52,7 @@ public function unsupportedMessagesProvider(): iterable */ public function testTestMode(int $expected, bool $testMode) { - $message = new SmsMessage('+37012345678', 'Hello World!'); + $message = new SmsMessage('0037012345678', 'Hello World'); $response = $this->createMock(ResponseInterface::class); $response->expects($this->atLeast(1)) diff --git a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/composer.json b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/composer.json index b2a986ba5e5d7..79b39c5982013 100644 --- a/src/Symfony/Component/Notifier/Bridge/SmsBiuras/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/SmsBiuras/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\SmsBiuras\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/LICENSE b/src/Symfony/Component/Notifier/Bridge/Smsapi/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php index 71bdde97a3d9f..7d994daf01342 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new SmsapiTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'smsapi://host.test?from=testFrom', @@ -33,23 +33,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'smsapi://host?from=testFrom']; yield [false, 'somethingElse://host?from=testFrom']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing token' => ['smsapi://host.test?from=testFrom']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['smsapi://token@host']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://token@host?from=testFrom']; yield ['somethingElse://token@host']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php index 3af790460bf28..2e50676ac40d4 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/Tests/SmsapiTransportTest.php @@ -16,9 +16,9 @@ use Symfony\Component\Notifier\Bridge\Smsapi\SmsapiTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,25 +27,25 @@ final class SmsapiTransportTest extends TransportTestCase /** * @return SmsapiTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new SmsapiTransport('testToken', 'testFrom', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('test.host'); + return (new SmsapiTransport('testToken', 'testFrom', $client ?? new MockHttpClient()))->setHost('test.host'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['smsapi://test.host?from=testFrom', $this->createTransport()]; + yield ['smsapi://test.host?from=testFrom', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function createClient(int $statusCode, string $content): HttpClientInterface @@ -53,7 +53,7 @@ public function createClient(int $statusCode, string $content): HttpClientInterf return new MockHttpClient(new MockResponse($content, ['http_code' => $statusCode])); } - public function responseProvider(): iterable + public static function responseProvider(): iterable { $responses = [ ['status' => 200, 'content' => '{"error":101,"message":"Authorization failed"}', 'errorMessage' => 'Unable to send the SMS: "Authorization failed".'], @@ -75,7 +75,7 @@ public function responseProvider(): iterable public function testThrowExceptionWhenMessageWasNotSent(int $statusCode, string $content, string $errorMessage) { $client = $this->createClient($statusCode, $content); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $message = new SmsMessage('0611223344', 'Hello!'); $this->expectException(TransportException::class); diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json b/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json index bfa0f1e3b5bf2..e1b0d7289c241 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Smsapi\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Smsc/LICENSE b/src/Symfony/Component/Notifier/Bridge/Smsc/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsc/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Smsc/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportFactoryTest.php index d3bf70319ae61..ee6a88940c7de 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new SmscTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'smsc://host.test?from=MyApp', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'smsc://login:password@default?from=MyApp']; yield [false, 'somethingElse://login:password@default?from=MyApp']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['smsc://login:password@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://login:password@default?from=MyApp']; yield ['somethingElse://login:password@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportTest.php index 5a849a646e3b1..382b6b2a8767c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsc/Tests/SmscTransportTest.php @@ -11,34 +11,35 @@ namespace Symfony\Component\Notifier\Bridge\Smsc\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Smsc\SmscTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; final class SmscTransportTest extends TransportTestCase { - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new SmscTransport('login', 'password', 'MyApp', $client ?? $this->createMock(HttpClientInterface::class)); + return new SmscTransport('login', 'password', 'MyApp', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['smsc://smsc.ru?from=MyApp', $this->createTransport()]; + yield ['smsc://smsc.ru?from=MyApp', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Smsc/composer.json b/src/Symfony/Component/Notifier/Bridge/Smsc/composer.json index f1a32db0913fd..43afd349e38b5 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsc/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Smsc/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Smsc\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/SpotHit/LICENSE b/src/Symfony/Component/Notifier/Bridge/SpotHit/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/SpotHit/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/SpotHit/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportFactoryTest.php index 57da2c142a5e4..a7ff7fb71b586 100644 --- a/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new SpotHitTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'spothit://spot-hit.fr', @@ -37,13 +37,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'spothit://api_token@default?from=MyCompany']; yield [false, 'somethingElse://api_token@default?from=MyCompany']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['foobar://api_token@default?from=MyCompany']; yield ['foobar://api_token@default']; diff --git a/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportTest.php b/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportTest.php index d3129b65efe54..e3e60fe3c7083 100644 --- a/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/SpotHit/Tests/SpotHitTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\SpotHit\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\SpotHit\SpotHitTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,25 +25,25 @@ final class SpotHitTransportTest extends TransportTestCase /** * @return SpotHitTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new SpotHitTransport('api_token', 'MyCompany', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new SpotHitTransport('api_token', 'MyCompany', $client ?? new MockHttpClient()))->setHost('host.test'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['spothit://host.test?from=MyCompany', $this->createTransport()]; + yield ['spothit://host.test?from=MyCompany', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; yield [new SmsMessage('+33611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/SpotHit/composer.json b/src/Symfony/Component/Notifier/Bridge/SpotHit/composer.json index dc81907cd13a5..186370817554c 100644 --- a/src/Symfony/Component/Notifier/Bridge/SpotHit/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/SpotHit/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.1|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\SpotHit\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/LICENSE b/src/Symfony/Component/Notifier/Bridge/Telegram/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportFactoryTest.php index 37a0577444c57..2ceb03b08ae83 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new TelegramTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'telegram://host.test?channel=testChannel', @@ -33,19 +33,19 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'telegram://host?channel=testChannel']; yield [false, 'somethingElse://host?channel=testChannel']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing password' => ['telegram://token@host.test?channel=testChannel']; yield 'missing token' => ['telegram://host.test?channel=testChannel']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://user:pwd@host']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php index 718f566b0c240..1ad87524ea452 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php @@ -16,9 +16,9 @@ use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransport; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -28,26 +28,26 @@ final class TelegramTransportTest extends TransportTestCase /** * @return TelegramTransport */ - public function createTransport(HttpClientInterface $client = null, string $channel = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $channel = null): TransportInterface { - return new TelegramTransport('token', $channel, $client ?? $this->createMock(HttpClientInterface::class)); + return new TelegramTransport('token', $channel, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['telegram://api.telegram.org', $this->createTransport()]; - yield ['telegram://api.telegram.org?channel=testChannel', $this->createTransport(null, 'testChannel')]; + yield ['telegram://api.telegram.org', self::createTransport()]; + yield ['telegram://api.telegram.org?channel=testChannel', self::createTransport(null, 'testChannel')]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSendWithErrorResponseThrowsTransportException() @@ -67,7 +67,7 @@ public function testSendWithErrorResponseThrowsTransportException() return $response; }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $transport->send(new ChatMessage('testMessage')); } @@ -119,7 +119,7 @@ public function testSendWithOptions() return $response; }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $sentMessage = $transport->send(new ChatMessage('testMessage')); @@ -175,7 +175,7 @@ public function testSendWithChannelOverride() return $response; }); - $transport = $this->createTransport($client, 'defaultChannel'); + $transport = self::createTransport($client, 'defaultChannel'); $messageOptions = new TelegramOptions(); $messageOptions->chatId($channelOverride); @@ -233,7 +233,7 @@ public function testSendWithMarkdownShouldEscapeSpecialCharacters() return $response; }); - $transport = $this->createTransport($client, 'testChannel'); + $transport = self::createTransport($client, 'testChannel'); $transport->send(new ChatMessage('I contain special characters _ * [ ] ( ) ~ ` > # + - = | { } . ! to send.')); } diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json index 610f06c97195f..1eb52c8d0d1b1 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Telegram\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Telnyx/LICENSE b/src/Symfony/Component/Notifier/Bridge/Telnyx/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telnyx/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Telnyx/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportFactoryTest.php index 3d7cd943723a9..de864da8f1980 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new TelnyxTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'telnyx://host.test?from=+0611223344', @@ -38,18 +38,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'telnyx://api_key@default?from=%2B0611223344']; yield [false, 'somethingElse://api_key@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['telnyx://api_key@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://api_key@default?from=+0611223344']; yield ['somethingElse://api_key@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportTest.php index 4ecb9b58c49ae..5a0e4f75bc122 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telnyx/Tests/TelnyxTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Telnyx\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class TelnyxTransportTest extends TransportTestCase /** * @return TelnyxTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new TelnyxTransport('api_key', 'from', 'messaging_profile_id', $client ?? $this->createMock(HttpClientInterface::class)); + return new TelnyxTransport('api_key', 'from', 'messaging_profile_id', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['telnyx://api.telnyx.com?from=from&messaging_profile_id=messaging_profile_id', $this->createTransport()]; + yield ['telnyx://api.telnyx.com?from=from&messaging_profile_id=messaging_profile_id', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('+0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Telnyx/composer.json b/src/Symfony/Component/Notifier/Bridge/Telnyx/composer.json index 7eff6f15d5165..ac5ff8bfd56b8 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telnyx/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Telnyx/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Telnyx\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/TurboSms/LICENSE b/src/Symfony/Component/Notifier/Bridge/TurboSms/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/TurboSms/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/TurboSms/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportFactoryTest.php index 682a6ae5548b1..cb957cb7a8088 100644 --- a/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new TurboSmsTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'turbosms://host.test?from=acme', @@ -38,18 +38,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'turbosms://authToken@default?from=acme']; yield [false, 'somethingElse://authToken@default?from=acme']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['turbosms://authToken@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://authToken@default?from=acme']; yield ['somethingElse://authToken@default']; diff --git a/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportTest.php index ae559bb012cf7..1206ce02b0979 100644 --- a/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/TurboSms/Tests/TurboSmsTransportTest.php @@ -16,10 +16,10 @@ use Symfony\Component\Notifier\Exception\LengthException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -29,25 +29,25 @@ final class TurboSmsTransportTest extends TransportTestCase /** * @return TurboSmsTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new TurboSmsTransport('authToken', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); + return new TurboSmsTransport('authToken', 'sender', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['turbosms://api.turbosms.ua?from=sender', $this->createTransport()]; + yield ['turbosms://api.turbosms.ua?from=sender', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('380931234567', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testSuccessfulSend() @@ -81,7 +81,7 @@ public function testSuccessfulSend() $message = new SmsMessage('380931234567', 'Тест/Test'); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $sentMessage = $transport->send($message); self::assertInstanceOf(SentMessage::class, $sentMessage); @@ -112,7 +112,7 @@ public function testFailedSend() $message = new SmsMessage('380931234567', 'Тест/Test'); - $transport = $this->createTransport($client); + $transport = self::createTransport($client); $this->expectException(TransportException::class); $this->expectExceptionMessage('Unable to send SMS with TurboSMS: Error code 103 with message "REQUIRED_TOKEN".'); diff --git a/src/Symfony/Component/Notifier/Bridge/TurboSms/composer.json b/src/Symfony/Component/Notifier/Bridge/TurboSms/composer.json index 4ea29366dae46..777b45974ca1f 100644 --- a/src/Symfony/Component/Notifier/Bridge/TurboSms/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/TurboSms/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/http-client": "^5.3|^6.0", - "symfony/notifier": "^5.3|^6.0", + "symfony/notifier": "^5.4.21|^6.2.7", "symfony/polyfill-mbstring": "^1.0" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/LICENSE b/src/Symfony/Component/Notifier/Bridge/Twilio/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportFactoryTest.php index a9f46e6103bef..c9e78fc91b974 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new TwilioTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'twilio://host.test?from=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'twilio://accountSid:authToken@default?from=0611223344']; yield [false, 'somethingElse://accountSid:authToken@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['twilio://accountSid:authToken@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://accountSid:authToken@default?from=0611223344']; yield ['somethingElse://accountSid:authToken@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportTest.php index d0cdd76ff9aee..e48e41f4d4040 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/Tests/TwilioTransportTest.php @@ -15,9 +15,9 @@ use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransport; use Symfony\Component\Notifier\Exception\InvalidArgumentException; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -27,25 +27,25 @@ final class TwilioTransportTest extends TransportTestCase /** * @return TwilioTransport */ - public function createTransport(HttpClientInterface $client = null, string $from = 'from'): TransportInterface + public static function createTransport(HttpClientInterface $client = null, string $from = 'from'): TransportInterface { - return new TwilioTransport('accountSid', 'authToken', $from, $client ?? $this->createMock(HttpClientInterface::class)); + return new TwilioTransport('accountSid', 'authToken', $from, $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['twilio://api.twilio.com?from=from', $this->createTransport()]; + yield ['twilio://api.twilio.com?from=from', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } /** @@ -53,7 +53,7 @@ public function unsupportedMessagesProvider(): iterable */ public function testInvalidArgumentExceptionIsThrownIfFromIsInvalid(string $from) { - $transport = $this->createTransport(null, $from); + $transport = self::createTransport(null, $from); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf('The "From" number "%s" is not a valid phone number, shortcode, or alphanumeric sender ID.', $from)); @@ -61,7 +61,7 @@ public function testInvalidArgumentExceptionIsThrownIfFromIsInvalid(string $from $transport->send(new SmsMessage('+33612345678', 'Hello!')); } - public function invalidFromProvider(): iterable + public static function invalidFromProvider(): iterable { // alphanumeric sender ids yield 'too short' => ['a']; @@ -98,14 +98,14 @@ public function testNoInvalidArgumentExceptionIsThrownIfFromIsValid(string $from return $response; }); - $transport = $this->createTransport($client, $from); + $transport = self::createTransport($client, $from); $sentMessage = $transport->send($message); $this->assertSame('123', $sentMessage->getMessageId()); } - public function validFromProvider(): iterable + public static function validFromProvider(): iterable { // alphanumeric sender ids yield ['ab']; diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json b/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json index f4c2575c12aa7..aad308279b93d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Twilio\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE b/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php index b25b549828847..dd983c5b14005 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new VonageTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'vonage://host.test?from=0611223344', @@ -33,18 +33,18 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'vonage://apiKey:apiSecret@default?from=0611223344']; yield [false, 'somethingElse://apiKey:apiSecret@default?from=0611223344']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: from' => ['vonage://apiKey:apiSecret@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://apiKey:apiSecret@default?from=0611223344']; yield ['somethingElse://apiKey:apiSecret@default']; // missing "from" option diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php index dc545a02a9d78..f2b403fc80e68 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Vonage\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Vonage\VonageTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class VonageTransportTest extends TransportTestCase /** * @return VonageTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new VonageTransport('apiKey', 'apiSecret', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); + return new VonageTransport('apiKey', 'apiSecret', 'sender', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['vonage://rest.nexmo.com?from=sender', $this->createTransport()]; + yield ['vonage://rest.nexmo.com?from=sender', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json b/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json index c80b016feaaa5..dfefd120702f9 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Vonage\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Yunpian/LICENSE b/src/Symfony/Component/Notifier/Bridge/Yunpian/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Yunpian/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Yunpian/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportFactoryTest.php index dfa5a23b735b7..737c228800189 100644 --- a/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new YunpianTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'yunpian://host.test', @@ -33,13 +33,13 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'yunpian://api_key@default']; yield [false, 'somethingElse://api_key@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://api_key@default']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportTest.php index 3adf11006bf3f..de1acba8189b8 100644 --- a/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Yunpian/Tests/YunpianTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Yunpian\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class YunpianTransportTest extends TransportTestCase /** * @return YunpianTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new YunpianTransport('api_key', $client ?? $this->createMock(HttpClientInterface::class)); + return new YunpianTransport('api_key', $client ?? new MockHttpClient()); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['yunpian://sms.yunpian.com', $this->createTransport()]; + yield ['yunpian://sms.yunpian.com', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new SmsMessage('+0611223344', 'Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Yunpian/composer.json b/src/Symfony/Component/Notifier/Bridge/Yunpian/composer.json index 873b1840ce3e2..ad30ecb6e1a2b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Yunpian/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Yunpian/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.2|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Yunpian\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/LICENSE b/src/Symfony/Component/Notifier/Bridge/Zulip/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportFactoryTest.php index 77c1b3f5f709d..438973b1b7393 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportFactoryTest.php @@ -25,7 +25,7 @@ public function createFactory(): TransportFactoryInterface return new ZulipTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'zulip://host.test?channel=testChannel', @@ -33,23 +33,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'zulip://host?channel=testChannel']; yield [false, 'somethingElse://host?channel=testChannel']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing email or token' => ['zulip://testOneOfEmailOrToken@host.test?channel=testChannel']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield 'missing option: channel' => ['zulip://email:token@host']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://email:token@host?channel=testChannel']; yield ['somethingElse://email:token@host']; // missing "channel" option diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportTest.php index 1da6bc6ee33fa..9dcb7547c207c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/Tests/ZulipTransportTest.php @@ -11,11 +11,12 @@ namespace Symfony\Component\Notifier\Bridge\Zulip\Tests; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransport; use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -24,24 +25,24 @@ final class ZulipTransportTest extends TransportTestCase /** * @return ZulipTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return (new ZulipTransport('testEmail', 'testToken', 'testChannel', $client ?? $this->createMock(HttpClientInterface::class)))->setHost('test.host'); + return (new ZulipTransport('testEmail', 'testToken', 'testChannel', $client ?? new MockHttpClient()))->setHost('test.host'); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { - yield ['zulip://test.host?channel=testChannel', $this->createTransport()]; + yield ['zulip://test.host?channel=testChannel', self::createTransport()]; } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new ChatMessage('Hello!')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json b/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json index b0751d660f2df..18df92260277f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0" + "symfony/notifier": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Zulip\\": "" }, diff --git a/src/Symfony/Component/Notifier/CHANGELOG.md b/src/Symfony/Component/Notifier/CHANGELOG.md index 5e353ec5cc437..5ed8f7b4961d8 100644 --- a/src/Symfony/Component/Notifier/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +5.4.21 +------ + + * [BC BREAK] The following data providers for `TransportTestCase` are now static: `toStringProvider()`, `supportedMessagesProvider()` and `unsupportedMessagesProvider()` + * [BC BREAK] `TransportTestCase::createTransport()` is now static + 5.4 --- diff --git a/src/Symfony/Component/Notifier/Event/NotificationEvents.php b/src/Symfony/Component/Notifier/Event/NotificationEvents.php index 19d698b61f3a1..4ed3e6fa78c05 100644 --- a/src/Symfony/Component/Notifier/Event/NotificationEvents.php +++ b/src/Symfony/Component/Notifier/Event/NotificationEvents.php @@ -24,7 +24,7 @@ class NotificationEvents public function add(MessageEvent $event): void { $this->events[] = $event; - $this->transports[$event->getMessage()->getTransport()] = true; + $this->transports[(string) $event->getMessage()->getTransport()] = true; } public function getTransports(): array @@ -43,7 +43,7 @@ public function getEvents(string $name = null): array $events = []; foreach ($this->events as $event) { - if ($name === $event->getMessage()->getTransport()) { + if ($name === (string) $event->getMessage()->getTransport()) { $events[] = $event; } } diff --git a/src/Symfony/Component/Notifier/LICENSE b/src/Symfony/Component/Notifier/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/Notifier/LICENSE +++ b/src/Symfony/Component/Notifier/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Test/TransportFactoryTestCase.php b/src/Symfony/Component/Notifier/Test/TransportFactoryTestCase.php index 861ccdb16b968..706cdea506656 100644 --- a/src/Symfony/Component/Notifier/Test/TransportFactoryTestCase.php +++ b/src/Symfony/Component/Notifier/Test/TransportFactoryTestCase.php @@ -17,6 +17,7 @@ use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; use Symfony\Component\Notifier\Transport\Dsn; use Symfony\Component\Notifier\Transport\TransportFactoryInterface; +use Symfony\Component\Notifier\Transport\TransportInterface; /** * A test case to ease testing a notifier transport factory. @@ -30,17 +31,17 @@ abstract public function createFactory(): TransportFactoryInterface; /** * @return iterable */ - abstract public function supportsProvider(): iterable; + abstract public static function supportsProvider(): iterable; /** * @return iterable */ - abstract public function createProvider(): iterable; + abstract public static function createProvider(): iterable; /** * @return iterable */ - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { return []; } @@ -48,7 +49,7 @@ public function unsupportedSchemeProvider(): iterable /** * @return iterable */ - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { return []; } @@ -56,7 +57,7 @@ public function incompleteDsnProvider(): iterable /** * @return iterable */ - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { return []; } diff --git a/src/Symfony/Component/Notifier/Test/TransportTestCase.php b/src/Symfony/Component/Notifier/Test/TransportTestCase.php index 012f4c56fa73d..0b80836d73aee 100644 --- a/src/Symfony/Component/Notifier/Test/TransportTestCase.php +++ b/src/Symfony/Component/Notifier/Test/TransportTestCase.php @@ -27,22 +27,22 @@ abstract class TransportTestCase extends TestCase protected const CUSTOM_HOST = 'host.test'; protected const CUSTOM_PORT = 42; - abstract public function createTransport(HttpClientInterface $client = null): TransportInterface; + abstract public static function createTransport(HttpClientInterface $client = null): TransportInterface; /** * @return iterable */ - abstract public function toStringProvider(): iterable; + abstract public static function toStringProvider(): iterable; /** * @return iterable */ - abstract public function supportedMessagesProvider(): iterable; + abstract public static function supportedMessagesProvider(): iterable; /** * @return iterable */ - abstract public function unsupportedMessagesProvider(): iterable; + abstract public static function unsupportedMessagesProvider(): iterable; /** * @dataProvider toStringProvider diff --git a/src/Symfony/Component/Notifier/Tests/Channel/ChannelPolicyTest.php b/src/Symfony/Component/Notifier/Tests/Channel/ChannelPolicyTest.php index 59acb33f0c873..e448368685b28 100644 --- a/src/Symfony/Component/Notifier/Tests/Channel/ChannelPolicyTest.php +++ b/src/Symfony/Component/Notifier/Tests/Channel/ChannelPolicyTest.php @@ -39,7 +39,7 @@ public function testCanRetrieveChannels(array $policy, string $importance, array $this->assertSame($expectedChannels, $channels); } - public function provideValidPolicies(): \Generator + public static function provideValidPolicies(): \Generator { yield [['urgent' => ['chat']], 'urgent', ['chat']]; yield [['urgent' => ['chat', 'sms']], 'urgent', ['chat', 'sms']]; diff --git a/src/Symfony/Component/Notifier/Tests/Event/FailedMessageEventTest.php b/src/Symfony/Component/Notifier/Tests/Event/FailedMessageEventTest.php index a2c0263eb50be..747100cd585a8 100644 --- a/src/Symfony/Component/Notifier/Tests/Event/FailedMessageEventTest.php +++ b/src/Symfony/Component/Notifier/Tests/Event/FailedMessageEventTest.php @@ -95,7 +95,7 @@ public function __toString(): string } } - public function messagesProvider(): iterable + public static function messagesProvider(): iterable { yield [$message = new ChatMessage('subject'), $error = new \RuntimeException(), new FailedMessageEvent($message, $error)]; yield [$message = new SmsMessage('+3312345678', 'subject'), $error = new \Exception(), new FailedMessageEvent($message, $error)]; diff --git a/src/Symfony/Component/Notifier/Tests/Event/SentMessageEventTest.php b/src/Symfony/Component/Notifier/Tests/Event/SentMessageEventTest.php index 0668c43171f78..b76886570b792 100644 --- a/src/Symfony/Component/Notifier/Tests/Event/SentMessageEventTest.php +++ b/src/Symfony/Component/Notifier/Tests/Event/SentMessageEventTest.php @@ -35,7 +35,7 @@ public function testGetMessage(SentMessage $message, SentMessageEvent $event) $this->assertSame($message, $event->getMessage()); } - public function messagesProvider(): iterable + public static function messagesProvider(): iterable { yield [$message = new SentMessage(new ChatMessage('subject'), 'null_transport'), new SentMessageEvent($message)]; yield [$message = new SentMessage(new SmsMessage('+3312345678', 'subject'), 'null_transport'), new SentMessageEvent($message)]; diff --git a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php index 1cd8d4033eb4d..98ffe6d615a42 100644 --- a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -127,7 +127,7 @@ public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme, ); } - public function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator { yield ['allmysms', 'symfony/all-my-sms-notifier']; yield ['sns', 'symfony/amazon-sns-notifier']; @@ -183,7 +183,7 @@ public function testMessageWhereSchemeIsNotPartOfSchemeToPackageMap(string $expe ); } - public function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator { yield [ 'The "somethingElse" scheme is not supported.', diff --git a/src/Symfony/Component/Notifier/Tests/Fixtures/TestOptions.php b/src/Symfony/Component/Notifier/Tests/Fixtures/TestOptions.php index 1f129767fdf8a..f2e09016985f8 100644 --- a/src/Symfony/Component/Notifier/Tests/Fixtures/TestOptions.php +++ b/src/Symfony/Component/Notifier/Tests/Fixtures/TestOptions.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Notifier\Tests\Fixtures; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; final class TestOptions implements MessageOptionsInterface diff --git a/src/Symfony/Component/Notifier/Tests/Message/NullMessageTest.php b/src/Symfony/Component/Notifier/Tests/Message/NullMessageTest.php index 9213fde3704ff..c3fee9a1d92bd 100644 --- a/src/Symfony/Component/Notifier/Tests/Message/NullMessageTest.php +++ b/src/Symfony/Component/Notifier/Tests/Message/NullMessageTest.php @@ -36,7 +36,7 @@ public function testCanBeConstructed(MessageInterface $message) : $this->assertSame($message->getTransport(), $nullMessage->getTransport()); } - public function messageDataProvider(): \Generator + public static function messageDataProvider(): \Generator { yield [new DummyMessageWithoutTransport()]; yield [new DummyMessageWithTransport()]; diff --git a/src/Symfony/Component/Notifier/Tests/Recipient/RecipientTest.php b/src/Symfony/Component/Notifier/Tests/Recipient/RecipientTest.php index f4e93ccd5127f..a1dce4357568e 100644 --- a/src/Symfony/Component/Notifier/Tests/Recipient/RecipientTest.php +++ b/src/Symfony/Component/Notifier/Tests/Recipient/RecipientTest.php @@ -38,7 +38,7 @@ public function testCanBeConstructed(string $email, string $phone) $this->assertSame($phone, $recipient->getPhone()); } - public function provideValidEmailAndPhone() + public static function provideValidEmailAndPhone() { yield ['test@test.de', '+0815']; yield ['test@test.de', '']; diff --git a/src/Symfony/Component/Notifier/Tests/Transport/DsnTest.php b/src/Symfony/Component/Notifier/Tests/Transport/DsnTest.php index b927c9d955689..98a898cd50a36 100644 --- a/src/Symfony/Component/Notifier/Tests/Transport/DsnTest.php +++ b/src/Symfony/Component/Notifier/Tests/Transport/DsnTest.php @@ -35,7 +35,7 @@ public function testConstruct(string $dsnString, string $scheme, string $host, s $this->assertSame($options, $dsn->getOptions()); } - public function constructProvider(): iterable + public static function constructProvider(): iterable { yield 'simple dsn' => [ 'scheme://localhost', @@ -151,7 +151,7 @@ public function testInvalidDsn(string $dsnString, string $exceptionMessage) new Dsn($dsnString); } - public function invalidDsnProvider(): iterable + public static function invalidDsnProvider(): iterable { yield [ 'some://', @@ -179,7 +179,7 @@ public function testGetOption($expected, string $dsnString, string $option, stri $this->assertSame($expected, $dsn->getOption($option, $default)); } - public function getOptionProvider(): iterable + public static function getOptionProvider(): iterable { yield [ 'foo', @@ -217,7 +217,7 @@ public function testGetRequiredOption(string $expectedValue, string $options, st $this->assertSame($expectedValue, $dsn->getRequiredOption($option)); } - public function getRequiredOptionProvider(): iterable + public static function getRequiredOptionProvider(): iterable { yield [ 'value', @@ -245,7 +245,7 @@ public function testGetRequiredOptionThrowsMissingRequiredOptionException(string $dsn->getRequiredOption($option); } - public function getRequiredOptionThrowsMissingRequiredOptionExceptionProvider(): iterable + public static function getRequiredOptionThrowsMissingRequiredOptionExceptionProvider(): iterable { yield [ 'The option "foo_bar" is required but missing.', diff --git a/src/Symfony/Component/OptionsResolver/LICENSE b/src/Symfony/Component/OptionsResolver/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/OptionsResolver/LICENSE +++ b/src/Symfony/Component/OptionsResolver/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index ba8ebfd20e8ab..2c8fc0639198e 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -552,7 +552,7 @@ public function testDeprecationMessages(\Closure $configureOptions, array $optio $this->assertSame($expectedCount, $count); } - public function provideDeprecationData() + public static function provideDeprecationData() { yield 'It deprecates an option with default message' => [ function (OptionsResolver $resolver) { @@ -850,7 +850,7 @@ public function testResolveFailsIfInvalidType($actualType, $allowedType, $except $this->resolver->resolve(['option' => $actualType]); } - public function provideInvalidTypes() + public static function provideInvalidTypes() { return [ [true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "bool".'], diff --git a/src/Symfony/Component/PasswordHasher/LICENSE b/src/Symfony/Component/PasswordHasher/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/PasswordHasher/LICENSE +++ b/src/Symfony/Component/PasswordHasher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php b/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php index 16924a18151d9..86a183e96547c 100644 --- a/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php +++ b/src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php @@ -302,7 +302,7 @@ public function testCompletionSuggestions(array $input, array $expectedSuggestio $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'user_class_empty' => [ ['p@ssw0rd', ''], diff --git a/src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php b/src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php index dc29ac6648173..2b7bd7855a9b7 100644 --- a/src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php +++ b/src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php @@ -39,7 +39,7 @@ public function testCostInRange($cost) $this->assertInstanceOf(NativePasswordHasher::class, new NativePasswordHasher(null, null, $cost)); } - public function validRangeData() + public static function validRangeData() { $costs = range(4, 31); array_walk($costs, function (&$cost) { $cost = [$cost]; }); diff --git a/src/Symfony/Component/Process/LICENSE b/src/Symfony/Component/Process/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Process/LICENSE +++ b/src/Symfony/Component/Process/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 14e17774655f1..b47ecca17bfe5 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -617,10 +617,10 @@ public function getIncrementalOutput() * * @param int $flags A bit field of Process::ITER_* flags * + * @return \Generator + * * @throws LogicException in case the output has been disabled * @throws LogicException In case the process is not started - * - * @return \Generator */ #[\ReturnTypeWillChange] public function getIterator(int $flags = 0) @@ -910,7 +910,7 @@ public function getStatus() * Stops the process. * * @param int|float $timeout The timeout in seconds - * @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9) + * @param int|null $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9) * * @return int|null The exit-code of the process or null if it's not running */ diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 1646bcb97b9b3..790167fcade94 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -301,7 +301,7 @@ public function testInvalidInput($value) $process->setInput($value); } - public function provideInvalidInputValues() + public static function provideInvalidInputValues() { return [ [[]], @@ -319,7 +319,7 @@ public function testValidInput($expected, $value) $this->assertSame($expected, $process->getInput()); } - public function provideInputValues() + public static function provideInputValues() { return [ [null, null], @@ -328,7 +328,7 @@ public function provideInputValues() ]; } - public function chainedCommandsOutputProvider() + public static function chainedCommandsOutputProvider() { if ('\\' === \DIRECTORY_SEPARATOR) { return [ @@ -422,7 +422,7 @@ public function testIncrementalOutput($getOutput, $getIncrementalOutput, $uri) fclose($h); } - public function provideIncrementalOutput() + public static function provideIncrementalOutput() { return [ ['getOutput', 'getIncrementalOutput', 'php://stdout'], @@ -957,7 +957,7 @@ public function testMethodsThatNeedARunningProcess($method) $process->{$method}(); } - public function provideMethodsThatNeedARunningProcess() + public static function provideMethodsThatNeedARunningProcess() { return [ ['getOutput'], @@ -988,7 +988,7 @@ public function testMethodsThatNeedATerminatedProcess($method) throw $e; } - public function provideMethodsThatNeedATerminatedProcess() + public static function provideMethodsThatNeedATerminatedProcess() { return [ ['hasBeenSignaled'], @@ -1093,7 +1093,7 @@ public function testGetOutputWhileDisabled($fetchMethod) $p->{$fetchMethod}(); } - public function provideOutputFetchingMethods() + public static function provideOutputFetchingMethods() { return [ ['getOutput'], @@ -1130,7 +1130,7 @@ public function testTermSignalTerminatesProcessCleanly() $this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException'); } - public function responsesCodeProvider() + public static function responsesCodeProvider() { return [ // expected output / getter / code to execute @@ -1140,7 +1140,7 @@ public function responsesCodeProvider() ]; } - public function pipesCodeProvider() + public static function pipesCodeProvider() { $variations = [ 'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);', @@ -1183,7 +1183,7 @@ public function testIncrementalOutputDoesNotRequireAnotherCall($stream, $method) $process->stop(); } - public function provideVariousIncrementals() + public static function provideVariousIncrementals() { return [ ['php://stdout', 'getIncrementalOutput'], @@ -1449,7 +1449,7 @@ public function testRawCommandLine() $this->assertSame($expected, str_replace('Standard input code', '-', $p->getOutput())); } - public function provideEscapeArgument() + public static function provideEscapeArgument() { yield ['a"b%c%']; yield ['a"b^c^']; diff --git a/src/Symfony/Component/PropertyAccess/LICENSE b/src/Symfony/Component/PropertyAccess/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/PropertyAccess/LICENSE +++ b/src/Symfony/Component/PropertyAccess/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTestCase.php similarity index 74% rename from src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php rename to src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTestCase.php index 98d6eb57d5936..b1b3f63d1c30e 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTestCase.php @@ -16,7 +16,7 @@ use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccessor; -abstract class PropertyAccessorArrayAccessTest extends TestCase +abstract class PropertyAccessorArrayAccessTestCase extends TestCase { /** * @var PropertyAccessor @@ -28,21 +28,21 @@ protected function setUp(): void $this->propertyAccessor = new PropertyAccessor(); } - abstract protected function getContainer(array $array); + abstract protected static function getContainer(array $array); - public function getValidPropertyPaths() + public static function getValidPropertyPaths(): array { return [ - [$this->getContainer(['firstName' => 'Bernhard']), '[firstName]', 'Bernhard'], - [$this->getContainer(['person' => $this->getContainer(['firstName' => 'Bernhard'])]), '[person][firstName]', 'Bernhard'], + [static::getContainer(['firstName' => 'Bernhard']), '[firstName]', 'Bernhard'], + [static::getContainer(['person' => static::getContainer(['firstName' => 'Bernhard'])]), '[person][firstName]', 'Bernhard'], ]; } - public function getInvalidPropertyPaths() + public static function getInvalidPropertyPaths(): array { return [ - [$this->getContainer(['firstName' => 'Bernhard']), 'firstName', 'Bernhard'], - [$this->getContainer(['person' => $this->getContainer(['firstName' => 'Bernhard'])]), 'person.firstName', 'Bernhard'], + [static::getContainer(['firstName' => 'Bernhard']), 'firstName', 'Bernhard'], + [static::getContainer(['person' => static::getContainer(['firstName' => 'Bernhard'])]), 'person.firstName', 'Bernhard'], ]; } @@ -61,7 +61,7 @@ public function testGetValueFailsIfNoSuchIndex() ->enableExceptionOnInvalidIndex() ->getPropertyAccessor(); - $object = $this->getContainer(['firstName' => 'Bernhard']); + $object = static::getContainer(['firstName' => 'Bernhard']); $this->propertyAccessor->getValue($object, '[lastName]'); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayObjectTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayObjectTest.php index fb0b383789ba5..9d836561d577b 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayObjectTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayObjectTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\PropertyAccess\Tests; -class PropertyAccessorArrayObjectTest extends PropertyAccessorCollectionTest +class PropertyAccessorArrayObjectTest extends PropertyAccessorCollectionTestCase { - protected function getContainer(array $array) + protected static function getContainer(array $array) { return new \ArrayObject($array); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayTest.php index c982826344cec..304b823ebf127 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\PropertyAccess\Tests; -class PropertyAccessorArrayTest extends PropertyAccessorCollectionTest +class PropertyAccessorArrayTest extends PropertyAccessorCollectionTestCase { - protected function getContainer(array $array) + protected static function getContainer(array $array) { return $array; } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTestCase.php similarity index 82% rename from src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php rename to src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTestCase.php index 2daf260fd8014..016d69422a2b4 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTestCase.php @@ -13,7 +13,7 @@ use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; -class PropertyAccessorCollectionTest_Car +class PropertyAccessorCollectionTestCase_Car { private $axes; @@ -45,7 +45,7 @@ public function getAxes() } } -class PropertyAccessorCollectionTest_CarOnlyAdder +class PropertyAccessorCollectionTestCase_CarOnlyAdder { public function addAxis($axis) { @@ -56,7 +56,7 @@ public function getAxes() } } -class PropertyAccessorCollectionTest_CarOnlyRemover +class PropertyAccessorCollectionTestCase_CarOnlyRemover { public function removeAxis($axis) { @@ -67,14 +67,14 @@ public function getAxes() } } -class PropertyAccessorCollectionTest_CarNoAdderAndRemover +class PropertyAccessorCollectionTestCase_CarNoAdderAndRemover { public function getAxes() { } } -class PropertyAccessorCollectionTest_CompositeCar +class PropertyAccessorCollectionTestCase_CompositeCar { public function getStructure() { @@ -85,7 +85,7 @@ public function setStructure($structure) } } -class PropertyAccessorCollectionTest_CarStructure +class PropertyAccessorCollectionTestCase_CarStructure { public function addAxis($axis) { @@ -100,7 +100,7 @@ public function getAxes() } } -abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAccessTest +abstract class PropertyAccessorCollectionTestCase extends PropertyAccessorArrayAccessTestCase { public function testSetValueCallsAdderAndRemoverForCollections() { @@ -111,7 +111,7 @@ public function testSetValueCallsAdderAndRemoverForCollections() // Don't use a mock in order to test whether the collections are // modified while iterating them - $car = new PropertyAccessorCollectionTest_Car($axesBefore); + $car = new PropertyAccessorCollectionTestCase_Car($axesBefore); $this->propertyAccessor->setValue($car, 'axes', $axesMerged); @@ -151,7 +151,7 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections() public function testSetValueFailsIfNoAdderNorRemoverFound() { $this->expectException(NoSuchPropertyException::class); - $this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./'); + $this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTestCase_CarNoAdderAndRemover_[^"]*"./'); $car = $this->createMock(__CLASS__.'_CarNoAdderAndRemover'); $axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']); $axesAfter = $this->getContainer([0 => 'first', 1 => 'second', 2 => 'third']); @@ -165,33 +165,33 @@ public function testSetValueFailsIfNoAdderNorRemoverFound() public function testIsWritableReturnsTrueIfAdderAndRemoverExists() { - $car = new PropertyAccessorCollectionTest_Car(); + $car = new PropertyAccessorCollectionTestCase_Car(); $this->assertTrue($this->propertyAccessor->isWritable($car, 'axes')); } public function testIsWritableReturnsFalseIfOnlyAdderExists() { - $car = new PropertyAccessorCollectionTest_CarOnlyAdder(); + $car = new PropertyAccessorCollectionTestCase_CarOnlyAdder(); $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes')); } public function testIsWritableReturnsFalseIfOnlyRemoverExists() { - $car = new PropertyAccessorCollectionTest_CarOnlyRemover(); + $car = new PropertyAccessorCollectionTestCase_CarOnlyRemover(); $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes')); } public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists() { - $car = new PropertyAccessorCollectionTest_CarNoAdderAndRemover(); + $car = new PropertyAccessorCollectionTestCase_CarNoAdderAndRemover(); $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes')); } public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable() { $this->expectException(NoSuchPropertyException::class); - $this->expectExceptionMessageMatches('/The property "axes" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\PropertyAccessorCollectionTest_Car" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\\Traversable\./'); - $car = new PropertyAccessorCollectionTest_Car(); + $this->expectExceptionMessageMatches('/The property "axes" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\PropertyAccessorCollectionTestCase_Car" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\\Traversable\./'); + $car = new PropertyAccessorCollectionTestCase_Car(); $this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable'); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorNonTraversableArrayObjectTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorNonTraversableArrayObjectTest.php index 6910d8be7031b..5c01079e13a77 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorNonTraversableArrayObjectTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorNonTraversableArrayObjectTest.php @@ -13,9 +13,9 @@ use Symfony\Component\PropertyAccess\Tests\Fixtures\NonTraversableArrayObject; -class PropertyAccessorNonTraversableArrayObjectTest extends PropertyAccessorArrayAccessTest +class PropertyAccessorNonTraversableArrayObjectTest extends PropertyAccessorArrayAccessTestCase { - protected function getContainer(array $array) + protected static function getContainer(array $array) { return new NonTraversableArrayObject($array); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 46ecfcca07bc0..5f1b51e5399fd 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -55,7 +55,7 @@ protected function setUp(): void $this->propertyAccessor = new PropertyAccessor(); } - public function getPathsWithUnexpectedType() + public static function getPathsWithUnexpectedType() { return [ ['', 'foobar'], @@ -69,7 +69,7 @@ public function getPathsWithUnexpectedType() ]; } - public function getPathsWithMissingProperty() + public static function getPathsWithMissingProperty() { return [ [(object) ['firstName' => 'Bernhard'], 'lastName'], @@ -89,7 +89,7 @@ public function getPathsWithMissingProperty() ]; } - public function getPathsWithMissingIndex() + public static function getPathsWithMissingIndex() { return [ [['firstName' => 'Bernhard'], '[lastName]'], @@ -129,6 +129,7 @@ public function testGetValueReturnsNullIfPropertyNotFoundAndExceptionIsDisabled( /** * @group legacy + * * @dataProvider getPathsWithMissingProperty */ public function testGetValueReturnsNullIfPropertyNotFoundAndExceptionIsDisabledUsingBooleanArgument($objectOrArray, $path) @@ -160,6 +161,7 @@ public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnab /** * @group legacy + * * @dataProvider getPathsWithMissingIndex */ public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabledUsingBooleanArgument($objectOrArray, $path) @@ -357,6 +359,7 @@ public function testGetValueDoesNotReadMagicCallByDefault() /** * @group legacy + * * @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer). */ public function testLegacyGetValueReadsMagicCallIfEnabled() @@ -476,6 +479,7 @@ public function testSetValueDoesNotUpdateMagicCallByDefault() /** * @group legacy + * * @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer). */ public function testLegacySetValueUpdatesMagicCallIfEnabled() @@ -564,6 +568,7 @@ public function testIsReadableDoesNotRecognizeMagicCallByDefault() /** * @group legacy + * * @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer). */ public function testLegacyIsReadableRecognizesMagicCallIfEnabled() @@ -636,6 +641,7 @@ public function testIsWritableDoesNotRecognizeMagicCallByDefault() /** * @group legacy + * * @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer). */ public function testLegacyIsWritableRecognizesMagicCallIfEnabled() @@ -660,7 +666,7 @@ public function testIsWritableReturnsFalseIfNotObjectOrArray($objectOrArray, $pa $this->assertFalse($this->propertyAccessor->isWritable($objectOrArray, $path)); } - public function getValidPropertyPaths() + public static function getValidPropertyPaths() { return [ [['Bernhard', 'Schussek'], '[0]', 'Bernhard'], @@ -723,7 +729,7 @@ public function testSetValueDeepWithMagicGetter() $this->assertSame('Updated', $obj->publicProperty['foo']['bar']); } - public function getReferenceChainObjectsForSetValue() + public static function getReferenceChainObjectsForSetValue() { return [ [['a' => ['b' => ['c' => 'old-value']]], '[a][b][c]', 'new-value'], @@ -744,7 +750,7 @@ public function testSetValueForReferenceChainIssue($object, $path, $value) $this->assertEquals($value, $this->propertyAccessor->getValue($object, $path)); } - public function getReferenceChainObjectsForIsWritable() + public static function getReferenceChainObjectsForIsWritable() { return [ [new TestClassIsWritable(['a' => ['b' => 'old-value']]), 'value[a][b]', false], diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTraversableArrayObjectTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTraversableArrayObjectTest.php index 4e45001176d03..bfd52fab05671 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTraversableArrayObjectTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTraversableArrayObjectTest.php @@ -13,9 +13,9 @@ use Symfony\Component\PropertyAccess\Tests\Fixtures\TraversableArrayObject; -class PropertyAccessorTraversableArrayObjectTest extends PropertyAccessorCollectionTest +class PropertyAccessorTraversableArrayObjectTest extends PropertyAccessorCollectionTestCase { - protected function getContainer(array $array) + protected static function getContainer(array $array) { return new TraversableArrayObject($array); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php index e26ed62e7e498..5f4671294ee74 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php @@ -194,7 +194,7 @@ public function testReplaceDoesNotAllowInvalidOffsets($offset) $this->builder->replace($offset, 1, new PropertyPath('new1[new2].new3')); } - public function provideInvalidOffsets() + public static function provideInvalidOffsets() { return [ [6], diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php index 87967373e38ff..88464d23b0834 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php @@ -37,7 +37,7 @@ public function testDotCannotBePresentAtTheBeginning() new PropertyPath('.property'); } - public function providePathsContainingUnexpectedCharacters() + public static function providePathsContainingUnexpectedCharacters() { return [ ['property.'], diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index ef1967b671a4e..2cecfcf8b3306 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -60,7 +60,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null) { if (!class_exists(DocBlockFactory::class)) { - throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed.', __CLASS__)); + throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', __CLASS__)); } $this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance(); diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php index f833731aa6dee..52a43d16aee46 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php @@ -11,6 +11,7 @@ namespace Symfony\Component\PropertyInfo\Extractor; +use phpDocumentor\Reflection\Types\ContextFactory; use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; @@ -59,6 +60,14 @@ final class PhpStanExtractor implements PropertyTypeExtractorInterface, Construc */ public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null) { + if (!class_exists(ContextFactory::class)) { + throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/type-resolver" package is not installed. Try running composer require "phpdocumentor/type-resolver".', __CLASS__)); + } + + if (!class_exists(PhpDocParser::class)) { + throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpstan/phpdoc-parser" package is not installed. Try running composer require "phpstan/phpdoc-parser".', __CLASS__)); + } + $this->phpStanTypeHelper = new PhpStanTypeHelper(); $this->mutatorPrefixes = $mutatorPrefixes ?? ReflectionExtractor::$defaultMutatorPrefixes; $this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes; diff --git a/src/Symfony/Component/PropertyInfo/LICENSE b/src/Symfony/Component/PropertyInfo/LICENSE index 63af57a7115e5..6e3afce692a76 100644 --- a/src/Symfony/Component/PropertyInfo/LICENSE +++ b/src/Symfony/Component/PropertyInfo/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2023 Fabien Potencier +Copyright (c) 2015-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/PropertyInfo/Tests/DependencyInjection/PropertyInfoPassTest.php b/src/Symfony/Component/PropertyInfo/Tests/DependencyInjection/PropertyInfoPassTest.php index aea826e210065..a1db4822e045c 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/DependencyInjection/PropertyInfoPassTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/DependencyInjection/PropertyInfoPassTest.php @@ -42,7 +42,7 @@ public function testServicesAreOrderedAccordingToPriority($index, $tag) $this->assertEquals($expected, $definition->getArgument($index)); } - public function provideTags() + public static function provideTags() { return [ [0, 'property_info.list_extractor'], diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php index f053832f0124c..c6a02b5f2f3e4 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php @@ -53,7 +53,7 @@ public function testParamTagTypeIsOmitted() $this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType')); } - public function invalidTypesProvider() + public static function invalidTypesProvider() { return [ 'pub' => ['pub', null, null], @@ -83,7 +83,7 @@ public function testExtractTypesWithNoPrefixes($property, array $type = null) $this->assertEquals($type, $noPrefixExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property)); } - public function typesProvider() + public static function typesProvider() { return [ ['foo', null, 'Short description.', 'Long description.'], @@ -166,7 +166,7 @@ public function testExtractCollection($property, array $type = null, $shortDescr $this->testExtract($property, $type, $shortDescription, $longDescription); } - public function provideCollectionTypes() + public static function provideCollectionTypes() { return [ ['iteratorCollection', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Iterator', true, null, new Type(Type::BUILTIN_TYPE_STRING))], null, null], @@ -230,7 +230,7 @@ public function testExtractTypesWithCustomPrefixes($property, array $type = null $this->assertEquals($type, $customExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property)); } - public function typesWithCustomPrefixesProvider() + public static function typesWithCustomPrefixesProvider() { return [ ['foo', null, 'Short description.', 'Long description.'], @@ -271,7 +271,7 @@ public function typesWithCustomPrefixesProvider() ]; } - public function typesWithNoPrefixesProvider() + public static function typesWithNoPrefixesProvider() { return [ ['foo', null, 'Short description.', 'Long description.'], @@ -317,7 +317,7 @@ public function testReturnNullOnEmptyDocBlock() $this->assertNull($this->extractor->getShortDescription(EmptyDocBlock::class, 'foo')); } - public function dockBlockFallbackTypesProvider() + public static function dockBlockFallbackTypesProvider() { return [ 'pub' => [ @@ -348,7 +348,7 @@ public function testPropertiesDefinedByTraits(string $property, Type $type) $this->assertEquals([$type], $this->extractor->getTypes(DummyUsingTrait::class, $property)); } - public function propertiesDefinedByTraitsProvider(): array + public static function propertiesDefinedByTraitsProvider(): array { return [ ['propertyInTraitPrimitiveType', new Type(Type::BUILTIN_TYPE_STRING)], @@ -368,7 +368,7 @@ public function testMethodsDefinedByTraits(string $property, Type $type) $this->assertEquals([$type], $this->extractor->getTypes(DummyUsingTrait::class, $property)); } - public function methodsDefinedByTraitsProvider(): array + public static function methodsDefinedByTraitsProvider(): array { return [ ['methodInTraitPrimitiveType', new Type(Type::BUILTIN_TYPE_STRING)], @@ -388,7 +388,7 @@ public function testPropertiesStaticType(string $class, string $property, Type $ $this->assertEquals([$type], $this->extractor->getTypes($class, $property)); } - public function propertiesStaticTypeProvider(): array + public static function propertiesStaticTypeProvider(): array { return [ [ParentDummy::class, 'propertyTypeStatic', new Type(Type::BUILTIN_TYPE_OBJECT, false, ParentDummy::class)], @@ -404,7 +404,7 @@ public function testPropertiesParentType(string $class, string $property, ?array $this->assertEquals($types, $this->extractor->getTypes($class, $property)); } - public function propertiesParentTypeProvider(): array + public static function propertiesParentTypeProvider(): array { return [ [ParentDummy::class, 'parentAnnotationNoParent', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'parent')]], @@ -435,7 +435,7 @@ public function testExtractConstructorTypes($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property)); } - public function constructorTypesProvider() + public static function constructorTypesProvider() { return [ ['date', [new Type(Type::BUILTIN_TYPE_INT)]], diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php index 467c076e2575e..a517e7ac30469 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php @@ -58,7 +58,7 @@ public function testParamTagTypeIsOmitted() $this->assertNull($this->extractor->getTypes(PhpStanOmittedParamTagTypeDocBlock::class, 'omittedType')); } - public function invalidTypesProvider() + public static function invalidTypesProvider() { return [ 'pub' => ['pub'], @@ -86,7 +86,7 @@ public function testExtractTypesWithNoPrefixes($property, array $type = null) $this->assertEquals($type, $noPrefixExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property)); } - public function typesProvider() + public static function typesProvider() { return [ ['foo', null], @@ -139,7 +139,7 @@ public function testExtractCollection($property, array $type = null) $this->testExtract($property, $type); } - public function provideCollectionTypes() + public static function provideCollectionTypes() { return [ ['iteratorCollection', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Iterator', true, null, new Type(Type::BUILTIN_TYPE_STRING))]], @@ -197,7 +197,7 @@ public function testExtractTypesWithCustomPrefixes($property, array $type = null $this->assertEquals($type, $customExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property)); } - public function typesWithCustomPrefixesProvider() + public static function typesWithCustomPrefixesProvider() { return [ ['foo', null], @@ -235,7 +235,7 @@ public function typesWithCustomPrefixesProvider() ]; } - public function typesWithNoPrefixesProvider() + public static function typesWithNoPrefixesProvider() { return [ ['foo', null], @@ -273,7 +273,7 @@ public function typesWithNoPrefixesProvider() ]; } - public function dockBlockFallbackTypesProvider() + public static function dockBlockFallbackTypesProvider() { return [ 'pub' => [ @@ -304,7 +304,7 @@ public function testPropertiesDefinedByTraits(string $property, Type $type) $this->assertEquals([$type], $this->extractor->getTypes(DummyUsingTrait::class, $property)); } - public function propertiesDefinedByTraitsProvider(): array + public static function propertiesDefinedByTraitsProvider(): array { return [ ['propertyInTraitPrimitiveType', new Type(Type::BUILTIN_TYPE_STRING)], @@ -321,7 +321,7 @@ public function testPropertiesStaticType(string $class, string $property, Type $ $this->assertEquals([$type], $this->extractor->getTypes($class, $property)); } - public function propertiesStaticTypeProvider(): array + public static function propertiesStaticTypeProvider(): array { return [ [ParentDummy::class, 'propertyTypeStatic', new Type(Type::BUILTIN_TYPE_OBJECT, false, ParentDummy::class)], @@ -337,7 +337,7 @@ public function testPropertiesParentType(string $class, string $property, ?array $this->assertEquals($types, $this->extractor->getTypes($class, $property)); } - public function propertiesParentTypeProvider(): array + public static function propertiesParentTypeProvider(): array { return [ [ParentDummy::class, 'parentAnnotationNoParent', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'parent')]], @@ -353,7 +353,7 @@ public function testExtractConstructorTypes($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property)); } - public function constructorTypesProvider() + public static function constructorTypesProvider() { return [ ['date', [new Type(Type::BUILTIN_TYPE_INT)]], @@ -372,7 +372,7 @@ public function testExtractorUnionTypes(string $property, ?array $types) $this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DummyUnionType', $property)); } - public function unionTypesProvider(): array + public static function unionTypesProvider(): array { return [ ['a', [new Type(Type::BUILTIN_TYPE_STRING), new Type(Type::BUILTIN_TYPE_INT)]], @@ -410,7 +410,7 @@ public function testExtractorIntRangeType(string $property, ?array $types) $this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\IntRangeDummy', $property)); } - public function intRangeTypeProvider(): array + public static function intRangeTypeProvider(): array { return [ ['a', [new Type(Type::BUILTIN_TYPE_INT)]], diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php index e17e203c1523c..b7955584d8c36 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php @@ -207,7 +207,7 @@ public function testExtractors($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, [])); } - public function typesProvider() + public static function typesProvider() { return [ ['a', null], @@ -234,7 +234,7 @@ public function testExtractPhp7Type(string $class, string $property, array $type $this->assertEquals($type, $this->extractor->getTypes($class, $property, [])); } - public function php7TypesProvider() + public static function php7TypesProvider() { return [ [Php7Dummy::class, 'foo', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]], @@ -255,7 +255,7 @@ public function testExtractPhp71Type($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php71Dummy', $property, [])); } - public function php71TypesProvider() + public static function php71TypesProvider() { return [ ['foo', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]], @@ -276,7 +276,7 @@ public function testExtractPhp80Type($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy', $property, [])); } - public function php80TypesProvider() + public static function php80TypesProvider() { return [ ['foo', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]], @@ -300,7 +300,7 @@ public function testExtractPhp81Type($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php81Dummy', $property, [])); } - public function php81TypesProvider() + public static function php81TypesProvider() { return [ ['nothing', null], @@ -326,7 +326,7 @@ public function testExtractPhp82Type($property, array $type = null) $this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php82Dummy', $property, [])); } - public function php82TypesProvider(): iterable + public static function php82TypesProvider(): iterable { yield ['nil', null]; yield ['false', [new Type(Type::BUILTIN_TYPE_FALSE)]]; @@ -344,7 +344,7 @@ public function testExtractWithDefaultValue($property, $type) $this->assertEquals($type, $this->extractor->getTypes(DefaultValue::class, $property, [])); } - public function defaultValueProvider() + public static function defaultValueProvider() { return [ ['defaultInt', [new Type(Type::BUILTIN_TYPE_INT, false)]], @@ -366,7 +366,7 @@ public function testIsReadable($property, $expected) ); } - public function getReadableProperties() + public static function getReadableProperties() { return [ ['bar', false], @@ -397,7 +397,7 @@ public function testIsWritable($property, $expected) ); } - public function getWritableProperties() + public static function getWritableProperties() { return [ ['bar', false], @@ -451,7 +451,7 @@ public function testIsInitializable(string $class, string $property, bool $expec $this->assertSame($expected, $this->extractor->isInitializable($class, $property)); } - public function getInitializableProperties(): array + public static function getInitializableProperties(): array { return [ [Php71Dummy::class, 'string', true], @@ -475,7 +475,7 @@ public function testExtractTypeConstructor(string $class, string $property, arra $this->assertNull($this->extractor->getTypes($class, $property, ['enable_constructor_extraction' => false])); } - public function constructorTypesProvider(): array + public static function constructorTypesProvider(): array { return [ // php71 dummy has following constructor: __construct(string $string, int $intPrivate) @@ -534,7 +534,7 @@ public function testGetReadAccessor($class, $property, $found, $type, $name, $vi $this->assertSame($static, $readAcessor->isStatic()); } - public function readAccessorProvider(): array + public static function readAccessorProvider(): array { return [ [Dummy::class, 'bar', true, PropertyReadInfo::TYPE_PROPERTY, 'bar', PropertyReadInfo::VISIBILITY_PRIVATE, false], @@ -592,7 +592,7 @@ public function testGetWriteMutator($class, $property, $allowConstruct, $found, } } - public function writeMutatorProvider(): array + public static function writeMutatorProvider(): array { return [ [Dummy::class, 'bar', false, true, PropertyWriteInfo::TYPE_PROPERTY, 'bar', null, null, PropertyWriteInfo::VISIBILITY_PRIVATE, false], @@ -650,7 +650,7 @@ public function testExtractConstructorTypes(string $property, array $type = null $this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property)); } - public function extractConstructorTypesProvider(): array + public static function extractConstructorTypesProvider(): array { return [ ['timezone', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeZone')]], diff --git a/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php b/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php index c4a2edb174900..2c858c3bf9f8b 100644 --- a/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php +++ b/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php @@ -173,7 +173,7 @@ private function normalizeType(string $docType): string case 'boolean': return 'bool'; - // real is not part of the PHPDoc standard, so we ignore it + // real is not part of the PHPDoc standard, so we ignore it case 'double': return 'float'; diff --git a/src/Symfony/Component/RateLimiter/LICENSE b/src/Symfony/Component/RateLimiter/LICENSE index f2345234aa9ea..0223acd4a01f4 100644 --- a/src/Symfony/Component/RateLimiter/LICENSE +++ b/src/Symfony/Component/RateLimiter/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2023 Fabien Potencier +Copyright (c) 2016-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/RateLimiter/LimiterInterface.php b/src/Symfony/Component/RateLimiter/LimiterInterface.php index 4c5ff397c0104..6f0ae7db0678f 100644 --- a/src/Symfony/Component/RateLimiter/LimiterInterface.php +++ b/src/Symfony/Component/RateLimiter/LimiterInterface.php @@ -26,8 +26,8 @@ interface LimiterInterface * future token consumptions. Do not use this method if you intend * to skip this process. * - * @param int $tokens the number of tokens required - * @param float $maxTime maximum accepted waiting time in seconds + * @param int $tokens the number of tokens required + * @param float|null $maxTime maximum accepted waiting time in seconds * * @throws MaxWaitDurationExceededException if $maxTime is set and the process needs to wait longer than its value (in seconds) * @throws ReserveNotSupportedException if this limiter implementation doesn't support reserving tokens diff --git a/src/Symfony/Component/RateLimiter/Policy/TokenBucketLimiter.php b/src/Symfony/Component/RateLimiter/Policy/TokenBucketLimiter.php index 99818c6e2e749..e3948761f2ac5 100644 --- a/src/Symfony/Component/RateLimiter/Policy/TokenBucketLimiter.php +++ b/src/Symfony/Component/RateLimiter/Policy/TokenBucketLimiter.php @@ -45,8 +45,8 @@ public function __construct(string $id, int $maxBurst, Rate $rate, StorageInterf * future token consumptions. Do not use this method if you intend * to skip this process. * - * @param int $tokens the number of tokens required - * @param float $maxTime maximum accepted waiting time in seconds + * @param int $tokens the number of tokens required + * @param float|null $maxTime maximum accepted waiting time in seconds * * @throws MaxWaitDurationExceededException if $maxTime is set and the process needs to wait longer than its value (in seconds) * @throws \InvalidArgumentException if $tokens is larger than the maximum burst size diff --git a/src/Symfony/Component/RateLimiter/Tests/Policy/FixedWindowLimiterTest.php b/src/Symfony/Component/RateLimiter/Tests/Policy/FixedWindowLimiterTest.php index a9f9960c4b547..0cffc14e1aee6 100644 --- a/src/Symfony/Component/RateLimiter/Tests/Policy/FixedWindowLimiterTest.php +++ b/src/Symfony/Component/RateLimiter/Tests/Policy/FixedWindowLimiterTest.php @@ -108,7 +108,7 @@ public function testWindowResilientToTimeShifting() $this->assertSame(100, $window->getAvailableTokens($serverOneClock)); } - public function provideConsumeOutsideInterval(): \Generator + public static function provideConsumeOutsideInterval(): \Generator { yield ['PT15S']; diff --git a/src/Symfony/Component/RateLimiter/Tests/Policy/RateTest.php b/src/Symfony/Component/RateLimiter/Tests/Policy/RateTest.php index a780d34fdb82f..f5dc600696007 100644 --- a/src/Symfony/Component/RateLimiter/Tests/Policy/RateTest.php +++ b/src/Symfony/Component/RateLimiter/Tests/Policy/RateTest.php @@ -24,7 +24,7 @@ public function testFromString(Rate $rate) $this->assertEquals($rate, Rate::fromString((string) $rate)); } - public function provideRate(): iterable + public static function provideRate(): iterable { yield [new Rate(new \DateInterval('PT15S'), 10)]; yield [Rate::perSecond(10)]; diff --git a/src/Symfony/Component/RateLimiter/Tests/RateLimiterFactoryTest.php b/src/Symfony/Component/RateLimiter/Tests/RateLimiterFactoryTest.php index 7d7627809238e..5ac5963a2a1cb 100644 --- a/src/Symfony/Component/RateLimiter/Tests/RateLimiterFactoryTest.php +++ b/src/Symfony/Component/RateLimiter/Tests/RateLimiterFactoryTest.php @@ -32,7 +32,7 @@ public function testValidConfig(string $expectedClass, array $config) $this->assertInstanceOf($expectedClass, $rateLimiter); } - public function validConfigProvider() + public static function validConfigProvider() { yield [TokenBucketLimiter::class, [ 'policy' => 'token_bucket', @@ -70,7 +70,7 @@ public function testInvalidConfig(string $exceptionClass, array $config) $factory->create('key'); } - public function invalidConfigProvider() + public static function invalidConfigProvider() { yield [MissingOptionsException::class, [ 'policy' => 'token_bucket', diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index acf3ead4fccb9..d27b000045c16 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -162,11 +162,11 @@ public function generate(string $name, array $parameters = [], int $referenceTyp } /** + * @return string + * * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement - * - * @return string */ protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = []) { diff --git a/src/Symfony/Component/Routing/LICENSE b/src/Symfony/Component/Routing/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Routing/LICENSE +++ b/src/Symfony/Component/Routing/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index e249aa5da8903..cde5f6203898a 100644 --- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -42,7 +42,7 @@ private function getMethodAnnotation(string $method, bool $attributes): Route return $route; } - public function provideDeprecationArrayAsFirstArgument() + public static function provideDeprecationArrayAsFirstArgument() { return [ ['requirements', ['locale' => 'en'], 'getRequirements'], @@ -60,6 +60,7 @@ public function provideDeprecationArrayAsFirstArgument() /** * @group legacy + * * @dataProvider provideDeprecationArrayAsFirstArgument */ public function testDeprecationArrayAsFirstArgument(string $parameter, $value, string $getter) @@ -72,6 +73,7 @@ public function testDeprecationArrayAsFirstArgument(string $parameter, $value, s /** * @requires PHP 8 + * * @dataProvider getValidParameters */ public function testLoadFromAttribute(string $methodName, string $getter, $expectedReturn) @@ -89,7 +91,7 @@ public function testLoadFromDoctrineAnnotation(string $methodName, string $gette $this->assertEquals($route->$getter(), $expectedReturn); } - public function getValidParameters(): iterable + public static function getValidParameters(): iterable { return [ ['simplePath', 'getPath', '/Blog'], diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 71501d2a1e896..f2062e8e6fec2 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -130,7 +130,7 @@ public function testAbsoluteUrlWithExtraParameters(string $expectedQueryString, $this->assertSame('http://localhost/app.php/testing'.$expectedQueryString, $url); } - public function valuesProvider(): array + public static function valuesProvider(): array { $stdClass = new \stdClass(); $stdClass->baz = 'bar'; @@ -862,7 +862,7 @@ public function testGetRelativePath($sourcePath, $targetPath, $expectedPath) $this->assertSame($expectedPath, UrlGenerator::getRelativePath($sourcePath, $targetPath)); } - public function provideRelativePaths() + public static function provideRelativePaths() { return [ [ @@ -1004,7 +1004,7 @@ public function testLookRoundRequirementsInPath($expected, $path, $requirement) $this->assertSame($expected, $this->getGenerator($routes)->generate('test', ['foo' => 'a/b', 'baz' => 'c/d/e'])); } - public function provideLookAroundRequirementsInPath() + public static function provideLookAroundRequirementsInPath() { yield ['/app.php/a/b/b%28ar/c/d/e', '/{foo}/b(ar/{baz}', '.+(?=/b\\(ar/)']; yield ['/app.php/a/b/bar/c/d/e', '/{foo}/bar/{baz}', '.+(?!$)']; diff --git a/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTestCase.php similarity index 92% rename from src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php rename to src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTestCase.php index fea06e51dcdc0..e743ef2e35d50 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTestCase.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Routing\Loader\AnnotationClassLoader; -abstract class AbstractAnnotationLoaderTest extends TestCase +abstract class AbstractAnnotationLoaderTestCase extends TestCase { public function getReader() { diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTestCase.php similarity index 98% rename from src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php rename to src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTestCase.php index fdac1aea8bc01..e10e9993a6a3e 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTestCase.php @@ -15,7 +15,7 @@ use Symfony\Component\Routing\Loader\AnnotationClassLoader; use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\AbstractClassController; -abstract class AnnotationClassLoaderTest extends TestCase +abstract class AnnotationClassLoaderTestCase extends TestCase { /** * @var AnnotationClassLoader @@ -30,7 +30,7 @@ public function testSupportsChecksResource($resource, $expectedSupports) $this->assertSame($expectedSupports, $this->loader->supports($resource), '->supports() returns true if the resource is loadable'); } - public function provideTestSupportsChecksResource() + public static function provideTestSupportsChecksResource() { return [ ['class', true], diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAnnotationsTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAnnotationsTest.php index e2843a0a39843..1130204bf6887 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAnnotationsTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAnnotationsTest.php @@ -16,7 +16,7 @@ use Symfony\Component\Routing\Loader\AnnotationClassLoader; use Symfony\Component\Routing\Route; -class AnnotationClassLoaderWithAnnotationsTest extends AnnotationClassLoaderTest +class AnnotationClassLoaderWithAnnotationsTest extends AnnotationClassLoaderTestCase { protected function setUp(string $env = null): void { diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAttributesTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAttributesTest.php index 6879761737ddc..5ff377aa6b754 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAttributesTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderWithAttributesTest.php @@ -17,7 +17,7 @@ /** * @requires PHP 8 */ -class AnnotationClassLoaderWithAttributesTest extends AnnotationClassLoaderTest +class AnnotationClassLoaderWithAttributesTest extends AnnotationClassLoaderTestCase { protected function setUp(string $env = null): void { diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php index 858044d459f7e..559c22975c797 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader; -class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest +class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTestCase { protected $loader; protected $reader; diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index 0e1331bf8147a..9cc384304cb35 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Loader\AnnotationFileLoader; -class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest +class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTestCase { protected $loader; protected $reader; diff --git a/src/Symfony/Component/Routing/Tests/Loader/ContainerLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ContainerLoaderTest.php index 5f74111d1b092..6a3e4c516c6c4 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ContainerLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ContainerLoaderTest.php @@ -25,7 +25,7 @@ public function testSupports(bool $expected, string $type = null) $this->assertSame($expected, (new ContainerLoader(new Container()))->supports('foo', $type)); } - public function supportsProvider() + public static function supportsProvider() { return [ [true, 'service'], diff --git a/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php index 184d5089bc633..d4f2fd3263b48 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Routing\Loader\YamlFileLoader; use Symfony\Component\Routing\RouteCollection; -class DirectoryLoaderTest extends AbstractAnnotationLoaderTest +class DirectoryLoaderTest extends AbstractAnnotationLoaderTestCase { private $loader; private $reader; diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php index fcd679ead9e31..6027c3fd63059 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php @@ -50,7 +50,7 @@ public function testExceptionWithoutSyntax(string $resourceString) $loader->load($resourceString); } - public function getBadResourceStrings() + public static function getBadResourceStrings() { return [ ['Foo:Bar:baz'], diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 7637fd600aa92..ec7bd6ed516bd 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -230,7 +230,7 @@ public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidatio $loader->load($filePath); } - public function getPathsToInvalidFiles() + public static function getPathsToInvalidFiles() { return [ ['nonvalidnode.xml'], @@ -478,7 +478,7 @@ public function testImportRouteWithController($file) $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); } - public function provideFilesImportingRoutesWithControllers() + public static function provideFilesImportingRoutesWithControllers() { yield ['import_controller.xml']; yield ['import__controller.xml']; diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index b509ce36237c8..a81a6b2faced7 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -52,7 +52,7 @@ public function testLoadThrowsExceptionWithInvalidFile($filePath) $loader->load($filePath); } - public function getPathsToInvalidFiles() + public static function getPathsToInvalidFiles() { return [ ['nonvalid.yml'], @@ -171,7 +171,7 @@ public function testImportRouteWithController($file) $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); } - public function provideFilesImportingRoutesWithControllers() + public static function provideFilesImportingRoutesWithControllers() { yield ['import_controller.yml']; yield ['import__controller.yml']; diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php index 4886d717685c6..913456775a3f1 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php @@ -65,7 +65,7 @@ public function testDump(RouteCollection $collection, $fixture) $this->assertStringEqualsFile($basePath.$fixture, $dumper->dump()); } - public function getRouteCollections() + public static function getRouteCollections() { /* test case 1 */ diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php index d3f4c4f0d517f..86e0d0e3e1970 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php @@ -34,7 +34,7 @@ public function testGrouping(array $routes, $expected) $this->assertEquals($expected, $dumped); } - public function routeProvider() + public static function routeProvider() { return [ 'Simple - not nested' => [ diff --git a/src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageProviderTest.php b/src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageProviderTest.php index 0aa3549b26c60..2e431b7197f5e 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageProviderTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/ExpressionLanguageProviderTest.php @@ -59,7 +59,7 @@ public function testCompile(string $expression, string $expected) $this->assertSame($expected, $this->expressionLanguage->compile($expression)); } - public function compileProvider(): iterable + public static function compileProvider(): iterable { return [ ['env("APP_ENV")', '($context->getParameter(\'_functions\')->get(\'env\')("APP_ENV"))'], @@ -76,7 +76,7 @@ public function testEvaluate(string $expression, $expected) $this->assertSame($expected, $this->expressionLanguage->evaluate($expression, ['context' => $this->context])); } - public function evaluateProvider(): iterable + public static function evaluateProvider(): iterable { return [ ['env("APP_ENV")', 'test'], diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index ef0d73a66af78..682b0ccec4175 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -251,7 +251,7 @@ public function testFlushPrefixesPaths($collectionPrefix, $routePath, $expectedP $this->assertEquals($expectedPath, $collection->get('test_route')->getPath()); } - public function providePrefixTests() + public static function providePrefixTests() { $tests = []; // empty prefix is of course ok diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 6f5b91f5727c3..57f61c7e865f2 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -32,7 +32,7 @@ public function testCompile($name, $arguments, $prefix, $regex, $variables, $tok $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); } - public function provideCompileData() + public static function provideCompileData() { return [ [ @@ -199,7 +199,7 @@ public function testCompileImplicitUtf8Data($name, $arguments, $prefix, $regex, $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); } - public function provideCompileImplicitUtf8Data() + public static function provideCompileImplicitUtf8Data() { return [ [ @@ -284,7 +284,7 @@ public function testRouteWithVariableNameStartingWithADigit($name) $route->compile(); } - public function getVariableNamesStartingWithADigit() + public static function getVariableNamesStartingWithADigit() { return [ ['09'], @@ -312,7 +312,7 @@ public function testCompileWithHost($name, $arguments, $prefix, $regex, $variabl $this->assertEquals($hostTokens, $compiled->getHostTokens(), $name.' (host tokens)'); } - public function provideCompileWithHostData() + public static function provideCompileWithHostData() { return [ [ @@ -381,7 +381,7 @@ public function testRemoveCapturingGroup($regex, $requirement) $this->assertSame($regex, $route->compile()->getRegex()); } - public function provideRemoveCapturingGroup() + public static function provideRemoveCapturingGroup() { yield ['{^/(?Pa(?:b|c)(?:d|e)f)$}sD', 'a(b|c)(d|e)f']; yield ['{^/(?Pa\(b\)c)$}sD', 'a\(b\)c']; diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index 4be50d9a45203..4d7d9299ab72a 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -151,7 +151,7 @@ public function testSetInvalidRequirement($req) $route->setRequirement('foo', $req); } - public function getInvalidRequirements() + public static function getInvalidRequirements() { return [ [''], @@ -354,7 +354,7 @@ public function testLocaleRequirementWithLocalizedRoutes(Route $route) $this->assertSame($expected, $route->getRequirement('_locale')); } - public function provideNonLocalizedRoutes() + public static function provideNonLocalizedRoutes() { return [ [new Route('/foo')], @@ -364,7 +364,7 @@ public function provideNonLocalizedRoutes() ]; } - public function provideLocalizedRoutes() + public static function provideLocalizedRoutes() { return [ [(new Route('/foo'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'foo')->setRequirement('_locale', 'en')], diff --git a/src/Symfony/Component/Runtime/LICENSE b/src/Symfony/Component/Runtime/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Runtime/LICENSE +++ b/src/Symfony/Component/Runtime/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/NullToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/NullToken.php index 1b30d5a7ccda6..52187bb75b1be 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/NullToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/NullToken.php @@ -115,6 +115,7 @@ public function __unserialize(array $data): void * @return string * * @internal in 5.3 + * * @final in 5.3 */ public function serialize() @@ -126,6 +127,7 @@ public function serialize() * @return void * * @internal in 5.3 + * * @final in 5.3 */ public function unserialize($serialized) diff --git a/src/Symfony/Component/Security/Core/CHANGELOG.md b/src/Symfony/Component/Security/Core/CHANGELOG.md index 2ee6d1a20f68a..d466a99ed9e7a 100644 --- a/src/Symfony/Component/Security/Core/CHANGELOG.md +++ b/src/Symfony/Component/Security/Core/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.4.21 +------ + + * [BC BREAK] `AccessDecisionStrategyTestCase::provideStrategyTests()` is now static + 5.4 --- diff --git a/src/Symfony/Component/Security/Core/LICENSE b/src/Symfony/Component/Security/Core/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Security/Core/LICENSE +++ b/src/Symfony/Component/Security/Core/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php b/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php index a82bf61f404ec..d542588fe9ff6 100644 --- a/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php +++ b/src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php @@ -40,32 +40,41 @@ final public function testDecide(AccessDecisionStrategyInterface $strategy, arra /** * @return iterable */ - abstract public function provideStrategyTests(): iterable; + abstract public static function provideStrategyTests(): iterable; /** * @return VoterInterface[] */ - final protected function getVoters(int $grants, int $denies, int $abstains): array + final protected static function getVoters(int $grants, int $denies, int $abstains): array { $voters = []; for ($i = 0; $i < $grants; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_GRANTED); + $voters[] = static::getVoter(VoterInterface::ACCESS_GRANTED); } for ($i = 0; $i < $denies; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_DENIED); + $voters[] = static::getVoter(VoterInterface::ACCESS_DENIED); } for ($i = 0; $i < $abstains; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_ABSTAIN); + $voters[] = static::getVoter(VoterInterface::ACCESS_ABSTAIN); } return $voters; } - final protected function getVoter(int $vote): VoterInterface + final protected static function getVoter(int $vote): VoterInterface { - $voter = $this->createMock(VoterInterface::class); - $voter->method('vote')->willReturn($vote); + return new class($vote) implements VoterInterface { + private $vote; - return $voter; + public function __construct(int $vote) + { + $this->vote = $vote; + } + + public function vote(TokenInterface $token, $subject, array $attributes): int + { + return $this->vote; + } + }; } } 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 5bad9611dadef..79c5f2bc63de5 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -27,6 +27,7 @@ /** * @requires extension ldap + * * @group legacy */ class LdapBindAuthenticationProviderTest extends TestCase 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 a52eb4753490d..1c767e1d886f2 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -73,13 +73,14 @@ public function testGetUserIdentifier($user, string $username) $this->assertEquals($username, $token->getUserIdentifier()); } - public function provideUsers() + public static function provideUsers() { yield [new InMemoryUser('fabien', null), 'fabien']; } /** * @dataProvider provideLegacyUsers + * * @group legacy */ public function testLegacyGetUserIdentifier($user, string $username) @@ -89,7 +90,7 @@ public function testLegacyGetUserIdentifier($user, string $username) $this->assertEquals($username, $token->getUserIdentifier()); } - public function provideLegacyUsers() + public static function provideLegacyUsers() { return [ [new TestUser('fabien'), 'fabien'], @@ -174,6 +175,7 @@ public function testSetUser($user) /** * @group legacy + * * @dataProvider getUserChanges */ public function testSetUserSetsAuthenticatedToFalseWhenUserChanges($firstUser, $secondUser) @@ -189,9 +191,9 @@ public function testSetUserSetsAuthenticatedToFalseWhenUserChanges($firstUser, $ $this->assertFalse($token->isAuthenticated()); } - public function getUserChanges() + public static function getUserChanges() { - $user = $this->createMock(UserInterface::class); + $user = new DummyUser(); return [ ['foo', 'bar'], @@ -207,6 +209,7 @@ public function getUserChanges() /** * @group legacy + * * @dataProvider provideUsers * @dataProvider provideLegacyUsers */ @@ -322,6 +325,36 @@ public function __unserialize(array $data): void } } +class DummyUser implements UserInterface +{ + public function getRoles(): array + { + return []; + } + + public function getPassword(): ?string + { + return null; + } + + public function getSalt(): ?string + { + return null; + } + + public function eraseCredentials(): void + { + } + + public function getUsername(): string + { + } + + public function getUserIdentifier(): string + { + } +} + class ConcreteToken extends AbstractToken { private $credentials = 'credentials_value'; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php index 2cca853eb4e01..9ddea2bb3344a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -72,7 +72,7 @@ public function decide(\Traversable $results): bool $manager->decide($token, ['ROLE_FOO']); } - public function provideBadVoterResults(): array + public static function provideBadVoterResults(): array { return [ [3], @@ -116,62 +116,62 @@ public function decide(\Traversable $results): bool $this->assertTrue($manager->decide($token, ['ROLE_FOO'])); } - public function getStrategyTests() + public static function getStrategyTests(): array { return [ // affirmative - [AccessDecisionManager::STRATEGY_AFFIRMATIVE, $this->getVoters(1, 0, 0), false, true, true], - [AccessDecisionManager::STRATEGY_AFFIRMATIVE, $this->getVoters(1, 2, 0), false, true, true], - [AccessDecisionManager::STRATEGY_AFFIRMATIVE, $this->getVoters(0, 1, 0), false, true, false], - [AccessDecisionManager::STRATEGY_AFFIRMATIVE, $this->getVoters(0, 0, 1), false, true, false], - [AccessDecisionManager::STRATEGY_AFFIRMATIVE, $this->getVoters(0, 0, 1), true, true, true], + [AccessDecisionManager::STRATEGY_AFFIRMATIVE, self::getVoters(1, 0, 0), false, true, true], + [AccessDecisionManager::STRATEGY_AFFIRMATIVE, self::getVoters(1, 2, 0), false, true, true], + [AccessDecisionManager::STRATEGY_AFFIRMATIVE, self::getVoters(0, 1, 0), false, true, false], + [AccessDecisionManager::STRATEGY_AFFIRMATIVE, self::getVoters(0, 0, 1), false, true, false], + [AccessDecisionManager::STRATEGY_AFFIRMATIVE, self::getVoters(0, 0, 1), true, true, true], // consensus - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(1, 0, 0), false, true, true], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(1, 2, 0), false, true, false], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(2, 1, 0), false, true, true], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(1, 0, 0), false, true, true], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(1, 2, 0), false, true, false], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(2, 1, 0), false, true, true], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(0, 0, 1), false, true, false], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(0, 0, 1), false, true, false], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(0, 0, 1), true, true, true], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(0, 0, 1), true, true, true], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(2, 2, 0), false, true, true], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(2, 2, 1), false, true, true], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(2, 2, 0), false, true, true], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(2, 2, 1), false, true, true], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(2, 2, 0), false, false, false], - [AccessDecisionManager::STRATEGY_CONSENSUS, $this->getVoters(2, 2, 1), false, false, false], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(2, 2, 0), false, false, false], + [AccessDecisionManager::STRATEGY_CONSENSUS, self::getVoters(2, 2, 1), false, false, false], // unanimous - [AccessDecisionManager::STRATEGY_UNANIMOUS, $this->getVoters(1, 0, 0), false, true, true], - [AccessDecisionManager::STRATEGY_UNANIMOUS, $this->getVoters(1, 0, 1), false, true, true], - [AccessDecisionManager::STRATEGY_UNANIMOUS, $this->getVoters(1, 1, 0), false, true, false], + [AccessDecisionManager::STRATEGY_UNANIMOUS, self::getVoters(1, 0, 0), false, true, true], + [AccessDecisionManager::STRATEGY_UNANIMOUS, self::getVoters(1, 0, 1), false, true, true], + [AccessDecisionManager::STRATEGY_UNANIMOUS, self::getVoters(1, 1, 0), false, true, false], - [AccessDecisionManager::STRATEGY_UNANIMOUS, $this->getVoters(0, 0, 2), false, true, false], - [AccessDecisionManager::STRATEGY_UNANIMOUS, $this->getVoters(0, 0, 2), true, true, true], + [AccessDecisionManager::STRATEGY_UNANIMOUS, self::getVoters(0, 0, 2), false, true, false], + [AccessDecisionManager::STRATEGY_UNANIMOUS, self::getVoters(0, 0, 2), true, true, true], // priority [AccessDecisionManager::STRATEGY_PRIORITY, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_GRANTED), - $this->getVoter(VoterInterface::ACCESS_DENIED), - $this->getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_DENIED), ], true, true, true], [AccessDecisionManager::STRATEGY_PRIORITY, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_DENIED), - $this->getVoter(VoterInterface::ACCESS_GRANTED), - $this->getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_GRANTED), ], true, true, false], [AccessDecisionManager::STRATEGY_PRIORITY, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), ], false, true, false], [AccessDecisionManager::STRATEGY_PRIORITY, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), ], true, true, true], ]; } @@ -338,30 +338,37 @@ public function testCacheableVotersWithMultipleAttributesAndNonString() $this->assertTrue($manager->decide($token, ['foo', 1337], 'bar', true)); } - protected function getVoters($grants, $denies, $abstains) + protected static function getVoters($grants, $denies, $abstains): array { $voters = []; for ($i = 0; $i < $grants; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_GRANTED); + $voters[] = self::getVoter(VoterInterface::ACCESS_GRANTED); } for ($i = 0; $i < $denies; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_DENIED); + $voters[] = self::getVoter(VoterInterface::ACCESS_DENIED); } for ($i = 0; $i < $abstains; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_ABSTAIN); + $voters[] = self::getVoter(VoterInterface::ACCESS_ABSTAIN); } return $voters; } - protected function getVoter($vote) + protected static function getVoter($vote) { - $voter = $this->createMock(VoterInterface::class); - $voter->expects($this->any()) - ->method('vote') - ->willReturn($vote); + return new class($vote) implements VoterInterface { + private $vote; - return $voter; + public function __construct(int $vote) + { + $this->vote = $vote; + } + + public function vote(TokenInterface $token, $subject, array $attributes) + { + return $this->vote; + } + }; } private function getExpectedVoter(int $vote): VoterInterface diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php index 160b921b3075c..5ea3e6eeb3589 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php @@ -117,7 +117,7 @@ public function testIsGranted($decide) $this->assertSame($decide, $this->authorizationChecker->isGranted('ROLE_FOO')); } - public function isGrantedProvider() + public static function isGrantedProvider() { return [[true], [false]]; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php index c76ca77dfbbf5..81c31d6de9f57 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php @@ -45,7 +45,7 @@ public function testIsAuthenticated($token, $expression, $result) $this->assertEquals($result, $expressionLanguage->evaluate($expression, $context)); } - public function provider() + public static function provider() { $roles = ['ROLE_USER', 'ROLE_ADMIN']; $user = new InMemoryUser('username', 'password', $roles); @@ -75,6 +75,7 @@ public function provider() /** * @dataProvider legacyProvider + * * @group legacy */ public function testLegacyIsAuthenticated($token, $expression, $result) @@ -85,7 +86,7 @@ public function testLegacyIsAuthenticated($token, $expression, $result) /** * @group legacy */ - public function legacyProvider() + public static function legacyProvider() { $roles = ['ROLE_USER', 'ROLE_ADMIN']; $user = new InMemoryUser('username', 'password', $roles); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/AffirmativeStrategyTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/AffirmativeStrategyTest.php index 3c9004c797df2..b467a920b0f67 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/AffirmativeStrategyTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/AffirmativeStrategyTest.php @@ -16,17 +16,17 @@ class AffirmativeStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new AffirmativeStrategy(); - yield [$strategy, $this->getVoters(1, 0, 0), true]; - yield [$strategy, $this->getVoters(1, 2, 0), true]; - yield [$strategy, $this->getVoters(0, 1, 0), false]; - yield [$strategy, $this->getVoters(0, 0, 1), false]; + yield [$strategy, self::getVoters(1, 0, 0), true]; + yield [$strategy, self::getVoters(1, 2, 0), true]; + yield [$strategy, self::getVoters(0, 1, 0), false]; + yield [$strategy, self::getVoters(0, 0, 1), false]; $strategy = new AffirmativeStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 1), true]; + yield [$strategy, self::getVoters(0, 0, 1), true]; } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ConsensusStrategyTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ConsensusStrategyTest.php index 83adf3ac4c26b..bde6fb0d624b7 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ConsensusStrategyTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ConsensusStrategyTest.php @@ -16,25 +16,25 @@ class ConsensusStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new ConsensusStrategy(); - yield [$strategy, $this->getVoters(1, 0, 0), true]; - yield [$strategy, $this->getVoters(1, 2, 0), false]; - yield [$strategy, $this->getVoters(2, 1, 0), true]; - yield [$strategy, $this->getVoters(0, 0, 1), false]; + yield [$strategy, self::getVoters(1, 0, 0), true]; + yield [$strategy, self::getVoters(1, 2, 0), false]; + yield [$strategy, self::getVoters(2, 1, 0), true]; + yield [$strategy, self::getVoters(0, 0, 1), false]; - yield [$strategy, $this->getVoters(2, 2, 0), true]; - yield [$strategy, $this->getVoters(2, 2, 1), true]; + yield [$strategy, self::getVoters(2, 2, 0), true]; + yield [$strategy, self::getVoters(2, 2, 1), true]; $strategy = new ConsensusStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 1), true]; + yield [$strategy, self::getVoters(0, 0, 1), true]; $strategy = new ConsensusStrategy(false, false); - yield [$strategy, $this->getVoters(2, 2, 0), false]; - yield [$strategy, $this->getVoters(2, 2, 1), false]; + yield [$strategy, self::getVoters(2, 2, 0), false]; + yield [$strategy, self::getVoters(2, 2, 1), false]; } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/PriorityStrategyTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/PriorityStrategyTest.php index 7cd3184245d1c..aef3aaf0b27e3 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/PriorityStrategyTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/PriorityStrategyTest.php @@ -17,28 +17,28 @@ class PriorityStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new PriorityStrategy(); yield [$strategy, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_GRANTED), - $this->getVoter(VoterInterface::ACCESS_DENIED), - $this->getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_DENIED), ], true]; yield [$strategy, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_DENIED), - $this->getVoter(VoterInterface::ACCESS_GRANTED), - $this->getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_GRANTED), ], false]; - yield [$strategy, $this->getVoters(0, 0, 2), false]; + yield [$strategy, self::getVoters(0, 0, 2), false]; $strategy = new PriorityStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 2), true]; + yield [$strategy, self::getVoters(0, 0, 2), true]; } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/UnanimousStrategyTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/UnanimousStrategyTest.php index 1d49cf4e5347d..e00a50e3186ba 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/UnanimousStrategyTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/UnanimousStrategyTest.php @@ -16,18 +16,18 @@ class UnanimousStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new UnanimousStrategy(); - yield [$strategy, $this->getVoters(1, 0, 0), true]; - yield [$strategy, $this->getVoters(1, 0, 1), true]; - yield [$strategy, $this->getVoters(1, 1, 0), false]; + yield [$strategy, self::getVoters(1, 0, 0), true]; + yield [$strategy, self::getVoters(1, 0, 1), true]; + yield [$strategy, self::getVoters(1, 1, 0), false]; - yield [$strategy, $this->getVoters(0, 0, 2), false]; + yield [$strategy, self::getVoters(0, 0, 2), false]; $strategy = new UnanimousStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 2), true]; + yield [$strategy, self::getVoters(0, 0, 2), true]; } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php index 4b97885eb7ad0..770495137c40e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; +use Symfony\Component\Security\Core\Tests\Fixtures\DummyVoter; class TraceableAccessDecisionManagerTest extends TestCase { @@ -50,10 +51,10 @@ public function testDecideLog(array $expectedLog, array $attributes, $object, ar $this->assertEquals($expectedLog, $adm->getDecisionLog()); } - public function provideObjectsAndLogs(): \Generator + public static function provideObjectsAndLogs(): \Generator { - $voter1 = $this->getMockForAbstractClass(VoterInterface::class); - $voter2 = $this->getMockForAbstractClass(VoterInterface::class); + $voter1 = new DummyVoter(); + $voter2 = new DummyVoter(); yield [ [[ diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php index c1abddb5b9e02..342552619953c 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php @@ -33,7 +33,7 @@ public function testVote($authenticated, $attributes, $expected) $this->assertSame($expected, $voter->vote($this->getToken($authenticated), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return [ ['fully', [], VoterInterface::ACCESS_ABSTAIN], @@ -55,6 +55,7 @@ public function getVoteTests() /** * @group legacy + * * @dataProvider getLegacyVoteTests */ public function testLegacyVote($authenticated, $attributes, $expected) @@ -62,7 +63,7 @@ public function testLegacyVote($authenticated, $attributes, $expected) $this->testVote($authenticated, $attributes, $expected); } - public function getLegacyVoteTests() + public static function getLegacyVoteTests() { return [ ['anonymously', [], VoterInterface::ACCESS_ABSTAIN], @@ -93,7 +94,7 @@ public function testSupportsAttribute(string $attribute, bool $expected) $this->assertSame($expected, $voter->supportsAttribute($attribute)); } - public function provideAttributes() + public static function provideAttributes() { yield [AuthenticatedVoter::IS_AUTHENTICATED_FULLY, true]; yield [AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED, true]; 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 a3e516950bcc5..369b17f0460ea 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -32,16 +32,16 @@ public function testVoteWithTokenThatReturnsRoleNames($roles, $attributes, $expe $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles, $tokenExpectsGetRoles), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return [ [[], [], VoterInterface::ACCESS_ABSTAIN, false, false], [[], ['FOO'], VoterInterface::ACCESS_ABSTAIN, false, false], - [[], [$this->createExpression()], VoterInterface::ACCESS_DENIED, true, false], + [[], [self::createExpression()], VoterInterface::ACCESS_DENIED, true, false], - [['ROLE_FOO'], [$this->createExpression(), $this->createExpression()], VoterInterface::ACCESS_GRANTED], - [['ROLE_BAR', 'ROLE_FOO'], [$this->createExpression()], VoterInterface::ACCESS_GRANTED], + [['ROLE_FOO'], [self::createExpression(), self::createExpression()], VoterInterface::ACCESS_GRANTED], + [['ROLE_BAR', 'ROLE_FOO'], [self::createExpression()], VoterInterface::ACCESS_GRANTED], ]; } @@ -81,8 +81,8 @@ protected function createAuthorizationChecker() return $this->createMock(AuthorizationCheckerInterface::class); } - protected function createExpression() + protected static function createExpression() { - return $this->createMock(Expression::class); + return new Expression(''); } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php index 571270072706b..b811bd745bb85 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php @@ -27,7 +27,7 @@ public function testVoteUsingTokenThatReturnsRoleNames($roles, $attributes, $exp $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return array_merge(parent::getVoteTests(), [ [['ROLE_FOO'], ['ROLE_FOOBAR'], VoterInterface::ACCESS_GRANTED], @@ -44,7 +44,7 @@ public function testVoteWithEmptyHierarchyUsingTokenThatReturnsRoleNames($roles, $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes)); } - public function getVoteWithEmptyHierarchyTests() + public static function getVoteWithEmptyHierarchyTests() { return parent::getVoteTests(); } 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 21946e5d0b567..59a7ab770991f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -33,7 +33,7 @@ public function testVoteUsingTokenThatReturnsRoleNames($roles, $attributes, $exp $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return [ [[], [], VoterInterface::ACCESS_ABSTAIN], @@ -70,7 +70,7 @@ public function testSupportsAttribute(string $prefix, string $attribute, bool $e $this->assertSame($expected, $voter->supportsAttribute($attribute)); } - public function provideAttributes() + public static function provideAttributes() { yield ['ROLE_', 'ROLE_foo', true]; yield ['ROLE_', 'ROLE_', true]; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index 4b729d6a017df..25aff8e1ad841 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->token = $this->createMock(TokenInterface::class); } - public function getTests() + public static function getTests(): array { $voter = new VoterTest_Voter(); $integerVoter = new IntegerVoterTest_Voter(); @@ -41,7 +41,7 @@ public function getTests() [$voter, ['DELETE'], VoterInterface::ACCESS_ABSTAIN, new \stdClass(), 'ACCESS_ABSTAIN if no attribute is supported'], - [$voter, ['EDIT'], VoterInterface::ACCESS_ABSTAIN, $this, 'ACCESS_ABSTAIN if class is not supported'], + [$voter, ['EDIT'], VoterInterface::ACCESS_ABSTAIN, new class() {}, 'ACCESS_ABSTAIN if class is not supported'], [$voter, ['EDIT'], VoterInterface::ACCESS_ABSTAIN, null, 'ACCESS_ABSTAIN if object is null'], diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php index 9d864dfce038e..b50bfc6f67d52 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php @@ -16,6 +16,7 @@ /** * @author Elnur Abdurrakhimov + * * @group legacy */ class NativePasswordEncoderTest extends TestCase @@ -40,7 +41,7 @@ public function testCostInRange($cost) $this->assertInstanceOf(NativePasswordEncoder::class, new NativePasswordEncoder(null, null, $cost)); } - public function validRangeData() + public static function validRangeData() { $costs = range(4, 31); array_walk($costs, function (&$cost) { $cost = [$cost]; }); diff --git a/src/Symfony/Component/Security/Core/Tests/Fixtures/DummyVoter.php b/src/Symfony/Component/Security/Core/Tests/Fixtures/DummyVoter.php new file mode 100644 index 0000000000000..1f923423a21ed --- /dev/null +++ b/src/Symfony/Component/Security/Core/Tests/Fixtures/DummyVoter.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Tests\Fixtures; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; + +final class DummyVoter implements VoterInterface +{ + public function vote(TokenInterface $token, $subject, array $attributes): int + { + } +} diff --git a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php index c0607ed107930..a3fb755e39c2e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php @@ -45,7 +45,7 @@ public function testTranslationFileIsValidWithoutEntityLoader($filePath) $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message')))); } - public function provideTranslationFiles() + public static function provideTranslationFiles() { return array_map( function ($filePath) { return (array) $filePath; }, diff --git a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php index e1398fa45108d..55dad5a679d76 100644 --- a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php +++ b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php @@ -59,7 +59,7 @@ public function testGetUser($userInToken, $expectedUser) $this->assertSame($expectedUser, $security->getUser()); } - public function getUserTests() + public static function getUserTests() { yield [null, null]; @@ -70,7 +70,7 @@ public function getUserTests() /** * @group legacy */ - public function getLegacyUserTests() + public static function getLegacyUserTests() { yield ['string_username', null]; diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordTest.php index 8e956c3848bbf..7e22d28b94a4e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordTest.php @@ -33,7 +33,7 @@ public function testValidatedByService(UserPassword $constraint) self::assertSame('my_service', $constraint->validatedBy()); } - public function provideServiceValidatedConstraints(): iterable + public static function provideServiceValidatedConstraints(): iterable { yield 'Doctrine style' => [new UserPassword(['service' => 'my_service'])]; diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTestCase.php similarity index 96% rename from src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php rename to src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTestCase.php index caf6137ab984c..6fe8de6a1aa87 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTestCase.php @@ -24,7 +24,7 @@ /** * @author Bernhard Schussek */ -abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase +abstract class UserPasswordValidatorTestCase extends ConstraintValidatorTestCase { private const PASSWORD = 's3Cr3t'; private const SALT = '^S4lt$'; @@ -90,7 +90,7 @@ public function testPasswordIsNotValid(UserPassword $constraint) ->assertRaised(); } - public function provideConstraints(): iterable + public static function provideConstraints(): iterable { yield 'Doctrine style' => [new UserPassword(['message' => 'myMessage'])]; @@ -114,7 +114,7 @@ public function testEmptyPasswordsAreNotValid($password) ->assertRaised(); } - public function emptyPasswordData() + public static function emptyPasswordData() { return [ [null], diff --git a/src/Symfony/Component/Security/Csrf/LICENSE b/src/Symfony/Component/Security/Csrf/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Security/Csrf/LICENSE +++ b/src/Symfony/Component/Security/Csrf/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index bd911987f1f2d..c1bff0522c9f6 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -21,13 +21,41 @@ /** * @author Bernhard Schussek + * @author Alexandre Daubois */ class CsrfTokenManagerTest extends TestCase { - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testGetNonExistingToken($namespace, $manager, $storage, $generator) + public function testGetNonExistingTokenEmptyNamespace() + { + $this->assertGetNonExistingToken(...$this->getEmptyNamespaceMocks()); + } + + public function testGetNonExistingTokenHttpsNamespace() + { + $this->assertGetNonExistingToken(...$this->getHttpsNamespaceMocks()); + } + + public function testGetNonExistingTokenCustomNamespace() + { + $this->assertGetNonExistingToken(...$this->getCustomNamespaceMocks()); + } + + public function testGetNonExistingTokenRequestStack() + { + $this->assertGetNonExistingToken(...$this->getRequestStackMocks()); + } + + public function testGetNonExistingTokenClosure() + { + $this->assertGetNonExistingToken(...$this->getClosureMocks()); + } + + public function testGetNonExistingTokenRequestStackEmptyNamespace() + { + $this->assertGetNonExistingToken(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertGetNonExistingToken($namespace, $manager, $storage, $generator): void { $storage->expects($this->once()) ->method('hasToken') @@ -49,10 +77,37 @@ public function testGetNonExistingToken($namespace, $manager, $storage, $generat $this->assertNotSame('TOKEN', $token->getValue()); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testUseExistingTokenIfAvailable($namespace, $manager, $storage) + public function testUseExistingTokenIfAvailableEmptyNamespace() + { + $this->assertUseExistingTokenIfAvailable(...$this->getEmptyNamespaceMocks()); + } + + public function testUseExistingTokenIfAvailableHttpsNamespace() + { + $this->assertUseExistingTokenIfAvailable(...$this->getHttpsNamespaceMocks()); + } + + public function testUseExistingTokenIfAvailableCustomNamespace() + { + $this->assertUseExistingTokenIfAvailable(...$this->getCustomNamespaceMocks()); + } + + public function testUseExistingTokenIfAvailableRequestStack() + { + $this->assertUseExistingTokenIfAvailable(...$this->getRequestStackMocks()); + } + + public function testUseExistingTokenIfAvailableClosure() + { + $this->assertUseExistingTokenIfAvailable(...$this->getClosureMocks()); + } + + public function testUseExistingTokenIfAvailableRequestStackEmptyNamespace() + { + $this->assertUseExistingTokenIfAvailable(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertUseExistingTokenIfAvailable($namespace, $manager, $storage): void { $storage->expects($this->once()) ->method('hasToken') @@ -71,10 +126,37 @@ public function testUseExistingTokenIfAvailable($namespace, $manager, $storage) $this->assertNotSame('TOKEN', $token->getValue()); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testRandomizeTheToken($namespace, $manager, $storage) + public function testRandomizeTheTokenEmptyNamespace() + { + $this->assertRandomizeTheToken(...$this->getEmptyNamespaceMocks()); + } + + public function testRandomizeTheTokenHttpsNamespace() + { + $this->assertRandomizeTheToken(...$this->getHttpsNamespaceMocks()); + } + + public function testRandomizeTheTokenCustomNamespace() + { + $this->assertRandomizeTheToken(...$this->getCustomNamespaceMocks()); + } + + public function testRandomizeTheTokenRequestStack() + { + $this->assertRandomizeTheToken(...$this->getRequestStackMocks()); + } + + public function testRandomizeTheTokenClosure() + { + $this->assertRandomizeTheToken(...$this->getClosureMocks()); + } + + public function testRandomizeTheTokenRequestStackEmptyNamespace() + { + $this->assertRandomizeTheToken(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertRandomizeTheToken($namespace, $manager, $storage): void { $storage->expects($this->any()) ->method('hasToken') @@ -98,10 +180,37 @@ public function testRandomizeTheToken($namespace, $manager, $storage) $this->assertGreaterThan(2, \count(array_unique($lengths))); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testRefreshTokenAlwaysReturnsNewToken($namespace, $manager, $storage, $generator) + public function testRefreshTokenAlwaysReturnsNewTokenEmptyNamespace() + { + $this->assertRefreshTokenAlwaysReturnsNewToken(...$this->getEmptyNamespaceMocks()); + } + + public function testRefreshTokenAlwaysReturnsNewTokenHttpsNamespace() + { + $this->assertRefreshTokenAlwaysReturnsNewToken(...$this->getHttpsNamespaceMocks()); + } + + public function testRefreshTokenAlwaysReturnsNewTokenCustomNamespace() + { + $this->assertRefreshTokenAlwaysReturnsNewToken(...$this->getCustomNamespaceMocks()); + } + + public function testRefreshTokenAlwaysReturnsNewTokenRequestStack() + { + $this->assertRefreshTokenAlwaysReturnsNewToken(...$this->getRequestStackMocks()); + } + + public function testRefreshTokenAlwaysReturnsNewTokenClosure() + { + $this->assertRefreshTokenAlwaysReturnsNewToken(...$this->getClosureMocks()); + } + + public function testRefreshTokenAlwaysReturnsNewTokenRequestStackEmptyNamespace() + { + $this->assertRefreshTokenAlwaysReturnsNewToken(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertRefreshTokenAlwaysReturnsNewToken($namespace, $manager, $storage, $generator): void { $storage->expects($this->never()) ->method('hasToken'); @@ -121,10 +230,37 @@ public function testRefreshTokenAlwaysReturnsNewToken($namespace, $manager, $sto $this->assertNotSame('TOKEN', $token->getValue()); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testMatchingTokenIsValid($namespace, $manager, $storage) + public function testMatchingTokenIsValidEmptyNamespace() + { + $this->assertMatchingTokenIsValid(...$this->getEmptyNamespaceMocks()); + } + + public function testMatchingTokenIsValidHttpsNamespace() + { + $this->assertMatchingTokenIsValid(...$this->getHttpsNamespaceMocks()); + } + + public function testMatchingTokenIsValidCustomNamespace() + { + $this->assertMatchingTokenIsValid(...$this->getCustomNamespaceMocks()); + } + + public function testMatchingTokenIsValidRequestStack() + { + $this->assertMatchingTokenIsValid(...$this->getRequestStackMocks()); + } + + public function testMatchingTokenIsValidClosure() + { + $this->assertMatchingTokenIsValid(...$this->getClosureMocks()); + } + + public function testMatchingTokenIsValidRequestStackEmptyNamespace() + { + $this->assertMatchingTokenIsValid(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertMatchingTokenIsValid($namespace, $manager, $storage) { $storage->expects($this->exactly(2)) ->method('hasToken') @@ -141,10 +277,37 @@ public function testMatchingTokenIsValid($namespace, $manager, $storage) $this->assertTrue($manager->isTokenValid($token)); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testMatchingTokenIsValidWithLegacyToken($namespace, $manager, $storage) + public function testMatchingTokenIsValidWithLegacyTokenEmptyNamespace() + { + $this->assertMatchingTokenIsValidWithLegacyToken(...$this->getEmptyNamespaceMocks()); + } + + public function testMatchingTokenIsValidWithLegacyTokenHttpsNamespace() + { + $this->assertMatchingTokenIsValidWithLegacyToken(...$this->getHttpsNamespaceMocks()); + } + + public function testMatchingTokenIsValidWithLegacyTokenCustomNamespace() + { + $this->assertMatchingTokenIsValidWithLegacyToken(...$this->getCustomNamespaceMocks()); + } + + public function testMatchingTokenIsValidWithLegacyTokenRequestStack() + { + $this->assertMatchingTokenIsValidWithLegacyToken(...$this->getRequestStackMocks()); + } + + public function testMatchingTokenIsValidWithLegacyTokenClosure() + { + $this->assertMatchingTokenIsValidWithLegacyToken(...$this->getClosureMocks()); + } + + public function testMatchingTokenIsValidWithLegacyTokenRequestStackEmptyNamespace() + { + $this->assertMatchingTokenIsValidWithLegacyToken(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertMatchingTokenIsValidWithLegacyToken($namespace, $manager, $storage): void { $storage->expects($this->once()) ->method('hasToken') @@ -159,10 +322,37 @@ public function testMatchingTokenIsValidWithLegacyToken($namespace, $manager, $s $this->assertTrue($manager->isTokenValid(new CsrfToken('token_id', 'TOKEN'))); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testNonMatchingTokenIsNotValid($namespace, $manager, $storage) + public function testNonMatchingTokenIsNotValidEmptyNamespace() + { + $this->assertNonMatchingTokenIsNotValid(...$this->getEmptyNamespaceMocks()); + } + + public function testNonMatchingTokenIsNotValidHttpsNamespace() + { + $this->assertNonMatchingTokenIsNotValid(...$this->getHttpsNamespaceMocks()); + } + + public function testNonMatchingTokenIsNotValidCustomNamespace() + { + $this->assertNonMatchingTokenIsNotValid(...$this->getCustomNamespaceMocks()); + } + + public function testNonMatchingTokenIsNotValidRequestStack() + { + $this->assertNonMatchingTokenIsNotValid(...$this->getRequestStackMocks()); + } + + public function testNonMatchingTokenIsNotValidClosure() + { + $this->assertNonMatchingTokenIsNotValid(...$this->getClosureMocks()); + } + + public function testNonMatchingTokenIsNotValidRequestStackEmptyNamespace() + { + $this->assertNonMatchingTokenIsNotValid(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertNonMatchingTokenIsNotValid($namespace, $manager, $storage): void { $storage->expects($this->once()) ->method('hasToken') @@ -177,10 +367,37 @@ public function testNonMatchingTokenIsNotValid($namespace, $manager, $storage) $this->assertFalse($manager->isTokenValid(new CsrfToken('token_id', 'FOOBAR'))); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testNonExistingTokenIsNotValid($namespace, $manager, $storage) + public function testNonExistingTokenIsNotValidEmptyNamespace() + { + $this->assertNonExistingTokenIsNotValid(...$this->getEmptyNamespaceMocks()); + } + + public function testNonExistingTokenIsNotValidHttpsNamespace() + { + $this->assertNonExistingTokenIsNotValid(...$this->getHttpsNamespaceMocks()); + } + + public function testNonExistingTokenIsNotValidCustomNamespace() + { + $this->assertNonExistingTokenIsNotValid(...$this->getCustomNamespaceMocks()); + } + + public function testNonExistingTokenIsNotValidRequestStack() + { + $this->assertNonExistingTokenIsNotValid(...$this->getRequestStackMocks()); + } + + public function testNonExistingTokenIsNotValidClosure() + { + $this->assertNonExistingTokenIsNotValid(...$this->getClosureMocks()); + } + + public function testNonExistingTokenIsNotValidRequestStackEmptyNamespace() + { + $this->assertNonExistingTokenIsNotValid(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertNonExistingTokenIsNotValid($namespace, $manager, $storage): void { $storage->expects($this->once()) ->method('hasToken') @@ -213,10 +430,37 @@ public function testTokenShouldNotTriggerDivisionByZero() $this->assertFalse($manager->isTokenValid(new CsrfToken('token_id', 'abc..ghi'))); } - /** - * @dataProvider getManagerGeneratorAndStorage - */ - public function testRemoveToken($namespace, $manager, $storage) + public function testRemoveTokenEmptyNamespace() + { + $this->assertRemoveToken(...$this->getEmptyNamespaceMocks()); + } + + public function testRemoveTokenHttpsNamespace() + { + $this->assertRemoveToken(...$this->getHttpsNamespaceMocks()); + } + + public function testRemoveTokenCustomNamespace() + { + $this->assertRemoveToken(...$this->getCustomNamespaceMocks()); + } + + public function testRemoveTokenRequestStack() + { + $this->assertRemoveToken(...$this->getRequestStackMocks()); + } + + public function testRemoveTokenClosure() + { + $this->assertRemoveToken(...$this->getClosureMocks()); + } + + public function testRemoveTokenRequestStackEmptyNamespace() + { + $this->assertRemoveToken(...$this->getRequestStackWithEmptyNamespaceMocks()); + } + + private function assertRemoveToken($namespace, $manager, $storage): void { $storage->expects($this->once()) ->method('removeToken') @@ -241,35 +485,52 @@ public function testNamespaced() $this->assertSame('foo', $token->getId()); } - public function getManagerGeneratorAndStorage() + private function getEmptyNamespaceMocks(): array { - $data = []; - [$generator, $storage] = $this->getGeneratorAndStorage(); - $data[] = ['', new CsrfTokenManager($generator, $storage, ''), $storage, $generator]; + return ['', new CsrfTokenManager($generator, $storage, ''), $storage, $generator]; + } + + private function getHttpsNamespaceMocks(): array + { [$generator, $storage] = $this->getGeneratorAndStorage(); - $data[] = ['https-', new CsrfTokenManager($generator, $storage), $storage, $generator]; + return ['https-', new CsrfTokenManager($generator, $storage), $storage, $generator]; + } + + private function getCustomNamespaceMocks(): array + { [$generator, $storage] = $this->getGeneratorAndStorage(); - $data[] = ['aNamespace-', new CsrfTokenManager($generator, $storage, 'aNamespace-'), $storage, $generator]; + return ['aNamespace-', new CsrfTokenManager($generator, $storage, 'aNamespace-'), $storage, $generator]; + } + + private function getRequestStackMocks(): array + { $requestStack = new RequestStack(); $requestStack->push(new Request([], [], [], [], [], ['HTTPS' => 'on'])); [$generator, $storage] = $this->getGeneratorAndStorage(); - $data[] = ['https-', new CsrfTokenManager($generator, $storage, $requestStack), $storage, $generator]; + return ['https-', new CsrfTokenManager($generator, $storage, $requestStack), $storage, $generator]; + } + + private function getClosureMocks(): array + { [$generator, $storage] = $this->getGeneratorAndStorage(); - $data[] = ['generated-', new CsrfTokenManager($generator, $storage, function () { + + return ['generated-', new CsrfTokenManager($generator, $storage, function () { return 'generated-'; }), $storage, $generator]; + } + private function getRequestStackWithEmptyNamespaceMocks(): array + { $requestStack = new RequestStack(); $requestStack->push(new Request()); [$generator, $storage] = $this->getGeneratorAndStorage(); - $data[] = ['', new CsrfTokenManager($generator, $storage, $requestStack), $storage, $generator]; - return $data; + return ['', new CsrfTokenManager($generator, $storage, $requestStack), $storage, $generator]; } private function getGeneratorAndStorage(): array diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php index cde252af84de7..5e0383cb1c439 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php @@ -19,6 +19,7 @@ * @author Bernhard Schussek * * @runTestsInSeparateProcesses + * * @preserveGlobalState disabled */ class NativeSessionTokenStorageTest extends TestCase diff --git a/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php b/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php index 699fd3e979083..0ddae828959ab 100644 --- a/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php +++ b/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php @@ -76,9 +76,9 @@ public function getCredentials(Request $request); * * @param mixed $credentials * - * @throws AuthenticationException - * * @return UserInterface|null + * + * @throws AuthenticationException */ public function getUser($credentials, UserProviderInterface $userProvider); diff --git a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php index 81fb20f6b7e38..a9765a603e2d0 100644 --- a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php +++ b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AccountStatusException; use Symfony\Component\Security\Core\Exception\AuthenticationException; @@ -49,12 +50,13 @@ class GuardAuthenticationListener extends AbstractListener private $logger; private $rememberMeServices; private $hideUserNotFoundExceptions; + private $tokenStorage; /** * @param string $providerKey The provider (i.e. firewall) key * @param iterable $guardAuthenticators The authenticators, with keys that match what's passed to GuardAuthenticationProvider */ - public function __construct(GuardAuthenticatorHandler $guardHandler, AuthenticationManagerInterface $authenticationManager, string $providerKey, iterable $guardAuthenticators, LoggerInterface $logger = null, bool $hideUserNotFoundExceptions = true) + public function __construct(GuardAuthenticatorHandler $guardHandler, AuthenticationManagerInterface $authenticationManager, string $providerKey, iterable $guardAuthenticators, LoggerInterface $logger = null, bool $hideUserNotFoundExceptions = true, TokenStorageInterface $tokenStorage = null) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); @@ -66,6 +68,7 @@ public function __construct(GuardAuthenticatorHandler $guardHandler, Authenticat $this->guardAuthenticators = $guardAuthenticators; $this->logger = $logger; $this->hideUserNotFoundExceptions = $hideUserNotFoundExceptions; + $this->tokenStorage = $tokenStorage; } /** @@ -135,6 +138,7 @@ public function authenticate(RequestEvent $event) private function executeGuardAuthenticator(string $uniqueGuardKey, AuthenticatorInterface $guardAuthenticator, RequestEvent $event) { $request = $event->getRequest(); + $previousToken = $this->tokenStorage ? $this->tokenStorage->getToken() : null; try { if (null !== $this->logger) { $this->logger->debug('Calling getCredentials() on guard authenticator.', ['firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)]); @@ -162,7 +166,11 @@ private function executeGuardAuthenticator(string $uniqueGuardKey, Authenticator } // sets the token on the token storage, etc - $this->guardHandler->authenticateWithToken($token, $request, $this->providerKey); + if ($this->tokenStorage) { + $this->guardHandler->authenticateWithToken($token, $request, $this->providerKey, $previousToken); + } else { + $this->guardHandler->authenticateWithToken($token, $request, $this->providerKey); + } } catch (AuthenticationException $e) { // oh no! Authentication failed! diff --git a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php index cbd5bdfc93c35..f4466653735c3 100644 --- a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php +++ b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php @@ -56,9 +56,9 @@ public function __construct(TokenStorageInterface $tokenStorage, EventDispatcher /** * Authenticates the given token in the system. */ - public function authenticateWithToken(TokenInterface $token, Request $request, string $providerKey = null) + public function authenticateWithToken(TokenInterface $token, Request $request, string $providerKey = null, TokenInterface $previousToken = null) { - $this->migrateSession($request, $token, $providerKey); + $this->migrateSession($request, $token, $providerKey, 3 < \func_num_args() ? $previousToken : $this->tokenStorage->getToken()); $this->tokenStorage->setToken($token); if (null !== $this->dispatcher) { @@ -91,7 +91,7 @@ public function authenticateUserAndHandleSuccess(UserInterface $user, Request $r // create an authenticated token for the User $token = $authenticator->createAuthenticatedToken($user, $providerKey); // authenticate this in the system - $this->authenticateWithToken($token, $request, $providerKey); + $this->authenticateWithToken($token, $request, $providerKey, $this->tokenStorage->getToken()); // return the success metric return $this->handleAuthenticationSuccess($token, $request, $authenticator, $providerKey); @@ -122,12 +122,21 @@ public function setSessionAuthenticationStrategy(SessionAuthenticationStrategyIn $this->sessionStrategy = $sessionStrategy; } - private function migrateSession(Request $request, TokenInterface $token, ?string $providerKey) + private function migrateSession(Request $request, TokenInterface $token, ?string $providerKey, ?TokenInterface $previousToken) { if (\in_array($providerKey, $this->statelessProviderKeys, true) || !$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession()) { return; } + if ($previousToken) { + $user = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(); + $previousUser = method_exists($previousToken, 'getUserIdentifier') ? $previousToken->getUserIdentifier() : $previousToken->getUsername(); + + if ('' !== ($user ?? '') && $user === $previousUser) { + return; + } + } + $this->sessionStrategy->onAuthentication($request, $token); } } diff --git a/src/Symfony/Component/Security/Guard/LICENSE b/src/Symfony/Component/Security/Guard/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Security/Guard/LICENSE +++ b/src/Symfony/Component/Security/Guard/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php index 6251ae584acc4..69ef58b412f07 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -24,6 +24,7 @@ /** * @author Jean Pasdeloup + * * @group legacy */ class FormLoginAuthenticatorTest extends TestCase diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/GuardBridgeAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/GuardBridgeAuthenticatorTest.php index 3dd65a1715023..0eb67318f5b8c 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/GuardBridgeAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/GuardBridgeAuthenticatorTest.php @@ -140,7 +140,7 @@ public function testAuthenticateRememberMe(bool $rememberMeSupported) $this->assertEquals($rememberMeSupported, $passport->hasBadge(RememberMeBadge::class)); } - public function provideRememberMeData() + public static function provideRememberMeData() { yield [true]; yield [false]; diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index 19bedb20dac66..f1f9cec886a47 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -32,6 +32,7 @@ /** * @author Ryan Weaver * @author Amaury Leroux de Lens + * * @group legacy */ class GuardAuthenticationListenerTest extends TestCase @@ -256,7 +257,7 @@ public function testHandleHidesInvalidUserExceptions(AuthenticationException $ex $listener($this->event); } - public function exceptionsToHide() + public static function exceptionsToHide() { return [ [new UserNotFoundException()], diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php index d36cf666f32a9..d14bf43d0f91f 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -109,7 +109,7 @@ public function testHandleAuthenticationClearsToken($tokenProviderKey, $actualPr $this->assertSame($response, $actualResponse); } - public function getTokenClearingTests() + public static function getTokenClearingTests() { $tests = []; // matching firewall => clear the token diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index 61b70af13398b..5fe7dc46b5713 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -26,6 +26,7 @@ /** * @author Ryan Weaver + * * @group legacy */ class GuardAuthenticationProviderTest extends TestCase diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php index 82c8cd2e7b7a7..f78ce0b4f16a8 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php @@ -22,7 +22,7 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException; -use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; +use Symfony\Component\Security\Core\Exception\UserNotFoundException; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator; @@ -84,7 +84,7 @@ public function authenticateUser(UserInterface $user, AuthenticatorInterface $au $token = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($token, $passport))->getAuthenticatedToken(); // authenticate this in the system - return $this->handleAuthenticationSuccess($token, $passport, $request, $authenticator); + return $this->handleAuthenticationSuccess($token, $passport, $request, $authenticator, $this->tokenStorage->getToken()); } public function supports(Request $request): ?bool @@ -174,6 +174,7 @@ private function executeAuthenticators(array $authenticators, Request $request): private function executeAuthenticator(AuthenticatorInterface $authenticator, Request $request): ?Response { $passport = null; + $previousToken = $this->tokenStorage->getToken(); try { // get the passport from the Authenticator @@ -224,7 +225,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req } // success! (sets the token on the token storage, etc) - $response = $this->handleAuthenticationSuccess($authenticatedToken, $passport, $request, $authenticator); + $response = $this->handleAuthenticationSuccess($authenticatedToken, $passport, $request, $authenticator, $previousToken); if ($response instanceof Response) { return $response; } @@ -236,7 +237,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req return null; } - private function handleAuthenticationSuccess(TokenInterface $authenticatedToken, PassportInterface $passport, Request $request, AuthenticatorInterface $authenticator): ?Response + private function handleAuthenticationSuccess(TokenInterface $authenticatedToken, PassportInterface $passport, Request $request, AuthenticatorInterface $authenticator, ?TokenInterface $previousToken): ?Response { // @deprecated since Symfony 5.3 $user = $authenticatedToken->getUser(); @@ -252,7 +253,7 @@ private function handleAuthenticationSuccess(TokenInterface $authenticatedToken, $this->eventDispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN); } - $this->eventDispatcher->dispatch($loginSuccessEvent = new LoginSuccessEvent($authenticator, $passport, $authenticatedToken, $request, $response, $this->firewallName)); + $this->eventDispatcher->dispatch($loginSuccessEvent = new LoginSuccessEvent($authenticator, $passport, $authenticatedToken, $request, $response, $this->firewallName, $previousToken)); return $loginSuccessEvent->getResponse(); } @@ -268,7 +269,7 @@ private function handleAuthenticationFailure(AuthenticationException $authentica // Avoid leaking error details in case of invalid user (e.g. user not found or invalid account status) // to prevent user enumeration via response content comparison - if ($this->hideUserNotFoundExceptions && ($authenticationException instanceof UsernameNotFoundException || ($authenticationException instanceof AccountStatusException && !$authenticationException instanceof CustomUserMessageAccountStatusException))) { + if ($this->hideUserNotFoundExceptions && ($authenticationException instanceof UserNotFoundException || ($authenticationException instanceof AccountStatusException && !$authenticationException instanceof CustomUserMessageAccountStatusException))) { $authenticationException = new BadCredentialsException('Bad credentials.', 0, $authenticationException); } diff --git a/src/Symfony/Component/Security/Http/Authenticator/AuthenticatorInterface.php b/src/Symfony/Component/Security/Http/Authenticator/AuthenticatorInterface.php index 4165d25af1a4d..b66874fa2c534 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/AuthenticatorInterface.php +++ b/src/Symfony/Component/Security/Http/Authenticator/AuthenticatorInterface.php @@ -51,9 +51,9 @@ public function supports(Request $request): ?bool; * You may throw any AuthenticationException in this method in case of error (e.g. * a UserNotFoundException when the user cannot be found). * - * @throws AuthenticationException - * * @return Passport + * + * @throws AuthenticationException */ public function authenticate(Request $request); /* : Passport; */ diff --git a/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php b/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php index cca50c8b2d82f..a7d7f01a4df52 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php +++ b/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php @@ -20,7 +20,7 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\CookieTheftException; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; -use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; +use Symfony\Component\Security\Core\Exception\UserNotFoundException; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Passport; use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; @@ -119,7 +119,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token, public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response { if (null !== $this->logger) { - if ($exception instanceof UsernameNotFoundException) { + if ($exception instanceof UserNotFoundException) { $this->logger->info('User for remember-me cookie not found.', ['exception' => $exception]); } elseif ($exception instanceof UnsupportedUserException) { $this->logger->warning('User class for remember-me cookie not supported.', ['exception' => $exception]); diff --git a/src/Symfony/Component/Security/Http/Event/LoginSuccessEvent.php b/src/Symfony/Component/Security/Http/Event/LoginSuccessEvent.php index d2272fe2c6f32..27a8621af02fb 100644 --- a/src/Symfony/Component/Security/Http/Event/LoginSuccessEvent.php +++ b/src/Symfony/Component/Security/Http/Event/LoginSuccessEvent.php @@ -37,6 +37,7 @@ class LoginSuccessEvent extends Event private $authenticator; private $passport; private $authenticatedToken; + private $previousToken; private $request; private $response; private $firewallName; @@ -44,7 +45,7 @@ class LoginSuccessEvent extends Event /** * @param Passport $passport */ - public function __construct(AuthenticatorInterface $authenticator, PassportInterface $passport, TokenInterface $authenticatedToken, Request $request, ?Response $response, string $firewallName) + public function __construct(AuthenticatorInterface $authenticator, PassportInterface $passport, TokenInterface $authenticatedToken, Request $request, ?Response $response, string $firewallName, TokenInterface $previousToken = null) { if (!$passport instanceof Passport) { trigger_deprecation('symfony/security-http', '5.4', 'Not passing an instance of "%s" as "$passport" argument of "%s()" is deprecated, "%s" given.', Passport::class, __METHOD__, get_debug_type($passport)); @@ -53,6 +54,7 @@ public function __construct(AuthenticatorInterface $authenticator, PassportInter $this->authenticator = $authenticator; $this->passport = $passport; $this->authenticatedToken = $authenticatedToken; + $this->previousToken = $previousToken; $this->request = $request; $this->response = $response; $this->firewallName = $firewallName; @@ -83,6 +85,11 @@ public function getAuthenticatedToken(): TokenInterface return $this->authenticatedToken; } + public function getPreviousToken(): ?TokenInterface + { + return $this->previousToken; + } + public function getRequest(): Request { return $this->request; diff --git a/src/Symfony/Component/Security/Http/EventListener/SessionStrategyListener.php b/src/Symfony/Component/Security/Http/EventListener/SessionStrategyListener.php index b1ba2889d614c..311a52ffd98bd 100644 --- a/src/Symfony/Component/Security/Http/EventListener/SessionStrategyListener.php +++ b/src/Symfony/Component/Security/Http/EventListener/SessionStrategyListener.php @@ -43,6 +43,16 @@ public function onSuccessfulLogin(LoginSuccessEvent $event): void return; } + if ($previousToken = $event->getPreviousToken()) { + // @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0 + $user = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(); + $previousUser = method_exists($previousToken, 'getUserIdentifier') ? $previousToken->getUserIdentifier() : $previousToken->getUsername(); + + if ('' !== ($user ?? '') && $user === $previousUser) { + return; + } + } + $this->sessionAuthenticationStrategy->onAuthentication($request, $token); } diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php index 33e2c08b64d86..6ff49cb0d595d 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php @@ -133,12 +133,14 @@ public function authenticate(RequestEvent $event) throw new SessionUnavailableException('Your session has timed out, or you have disabled cookies.'); } + $previousToken = $this->tokenStorage->getToken(); + if (null === $returnValue = $this->attemptAuthentication($request)) { return; } if ($returnValue instanceof TokenInterface) { - $this->sessionStrategy->onAuthentication($request, $returnValue); + $this->migrateSession($request, $returnValue, $previousToken); $response = $this->onSuccess($request, $returnValue); } elseif ($returnValue instanceof Response) { @@ -226,4 +228,18 @@ private function onSuccess(Request $request, TokenInterface $token): Response return $response; } + + private function migrateSession(Request $request, TokenInterface $token, ?TokenInterface $previousToken) + { + if ($previousToken) { + $user = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(); + $previousUser = method_exists($previousToken, 'getUserIdentifier') ? $previousToken->getUserIdentifier() : $previousToken->getUsername(); + + if ('' !== ($user ?? '') && $user === $previousUser) { + return; + } + } + + $this->sessionStrategy->onAuthentication($request, $token); + } } diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php index b698e1e4d7dca..bc59e4e365536 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php @@ -98,13 +98,14 @@ public function authenticate(RequestEvent $event) } try { + $previousToken = $token; $token = $this->authenticationManager->authenticate(new PreAuthenticatedToken($user, $credentials, $this->providerKey)); if (null !== $this->logger) { $this->logger->info('Pre-authentication successful.', ['token' => (string) $token]); } - $this->migrateSession($request, $token); + $this->migrateSession($request, $token, $previousToken); $this->tokenStorage->setToken($token); @@ -149,12 +150,21 @@ private function clearToken(AuthenticationException $exception) */ abstract protected function getPreAuthenticatedData(Request $request); - private function migrateSession(Request $request, TokenInterface $token) + private function migrateSession(Request $request, TokenInterface $token, ?TokenInterface $previousToken) { if (!$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession()) { return; } + if ($previousToken) { + $user = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(); + $previousUser = method_exists($previousToken, 'getUserIdentifier') ? $previousToken->getUserIdentifier() : $previousToken->getUsername(); + + if ('' !== ($user ?? '') && $user === $previousUser) { + return; + } + } + $this->sessionStrategy->onAuthentication($request, $token); } } diff --git a/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php index 8113e9f1ad267..cb02f0120ee68 100644 --- a/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php @@ -88,9 +88,10 @@ public function authenticate(RequestEvent $event) } try { + $previousToken = $token; $token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey)); - $this->migrateSession($request, $token); + $this->migrateSession($request, $token, $previousToken); $this->tokenStorage->setToken($token); } catch (AuthenticationException $e) { @@ -121,12 +122,21 @@ public function setSessionAuthenticationStrategy(SessionAuthenticationStrategyIn $this->sessionStrategy = $sessionStrategy; } - private function migrateSession(Request $request, TokenInterface $token) + private function migrateSession(Request $request, TokenInterface $token, ?TokenInterface $previousToken) { if (!$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession()) { return; } + if ($previousToken) { + $user = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(); + $previousUser = method_exists($previousToken, 'getUserIdentifier') ? $previousToken->getUserIdentifier() : $previousToken->getUsername(); + + if ('' !== ($user ?? '') && $user === $previousUser) { + return; + } + } + $this->sessionStrategy->onAuthentication($request, $token); } } diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php index 9679b33ff92a5..13025ce6241e4 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php @@ -101,6 +101,7 @@ public function authenticate(RequestEvent $event) { $request = $event->getRequest(); $data = json_decode($request->getContent()); + $previousToken = $this->tokenStorage->getToken(); try { if (!$data instanceof \stdClass) { @@ -134,7 +135,7 @@ public function authenticate(RequestEvent $event) $token = new UsernamePasswordToken($username, $password, $this->providerKey); $authenticatedToken = $this->authenticationManager->authenticate($token); - $response = $this->onSuccess($request, $authenticatedToken); + $response = $this->onSuccess($request, $authenticatedToken, $previousToken); } catch (AuthenticationException $e) { $response = $this->onFailure($request, $e); } catch (BadRequestHttpException $e) { @@ -150,14 +151,14 @@ public function authenticate(RequestEvent $event) $event->setResponse($response); } - private function onSuccess(Request $request, TokenInterface $token): ?Response + private function onSuccess(Request $request, TokenInterface $token, ?TokenInterface $previousToken): ?Response { if (null !== $this->logger) { // @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 6.0 $this->logger->info('User has been authenticated successfully.', ['username' => method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername()]); } - $this->migrateSession($request, $token); + $this->migrateSession($request, $token, $previousToken); $this->tokenStorage->setToken($token); @@ -224,12 +225,21 @@ public function setTranslator(TranslatorInterface $translator) $this->translator = $translator; } - private function migrateSession(Request $request, TokenInterface $token) + private function migrateSession(Request $request, TokenInterface $token, ?TokenInterface $previousToken) { if (!$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession()) { return; } + if ($previousToken) { + $user = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername(); + $previousUser = method_exists($previousToken, 'getUserIdentifier') ? $previousToken->getUserIdentifier() : $previousToken->getUsername(); + + if ('' !== ($user ?? '') && $user === $previousUser) { + return; + } + } + $this->sessionStrategy->onAuthentication($request, $token); } } diff --git a/src/Symfony/Component/Security/Http/LICENSE b/src/Symfony/Component/Security/Http/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Security/Http/LICENSE +++ b/src/Symfony/Component/Security/Http/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticatorManagerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticatorManagerTest.php index 96dea2730aa24..f1eddd09c723b 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticatorManagerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticatorManagerTest.php @@ -33,6 +33,7 @@ use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; use Symfony\Component\Security\Http\Event\AuthenticationTokenCreatedEvent; use Symfony\Component\Security\Http\Event\CheckPassportEvent; +use Symfony\Component\Security\Http\Tests\Fixtures\DummySupportsAuthenticator; class AuthenticatorManagerTest extends TestCase { @@ -64,15 +65,15 @@ public function testSupports($authenticators, $result) $this->assertEquals($result, $manager->supports($this->request)); } - public function provideSupportsData() + public static function provideSupportsData() { - yield [[$this->createAuthenticator(null), $this->createAuthenticator(null)], null]; - yield [[$this->createAuthenticator(null), $this->createAuthenticator(false)], null]; + yield [[self::createDummySupportsAuthenticator(null), self::createDummySupportsAuthenticator(null)], null]; + yield [[self::createDummySupportsAuthenticator(null), self::createDummySupportsAuthenticator(false)], null]; - yield [[$this->createAuthenticator(null), $this->createAuthenticator(true)], true]; - yield [[$this->createAuthenticator(true), $this->createAuthenticator(false)], true]; + yield [[self::createDummySupportsAuthenticator(null), self::createDummySupportsAuthenticator(true)], true]; + yield [[self::createDummySupportsAuthenticator(true), self::createDummySupportsAuthenticator(false)], true]; - yield [[$this->createAuthenticator(false), $this->createAuthenticator(false)], false]; + yield [[self::createDummySupportsAuthenticator(false), self::createDummySupportsAuthenticator(false)], false]; yield [[], false]; } @@ -118,7 +119,7 @@ public function testAuthenticateRequest($matchingAuthenticatorIndex) $this->assertTrue($listenerCalled, 'The CheckPassportEvent listener is not called'); } - public function provideMatchingAuthenticatorIndex() + public static function provideMatchingAuthenticatorIndex() { yield [0]; yield [1]; @@ -188,7 +189,7 @@ public function testEraseCredentials($eraseCredentials) $manager->authenticateRequest($this->request); } - public function provideEraseCredentialsData() + public static function provideEraseCredentialsData() { yield [true]; yield [false]; @@ -351,7 +352,7 @@ public function log($level, $message, array $context = []): void $this->assertStringContainsString('Mock_TestInteractiveAuthenticator', $logger->logContexts[0]['authenticator']); } - private function createAuthenticator($supports = true) + private function createAuthenticator(?bool $supports = true) { $authenticator = $this->createMock(TestInteractiveAuthenticator::class); $authenticator->expects($this->any())->method('supports')->willReturn($supports); @@ -359,6 +360,11 @@ private function createAuthenticator($supports = true) return $authenticator; } + private static function createDummySupportsAuthenticator(?bool $supports = true) + { + return new DummySupportsAuthenticator($supports); + } + private function createManager($authenticators, $firewallName = 'main', $eraseCredentials = true, array $requiredBadges = [], LoggerInterface $logger = null) { return new AuthenticatorManager($authenticators, $this->tokenStorage, $this->eventDispatcher, $firewallName, $logger, $eraseCredentials, true, $requiredBadges); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index 852fb4bcdcb6d..2d63821b42ccd 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -38,7 +38,7 @@ public function testRequestRedirections(Request $request, $options, $redirectedU $this->assertSame('http://localhost'.$redirectedUrl, $handler->onAuthenticationSuccess($request, $token)->getTargetUrl()); } - public function getRequestRedirections() + public function testRequestRedirectionsWithTargetPathInSessions() { $session = $this->createMock(SessionInterface::class); $session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard'); @@ -46,6 +46,18 @@ public function getRequestRedirections() $requestWithSession = Request::create('/'); $requestWithSession->setSession($session); + $urlGenerator = $this->createMock(UrlGeneratorInterface::class); + $urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login'); + $httpUtils = new HttpUtils($urlGenerator); + $token = $this->createMock(TokenInterface::class); + $handler = new DefaultAuthenticationSuccessHandler($httpUtils); + $handler->setFirewallName('admin'); + + $this->assertSame('http://localhost/admin/dashboard', $handler->onAuthenticationSuccess($requestWithSession, $token)->getTargetUrl()); + } + + public static function getRequestRedirections() + { return [ 'default' => [ Request::create('/'), @@ -72,11 +84,6 @@ public function getRequestRedirections() ['target_path_parameter' => '_target_path[value]'], '/dashboard', ], - 'target path in session' => [ - $requestWithSession, - [], - '/admin/dashboard', - ], 'target path as referer' => [ Request::create('/', 'GET', [], [], [], ['HTTP_REFERER' => 'http://localhost/dashboard']), ['use_referer' => true], diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/AbstractLoginFormAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/AbstractLoginFormAuthenticatorTest.php index 3a50c131cd522..bbedd40b7c4ea 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/AbstractLoginFormAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/AbstractLoginFormAuthenticatorTest.php @@ -30,7 +30,7 @@ public function testSupports(string $loginUrl, Request $request, bool $expected) $this->assertSame($expected, $authenticator->supports($request)); } - public function provideSupportsData(): iterable + public static function provideSupportsData(): iterable { yield [ '/login', diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/FormLoginAuthenticatorTest.php index 3536b103a3041..aa1ae8a950ccf 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -60,7 +60,7 @@ public function testHandleWhenUsernameLength($username, $ok) $this->authenticator->authenticate($request); } - public function provideUsernamesForLength() + public static function provideUsernamesForLength() { yield [str_repeat('x', Security::MAX_USERNAME_LENGTH + 1), false]; yield [str_repeat('x', Security::MAX_USERNAME_LENGTH - 1), true]; @@ -126,7 +126,7 @@ public function testHandleNonStringUsernameWithToString($postOnly) $this->authenticator->authenticate($request); } - public function postOnlyDataProvider() + public static function postOnlyDataProvider() { yield [true]; yield [false]; @@ -171,7 +171,7 @@ public function testSupportsFormOnly(string $contentType, bool $shouldSupport) $this->assertSame($shouldSupport, $this->authenticator->supports($request)); } - public function provideContentTypes() + public static function provideContentTypes() { yield ['application/json', false]; yield ['application/x-www-form-urlencoded', true]; diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/HttpBasicAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/HttpBasicAuthenticatorTest.php index 70f48b9bc138e..b7b0cc010801f 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/HttpBasicAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/HttpBasicAuthenticatorTest.php @@ -67,7 +67,7 @@ public function testHttpBasicServerParametersMissing(array $serverParameters) $this->assertFalse($this->authenticator->supports($request)); } - public function provideMissingHttpBasicServerParameters() + public static function provideMissingHttpBasicServerParameters() { return [ [[]], diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php index 47e02689ead93..ae37976d5ee0f 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php @@ -45,7 +45,7 @@ public function testSupport($request) $this->assertTrue($this->authenticator->supports($request)); } - public function provideSupportData() + public static function provideSupportData() { yield [new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}')]; @@ -64,7 +64,7 @@ public function testSupportsWithCheckPath($request, $result) $this->assertSame($result, $this->authenticator->supports($request)); } - public function provideSupportsWithCheckPathData() + public static function provideSupportsWithCheckPathData() { yield [Request::create('/api/login', 'GET', [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json']), true]; yield [Request::create('/login', 'GET', [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json']), false]; @@ -104,7 +104,7 @@ public function testAuthenticateInvalid($request, $errorMessage, $exceptionType $this->authenticator->authenticate($request); } - public function provideInvalidAuthenticateData() + public static function provideInvalidAuthenticateData() { $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json']); yield [$request, 'Invalid JSON.']; diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/LoginLinkAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/LoginLinkAuthenticatorTest.php index 7e533398d96c6..fb704d988ec7e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/LoginLinkAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/LoginLinkAuthenticatorTest.php @@ -50,7 +50,7 @@ public function testSupport(array $options, $request, bool $supported) $this->assertEquals($supported, $this->authenticator->supports($request)); } - public function provideSupportData() + public static function provideSupportData() { yield [['check_route' => '/validate_link'], Request::create('/validate_link?hash=abc123'), true]; yield [['check_route' => '/validate_link'], Request::create('/login?hash=abc123'), false]; diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php index c7492a95a464f..302def675391b 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php @@ -51,7 +51,7 @@ public function testSupports($request, $support) $this->assertSame($support, $this->authenticator->supports($request)); } - public function provideSupportsData() + public static function provideSupportsData() { yield [Request::create('/'), false]; diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php index 89a5776decd29..5119f8ce09e74 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php @@ -64,7 +64,7 @@ public function testAuthenticate(InMemoryUserProvider $userProvider, RemoteUserA $this->assertTrue($user->isEqualTo($passport->getUser())); } - public function provideAuthenticators() + public static function provideAuthenticators() { $userProvider = new InMemoryUserProvider(); yield [$userProvider, new RemoteUserAuthenticator($userProvider, new TokenStorage(), 'main'), 'REMOTE_USER']; diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php index e9e5ddd54aba4..9b9492d9ff822 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php @@ -33,7 +33,7 @@ public function testStart($httpPort, $httpsPort, $request, $expectedUrl) $this->assertEquals($expectedUrl, $response->headers->get('Location')); } - public function dataForStart() + public static function dataForStart() { if (!class_exists(Request::class)) { return [[]]; diff --git a/src/Symfony/Component/Security/Http/Tests/EventListener/CheckCredentialsListenerTest.php b/src/Symfony/Component/Security/Http/Tests/EventListener/CheckCredentialsListenerTest.php index bab2ad0fc13f7..7135edbcb80b6 100644 --- a/src/Symfony/Component/Security/Http/Tests/EventListener/CheckCredentialsListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EventListener/CheckCredentialsListenerTest.php @@ -62,7 +62,7 @@ public function testPasswordAuthenticated($password, $passwordValid, $result) } } - public function providePasswords() + public static function providePasswords() { yield ['ThePa$$word', true, true]; yield ['Invalid', false, false]; @@ -100,7 +100,7 @@ public function testCustomAuthenticated($result) } } - public function provideCustomAuthenticatedResults() + public static function provideCustomAuthenticatedResults() { yield [true]; yield [false]; diff --git a/src/Symfony/Component/Security/Http/Tests/EventListener/CheckRememberMeConditionsListenerTest.php b/src/Symfony/Component/Security/Http/Tests/EventListener/CheckRememberMeConditionsListenerTest.php index adc4a51251ded..a0e4904c20329 100644 --- a/src/Symfony/Component/Security/Http/Tests/EventListener/CheckRememberMeConditionsListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EventListener/CheckRememberMeConditionsListenerTest.php @@ -80,7 +80,7 @@ public function testSuccessfulLoginWithOptInRequestParameter($optInValue) $this->assertTrue($passport->getBadge(RememberMeBadge::class)->isEnabled()); } - public function provideRememberMeOptInValues() + public static function provideRememberMeOptInValues() { yield ['true']; yield ['1']; diff --git a/src/Symfony/Component/Security/Http/Tests/EventListener/PasswordMigratingListenerTest.php b/src/Symfony/Component/Security/Http/Tests/EventListener/PasswordMigratingListenerTest.php index 9f8e218e70714..70725c2039243 100644 --- a/src/Symfony/Component/Security/Http/Tests/EventListener/PasswordMigratingListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EventListener/PasswordMigratingListenerTest.php @@ -15,13 +15,12 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface; use Symfony\Component\PasswordHasher\PasswordHasherInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authentication\Token\NullToken; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; -use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; @@ -29,6 +28,7 @@ use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface; use Symfony\Component\Security\Http\Event\LoginSuccessEvent; use Symfony\Component\Security\Http\EventListener\PasswordMigratingListener; +use Symfony\Component\Security\Http\Tests\Fixtures\DummyAuthenticator; class PasswordMigratingListenerTest extends TestCase { @@ -58,13 +58,13 @@ public function testUnsupportedEvents($event) $this->listener->onLoginSuccess($event); } - public function provideUnsupportedEvents() + public static function provideUnsupportedEvents() { // no password upgrade badge - yield [$this->createEvent(new SelfValidatingPassport(new UserBadge('test', function () { return $this->createMock(UserInterface::class); })))]; + yield [self::createEvent(new SelfValidatingPassport(new UserBadge('test', function () { return new DummyTestPasswordAuthenticatedUser(); })))]; // blank password - yield [$this->createEvent(new SelfValidatingPassport(new UserBadge('test', function () { return $this->createMock(TestPasswordAuthenticatedUser::class); }), [new PasswordUpgradeBadge('', $this->createPasswordUpgrader())]))]; + yield [self::createEvent(new SelfValidatingPassport(new UserBadge('test', function () { return new DummyTestPasswordAuthenticatedUser(); }), [new PasswordUpgradeBadge('', self::createPasswordUpgrader())]))]; } /** @@ -96,7 +96,7 @@ public function testUnsupportedPassport() public function testUpgradeWithUpgrader() { - $passwordUpgrader = $this->createPasswordUpgrader(); + $passwordUpgrader = $this->getMockForAbstractClass(TestMigratingUserProvider::class); $passwordUpgrader->expects($this->once()) ->method('upgradePassword') ->with($this->user, 'new-hash') @@ -133,14 +133,14 @@ public function testUserWithoutPassword() $this->listener->onLoginSuccess($event); } - private function createPasswordUpgrader() + private static function createPasswordUpgrader() { - return $this->getMockForAbstractClass(TestMigratingUserProvider::class); + return new DummyTestMigratingUserProvider(); } - private function createEvent(PassportInterface $passport) + private static function createEvent(PassportInterface $passport) { - return new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class), $passport, $this->createMock(TokenInterface::class), new Request(), null, 'main'); + return new LoginSuccessEvent(new DummyAuthenticator(), $passport, new NullToken(), new Request(), null, 'main'); } } @@ -151,9 +151,62 @@ abstract public function upgradePassword(PasswordAuthenticatedUserInterface $use abstract public function loadUserByIdentifier(string $identifier): UserInterface; } +class DummyTestMigratingUserProvider extends TestMigratingUserProvider +{ + public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void + { + } + + public function loadUserByIdentifier(string $identifier): UserInterface + { + } + + public function refreshUser(UserInterface $user) + { + } + + public function supportsClass(string $class) + { + } + + public function loadUserByUsername(string $username) + { + } +} + abstract class TestPasswordAuthenticatedUser implements UserInterface, PasswordAuthenticatedUserInterface { abstract public function getPassword(): ?string; abstract public function getSalt(): ?string; } + +class DummyTestPasswordAuthenticatedUser extends TestPasswordAuthenticatedUser +{ + public function getPassword(): ?string + { + return null; + } + + public function getSalt(): ?string + { + return null; + } + + public function getRoles(): array + { + return []; + } + + public function eraseCredentials() + { + } + + public function getUsername() + { + } + + public function getUserIdentifier(): string + { + } +} diff --git a/src/Symfony/Component/Security/Http/Tests/EventListener/SessionStrategyListenerTest.php b/src/Symfony/Component/Security/Http/Tests/EventListener/SessionStrategyListenerTest.php index a28b316f31d48..51b8dc1878ed3 100644 --- a/src/Symfony/Component/Security/Http/Tests/EventListener/SessionStrategyListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EventListener/SessionStrategyListenerTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authentication\Token\NullToken; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; @@ -35,7 +35,7 @@ protected function setUp(): void $this->sessionAuthenticationStrategy = $this->createMock(SessionAuthenticationStrategyInterface::class); $this->listener = new SessionStrategyListener($this->sessionAuthenticationStrategy); $this->request = new Request(); - $this->token = $this->createMock(TokenInterface::class); + $this->token = $this->createMock(NullToken::class); } public function testRequestWithSession() @@ -62,6 +62,25 @@ public function testStatelessFirewalls() $listener->onSuccessfulLogin($this->createEvent('api_firewall')); } + public function testRequestWithSamePreviousUser() + { + $this->configurePreviousSession(); + $this->sessionAuthenticationStrategy->expects($this->never())->method('onAuthentication'); + + $token = $this->createMock(NullToken::class); + $token->expects($this->once()) + ->method('getUserIdentifier') + ->willReturn('test'); + $previousToken = $this->createMock(NullToken::class); + $previousToken->expects($this->once()) + ->method('getUserIdentifier') + ->willReturn('test'); + + $event = new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('test', function () {})), $token, $this->request, null, 'main_firewall', $previousToken); + + $this->listener->onSuccessfulLogin($event); + } + private function createEvent($firewallName) { return new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('test', function ($username) { return new InMemoryUser($username, null); })), $this->token, $this->request, null, $firewallName); diff --git a/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php b/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php index 1f5a65ac0b926..d81fc80c8de8e 100644 --- a/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php @@ -59,7 +59,7 @@ public function testNotOverrideUserLoader($passport) $this->assertEquals($passport->hasBadge(UserBadge::class) ? $passport->getBadge(UserBadge::class) : null, $badgeBefore); } - public function provideCompletePassports() + public static function provideCompletePassports() { yield [new SelfValidatingPassport(new UserBadge('wouter', function () {}))]; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 6c02847bc4b26..b98dc77651ff8 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -169,7 +169,7 @@ public function testInvalidTokenInSession($token) $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } - public function provideInvalidToken() + public static function provideInvalidToken() { return [ ['foo'], diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 487b0f7caf93f..f05ce5f4315e7 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -64,7 +64,7 @@ public function testAuthenticationExceptionWithEntryPoint(\Exception $exception) $this->assertSame($exception, $event->getThrowable()); } - public function getAuthenticationExceptionProvider() + public static function getAuthenticationExceptionProvider() { return [ [$e = new AuthenticationException(), new HttpException(Response::HTTP_UNAUTHORIZED, '', $e, [], 0)], @@ -183,7 +183,7 @@ public function testUnregister() $this->assertEmpty($dispatcher->getListeners()); } - public function getAccessDeniedExceptionProvider() + public static function getAccessDeniedExceptionProvider() { return [ [new AccessDeniedException()], diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index ec9165ffcbb09..57c23b5ca636a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -204,7 +204,7 @@ public function testLegacyLogoutHandlers() $this->assertSame($response, $event->getResponse()); } - public function provideInvalidCsrfTokens(): array + public static function provideInvalidCsrfTokens(): array { return [ ['invalid'], diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index 73d03e1a27d98..063afc4188f2c 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -267,7 +267,7 @@ public function testInvalidCsrfToken($invalidToken) $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } - public function postOnlyDataProvider(): array + public static function postOnlyDataProvider(): array { return [ [true], @@ -275,7 +275,7 @@ public function postOnlyDataProvider(): array ]; } - public function getUsernameForLength(): array + public static function getUsernameForLength(): array { return [ [str_repeat('x', Security::MAX_USERNAME_LENGTH + 1), false], @@ -283,7 +283,7 @@ public function getUsernameForLength(): array ]; } - public function provideInvalidCsrfTokens(): array + public static function provideInvalidCsrfTokens(): array { return [ ['invalid'], diff --git a/src/Symfony/Component/Security/Http/Tests/Fixtures/DummyAuthenticator.php b/src/Symfony/Component/Security/Http/Tests/Fixtures/DummyAuthenticator.php new file mode 100644 index 0000000000000..0b221813faebc --- /dev/null +++ b/src/Symfony/Component/Security/Http/Tests/Fixtures/DummyAuthenticator.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Http\Tests\Fixtures; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; +use Symfony\Component\Security\Http\Authenticator\Passport\Passport; +use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; + +/** + * @author Alexandre Daubois + */ +class DummyAuthenticator implements AuthenticatorInterface +{ + public function supports(Request $request): ?bool + { + return null; + } + + public function authenticate(Request $request): Passport + { + } + + public function createToken(Passport $passport, string $firewallName): TokenInterface + { + } + + public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response + { + return null; + } + + public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response + { + return null; + } + + public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface + { + } +} diff --git a/src/Symfony/Component/Security/Http/Tests/Fixtures/DummySupportsAuthenticator.php b/src/Symfony/Component/Security/Http/Tests/Fixtures/DummySupportsAuthenticator.php new file mode 100644 index 0000000000000..8e7d394a7499a --- /dev/null +++ b/src/Symfony/Component/Security/Http/Tests/Fixtures/DummySupportsAuthenticator.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Http\Tests\Fixtures; + +use Symfony\Component\HttpFoundation\Request; + +class DummySupportsAuthenticator extends DummyAuthenticator +{ + private $supports; + + public function __construct(?bool $supports) + { + $this->supports = $supports; + } + + public function supports(Request $request): ?bool + { + return $this->supports; + } +} diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php index 4d07f0a100026..4a1ba23ac60ca 100644 --- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php @@ -69,7 +69,7 @@ public function testCreateRedirectResponseWithBadRequestsDomain($url) $this->assertTrue($response->isRedirect('http://localhost/')); } - public function badRequestDomainUrls() + public static function badRequestDomainUrls() { return [ ['http://pirate.net/foo'], @@ -175,7 +175,7 @@ public function testCreateRequestPassesSecurityContextAttributesToTheNewRequest( $this->assertSame('foo', $subRequest->attributes->get($attribute)); } - public function provideSecurityContextAttributes() + public static function provideSecurityContextAttributes() { return [ [Security::AUTHENTICATION_ERROR], diff --git a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php index f2d03eed1c0f1..0d6983620439d 100644 --- a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php @@ -89,7 +89,7 @@ public function testCreateLoginLink($user, array $extraProperties, Request $requ $this->assertSame('https://example.com/login/verify?user=weaverryan&hash=abchash&expires=1601235000', $loginLink->getUrl()); } - public function provideCreateLoginLinkData() + public static function provideCreateLoginLinkData() { yield [ new TestLoginLinkHandlerUser('weaverryan', 'ryan@symfonycasts.com', 'pwhash'), diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index 1cfec9bdca5eb..37e4d753da521 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -119,7 +119,7 @@ public function testLogout(array $options) $this->assertSame($options['httponly'], $cookie->isHttpOnly()); } - public function provideOptionsForLogout() + public static function provideOptionsForLogout() { return [ [['name' => 'foo', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => true]], @@ -259,7 +259,7 @@ public function testLoginSuccessWhenRememberMeParameterIsPositive($value) $service->loginSuccess($request, $response, $token); } - public function getPositiveRememberMeParameterValues() + public static function getPositiveRememberMeParameterValues() { return [ ['true'], diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index ff774506f2a43..792afce133dff 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -107,7 +107,7 @@ public function testAutoLogin($username) $this->assertEquals('foosecret', $returnedToken->getSecret()); } - public function provideUsernamesForAutoLogin() + public static function provideUsernamesForAutoLogin() { return [ ['foouser', 'Simple username'], diff --git a/src/Symfony/Component/Semaphore/LICENSE b/src/Symfony/Component/Semaphore/LICENSE index f2345234aa9ea..0223acd4a01f4 100644 --- a/src/Symfony/Component/Semaphore/LICENSE +++ b/src/Symfony/Component/Semaphore/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2023 Fabien Potencier +Copyright (c) 2016-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Semaphore/Tests/SemaphoreTest.php b/src/Symfony/Component/Semaphore/Tests/SemaphoreTest.php index 994b02e804254..e6697913ad463 100644 --- a/src/Symfony/Component/Semaphore/Tests/SemaphoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/SemaphoreTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Semaphore\Tests; use PHPUnit\Framework\TestCase; -use RuntimeException; use Symfony\Component\Semaphore\Exception\SemaphoreAcquiringException; use Symfony\Component\Semaphore\Exception\SemaphoreExpiredException; use Symfony\Component\Semaphore\Exception\SemaphoreReleasingException; @@ -72,7 +71,7 @@ public function testAcquireThrowException() ->willThrowException(new \RuntimeException()) ; - $this->expectException(RuntimeException::class); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Failed to acquire the "key" semaphore.'); $semaphore->acquire(); @@ -142,7 +141,7 @@ public function testRefreshWhenItFailsHard() ->willThrowException(new \RuntimeException()) ; - $this->expectException(RuntimeException::class); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Failed to define an expiration for the "key" semaphore.'); $semaphore->refresh(); @@ -195,7 +194,7 @@ public function testReleaseWhenItFailsHard() ->willThrowException(new \RuntimeException()) ; - $this->expectException(RuntimeException::class); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Failed to release the "key" semaphore.'); $semaphore->release(); diff --git a/src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTestCase.php similarity index 91% rename from src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTest.php rename to src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTestCase.php index 11bb931684528..b8d8a2ef5ca24 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/AbstractRedisStoreTestCase.php @@ -17,7 +17,7 @@ /** * @author Jérémy Derussé */ -abstract class AbstractRedisStoreTest extends AbstractStoreTest +abstract class AbstractRedisStoreTestCase extends AbstractStoreTestCase { /** * Return a RedisConnection. diff --git a/src/Symfony/Component/Semaphore/Tests/Store/AbstractStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/AbstractStoreTestCase.php similarity index 97% rename from src/Symfony/Component/Semaphore/Tests/Store/AbstractStoreTest.php rename to src/Symfony/Component/Semaphore/Tests/Store/AbstractStoreTestCase.php index 999b0ea8c83f2..4cd89458f5d92 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/AbstractStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/AbstractStoreTestCase.php @@ -21,7 +21,7 @@ * @author Jérémy Derussé * @author Grégoire Pineau */ -abstract class AbstractStoreTest extends TestCase +abstract class AbstractStoreTestCase extends TestCase { abstract protected function getStore(): PersistingStoreInterface; @@ -204,7 +204,7 @@ public function testPutOffExpirationWhenSaveHasNotBeenCalled() $key1 = new Key(__METHOD__, 4, 2); $this->expectException(SemaphoreExpiredException::class); - $this->expectExceptionMessage('The semaphore "Symfony\Component\Semaphore\Tests\Store\AbstractStoreTest::testPutOffExpirationWhenSaveHasNotBeenCalled" has expired: the script returns a positive number.'); + $this->expectExceptionMessage('The semaphore "Symfony\Component\Semaphore\Tests\Store\AbstractStoreTestCase::testPutOffExpirationWhenSaveHasNotBeenCalled" has expired: the script returns a positive number.'); $store->putOffExpiration($key1, 20); } diff --git a/src/Symfony/Component/Semaphore/Tests/Store/PredisStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/PredisStoreTest.php index 81a48815656d9..e186860663bfa 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/PredisStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/PredisStoreTest.php @@ -16,7 +16,7 @@ /** * @author Jérémy Derussé */ -class PredisStoreTest extends AbstractRedisStoreTest +class PredisStoreTest extends AbstractRedisStoreTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Semaphore/Tests/Store/RedisArrayStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/RedisArrayStoreTest.php index 8f5dd8ca3d5ce..5458b16d8e3e9 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/RedisArrayStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/RedisArrayStoreTest.php @@ -18,7 +18,7 @@ * * @requires extension redis */ -class RedisArrayStoreTest extends AbstractRedisStoreTest +class RedisArrayStoreTest extends AbstractRedisStoreTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Semaphore/Tests/Store/RedisClusterStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/RedisClusterStoreTest.php index be463d52d0b5e..dcf643ae84ba7 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/RedisClusterStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/RedisClusterStoreTest.php @@ -18,7 +18,7 @@ * * @requires extension redis */ -class RedisClusterStoreTest extends AbstractRedisStoreTest +class RedisClusterStoreTest extends AbstractRedisStoreTestCase { public static function setUpBeforeClass(): void { diff --git a/src/Symfony/Component/Semaphore/Tests/Store/RedisStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/RedisStoreTest.php index 2eefb9a2c138b..ba6175687e743 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/RedisStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/RedisStoreTest.php @@ -18,7 +18,7 @@ * * @requires extension redis */ -class RedisStoreTest extends AbstractRedisStoreTest +class RedisStoreTest extends AbstractRedisStoreTestCase { protected function setUp(): void { diff --git a/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php b/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php index 8deec34b444b9..2da44ba0a8be8 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php @@ -12,37 +12,43 @@ namespace Symfony\Component\Semaphore\Tests\Store; use PHPUnit\Framework\TestCase; -use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Semaphore\Store\RedisStore; use Symfony\Component\Semaphore\Store\StoreFactory; /** * @author Jérémy Derussé + * + * @requires extension redis */ class StoreFactoryTest extends TestCase { - /** - * @dataProvider validConnections - */ - public function testCreateStore($connection, string $expectedStoreClass) + public function testCreateRedisStore() { - $store = StoreFactory::createStore($connection); + $store = StoreFactory::createStore($this->createMock(\Redis::class)); - $this->assertInstanceOf($expectedStoreClass, $store); + $this->assertInstanceOf(RedisStore::class, $store); } - public function validConnections() + public function testCreateRedisProxyStore() { - if (class_exists(\Redis::class)) { - yield [$this->createMock(\Redis::class), RedisStore::class]; - } - if (class_exists(RedisProxy::class)) { - yield [$this->createMock(RedisProxy::class), RedisStore::class]; + if (!class_exists(RedisProxy::class)) { + $this->markTestSkipped(); } - yield [new \Predis\Client(), RedisStore::class]; - if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) { - yield ['redis://localhost', RedisStore::class]; + + $store = StoreFactory::createStore($this->createMock(RedisProxy::class)); + + $this->assertInstanceOf(RedisStore::class, $store); + } + + public function testCreateRedisAsDsnStore() + { + if (!class_exists(RedisProxy::class)) { + $this->markTestSkipped(); } + + $store = StoreFactory::createStore('redis://localhost'); + + $this->assertInstanceOf(RedisStore::class, $store); } } diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index 4c518145612d2..55f78b1d0e013 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -167,7 +167,7 @@ public function decode(string $data, string $format, array $context = []) $headerCount = array_fill(0, $nbCols, 1); } else { foreach ($cols as $col) { - $header = explode($keySeparator, $col); + $header = explode($keySeparator, $col ?? ''); $headers[] = $header; $headerCount[] = \count($header); } diff --git a/src/Symfony/Component/Serializer/LICENSE b/src/Symfony/Component/Serializer/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Serializer/LICENSE +++ b/src/Symfony/Component/Serializer/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 143ce4a36b07b..6805a29935d9c 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -213,9 +213,9 @@ protected function handleCircularReference(object $object, string $format = null * @param string|object $classOrObject * @param bool $attributesAsString If false, return an array of {@link AttributeMetadataInterface} * - * @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided - * * @return string[]|AttributeMetadataInterface[]|bool + * + * @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided */ protected function getAllowedAttributes($classOrObject, array $context, bool $attributesAsString = false) { diff --git a/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php index ad9fb807aed19..21fac3248cd6e 100644 --- a/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php @@ -25,9 +25,9 @@ final class BackedEnumNormalizer implements NormalizerInterface, DenormalizerInt /** * {@inheritdoc} * - * @throws InvalidArgumentException - * * @return int|string + * + * @throws InvalidArgumentException */ public function normalize($object, string $format = null, array $context = []) { diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index 44ad1771b6245..ebe2f0f69798b 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -44,8 +44,8 @@ public function denormalize($data, string $type, string $format = null, array $c /** * Checks if the given class implements the NormalizableInterface. * - * @param mixed $data Data to normalize - * @param string $format The format being (de-)serialized from or into + * @param mixed $data Data to normalize + * @param string|null $format The format being (de-)serialized from or into * * @return bool */ @@ -57,9 +57,9 @@ public function supportsNormalization($data, string $format = null) /** * Checks if the given class implements the DenormalizableInterface. * - * @param mixed $data Data to denormalize from - * @param string $type The class to which the data should be denormalized - * @param string $format The format being deserialized from + * @param mixed $data Data to denormalize from + * @param string $type The class to which the data should be denormalized + * @param string|null $format The format being deserialized from * * @return bool */ diff --git a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php index 61f5f89ca6fe5..f338c49f851c7 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php @@ -88,10 +88,10 @@ public function supportsNormalization($data, string $format = null) * * @see https://gist.github.com/bgrins/6194623 * + * @return \SplFileInfo + * * @throws InvalidArgumentException * @throws NotNormalizableValueException - * - * @return \SplFileInfo */ public function denormalize($data, string $type, string $format = null, array $context = []) { diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php index 7a02d182768fc..aef500b4dcff0 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php @@ -36,9 +36,9 @@ public function __construct(array $defaultContext = []) /** * {@inheritdoc} * - * @throws InvalidArgumentException - * * @return string + * + * @throws InvalidArgumentException */ public function normalize($object, string $format = null, array $context = []) { @@ -68,10 +68,10 @@ public function hasCacheableSupportsMethod(): bool /** * {@inheritdoc} * + * @return \DateInterval + * * @throws InvalidArgumentException * @throws UnexpectedValueException - * - * @return \DateInterval */ public function denormalize($data, string $type, string $format = null, array $context = []) { diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php index 2d46898f16455..cbce0c529dac9 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php @@ -50,9 +50,9 @@ public function setDefaultContext(array $defaultContext): void /** * {@inheritdoc} * - * @throws InvalidArgumentException - * * @return string + * + * @throws InvalidArgumentException */ public function normalize($object, string $format = null, array $context = []) { @@ -82,9 +82,9 @@ public function supportsNormalization($data, string $format = null) /** * {@inheritdoc} * - * @throws NotNormalizableValueException - * * @return \DateTimeInterface + * + * @throws NotNormalizableValueException */ public function denormalize($data, string $type, string $format = null, array $context = []) { diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php index e7b6665d6fcfd..7d63b76098481 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php @@ -25,9 +25,9 @@ class DateTimeZoneNormalizer implements NormalizerInterface, DenormalizerInterfa /** * {@inheritdoc} * - * @throws InvalidArgumentException - * * @return string + * + * @throws InvalidArgumentException */ public function normalize($object, string $format = null, array $context = []) { @@ -49,9 +49,9 @@ public function supportsNormalization($data, string $format = null) /** * {@inheritdoc} * - * @throws NotNormalizableValueException - * * @return \DateTimeZone + * + * @throws NotNormalizableValueException */ public function denormalize($data, string $type, string $format = null, array $context = []) { diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php index 5b7d7f2288fb9..e3f7113b1dd93 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php @@ -29,10 +29,10 @@ interface DenormalizerInterface /** * Denormalizes data back into an object of the given class. * - * @param mixed $data Data to restore - * @param string $type The expected class to instantiate - * @param string $format Format the given data was extracted from - * @param array $context Options available to the denormalizer + * @param mixed $data Data to restore + * @param string $type The expected class to instantiate + * @param string|null $format Format the given data was extracted from + * @param array $context Options available to the denormalizer * * @return mixed * @@ -49,9 +49,9 @@ public function denormalize($data, string $type, string $format = null, array $c /** * Checks whether the given class is supported for denormalization by this normalizer. * - * @param mixed $data Data to denormalize from - * @param string $type The class to which the data should be denormalized - * @param string $format The format being deserialized from + * @param mixed $data Data to denormalize from + * @param string $type The class to which the data should be denormalized + * @param string|null $format The format being deserialized from * * @return bool */ diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php index 653f949548c41..b282f1dd61f91 100644 --- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php @@ -24,9 +24,9 @@ interface NormalizerInterface /** * Normalizes an object into a set of arrays/scalars. * - * @param mixed $object Object to normalize - * @param string $format Format the normalization result will be encoded as - * @param array $context Context options for the normalizer + * @param mixed $object Object to normalize + * @param string|null $format Format the normalization result will be encoded as + * @param array $context Context options for the normalizer * * @return array|string|int|float|bool|\ArrayObject|null \ArrayObject is used to make sure an empty object is encoded as an object not an array * @@ -41,8 +41,8 @@ public function normalize($object, string $format = null, array $context = []); /** * Checks whether the given class is supported for normalization by this normalizer. * - * @param mixed $data Data to normalize - * @param string $format The format being (de-)serialized from or into + * @param mixed $data Data to normalize + * @param string|null $format The format being (de-)serialized from or into * * @return bool */ diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index d5fda3b8c64b4..c0a49a8089db0 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -257,9 +257,9 @@ public function supportsDenormalization($data, string $type, string $format = nu /** * Returns a matching normalizer. * - * @param mixed $data Data to get the serializer for - * @param string $format Format name, present to give the option to normalizers to act differently based on formats - * @param array $context Options available to the normalizer + * @param mixed $data Data to get the serializer for + * @param string|null $format Format name, present to give the option to normalizers to act differently based on formats + * @param array $context Options available to the normalizer */ private function getNormalizer($data, ?string $format, array $context): ?NormalizerInterface { @@ -295,10 +295,10 @@ private function getNormalizer($data, ?string $format, array $context): ?Normali /** * Returns a matching denormalizer. * - * @param mixed $data Data to restore - * @param string $class The expected class to instantiate - * @param string $format Format name, present to give the option to normalizers to act differently based on formats - * @param array $context Options available to the denormalizer + * @param mixed $data Data to restore + * @param string $class The expected class to instantiate + * @param string|null $format Format name, present to give the option to normalizers to act differently based on formats + * @param array $context Options available to the denormalizer */ private function getDenormalizer($data, string $class, ?string $format, array $context): ?DenormalizerInterface { diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/ContextTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/ContextTest.php index ad79c893b5fed..77c1edca02afb 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/ContextTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/ContextTest.php @@ -41,6 +41,7 @@ public function testThrowsOnEmptyContext() /** * @group legacy + * * @dataProvider provideTestThrowsOnEmptyContextLegacyData */ public function testThrowsOnEmptyContextLegacy(callable $factory) @@ -51,7 +52,7 @@ public function testThrowsOnEmptyContextLegacy(callable $factory) $factory(); } - public function provideTestThrowsOnEmptyContextLegacyData(): iterable + public static function provideTestThrowsOnEmptyContextLegacyData(): iterable { yield 'doctrine-style: value option as empty array' => [function () { new Context(['value' => []]); }]; yield 'doctrine-style: context option as empty array' => [function () { new Context(['context' => []]); }]; @@ -60,6 +61,7 @@ public function provideTestThrowsOnEmptyContextLegacyData(): iterable /** * @group legacy + * * @dataProvider provideTestThrowsOnNonArrayContextData */ public function testThrowsOnNonArrayContext(array $options) @@ -70,7 +72,7 @@ public function testThrowsOnNonArrayContext(array $options) new Context($options); } - public function provideTestThrowsOnNonArrayContextData(): iterable + public static function provideTestThrowsOnNonArrayContextData(): iterable { yield 'non-array context' => [['context' => 'not_an_array']]; yield 'non-array normalization context' => [['normalizationContext' => 'not_an_array']]; @@ -129,6 +131,7 @@ public function testAsContextArg() /** * @requires PHP 8 + * * @dataProvider provideValidInputs */ public function testValidInputs(callable $factory, string $expectedDump) @@ -136,7 +139,7 @@ public function testValidInputs(callable $factory, string $expectedDump) $this->assertDumpEquals($expectedDump, $factory()); } - public function provideValidInputs(): iterable + public static function provideValidInputs(): iterable { yield 'named arguments: with context option' => [ function () { return new Context(...['context' => ['foo' => 'bar']]); }, @@ -216,6 +219,7 @@ function () { return new Context(...['context' => ['foo' => 'bar'], 'groups' => /** * @group legacy + * * @dataProvider provideValidLegacyInputs */ public function testValidLegacyInputs(callable $factory, string $expectedDump) @@ -224,7 +228,7 @@ public function testValidLegacyInputs(callable $factory, string $expectedDump) $this->assertDumpEquals($expectedDump, $factory()); } - public function provideValidLegacyInputs(): iterable + public static function provideValidLegacyInputs(): iterable { yield 'doctrine-style: with context option' => [ function () { return new Context(['context' => ['foo' => 'bar']]); }, diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php index 3d3355e16ae41..e1a7c1ca3323b 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php @@ -33,7 +33,7 @@ public function testNotSetMaxDepthParameter() new MaxDepth([]); } - public function provideInvalidValues() + public static function provideInvalidValues() { return [ [''], diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php index 8ea70a67444a1..2a2ca2bbf3dc0 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php @@ -33,7 +33,7 @@ public function testNotSetSerializedNameParameter() new SerializedName([]); } - public function provideInvalidValues(): array + public static function provideInvalidValues(): array { return [ [''], diff --git a/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php b/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php index 1130c82de7b10..0be95e92121b1 100644 --- a/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php +++ b/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php @@ -20,7 +20,7 @@ class DeserializeNestedArrayOfObjectsTest extends TestCase { - public function provider() + public static function provider() { return [ // from property PhpDoc diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php index 92df80ea98215..06cf6a0617d86 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php @@ -211,6 +211,14 @@ public function testEncodeEmptyArray() { $this->assertEquals("\n\n", $this->encoder->encode([], 'csv')); $this->assertEquals("\n\n", $this->encoder->encode([[]], 'csv')); + $this->assertEquals("\n\n", $this->encoder->encode([['' => null]], 'csv')); + } + + public function testDecodeEmptyData() + { + $data = $this->encoder->decode("\n\n", 'csv'); + + $this->assertSame([['' => null]], $data); } public function testEncodeVariableStructure() diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php index 9fd943211d610..62045972dbe68 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php @@ -43,7 +43,7 @@ public function testDecode($toDecode, $expected, $context) ); } - public function decodeProvider() + public static function decodeProvider() { $stdClass = new \stdClass(); $stdClass->foo = 'bar'; @@ -65,7 +65,7 @@ public function testDecodeWithException($value) $this->decode->decode($value, JsonEncoder::FORMAT); } - public function decodeProviderException() + public static function decodeProviderException() { return [ ["{'foo': 'bar'}"], diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php index 141ff43227a44..779cad6e37958 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php @@ -42,7 +42,7 @@ public function testEncode($toEncode, $expected, $context) ); } - public function encodeProvider() + public static function encodeProvider() { return [ [[], '[]', []], diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php index 13e766af72e45..d82431a8adec3 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php @@ -128,7 +128,7 @@ public function testItDelegatesHasMetadataForCall() $this->assertTrue($compiledClassMetadataFactory->hasMetadataFor(SerializedNameDummy::class)); } - public function valueProvider() + public static function valueProvider() { return [ [Dummy::class], diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTestCase.php similarity index 99% rename from src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php rename to src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTestCase.php index 735568110cd74..5c3a686647010 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTestCase.php @@ -24,7 +24,7 @@ /** * @author Kévin Dunglas */ -abstract class AnnotationLoaderTest extends TestCase +abstract class AnnotationLoaderTestCase extends TestCase { use ContextMappingTestTrait; diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php index c5836f26f9a24..cb1b9d6498c66 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithAttributesTest.php @@ -16,7 +16,7 @@ /** * @requires PHP 8 */ -class AnnotationLoaderWithAttributesTest extends AnnotationLoaderTest +class AnnotationLoaderWithAttributesTest extends AnnotationLoaderTestCase { protected function createLoader(): AnnotationLoader { diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php index 37675a49d94ac..cfb1547c503cd 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderWithDoctrineAnnotationsTest.php @@ -14,7 +14,7 @@ use Doctrine\Common\Annotations\AnnotationReader; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; -class AnnotationLoaderWithDoctrineAnnotationsTest extends AnnotationLoaderTest +class AnnotationLoaderWithDoctrineAnnotationsTest extends AnnotationLoaderTestCase { protected function createLoader(): AnnotationLoader { diff --git a/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php b/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php index d3bf3e12635a2..e4d419e454f16 100644 --- a/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php +++ b/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php @@ -44,7 +44,7 @@ public function testDenormalize($underscored, $camelCased, $useLowerCamelCase) $this->assertEquals($nameConverter->denormalize($underscored), $camelCased); } - public function attributeProvider() + public static function attributeProvider() { return [ ['coop_tilleuls', 'coopTilleuls', true], diff --git a/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php b/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php index 119edfbfb954d..e0c2d4fafabb6 100644 --- a/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php +++ b/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php @@ -97,7 +97,7 @@ public function testDenormalizeWithFallback($expected, $propertyName) $this->assertEquals($expected, $nameConverter->denormalize($propertyName, SerializedNameDummy::class)); } - public function attributeProvider(): array + public static function attributeProvider(): array { return [ ['foo', 'baz'], @@ -107,7 +107,7 @@ public function attributeProvider(): array ]; } - public function fallbackAttributeProvider(): array + public static function fallbackAttributeProvider(): array { return [ ['foo', 'baz'], @@ -141,7 +141,7 @@ public function testDenormalizeWithGroups($expected, $propertyName, $context = [ $this->assertEquals($expected, $nameConverter->denormalize($propertyName, OtherSerializedNameDummy::class, null, $context)); } - public function attributeAndContextProvider() + public static function attributeAndContextProvider() { return [ ['buz', 'buz', ['groups' => ['a']]], diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php index ee305403837c2..822b21dd5e411 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -201,7 +201,7 @@ public function testObjectWithVariadicConstructorTypedArguments(AbstractNormaliz } } - public function getNormalizer() + public static function getNormalizer() { $extractor = new PhpDocExtractor(); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php index d558c126c5b44..4dd1779489c81 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php @@ -128,7 +128,7 @@ public function testNormalizePayloadFields($fields, array $expected = null) $this->assertSame($expected, $violation['payload']); } - public function payloadFieldsProvider(): iterable + public static function payloadFieldsProvider(): iterable { yield [['severity', 'anotherField1'], ['severity' => 'warning']]; yield [null, ['severity' => 'warning', 'anotherField2' => 'aValue']]; diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php index 02bd050bd395b..8c55ac1ab2454 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php @@ -130,7 +130,7 @@ public function testInvalidData($uri) $this->normalizer->denormalize($uri, 'SplFileObject'); } - public function invalidUriProvider() + public static function invalidUriProvider() { return [ ['dataxbase64'], @@ -156,7 +156,7 @@ public function testValidData($uri) $this->assertInstanceOf(\SplFileObject::class, $this->normalizer->denormalize($uri, 'SplFileObject')); } - public function validUriProvider() + public static function validUriProvider() { return [ ['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC'], diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php index 36779e544bced..cfe8c573c9c50 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php @@ -31,7 +31,7 @@ protected function setUp(): void $this->normalizer = new DateIntervalNormalizer(); } - public function dataProviderISO() + public static function dataProviderISO() { $data = [ ['P%YY%MM%DDT%HH%IM%SS', 'P00Y00M00DT00H00M00S', 'PT0S'], diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php index 85122918faf36..8f368deca68b3 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php @@ -73,7 +73,7 @@ public function testNormalizeUsingTimeZonePassedInContext($expected, $input, $ti ])); } - public function normalizeUsingTimeZonePassedInContextProvider() + public static function normalizeUsingTimeZonePassedInContextProvider() { yield ['2016-12-01T00:00:00+00:00', new \DateTime('2016/12/01', new \DateTimeZone('UTC')), null]; yield ['2016-12-01T00:00:00+09:00', new \DateTime('2016/12/01', new \DateTimeZone('Japan')), new \DateTimeZone('Japan')]; @@ -99,7 +99,7 @@ public function testNormalizeUsingTimeZonePassedInContextAndFormattedWithMicrose ); } - public function normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider() + public static function normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider() { yield [ '2018-12-01T18:03:06.067634', @@ -211,7 +211,7 @@ public function testDenormalizeUsingTimezonePassedInContext($input, $expected, $ $this->assertEquals($expected, $actual); } - public function denormalizeUsingTimezonePassedInContextProvider() + public static function denormalizeUsingTimezonePassedInContextProvider() { yield 'with timezone' => [ '2016/12/01 17:35:00', diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipUninitializedValuesTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipUninitializedValuesTestTrait.php index 038965730c207..0d17ba46dc167 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipUninitializedValuesTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipUninitializedValuesTestTrait.php @@ -23,6 +23,7 @@ abstract protected function getNormalizerForSkipUninitializedValues(): Normalize /** * @requires PHP 7.4 + * * @dataProvider skipUninitializedValuesFlagProvider */ public function testSkipUninitializedValues(array $context) diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/UidNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/UidNormalizerTest.php index 643e1f809abb9..72e6b64c345a4 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/UidNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/UidNormalizerTest.php @@ -46,7 +46,7 @@ public function testSupportsNormalization() $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass())); } - public function normalizeProvider() + public static function normalizeProvider() { $uidFormats = [null, 'canonical', 'base58', 'base32', 'rfc4122']; $data = [ @@ -117,7 +117,7 @@ public function testNormalize(string $expected, AbstractUid $uid, ?string $uidFo ] : [])); } - public function dataProvider() + public static function dataProvider() { return [ ['9b7541de-6f87-11ea-ab3c-9da9a81562fc', UuidV1::class], diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index b2a33cbc0e5db..957330faa3e39 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -550,7 +550,7 @@ public function testNormalizeTransformEmptyArrayObjectToArray() $this->assertSame('{"foo":[],"bar":["notempty"],"baz":{"nested":[]},"a":{"nested":[]},"b":[]}', $serializer->serialize($object, 'json')); } - public function provideObjectOrCollectionTests() + public static function provideObjectOrCollectionTests() { $serializer = new Serializer( [ @@ -1238,7 +1238,7 @@ public function testNoCollectDenormalizationErrorsWithWrongEnum() } } - public function provideCollectDenormalizationErrors() + public static function provideCollectDenormalizationErrors() { return [ [null], diff --git a/src/Symfony/Component/Stopwatch/LICENSE b/src/Symfony/Component/Stopwatch/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Stopwatch/LICENSE +++ b/src/Symfony/Component/Stopwatch/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchPeriodTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchPeriodTest.php index 81010a79413fd..37417ae439512 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchPeriodTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchPeriodTest.php @@ -43,7 +43,7 @@ public function testGetDuration($start, $end, $useMorePrecision, $duration) $this->assertEqualsWithDelta($duration, $period->getDuration(), \PHP_FLOAT_EPSILON); } - public function provideTimeValues() + public static function provideTimeValues() { yield [0, false, 0]; yield [0, true, 0.0]; @@ -53,7 +53,7 @@ public function provideTimeValues() yield [2.71, true, 2.71]; } - public function provideDurationValues() + public static function provideDurationValues() { yield [0, 0, false, 0]; yield [0, 0, true, 0.0]; diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index 1bc6f88fdac22..80b8326aee722 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -37,8 +37,8 @@ abstract class AbstractUnicodeString extends AbstractString private const ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; // the subset of folded case mappings that is not in lower case mappings - private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'İ', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ']; - private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'i̇', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ']; + private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ']; + private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ']; // the subset of upper case mappings that map one code point to many code points private const UPPER_FROM = ['ß', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', 'ΐ', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ']; diff --git a/src/Symfony/Component/String/LICENSE b/src/Symfony/Component/String/LICENSE index 5c7ba0551cb65..f37c76b591dbd 100644 --- a/src/Symfony/Component/String/LICENSE +++ b/src/Symfony/Component/String/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php b/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php index a0cf2068f9476..d25fbdee57b6f 100644 --- a/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php +++ b/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php @@ -110,7 +110,7 @@ public function testWordwrap($expected, $actual, $length, $break, $cut = false) $this->assertEquals($expected, $actual); } - public function wordwrapProvider() + public static function wordwrapProvider() { return [ [ diff --git a/src/Symfony/Component/String/Tests/ByteStringTest.php b/src/Symfony/Component/String/Tests/ByteStringTest.php index 22842fbac359f..f8415d54916d0 100644 --- a/src/Symfony/Component/String/Tests/ByteStringTest.php +++ b/src/Symfony/Component/String/Tests/ByteStringTest.php @@ -28,7 +28,7 @@ public function testFromRandom() self::assertSame(32, $random->length()); foreach ($random->chunk() as $char) { - self::assertNotNull((new ByteString('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'))->indexOf($char)); + self::assertNotNull((new ByteString('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'))->indexOf($char)); } } diff --git a/src/Symfony/Component/String/Tests/FunctionsTest.php b/src/Symfony/Component/String/Tests/FunctionsTest.php index a721d8591aa03..6a69106553d19 100644 --- a/src/Symfony/Component/String/Tests/FunctionsTest.php +++ b/src/Symfony/Component/String/Tests/FunctionsTest.php @@ -30,7 +30,7 @@ public function testS(AbstractString $expected, ?string $input) $this->assertEquals($expected, s($input)); } - public function provideSStrings(): array + public static function provideSStrings(): array { return [ [new UnicodeString(''), ''], @@ -50,7 +50,7 @@ public function testU(UnicodeString $expected, ?string $input) $this->assertEquals($expected, u($input)); } - public function provideUStrings(): array + public static function provideUStrings(): array { return [ [new UnicodeString(''), ''], @@ -68,7 +68,7 @@ public function testB(ByteString $expected, ?string $input) $this->assertEquals($expected, b($input)); } - public function provideBStrings(): array + public static function provideBStrings(): array { return [ [new ByteString(''), ''], diff --git a/src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php b/src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php index face92d406897..afe3b63911d39 100644 --- a/src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php +++ b/src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php @@ -16,7 +16,7 @@ class EnglishInflectorTest extends TestCase { - public function singularizeProvider() + public static function singularizeProvider() { // see http://english-zone.com/spelling/plurals.html // see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English @@ -166,7 +166,7 @@ public function singularizeProvider() ]; } - public function pluralizeProvider() + public static function pluralizeProvider() { // see http://english-zone.com/spelling/plurals.html // see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English diff --git a/src/Symfony/Component/String/Tests/Inflector/FrenchInflectorTest.php b/src/Symfony/Component/String/Tests/Inflector/FrenchInflectorTest.php index 1d5bdac2c9e4f..530b0279a7a9e 100644 --- a/src/Symfony/Component/String/Tests/Inflector/FrenchInflectorTest.php +++ b/src/Symfony/Component/String/Tests/Inflector/FrenchInflectorTest.php @@ -16,7 +16,7 @@ class FrenchInflectorTest extends TestCase { - public function pluralizeProvider() + public static function pluralizeProvider() { return [ // Le pluriel par défaut diff --git a/src/Symfony/Component/String/Tests/Slugger/AsciiSluggerTest.php b/src/Symfony/Component/String/Tests/Slugger/AsciiSluggerTest.php index d58c002c40d99..89b5887a4099f 100644 --- a/src/Symfony/Component/String/Tests/Slugger/AsciiSluggerTest.php +++ b/src/Symfony/Component/String/Tests/Slugger/AsciiSluggerTest.php @@ -16,7 +16,7 @@ class AsciiSluggerTest extends TestCase { - public function provideSlugTests(): iterable + public static function provideSlugTests(): iterable { yield ['', '']; yield ['foo', ' foo ']; diff --git a/src/Symfony/Component/String/Tests/SluggerTest.php b/src/Symfony/Component/String/Tests/SluggerTest.php index 4066867e1ae13..6b4fc643f1cd5 100644 --- a/src/Symfony/Component/String/Tests/SluggerTest.php +++ b/src/Symfony/Component/String/Tests/SluggerTest.php @@ -18,6 +18,7 @@ class SluggerTest extends TestCase { /** * @requires extension intl + * * @dataProvider provideSlug */ public function testSlug(string $string, string $locale, string $expectedSlug) diff --git a/src/Symfony/Component/Templating/LICENSE b/src/Symfony/Component/Templating/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Templating/LICENSE +++ b/src/Symfony/Component/Templating/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php index c6676fcde5676..7948e8578f42a 100644 --- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php @@ -135,7 +135,7 @@ public function testRenderForbiddenParameter($name) $engine->render('foo.php', [$name => 'foo']); } - public function forbiddenParameterNames() + public static function forbiddenParameterNames() { return [ ['this'], diff --git a/src/Symfony/Component/Templating/Tests/TemplateNameParserTest.php b/src/Symfony/Component/Templating/Tests/TemplateNameParserTest.php index 19a38dd236258..6c833f7342b72 100644 --- a/src/Symfony/Component/Templating/Tests/TemplateNameParserTest.php +++ b/src/Symfony/Component/Templating/Tests/TemplateNameParserTest.php @@ -40,7 +40,7 @@ public function testParse($name, $ref) $this->assertEquals($template->getLogicalName(), $name); } - public function getLogicalNameToTemplateProvider() + public static function getLogicalNameToTemplateProvider() { return [ ['/path/to/section/name.engine', new TemplateReference('/path/to/section/name.engine', 'engine')], diff --git a/src/Symfony/Component/Translation/Bridge/Crowdin/LICENSE b/src/Symfony/Component/Translation/Bridge/Crowdin/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Translation/Bridge/Crowdin/LICENSE +++ b/src/Symfony/Component/Translation/Bridge/Crowdin/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderFactoryTest.php b/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderFactoryTest.php index e8b641d169a0c..f6013bd226c1f 100644 --- a/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderFactoryTest.php +++ b/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderFactoryTest.php @@ -17,13 +17,13 @@ class CrowdinProviderFactoryTest extends ProviderFactoryTestCase { - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'crowdin://PROJECT_ID:API_TOKEN@default']; yield [false, 'somethingElse://PROJECT_ID:API_TOKEN@default']; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'crowdin://api.crowdin.com', @@ -36,12 +36,12 @@ public function createProvider(): iterable ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://API_TOKEN@default']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield ['crowdin://default']; } diff --git a/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderTest.php b/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderTest.php index 8ecee4d1bfe95..964082ab4682b 100644 --- a/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderTest.php +++ b/src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Bridge\Crowdin\Tests; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\Translation\Bridge\Crowdin\CrowdinProvider; @@ -28,34 +29,34 @@ class CrowdinProviderTest extends ProviderTestCase { - public function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface + public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface { - return new CrowdinProvider($client, $loader, $logger, $this->getXliffFileDumper(), $defaultLocale, $endpoint); + return new CrowdinProvider($client, $loader, $logger, new XliffFileDumper(), $defaultLocale, $endpoint); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'api.crowdin.com'), 'crowdin://api.crowdin.com', ]; yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://domain.api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'domain.api.crowdin.com'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'domain.api.crowdin.com'), 'crowdin://domain.api.crowdin.com', ]; yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://api.crowdin.com:99/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com:99'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'api.crowdin.com:99'), 'crowdin://api.crowdin.com:99', ]; } @@ -148,7 +149,7 @@ public function testCompleteWriteProcessAddFiles() 'validators' => ['post.num_comments' => '{count, plural, one {# comment} other {# comments}}'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -210,7 +211,7 @@ public function testWriteAddFileServerError() 'validators' => ['post.num_comments' => '{count, plural, one {# comment} other {# comments}}'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -282,7 +283,7 @@ public function testWriteUpdateFileServerError() 'validators' => ['post.num_comments' => '{count, plural, one {# comment} other {# comments}}'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -389,7 +390,7 @@ public function testWriteUploadTranslationsServerError() 'messages' => ['a' => 'trans_fr_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -463,7 +464,7 @@ public function testCompleteWriteProcessUpdateFiles() 'messages' => ['a' => 'trans_en_a', 'b' => 'trans_en_b'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -544,7 +545,7 @@ public function testCompleteWriteProcessAddFileAndUploadTranslations(TranslatorB }, ]; - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -552,7 +553,7 @@ public function testCompleteWriteProcessAddFileAndUploadTranslations(TranslatorB $provider->write($translatorBag); } - public function getResponsesForProcessAddFileAndUploadTranslations(): \Generator + public static function getResponsesForProcessAddFileAndUploadTranslations(): \Generator { $arrayLoader = new ArrayLoader(); @@ -650,7 +651,7 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain, ->method('load') ->willReturn($expectedTranslatorBag->getCatalogue($locale)); - $crowdinProvider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $crowdinProvider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2'); @@ -660,7 +661,7 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain, $this->assertEquals($expectedTranslatorBag->getCatalogues(), $translatorBag->getCatalogues()); } - public function getResponsesForOneLocaleAndOneDomain(): \Generator + public static function getResponsesForOneLocaleAndOneDomain(): \Generator { $arrayLoader = new ArrayLoader(); @@ -763,7 +764,7 @@ public function testReadForDefaultLocaleAndOneDomain(string $locale, string $dom ->method('load') ->willReturn($expectedTranslatorBag->getCatalogue($locale)); - $crowdinProvider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $crowdinProvider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2'); @@ -773,7 +774,7 @@ public function testReadForDefaultLocaleAndOneDomain(string $locale, string $dom $this->assertEquals($expectedTranslatorBag->getCatalogues(), $translatorBag->getCatalogues()); } - public function getResponsesForDefaultLocaleAndOneDomain(): \Generator + public static function getResponsesForDefaultLocaleAndOneDomain(): \Generator { $arrayLoader = new ArrayLoader(); @@ -832,7 +833,7 @@ public function testReadServerException() }, ]; - $crowdinProvider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $crowdinProvider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2'); @@ -873,7 +874,7 @@ public function testReadDownloadServerException() }, ]; - $crowdinProvider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $crowdinProvider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2'); @@ -945,7 +946,7 @@ public function testDelete() ], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -984,7 +985,7 @@ public function testDeleteListStringServerException() ], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); @@ -1049,7 +1050,7 @@ public function testDeleteDeleteStringServerException() ], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/', 'auth_bearer' => 'API_TOKEN', ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.crowdin.com/api/v2/projects/1/'); diff --git a/src/Symfony/Component/Translation/Bridge/Crowdin/composer.json b/src/Symfony/Component/Translation/Bridge/Crowdin/composer.json index 86bbd01dc7ee2..438ab7e01743d 100644 --- a/src/Symfony/Component/Translation/Bridge/Crowdin/composer.json +++ b/src/Symfony/Component/Translation/Bridge/Crowdin/composer.json @@ -23,7 +23,7 @@ "php": ">=7.2.5", "symfony/config": "^5.3|^6.0", "symfony/http-client": "^5.3|^6.0", - "symfony/translation": "^5.3|^6.0" + "symfony/translation": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Translation\\Bridge\\Crowdin\\": "" }, diff --git a/src/Symfony/Component/Translation/Bridge/Loco/LICENSE b/src/Symfony/Component/Translation/Bridge/Loco/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Translation/Bridge/Loco/LICENSE +++ b/src/Symfony/Component/Translation/Bridge/Loco/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderFactoryTest.php b/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderFactoryTest.php index 8afb429dfd784..4e928ad2ffe55 100644 --- a/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderFactoryTest.php +++ b/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderFactoryTest.php @@ -17,18 +17,18 @@ class LocoProviderFactoryTest extends ProviderFactoryTestCase { - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'loco://API_KEY@default']; yield [false, 'somethingElse://API_KEY@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://API_KEY@default']; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'loco://localise.biz', @@ -36,7 +36,7 @@ public function createProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield ['loco://default']; } diff --git a/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php b/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php index e38f9bf37f0a6..470aea2bb37bc 100644 --- a/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php +++ b/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Bridge\Loco\Tests; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\Translation\Bridge\Loco\LocoProvider; @@ -28,40 +29,40 @@ class LocoProviderTest extends ProviderTestCase { - public function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface + public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface { return new LocoProvider($client, $loader, $logger, $defaultLocale, $endpoint); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => [ 'Authorization' => 'Loco API_KEY', ], - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'localise.biz/api/'), 'loco://localise.biz/api/', ]; yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://example.com', 'headers' => [ 'Authorization' => 'Loco API_KEY', ], - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'example.com'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'example.com'), 'loco://example.com', ]; yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://example.com:99', 'headers' => [ 'Authorization' => 'Loco API_KEY', ], - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'example.com:99'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'example.com:99'), 'loco://example.com:99', ]; } @@ -243,7 +244,7 @@ public function testCompleteWriteProcess() 'validators' => ['post.num_comments' => '{count, plural, one {# commentaire} other {# commentaires}}'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -277,7 +278,7 @@ public function testWriteCreateAssetServerError() 'messages' => ['a' => 'trans_en_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -329,7 +330,7 @@ public function testWriteCreateTagServerError() 'messages' => ['a' => 'trans_en_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -389,7 +390,7 @@ public function testWriteTagAssetsServerError() 'messages' => ['a' => 'trans_en_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -449,7 +450,7 @@ public function testWriteTagAssetsServerErrorWithComma() 'messages' => ['a' => 'trans_en_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -523,7 +524,7 @@ public function testWriteCreateLocaleServerError() 'messages' => ['a' => 'trans_en_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -600,7 +601,7 @@ public function testWriteGetAssetsIdsServerError() 'messages' => ['a' => 'trans_fr_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -685,7 +686,7 @@ public function testWriteTranslateAssetsServerError() 'messages' => ['a' => 'trans_fr_a'], ])); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => ['Authorization' => 'Loco API_KEY'], ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); @@ -706,12 +707,12 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain, ->method('load') ->willReturn((new XliffFileLoader())->load($responseContent, $locale, $domain)); - $provider = $this->createProvider((new MockHttpClient(new MockResponse($responseContent)))->withOptions([ + $provider = self::createProvider((new MockHttpClient(new MockResponse($responseContent)))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => [ 'Authorization' => 'Loco API_KEY', ], - ]), $loader, $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); + ]), $loader, new NullLogger(), 'en', 'localise.biz/api/'); $translatorBag = $provider->read([$domain], [$locale]); // We don't want to assert equality of metadata here, due to the ArrayLoader usage. foreach ($translatorBag->getCatalogues() as $catalogue) { @@ -744,12 +745,12 @@ public function testReadForManyLocalesAndManyDomains(array $locales, array $doma ->withConsecutive(...$consecutiveLoadArguments) ->willReturnOnConsecutiveCalls(...$consecutiveLoadReturns); - $provider = $this->createProvider((new MockHttpClient($responses))->withOptions([ + $provider = self::createProvider((new MockHttpClient($responses))->withOptions([ 'base_uri' => 'https://localise.biz/api/', 'headers' => [ 'Authorization' => 'Loco API_KEY', ], - ]), $loader, $this->getLogger(), $this->getDefaultLocale(), 'localise.biz/api/'); + ]), $loader, $this->getLogger(), 'en', 'localise.biz/api/'); $translatorBag = $provider->read($domains, $locales); // We don't want to assert equality of metadata here, due to the ArrayLoader usage. foreach ($translatorBag->getCatalogues() as $catalogue) { @@ -771,7 +772,7 @@ public function testDeleteProcess() 'validators' => ['post.num_comments' => '{count, plural, one {# commentaire} other {# commentaires}}'], ])); - $provider = $this->createProvider( + $provider = self::createProvider( new MockHttpClient([ function (string $method, string $url, array $options = []): ResponseInterface { $this->assertSame('GET', $method); @@ -816,7 +817,7 @@ public function testDeleteServerError() 'messages' => ['a' => 'trans_en_a'], ])); - $provider = $this->createProvider( + $provider = self::createProvider( new MockHttpClient([ function (string $method, string $url, array $options = []): ResponseInterface { $this->assertSame('GET', $method); @@ -844,7 +845,7 @@ function (string $method, string $url): MockResponse { $provider->delete($translatorBag); } - public function getResponsesForOneLocaleAndOneDomain(): \Generator + public static function getResponsesForOneLocaleAndOneDomain(): \Generator { $arrayLoader = new ArrayLoader(); @@ -909,7 +910,7 @@ public function getResponsesForOneLocaleAndOneDomain(): \Generator ]; } - public function getResponsesForManyLocalesAndManyDomains(): \Generator + public static function getResponsesForManyLocalesAndManyDomains(): \Generator { $arrayLoader = new ArrayLoader(); diff --git a/src/Symfony/Component/Translation/Bridge/Loco/composer.json b/src/Symfony/Component/Translation/Bridge/Loco/composer.json index 01f804e339a90..de6352c288e53 100644 --- a/src/Symfony/Component/Translation/Bridge/Loco/composer.json +++ b/src/Symfony/Component/Translation/Bridge/Loco/composer.json @@ -20,7 +20,7 @@ "symfony/http-client": "^5.3|^6.0", "symfony/config": "^5.3|^6.0", "symfony/polyfill-php80": "^1.23", - "symfony/translation": "^5.3|^6.0" + "symfony/translation": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Translation\\Bridge\\Loco\\": "" }, diff --git a/src/Symfony/Component/Translation/Bridge/Lokalise/LICENSE b/src/Symfony/Component/Translation/Bridge/Lokalise/LICENSE index d354b95ffee02..99c6bdf356ee7 100644 --- a/src/Symfony/Component/Translation/Bridge/Lokalise/LICENSE +++ b/src/Symfony/Component/Translation/Bridge/Lokalise/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2023 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderFactoryTest.php b/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderFactoryTest.php index df9ce688f8791..7e18188c3f625 100644 --- a/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderFactoryTest.php +++ b/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderFactoryTest.php @@ -20,18 +20,18 @@ class LokaliseProviderFactoryTest extends ProviderFactoryTestCase { - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'lokalise://PROJECT_ID:API_KEY@default']; yield [false, 'somethingElse://PROJECT_ID:API_KEY@default']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://PROJECT_ID:API_KEY@default']; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'lokalise://api.lokalise.com', @@ -39,7 +39,7 @@ public function createProvider(): iterable ]; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield ['lokalise://default']; } diff --git a/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php b/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php index 0c3b7d511aa43..9859798efb36e 100644 --- a/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php +++ b/src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Bridge\Lokalise\Tests; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\Translation\Bridge\Lokalise\LokaliseProvider; @@ -28,34 +29,34 @@ class LokaliseProviderTest extends ProviderTestCase { - public function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface + public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface { return new LokaliseProvider($client, $loader, $logger, $defaultLocale, $endpoint); } - public function toStringProvider(): iterable + public static function toStringProvider(): iterable { yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://api.lokalise.com/api2/projects/PROJECT_ID/', 'headers' => ['X-Api-Token' => 'API_KEY'], - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'api.lokalise.com'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'api.lokalise.com'), 'lokalise://api.lokalise.com', ]; yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://example.com', 'headers' => ['X-Api-Token' => 'API_KEY'], - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'example.com'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'example.com'), 'lokalise://example.com', ]; yield [ - $this->createProvider($this->getClient()->withOptions([ + self::createProvider((new MockHttpClient())->withOptions([ 'base_uri' => 'https://example.com:99', 'headers' => ['X-Api-Token' => 'API_KEY'], - ]), $this->getLoader(), $this->getLogger(), $this->getDefaultLocale(), 'example.com:99'), + ]), new ArrayLoader(), new NullLogger(), 'en', 'example.com:99'), 'lokalise://example.com:99', ]; } @@ -221,7 +222,7 @@ public function testCompleteWriteProcess() return new MockResponse(); }; - $provider = $this->createProvider((new MockHttpClient([ + $provider = self::createProvider((new MockHttpClient([ $getLanguagesResponse, $createLanguagesResponse, $getKeysIdsForMessagesDomainResponse, @@ -257,7 +258,7 @@ public function testWriteGetLanguageServerError() return new MockResponse('', ['http_code' => 500]); }; - $provider = $this->createProvider((new MockHttpClient([ + $provider = self::createProvider((new MockHttpClient([ $getLanguagesResponse, ]))->withOptions([ 'base_uri' => 'https://api.lokalise.com/api2/projects/PROJECT_ID/', @@ -298,7 +299,7 @@ public function testWriteCreateLanguageServerError() return new MockResponse('', ['http_code' => 500]); }; - $provider = $this->createProvider((new MockHttpClient([ + $provider = self::createProvider((new MockHttpClient([ $getLanguagesResponse, $createLanguagesResponse, ]))->withOptions([ @@ -355,7 +356,7 @@ public function testWriteGetKeysIdsServerError() return new MockResponse('', ['http_code' => 500]); }; - $provider = $this->createProvider((new MockHttpClient([ + $provider = self::createProvider((new MockHttpClient([ $getLanguagesResponse, $createLanguagesResponse, $getKeysIdsForMessagesDomainResponse, @@ -435,7 +436,7 @@ public function testWriteCreateKeysServerError() return new MockResponse('', ['http_code' => 500]); }; - $provider = $this->createProvider((new MockHttpClient([ + $provider = self::createProvider((new MockHttpClient([ $getLanguagesResponse, $createLanguagesResponse, $getKeysIdsForMessagesDomainResponse, @@ -527,7 +528,7 @@ public function testWriteUploadTranslationsServerError() return new MockResponse('', ['http_code' => 500]); }; - $provider = $this->createProvider((new MockHttpClient([ + $provider = self::createProvider((new MockHttpClient([ $getLanguagesResponse, $createLanguagesResponse, $getKeysIdsForMessagesDomainResponse, @@ -585,7 +586,7 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain, ->method('load') ->willReturn((new XliffFileLoader())->load($responseContent, $locale, $domain)); - $provider = $this->createProvider((new MockHttpClient($response))->withOptions([ + $provider = self::createProvider((new MockHttpClient($response))->withOptions([ 'base_uri' => 'https://api.lokalise.com/api2/projects/PROJECT_ID/', 'headers' => ['X-Api-Token' => 'API_KEY'], ]), $loader, $this->getLogger(), $this->getDefaultLocale(), 'api.lokalise.com'); @@ -629,7 +630,7 @@ public function testReadForManyLocalesAndManyDomains(array $locales, array $doma ->withConsecutive(...$consecutiveLoadArguments) ->willReturnOnConsecutiveCalls(...$consecutiveLoadReturns); - $provider = $this->createProvider((new MockHttpClient($response))->withOptions([ + $provider = self::createProvider((new MockHttpClient($response))->withOptions([ 'base_uri' => 'https://api.lokalise.com/api2/projects/PROJECT_ID/', 'headers' => ['X-Api-Token' => 'API_KEY'], ]), $loader, $this->getLogger(), $this->getDefaultLocale(), 'api.lokalise.com'); @@ -708,7 +709,7 @@ public function testDeleteProcess() 'domain_without_missing_messages' => [], ])); - $provider = $this->createProvider( + $provider = self::createProvider( new MockHttpClient([ $getKeysIdsForMessagesDomainResponse, $getKeysIdsForValidatorsDomainResponse, @@ -723,7 +724,7 @@ public function testDeleteProcess() $provider->delete($translatorBag); } - public function getResponsesForOneLocaleAndOneDomain(): \Generator + public static function getResponsesForOneLocaleAndOneDomain(): \Generator { $arrayLoader = new ArrayLoader(); @@ -788,7 +789,7 @@ public function getResponsesForOneLocaleAndOneDomain(): \Generator ]; } - public function getResponsesForManyLocalesAndManyDomains(): \Generator + public static function getResponsesForManyLocalesAndManyDomains(): \Generator { $arrayLoader = new ArrayLoader(); diff --git a/src/Symfony/Component/Translation/Bridge/Lokalise/composer.json b/src/Symfony/Component/Translation/Bridge/Lokalise/composer.json index a6904d6e63ffc..944a7dff5d2b6 100644 --- a/src/Symfony/Component/Translation/Bridge/Lokalise/composer.json +++ b/src/Symfony/Component/Translation/Bridge/Lokalise/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "symfony/config": "^5.3|^6.0", "symfony/http-client": "^5.3|^6.0", - "symfony/translation": "^5.3|^6.0" + "symfony/translation": "^5.4.21|^6.2.7" }, "autoload": { "psr-4": { "Symfony\\Component\\Translation\\Bridge\\Lokalise\\": "" }, diff --git a/src/Symfony/Component/Translation/CHANGELOG.md b/src/Symfony/Component/Translation/CHANGELOG.md index 160b5e694fbcb..93615dcac2368 100644 --- a/src/Symfony/Component/Translation/CHANGELOG.md +++ b/src/Symfony/Component/Translation/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +5.4.21 +------ + + * [BC BREAK] The following data providers for `ProviderFactoryTestCase` are now static: + `supportsProvider()`, `createProvider()`, `unsupportedSchemeProvider()`and `incompleteDsnProvider()` + * [BC BREAK] `ProviderTestCase::toStringProvider()` is now static + 5.4 --- diff --git a/src/Symfony/Component/Translation/LICENSE b/src/Symfony/Component/Translation/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Translation/LICENSE +++ b/src/Symfony/Component/Translation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php index 7e3391ecba2ad..6b7834e675a4b 100644 --- a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php @@ -71,7 +71,7 @@ public function load($resource, string $locale, string $domain = 'messages') * * @param \ResourceBundle $rb The ResourceBundle that will be flattened * @param array $messages Used internally for recursive calls - * @param string $path Current path being parsed, used internally for recursive calls + * @param string|null $path Current path being parsed, used internally for recursive calls * * @return array */ diff --git a/src/Symfony/Component/Translation/MessageCatalogueInterface.php b/src/Symfony/Component/Translation/MessageCatalogueInterface.php index cf7746c239962..965bf008f8ca4 100644 --- a/src/Symfony/Component/Translation/MessageCatalogueInterface.php +++ b/src/Symfony/Component/Translation/MessageCatalogueInterface.php @@ -41,7 +41,7 @@ public function getDomains(); * * If $domain is null, it returns all messages. * - * @param string $domain The domain name + * @param string|null $domain The domain name * * @return array */ diff --git a/src/Symfony/Component/Translation/Test/ProviderFactoryTestCase.php b/src/Symfony/Component/Translation/Test/ProviderFactoryTestCase.php index 6d5f4b7bf7dca..5df82ebe227da 100644 --- a/src/Symfony/Component/Translation/Test/ProviderFactoryTestCase.php +++ b/src/Symfony/Component/Translation/Test/ProviderFactoryTestCase.php @@ -42,17 +42,17 @@ abstract public function createFactory(): ProviderFactoryInterface; /** * @return iterable */ - abstract public function supportsProvider(): iterable; + abstract public static function supportsProvider(): iterable; /** - * @return iterable + * @return iterable */ - abstract public function createProvider(): iterable; + abstract public static function createProvider(): iterable; /** * @return iterable */ - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { return []; } @@ -60,7 +60,7 @@ public function unsupportedSchemeProvider(): iterable /** * @return iterable */ - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { return []; } diff --git a/src/Symfony/Component/Translation/Test/ProviderTestCase.php b/src/Symfony/Component/Translation/Test/ProviderTestCase.php index 4eb08604ba193..cb8a03fc381e1 100644 --- a/src/Symfony/Component/Translation/Test/ProviderTestCase.php +++ b/src/Symfony/Component/Translation/Test/ProviderTestCase.php @@ -34,12 +34,12 @@ abstract class ProviderTestCase extends TestCase protected $loader; protected $xliffFileDumper; - abstract public function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface; + abstract public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface; /** - * @return iterable + * @return iterable */ - abstract public function toStringProvider(): iterable; + abstract public static function toStringProvider(): iterable; /** * @dataProvider toStringProvider diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTestCase.php similarity index 97% rename from src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php rename to src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTestCase.php index 30fc1171ede60..d6b67d27b53c8 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTestCase.php @@ -15,7 +15,7 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\MessageCatalogueInterface; -abstract class AbstractOperationTest extends TestCase +abstract class AbstractOperationTestCase extends TestCase { public function testGetEmptyDomains() { diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php index 1c9bcbc265571..d5bfc0e12bef2 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\MessageCatalogueInterface; -class MergeOperationTest extends AbstractOperationTest +class MergeOperationTest extends AbstractOperationTestCase { public function testGetMessagesFromSingleDomain() { diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php index 6f4de858870dc..1b376394eaa1b 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\MessageCatalogueInterface; -class TargetOperationTest extends AbstractOperationTest +class TargetOperationTest extends AbstractOperationTestCase { public function testGetMessagesFromSingleDomain() { diff --git a/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php index c002fc7532b1f..7ae435afbeb6a 100644 --- a/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php @@ -614,7 +614,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): \Generator + public static function provideCompletionSuggestions(): \Generator { yield 'provider' => [ [''], diff --git a/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php index 9fcd0d77b183b..b174c5c0cfaa4 100644 --- a/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php @@ -340,7 +340,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): \Generator + public static function provideCompletionSuggestions(): \Generator { yield 'provider' => [ [''], diff --git a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php index 3c98c2055a4d7..3b9dca6d18340 100644 --- a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php @@ -240,7 +240,7 @@ protected function tearDown(): void @rmdir(sys_get_temp_dir().'/translation-xliff-lint-test'); } - public function provideStrictFilenames() + public static function provideStrictFilenames() { yield [false, 'messages.%locale%.xlf', 'en', false]; yield [false, 'messages.%locale%.xlf', 'es', true]; @@ -262,7 +262,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option' => [['--format', ''], ['txt', 'json', 'github']]; } diff --git a/src/Symfony/Component/Translation/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Translation/Tests/Exception/UnsupportedSchemeExceptionTest.php index 5fa018d8090a1..2eb022ec4bbaf 100644 --- a/src/Symfony/Component/Translation/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Translation/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -47,7 +47,7 @@ public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme, ); } - public function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator { yield ['crowdin', 'symfony/crowdin-translation-provider']; yield ['loco', 'symfony/loco-translation-provider']; @@ -65,7 +65,7 @@ public function testMessageWhereSchemeIsNotPartOfSchemeToPackageMap(string $expe ); } - public function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator { yield [ 'The "somethingElse" scheme is not supported.', diff --git a/src/Symfony/Component/Translation/Tests/Extractor/PhpExtractorTest.php b/src/Symfony/Component/Translation/Tests/Extractor/PhpExtractorTest.php index 82ddfe0e8aeac..5a84fb6f53974 100644 --- a/src/Symfony/Component/Translation/Tests/Extractor/PhpExtractorTest.php +++ b/src/Symfony/Component/Translation/Tests/Extractor/PhpExtractorTest.php @@ -151,7 +151,7 @@ public function testExtractionFromIndentedHeredocNowdoc() $this->assertEquals($expectedCatalogue, $catalogue->all()); } - public function resourcesProvider() + public static function resourcesProvider() { $directory = __DIR__.'/../fixtures/extractor/'; $phpFiles = []; diff --git a/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php b/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php index b904c8fc76211..4bf8ed43e8389 100644 --- a/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php +++ b/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php @@ -69,7 +69,7 @@ public function testFormatWithNamedArguments() $this->assertEquals('Fabien invites Guilherme as one of the 9 people invited to his party.', $message); } - public function provideDataForFormat() + public static function provideDataForFormat() { return [ [ diff --git a/src/Symfony/Component/Translation/Tests/Formatter/MessageFormatterTest.php b/src/Symfony/Component/Translation/Tests/Formatter/MessageFormatterTest.php index 6e25eed3fe032..46e0e09c3579b 100644 --- a/src/Symfony/Component/Translation/Tests/Formatter/MessageFormatterTest.php +++ b/src/Symfony/Component/Translation/Tests/Formatter/MessageFormatterTest.php @@ -24,7 +24,7 @@ public function testFormat($expected, $message, $parameters = []) $this->assertEquals($expected, $this->getMessageFormatter()->format($message, 'en', $parameters)); } - public function getTransMessages() + public static function getTransMessages() { return [ [ diff --git a/src/Symfony/Component/Translation/Tests/Provider/DsnTest.php b/src/Symfony/Component/Translation/Tests/Provider/DsnTest.php index 99e3a60386f16..6240e7c4e6e95 100644 --- a/src/Symfony/Component/Translation/Tests/Provider/DsnTest.php +++ b/src/Symfony/Component/Translation/Tests/Provider/DsnTest.php @@ -35,7 +35,7 @@ public function testConstruct(string $dsnString, string $scheme, string $host, s $this->assertSame($options, $dsn->getOptions()); } - public function constructProvider(): iterable + public static function constructProvider(): iterable { yield 'simple dsn' => [ 'scheme://localhost', @@ -151,7 +151,7 @@ public function testInvalidDsn(string $dsnString, string $exceptionMessage) new Dsn($dsnString); } - public function invalidDsnProvider(): iterable + public static function invalidDsnProvider(): iterable { yield [ 'some://', @@ -179,7 +179,7 @@ public function testGetOption($expected, string $dsnString, string $option, stri $this->assertSame($expected, $dsn->getOption($option, $default)); } - public function getOptionProvider(): iterable + public static function getOptionProvider(): iterable { yield [ 'foo', @@ -217,7 +217,7 @@ public function testGetRequiredOption(string $expectedValue, string $options, st $this->assertSame($expectedValue, $dsn->getRequiredOption($option)); } - public function getRequiredOptionProvider(): iterable + public static function getRequiredOptionProvider(): iterable { yield [ 'value', @@ -245,7 +245,7 @@ public function testGetRequiredOptionThrowsMissingRequiredOptionException(string $dsn->getRequiredOption($option); } - public function getRequiredOptionThrowsMissingRequiredOptionExceptionProvider(): iterable + public static function getRequiredOptionThrowsMissingRequiredOptionExceptionProvider(): iterable { yield [ 'The option "foo_bar" is required but missing.', diff --git a/src/Symfony/Component/Translation/Tests/PseudoLocalizationTranslatorTest.php b/src/Symfony/Component/Translation/Tests/PseudoLocalizationTranslatorTest.php index 895586fde7ee2..e69e669c205af 100644 --- a/src/Symfony/Component/Translation/Tests/PseudoLocalizationTranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/PseudoLocalizationTranslatorTest.php @@ -26,24 +26,24 @@ public function testTrans(string $expected, string $input, array $options = []) $this->assertSame($expected, (new PseudoLocalizationTranslator(new IdentityTranslator(), $options))->trans($input)); } - public function provideTrans(): array + public static function provideTrans(): array { return [ ['[ƒöö⭐ ≤þ≥ƁÅŔ≤⁄þ≥]', 'foo⭐

BAR

'], // Test defaults - ['before after', 'before after', $this->getIsolatedOptions(['parse_html' => true])], - ['ƀéƒöŕé  åƒţéŕ', 'before after', $this->getIsolatedOptions(['parse_html' => true, 'accents' => true])], - ['ƀéƒöŕé  åƒţéŕ', 'before after', $this->getIsolatedOptions(['parse_html' => true, 'localizable_html_attributes' => ['data-label', 'title'], 'accents' => true])], - [' ¡″♯€‰⅋´{}⁎⁺،‐·⁄⓪①②③④⑤⑥⑦⑧⑨∶⁏≤≂≥¿՞ÅƁÇÐÉƑĜĤÎĴĶĻṀÑÖÞǪŔŠŢÛṼŴẊÝŽ⁅∖⁆˄‿‵åƀçðéƒĝĥîĵķļɱñöþǫŕšţûṽŵẋýž(¦)˞', ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', $this->getIsolatedOptions(['accents' => true])], - ['foo

bar

~~~~~~~~~~ ~~', 'foo

bar

', $this->getIsolatedOptions(['expansion_factor' => 2.0])], - ['foo

bar

~~~ ~~', 'foo

bar

', $this->getIsolatedOptions(['parse_html' => true, 'expansion_factor' => 2.0])], // Only the visible text length is expanded - ['foobar ~~', 'foobar', $this->getIsolatedOptions(['expansion_factor' => 1.35])], // 6*1.35 = 8.1 but we round up to 9 - ['[foobar]', 'foobar', $this->getIsolatedOptions(['brackets' => true])], - ['[foobar ~~~]', 'foobar', $this->getIsolatedOptions(['expansion_factor' => 2.0, 'brackets' => true])], // The added brackets are taken into account in the expansion - ['

ƀåŕ

', '

bar

', $this->getIsolatedOptions(['parse_html' => true, 'localizable_html_attributes' => ['data-foo'], 'accents' => true])], - ['

ƀåéŕ

', '

baér

', $this->getIsolatedOptions(['parse_html' => true, 'localizable_html_attributes' => ['data-foo'], 'accents' => true])], - ['

ƀåŕ

', '

bar

', $this->getIsolatedOptions(['parse_html' => true, 'accents' => true])], - ['

″≤″

', '

"<"

', $this->getIsolatedOptions(['parse_html' => true, 'accents' => true])], - ['Symfony is an Open Source, community-driven project with thousands of contributors. ~~~~~~~ ~~ ~~~~ ~~~~~~~ ~~~~~~~ ~~ ~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~~ ~~ ~~~', 'Symfony is an Open Source, community-driven project with thousands of contributors.', $this->getIsolatedOptions(['expansion_factor' => 2.0])], + ['before after', 'before after', self::getIsolatedOptions(['parse_html' => true])], + ['ƀéƒöŕé  åƒţéŕ', 'before after', self::getIsolatedOptions(['parse_html' => true, 'accents' => true])], + ['ƀéƒöŕé  åƒţéŕ', 'before after', self::getIsolatedOptions(['parse_html' => true, 'localizable_html_attributes' => ['data-label', 'title'], 'accents' => true])], + [' ¡″♯€‰⅋´{}⁎⁺،‐·⁄⓪①②③④⑤⑥⑦⑧⑨∶⁏≤≂≥¿՞ÅƁÇÐÉƑĜĤÎĴĶĻṀÑÖÞǪŔŠŢÛṼŴẊÝŽ⁅∖⁆˄‿‵åƀçðéƒĝĥîĵķļɱñöþǫŕšţûṽŵẋýž(¦)˞', ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', self::getIsolatedOptions(['accents' => true])], + ['foo

bar

~~~~~~~~~~ ~~', 'foo

bar

', self::getIsolatedOptions(['expansion_factor' => 2.0])], + ['foo

bar

~~~ ~~', 'foo

bar

', self::getIsolatedOptions(['parse_html' => true, 'expansion_factor' => 2.0])], // Only the visible text length is expanded + ['foobar ~~', 'foobar', self::getIsolatedOptions(['expansion_factor' => 1.35])], // 6*1.35 = 8.1 but we round up to 9 + ['[foobar]', 'foobar', self::getIsolatedOptions(['brackets' => true])], + ['[foobar ~~~]', 'foobar', self::getIsolatedOptions(['expansion_factor' => 2.0, 'brackets' => true])], // The added brackets are taken into account in the expansion + ['

ƀåŕ

', '

bar

', self::getIsolatedOptions(['parse_html' => true, 'localizable_html_attributes' => ['data-foo'], 'accents' => true])], + ['

ƀåéŕ

', '

baér

', self::getIsolatedOptions(['parse_html' => true, 'localizable_html_attributes' => ['data-foo'], 'accents' => true])], + ['

ƀåŕ

', '

bar

', self::getIsolatedOptions(['parse_html' => true, 'accents' => true])], + ['

″≤″

', '

"<"

', self::getIsolatedOptions(['parse_html' => true, 'accents' => true])], + ['Symfony is an Open Source, community-driven project with thousands of contributors. ~~~~~~~ ~~ ~~~~ ~~~~~~~ ~~~~~~~ ~~ ~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~~ ~~ ~~~', 'Symfony is an Open Source, community-driven project with thousands of contributors.', self::getIsolatedOptions(['expansion_factor' => 2.0])], ]; } @@ -60,7 +60,7 @@ public function testInvalidExpansionFactor(float $expansionFactor) ]); } - public function provideInvalidExpansionFactor(): array + public static function provideInvalidExpansionFactor(): array { return [ [0], @@ -69,7 +69,7 @@ public function provideInvalidExpansionFactor(): array ]; } - private function getIsolatedOptions(array $options): array + private static function getIsolatedOptions(array $options): array { return array_replace([ 'parse_html' => false, diff --git a/src/Symfony/Component/Translation/Tests/TranslatableTest.php b/src/Symfony/Component/Translation/Tests/TranslatableTest.php index 914cf6429b581..ce08c8ae1a8b3 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatableTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatableTest.php @@ -47,7 +47,7 @@ public function testToString() $this->assertSame('Symfony is great!', (string) new TranslatableMessage('Symfony is great!')); } - public function getTransTests() + public static function getTransTests() { return [ ['Symfony est super !', new TranslatableMessage('Symfony is great!', [], ''), [ @@ -63,7 +63,7 @@ public function getTransTests() ]; } - public function getFlattenedTransTests() + public static function getFlattenedTransTests() { $messages = [ 'symfony' => [ diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 3720aeb74e047..596b8d4afa982 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -302,7 +302,7 @@ protected function getCatalogue($locale, $messages, $resources = []) return $catalogue; } - public function runForDebugAndProduction() + public static function runForDebugAndProduction() { return [[true], [false]]; } diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index ea8248cb64c8f..a9700228bdf28 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -15,10 +15,8 @@ use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Exception\RuntimeException; -use Symfony\Component\Translation\Formatter\IntlFormatter; use Symfony\Component\Translation\Formatter\IntlFormatterInterface; use Symfony\Component\Translation\Formatter\MessageFormatter; -use Symfony\Component\Translation\Formatter\MessageFormatterInterface; use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Translator; @@ -301,7 +299,7 @@ public function testTransWithFallbackLocaleBis($expectedLocale, $locale) $this->assertEquals('foobar', $translator->trans('bar')); } - public function getFallbackLocales() + public static function getFallbackLocales() { $locales = [ ['en', 'en_US'], @@ -456,7 +454,7 @@ public function testTransNullId() }, $this, Translator::class))(); } - public function getTransFileTests() + public static function getTransFileTests() { return [ ['csv', 'CsvFileLoader'], @@ -471,7 +469,7 @@ public function getTransFileTests() ]; } - public function getTransTests() + public static function getTransTests() { return [ ['Symfony est super !', 'Symfony is great!', 'Symfony est super !', [], 'fr', ''], @@ -481,7 +479,7 @@ public function getTransTests() ]; } - public function getTransICUTests() + public static function getTransICUTests() { $id = '{apples, plural, =0 {There are no apples} one {There is one apple} other {There are # apples}}'; @@ -492,7 +490,7 @@ public function getTransICUTests() ]; } - public function getFlattenedTransTests() + public static function getFlattenedTransTests() { $messages = [ 'symfony' => [ @@ -515,7 +513,7 @@ public function getFlattenedTransTests() ]; } - public function getInvalidLocalesTests() + public static function getInvalidLocalesTests() { return [ ['fr FR'], @@ -532,7 +530,7 @@ public function getInvalidLocalesTests() ]; } - public function getValidLocalesTests() + public static function getValidLocalesTests() { return [ [''], diff --git a/src/Symfony/Component/Translation/Tests/Util/ArrayConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/ArrayConverterTest.php index b0335415e1b3d..8936ef1ae6926 100644 --- a/src/Symfony/Component/Translation/Tests/Util/ArrayConverterTest.php +++ b/src/Symfony/Component/Translation/Tests/Util/ArrayConverterTest.php @@ -24,7 +24,7 @@ public function testDump($input, $expectedOutput) $this->assertEquals($expectedOutput, ArrayConverter::expandToTree($input)); } - public function messagesData() + public static function messagesData() { return [ [ diff --git a/src/Symfony/Component/Uid/LICENSE b/src/Symfony/Component/Uid/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Component/Uid/LICENSE +++ b/src/Symfony/Component/Uid/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php b/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php index 48814de9c72fb..d1116c0a8c9e6 100644 --- a/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php +++ b/src/Symfony/Component/Uid/Tests/Command/GenerateUlidCommandTest.php @@ -119,7 +119,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php b/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php index 65b9f87f7063a..a0ee281c243b6 100644 --- a/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php +++ b/src/Symfony/Component/Uid/Tests/Command/GenerateUuidCommandTest.php @@ -132,7 +132,7 @@ public function testInvalidCombinationOfBasedOptions(array $input) $this->assertStringContainsString('Only one of "--time-based", "--name-based" or "--random-based"', $commandTester->getDisplay()); } - public function provideInvalidCombinationOfBasedOptions() + public static function provideInvalidCombinationOfBasedOptions() { return [ [['--time-based' => 'now', '--name-based' => 'foo']], @@ -153,7 +153,7 @@ public function testExtraNodeOption(array $input) $this->assertStringContainsString('Option "--node" can only be used with "--time-based"', $commandTester->getDisplay()); } - public function provideExtraNodeOption() + public static function provideExtraNodeOption() { return [ [['--node' => 'foo']], @@ -173,7 +173,7 @@ public function testExtraNamespaceOption(array $input) $this->assertStringContainsString('Option "--namespace" can only be used with "--name-based"', $commandTester->getDisplay()); } - public function provideExtraNamespaceOption() + public static function provideExtraNamespaceOption() { return [ [['--namespace' => 'foo']], @@ -248,7 +248,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Component/Uid/Tests/UlidTest.php b/src/Symfony/Component/Uid/Tests/UlidTest.php index 50801a840c326..27f06645fccb2 100644 --- a/src/Symfony/Component/Uid/Tests/UlidTest.php +++ b/src/Symfony/Component/Uid/Tests/UlidTest.php @@ -149,7 +149,7 @@ public function testFromBinaryInvalidFormat(string $ulid) Ulid::fromBinary($ulid); } - public function provideInvalidBinaryFormat() + public static function provideInvalidBinaryFormat() { return [ ['01EW2RYKDCT2SAK454KBR2QG08'], @@ -176,7 +176,7 @@ public function testFromBase58InvalidFormat(string $ulid) Ulid::fromBase58($ulid); } - public function provideInvalidBase58Format() + public static function provideInvalidBase58Format() { return [ ["\x01\x77\x05\x8F\x4D\xAC\xD0\xB2\xA9\x90\xA4\x9A\xF0\x2B\xC0\x08"], @@ -203,7 +203,7 @@ public function testFromBase32InvalidFormat(string $ulid) Ulid::fromBase32($ulid); } - public function provideInvalidBase32Format() + public static function provideInvalidBase32Format() { return [ ["\x01\x77\x05\x8F\x4D\xAC\xD0\xB2\xA9\x90\xA4\x9A\xF0\x2B\xC0\x08"], @@ -230,7 +230,7 @@ public function testFromRfc4122InvalidFormat(string $ulid) Ulid::fromRfc4122($ulid); } - public function provideInvalidRfc4122Format() + public static function provideInvalidRfc4122Format() { return [ ["\x01\x77\x05\x8F\x4D\xAC\xD0\xB2\xA9\x90\xA4\x9A\xF0\x2B\xC0\x08"], diff --git a/src/Symfony/Component/Uid/Tests/UuidTest.php b/src/Symfony/Component/Uid/Tests/UuidTest.php index 8e73eb0d2d057..dbf5ea03c1375 100644 --- a/src/Symfony/Component/Uid/Tests/UuidTest.php +++ b/src/Symfony/Component/Uid/Tests/UuidTest.php @@ -38,7 +38,7 @@ public function testConstructorWithInvalidUuid(string $uuid) Uuid::fromString($uuid); } - public function provideInvalidUuids(): iterable + public static function provideInvalidUuids(): iterable { yield ['this is not a uuid']; yield ['these are just thirty-six characters']; @@ -61,7 +61,7 @@ public function testInvalidVariant(string $uuid) new $class($uuid); } - public function provideInvalidVariant(): iterable + public static function provideInvalidVariant(): iterable { yield ['8dac64d3-937a-1e7c-fa1d-d5d6c06a61f5']; yield ['8dac64d3-937a-3e7c-fa1d-d5d6c06a61f5']; @@ -206,7 +206,7 @@ public function testEqualsAgainstOtherType($other) $this->assertFalse((new UuidV4(self::A_UUID_V4))->equals($other)); } - public function provideInvalidEqualType() + public static function provideInvalidEqualType() { yield [null]; yield [self::A_UUID_V1]; @@ -268,7 +268,7 @@ public function testFromBinaryInvalidFormat(string $ulid) Uuid::fromBinary($ulid); } - public function provideInvalidBinaryFormat() + public static function provideInvalidBinaryFormat() { return [ ['01EW2RYKDCT2SAK454KBR2QG08'], @@ -295,7 +295,7 @@ public function testFromBase58InvalidFormat(string $ulid) Uuid::fromBase58($ulid); } - public function provideInvalidBase58Format() + public static function provideInvalidBase58Format() { return [ ["\x41\x4C\x08\x92\x57\x1B\x11\xEB\xBF\x70\x93\xF9\xB0\x82\x2C\x57"], @@ -322,7 +322,7 @@ public function testFromBase32InvalidFormat(string $ulid) Uuid::fromBase32($ulid); } - public function provideInvalidBase32Format() + public static function provideInvalidBase32Format() { return [ ["\x5B\xA8\x32\x72\x45\x6D\x5A\xC0\xAB\xE3\xAA\x8B\xF7\x01\x96\x73"], @@ -349,7 +349,7 @@ public function testFromRfc4122InvalidFormat(string $ulid) Uuid::fromRfc4122($ulid); } - public function provideInvalidRfc4122Format() + public static function provideInvalidRfc4122Format() { return [ ["\x1E\xB5\x71\xB4\x14\xC0\x68\x93\xBF\x70\x2D\x4C\x83\xCF\x75\x5A"], diff --git a/src/Symfony/Component/Validator/.gitattributes b/src/Symfony/Component/Validator/.gitattributes index 84c7add058fb5..c34694db5f725 100644 --- a/src/Symfony/Component/Validator/.gitattributes +++ b/src/Symfony/Component/Validator/.gitattributes @@ -2,3 +2,4 @@ /phpunit.xml.dist export-ignore /.gitattributes export-ignore /.gitignore export-ignore +/Resources/bin/sync-iban-formats.php export-ignore diff --git a/src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php b/src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php index 888f583eb92b6..692b1176b6e58 100644 --- a/src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php @@ -31,7 +31,11 @@ public function validate($value, Constraint $constraint) $validator = $this->context->getValidator(); - $messages = [$constraint->message]; + // Build a first violation to have the base message of the constraint translated + $baseMessageContext = clone $this->context; + $baseMessageContext->buildViolation($constraint->message)->addViolation(); + $baseViolations = $baseMessageContext->getViolations(); + $messages = [(string) $baseViolations->get(\count($baseViolations) - 1)->getMessage()]; foreach ($constraint->constraints as $key => $item) { if (!\in_array($this->context->getGroup(), $item->groups, true)) { diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 215eb16f174fc..173cb6678dc0e 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -20,8 +20,6 @@ * @author Manuel Reinhard * @author Michael Schummel * @author Bernhard Schussek - * - * @see http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/ */ class IbanValidator extends ConstraintValidator { @@ -34,107 +32,135 @@ class IbanValidator extends ConstraintValidator * a BBAN (Basic Bank Account Number) which has a fixed length per country and, * included within it, a bank identifier with a fixed position and a fixed length per country * - * @see https://www.swift.com/sites/default/files/resources/iban_registry.pdf + * @see Resources/bin/sync-iban-formats.php + * @see https://www.swift.com/swift-resource/11971/download?language=en + * @see https://en.wikipedia.org/wiki/International_Bank_Account_Number */ private const FORMATS = [ + // auto-generated 'AD' => 'AD\d{2}\d{4}\d{4}[\dA-Z]{12}', // Andorra - 'AE' => 'AE\d{2}\d{3}\d{16}', // United Arab Emirates + 'AE' => 'AE\d{2}\d{3}\d{16}', // United Arab Emirates (The) 'AL' => 'AL\d{2}\d{8}[\dA-Z]{16}', // Albania 'AO' => 'AO\d{2}\d{21}', // Angola 'AT' => 'AT\d{2}\d{5}\d{11}', // Austria - 'AX' => 'FI\d{2}\d{6}\d{7}\d{1}', // Aland Islands + 'AX' => 'FI\d{2}\d{3}\d{11}', // Finland 'AZ' => 'AZ\d{2}[A-Z]{4}[\dA-Z]{20}', // Azerbaijan 'BA' => 'BA\d{2}\d{3}\d{3}\d{8}\d{2}', // Bosnia and Herzegovina 'BE' => 'BE\d{2}\d{3}\d{7}\d{2}', // Belgium - 'BF' => 'BF\d{2}\d{23}', // Burkina Faso + 'BF' => 'BF\d{2}[\dA-Z]{2}\d{22}', // Burkina Faso 'BG' => 'BG\d{2}[A-Z]{4}\d{4}\d{2}[\dA-Z]{8}', // Bulgaria 'BH' => 'BH\d{2}[A-Z]{4}[\dA-Z]{14}', // Bahrain - 'BI' => 'BI\d{2}\d{12}', // Burundi - 'BJ' => 'BJ\d{2}[A-Z]{1}\d{23}', // Benin - 'BY' => 'BY\d{2}[\dA-Z]{4}\d{4}[\dA-Z]{16}', // Belarus - https://bank.codes/iban/structure/belarus/ - 'BL' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Saint Barthelemy - 'BR' => 'BR\d{2}\d{8}\d{5}\d{10}[A-Z][\dA-Z]', // Brazil - 'CG' => 'CG\d{2}\d{23}', // Congo + 'BI' => 'BI\d{2}\d{5}\d{5}\d{11}\d{2}', // Burundi + 'BJ' => 'BJ\d{2}[\dA-Z]{2}\d{22}', // Benin + 'BL' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'BR' => 'BR\d{2}\d{8}\d{5}\d{10}[A-Z]{1}[\dA-Z]{1}', // Brazil + 'BY' => 'BY\d{2}[\dA-Z]{4}\d{4}[\dA-Z]{16}', // Republic of Belarus + 'CF' => 'CF\d{2}\d{23}', // Central African Republic + 'CG' => 'CG\d{2}\d{23}', // Congo, Republic of the 'CH' => 'CH\d{2}\d{5}[\dA-Z]{12}', // Switzerland - 'CI' => 'CI\d{2}[A-Z]{1}\d{23}', // Ivory Coast - 'CM' => 'CM\d{2}\d{23}', // Cameron - 'CR' => 'CR\d{2}0\d{3}\d{14}', // Costa Rica - 'CV' => 'CV\d{2}\d{21}', // Cape Verde + 'CI' => 'CI\d{2}[A-Z]{1}\d{23}', // Côte d'Ivoire + 'CM' => 'CM\d{2}\d{23}', // Cameroon + 'CR' => 'CR\d{2}\d{4}\d{14}', // Costa Rica + 'CV' => 'CV\d{2}\d{21}', // Cabo Verde 'CY' => 'CY\d{2}\d{3}\d{5}[\dA-Z]{16}', // Cyprus - 'CZ' => 'CZ\d{2}\d{20}', // Czech Republic + 'CZ' => 'CZ\d{2}\d{4}\d{6}\d{10}', // Czechia 'DE' => 'DE\d{2}\d{8}\d{10}', // Germany + 'DJ' => 'DJ\d{2}\d{5}\d{5}\d{11}\d{2}', // Djibouti + 'DK' => 'DK\d{2}\d{4}\d{9}\d{1}', // Denmark 'DO' => 'DO\d{2}[\dA-Z]{4}\d{20}', // Dominican Republic - 'DK' => 'DK\d{2}\d{4}\d{10}', // Denmark - 'DZ' => 'DZ\d{2}\d{20}', // Algeria + 'DZ' => 'DZ\d{2}\d{22}', // Algeria 'EE' => 'EE\d{2}\d{2}\d{2}\d{11}\d{1}', // Estonia - 'ES' => 'ES\d{2}\d{4}\d{4}\d{1}\d{1}\d{10}', // Spain (also includes Canary Islands, Ceuta and Melilla) - 'FI' => 'FI\d{2}\d{6}\d{7}\d{1}', // Finland + 'EG' => 'EG\d{2}\d{4}\d{4}\d{17}', // Egypt + 'ES' => 'ES\d{2}\d{4}\d{4}\d{1}\d{1}\d{10}', // Spain + 'FI' => 'FI\d{2}\d{3}\d{11}', // Finland 'FO' => 'FO\d{2}\d{4}\d{9}\d{1}', // Faroe Islands 'FR' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France - 'GF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Guyana - 'GB' => 'GB\d{2}[A-Z]{4}\d{6}\d{8}', // United Kingdom of Great Britain and Northern Ireland + 'GA' => 'GA\d{2}\d{23}', // Gabon + 'GB' => 'GB\d{2}[A-Z]{4}\d{6}\d{8}', // United Kingdom 'GE' => 'GE\d{2}[A-Z]{2}\d{16}', // Georgia + 'GF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'GG' => 'GB\d{2}[A-Z]{4}\d{6}\d{8}', // United Kingdom 'GI' => 'GI\d{2}[A-Z]{4}[\dA-Z]{15}', // Gibraltar 'GL' => 'GL\d{2}\d{4}\d{9}\d{1}', // Greenland - 'GP' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Guadeloupe + 'GP' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'GQ' => 'GQ\d{2}\d{23}', // Equatorial Guinea 'GR' => 'GR\d{2}\d{3}\d{4}[\dA-Z]{16}', // Greece 'GT' => 'GT\d{2}[\dA-Z]{4}[\dA-Z]{20}', // Guatemala + 'GW' => 'GW\d{2}[\dA-Z]{2}\d{19}', // Guinea-Bissau + 'HN' => 'HN\d{2}[A-Z]{4}\d{20}', // Honduras 'HR' => 'HR\d{2}\d{7}\d{10}', // Croatia 'HU' => 'HU\d{2}\d{3}\d{4}\d{1}\d{15}\d{1}', // Hungary 'IE' => 'IE\d{2}[A-Z]{4}\d{6}\d{8}', // Ireland 'IL' => 'IL\d{2}\d{3}\d{3}\d{13}', // Israel + 'IM' => 'GB\d{2}[A-Z]{4}\d{6}\d{8}', // United Kingdom + 'IQ' => 'IQ\d{2}[A-Z]{4}\d{3}\d{12}', // Iraq 'IR' => 'IR\d{2}\d{22}', // Iran 'IS' => 'IS\d{2}\d{4}\d{2}\d{6}\d{10}', // Iceland 'IT' => 'IT\d{2}[A-Z]{1}\d{5}\d{5}[\dA-Z]{12}', // Italy + 'JE' => 'GB\d{2}[A-Z]{4}\d{6}\d{8}', // United Kingdom 'JO' => 'JO\d{2}[A-Z]{4}\d{4}[\dA-Z]{18}', // Jordan - 'KW' => 'KW\d{2}[A-Z]{4}\d{22}', // KUWAIT + 'KM' => 'KM\d{2}\d{23}', // Comoros + 'KW' => 'KW\d{2}[A-Z]{4}[\dA-Z]{22}', // Kuwait 'KZ' => 'KZ\d{2}\d{3}[\dA-Z]{13}', // Kazakhstan - 'LB' => 'LB\d{2}\d{4}[\dA-Z]{20}', // LEBANON - 'LI' => 'LI\d{2}\d{5}[\dA-Z]{12}', // Liechtenstein (Principality of) + 'LB' => 'LB\d{2}\d{4}[\dA-Z]{20}', // Lebanon + 'LC' => 'LC\d{2}[A-Z]{4}[\dA-Z]{24}', // Saint Lucia + 'LI' => 'LI\d{2}\d{5}[\dA-Z]{12}', // Liechtenstein 'LT' => 'LT\d{2}\d{5}\d{11}', // Lithuania 'LU' => 'LU\d{2}\d{3}[\dA-Z]{13}', // Luxembourg 'LV' => 'LV\d{2}[A-Z]{4}[\dA-Z]{13}', // Latvia + 'LY' => 'LY\d{2}\d{3}\d{3}\d{15}', // Libya + 'MA' => 'MA\d{2}\d{24}', // Morocco 'MC' => 'MC\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Monaco 'MD' => 'MD\d{2}[\dA-Z]{2}[\dA-Z]{18}', // Moldova 'ME' => 'ME\d{2}\d{3}\d{13}\d{2}', // Montenegro - 'MF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Saint Martin (French part) + 'MF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France 'MG' => 'MG\d{2}\d{23}', // Madagascar - 'MK' => 'MK\d{2}\d{3}[\dA-Z]{10}\d{2}', // Macedonia, Former Yugoslav Republic of - 'ML' => 'ML\d{2}[A-Z]{1}\d{23}', // Mali - 'MQ' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Martinique + 'MK' => 'MK\d{2}\d{3}[\dA-Z]{10}\d{2}', // Macedonia + 'ML' => 'ML\d{2}[\dA-Z]{2}\d{22}', // Mali + 'MQ' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France 'MR' => 'MR\d{2}\d{5}\d{5}\d{11}\d{2}', // Mauritania 'MT' => 'MT\d{2}[A-Z]{4}\d{5}[\dA-Z]{18}', // Malta 'MU' => 'MU\d{2}[A-Z]{4}\d{2}\d{2}\d{12}\d{3}[A-Z]{3}', // Mauritius 'MZ' => 'MZ\d{2}\d{21}', // Mozambique - 'NC' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // New Caledonia - 'NL' => 'NL\d{2}[A-Z]{4}\d{10}', // The Netherlands + 'NC' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'NE' => 'NE\d{2}[A-Z]{2}\d{22}', // Niger + 'NI' => 'NI\d{2}[A-Z]{4}\d{24}', // Nicaragua + 'NL' => 'NL\d{2}[A-Z]{4}\d{10}', // Netherlands (The) 'NO' => 'NO\d{2}\d{4}\d{6}\d{1}', // Norway - 'PF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Polynesia + 'PF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France 'PK' => 'PK\d{2}[A-Z]{4}[\dA-Z]{16}', // Pakistan 'PL' => 'PL\d{2}\d{8}\d{16}', // Poland - 'PM' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Saint Pierre et Miquelon + 'PM' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France 'PS' => 'PS\d{2}[A-Z]{4}[\dA-Z]{21}', // Palestine, State of - 'PT' => 'PT\d{2}\d{4}\d{4}\d{11}\d{2}', // Portugal (plus Azores and Madeira) + 'PT' => 'PT\d{2}\d{4}\d{4}\d{11}\d{2}', // Portugal 'QA' => 'QA\d{2}[A-Z]{4}[\dA-Z]{21}', // Qatar - 'RE' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Reunion + 'RE' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France 'RO' => 'RO\d{2}[A-Z]{4}[\dA-Z]{16}', // Romania 'RS' => 'RS\d{2}\d{3}\d{13}\d{2}', // Serbia + 'RU' => 'RU\d{2}\d{9}\d{5}[\dA-Z]{15}', // Russia 'SA' => 'SA\d{2}\d{2}[\dA-Z]{18}', // Saudi Arabia + 'SC' => 'SC\d{2}[A-Z]{4}\d{2}\d{2}\d{16}[A-Z]{3}', // Seychelles + 'SD' => 'SD\d{2}\d{2}\d{12}', // Sudan 'SE' => 'SE\d{2}\d{3}\d{16}\d{1}', // Sweden 'SI' => 'SI\d{2}\d{5}\d{8}\d{2}', // Slovenia - 'SK' => 'SK\d{2}\d{4}\d{6}\d{10}', // Slovak Republic + 'SK' => 'SK\d{2}\d{4}\d{6}\d{10}', // Slovakia 'SM' => 'SM\d{2}[A-Z]{1}\d{5}\d{5}[\dA-Z]{12}', // San Marino - 'SN' => 'SN\d{2}[A-Z]{1}\d{23}', // Senegal - 'TF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Southern Territories + 'SN' => 'SN\d{2}[A-Z]{2}\d{22}', // Senegal + 'SO' => 'SO\d{2}\d{4}\d{3}\d{12}', // Somalia + 'ST' => 'ST\d{2}\d{4}\d{4}\d{11}\d{2}', // Sao Tome and Principe + 'SV' => 'SV\d{2}[A-Z]{4}\d{20}', // El Salvador + 'TD' => 'TD\d{2}\d{23}', // Chad + 'TF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'TG' => 'TG\d{2}[A-Z]{2}\d{22}', // Togo 'TL' => 'TL\d{2}\d{3}\d{14}\d{2}', // Timor-Leste 'TN' => 'TN\d{2}\d{2}\d{3}\d{13}\d{2}', // Tunisia - 'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}', // Turkey + 'TR' => 'TR\d{2}\d{5}\d{1}[\dA-Z]{16}', // Turkey 'UA' => 'UA\d{2}\d{6}[\dA-Z]{19}', // Ukraine 'VA' => 'VA\d{2}\d{3}\d{15}', // Vatican City State - 'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands, British - 'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Wallis and Futuna Islands - 'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Republic of Kosovo - 'YT' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Mayotte + 'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands + 'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Kosovo + 'YT' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France ]; /** diff --git a/src/Symfony/Component/Validator/LICENSE b/src/Symfony/Component/Validator/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Validator/LICENSE +++ b/src/Symfony/Component/Validator/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php b/src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php new file mode 100755 index 0000000000000..fa7ba520cfa02 --- /dev/null +++ b/src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php @@ -0,0 +1,204 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if ('cli' !== \PHP_SAPI) { + throw new \Exception('This script must be run from the command line.'); +} + +/* + * This script syncs IBAN formats from the upstream and updates them into IbanValidator. + * + * Usage: + * php Resources/bin/sync-iban-formats.php + */ + +error_reporting(\E_ALL); + +set_error_handler(static function (int $type, string $msg, string $file, int $line): void { + throw new \ErrorException($msg, 0, $type, $file, $line); +}); + +echo "Collecting IBAN formats...\n"; + +$formats = array_merge( + (new WikipediaIbanProvider())->getIbanFormats(), + (new SwiftRegistryIbanProvider())->getIbanFormats() +); + +printf("Collected %d IBAN formats\n", count($formats)); + +echo "Updating validator...\n"; + +updateValidatorFormats(__DIR__.'/../../Constraints/IbanValidator.php', $formats); + +echo "Done.\n"; + +exit(0); + +function updateValidatorFormats(string $validatorPath, array $formats): void +{ + ksort($formats); + + $formatsContent = "[\n"; + $formatsContent .= " // auto-generated\n"; + + foreach ($formats as $countryCode => [$format, $country]) { + $formatsContent .= " '{$countryCode}' => '{$format}', // {$country}\n"; + } + + $formatsContent .= ' ]'; + + $validatorContent = file_get_contents($validatorPath); + + $validatorContent = preg_replace( + '/FORMATS = \[.*?\];/s', + "FORMATS = {$formatsContent};", + $validatorContent + ); + + file_put_contents($validatorPath, $validatorContent); +} + +final class SwiftRegistryIbanProvider +{ + /** + * @return array + */ + public function getIbanFormats(): array + { + $items = $this->readPropertiesFromRegistry([ + 'Name of country' => 'country', + 'IBAN prefix country code (ISO 3166)' => 'country_code', + 'IBAN structure' => 'iban_structure', + 'Country code includes other countries/territories' => 'included_country_codes', + ]); + + $formats = []; + + foreach ($items as $item) { + $formats[$item['country_code']] = [$this->buildIbanRegexp($item['iban_structure']), $item['country']]; + + foreach ($this->parseCountryCodesList($item['included_country_codes']) as $includedCountryCode) { + $formats[$includedCountryCode] = $formats[$item['country_code']]; + } + } + + return $formats; + } + + /** + * @return list + */ + private function parseCountryCodesList(string $countryCodesList): array + { + if ('N/A' === $countryCodesList) { + return []; + } + + $countryCodes = []; + + foreach (explode(',', $countryCodesList) as $countryCode) { + $countryCodes[] = preg_replace('/^([A-Z]{2})(\s+\(.+?\))?$/', '$1', trim($countryCode)); + } + + return $countryCodes; + } + + /** + * @param array $properties + * + * @return list> + */ + private function readPropertiesFromRegistry(array $properties): array + { + $items = []; + + $registryContent = file_get_contents('https://www.swift.com/swift-resource/11971/download'); + $lines = explode("\n", $registryContent); + + // skip header line + array_shift($lines); + + foreach ($lines as $line) { + $columns = str_getcsv($line, "\t"); + $propertyLabel = array_shift($columns); + + if (!isset($properties[$propertyLabel])) { + continue; + } + + $propertyField = $properties[$propertyLabel]; + + foreach ($columns as $index => $value) { + $items[$index][$propertyField] = $value; + } + } + + return array_values($items); + } + + private function buildIbanRegexp(string $ibanStructure): string + { + $pattern = $ibanStructure; + + $pattern = preg_replace('/(\d+)!n/', '\\d{$1}', $pattern); + $pattern = preg_replace('/(\d+)!a/', '[A-Z]{$1}', $pattern); + $pattern = preg_replace('/(\d+)!c/', '[\\dA-Z]{$1}', $pattern); + + return $pattern; + } +} + +final class WikipediaIbanProvider +{ + /** + * @return array + */ + public function getIbanFormats(): array + { + $formats = []; + + foreach ($this->readIbanFormatsTable() as $item) { + if (!preg_match('/^([A-Z]{2})/', $item['Example'], $matches)) { + continue; + } + + $countryCode = $matches[1]; + + $formats[$countryCode] = [$this->buildIbanRegexp($countryCode, $item['BBAN Format']), $item['Country']]; + } + + return $formats; + } + + /** + * @return list> + */ + private function readIbanFormatsTable(): array + { + $tablesResponse = file_get_contents('https://www.wikitable2json.com/api/International_Bank_Account_Number?table=3&keyRows=1&clearRef=true'); + + return json_decode($tablesResponse, true, 512, JSON_THROW_ON_ERROR)[0]; + } + + private function buildIbanRegexp(string $countryCode, string $bbanFormat): string + { + $pattern = $bbanFormat; + + $pattern = preg_replace('/\s*,\s*/', '', $pattern); + $pattern = preg_replace('/(\d+)n/', '\\d{$1}', $pattern); + $pattern = preg_replace('/(\d+)a/', '[A-Z]{$1}', $pattern); + $pattern = preg_replace('/(\d+)c/', '[\\dA-Z]{$1}', $pattern); + + return $countryCode.'\\d{2}'.$pattern; + } +} diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index bee4639b26bfa..073dd17f741df 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -130,16 +130,22 @@ protected function createContext() $context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); $context->setConstraint($this->constraint); - $contextualValidator = $this->getMockBuilder(AssertingContextualValidator::class) - ->setConstructorArgs([$context]) - ->setMethods([ - 'atPath', - 'validate', - 'validateProperty', - 'validatePropertyValue', - 'getViolations', - ]) - ->getMock(); + $contextualValidatorMockBuilder = $this->getMockBuilder(AssertingContextualValidator::class) + ->setConstructorArgs([$context]); + $contextualValidatorMethods = [ + 'atPath', + 'validate', + 'validateProperty', + 'validatePropertyValue', + 'getViolations', + ]; + // PHPUnit 10 removed MockBuilder::setMethods() + if (method_exists($contextualValidatorMockBuilder, 'onlyMethods')) { + $contextualValidatorMockBuilder->onlyMethods($contextualValidatorMethods); + } else { + $contextualValidatorMockBuilder->setMethods($contextualValidatorMethods); + } + $contextualValidator = $contextualValidatorMockBuilder->getMock(); $contextualValidator->expects($this->any()) ->method('atPath') ->willReturnCallback(function ($path) use ($contextualValidator) { diff --git a/src/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php index aeaef472fb03d..128a41c067686 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php @@ -27,7 +27,7 @@ public function testFormatValue($expected, $value, $format = 0) $this->assertSame($expected, (new TestFormatValueConstraintValidator())->formatValueProxy($value, $format)); } - public function formatValueProvider() + public static function formatValueProvider() { $defaultTimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Moscow'); // GMT+3 diff --git a/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php b/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php index effaab06d33c2..3aabf7a2137f6 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php @@ -146,7 +146,7 @@ public function testFindByCodes($code, $violationsCount) $this->assertCount($violationsCount, $specificErrors); } - public function findByCodesProvider() + public static function findByCodesProvider() { return [ ['code1', 2], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 4544e46687e48..0df1bae15e02b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -69,7 +69,7 @@ protected static function addPhp5Dot5Comparisons(array $comparisons) return $result; } - public function provideInvalidConstraintOptions() + public static function provideInvalidConstraintOptions() { return [ [null], @@ -112,15 +112,16 @@ public function testValidComparisonToValue($dirtyValue, $comparisonValue) $this->assertNoViolation(); } - public function provideAllValidComparisons(): array + public static function provideAllValidComparisons(): array { // The provider runs before setUp(), so we need to manually fix // the default timezone - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); - $comparisons = self::addPhp5Dot5Comparisons($this->provideValidComparisons()); + $comparisons = self::addPhp5Dot5Comparisons(static::provideValidComparisons()); - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $comparisons; } @@ -166,9 +167,9 @@ public function testInvalidValuePath() $this->validator->validate(5, $constraint); } - abstract public function provideValidComparisons(): array; + abstract public static function provideValidComparisons(): array; - abstract public function provideValidComparisonsToPropertyPath(): array; + abstract public static function provideValidComparisonsToPropertyPath(): array; /** * @dataProvider provideAllInvalidComparisons @@ -233,9 +234,9 @@ public function testThrowsOnInvalidStringDates(AbstractComparison $constraint, $ $this->validator->validate($value, $constraint); } - public function throwsOnInvalidStringDatesProvider(): array + public static function throwsOnInvalidStringDatesProvider(): array { - $constraint = $this->createConstraint([ + $constraint = static::createConstraint([ 'value' => 'foo', ]); @@ -273,27 +274,28 @@ public function testCompareWithNullValueAtPropertyAt($dirtyValue, $dirtyValueAsS } } - public function provideAllInvalidComparisons(): array + public static function provideAllInvalidComparisons(): array { // The provider runs before setUp(), so we need to manually fix // the default timezone - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); - $comparisons = self::addPhp5Dot5Comparisons($this->provideInvalidComparisons()); + $comparisons = self::addPhp5Dot5Comparisons(static::provideInvalidComparisons()); - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $comparisons; } - abstract public function provideInvalidComparisons(): array; + abstract public static function provideInvalidComparisons(): array; - abstract public function provideComparisonsToNullValueAtPropertyPath(); + abstract public static function provideComparisonsToNullValueAtPropertyPath(); /** * @param array|null $options Options for the constraint */ - abstract protected function createConstraint(array $options = null): Constraint; + abstract protected static function createConstraint(array $options = null): Constraint; protected function getErrorCode(): ?string { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index 0daa82498af19..ff884d43a6714 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -77,7 +77,7 @@ public function testWalkMultipleConstraints($array) $this->assertNoViolation(); } - public function getValidArguments() + public static function getValidArguments() { return [ [[5, 6, 7]], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php index 0fb735a84cdb2..961607b4b7a45 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php @@ -22,6 +22,7 @@ use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; use Symfony\Component\Validator\Constraints\IdenticalTo; +use Symfony\Component\Validator\Constraints\IsNull; use Symfony\Component\Validator\Constraints\Language; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\LessThan; @@ -37,6 +38,9 @@ use Symfony\Component\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; use Symfony\Component\Validator\Validation; +use Symfony\Contracts\Translation\LocaleAwareInterface; +use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorTrait; /** * @author Przemysław Bogusz @@ -56,7 +60,7 @@ public function testValidCombinations($value, $constraints) $this->assertCount(0, Validation::createValidator()->validate($value, new AtLeastOneOf($constraints))); } - public function getValidCombinations() + public static function getValidCombinations() { return [ ['symfony', [ @@ -125,7 +129,7 @@ public function testInvalidCombinationsWithCustomMessage($value, $constraints) $this->assertEquals(new ConstraintViolation('foo', 'foo', [], $value, '', $value, null, AtLeastOneOf::AT_LEAST_ONE_OF_ERROR, $atLeastOneOf), $violations->get(0)); } - public function getInvalidCombinations() + public static function getInvalidCombinations() { return [ ['symphony', [ @@ -258,6 +262,40 @@ public function testNestedConstraintsAreNotExecutedWhenGroupDoesNotMatch() $this->assertCount(1, $violations); } + + public function testTranslatorIsCalledOnConstraintBaseMessageAndViolations() + { + $translator = new class() implements TranslatorInterface, LocaleAwareInterface { + use TranslatorTrait; + + public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string + { + if ('This value should satisfy at least one of the following constraints:' === $id) { + return 'Dummy translation:'; + } + + if ('This value should be null.' === $id) { + return 'Dummy violation.'; + } + + return $id; + } + }; + + $validator = Validation::createValidatorBuilder() + ->setTranslator($translator) + ->getValidator() + ; + + $violations = $validator->validate('Test', [ + new AtLeastOneOf([ + new IsNull(), + ]), + ]); + + $this->assertCount(1, $violations); + $this->assertSame('Dummy translation: [1] Dummy violation.', $violations->get(0)->getMessage()); + } } class ExpressionConstraintNested diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php index 20c9d7c54681a..564fa30c95957 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php @@ -197,7 +197,7 @@ public function testValidBics($bic) $this->assertNoViolation(); } - public function getValidBics() + public static function getValidBics() { // http://formvalidation.io/validators/bic/ return [ @@ -229,6 +229,7 @@ public function testInvalidBics($bic, $code) /** * @requires PHP 8 + * * @dataProvider getInvalidBics */ public function testInvalidBicsNamed($bic, $code) @@ -243,7 +244,7 @@ public function testInvalidBicsNamed($bic, $code) ->assertRaised(); } - public function getInvalidBics() + public static function getInvalidBics() { return [ ['DEUTD', Bic::INVALID_LENGTH_ERROR], @@ -287,7 +288,7 @@ public function testValidBicSpecialCases(string $bic, string $iban) $this->assertNoViolation(); } - public function getValidBicSpecialCases() + public static function getValidBicSpecialCases() { // FR related special cases yield ['BNPAGFGX', 'FR14 2004 1010 0505 0001 3M02 606']; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index 1d138348a9e7b..95f5bc8f7846d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -53,7 +53,7 @@ public function testInvalidValues($value, $valueAsString) ->assertRaised(); } - public function getInvalidValues() + public static function getInvalidValues() { return [ ['foobar', '"foobar"'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index 100a3811b00ff..dcb40c9e7383b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -90,7 +90,7 @@ public function testInvalidNumberNamedArguments() ->assertRaised(); } - public function getValidNumbers() + public static function getValidNumbers() { return [ ['AMEX', '378282246310005'], @@ -145,7 +145,7 @@ public function getValidNumbers() ]; } - public function getInvalidNumbers() + public static function getInvalidNumbers() { return [ ['VISA', '42424242424242424242', CardScheme::INVALID_FORMAT_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index 262e8654f043b..5c3bcc4720353 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -84,7 +84,7 @@ public function testValidChoiceArray(Choice $constraint) $this->assertNoViolation(); } - public function provideConstraintsWithChoicesArray(): iterable + public static function provideConstraintsWithChoicesArray(): iterable { yield 'Doctrine style' => [new Choice(['choices' => ['foo', 'bar']])]; yield 'Doctrine default option' => [new Choice(['value' => ['foo', 'bar']])]; @@ -105,7 +105,7 @@ public function testValidChoiceCallbackFunction(Choice $constraint) $this->assertNoViolation(); } - public function provideConstraintsWithCallbackFunction(): iterable + public static function provideConstraintsWithCallbackFunction(): iterable { yield 'doctrine style, namespaced function' => [new Choice(['callback' => __NAMESPACE__.'\choice_callback'])]; yield 'doctrine style, closure' => [new Choice([ @@ -156,7 +156,7 @@ public function testMultipleChoices(Choice $constraint) $this->assertNoViolation(); } - public function provideConstraintsWithMultipleTrue(): iterable + public static function provideConstraintsWithMultipleTrue(): iterable { yield 'Doctrine style' => [new Choice([ 'choices' => ['foo', 'bar', 'baz'], @@ -185,7 +185,7 @@ public function testInvalidChoice(Choice $constraint) ->assertRaised(); } - public function provideConstraintsWithMessage(): iterable + public static function provideConstraintsWithMessage(): iterable { yield 'Doctrine style' => [new Choice(['choices' => ['foo', 'bar'], 'message' => 'myMessage'])]; @@ -227,7 +227,7 @@ public function testInvalidChoiceMultiple(Choice $constraint) ->assertRaised(); } - public function provideConstraintsWithMultipleMessage(): iterable + public static function provideConstraintsWithMultipleMessage(): iterable { yield 'Doctrine style' => [new Choice([ 'choices' => ['foo', 'bar'], @@ -263,7 +263,7 @@ public function testTooFewChoices(Choice $constraint) ->assertRaised(); } - public function provideConstraintsWithMin(): iterable + public static function provideConstraintsWithMin(): iterable { yield 'Doctrine style' => [new Choice([ 'choices' => ['foo', 'bar', 'moo', 'maa'], @@ -301,7 +301,7 @@ public function testTooManyChoices(Choice $constraint) ->assertRaised(); } - public function provideConstraintsWithMax(): iterable + public static function provideConstraintsWithMax(): iterable { yield 'Doctrine style' => [new Choice([ 'choices' => ['foo', 'bar', 'moo', 'maa'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CidrTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CidrTest.php index 571cdbf2758c9..dc41ae1f0f597 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CidrTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CidrTest.php @@ -90,7 +90,7 @@ public function testWithInvalidMinMaxValues(string $ipVersion, int $netmaskMin, ]); } - public function getInvalidMinMaxValues(): array + public static function getInvalidMinMaxValues(): array { return [ [Ip::ALL, -1, 23], @@ -108,7 +108,7 @@ public function getInvalidMinMaxValues(): array ]; } - public function getValidMinMaxValues(): array + public static function getValidMinMaxValues(): array { return [ [Ip::ALL, 0, 23], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CidrValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CidrValidatorTest.php index c522335a84b05..7c5745ee6942a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CidrValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CidrValidatorTest.php @@ -135,7 +135,7 @@ public function testWrongVersion(string $cidr, string $version) ->assertRaised(); } - public function getWithInvalidIps(): array + public static function getWithInvalidIps(): array { return [ ['0/20'], @@ -164,7 +164,7 @@ public function getWithInvalidIps(): array ]; } - public function getValid(): array + public static function getValid(): array { return [ ['127.0.0.0/32', Ip::ALL], @@ -198,7 +198,7 @@ public function getValid(): array ]; } - public function getWithInvalidNetmask(): array + public static function getWithInvalidNetmask(): array { return [ ['192.168.1.0/-1'], @@ -217,7 +217,7 @@ public function getWithInvalidNetmask(): array ]; } - public function getWithInvalidMasksAndIps(): array + public static function getWithInvalidMasksAndIps(): array { return [ ['0.0.0.0/foobar'], @@ -236,7 +236,7 @@ public function getWithInvalidMasksAndIps(): array ]; } - public function getOutOfRangeNetmask(): array + public static function getOutOfRangeNetmask(): array { return [ ['10.0.0.0/24', Ip::V4, 10, 20], @@ -244,7 +244,7 @@ public function getOutOfRangeNetmask(): array ]; } - public function getWithWrongVersion(): array + public static function getWithWrongVersion(): array { return [ ['2001:0db8:85a3:0000:0000:8a2e:0370:7334/12', Ip::V4], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayObjectTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayObjectTest.php index a3c4b3340ec70..da68d42d9c0d2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayObjectTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayObjectTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; -class CollectionValidatorArrayObjectTest extends CollectionValidatorTest +class CollectionValidatorArrayObjectTest extends CollectionValidatorTestCase { public function prepareTestData(array $contents) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayTest.php index 7517d0ce340e4..993a870714d75 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorArrayTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; -class CollectionValidatorArrayTest extends CollectionValidatorTest +class CollectionValidatorArrayTest extends CollectionValidatorTestCase { public function prepareTestData(array $contents) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php index 3d4c29681bf47..bfb9af29a8bb0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Validator\Tests\Fixtures\CustomArrayObject; -class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTest +class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTestCase { public function prepareTestData(array $contents) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTestCase.php similarity index 99% rename from src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTestCase.php index 64fa81f839e07..9fd396296338e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTestCase.php @@ -20,7 +20,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -abstract class CollectionValidatorTest extends ConstraintValidatorTestCase +abstract class CollectionValidatorTestCase extends ConstraintValidatorTestCase { protected function createValidator() { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorArrayTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorArrayTest.php index 5f562e7445f8f..1f441ea136508 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorArrayTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorArrayTest.php @@ -14,9 +14,9 @@ /** * @author Bernhard Schussek */ -class CountValidatorArrayTest extends CountValidatorTest +class CountValidatorArrayTest extends CountValidatorTestCase { - protected function createCollection(array $content) + protected static function createCollection(array $content) { return $content; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php index 7d46967bde483..48a8063e5fb0a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php @@ -16,9 +16,9 @@ /** * @author Bernhard Schussek */ -class CountValidatorCountableTest extends CountValidatorTest +class CountValidatorCountableTest extends CountValidatorTestCase { - protected function createCollection(array $content) + protected static function createCollection(array $content) { return new Countable($content); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTestCase.php similarity index 90% rename from src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTestCase.php index 11e83d3688998..68b8766c516b8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTestCase.php @@ -20,14 +20,14 @@ /** * @author Bernhard Schussek */ -abstract class CountValidatorTest extends ConstraintValidatorTestCase +abstract class CountValidatorTestCase extends ConstraintValidatorTestCase { protected function createValidator() { return new CountValidator(); } - abstract protected function createCollection(array $content); + abstract protected static function createCollection(array $content); public function testNullIsValid() { @@ -42,30 +42,30 @@ public function testExpectsCountableType() $this->validator->validate(new \stdClass(), new Count(5)); } - public function getThreeOrLessElements() + public static function getThreeOrLessElements() { return [ - [$this->createCollection([1])], - [$this->createCollection([1, 2])], - [$this->createCollection([1, 2, 3])], - [$this->createCollection(['a' => 1, 'b' => 2, 'c' => 3])], + [static::createCollection([1])], + [static::createCollection([1, 2])], + [static::createCollection([1, 2, 3])], + [static::createCollection(['a' => 1, 'b' => 2, 'c' => 3])], ]; } - public function getFourElements() + public static function getFourElements() { return [ - [$this->createCollection([1, 2, 3, 4])], - [$this->createCollection(['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4])], + [static::createCollection([1, 2, 3, 4])], + [static::createCollection(['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4])], ]; } - public function getFiveOrMoreElements() + public static function getFiveOrMoreElements() { return [ - [$this->createCollection([1, 2, 3, 4, 5])], - [$this->createCollection([1, 2, 3, 4, 5, 6])], - [$this->createCollection(['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5])], + [static::createCollection([1, 2, 3, 4, 5])], + [static::createCollection([1, 2, 3, 4, 5, 6])], + [static::createCollection(['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5])], ]; } @@ -82,6 +82,7 @@ public function testValidValuesMax($value) /** * @requires PHP 8 + * * @dataProvider getThreeOrLessElements */ public function testValidValuesMaxNamed($value) @@ -105,6 +106,7 @@ public function testValidValuesMin($value) /** * @requires PHP 8 + * * @dataProvider getFiveOrMoreElements */ public function testValidValuesMinNamed($value) @@ -128,6 +130,7 @@ public function testValidValuesExact($value) /** * @requires PHP 8 + * * @dataProvider getFourElements */ public function testValidValuesExactNamed($value) @@ -161,6 +164,7 @@ public function testTooManyValues($value) /** * @requires PHP 8 + * * @dataProvider getFiveOrMoreElements */ public function testTooManyValuesNamed($value) @@ -201,6 +205,7 @@ public function testTooFewValues($value) /** * @requires PHP 8 + * * @dataProvider getThreeOrLessElements */ public function testTooFewValuesNamed($value) @@ -242,6 +247,7 @@ public function testTooManyValuesExact($value) /** * @requires PHP 8 + * * @dataProvider getFiveOrMoreElements */ public function testTooManyValuesExactNamed($value) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 71cb41c46564d..be80a9e63dba8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -70,7 +70,7 @@ public function testValidCountries($country) $this->assertNoViolation(); } - public function getValidCountries() + public static function getValidCountries() { return [ ['GB'], @@ -96,7 +96,7 @@ public function testInvalidCountries($country) ->assertRaised(); } - public function getInvalidCountries() + public static function getInvalidCountries() { return [ ['foobar'], @@ -116,7 +116,7 @@ public function testValidAlpha3Countries($country) $this->assertNoViolation(); } - public function getValidAlpha3Countries() + public static function getValidAlpha3Countries() { return [ ['GBR'], @@ -143,7 +143,7 @@ public function testInvalidAlpha3Countries($country) ->assertRaised(); } - public function getInvalidAlpha3Countries() + public static function getInvalidAlpha3Countries() { return [ ['foobar'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CssColorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CssColorTest.php index fcf58b85b33c4..aba40a875c800 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CssColorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CssColorTest.php @@ -18,6 +18,7 @@ /** * @author Mathieu Santostefano + * * @requires PHP 8 */ final class CssColorTest extends TestCase diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php index 6a9b398ac57a1..95b0b6f29ea34 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php @@ -52,7 +52,7 @@ public function testValidAnyColor($cssColor) $this->assertNoViolation(); } - public function getValidAnyColor(): array + public static function getValidAnyColor(): array { return [ ['#ABCDEF'], @@ -79,7 +79,7 @@ public function testValidHexLongColors($cssColor) $this->assertNoViolation(); } - public function getValidHexLongColors(): array + public static function getValidHexLongColors(): array { return [['#ABCDEF'], ['#abcdef'], ['#C0FFEE'], ['#c0ffee'], ['#501311']]; } @@ -93,7 +93,7 @@ public function testValidHexLongColorsWithAlpha($cssColor) $this->assertNoViolation(); } - public function getValidHexLongColorsWithAlpha(): array + public static function getValidHexLongColorsWithAlpha(): array { return [['#ABCDEF00'], ['#abcdef01'], ['#C0FFEE02'], ['#c0ffee03'], ['#501311FF']]; } @@ -107,7 +107,7 @@ public function testValidHexShortColors($cssColor) $this->assertNoViolation(); } - public function getValidHexShortColors(): array + public static function getValidHexShortColors(): array { return [['#F4B'], ['#FAB'], ['#f4b'], ['#fab']]; } @@ -121,7 +121,7 @@ public function testValidHexShortColorsWithAlpha($cssColor) $this->assertNoViolation(); } - public function getValidHexShortColorsWithAlpha(): array + public static function getValidHexShortColorsWithAlpha(): array { return [['#F4B1'], ['#FAB1'], ['#f4b1'], ['#fab1']]; } @@ -135,7 +135,7 @@ public function testValidBasicNamedColors($cssColor) $this->assertNoViolation(); } - public function getValidBasicNamedColors(): array + public static function getValidBasicNamedColors(): array { return [ ['black'], ['silver'], ['gray'], ['white'], ['maroon'], ['red'], ['purple'], ['fuchsia'], ['green'], ['lime'], ['olive'], ['yellow'], ['navy'], ['blue'], ['teal'], ['aqua'], @@ -152,7 +152,7 @@ public function testValidExtendedNamedColors($cssColor) $this->assertNoViolation(); } - public function getValidExtendedNamedColors(): array + public static function getValidExtendedNamedColors(): array { return [ ['aliceblue'], ['antiquewhite'], ['aqua'], ['aquamarine'], ['azure'], ['beige'], ['bisque'], ['black'], ['blanchedalmond'], ['blue'], ['blueviolet'], ['brown'], ['burlywood'], ['cadetblue'], ['chartreuse'], ['chocolate'], ['coral'], ['cornflowerblue'], ['cornsilk'], ['crimson'], ['cyan'], ['darkblue'], ['darkcyan'], ['darkgoldenrod'], ['darkgray'], ['darkgreen'], ['darkgrey'], ['darkkhaki'], ['darkmagenta'], ['darkolivegreen'], ['darkorange'], ['darkorchid'], ['darkred'], ['darksalmon'], ['darkseagreen'], ['darkslateblue'], ['darkslategray'], ['darkslategrey'], ['darkturquoise'], ['darkviolet'], ['deeppink'], ['deepskyblue'], ['dimgray'], ['dimgrey'], ['dodgerblue'], ['firebrick'], ['floralwhite'], ['forestgreen'], ['fuchsia'], ['gainsboro'], ['ghostwhite'], ['gold'], ['goldenrod'], ['gray'], ['green'], ['greenyellow'], ['grey'], ['honeydew'], ['hotpink'], ['indianred'], ['indigo'], ['ivory'], ['khaki'], ['lavender'], ['lavenderblush'], ['lawngreen'], ['lemonchiffon'], ['lightblue'], ['lightcoral'], ['lightcyan'], ['lightgoldenrodyellow'], ['lightgray'], ['lightgreen'], ['lightgrey'], ['lightpink'], ['lightsalmon'], ['lightseagreen'], ['lightskyblue'], ['lightslategray'], ['lightslategrey'], ['lightsteelblue'], ['lightyellow'], ['lime'], ['limegreen'], ['linen'], ['magenta'], ['maroon'], ['mediumaquamarine'], ['mediumblue'], ['mediumorchid'], ['mediumpurple'], ['mediumseagreen'], ['mediumslateblue'], ['mediumspringgreen'], ['mediumturquoise'], ['mediumvioletred'], ['midnightblue'], ['mintcream'], ['mistyrose'], ['moccasin'], ['navajowhite'], ['navy'], ['oldlace'], ['olive'], ['olivedrab'], ['orange'], ['orangered'], ['orchid'], ['palegoldenrod'], ['palegreen'], ['paleturquoise'], ['palevioletred'], ['papayawhip'], ['peachpuff'], ['peru'], ['pink'], ['plum'], ['powderblue'], ['purple'], ['red'], ['rosybrown'], ['royalblue'], ['saddlebrown'], ['salmon'], ['sandybrown'], ['seagreen'], ['seashell'], ['sienna'], ['silver'], ['skyblue'], ['slateblue'], ['slategray'], ['slategrey'], ['snow'], ['springgreen'], ['steelblue'], ['tan'], ['teal'], ['thistle'], ['tomato'], ['turquoise'], ['violet'], ['wheat'], ['white'], ['whitesmoke'], ['yellow'], ['yellowgreen'], @@ -169,7 +169,7 @@ public function testValidSystemColors($cssColor) $this->assertNoViolation(); } - public function getValidSystemColors(): array + public static function getValidSystemColors(): array { return [ ['Canvas'], ['CanvasText'], ['LinkText'], ['VisitedText'], ['ActiveText'], ['ButtonFace'], ['ButtonText'], ['ButtonBorder'], ['Field'], ['FieldText'], ['Highlight'], ['HighlightText'], ['SelectedItem'], ['SelectedItemText'], ['Mark'], ['MarkText'], ['GrayText'], @@ -187,7 +187,7 @@ public function testValidKeywords($cssColor) $this->assertNoViolation(); } - public function getValidKeywords(): array + public static function getValidKeywords(): array { return [['transparent'], ['currentColor']]; } @@ -201,7 +201,7 @@ public function testValidRGB($cssColor) $this->assertNoViolation(); } - public function getValidRGB(): array + public static function getValidRGB(): array { return [ ['rgb(0, 255, 243)'], @@ -219,7 +219,7 @@ public function testValidRGBA($cssColor) $this->assertNoViolation(); } - public function getValidRGBA(): array + public static function getValidRGBA(): array { return [ ['rgba( 255, 255, 255, 0.3 )'], ['rgba(255, 255, 255, 0.3)'], ['rgba(255, 255, 255, .3)'], @@ -238,7 +238,7 @@ public function testValidHSL($cssColor) $this->assertNoViolation(); } - public function getValidHSL(): array + public static function getValidHSL(): array { return [ ['hsl(0, 0%, 20%)'], ['hsl( 0, 0%, 20% )'], @@ -256,7 +256,7 @@ public function testValidHSLA($cssColor) $this->assertNoViolation(); } - public function getValidHSLA(): array + public static function getValidHSLA(): array { return [ ['hsla( 0, 0%, 20%, 0.4 )'], ['hsla(0, 0%, 20%, 0.4)'], ['hsla(0, 0%, 20%, .4)'], @@ -280,7 +280,7 @@ public function testInvalidHexColors($cssColor) ->assertRaised(); } - public function getInvalidHexColors(): array + public static function getInvalidHexColors(): array { return [['ABCDEF'], ['abcdef'], ['#K0FFEE'], ['#k0ffee'], ['#_501311'], ['ABCDEF00'], ['abcdefcc'], ['#K0FFEE33'], ['#k0ffeecc'], ['#_50131100'], ['#FAℬ'], ['#Ⅎab'], ['#F4️⃣B'], ['#f(4)b'], ['#907;']]; } @@ -298,7 +298,7 @@ public function testInvalidShortHexColors($cssColor) ->assertRaised(); } - public function getInvalidShortHexColors(): array + public static function getInvalidShortHexColors(): array { return [['ABC'], ['ABCD'], ['abc'], ['abcd'], ['#K0F'], ['#K0FF'], ['#k0f'], ['#k0ff'], ['#_50'], ['#_501']]; } @@ -321,7 +321,7 @@ public function testInvalidNamedColors($cssColor) ->assertRaised(); } - public function getInvalidNamedColors(): array + public static function getInvalidNamedColors(): array { return [['fabpot'], ['ngrekas'], ['symfony'], ['FABPOT'], ['NGREKAS'], ['SYMFONY']]; } @@ -344,7 +344,7 @@ public function testInvalidRGB($cssColor) ->assertRaised(); } - public function getInvalidRGB(): array + public static function getInvalidRGB(): array { return [['rgb(999,999,999)'], ['rgb(-99,-99,-99)'], ['rgb(a,b,c)'], ['rgb(99 99, 9 99, 99 9)']]; } @@ -367,7 +367,7 @@ public function testInvalidRGBA($cssColor) ->assertRaised(); } - public function getInvalidRGBA(): array + public static function getInvalidRGBA(): array { return [['rgba(999,999,999,999)'], ['rgba(-99,-99,-99,-99)'], ['rgba(a,b,c,d)'], ['rgba(99 99, 9 99, 99 9, . 9)']]; } @@ -390,7 +390,7 @@ public function testInvalidHSL($cssColor) ->assertRaised(); } - public function getInvalidHSL(): array + public static function getInvalidHSL(): array { return [['hsl(1000, 1000%, 20000%)'], ['hsl(-100, -10%, -2%)'], ['hsl(a, b, c)'], ['hsl(a, b%, c%)'], ['hsl( 99 99% , 9 99% , 99 9%)']]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index dcca9e0ed7c54..c5d2ddb62c5fb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -84,7 +84,7 @@ public function testValidCurrenciesWithCountrySpecificLocale($currency) $this->assertNoViolation(); } - public function getValidCurrencies() + public static function getValidCurrencies() { return [ ['EUR'], @@ -114,6 +114,7 @@ public function testInvalidCurrencies($currency) /** * @requires PHP 8 + * * @dataProvider getInvalidCurrencies */ public function testInvalidCurrenciesNamed($currency) @@ -128,7 +129,7 @@ public function testInvalidCurrenciesNamed($currency) ->assertRaised(); } - public function getInvalidCurrencies() + public static function getInvalidCurrencies() { return [ ['EN'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index aa956c1433931..4438d2f48e559 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -71,7 +71,7 @@ public function testValidDateTimes($format, $dateTime) $this->assertNoViolation(); } - public function getValidDateTimes() + public static function getValidDateTimes() { return [ ['Y-m-d H:i:s e', '1995-03-24 00:00:00 UTC'], @@ -100,7 +100,7 @@ public function testInvalidDateTimes($format, $dateTime, $code) ->assertRaised(); } - public function getInvalidDateTimes() + public static function getInvalidDateTimes() { return [ ['Y-m-d', 'foobar', DateTime::INVALID_FORMAT_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index af16525892c4c..b2e9fdf5e2f82 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -53,7 +53,7 @@ public function testValidDates($date) $this->assertNoViolation(); } - public function getValidDates() + public static function getValidDates() { return [ ['2010-01-01'], @@ -94,7 +94,7 @@ public function testInvalidDateNamed() ->assertRaised(); } - public function getInvalidDates() + public static function getInvalidDates() { return [ ['foobar', Date::INVALID_FORMAT_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php index 4ce2723c0d845..ebcf9b8493af1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php @@ -26,7 +26,7 @@ protected function createValidator() return new DivisibleByValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new DivisibleBy($options); } @@ -39,7 +39,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [-7, 1], @@ -68,7 +68,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [25], @@ -78,7 +78,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'int'], @@ -104,7 +104,7 @@ public function testThrowsOnNonNumericValues(string $expectedGivenType, $value, ])); } - public function throwsOnNonNumericValuesProvider() + public static function throwsOnNonNumericValuesProvider() { return [ [\stdClass::class, 2, new \stdClass()], @@ -112,8 +112,8 @@ public function throwsOnNonNumericValuesProvider() ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { - $this->markTestSkipped('DivisibleByValidator rejects null values.'); + self::markTestSkipped('DivisibleByValidator rejects null values.'); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 3fff0c35d57f2..fa829e77b6764 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -70,7 +70,7 @@ public function testValidEmails($email) $this->assertNoViolation(); } - public function getValidEmails() + public static function getValidEmails() { return [ ['fabien@symfony.com'], @@ -94,7 +94,7 @@ public function testValidNormalizedEmails($email) $this->assertNoViolation(); } - public function getValidEmailsWithWhitespaces() + public static function getValidEmailsWithWhitespaces() { return [ ["\x20example@example.co.uk\x20"], @@ -116,7 +116,7 @@ public function testValidEmailsHtml5($email) $this->assertNoViolation(); } - public function getValidEmailsHtml5() + public static function getValidEmailsHtml5() { return [ ['fabien@symfony.com'], @@ -143,7 +143,7 @@ public function testInvalidEmails($email) ->assertRaised(); } - public function getInvalidEmails() + public static function getInvalidEmails() { return [ ['example'], @@ -171,7 +171,7 @@ public function testInvalidHtml5Emails($email) ->assertRaised(); } - public function getInvalidHtml5Emails() + public static function getInvalidHtml5Emails() { return [ ['example'], @@ -255,7 +255,7 @@ public function testStrictWithInvalidEmails($email) /** * @see https://github.com/egulias/EmailValidator/blob/1.2.8/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php */ - public function getInvalidEmailsForStrictChecks() + public static function getInvalidEmailsForStrictChecks() { return [ ['test@example.com test'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index db825543fb075..628bd2534ff28 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new EqualToValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new EqualTo($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [3, 3], @@ -55,7 +55,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [5], @@ -65,7 +65,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'int'], @@ -77,7 +77,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', false], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php index 1c57d56f0e6a6..3894269a9b90b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php @@ -34,7 +34,7 @@ public function testValidatedByService(ExpressionLanguageSyntax $constraint) self::assertSame('my_service', $constraint->validatedBy()); } - public function provideServiceValidatedConstraints(): iterable + public static function provideServiceValidatedConstraints(): iterable { yield 'Doctrine style' => [new ExpressionLanguageSyntax(['service' => 'my_service'])]; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php index 31227bb737c84..d12c1ad9651bd 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php @@ -86,7 +86,7 @@ public function testInvalidMaxSize($maxSize) new File(['maxSize' => $maxSize]); } - public function provideValidSizes() + public static function provideValidSizes() { return [ ['500', 500, false], @@ -106,7 +106,7 @@ public function provideValidSizes() ]; } - public function provideInvalidSizes() + public static function provideInvalidSizes() { return [ ['+100'], @@ -126,7 +126,7 @@ public function testBinaryFormat($maxSize, $guessedFormat, $binaryFormat) $this->assertSame($binaryFormat, $file->binaryFormat); } - public function provideFormats() + public static function provideFormats() { return [ [100, null, false], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorObjectTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorObjectTest.php index f35f93b1797d6..932b45cbc1a9f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorObjectTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorObjectTest.php @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\File\File; -class FileValidatorObjectTest extends FileValidatorTest +class FileValidatorObjectTest extends FileValidatorTestCase { protected function getFile($filename) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php index dfd82f15ccf4d..9a89688016de3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Validator\Constraints\File; -class FileValidatorPathTest extends FileValidatorTest +class FileValidatorPathTest extends FileValidatorTestCase { protected function getFile($filename) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php similarity index 97% rename from src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php index 327cb963b33bc..cd16f8b4b0682 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php @@ -18,7 +18,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -abstract class FileValidatorTest extends ConstraintValidatorTestCase +abstract class FileValidatorTestCase extends ConstraintValidatorTestCase { protected $path; @@ -90,7 +90,7 @@ public function testValidUploadedfile() $this->assertNoViolation(); } - public function provideMaxSizeExceededTests() + public static function provideMaxSizeExceededTests() { // We have various interesting limit - size combinations to test. // Assume a limit of 1000 bytes (1 kB). Then the following table @@ -182,7 +182,7 @@ public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limit ->assertRaised(); } - public function provideMaxSizeNotExceededTests() + public static function provideMaxSizeNotExceededTests() { return [ // 0 has no effect @@ -237,7 +237,7 @@ public function testInvalidMaxSize() $this->validator->validate($this->path, $constraint); } - public function provideBinaryFormatTests() + public static function provideBinaryFormatTests() { return [ [11, 10, null, '11', '10', 'bytes'], @@ -386,7 +386,7 @@ public function testInvalidMimeType(File $constraint) ->assertRaised(); } - public function provideMimeTypeConstraints(): iterable + public static function provideMimeTypeConstraints(): iterable { yield 'Doctrine style' => [new File([ 'mimeTypes' => ['image/png', 'image/jpg'], @@ -447,7 +447,7 @@ public function testDisallowEmpty(File $constraint) ->assertRaised(); } - public function provideDisallowEmptyConstraints(): iterable + public static function provideDisallowEmptyConstraints(): iterable { yield 'Doctrine style' => [new File([ 'disallowEmptyMessage' => 'myMessage', @@ -480,7 +480,7 @@ public function testUploadedFileError($error, $message, array $params = [], $max ->assertRaised(); } - public function uploadedFileErrorProvider() + public static function uploadedFileErrorProvider() { $tests = [ [(string) \UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index 7484e9ff5d050..fd3622e870125 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new GreaterThanOrEqualValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new GreaterThanOrEqual($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [3, 2], @@ -58,7 +58,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [5], @@ -69,7 +69,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'int'], @@ -80,7 +80,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php index 3aea5554dafb6..d6c6682fabf92 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php @@ -21,7 +21,7 @@ */ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends GreaterThanOrEqualValidatorTest { - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new PositiveOrZero(); } @@ -29,7 +29,7 @@ protected function createConstraint(array $options = null): Constraint /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [0, 0], @@ -45,7 +45,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [-1, '-1', 0, '0', 'int'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index 7c6b693d326e5..5f68e6fe2723c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new GreaterThanValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new GreaterThan($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [2, 1], @@ -54,7 +54,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [6], @@ -64,7 +64,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'int'], @@ -82,7 +82,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php index a16320c0044a4..3b31ff4d0be35 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php @@ -21,7 +21,7 @@ */ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidatorTest { - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new Positive(); } @@ -29,7 +29,7 @@ protected function createConstraint(array $options = null): Constraint /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [2, 0], @@ -42,7 +42,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [0, '0', 0, '0', 'int'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/HostnameValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/HostnameValidatorTest.php index 16c3121705115..4ac1970390683 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/HostnameValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/HostnameValidatorTest.php @@ -62,7 +62,7 @@ public function testValidTldDomainsPassValidationIfTldNotRequired($domain) $this->assertNoViolation(); } - public function getValidMultilevelDomains() + public static function getValidMultilevelDomains() { return [ ['symfony.com'], @@ -107,7 +107,7 @@ public function testInvalidDomainsRaiseViolationIfTldNotRequired($domain) ->assertRaised(); } - public function getInvalidDomains() + public static function getInvalidDomains() { return [ ['acme..com'], @@ -144,7 +144,7 @@ public function testReservedDomainsRaiseViolationIfTldRequired($domain) ->assertRaised(); } - public function getReservedDomains() + public static function getReservedDomains() { return [ ['example'], @@ -200,7 +200,7 @@ public function testTopLevelDomainsRaiseViolationIfTldRequired($domain) ->assertRaised(); } - public function getTopLevelDomains() + public static function getTopLevelDomains() { return [ ['com'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index 6274a41cddbe6..70994f509170c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -48,7 +48,7 @@ public function testValidIbans($iban) $this->assertNoViolation(); } - public function getValidIbans() + public static function getValidIbans() { return [ ['CH9300762011623852957'], // Switzerland without spaces @@ -116,6 +116,17 @@ public function getValidIbans() ['AE07 0331 2345 6789 0123 456'], // UAE ['GB12 CPBK 0892 9965 0449 91'], // United Kingdom + ['DJ21 0001 0000 0001 5400 0100 186'], // Djibouti + ['EG38 0019 0005 0000 0000 2631 8000 2'], // Egypt + ['IQ98 NBIQ 8501 2345 6789 012'], // Iraq + ['LC55 HEMM 0001 0001 0012 0012 0002 3015'], // Saint Lucia + ['LY83 0020 4800 0020 1001 2036 1'], // Libya + ['RU02 0445 2560 0407 0281 0412 3456 7890 1'], // Russia + ['SC18 SSCB 1101 0000 0000 0000 1497 USD'], // Seychelles + ['SD21 2901 0501 2340 01'], // Sudan + ['ST23 0002 0000 0289 3557 1014 8'], // Sao Tome and Principe + ['SV62 CENR 0000 0000 0000 0070 0025'], // El Salvador + // Extended country list // http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html // https://www.swift.com/sites/default/files/resources/iban_registry.pdf @@ -126,8 +137,8 @@ public function getValidIbans() ['BR9700360305000010009795493P1'], // Brazil ['BR1800000000141455123924100C2'], // Brazil ['VG96VPVG0000012345678901'], // British Virgin Islands - ['BF1030134020015400945000643'], // Burkina Faso - ['BI43201011067444'], // Burundi + ['BF42BF0840101300463574000390'], // Burkina Faso + ['BI4210000100010000332045181'], // Burundi ['CM2110003001000500000605306'], // Cameroon ['CV64000300004547069110176'], // Cape Verde ['FR7630007000110009970004942'], // Central African Republic @@ -152,7 +163,7 @@ public function getValidIbans() ['XK051212012345678906'], // Republic of Kosovo ['PT50000200000163099310355'], // Sao Tome and Principe ['SA0380000000608010167519'], // Saudi Arabia - ['SN12K00100152000025690007542'], // Senegal + ['SN08SN0100152000048500003035'], // Senegal ['TL380080012345678910157'], // Timor-Leste ['TN5914207207100707129648'], // Tunisia ['TR330006100519786457841326'], // Turkey @@ -170,7 +181,7 @@ public function testIbansWithInvalidFormat($iban) $this->assertViolationRaised($iban, Iban::INVALID_FORMAT_ERROR); } - public function getIbansWithInvalidFormat() + public static function getIbansWithInvalidFormat() { return [ ['AL47 2121 1009 0000 0002 3569 874'], // Albania @@ -244,13 +255,13 @@ public function getIbansWithInvalidFormat() ['BR9700360305000010009795493P11'], // Brazil ['BR1800000000141455123924100C21'], // Brazil ['VG96VPVG00000123456789011'], // British Virgin Islands - ['BF10301340200154009450006431'], // Burkina Faso + ['BF1030134020015400945000643'], // Burkina Faso ['BI432010110674441'], // Burundi ['CM21100030010005000006053061'], // Cameroon ['CV640003000045470691101761'], // Cape Verde ['FR76300070001100099700049421'], // Central African Republic ['CG52300110002021512345678901'], // Congo - ['CR05152020010262840661'], // Costa Rica + ['CR05A52020010262840661'], // Costa Rica ['CR0515202001026284066'], // Costa Rica ['DO28BAGR000000012124536113241'], // Dominican Republic ['GT82TRAJ010200000012100296901'], // Guatemala @@ -289,7 +300,7 @@ public function testIbansWithValidFormatButIncorrectChecksum($iban) $this->assertViolationRaised($iban, Iban::CHECKSUM_FAILED_ERROR); } - public function getIbansWithValidFormatButIncorrectChecksum() + public static function getIbansWithValidFormatButIncorrectChecksum() { return [ ['AL47 2121 1009 0000 0002 3569 8742'], // Albania @@ -357,8 +368,8 @@ public function getIbansWithValidFormatButIncorrectChecksum() ['BR9700360305000010009795493P2'], // Brazil ['BR1800000000141455123924100C3'], // Brazil ['VG96VPVG0000012345678902'], // British Virgin Islands - ['BF1030134020015400945000644'], // Burkina Faso - ['BI43201011067445'], // Burundi + ['BF41BF0840101300463574000390'], // Burkina Faso + ['BI3210000100010000332045181'], // Burundi ['CM2110003001000500000605307'], // Cameroon ['CV64000300004547069110177'], // Cape Verde ['FR7630007000110009970004943'], // Central African Republic @@ -383,7 +394,7 @@ public function getIbansWithValidFormatButIncorrectChecksum() ['XK051212012345678907'], // Republic of Kosovo ['PT50000200000163099310356'], // Sao Tome and Principe ['SA0380000000608010167518'], // Saudi Arabia - ['SN12K00100152000025690007543'], // Senegal + ['SN07SN0100152000048500003035'], // Senegal ['TL380080012345678910158'], // Timor-Leste ['TN5914207207100707129649'], // Tunisia ['TR330006100519786457841327'], // Turkey @@ -401,7 +412,7 @@ public function testIbansWithUnsupportedCountryCode($countryCode) $this->assertViolationRaised($countryCode.'260211000000230064016', Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR); } - public function getUnsupportedCountryCodes() + public static function getUnsupportedCountryCodes() { return [ ['AG'], @@ -443,7 +454,7 @@ public function testLoadFromAttribute() ->assertRaised(); } - public function getIbansWithInvalidCountryCode() + public static function getIbansWithInvalidCountryCode() { return [ ['0750447346'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index 98c467bc7627e..f9cc83b515b40 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new IdenticalToValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new IdenticalTo($options); } @@ -35,15 +35,16 @@ protected function getErrorCode(): ?string return IdenticalTo::NOT_IDENTICAL_ERROR; } - public function provideAllValidComparisons(): array + public static function provideAllValidComparisons(): array { - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); // Don't call addPhp5Dot5Comparisons() automatically, as it does // not take care of identical objects - $comparisons = $this->provideValidComparisons(); + $comparisons = self::provideValidComparisons(); - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $comparisons; } @@ -51,7 +52,7 @@ public function provideAllValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { $date = new \DateTime('2000-01-01'); $object = new ComparisonTest_Class(2); @@ -73,7 +74,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [5], @@ -83,7 +84,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'int'], @@ -95,7 +96,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', false], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index b43e76559e709..862876a0b6ef5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -91,7 +91,7 @@ public function testFileNotFound(Image $constraint) ->assertRaised(); } - public function provideConstraintsWithNotFoundMessage(): iterable + public static function provideConstraintsWithNotFoundMessage(): iterable { yield 'Doctrine style' => [new Image([ 'notFoundMessage' => 'myMessage', @@ -132,7 +132,7 @@ public function testWidthTooSmall(Image $constraint) ->assertRaised(); } - public function provideMinWidthConstraints(): iterable + public static function provideMinWidthConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'minWidth' => 3, @@ -160,7 +160,7 @@ public function testWidthTooBig(Image $constraint) ->assertRaised(); } - public function provideMaxWidthConstraints(): iterable + public static function provideMaxWidthConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'maxWidth' => 1, @@ -188,7 +188,7 @@ public function testHeightTooSmall(Image $constraint) ->assertRaised(); } - public function provideMinHeightConstraints(): iterable + public static function provideMinHeightConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'minHeight' => 3, @@ -216,7 +216,7 @@ public function testHeightTooBig(Image $constraint) ->assertRaised(); } - public function provideMaxHeightConstraints(): iterable + public static function provideMaxHeightConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'maxHeight' => 1, @@ -246,7 +246,7 @@ public function testPixelsTooFew(Image $constraint) ->assertRaised(); } - public function provideMinPixelsConstraints(): iterable + public static function provideMinPixelsConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'minPixels' => 5, @@ -276,7 +276,7 @@ public function testPixelsTooMany(Image $constraint) ->assertRaised(); } - public function provideMaxPixelsConstraints(): iterable + public static function provideMaxPixelsConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'maxPixels' => 3, @@ -364,7 +364,7 @@ public function testRatioTooSmall(Image $constraint) ->assertRaised(); } - public function provideMinRatioConstraints(): iterable + public static function provideMinRatioConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'minRatio' => 2, @@ -392,7 +392,7 @@ public function testRatioTooBig(Image $constraint) ->assertRaised(); } - public function provideMaxRatioConstraints(): iterable + public static function provideMaxRatioConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'maxRatio' => 0.5, @@ -473,7 +473,7 @@ public function testSquareNotAllowed(Image $constraint) ->assertRaised(); } - public function provideAllowSquareConstraints(): iterable + public static function provideAllowSquareConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'allowSquare' => false, @@ -501,7 +501,7 @@ public function testLandscapeNotAllowed(Image $constraint) ->assertRaised(); } - public function provideAllowLandscapeConstraints(): iterable + public static function provideAllowLandscapeConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'allowLandscape' => false, @@ -529,7 +529,7 @@ public function testPortraitNotAllowed(Image $constraint) ->assertRaised(); } - public function provideAllowPortraitConstraints(): iterable + public static function provideAllowPortraitConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'allowPortrait' => false, @@ -578,7 +578,7 @@ public function testInvalidMimeType() ->assertRaised(); } - public function provideDetectCorruptedConstraints(): iterable + public static function provideDetectCorruptedConstraints(): iterable { yield 'Doctrine style' => [new Image([ 'detectCorrupted' => true, diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index f2cfa0a3f1490..b00f942441f55 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -64,7 +64,7 @@ public function testValidIpsV4($ip) $this->assertNoViolation(); } - public function getValidIpsV4() + public static function getValidIpsV4() { return [ ['0.0.0.0'], @@ -104,7 +104,7 @@ public function testValidIpV6WithWhitespacesNamed() $this->assertNoViolation(); } - public function getValidIpsV4WithWhitespaces() + public static function getValidIpsV4WithWhitespaces() { return [ ["\x200.0.0.0"], @@ -128,7 +128,7 @@ public function testValidIpsV6($ip) $this->assertNoViolation(); } - public function getValidIpsV6() + public static function getValidIpsV6() { return [ ['2001:0db8:85a3:0000:0000:8a2e:0370:7334'], @@ -165,9 +165,9 @@ public function testValidIpsAll($ip) $this->assertNoViolation(); } - public function getValidIpsAll() + public static function getValidIpsAll() { - return array_merge($this->getValidIpsV4(), $this->getValidIpsV6()); + return array_merge(self::getValidIpsV4(), self::getValidIpsV6()); } /** @@ -188,7 +188,7 @@ public function testInvalidIpsV4($ip) ->assertRaised(); } - public function getInvalidIpsV4() + public static function getInvalidIpsV4() { return [ ['0'], @@ -221,7 +221,7 @@ public function testInvalidPrivateIpsV4($ip) ->assertRaised(); } - public function getInvalidPrivateIpsV4() + public static function getInvalidPrivateIpsV4() { return [ ['10.0.0.0'], @@ -248,7 +248,7 @@ public function testInvalidReservedIpsV4($ip) ->assertRaised(); } - public function getInvalidReservedIpsV4() + public static function getInvalidReservedIpsV4() { return [ ['0.0.0.0'], @@ -275,9 +275,9 @@ public function testInvalidPublicIpsV4($ip) ->assertRaised(); } - public function getInvalidPublicIpsV4() + public static function getInvalidPublicIpsV4() { - return array_merge($this->getInvalidPrivateIpsV4(), $this->getInvalidReservedIpsV4()); + return array_merge(self::getInvalidPrivateIpsV4(), self::getInvalidReservedIpsV4()); } /** @@ -298,7 +298,7 @@ public function testInvalidIpsV6($ip) ->assertRaised(); } - public function getInvalidIpsV6() + public static function getInvalidIpsV6() { return [ ['z001:0db8:85a3:0000:0000:8a2e:0370:7334'], @@ -335,7 +335,7 @@ public function testInvalidPrivateIpsV6($ip) ->assertRaised(); } - public function getInvalidPrivateIpsV6() + public static function getInvalidPrivateIpsV6() { return [ ['fdfe:dcba:9876:ffff:fdc6:c46b:bb8f:7d4c'], @@ -362,12 +362,12 @@ public function testInvalidReservedIpsV6($ip) ->assertRaised(); } - public function getInvalidReservedIpsV6() + public static function getInvalidReservedIpsV6() { // Quoting after official filter documentation: // "FILTER_FLAG_NO_RES_RANGE = This flag does not apply to IPv6 addresses." // Full description: https://php.net/filter.filters.flags - return $this->getInvalidIpsV6(); + return self::getInvalidIpsV6(); } /** @@ -388,9 +388,9 @@ public function testInvalidPublicIpsV6($ip) ->assertRaised(); } - public function getInvalidPublicIpsV6() + public static function getInvalidPublicIpsV6() { - return array_merge($this->getInvalidPrivateIpsV6(), $this->getInvalidReservedIpsV6()); + return array_merge(self::getInvalidPrivateIpsV6(), self::getInvalidReservedIpsV6()); } /** @@ -411,9 +411,9 @@ public function testInvalidIpsAll($ip) ->assertRaised(); } - public function getInvalidIpsAll() + public static function getInvalidIpsAll() { - return array_merge($this->getInvalidIpsV4(), $this->getInvalidIpsV6()); + return array_merge(self::getInvalidIpsV4(), self::getInvalidIpsV6()); } /** @@ -434,9 +434,9 @@ public function testInvalidPrivateIpsAll($ip) ->assertRaised(); } - public function getInvalidPrivateIpsAll() + public static function getInvalidPrivateIpsAll() { - return array_merge($this->getInvalidPrivateIpsV4(), $this->getInvalidPrivateIpsV6()); + return array_merge(self::getInvalidPrivateIpsV4(), self::getInvalidPrivateIpsV6()); } /** @@ -457,9 +457,9 @@ public function testInvalidReservedIpsAll($ip) ->assertRaised(); } - public function getInvalidReservedIpsAll() + public static function getInvalidReservedIpsAll() { - return array_merge($this->getInvalidReservedIpsV4(), $this->getInvalidReservedIpsV6()); + return array_merge(self::getInvalidReservedIpsV4(), self::getInvalidReservedIpsV6()); } /** @@ -480,8 +480,8 @@ public function testInvalidPublicIpsAll($ip) ->assertRaised(); } - public function getInvalidPublicIpsAll() + public static function getInvalidPublicIpsAll() { - return array_merge($this->getInvalidPublicIpsV4(), $this->getInvalidPublicIpsV6()); + return array_merge(self::getInvalidPublicIpsV4(), self::getInvalidPublicIpsV6()); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php index 1ec75dcb844e4..567ddfe99b838 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php @@ -49,7 +49,7 @@ public function testTrueIsInvalid(IsFalse $constraint) ->assertRaised(); } - public function provideInvalidConstraints(): iterable + public static function provideInvalidConstraints(): iterable { yield 'Doctrine style' => [new IsFalse([ 'message' => 'myMessage', diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php index f3128eb23e38e..ce8d89362d900 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php @@ -48,6 +48,7 @@ public function testInvalidValues($value, $valueAsString) /** * @requires PHP 8 + * * @dataProvider getInvalidValues */ public function testInvalidValuesNamed($value, $valueAsString) @@ -62,7 +63,7 @@ public function testInvalidValuesNamed($value, $valueAsString) ->assertRaised(); } - public function getInvalidValues() + public static function getInvalidValues() { return [ [0, '0'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php index e12cbdde3f20b..81c6067eace92 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php @@ -49,7 +49,7 @@ public function testFalseIsInvalid(IsTrue $constraint) ->assertRaised(); } - public function provideInvalidConstraints(): iterable + public static function provideInvalidConstraints(): iterable { yield 'Doctrine style' => [new IsTrue([ 'message' => 'myMessage', diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index 25889b0778386..fc872ad471e79 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -26,7 +26,7 @@ protected function createValidator() return new IsbnValidator(); } - public function getValidIsbn10() + public static function getValidIsbn10() { return [ ['2723442284'], @@ -45,7 +45,7 @@ public function getValidIsbn10() ]; } - public function getInvalidIsbn10() + public static function getInvalidIsbn10() { return [ ['27234422841', Isbn::TOO_LONG_ERROR], @@ -65,7 +65,7 @@ public function getInvalidIsbn10() ]; } - public function getValidIsbn13() + public static function getValidIsbn13() { return [ ['978-2723442282'], @@ -83,7 +83,7 @@ public function getValidIsbn13() ]; } - public function getInvalidIsbn13() + public static function getInvalidIsbn13() { return [ ['978-27234422821', Isbn::TOO_LONG_ERROR], @@ -103,19 +103,19 @@ public function getInvalidIsbn13() ]; } - public function getValidIsbn() + public static function getValidIsbn() { return array_merge( - $this->getValidIsbn10(), - $this->getValidIsbn13() + self::getValidIsbn10(), + self::getValidIsbn13() ); } - public function getInvalidIsbn() + public static function getInvalidIsbn() { return array_merge( - $this->getInvalidIsbn10(), - $this->getInvalidIsbn13() + self::getInvalidIsbn10(), + self::getInvalidIsbn13() ); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsinValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsinValidatorTest.php index 9f19493937abc..44c55d9fc74ff 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsinValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsinValidatorTest.php @@ -47,7 +47,7 @@ public function testValidIsin($isin) $this->assertNoViolation(); } - public function getValidIsin() + public static function getValidIsin() { return [ ['XS2125535901'], // Goldman Sachs International @@ -71,7 +71,7 @@ public function testIsinWithInvalidFormat($isin) $this->assertViolationRaised($isin, Isin::INVALID_LENGTH_ERROR); } - public function getIsinWithInvalidLenghFormat() + public static function getIsinWithInvalidLenghFormat() { return [ ['X'], @@ -96,7 +96,7 @@ public function testIsinWithInvalidPattern($isin) $this->assertViolationRaised($isin, Isin::INVALID_PATTERN_ERROR); } - public function getIsinWithInvalidPattern() + public static function getIsinWithInvalidPattern() { return [ ['X12155696679'], @@ -115,7 +115,7 @@ public function testIsinWithValidFormatButIncorrectChecksum($isin) $this->assertViolationRaised($isin, Isin::INVALID_CHECKSUM_ERROR); } - public function getIsinWithValidFormatButIncorrectChecksum() + public static function getIsinWithValidFormatButIncorrectChecksum() { return [ ['XS2112212144'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php index ea2ca4ecd6169..287f8c14477e8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -26,7 +26,7 @@ protected function createValidator() return new IssnValidator(); } - public function getValidLowerCasedIssn() + public static function getValidLowerCasedIssn() { return [ ['2162-321x'], @@ -39,7 +39,7 @@ public function getValidLowerCasedIssn() ]; } - public function getValidNonHyphenatedIssn() + public static function getValidNonHyphenatedIssn() { return [ ['2162321X'], @@ -52,7 +52,7 @@ public function getValidNonHyphenatedIssn() ]; } - public function getFullValidIssn() + public static function getFullValidIssn() { return [ ['1550-7416'], @@ -66,16 +66,16 @@ public function getFullValidIssn() ]; } - public function getValidIssn() + public static function getValidIssn() { return array_merge( - $this->getValidLowerCasedIssn(), - $this->getValidNonHyphenatedIssn(), - $this->getFullValidIssn() + self::getValidLowerCasedIssn(), + self::getValidNonHyphenatedIssn(), + self::getFullValidIssn() ); } - public function getInvalidIssn() + public static function getInvalidIssn() { return [ [0, Issn::TOO_SHORT_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/JsonValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/JsonValidatorTest.php index 6c94c1d8df6cc..a336e680d2790 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/JsonValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/JsonValidatorTest.php @@ -49,7 +49,7 @@ public function testInvalidValues($value) ->assertRaised(); } - public function getValidValues() + public static function getValidValues() { return [ ['{"planet":"earth", "country": "Morocco","city": "Rabat" ,"postcode" : 10160, "is_great": true, @@ -65,7 +65,7 @@ public function getValidValues() ]; } - public function getInvalidValues() + public static function getInvalidValues() { return [ ['{"foo": 3 "bar": 4}'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 23df113872367..15f7ddc42602f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -70,7 +70,7 @@ public function testValidLanguages($language) $this->assertNoViolation(); } - public function getValidLanguages() + public static function getValidLanguages() { return [ ['en'], @@ -95,7 +95,7 @@ public function testInvalidLanguages($language) ->assertRaised(); } - public function getInvalidLanguages() + public static function getInvalidLanguages() { return [ ['EN'], @@ -115,7 +115,7 @@ public function testValidAlpha3Languages($language) $this->assertNoViolation(); } - public function getValidAlpha3Languages() + public static function getValidAlpha3Languages() { return [ ['deu'], @@ -142,7 +142,7 @@ public function testInvalidAlpha3Languages($language) ->assertRaised(); } - public function getInvalidAlpha3Languages() + public static function getInvalidAlpha3Languages() { return [ ['foobar'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php index 90c57bed6d1b7..2a30dca1432b6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php @@ -48,6 +48,7 @@ public function testInvalidNormalizerObjectThrowsException() /** * @group legacy + * * @dataProvider allowEmptyStringOptionData */ public function testDeprecatedAllowEmptyStringOption(bool $value) @@ -57,7 +58,7 @@ public function testDeprecatedAllowEmptyStringOption(bool $value) new Length(['allowEmptyString' => $value, 'max' => 5]); } - public function allowEmptyStringOptionData() + public static function allowEmptyStringOptionData() { return [ [true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index 5772d6e0a8308..f8ce331430d40 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -62,7 +62,7 @@ public function testExpectsStringCompatibleType() $this->validator->validate(new \stdClass(), new Length(['value' => 5])); } - public function getThreeOrLessCharacters() + public static function getThreeOrLessCharacters() { return [ [12], @@ -76,7 +76,7 @@ public function getThreeOrLessCharacters() ]; } - public function getFourCharacters() + public static function getFourCharacters() { return [ [1234], @@ -86,7 +86,7 @@ public function getFourCharacters() ]; } - public function getFiveOrMoreCharacters() + public static function getFiveOrMoreCharacters() { return [ [12345], @@ -100,7 +100,7 @@ public function getFiveOrMoreCharacters() ]; } - public function getOneCharset() + public static function getOneCharset() { return [ ['é', 'utf8', true], @@ -110,7 +110,7 @@ public function getOneCharset() ]; } - public function getThreeCharactersWithWhitespaces() + public static function getThreeCharactersWithWhitespaces() { return [ ["\x20ccc"], @@ -189,6 +189,7 @@ public function testInvalidValuesMin($value) /** * @requires PHP 8 + * * @dataProvider getThreeOrLessCharacters */ public function testInvalidValuesMinNamed($value) @@ -229,6 +230,7 @@ public function testInvalidValuesMax($value) /** * @requires PHP 8 + * * @dataProvider getFiveOrMoreCharacters */ public function testInvalidValuesMaxNamed($value) @@ -270,6 +272,7 @@ public function testInvalidValuesExactLessThanFour($value) /** * @requires PHP 8 + * * @dataProvider getThreeOrLessCharacters */ public function testInvalidValuesExactLessThanFourNamed($value) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index 73c9a1d154f17..6072f6f2275e9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new LessThanOrEqualValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new LessThanOrEqual($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [1, 2], @@ -60,7 +60,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [4], @@ -71,7 +71,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [2, '2', 1, '1', 'int'], @@ -83,7 +83,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php index 24a2a3c9c53e9..c5874ed5b5368 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php @@ -21,7 +21,7 @@ */ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanOrEqualValidatorTest { - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new NegativeOrZero(); } @@ -29,7 +29,7 @@ protected function createConstraint(array $options = null): Constraint /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [0, 0], @@ -43,7 +43,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [2, '2', 0, '0', 'int'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index 7241203fcb3d7..acc815a04530b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new LessThanValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new LessThan($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [1, 2], @@ -54,7 +54,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [4], @@ -64,7 +64,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [3, '3', 2, '2', 'int'], @@ -81,7 +81,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php index aba9f78c4b8e3..5e7173c304f40 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php @@ -21,7 +21,7 @@ */ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest { - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new Negative(); } @@ -29,7 +29,7 @@ protected function createConstraint(array $options = null): Constraint /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [-1, 0], @@ -42,7 +42,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [0, '0', 0, '0', 'int'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 7c3746f5c8fe3..91153cad47736 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -53,7 +53,7 @@ public function testValidLocales($locale) $this->assertNoViolation(); } - public function getValidLocales() + public static function getValidLocales() { return [ ['en'], @@ -83,7 +83,7 @@ public function testInvalidLocales($locale) ->assertRaised(); } - public function getInvalidLocales() + public static function getInvalidLocales() { return [ ['baz'], @@ -154,7 +154,7 @@ public function testInvalidLocaleWithoutCanonicalizationNamed() ->assertRaised(); } - public function getUncanonicalizedLocales(): iterable + public static function getUncanonicalizedLocales(): iterable { return [ ['en-US'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php index 5dc15b41a9705..17f38bee4c8d7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php @@ -47,7 +47,7 @@ public function testValidNumbers($number) $this->assertNoViolation(); } - public function getValidNumbers() + public static function getValidNumbers() { return [ ['42424242424242424242'], @@ -88,7 +88,7 @@ public function testInvalidNumbers($number, $code) ->assertRaised(); } - public function getInvalidNumbers() + public static function getInvalidNumbers() { return [ ['1234567812345678', Luhn::CHECKSUM_FAILED_ERROR], @@ -110,7 +110,7 @@ public function testInvalidTypes($number) $this->validator->validate($number, $constraint); } - public function getInvalidTypes() + public static function getInvalidTypes() { return [ [0], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php index 3bf322052759a..1437c01093c76 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php @@ -32,7 +32,7 @@ public function testValidValues($value) $this->assertNoViolation(); } - public function getValidValues() + public static function getValidValues() { return [ ['foobar'], @@ -143,7 +143,7 @@ public function testNormalizedStringIsInvalid($value) ->assertRaised(); } - public function getWhitespaces() + public static function getWhitespaces() { return [ ["\x20"], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php index 4209c45c771ec..8a3d343b2011a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php @@ -103,7 +103,7 @@ public function testThresholdNotReached(NotCompromisedPassword $constraint) $this->assertNoViolation(); } - public function provideConstraintsWithThreshold(): iterable + public static function provideConstraintsWithThreshold(): iterable { yield 'Doctrine style' => [new NotCompromisedPassword(['threshold' => 10])]; @@ -218,7 +218,7 @@ public function testApiErrorSkipped(NotCompromisedPassword $constraint) $this->assertTrue(true); // No exception have been thrown } - public function provideErrorSkippingConstraints(): iterable + public static function provideErrorSkippingConstraints(): iterable { yield 'Doctrine style' => [new NotCompromisedPassword(['skipOnError' => true])]; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index 47cdcac966b62..465458b07c0d4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new NotEqualToValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new NotEqualTo($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [1, 2], @@ -54,7 +54,7 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [0], @@ -64,7 +64,7 @@ public function provideValidComparisonsToPropertyPath(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { return [ [3, '3', 3, '3', 'int'], @@ -77,7 +77,7 @@ public function provideInvalidComparisons(): array ]; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 41660bda517a8..49cff99122d9d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -25,7 +25,7 @@ protected function createValidator() return new NotIdenticalToValidator(); } - protected function createConstraint(array $options = null): Constraint + protected static function createConstraint(array $options = null): Constraint { return new NotIdenticalTo($options); } @@ -38,7 +38,7 @@ protected function getErrorCode(): ?string /** * {@inheritdoc} */ - public function provideValidComparisons(): array + public static function provideValidComparisons(): array { return [ [1, 2], @@ -57,22 +57,23 @@ public function provideValidComparisons(): array /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath(): array + public static function provideValidComparisonsToPropertyPath(): array { return [ [0], ]; } - public function provideAllInvalidComparisons(): array + public static function provideAllInvalidComparisons(): array { - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); // Don't call addPhp5Dot5Comparisons() automatically, as it does // not take care of identical objects - $comparisons = $this->provideInvalidComparisons(); + $comparisons = self::provideInvalidComparisons(); - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $comparisons; } @@ -80,7 +81,7 @@ public function provideAllInvalidComparisons(): array /** * {@inheritdoc} */ - public function provideInvalidComparisons(): array + public static function provideInvalidComparisons(): array { $date = new \DateTime('2000-01-01'); $object = new ComparisonTest_Class(2); @@ -95,7 +96,7 @@ public function provideInvalidComparisons(): array return $comparisons; } - public function provideComparisonsToNullValueAtPropertyPath() + public static function provideComparisonsToNullValueAtPropertyPath() { return [ [5, '5', true], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php index abaa7f874a530..1b54c420dbf9a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php @@ -32,7 +32,7 @@ public function testValidValues($value) $this->assertNoViolation(); } - public function getValidValues() + public static function getValidValues() { return [ [0], @@ -55,7 +55,7 @@ public function testNullIsInvalid(NotNull $constraint) ->assertRaised(); } - public function provideInvalidConstraints(): iterable + public static function provideInvalidConstraints(): iterable { yield 'Doctrine style' => [new NotNull([ 'message' => 'myMessage', diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php index 542cb3996d10c..4dcd77ca9b2c1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php @@ -74,7 +74,7 @@ public function testThrowsNoDefaultOptionConfiguredException() new Range('value'); } - public function provideDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet(): array + public static function provideDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet(): array { return [ [['min' => 1, 'max' => 10, 'minMessage' => 'my_min_message'], true, false], @@ -85,6 +85,7 @@ public function provideDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet( /** * @group legacy + * * @dataProvider provideDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet */ public function testDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet(array $options, bool $expectedDeprecatedMinMessageSet, bool $expectedDeprecatedMaxMessageSet) @@ -96,7 +97,7 @@ public function testDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet(arr $this->assertEquals($expectedDeprecatedMaxMessageSet, $sut->deprecatedMaxMessageSet); } - public function provideDeprecationNotTriggeredIfNotMinMaxOrNotMinMessageNorMaxMessageSet(): array + public static function provideDeprecationNotTriggeredIfNotMinMaxOrNotMinMessageNorMaxMessageSet(): array { return [ [['min' => 1, 'minMessage' => 'my_min_message', 'maxMessage' => 'my_max_message']], @@ -107,6 +108,7 @@ public function provideDeprecationNotTriggeredIfNotMinMaxOrNotMinMessageNorMaxMe /** * @doesNotPerformAssertions + * * @dataProvider provideDeprecationNotTriggeredIfNotMinMaxOrNotMinMessageNorMaxMessageSet */ public function testDeprecationNotTriggeredIfNotMinMaxOrNotMinMessageNorMaxMessageSet(array $options) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index 7a34810bdfab8..2f7da24176cfb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -31,7 +31,7 @@ public function testNullIsValid() $this->assertNoViolation(); } - public function getTenToTwenty() + public static function getTenToTwenty() { return [ [10.00001], @@ -45,7 +45,7 @@ public function getTenToTwenty() ]; } - public function getLessThanTen() + public static function getLessThanTen() { return [ [9.99999, '9.99999'], @@ -55,7 +55,7 @@ public function getLessThanTen() ]; } - public function getMoreThanTwenty() + public static function getMoreThanTwenty() { return [ [20.000001, '20.000001'], @@ -78,6 +78,7 @@ public function testValidValuesMin($value) /** * @requires PHP 8 + * * @dataProvider getTenToTwenty */ public function testValidValuesMinNamed($value) @@ -101,6 +102,7 @@ public function testValidValuesMax($value) /** * @requires PHP 8 + * * @dataProvider getTenToTwenty */ public function testValidValuesMaxNamed($value) @@ -124,6 +126,7 @@ public function testValidValuesMinMax($value) /** * @requires PHP 8 + * * @dataProvider getTenToTwenty */ public function testValidValuesMinMaxNamed($value) @@ -155,6 +158,7 @@ public function testInvalidValuesMin($value, $formattedValue) /** * @requires PHP 8 + * * @dataProvider getLessThanTen */ public function testInvalidValuesMinNamed($value, $formattedValue) @@ -191,6 +195,7 @@ public function testInvalidValuesMax($value, $formattedValue) /** * @requires PHP 8 + * * @dataProvider getMoreThanTwenty */ public function testInvalidValuesMaxNamed($value, $formattedValue) @@ -229,6 +234,7 @@ public function testInvalidValuesCombinedMax($value, $formattedValue) /** * @requires PHP 8 + * * @dataProvider getMoreThanTwenty */ public function testInvalidValuesCombinedMaxNamed($value, $formattedValue) @@ -268,6 +274,7 @@ public function testInvalidValuesCombinedMin($value, $formattedValue) /** * @requires PHP 8 + * * @dataProvider getLessThanTen */ public function testInvalidValuesCombinedMinNamed($value, $formattedValue) @@ -284,11 +291,12 @@ public function testInvalidValuesCombinedMinNamed($value, $formattedValue) ->assertRaised(); } - public function getTenthToTwentiethMarch2014() + public static function getTenthToTwentiethMarch2014() { // The provider runs before setUp(), so we need to manually fix // the default timezone - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); $tests = [ [new \DateTime('March 10, 2014')], @@ -300,16 +308,17 @@ public function getTenthToTwentiethMarch2014() $tests[] = [new \DateTimeImmutable('March 15, 2014')]; $tests[] = [new \DateTimeImmutable('March 20, 2014')]; - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $tests; } - public function getSoonerThanTenthMarch2014() + public static function getSoonerThanTenthMarch2014() { // The provider runs before setUp(), so we need to manually fix // the default timezone - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); $tests = [ [new \DateTime('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'], @@ -319,16 +328,17 @@ public function getSoonerThanTenthMarch2014() $tests[] = [new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM']; $tests[] = [new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM']; - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $tests; } - public function getLaterThanTwentiethMarch2014() + public static function getLaterThanTwentiethMarch2014() { // The provider runs before setUp(), so we need to manually fix // the default timezone - $this->setDefaultTimezone('UTC'); + $timezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); $tests = [ [new \DateTime('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'], @@ -338,7 +348,7 @@ public function getLaterThanTwentiethMarch2014() $tests[] = [new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM']; $tests[] = [new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM']; - $this->restoreDefaultTimezone(); + date_default_timezone_set($timezone); return $tests; } @@ -600,7 +610,7 @@ public function testThrowsOnInvalidStringDates($expectedMessage, $value, $min, $ ])); } - public function throwsOnInvalidStringDatesProvider(): array + public static function throwsOnInvalidStringDatesProvider(): array { return [ ['The min value "foo" could not be converted to a "DateTimeImmutable" instance in the "Symfony\Component\Validator\Constraints\Range" constraint.', new \DateTimeImmutable(), 'foo', null], @@ -639,6 +649,7 @@ public function testValidValuesMinPropertyPath($value) /** * @requires PHP 8 + * * @dataProvider getTenToTwenty */ public function testValidValuesMinPropertyPathNamed($value) @@ -666,6 +677,7 @@ public function testValidValuesMaxPropertyPath($value) /** * @requires PHP 8 + * * @dataProvider getTenToTwenty */ public function testValidValuesMaxPropertyPathNamed($value) @@ -763,6 +775,7 @@ public function testInvalidValuesCombinedMaxPropertyPath($value, $formattedValue /** * @requires PHP 8 + * * @dataProvider getMoreThanTwenty */ public function testInvalidValuesCombinedMaxPropertyPathNamed($value, $formattedValue) @@ -814,6 +827,7 @@ public function testInvalidValuesCombinedMinPropertyPath($value, $formattedValue /** * @requires PHP 8 + * * @dataProvider getLessThanTen */ public function testInvalidValuesCombinedMinPropertyPathNamed($value, $formattedValue) @@ -1028,7 +1042,7 @@ public function testInvalidDatesCombinedMinPropertyPath($value, $dateTimeAsStrin ->assertRaised(); } - public function provideMessageIfMinAndMaxSet(): array + public static function provideMessageIfMinAndMaxSet(): array { $notInRangeMessage = (new Range(['min' => '']))->notInRangeMessage; @@ -1074,6 +1088,7 @@ public function provideMessageIfMinAndMaxSet(): array /** * @group legacy + * * @dataProvider provideMessageIfMinAndMaxSet */ public function testMessageIfMinAndMaxSet(array $constraintExtraOptions, int $value, string $expectedMessage, string $expectedCode) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php index 1b9f25c362325..384e53fe744b0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php @@ -29,7 +29,7 @@ public function testConstraintGetDefaultOption() $this->assertSame('/^[0-9]+$/', $constraint->pattern); } - public function provideHtmlPatterns() + public static function provideHtmlPatterns() { return [ // HTML5 wraps the pattern in ^(?:pattern)$ diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 63645ca04e162..7589b3d607193 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -67,6 +67,7 @@ public function testValidValuesWithWhitespaces($value) /** * @requires PHP 8 + * * @dataProvider getValidValuesWithWhitespaces */ public function testValidValuesWithWhitespacesNamed($value) @@ -77,7 +78,7 @@ public function testValidValuesWithWhitespacesNamed($value) $this->assertNoViolation(); } - public function getValidValues() + public static function getValidValues() { return [ [0], @@ -93,7 +94,7 @@ public function __toString(): string ]; } - public function getValidValuesWithWhitespaces() + public static function getValidValuesWithWhitespaces() { return [ ["\x207"], @@ -125,6 +126,7 @@ public function testInvalidValues($value) /** * @requires PHP 8 + * * @dataProvider getInvalidValues */ public function testInvalidValuesNamed($value) @@ -139,7 +141,7 @@ public function testInvalidValuesNamed($value) ->assertRaised(); } - public function getInvalidValues() + public static function getInvalidValues() { return [ ['abcd'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index 0e0a23fbb3cbc..80d21d5c28d35 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -53,7 +53,7 @@ public function testValidTimes($time) $this->assertNoViolation(); } - public function getValidTimes() + public static function getValidTimes() { return [ ['01:02:03'], @@ -79,7 +79,7 @@ public function testInvalidTimes($time, $code) ->assertRaised(); } - public function getInvalidTimes() + public static function getInvalidTimes() { return [ ['foobar', Time::INVALID_FORMAT_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php index 271b17174cb39..e5a0cd3668646 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php @@ -59,7 +59,7 @@ public function testExceptionForInvalidGroupedTimezones(int $zone) new Timezone(['zone' => $zone]); } - public function provideInvalidZones(): iterable + public static function provideInvalidZones(): iterable { yield [-1]; yield [0]; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php index 3b00b75acdc95..3e0b23f0498eb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php @@ -57,7 +57,7 @@ public function testValidTimezones(string $timezone) $this->assertNoViolation(); } - public function getValidTimezones(): iterable + public static function getValidTimezones(): iterable { // ICU standard (alias/BC in PHP) yield ['Etc/UTC']; @@ -105,7 +105,7 @@ public function testValidGroupedTimezones(string $timezone, int $zone) $this->assertNoViolation(); } - public function getValidGroupedTimezones(): iterable + public static function getValidGroupedTimezones(): iterable { yield ['America/Buenos_Aires', \DateTimeZone::AMERICA | \DateTimeZone::AUSTRALIA]; // icu yield ['America/Argentina/Buenos_Aires', \DateTimeZone::AMERICA]; // php @@ -141,7 +141,7 @@ public function testInvalidTimezoneWithoutZone(string $timezone) ->assertRaised(); } - public function getInvalidTimezones(): iterable + public static function getInvalidTimezones(): iterable { yield ['Buenos_Aires/America']; yield ['Buenos_Aires/Argentina/America']; @@ -167,7 +167,7 @@ public function testInvalidGroupedTimezones(string $timezone, int $zone) ->assertRaised(); } - public function getInvalidGroupedTimezones(): iterable + public static function getInvalidGroupedTimezones(): iterable { yield ['America/Buenos_Aires', \DateTimeZone::ASIA | \DateTimeZone::AUSTRALIA]; // icu yield ['America/Argentina/Buenos_Aires', \DateTimeZone::EUROPE]; // php @@ -210,7 +210,7 @@ public function testValidGroupedTimezonesByCountry(string $timezone, string $cou $this->assertNoViolation(); } - public function getValidGroupedTimezonesByCountry(): iterable + public static function getValidGroupedTimezonesByCountry(): iterable { yield ['America/Buenos_Aires', 'AR']; // icu yield ['America/Argentina/Buenos_Aires', 'AR']; // php @@ -251,7 +251,7 @@ public function testInvalidGroupedTimezonesByCountry(string $timezone, string $c ->assertRaised(); } - public function getInvalidGroupedTimezonesByCountry(): iterable + public static function getInvalidGroupedTimezonesByCountry(): iterable { yield ['America/Argentina/Cordoba', 'FR']; yield ['America/Barbados', 'PT']; @@ -305,7 +305,7 @@ public function testDeprecatedTimezonesAreInvalidWithoutBC(string $timezone) ->assertRaised(); } - public function getDeprecatedTimezones(): iterable + public static function getDeprecatedTimezones(): iterable { yield ['Australia/ACT']; yield ['Australia/LHI']; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index 024de4553693b..e7687da58a345 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -70,10 +70,10 @@ public function testValidValues($value, $type) $this->assertNoViolation(); } - public function getValidValues() + public static function getValidValues() { $object = new \stdClass(); - $file = $this->createFile(); + $file = self::createFile(); return [ [true, 'Boolean'], @@ -126,10 +126,10 @@ public function testInvalidValues($value, $type, $valueAsString) ->assertRaised(); } - public function getInvalidValues() + public static function getInvalidValues() { $object = new \stdClass(); - $file = $this->createFile(); + $file = self::createFile(); return [ ['foobar', 'numeric', '"foobar"'], @@ -175,7 +175,7 @@ public function testValidValuesMultipleTypes($value, array $types) $this->assertNoViolation(); } - public function getValidValuesMultipleTypes() + public static function getValidValuesMultipleTypes() { return [ ['12345', ['array', 'string']], @@ -197,7 +197,7 @@ public function testInvalidValuesMultipleTypes(Type $constraint) ->assertRaised(); } - public function provideConstraintsWithMultipleTypes() + public static function provideConstraintsWithMultipleTypes() { yield 'Doctrine style' => [new Type([ 'type' => ['boolean', 'array'], @@ -209,20 +209,20 @@ public function provideConstraintsWithMultipleTypes() } } - protected function createFile() + protected static function createFile() { - if (!static::$file) { - static::$file = fopen(__FILE__, 'r'); + if (!self::$file) { + self::$file = fopen(__FILE__, 'r'); } - return static::$file; + return self::$file; } public static function tearDownAfterClass(): void { - if (static::$file) { - fclose(static::$file); - static::$file = null; + if (self::$file) { + fclose(self::$file); + self::$file = null; } } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UlidValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UlidValidatorTest.php index 8948cbabd8d9f..626b6bbceff0b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UlidValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UlidValidatorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use stdClass; use Symfony\Component\Validator\Constraints\Ulid; use Symfony\Component\Validator\Constraints\UlidValidator; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -44,7 +43,7 @@ public function testEmptyStringIsValid() public function testExpectsStringCompatibleType() { $this->expectException(UnexpectedValueException::class); - $this->validator->validate(new stdClass(), new Ulid()); + $this->validator->validate(new \stdClass(), new Ulid()); } public function testValidUlid() @@ -71,7 +70,7 @@ public function testInvalidUlid(string $ulid, string $code) ->assertRaised(); } - public function getInvalidUlids() + public static function getInvalidUlids() { return [ ['01ARZ3NDEKTSV4RRFFQ69G5FA', Ulid::TOO_SHORT_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php index 6b892cb0a5ca5..417050bd8e67d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php @@ -39,7 +39,7 @@ public function testValidValues($value) $this->assertNoViolation(); } - public function getValidValues() + public static function getValidValues() { return [ yield 'null' => [[null]], @@ -72,7 +72,7 @@ public function testInvalidValues($value) ->assertRaised(); } - public function getInvalidValues() + public static function getInvalidValues() { $object = new \stdClass(); @@ -156,7 +156,7 @@ public function testExpectsNonUniqueObjects($callback) ->assertRaised(); } - public function getCallback() + public static function getCallback() { return [ yield 'static function' => [static function (\stdClass $object) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index 8227cd73f1b21..e7bd83d07d708 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -85,7 +85,7 @@ public function testValidRelativeUrl($url) $this->assertNoViolation(); } - public function getValidRelativeUrls() + public static function getValidRelativeUrls() { return [ ['//example.com'], @@ -95,7 +95,7 @@ public function getValidRelativeUrls() ]; } - public function getValidUrls() + public static function getValidUrls() { return [ ['http://a.pl'], @@ -177,7 +177,7 @@ public function getValidUrls() ]; } - public function getValidUrlsWithWhitespaces() + public static function getValidUrlsWithWhitespaces() { return [ ["\x20http://www.example.com"], @@ -225,7 +225,7 @@ public function testInvalidRelativeUrl($url) ->assertRaised(); } - public function getInvalidRelativeUrls() + public static function getInvalidRelativeUrls() { return [ ['/example.com'], @@ -245,7 +245,7 @@ public function getInvalidRelativeUrls() ]; } - public function getInvalidUrls() + public static function getInvalidUrls() { return [ ['example.com'], @@ -303,7 +303,7 @@ public function testCustomProtocolIsValid($url) $this->assertNoViolation(); } - public function getValidCustomUrls() + public static function getValidCustomUrls() { return [ ['ftp://example.com'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php index 672a594e9e952..d6d6e80699ed9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php @@ -72,7 +72,7 @@ public function testValidStrictUuids($uuid, $versions = null) $this->assertNoViolation(); } - public function getValidStrictUuids() + public static function getValidStrictUuids() { return [ ['216fff40-98d9-11e3-a5e2-0800200c9a66'], // Version 1 UUID in lowercase @@ -101,7 +101,7 @@ public function testValidStrictUuidsWithWhitespaces($uuid, $versions = null) $this->assertNoViolation(); } - public function getValidStrictUuidsWithWhitespaces() + public static function getValidStrictUuidsWithWhitespaces() { return [ ["\x20216fff40-98d9-11e3-a5e2-0800200c9a66"], // Version 1 UUID in lowercase @@ -147,7 +147,7 @@ public function testInvalidStrictUuids($uuid, $code, $versions = null) ->assertRaised(); } - public function getInvalidStrictUuids() + public static function getInvalidStrictUuids() { return [ ['216fff40-98d9-11e3-a5e2_0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR], @@ -206,7 +206,7 @@ public function testValidNonStrictUuids($uuid) $this->assertNoViolation(); } - public function getValidNonStrictUuids() + public static function getValidNonStrictUuids() { return [ ['216fff40-98d9-11e3-a5e2-0800200c9a66'], // Version 1 UUID in lowercase @@ -241,7 +241,7 @@ public function testInvalidNonStrictUuids($uuid, $code) ->assertRaised(); } - public function getInvalidNonStrictUuids() + public static function getInvalidNonStrictUuids() { return [ ['216fff40-98d9-11e3-a5e2_0800200c9a66', Uuid::INVALID_CHARACTERS_ERROR], diff --git a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php index 4571436c12f73..9a6817966d104 100644 --- a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php +++ b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php @@ -60,7 +60,7 @@ public function testProcess(string $namespace, array $services, string $expected $this->assertCount(\count($services), $container->getDefinition('validator.builder')->getMethodCalls()); } - public function mappingProvider(): array + public static function mappingProvider(): array { return [ ['Foo\\', ['foo', 'baz'], '{^App\\\\|^Foo\\\\}'], diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php index ab0f79663562e..020b554acc554 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -211,7 +211,7 @@ public function testLoadGroupSequenceProviderAnnotation(string $namespace) $this->assertEquals($expected, $metadata); } - public function provideNamespaces(): iterable + public static function provideNamespaces(): iterable { yield 'annotations' => ['Symfony\Component\Validator\Tests\Fixtures\Annotation']; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php index 0965d8e135fa0..f41d4c55443a9 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php @@ -205,7 +205,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp $this->assertSame($expected, $propertyInfoLoader->loadClassMetadata($classMetadata)); } - public function regexpProvider() + public static function regexpProvider() { return [ [false, null], diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php index 1813019b43a67..8ddcd02f17608 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -52,7 +52,7 @@ public function testInvalidYamlFiles($path) $loader->loadClassMetadata($metadata); } - public function provideInvalidYamlFiles() + public static function provideInvalidYamlFiles() { return [ ['nonvalid-mapping.yml'], diff --git a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php index 7fa81d9fe02be..68f7e9b11c6e1 100644 --- a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php @@ -45,7 +45,7 @@ public function testTranslationFileIsValidWithoutEntityLoader($filePath) $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message')))); } - public function provideTranslationFiles() + public static function provideTranslationFiles() { return array_map( function ($filePath) { return (array) $filePath; }, diff --git a/src/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php b/src/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php index 99bf9e6eb2ebe..f7f33d476988a 100644 --- a/src/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php +++ b/src/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php @@ -24,7 +24,7 @@ public function testAppend($basePath, $subPath, $expectedPath, $message) $this->assertSame($expectedPath, PropertyPath::append($basePath, $subPath), $message); } - public function provideAppendPaths() + public static function provideAppendPaths() { return [ ['foo', '', 'foo', 'It returns the basePath if subPath is empty'], diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index c78eb75448701..2bb212eaac293 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -1284,7 +1284,7 @@ public function testReplaceDefaultGroup($sequence, array $assertViolations) } } - public function getConstraintMethods() + public static function getConstraintMethods() { return [ ['addPropertyConstraint'], @@ -1292,7 +1292,7 @@ public function getConstraintMethods() ]; } - public function getTestReplaceDefaultGroup() + public static function getTestReplaceDefaultGroup() { return [ [ diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index 890f531063760..81bfd54e5aa38 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -115,7 +115,7 @@ public static function castObject(object $obj, string $class, bool $hasDebugInfo * @param array $a The array containing the properties to filter * @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out * @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set - * @param int &$count Set to the number of removed properties + * @param int|null &$count Set to the number of removed properties */ public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array { diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 5c644053ad136..ef6a85ef0fb1c 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -292,7 +292,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st if ($c->isOptional()) { try { $a[$prefix.'default'] = $v = $c->getDefaultValue(); - if ($c->isDefaultValueConstant()) { + if ($c->isDefaultValueConstant() && !\is_object($v)) { $a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v); } if (null === $v) { diff --git a/src/Symfony/Component/VarDumper/LICENSE b/src/Symfony/Component/VarDumper/LICENSE index 72412a62b2029..29f72d5e95920 100644 --- a/src/Symfony/Component/VarDumper/LICENSE +++ b/src/Symfony/Component/VarDumper/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2023 Fabien Potencier +Copyright (c) 2014-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php index 66cd5fbeda660..55eb4040f62b8 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php @@ -46,7 +46,7 @@ public function testFilter($filter, $expectedDiff, $listedProperties = null) $this->assertSame($expectedDiff, array_diff_assoc(self::$referenceArray, $filteredArray)); } - public function provideFilter() + public static function provideFilter() { return [ [ diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php index 335aa7dda4b1c..40835671b5137 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php @@ -74,7 +74,7 @@ public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos) $this->assertDumpMatchesFormat($xDump, $cast["\0~\0date"]); } - public function provideDateTimes() + public static function provideDateTimes() { return [ ['2017-04-30 00:00:00.000000', 'Europe/Zurich', '2017-04-30 00:00:00.0 Europe/Zurich (+02:00)', 1493503200, 'Sunday, April 30, 2017%Afrom now%ADST On'], @@ -194,7 +194,7 @@ public function testCastInterval($intervalSpec, $ms, $invert, $xInterval, $xSeco $this->assertDumpMatchesFormat($xDump, $cast["\0~\0interval"]); } - public function provideIntervals() + public static function provideIntervals() { return [ ['PT0S', 0, 0, '0s', '0s'], @@ -293,7 +293,7 @@ public function testCastTimeZone($timezone, $xTimezone, $xRegion) $this->assertDumpMatchesFormat($xDump, $cast["\0~\0timezone"]); } - public function provideTimeZones() + public static function provideTimeZones() { $xRegion = \extension_loaded('intl') ? '%s' : ''; @@ -370,7 +370,7 @@ public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDa $this->assertDumpMatchesFormat($xDump, $cast["\0~\0period"]); } - public function providePeriods() + public static function providePeriods() { $periods = [ ['2017-01-01', 'P1D', '2017-01-03', 0, 'every + 1d, from [2017-01-01 00:00:00.0 to 2017-01-03 00:00:00.0[', '1) 2017-01-01%a2) 2017-01-02'], diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php index e05ae41b1b19f..983f541a3f786 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/MysqliCasterTest.php @@ -16,6 +16,7 @@ /** * @requires extension mysqli + * * @group integration */ class MysqliCasterTest extends TestCase diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/RdKafkaCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/RdKafkaCasterTest.php index 4cc836f2b4a52..65e8ec3b8fd96 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/RdKafkaCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/RdKafkaCasterTest.php @@ -20,6 +20,7 @@ /** * @requires extension rdkafka + * * @group integration */ class RdKafkaCasterTest extends TestCase diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/RedisCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/RedisCasterTest.php index 058b95d0d0ab6..566de12a5e4eb 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/RedisCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/RedisCasterTest.php @@ -16,7 +16,9 @@ /** * @author Nicolas Grekas + * * @requires extension redis + * * @group integration */ class RedisCasterTest extends TestCase diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php index 5bba4e55fc8d7..4093471f8929a 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php @@ -21,7 +21,7 @@ class SplCasterTest extends TestCase { use VarDumperTestTrait; - public function getCastFileInfoTests() + public static function getCastFileInfoTests() { return [ [__FILE__, <<<'EOTXT' @@ -135,7 +135,7 @@ public function testCastSplDoublyLinkedList($modeValue, $modeDump) $this->assertDumpMatchesFormat($dump, $var); } - public function provideCastSplDoublyLinkedList() + public static function provideCastSplDoublyLinkedList() { return [ [\SplDoublyLinkedList::IT_MODE_FIFO, 'IT_MODE_FIFO | IT_MODE_KEEP'], diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php index cde1d7e91236e..78416f30943b7 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php @@ -64,7 +64,7 @@ public function testNodes($seek, $expectedDump) $this->assertDumpMatchesFormat($expectedDump, $this->reader); } - public function provideNodes() + public static function provideNodes() { return [ [0, <<<'EODUMP' diff --git a/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php b/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php index 56fb218776259..5941508a3a235 100644 --- a/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php @@ -54,7 +54,7 @@ public function testDescribe(array $context, string $expectedOutput, bool $decor $this->assertStringMatchesFormat(trim($expectedOutput), str_replace(\PHP_EOL, "\n", trim($output->fetch()))); } - public function provideContext() + public static function provideContext() { yield 'source' => [ [ diff --git a/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/HtmlDescriptorTest.php b/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/HtmlDescriptorTest.php index 426e99d360c3e..09acf149a877b 100644 --- a/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/HtmlDescriptorTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/HtmlDescriptorTest.php @@ -63,7 +63,7 @@ public function testDescribe(array $context, string $expectedOutput) $this->assertStringMatchesFormat(trim($expectedOutput), trim(preg_replace('@@s', '', $output->fetch()))); } - public function provideContext() + public static function provideContext() { yield 'source' => [ [ diff --git a/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php b/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php index fe1a9b05d3da9..d593608de897e 100644 --- a/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Command/ServerDumpCommandTest.php @@ -32,7 +32,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option --format' => [ ['--format', ''], diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php index 92b7119a01009..d94b15ff4b731 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php @@ -157,7 +157,7 @@ public function testDumpWithCommaFlagsAndExceptionCodeExcerpt() , $dump); } - public function provideDumpWithCommaFlagTests() + public static function provideDumpWithCommaFlagTests() { $expected = <<<'EOTXT' array:3 [ @@ -492,7 +492,7 @@ public function testIncompleteClass() ); } - public function provideDumpArrayWithColor() + public static function provideDumpArrayWithColor() { yield [ ['foo' => 'bar'], diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php index 1fd98640312e0..8c9592e47b304 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php @@ -180,7 +180,7 @@ public function testDumpString($var, $needle) $this->assertStringContainsString($needle, $out); } - public function varToDumpProvider() + public static function varToDumpProvider() { return [ [['dummy' => new ImgStub('dummy', 'img/png', '100em')], ''], diff --git a/src/Symfony/Component/VarExporter/LICENSE b/src/Symfony/Component/VarExporter/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Component/VarExporter/LICENSE +++ b/src/Symfony/Component/VarExporter/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php index cbd223642320b..ec6fc98d2a2e5 100644 --- a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php +++ b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php @@ -35,7 +35,7 @@ public function testFailingInstantiation(string $class) Instantiator::instantiate($class); } - public function provideFailingInstantiation() + public static function provideFailingInstantiation() { yield ['ReflectionClass']; yield ['SplHeap']; diff --git a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php index a4ea1a9221d3c..21320e1d59d4c 100644 --- a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php +++ b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php @@ -53,7 +53,7 @@ public function testFailingSerialization($value) } } - public function provideFailingSerialization() + public static function provideFailingSerialization() { yield [hash_init('md5')]; yield [new \ReflectionClass(\stdClass::class)]; @@ -122,7 +122,7 @@ public function testExport(string $testName, $value, bool $staticValueExpected = } } - public function provideExport() + public static function provideExport() { yield ['multiline-string', ["\0\0\r\nA" => "B\rC\n\n"], true]; yield ['lf-ending-string', "'BOOM'\n.var_dump(123)//'", true]; diff --git a/src/Symfony/Component/VarExporter/VarExporter.php b/src/Symfony/Component/VarExporter/VarExporter.php index 003388e7985f9..85813378137df 100644 --- a/src/Symfony/Component/VarExporter/VarExporter.php +++ b/src/Symfony/Component/VarExporter/VarExporter.php @@ -34,7 +34,7 @@ final class VarExporter * * @param mixed $value The value to export * @param bool &$isStaticValue Set to true after execution if the provided value is static, false otherwise - * @param bool &$classes Classes found in the value are added to this list as both keys and values + * @param array &$foundClasses Classes found in the value are added to this list as both keys and values * * @throws ExceptionInterface When the provided value cannot be serialized */ diff --git a/src/Symfony/Component/WebLink/LICENSE b/src/Symfony/Component/WebLink/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/WebLink/LICENSE +++ b/src/Symfony/Component/WebLink/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/WebLink/Tests/LinkTest.php b/src/Symfony/Component/WebLink/Tests/LinkTest.php index 979bbb8b4f67e..e1c03bae7c073 100644 --- a/src/Symfony/Component/WebLink/Tests/LinkTest.php +++ b/src/Symfony/Component/WebLink/Tests/LinkTest.php @@ -91,7 +91,7 @@ public function testNotTemplated(string $href) $this->assertFalse($link->isTemplated()); } - public function templatedHrefProvider() + public static function templatedHrefProvider() { return [ ['http://www.google.com/{param}/foo'], @@ -99,7 +99,7 @@ public function templatedHrefProvider() ]; } - public function notTemplatedHrefProvider() + public static function notTemplatedHrefProvider() { return [ ['http://www.google.com/foo'], diff --git a/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php b/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php index 15ec8c65c5ffa..b7f5eae1421fc 100644 --- a/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php @@ -224,7 +224,7 @@ private function styleStatemachineTransition( string $transitionLabel, array $transitionMeta ): array { - $transitionOutput = [sprintf('%s-->|%s|%s', $from, $this->escape($transitionLabel), $to)]; + $transitionOutput = [sprintf('%s-->|%s|%s', $from, str_replace("\n", ' ', $this->escape($transitionLabel)), $to)]; $linkStyle = $this->styleLink($transitionMeta); if ('' !== $linkStyle) { diff --git a/src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php b/src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php index 43595c6f25394..d8548469a54e4 100644 --- a/src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php @@ -195,7 +195,7 @@ private function getState(string $place, Definition $definition, Marking $markin { $workflowMetadata = $definition->getMetadataStore(); - $placeEscaped = $this->escape($place); + $placeEscaped = str_replace("\n", ' ', $this->escape($place)); $output = "state $placeEscaped". (\in_array($place, $definition->getInitialPlaces(), true) ? ' '.self::INITIAL : ''). @@ -208,7 +208,7 @@ private function getState(string $place, Definition $definition, Marking $markin $description = $workflowMetadata->getMetadata('description', $place); if (null !== $description) { - $output .= \PHP_EOL.$placeEscaped.' : '.$description; + $output .= \PHP_EOL.$placeEscaped.' : '.str_replace("\n", ' ', $description); } return $output; @@ -217,10 +217,17 @@ private function getState(string $place, Definition $definition, Marking $markin private function getTransitionEscapedWithStyle(MetadataStoreInterface $workflowMetadata, Transition $transition, string $to): string { $to = $workflowMetadata->getMetadata('label', $transition) ?? $to; + // Change new lines symbols to actual '\n' string, + // PUML will render them as new lines + $to = str_replace("\n", '\n', $to); $color = $workflowMetadata->getMetadata('color', $transition) ?? null; if (null !== $color) { + // Close and open before and after every '\n' string, + // so that the style is applied properly on every line + $to = str_replace('\n', sprintf('\n', $color), $to); + $to = sprintf( '%2$s', $color, diff --git a/src/Symfony/Component/Workflow/LICENSE b/src/Symfony/Component/Workflow/LICENSE index 72412a62b2029..29f72d5e95920 100644 --- a/src/Symfony/Component/Workflow/LICENSE +++ b/src/Symfony/Component/Workflow/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2023 Fabien Potencier +Copyright (c) 2014-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Workflow/Tests/Dumper/GraphvizDumperTest.php b/src/Symfony/Component/Workflow/Tests/Dumper/GraphvizDumperTest.php index fcedde01577c8..f18868fcc3b41 100644 --- a/src/Symfony/Component/Workflow/Tests/Dumper/GraphvizDumperTest.php +++ b/src/Symfony/Component/Workflow/Tests/Dumper/GraphvizDumperTest.php @@ -47,28 +47,28 @@ public function testDumpWithMarking($definition, $marking, $expected) $this->assertEquals($expected, $dump); } - public function provideWorkflowDefinitionWithMarking() + public static function provideWorkflowDefinitionWithMarking() { yield [ - $this->createComplexWorkflowDefinition(), + self::createComplexWorkflowDefinition(), new Marking(['b' => 1]), - $this->createComplexWorkflowDefinitionDumpWithMarking(), + self::createComplexWorkflowDefinitionDumpWithMarking(), ]; yield [ - $this->createSimpleWorkflowDefinition(), + self::createSimpleWorkflowDefinition(), new Marking(['c' => 1, 'd' => 1]), - $this->createSimpleWorkflowDumpWithMarking(), + self::createSimpleWorkflowDumpWithMarking(), ]; } - public function provideWorkflowDefinitionWithoutMarking() + public static function provideWorkflowDefinitionWithoutMarking() { - yield [$this->createComplexWorkflowDefinition(), $this->provideComplexWorkflowDumpWithoutMarking()]; - yield [$this->createSimpleWorkflowDefinition(), $this->provideSimpleWorkflowDumpWithoutMarking()]; + yield [self::createComplexWorkflowDefinition(), self::provideComplexWorkflowDumpWithoutMarking()]; + yield [self::createSimpleWorkflowDefinition(), self::provideSimpleWorkflowDumpWithoutMarking()]; } - public function createComplexWorkflowDefinitionDumpWithMarking() + public static function createComplexWorkflowDefinitionDumpWithMarking() { return 'digraph workflow { ratio="compress" rankdir="LR" @@ -106,7 +106,7 @@ public function createComplexWorkflowDefinitionDumpWithMarking() '; } - public function createSimpleWorkflowDumpWithMarking() + public static function createSimpleWorkflowDumpWithMarking() { return 'digraph workflow { ratio="compress" rankdir="LR" @@ -126,7 +126,7 @@ public function createSimpleWorkflowDumpWithMarking() '; } - public function provideComplexWorkflowDumpWithoutMarking() + public static function provideComplexWorkflowDumpWithoutMarking() { return 'digraph workflow { ratio="compress" rankdir="LR" @@ -164,7 +164,7 @@ public function provideComplexWorkflowDumpWithoutMarking() '; } - public function provideSimpleWorkflowDumpWithoutMarking() + public static function provideSimpleWorkflowDumpWithoutMarking() { return 'digraph workflow { ratio="compress" rankdir="LR" diff --git a/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php b/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php index 4eaebe1e452b3..93c1e339486ee 100644 --- a/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php +++ b/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php @@ -71,11 +71,11 @@ public function testDumpWorkflowWithMarking(Definition $definition, Marking $mar $this->assertEquals($expected, $dump); } - public function provideWorkflowDefinitionWithoutMarking(): array + public static function provideWorkflowDefinitionWithoutMarking(): array { return [ [ - $this->createComplexWorkflowDefinition(), + self::createComplexWorkflowDefinition(), "graph LR\n" ."a0([\"a\"])\n" ."b1((\"b\"))\n" @@ -108,7 +108,7 @@ public function provideWorkflowDefinitionWithoutMarking(): array .'transition5-->g6', ], [ - $this->createWorkflowWithSameNameTransition(), + self::createWorkflowWithSameNameTransition(), "graph LR\n" ."a0([\"a\"])\n" ."b1((\"b\"))\n" @@ -128,7 +128,7 @@ public function provideWorkflowDefinitionWithoutMarking(): array .'transition3-->a0', ], [ - $this->createSimpleWorkflowDefinition(), + self::createSimpleWorkflowDefinition(), "graph LR\n" ."a0([\"a\"])\n" ."b1((\"b\"))\n" @@ -146,7 +146,7 @@ public function provideWorkflowDefinitionWithoutMarking(): array ]; } - public function provideWorkflowWithReservedWords() + public static function provideWorkflowWithReservedWords() { $builder = new DefinitionBuilder(); @@ -177,11 +177,11 @@ public function provideWorkflowWithReservedWords() ]; } - public function provideStatemachine(): array + public static function provideStatemachine(): array { return [ [ - $this->createComplexStateMachineDefinition(), + self::createComplexStateMachineDefinition(), "graph LR\n" ."a0([\"a\"])\n" ."b1((\"b\"))\n" @@ -196,7 +196,7 @@ public function provideStatemachine(): array ]; } - public function provideWorkflowWithMarking(): array + public static function provideWorkflowWithMarking(): array { $marking = new Marking(); $marking->mark('b'); @@ -204,7 +204,7 @@ public function provideWorkflowWithMarking(): array return [ [ - $this->createSimpleWorkflowDefinition(), + self::createSimpleWorkflowDefinition(), $marking, "graph LR\n" ."a0([\"a\"])\n" diff --git a/src/Symfony/Component/Workflow/Tests/Dumper/PlantUmlDumperTest.php b/src/Symfony/Component/Workflow/Tests/Dumper/PlantUmlDumperTest.php index 0c750fc750255..6af7809ae0ad5 100644 --- a/src/Symfony/Component/Workflow/Tests/Dumper/PlantUmlDumperTest.php +++ b/src/Symfony/Component/Workflow/Tests/Dumper/PlantUmlDumperTest.php @@ -36,14 +36,14 @@ public function testDumpWorkflowWithoutMarking($definition, $marking, $expectedF $this->assertStringEqualsFile($file, $dump); } - public function provideWorkflowDefinitionWithoutMarking() + public static function provideWorkflowDefinitionWithoutMarking() { - yield [$this->createSimpleWorkflowDefinition(), null, 'simple-workflow-nomarking', 'SimpleDiagram']; - yield [$this->createComplexWorkflowDefinition(), null, 'complex-workflow-nomarking', 'ComplexDiagram']; + yield [self::createSimpleWorkflowDefinition(), null, 'simple-workflow-nomarking', 'SimpleDiagram']; + yield [self::createComplexWorkflowDefinition(), null, 'complex-workflow-nomarking', 'ComplexDiagram']; $marking = new Marking(['b' => 1]); - yield [$this->createSimpleWorkflowDefinition(), $marking, 'simple-workflow-marking', 'SimpleDiagram']; + yield [self::createSimpleWorkflowDefinition(), $marking, 'simple-workflow-marking', 'SimpleDiagram']; $marking = new Marking(['c' => 1, 'e' => 1]); - yield [$this->createComplexWorkflowDefinition(), $marking, 'complex-workflow-marking', 'ComplexDiagram']; + yield [self::createComplexWorkflowDefinition(), $marking, 'complex-workflow-marking', 'ComplexDiagram']; } /** @@ -59,11 +59,11 @@ public function testDumpStateMachineWithoutMarking($definition, $marking, $expec $this->assertStringEqualsFile($file, $dump); } - public function provideStateMachineDefinitionWithoutMarking() + public static function provideStateMachineDefinitionWithoutMarking() { - yield [$this->createComplexStateMachineDefinition(), null, 'complex-state-machine-nomarking', 'SimpleDiagram']; + yield [static::createComplexStateMachineDefinition(), null, 'complex-state-machine-nomarking', 'SimpleDiagram']; $marking = new Marking(['c' => 1, 'e' => 1]); - yield [$this->createComplexStateMachineDefinition(), $marking, 'complex-state-machine-marking', 'SimpleDiagram']; + yield [static::createComplexStateMachineDefinition(), $marking, 'complex-state-machine-marking', 'SimpleDiagram']; } public function testDumpWorkflowWithSpacesInTheStateNamesAndDescription() diff --git a/src/Symfony/Component/Workflow/Tests/Dumper/StateMachineGraphvizDumperTest.php b/src/Symfony/Component/Workflow/Tests/Dumper/StateMachineGraphvizDumperTest.php index a7253ecc90d5d..a45e07c98f126 100644 --- a/src/Symfony/Component/Workflow/Tests/Dumper/StateMachineGraphvizDumperTest.php +++ b/src/Symfony/Component/Workflow/Tests/Dumper/StateMachineGraphvizDumperTest.php @@ -44,7 +44,8 @@ public function testDumpWithoutMarking() place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle]; place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle]; place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"]; - place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition label 3" style="solid" fontcolor="Grey" color="Red"]; + place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition +label 3" style="solid" fontcolor="Grey" color="Red"]; place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"]; place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"]; } @@ -70,7 +71,8 @@ public function testDumpWithMarking() place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle]; place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle]; place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"]; - place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition label 3" style="solid" fontcolor="Grey" color="Red"]; + place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition +label 3" style="solid" fontcolor="Grey" color="Red"]; place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"]; place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"]; } diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowBuilderTrait.php b/src/Symfony/Component/Workflow/Tests/WorkflowBuilderTrait.php index bf254f009969a..ae812324c6395 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowBuilderTrait.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowBuilderTrait.php @@ -17,7 +17,7 @@ trait WorkflowBuilderTrait { - private function createComplexWorkflowDefinition() + private static function createComplexWorkflowDefinition() { $places = range('a', 'g'); @@ -52,7 +52,7 @@ private function createComplexWorkflowDefinition() // +----+ +----+ +----+ +----+ } - private function createSimpleWorkflowDefinition() + private static function createSimpleWorkflowDefinition() { $places = range('a', 'c'); @@ -87,7 +87,7 @@ private function createSimpleWorkflowDefinition() // +---+ +----+ +---+ +----+ +---+ } - private function createWorkflowWithSameNameTransition() + private static function createWorkflowWithSameNameTransition() { $places = range('a', 'c'); @@ -115,7 +115,7 @@ private function createWorkflowWithSameNameTransition() // +--------------------------------------------------------------------+ } - private function createComplexStateMachineDefinition() + private static function createComplexStateMachineDefinition() { $places = ['a', 'b', 'c', 'd']; @@ -127,8 +127,13 @@ private function createComplexStateMachineDefinition() $transitions[] = new Transition('t3', 'b', 'd'); $transitionsMetadata = new \SplObjectStorage(); + // PHP 7.2 doesn't allow this heredoc syntax in an array, use a dedicated variable instead + $label = <<<'EOTXT' +My custom transition +label 3 +EOTXT; $transitionsMetadata[$transitionWithMetadataDumpStyle] = [ - 'label' => 'My custom transition label 3', + 'label' => $label, 'color' => 'Grey', 'arrow_color' => 'Red', ]; diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 6399bf21d9c15..6d84b1937d94d 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -438,7 +438,7 @@ public function testApplyWithEventDispatcher() $this->assertSame($eventNameExpected, $eventDispatcher->dispatchedEvents); } - public function provideApplyWithEventDispatcherForAnnounceTests() + public static function provideApplyWithEventDispatcherForAnnounceTests() { yield [false, [Workflow::DISABLE_ANNOUNCE_EVENT => true]]; yield [true, [Workflow::DISABLE_ANNOUNCE_EVENT => false]]; diff --git a/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-marking.puml b/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-marking.puml index 59f8309adff36..7f1367f5a9542 100644 --- a/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-marking.puml +++ b/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-marking.puml @@ -15,7 +15,7 @@ state "b" state "c" <> state "d" "a" --> "b": "t1" -"d" -[#Red]-> "b": "My custom transition label 3" +"d" -[#Red]-> "b": "My custom transition\nlabel 3" "b" -[#Blue]-> "c": "t2" "b" --> "d": "t3" @enduml diff --git a/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-nomarking.puml b/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-nomarking.puml index f3549c6d751af..9d6531435dcd9 100644 --- a/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-nomarking.puml +++ b/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-nomarking.puml @@ -15,7 +15,7 @@ state "b" state "c" state "d" "a" --> "b": "t1" -"d" -[#Red]-> "b": "My custom transition label 3" +"d" -[#Red]-> "b": "My custom transition\nlabel 3" "b" -[#Blue]-> "c": "t2" "b" --> "d": "t3" @enduml diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 8118a43ab8f37..04c9690c9d1f3 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -50,9 +50,9 @@ public static function initialize(int $flags, int $parsedLineNumber = null, stri /** * Converts a YAML string to a PHP value. * - * @param string $value A YAML string - * @param int $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior - * @param array $references Mapping of variable names to values + * @param string|null $value A YAML string + * @param int $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior + * @param array $references Mapping of variable names to values * * @return mixed * diff --git a/src/Symfony/Component/Yaml/LICENSE b/src/Symfony/Component/Yaml/LICENSE index 008370457251e..0138f8f071351 100644 --- a/src/Symfony/Component/Yaml/LICENSE +++ b/src/Symfony/Component/Yaml/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php index 90e20455ff0ed..4d3024cc3e4b1 100644 --- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php @@ -179,7 +179,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option' => [['--format', ''], ['txt', 'json', 'github']]; } diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 16551f187136c..721b04caab2ee 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -225,7 +225,7 @@ public function testEscapedEscapeSequencesInQuotedScalar($input, $expected) $this->assertSameData($input, $this->parser->parse($expected)); } - public function getEscapeSequences() + public static function getEscapeSequences() { return [ 'empty string' => ['', "''"], @@ -275,7 +275,7 @@ public function testDumpObjectAsMap($object, $expected) $this->assertSameData($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP)); } - public function objectAsMapProvider() + public static function objectAsMapProvider() { $tests = []; diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index f71509d28f35c..8cd2582fdccc5 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -56,7 +56,7 @@ public function testParsePhpConstants($yaml, $value) $this->assertSame($value, $actual); } - public function getTestsForParsePhpConstants() + public static function getTestsForParsePhpConstants() { return [ ['!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT], @@ -195,7 +195,7 @@ public function testParseReferences($yaml, $expected) $this->assertSame($expected, Inline::parse($yaml, 0, $references)); } - public function getDataForParseReferences() + public static function getDataForParseReferences() { return [ 'scalar' => ['*var', 'var-value'], @@ -245,7 +245,7 @@ public function testParseUnquotedScalarStartingWithReservedIndicator($indicator) Inline::parse(sprintf('{ foo: %sfoo }', $indicator)); } - public function getReservedIndicators() + public static function getReservedIndicators() { return [['@'], ['`']]; } @@ -261,7 +261,7 @@ public function testParseUnquotedScalarStartingWithScalarIndicator($indicator) Inline::parse(sprintf('{ foo: %sfoo }', $indicator)); } - public function getScalarIndicators() + public static function getScalarIndicators() { return [['|'], ['>'], ['%']]; } @@ -274,7 +274,7 @@ public function testIsHash($array, $expected) $this->assertSame($expected, Inline::isHash($array)); } - public function getDataForIsHash() + public static function getDataForIsHash() { return [ [[], false], @@ -284,7 +284,7 @@ public function getDataForIsHash() ]; } - public function getTestsForParse() + public static function getTestsForParse() { return [ ['', ''], @@ -370,7 +370,7 @@ public function getTestsForParse() ]; } - public function getTestsForParseWithMapObjects() + public static function getTestsForParseWithMapObjects() { return [ ['', ''], @@ -451,7 +451,7 @@ public function getTestsForParseWithMapObjects() ]; } - public function getTestsForDump() + public static function getTestsForDump() { return [ ['null', null], @@ -549,7 +549,7 @@ public function testParseTimestampAsDateTimeObject(string $yaml, int $year, int $this->assertSame($timezone, $date->format('O')); } - public function getTimestampTests(): array + public static function getTimestampTests(): array { return [ 'canonical' => ['2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43, 100000, '+0000'], @@ -591,7 +591,7 @@ public function testDumpUnitEnum() $this->assertSame("!php/const Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum::BAR", Inline::dump(FooUnitEnum::BAR)); } - public function getDateTimeDumpTests() + public static function getDateTimeDumpTests() { $tests = []; @@ -612,7 +612,7 @@ public function testParseBinaryData($data) $this->assertSame('Hello world', Inline::parse($data)); } - public function getBinaryData() + public static function getBinaryData() { return [ 'enclosed with double quotes' => ['!!binary "SGVsbG8gd29ybGQ="'], @@ -632,7 +632,7 @@ public function testParseInvalidBinaryData($data, $expectedMessage) Inline::parse($data); } - public function getInvalidBinaryData() + public static function getInvalidBinaryData() { return [ 'length not a multiple of four' => ['!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'], @@ -674,7 +674,7 @@ public function testParseMissingMappingValueAsNull($yaml, $expected) $this->assertSame($expected, Inline::parse($yaml)); } - public function getTestsForNullValues() + public static function getTestsForNullValues() { return [ 'null before closing curly brace' => ['{foo:}', ['foo' => null]], @@ -697,7 +697,7 @@ public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expec $this->assertSame($expected, Inline::parse($yaml)); } - public function getNotPhpCompatibleMappingKeyData() + public static function getNotPhpCompatibleMappingKeyData() { return [ 'boolean-true' => ['{true: "foo"}', ['true' => 'foo']], @@ -776,7 +776,7 @@ public function testParseOctalNumbers($expected, $yaml) self::assertSame($expected, Inline::parse($yaml)); } - public function getTestsForOctalNumbers() + public static function getTestsForOctalNumbers() { return [ 'positive octal number' => [28, '0o34'], @@ -797,7 +797,7 @@ public function testParseOctalNumbersYaml11Notation(int $expected, string $yaml, self::assertSame($expected, Inline::parse($yaml)); } - public function getTestsForOctalNumbersYaml11Notation() + public static function getTestsForOctalNumbersYaml11Notation() { return [ 'positive octal number' => [28, '034', '0o34'], @@ -818,7 +818,7 @@ public function testPhpObjectWithEmptyValue($expected, $value) $this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT)); } - public function phpObjectTagWithEmptyValueProvider() + public static function phpObjectTagWithEmptyValueProvider() { return [ [false, '!php/object'], @@ -842,7 +842,7 @@ public function testPhpConstTagWithEmptyValue($expected, $value) $this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT)); } - public function phpConstTagWithEmptyValueProvider() + public static function phpConstTagWithEmptyValueProvider() { return [ ['', '!php/const'], @@ -894,7 +894,7 @@ public function testUnquotedExclamationMarkThrows(string $value) Inline::parse($value); } - public function unquotedExclamationMarkThrowsProvider() + public static function unquotedExclamationMarkThrowsProvider() { return [ ['!'], @@ -926,7 +926,7 @@ public function testQuotedExclamationMark($expected, string $value) } // This provider should stay consistent with unquotedExclamationMarkThrowsProvider - public function quotedExclamationMarkProvider() + public static function quotedExclamationMarkProvider() { return [ ['!', '"!"'], @@ -956,7 +956,7 @@ public function testParseIdeographicSpace(string $yaml, string $expected) $this->assertSame($expected, Inline::parse($yaml)); } - public function ideographicSpaceProvider(): array + public static function ideographicSpaceProvider(): array { return [ ["\u{3000}", ' '], diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 0941075b10b57..98e5e73ec53e7 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -124,14 +124,14 @@ public function testSpecifications($expected, $yaml, $comment) $this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment); } - public function getDataFormSpecifications() + public static function getDataFormSpecifications() { - return $this->loadTestsFromFixtureFiles('index.yml'); + return self::loadTestsFromFixtureFiles('index.yml'); } - public function getNonStringMappingKeysData() + public static function getNonStringMappingKeysData() { - return $this->loadTestsFromFixtureFiles('nonStringKeys.yml'); + return self::loadTestsFromFixtureFiles('nonStringKeys.yml'); } /** @@ -144,7 +144,7 @@ public function testTabsAsIndentationInYaml(string $given, string $expectedMessa $this->parser->parse($given); } - public function invalidIndentation(): array + public static function invalidIndentation(): array { return [ [ @@ -189,7 +189,7 @@ public function testValidTokenSeparation(string $given, array $expected) $this->assertSameData($expected, $actual); } - public function validTokenSeparators(): array + public static function validTokenSeparators(): array { return [ [ @@ -222,7 +222,7 @@ public function testEndOfTheDocumentMarker() $this->assertEquals('foo', $this->parser->parse($yaml)); } - public function getBlockChompingTests() + public static function getBlockChompingTests() { $tests = []; @@ -586,7 +586,7 @@ public function testObjectForMap($yaml, $expected) $this->assertSameData($expected, $this->parser->parse($yaml, $flags)); } - public function getObjectForMapTests() + public static function getObjectForMapTests() { $tests = []; @@ -833,7 +833,7 @@ public function testNonStringFollowedByCommentEmbeddedInMapping() $this->assertSame($expected, $this->parser->parse($yaml)); } - public function getParseExceptionNotAffectedMultiLineStringLastResortParsing() + public static function getParseExceptionNotAffectedMultiLineStringLastResortParsing() { $tests = []; @@ -975,7 +975,7 @@ public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber Yaml::parse($input); } - public function getParseExceptionOnDuplicateData() + public static function getParseExceptionOnDuplicateData() { $tests = []; @@ -1280,7 +1280,7 @@ public function testCommentLikeStringsAreNotStrippedInBlockScalars($yaml, $expec $this->assertSame($expectedParserResult, $this->parser->parse($yaml)); } - public function getCommentLikeStringInScalarBlockData() + public static function getCommentLikeStringInScalarBlockData() { $tests = []; @@ -1465,7 +1465,7 @@ public function testParseBinaryData($data) $this->assertSame(['data' => 'Hello world'], $this->parser->parse($data)); } - public function getBinaryData() + public static function getBinaryData() { return [ 'enclosed with double quotes' => ['data: !!binary "SGVsbG8gd29ybGQ="'], @@ -1497,7 +1497,7 @@ public function testParseInvalidBinaryData($data, $expectedMessage) $this->parser->parse($data); } - public function getInvalidBinaryData() + public static function getInvalidBinaryData() { return [ 'length not a multiple of four' => ['data: !!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'], @@ -1563,7 +1563,7 @@ public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yam $this->parser->parse($yaml); } - public function parserThrowsExceptionWithCorrectLineNumberProvider() + public static function parserThrowsExceptionWithCorrectLineNumberProvider() { return [ [ @@ -1720,7 +1720,7 @@ public function testParseQuotedStringContainingEscapedQuotationCharacters(string $this->assertSame($expected, $this->parser->parse($yaml)); } - public function escapedQuotationCharactersInQuotedStrings() + public static function escapedQuotationCharactersInQuotedStrings() { return [ 'single quoted string' => [ @@ -1778,7 +1778,7 @@ public function testParseMultiLineMappingValue($yaml, $expected, $parseError) $this->assertSame($expected, $this->parser->parse($yaml)); } - public function multiLineDataProvider() + public static function multiLineDataProvider() { $tests = []; @@ -1845,7 +1845,7 @@ public function testInlineNotationSpanningMultipleLines($expected, string $yaml) $this->assertSame($expected, $this->parser->parse($yaml)); } - public function inlineNotationSpanningMultipleLinesProvider(): array + public static function inlineNotationSpanningMultipleLinesProvider(): array { return [ 'mapping' => [ @@ -2234,7 +2234,7 @@ public function testCustomTagSupport($expected, $yaml) $this->assertSameData($expected, $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS)); } - public function taggedValuesProvider() + public static function taggedValuesProvider() { return [ 'scalars' => [ @@ -2390,7 +2390,7 @@ public function testParsingIniThrowsException() $this->parser->parse($ini); } - private function loadTestsFromFixtureFiles($testsFile) + private static function loadTestsFromFixtureFiles($testsFile) { $parser = new Parser(); @@ -2658,7 +2658,7 @@ public function testDetectCircularReferences($yaml) $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS); } - public function circularReferenceProvider() + public static function circularReferenceProvider() { $tests = []; @@ -2698,7 +2698,7 @@ public function testParseIndentedMappings($yaml, $expected) $this->assertSame($expected, $this->parser->parse($yaml)); } - public function indentedMappingData() + public static function indentedMappingData() { $tests = []; diff --git a/src/Symfony/Contracts/Cache/CacheInterface.php b/src/Symfony/Contracts/Cache/CacheInterface.php index 67e4dfd3a1025..5244a2d0de5e9 100644 --- a/src/Symfony/Contracts/Cache/CacheInterface.php +++ b/src/Symfony/Contracts/Cache/CacheInterface.php @@ -49,9 +49,9 @@ public function get(string $key, callable $callback, float $beta = null, array & * * @param string $key The key to delete * - * @throws InvalidArgumentException When $key is not valid - * * @return bool True if the item was successfully removed, false if there was any error + * + * @throws InvalidArgumentException When $key is not valid */ public function delete(string $key): bool; } diff --git a/src/Symfony/Contracts/Cache/LICENSE b/src/Symfony/Contracts/Cache/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Contracts/Cache/LICENSE +++ b/src/Symfony/Contracts/Cache/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/Deprecation/LICENSE b/src/Symfony/Contracts/Deprecation/LICENSE index 0f262c225767a..0ed3a246553be 100644 --- a/src/Symfony/Contracts/Deprecation/LICENSE +++ b/src/Symfony/Contracts/Deprecation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/EventDispatcher/LICENSE b/src/Symfony/Contracts/EventDispatcher/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Contracts/EventDispatcher/LICENSE +++ b/src/Symfony/Contracts/EventDispatcher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/HttpClient/LICENSE b/src/Symfony/Contracts/HttpClient/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Contracts/HttpClient/LICENSE +++ b/src/Symfony/Contracts/HttpClient/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/LICENSE b/src/Symfony/Contracts/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Contracts/LICENSE +++ b/src/Symfony/Contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/Service/LICENSE b/src/Symfony/Contracts/Service/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Contracts/Service/LICENSE +++ b/src/Symfony/Contracts/Service/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/Service/ServiceSubscriberTrait.php b/src/Symfony/Contracts/Service/ServiceSubscriberTrait.php index 16e3eb2c19757..6c560a427f778 100644 --- a/src/Symfony/Contracts/Service/ServiceSubscriberTrait.php +++ b/src/Symfony/Contracts/Service/ServiceSubscriberTrait.php @@ -98,12 +98,13 @@ public static function getSubscribedServices(): array */ public function setContainer(ContainerInterface $container) { - $this->container = $container; - + $ret = null; if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) { - return parent::setContainer($container); + $ret = parent::setContainer($container); } - return null; + $this->container = $container; + + return $ret; } } diff --git a/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php b/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php index 8d0dc467642bc..1d86e72d0b2b2 100644 --- a/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php +++ b/src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php @@ -81,8 +81,21 @@ public function testParentNotCalledIfNoParent() $this->assertSame([], $service::getSubscribedServices()); } + public function testSetContainerCalledFirstOnParent() + { + $container1 = new class([]) implements ContainerInterface { + use ServiceLocatorTrait; + }; + $container2 = clone $container1; + + $testService = new TestService2(); + $this->assertNull($testService->setContainer($container1)); + $this->assertSame($container1, $testService->setContainer($container2)); + } + /** * @requires PHP 8 + * * @group legacy */ public function testMethodsWithUnionReturnTypesAreIgnored() @@ -160,3 +173,22 @@ public static function __callStatic($method, $args) class Service3 { } + +class ParentTestService2 +{ + /** @var ContainerInterface */ + protected $container; + + public function setContainer(ContainerInterface $container) + { + $previous = $this->container; + $this->container = $container; + + return $previous; + } +} + +class TestService2 extends ParentTestService2 implements ServiceSubscriberInterface +{ + use ServiceSubscriberTrait; +} diff --git a/src/Symfony/Contracts/Translation/LICENSE b/src/Symfony/Contracts/Translation/LICENSE index 99757d517117d..7536caeae80d8 100644 --- a/src/Symfony/Contracts/Translation/LICENSE +++ b/src/Symfony/Contracts/Translation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2023 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php index 68587f12d9817..fdf4f76c1589a 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -117,7 +117,7 @@ public function testGetLocaleReturnsDefaultLocaleIfNotSet() $this->assertEquals('en', $translator->getLocale()); } - public function getTransTests() + public static function getTransTests() { return [ ['Symfony is great!', 'Symfony is great!', []], @@ -125,7 +125,7 @@ public function getTransTests() ]; } - public function getTransChoiceTests() + public static function getTransChoiceTests() { return [ ['There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0], @@ -149,7 +149,7 @@ public function testInterval($expected, $number, $interval) $this->assertEquals($expected, $translator->trans($interval.' foo|[1,Inf[ bar', ['%count%' => $number])); } - public function getInterval() + public static function getInterval() { return [ ['foo', 3, '{1,2, 3 ,4}'], @@ -192,7 +192,7 @@ public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number) $translator->trans($id, ['%count%' => $number]); } - public function getNonMatchingMessages() + public static function getNonMatchingMessages() { return [ ['{0} There are no apples|{1} There is one apple', 2], @@ -202,7 +202,7 @@ public function getNonMatchingMessages() ]; } - public function getChooseTests() + public static function getChooseTests() { return [ ['There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0], @@ -320,7 +320,7 @@ public function testLangcodes($nplural, $langCodes) * * @return array */ - public function successLangcodes() + public static function successLangcodes() { return [ ['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']], @@ -339,7 +339,7 @@ public function successLangcodes() * * @return array with nplural together with langcodes */ - public function failingLangcodes() + public static function failingLangcodes() { return [ ['1', ['fa']],