8000 [HttpClient] Add support for amphp/http-client v5 by nicolas-grekas · Pull Request #43 · nicolas-grekas/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpClient] Add support for amphp/http-client v5 #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7e62355
chore: simplify PHP CS Fixer config
keradus Feb 26, 2024
c24e3e7
[Validator] Simplify `NoSuspiciousCharactersValidator`
MatTheCat Feb 26, 2024
f8611cf
minor #54062 [Validator] Simplify `NoSuspiciousCharactersValidator` (…
nicolas-grekas Feb 27, 2024
dfb41cd
[Mailer][Brevo] Remove tags from mandatory event arguments
palgalik Feb 27, 2024
182e93e
bug #54089 [Mailer] [Brevo] Remove tags from mandatory event argument…
fabpot Feb 28, 2024
9407a1b
[HttpClient] Fix deprecation on PHP 8.3
nicolas-grekas Feb 28, 2024
3a02e21
minor #54073 chore: simplify PHP CS Fixer config (keradus)
fabpot Feb 29, 2024
bb7c711
bug #54102 [HttpClient] Fix deprecation on PHP 8.3 (nicolas-grekas)
derrabus Feb 29, 2024
ae16b2d
[AssetMapper] Fix `JavaScriptImportPathCompiler` regression in regex
PhilETaylor Feb 27, 2024
91278da
bug #54079 [AssetMapper] Fix `JavaScriptImportPathCompiler` regressio…
nicolas-grekas Feb 29, 2024
5f959e2
Remove undefined variable
smnandre Mar 1, 2024
0478d54
[Clock] Add PHPUnit 10 attributes
ruudk Mar 1, 2024
ff08e9e
bug #54129 [Clock] Add attributes to support PHPUnit 10 + 11 (ruudk)
nicolas-grekas Mar 1, 2024
4155f66
[Security][Tests] Update functional tests to better reflect end-user …
llupa Feb 27, 2024
1f386a3
minor #54086 [Security][Tests] Update functional tests to better refl…
chalasr Mar 1, 2024
a184a18
Merge branch '5.4' into 6.4
wouterj Mar 2, 2024
e770fba
Merge branch '6.4' into 7.0
wouterj Mar 2, 2024
9482c97
Merge branch '7.0' into 7.1
wouterj Mar 2, 2024
9af1f34
[AssetMapper] Deprecate unused method `splitPackageNameAndFilePath`
smnandre Mar 1, 2024
31a9b35
feature #54125 [AssetMapper] Deprecate unused method `splitPackageNam…
fabpot Mar 2, 2024
4d120b8
[HttpClient] Preserve float in JsonMockResponse
Jibbarth Mar 4, 2024
24cf1eb
minor #54122 [AssetMapper] Remove undefined $path variable (smnandre)
fabpot Mar 4, 2024
2333b58
[AssetMapper] Throw exception in Javascript compiler when PCRE error
smnandre Feb 29, 2024
5f78910
bug #54113 [AssetMapper] Throw exception in Javascript compiler when …
fabpot Mar 4, 2024
3c39c04
Merge branch '6.4' into 7.0
fabpot Mar 4, 2024
f208ca7
Merge branch '7.0' into 7.1
fabpot Mar 4, 2024
fdb0340
[Mailer] Simplify MailerTestCommand
lyrixx Feb 29, 2024
9d6ee30
minor #54110 [Mailer] Simplify MailerTestCommand (lyrixx)
fabpot Mar 4, 2024
9b03f27
Update CHANGELOG for 5.4.37
fabpot Mar 4, 2024
8d1867d
Update CONTRIBUTORS for 5.4.37
fabpot Mar 4, 2024
3e40319
Update VERSION for 5.4.37
fabpot Mar 4, 2024
3f8d2f1
Merge pull request #54157 from fabpot/release-5.4.37
fabpot Mar 4, 2024
2ed7af7
Bump Symfony version to 5.4.38
fabpot Mar 4, 2024
b9da773
Update CHANGELOG for 6.4.5
fabpot Mar 4, 2024
e394573
Update VERSION for 6.4.5
fabpot Mar 4, 2024
86b66dc
Merge pull request #54158 from fabpot/release-6.4.5
fabpot Mar 4, 2024
75bafd2
Bump Symfony version to 6.4.6
fabpot Mar 4, 2024
47d722b
Update CHANGELOG for 7.0.5
fabpot Mar 4, 2024
f3ecda4
Update VERSION for 7.0.5
fabpot Mar 4, 2024
aa77387
Merge pull request #54159 from fabpot/release-7.0.5
fabpot Mar 4, 2024
cdb3fdd
Bump Symfony version to 7.0.6
fabpot Mar 4, 2024
f5b5e14
Merge branch '5.4' into 6.4
derrabus Mar 5, 2024
0523300
bug #54146 [HttpClient] Preserve float in JsonMockResponse (Jibbarth)
derrabus Mar 5, 2024
e37f57b
Merge branch '6.4' into 7.0
derrabus Mar 5, 2024
b982c71
Merge branch '7.0' into 7.1
derrabus Mar 5, 2024
dac2ea7
[HttpClient] Add support for amphp/http-client v5
nicolas-grekas May 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- php: '8.2'
mode: low-deps
- php: '8.3'
- php: '8.4'
#mode: experimental
fail-fast: false

Expand Down
9 changes: 0 additions & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,8 @@
'@Symfony' => true,
'@Symfony:risky' => true,
'protected_to_private' => false,
'native_constant_invocation' => ['strict' => false],
'no_superfluous_phpdoc_tags' => [
'remove_inheritdoc' => true,
'allow_unused_params' => true, // for future-ready params, to be replaced with https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7377
],
'nullable_type_declaration_for_default_null_value' => true,
'header_comment' => ['header' => $fileHeaderComment],
'modernize_strpos' => true,
'get_class_to_class_keyword' => true,
'nullable_type_declaration' => true,
'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
])
->setRiskyAllowed(true)
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ in 7.0 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/v7.0.0...v7.0.1

* 7.0.5 (2024-03-04)

* bug #54113 [AssetMapper] Throw exception in Javascript compiler when PCRE error (smnandre)
* bug #54129 [Clock] Add attributes to support PHPUnit 10 + 11 (ruudk)
* bug #54079 [AssetMapper] Fix `JavaScriptImportPathCompiler` regression in regex (PhilETaylor)
* bug #54102 [HttpClient] Fix deprecation on PHP 8.3 (nicolas-grekas)
* bug #54089 [Mailer] [Brevo] Remove tags from mandatory event arguments (palgalik)
* bug #54081 [DoctrineBridge] Safeguard dynamic access to Doctrine metadata properties (derrabus)
* bug #54080 [Routing] Enhance error handling in StaticPrefixCollection for compatibility with libpcre2-10.43 (Lustmored)

* 7.0.4 (2024-02-27)

* bug #53985 [HttpKernel] Allow tagged controllers in ControllerResolver (marein)
Expand Down
16 changes: 10 additions & 6 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ The Symfony Connect username in parenthesis allows to get more information
- Mathieu Santostefano (welcomattic)
- Alexander Schranz (alexander-schranz)
- Vasilij Duško (staff)
- Simon André (simonandre)
- Sarah Khalil (saro0h)
- Laurent VOULLEMIER (lvo)
- Konstantin Kudryashov (everzet)
- Tomasz Kowalczyk (thunderer)
- Simon André (simonandre)
- Guilhem N (guilhemn)
- Bilal Amarni (bamarni)
- Eriksen Costa
Expand All @@ -97,10 +97,10 @@ The Symfony Connect username in parenthesis allows to get more information
- David Buchmann (dbu)
- Andrej Hudec (pulzarraider)
- Jáchym Toušek (enumag)
- Ruud Kamphuis (ruudk)
- Christian Raue
- Eric Clemmons (ericclemmons)
- Denis (yethee)
- Ruud Kamphuis (ruudk)
- Michel Weimerskirch (mweimerskirch)
- Issei Murasawa (issei_m)
- Douglas Greenshields (shieldo)
Expand Down Expand Up @@ -129,8 +129,8 @@ The Symfony Connect username in parenthesis allows to get more information
- Bart van den Burg (burgov)
- Vasilij Dusko | CREATION
- Jordan Alliot (jalliot)
- John Wards (johnwards)
- Phil E. Taylor (philetaylor)
- John Wards (johnwards)
- Théo FIDRY
- Antoine Hérault (herzult)
- Konstantin.Myakshin
Expand Down Expand Up @@ -177,6 +177,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Maxime Helias (maxhelias)
- Robert Schönthal (digitalkaoz)
- Smaine Milianni (ismail1432)
- Michael Babker (mbabker)
- François-Xavier de Guillebon (de-gui_f)
- Maximilian Beckers (maxbeckers)
- noniagriconomie
Expand All @@ -188,7 +189,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Jhonny Lidfors (jhonne)
- Juti Noppornpitak (shiroyuki)
- Gregor Harlan (gharlan)
- Michael Babker (mbabker)
- Anthony MARTIN
- Sebastian Hörl (blogsh)
- Tigran Azatyan (tigranazatyan)
Expand Down Expand Up @@ -231,6 +231,7 @@ The Symfony Connect username in parenthesis allows to get more information
- George Mponos (gmponos)
- Richard Shank (iampersistent)
- Thomas Landauer (thomas-landauer)
- Roland Franssen :)
- Romain Monteil (ker0x)
- Sergey (upyx)
- Marco Pivetta (ocramius)
Expand All @@ -257,7 +258,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Artur Kotyrba
- Wouter J
- Tyson Andre
- Roland Franssen :)
- GDIBass
- Samuel NELA (snela)
- Vincent AUBERT (vincent)
Expand Down Expand Up @@ -733,6 +733,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Vadim Borodavko (javer)
- Tavo Nieves J (tavoniievez)
- Luc Vieillescazes (iamluc)
- Stiven Llupa (sllupa)
- Erik Saunier (snickers)
- François Dume (franek)
- Jerzy Lekowski (jlekowski)
Expand Down Expand Up @@ -1043,7 +1044,6 @@ The Symfony Connect username in parenthesis allows to get more information
- Florian Pfitzer (marmelatze)
- Ivan Grigoriev (greedyivan)
- Johann Saunier (prophet777)
- Stiven Llupa (sllupa)
- Kevin SCHNEKENBURGER
- Fabien Salles (blacked)
- Andreas Erhard (andaris)
Expand Down Expand Up @@ -2117,6 +2117,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Sébastien HOUZÉ
- Mbechezi Nawo
- wivaku
- Markus Reinhold
- Jingyu Wang
- steveYeah
- Asrorbek (asrorbek)
Expand Down Expand Up @@ -2523,6 +2524,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Roy de Vos Burchart
- John Stevenson
- everyx
- Richard Heine
- Francisco Facioni (fran6co)
- Stanislav Gamaiunov (happyproff)
- Iwan van Staveren (istaveren)
Expand Down Expand Up @@ -3193,6 +3195,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Daniele Cesarini (ijanki)
- Ismail Asci (ismailasci)
- Jeffrey Moelands (jeffreymoelands)
- Jakub Caban (lustmored)
- Ondřej Mirtes (mirtes)
- Paulius Jarmalavičius (pjarmalavicius)
- Ramon Ornelas (ramonornela)
Expand Down Expand Up @@ -3615,6 +3618,7 @@ The Symfony Connect username in parenthesis allows to get more information
- Konrad
- Kovacs Nicolas
- eminjk
- Gálik Pál
- craigmarvelley
- Stano Turza
- Antoine Leblanc
Expand Down
5 changes: 5 additions & 0 deletions UPGRADE-7.1.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
UPGRADE FROM 7.0 to 7.1
=======================

AssetMapper
-----------

* Deprecate `ImportMapConfigReader::splitPackageNameAndFilePath()`, use `ImportMapEntry::splitPackageNameAndFilePath()` instead

Cache
-----

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@
"symfony/yaml": "self.version"
},
"require-dev": {
"amphp/amp": "^2.5",
"amphp/http-client": "^4.2.1",
"amphp/http-tunnel": "^1.0",
"amphp/http-client": "^4.2.1|^5.0",
"amphp/http-tunnel": "^1.0|^2.0",
"async-aws/ses": "^1.0",
"async-aws/sqs": "^1.0|^2.0",
"async-aws/sns": "^1.0",
Expand All @@ -151,6 +150,7 @@
"psr/http-client": "^1.0",
"psr/simple-cache": "^1.0|^2.0|^3.0",
"seld/jsonlint": "^1.10",
"symfony/amphp-http-client-meta": "^1.0|^2.0",
"symfony/mercure-bundle": "^0.3",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/runtime": "self.version",
Expand All @@ -163,6 +163,7 @@
},
"conflict": {
"ext-psr": "<1.1|>=2",
"amphp/amp": "<2.5",
"async-aws/core": "<1.5",
"doctrine/dbal": "<3.6",
"doctrine/orm": "<2.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public function testCustomFailureHandler()

$client->request('POST', '/firewall1/login', [
'_username' => 'jane@example.org',
'_password' => '',
'_password' => 'wrong',
]);
$this->assertResponseRedirects('http://localhost/firewall1/login');

$client->request('POST', '/firewall1/dummy_login', [
'_username' => 'jane@example.org',
'_password' => '',
'_password' => 'wrong',
]);
$this->assertResponseRedirects('http://localhost/firewall1/dummy_login');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function testFormLoginWithInvalidCsrfToken($options)
});

$form = $client->request('GET', '/login')->selectButton('login')->form();
$form['user_login[username]'] = 'johannes';
$form['user_login[password]'] = 'test';
$form['user_login[_token]'] = '';
$client->submit($form);

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/AssetMapper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.1
---

* Deprecate `ImportMapConfigReader::splitPackageNameAndFilePath()`, use `ImportMapEntry::splitPackageNameAndFilePath()` instead

6.4
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@
final class JavaScriptImportPathCompiler implements AssetCompilerInterface
{
/**
* @see https://regex101.com/r/1iBAIb/1
* @see https://regex101.com/r/1iBAIb/2
*/
private const IMPORT_PATTERN = '/
^
(?:\/\/.*) # Lines that start with comments
^(?:\/\/.*) # Lines that start with comments
|
(?:
\'(?:[^\'\\\\\n]|\\\\.)*\' # Strings enclosed in single quotes
\'(?:[^\'\\\\\n]|\\\\.)*+\' # Strings enclosed in single quotes
|
"(?:[^"\\\\\n]|\\\\.)*" # Strings enclosed in double quotes
"(?:[^"\\\\\n]|\\\\.)*+" # Strings enclosed in double quotes
)
|
(?: # Import statements (script captured)
Expand All @@ -49,7 +48,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface
|
\bimport\(
)
\s*[\'"`](\.\/[^\'"`\n]+|(\.\.\/)*[^\'"`\n]+)[\'"`]\s*[;\)]
\s*[\'"`](\.\/[^\'"`\n]++|(\.\.\/)*+[^\'"`\n]++)[\'"`]\s*[;\)]
?
/mx';

Expand Down Expand Up @@ -116,7 +115,7 @@ public function compile(string $content, MappedAsset $asset, AssetMapperInterfac
$relativeImportPath = $this->makeRelativeForJavaScript($relativeImportPath);

return str_replace($importedModule, $relativeImportPath, $fullImportString);
}, $content, -1, $count, \PREG_OFFSET_CAPTURE);
}, $content, -1, $count, \PREG_OFFSET_CAPTURE) ?? throw new RuntimeException(sprintf('Failed to compile JavaScript import paths in "%s". Error: "%s".', $asset->sourcePath, preg_last_error_msg()));
}

public function supports(MappedAsset $asset): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getEntries(): ImportMapEntries

$version = $data['version'] ?? null;

if (null === $version && null === $path) {
if (null === $version) {
throw new RuntimeException(sprintf('The importmap entry "%s" must have either a "path" or "version" option.', $importName));
}

Expand Down Expand Up @@ -172,8 +172,13 @@ private function getRootDirectory(): string
return \dirname($this->importMapConfigPath);
}

/**
* @deprecated since Symfony 7.1, use ImportMapEntry::splitPackageNameAndFilePath() instead
*/
public static function splitPackageNameAndFilePath(string $packageName): array
{
trigger_deprecation('symfony/asset-mapper', '7.1', 'The method "%s()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.', __METHOD__);

$filePath = '';
$i = strpos($packageName, '/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,23 @@ public function testErrorMessageAvoidsCircularException()
// should not be caught.
$this->assertSame($content, $compiled);
}

public function testCompilerThrowsExceptionOnPcreError()
{
$compiler = new JavaScriptImportPathCompiler($this->createMock(ImportMapConfigReader::class));
$content = str_repeat('foo "import * ', 50);
$javascriptAsset = new MappedAsset('app.js', '/project/assets/app.js', publicPathWithoutDigest: '/assets/app.js');
$assetMapper = $this->createMock(AssetMapperInterface::class);

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Failed to compile JavaScript import paths in "/project/assets/app.js". Error: "Backtrack limit exhausted".');

$limit = \ini_get('pcre.backtrack_limit');
ini_set('pcre.backtrack_limit', 10);
try {
$compiler->compile($content, $javascriptAsset, $assetMapper);
} finally {
ini_set('pcre.backtrack_limit', $limit);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\AssetMapper\Tests\ImportMap;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader;
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries;
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry;
Expand All @@ -21,6 +22,8 @@

class ImportMapConfigReaderTest extends TestCase
{
use ExpectDeprecationTrait;

private Filesystem $filesystem;

protected function setUp(): void
Expand Down Expand Up @@ -162,4 +165,13 @@ public function testFindRootImportMapEntry()
$this->assertSame('file2', $entry->importName);
$this->assertSame('file2.js', $entry->path);
}

/**
* @group legacy
*/
public function testDeprecatedMethodTriggerDeprecation()
{
$this->expectDeprecation('Since symfony/asset-mapper 7.1: The method "Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader::splitPackageNameAndFilePath()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.');
ImportMapConfigReader::splitPackageNameAndFilePath('foo');
}
}
1 change: 1 addition & 0 deletions src/Symfony/Component/AssetMapper/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": ">=8.2",
"composer/semver": "^3.0",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/filesystem": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0"
},
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Clock/Test/ClockSensitiveTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Symfony\Component\Clock\Test;

use PHPUnit\Framework\Attributes\After;
use PHPUnit\Framework\Attributes\Before;
use PHPUnit\Framework\Attributes\BeforeClass;
use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\Clock\Clock;
use Symfony\Component\Clock\MockClock;
Expand Down Expand Up @@ -48,6 +51,8 @@ public static function mockTime(string|\DateTimeImmutable|bool $when = true): Cl
*
* @internal
*/
#[Before]
#[BeforeClass]
public static function saveClockBeforeTest(bool $save = true): ClockInterface
{
static $originalClock;
Expand All @@ -64,6 +69,7 @@ public static function saveClockBeforeTest(bool $save = true): ClockInterface
*
* @internal
*/
#[After]
protected static function restoreClockAfterTest(): void
{
Clock::set(self::saveClockBeforeTest(false));
Expand Down
Loading
0