Skip to content

Commit 9fd64b8

Browse files
Merge branch '7.0' into 7.1
* 7.0: Fix CI Bump ext-redis in CI on PHP >= 8.4 Adjust pretty name of closures on PHP 8.4 implement NodeVisitorInterface instead of extending AbstractNodeVisitor sync .github/expected-missing-return-types.diff skip test assertions that are no longer valid with PHP >= 8.2.18/8.3.5
2 parents 39a5fdc + f09249c commit 9fd64b8

File tree

14 files changed

+38
-24
lines changed

14 files changed

+38
-24
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
coverage: "none"
5151
ini-values: date.timezone=UTC,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1
5252
php-version: "${{ matrix.php }}"
53-
extensions: "${{ env.extensions }}"
53+
extensions: "${{ matrix.extensions || env.extensions }}"
5454
tools: flex
5555

5656
- name: Configure environment

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
use Twig\Node\ModuleNode;
2424
use Twig\Node\Node;
2525
use Twig\Node\SetNode;
26-
use Twig\NodeVisitor\AbstractNodeVisitor;
26+
use Twig\NodeVisitor\NodeVisitorInterface;
2727

2828
/**
2929
* @author Fabien Potencier <[email protected]>
3030
*/
31-
final class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
31+
final class TranslationDefaultDomainNodeVisitor implements NodeVisitorInterface
3232
{
3333
private Scope $scope;
3434

@@ -37,7 +37,7 @@ public function __construct()
3737
$this->scope = new Scope();
3838
}
3939

40-
protected function doEnterNode(Node $node, Environment $env): Node
40+
public function enterNode(Node $node, Environment $env): Node
4141
{
4242
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
4343
$this->scope = $this->scope->enter();
@@ -83,7 +83,7 @@ protected function doEnterNode(Node $node, Environment $env): Node
8383
return $node;
8484
}
8585

86-
protected function doLeaveNode(Node $node, Environment $env): ?Node
86+
public function leaveNode(Node $node, Environment $env): ?Node
8787
{
8888
if ($node instanceof TransDefaultDomainNode) {
8989
return null;

src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
use Twig\Node\Expression\FilterExpression;
1919
use Twig\Node\Expression\FunctionExpression;
2020
use Twig\Node\Node;
21-
use Twig\NodeVisitor\AbstractNodeVisitor;
21+
use Twig\NodeVisitor\NodeVisitorInterface;
2222

2323
/**
2424
* TranslationNodeVisitor extracts translation messages.
2525
*
2626
* @author Fabien Potencier <[email protected]>
2727
*/
28-
final class TranslationNodeVisitor extends AbstractNodeVisitor
28+
final class TranslationNodeVisitor implements NodeVisitorInterface
2929
{
3030
public const UNDEFINED_DOMAIN = '_undefined';
3131

@@ -49,7 +49,7 @@ public function getMessages(): array
4949
return $this->messages;
5050
}
5151

52-
protected function doEnterNode(Node $node, Environment $env): Node
52+
public function enterNode(Node $node, Environment $env): Node
5353
{
5454
if (!$this->enabled) {
5555
return $node;
@@ -98,7 +98,7 @@ protected function doEnterNode(Node $node, Environment $env): Node
9898
return $node;
9999
}
100100

101-
protected function doLeaveNode(Node $node, Environment $env): ?Node
101+
public function leaveNode(Node $node, Environment $env): ?Node
102102
{
103103
return $node;
104104
}

src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function testCreateConnection(string $dsn, string $expectedClass)
3131
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
3232
}
3333

34-
$mock = self::getObjectForTrait(RedisTrait::class);
34+
$mock = new class () {
35+
use RedisTrait;
36+
};
3537
$connection = $mock::createConnection($dsn);
3638

3739
self::assertInstanceOf($expectedClass, $connection);
@@ -43,7 +45,9 @@ public function testUrlDecodeParameters()
4345
self::markTestSkipped('REDIS_AUTHENTICATED_HOST env var is not defined.');
4446
}
4547

46-
$mock = self::getObjectForTrait(RedisTrait::class);
48+
$mock = new class () {
49+
use RedisTrait;
50+
};
4751
$connection = $mock::createConnection('redis://:p%40ssword@'.getenv('REDIS_AUTHENTICATED_HOST'));
4852

4953
self::assertInstanceOf(\Redis::class, $connection);
@@ -100,7 +104,9 @@ public function testPconnectSelectsCorrectDatabase()
100104
}
101105

102106
try {
103-
$mock = self::getObjectForTrait(RedisTrait::class);
107+
$mock = new class () {
108+
use RedisTrait;
109+
};
104110

105111
$dsn = 'redis://'.getenv('REDIS_HOST');
106112

src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testCallErrorExceptionInfo()
161161
$this->assertSame('Undefined variable $foo', $e->getMessage());
162162
$this->assertSame(__FILE__, $e->getFile());
163163
$this->assertSame(0, $e->getCode());
164-
$this->assertSame('Symfony\Component\ErrorHandler\{closure}', $trace[0]['function']);
164+
$this->assertStringMatchesFormat('%A{closure%A}', $trace[0]['function']);
165165
$this->assertSame(ErrorHandler::class, $trace[0]['class']);
166166
$this->assertSame('triggerNotice', $trace[1]['function']);
167167
$this->assertSame(__CLASS__, $trace[1]['class']);

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
171171
}
172172

173173
$finder = new PhpExecutableFinder();
174-
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057']));
174+
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', 'localhost:8057']));
175175
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
176176

177177
$process->start();
178178

179179
do {
180180
usleep(50000);
181-
} while (!@fopen('http://127.0.0.1:8057', 'r'));
181+
} while (!@fopen('http://localhost:8057', 'r'));
182182

183183
try {
184184
$sourceFilePath = 'http://localhost:8057/logo_symfony_header.png';

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static function provideControllerCallables(): array
118118
'Closure',
119119
fn () => 'foo',
120120
[
121-
'class' => __NAMESPACE__.'\{closure}',
121+
'class' => \PHP_VERSION_ID >= 80400 ? sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}',
122122
'method' => null,
123123
'file' => __FILE__,
124124
'line' => __LINE__ - 5,

src/Symfony/Component/Mime/Tests/Part/DataPartTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ public function testFromPathWithUrl()
143143
}
144144

145145
$finder = new PhpExecutableFinder();
146-
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057']));
146+
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', 'localhost:8057']));
147147
$process->setWorkingDirectory(__DIR__.'/../Fixtures/web');
148148
$process->start();
149149

150150
try {
151151
do {
152152
usleep(50000);
153-
} while (!@fopen('http://127.0.0.1:8057', 'r'));
153+
} while (!@fopen('http://localhost:8057', 'r'));
154154
$p = DataPart::fromPath($file = 'http://localhost:8057/logo_symfony_header.png');
155155
$content = file_get_contents($file);
156156
$this->assertEquals($content, $p->getBody());

src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ public function testBcryptWithNulByte()
104104
$hasher = new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT);
105105
$plainPassword = "a\0b";
106106

107-
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
107+
if (\PHP_VERSION_ID < 80218 || \PHP_VERSION_ID >= 80300 && \PHP_VERSION_ID < 80305) {
108+
// password_hash() does not accept passwords containing NUL bytes since PHP 8.2.18 and 8.3.5
109+
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
110+
}
111+
108112
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
109113
}
110114

src/Symfony/Component/PasswordHasher/Tests/Hasher/SodiumPasswordHasherTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public function testBcryptWithNulByte()
7878
$hasher = new SodiumPasswordHasher(null, null);
7979
$plainPassword = "a\0b";
8080

81-
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
81+
if (\PHP_VERSION_ID < 80218 || \PHP_VERSION_ID >= 80300 && \PHP_VERSION_ID < 80305) {
82+
// password_hash() does not accept passwords containing NUL bytes since PHP 8.2.18 and 8.3.5
83+
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
84+
}
85+
8286
$this->assertTrue($hasher->verify((new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT))->hash($plainPassword), $plainPassword));
8387
}
8488

0 commit comments

Comments
 (0)