Skip to content

Commit f4d0372

Browse files
Merge branch '6.0' into 6.1
* 6.0: [VarDumper] fix tests on PHP 8.2 [Mime] Add null check for EmailHeaderSame Add approriate description to CollectionToArrayTransformer::reverseTransform docblock [PropertyInfo] CS fixes [VarDumper] fix test on PHP 8.2 [Config] Fix looking for single files in phars with GlobResource Revert "bug #46327 [HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 (mpdude)"
2 parents 9fafd82 + 25bba6b commit f4d0372

File tree

14 files changed

+103
-16
lines changed

14 files changed

+103
-16
lines changed

src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public function transform(mixed $collection): mixed
4646
}
4747

4848
/**
49-
* Transforms choice keys into entities.
50-
*
51-
* @param mixed $array An array of entities
49+
* Transforms an array into a collection.
5250
*/
5351
public function reverseTransform(mixed $array): Collection
5452
{

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ public function getIterator(): \Traversable
106106
$prefix = str_replace('\\', '/', $this->prefix);
107107
$paths = null;
108108

109-
if (!str_starts_with($this->prefix, 'phar://') && !str_contains($this->pattern, '/**/')) {
109+
if ('' === $this->pattern && is_file($prefix)) {
110+
$paths = [$this->prefix];
111+
} elseif (!str_starts_with($this->prefix, 'phar://') && !str_contains($this->pattern, '/**/')) {
110112
if ($this->globBrace || !str_contains($this->pattern, '{')) {
111113
$paths = glob($this->prefix.$this->pattern, \GLOB_NOSORT | $this->globBrace);
112114
} elseif (!str_contains($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
@@ -167,12 +169,19 @@ function (\SplFileInfo $file, $path) {
167169
throw new \LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $this->pattern));
168170
}
169171

170-
$regex = Glob::toRegex($this->pattern);
172+
if (is_file($prefix = $this->prefix)) {
173+
$prefix = \dirname($prefix);
174+
$pattern = basename($prefix).$this->pattern;
175+
} else {
176+
$pattern = $this->pattern;
177+
}
178+
179+
$regex = Glob::toRegex($pattern);
171180
if ($this->recursive) {
172181
$regex = substr_replace($regex, '(/|$)', -2, 1);
173182
}
174183

175-
$prefixLen = \strlen($this->prefix);
184+
$prefixLen = \strlen($prefix);
176185

177186
yield from (new Finder())
178187
->followLinks()
@@ -190,7 +199,7 @@ function (\SplFileInfo $file, $path) {
190199
}
191200
})
192201
->sortByName()
193-
->in($this->prefix)
202+
->in($prefix)
194203
;
195204
}
196205

1.16 KB
Binary file not shown.

src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,29 @@ public function testSerializeUnserialize()
205205

206206
$this->assertEquals($p->getValue($resource), $p->getValue($newResource));
207207
}
208+
209+
public function testPhar()
210+
{
211+
$s = \DIRECTORY_SEPARATOR;
212+
$cwd = getcwd();
213+
chdir(\dirname(__DIR__).'/Fixtures');
214+
try {
215+
$resource = new GlobResource('phar://some.phar', '*', true);
216+
$files = array_keys(iterator_to_array($resource));
217+
$this->assertSame(["phar://some.phar{$s}ProjectWithXsdExtensionInPhar.php", "phar://some.phar{$s}schema{$s}project-1.0.xsd"], $files);
218+
219+
$resource = new GlobResource("phar://some.phar{$s}ProjectWithXsdExtensionInPhar.php", '', true);
220+
$files = array_keys(iterator_to_array($resource));
221+
$this->assertSame(["phar://some.phar{$s}ProjectWithXsdExtensionInPhar.php"], $files);
222+
} finally {
223+
chdir($cwd);
224+
}
225+
}
226+
227+
public function testFilePrefix()
228+
{
229+
$resource = new GlobResource(__FILE__, '/**/', true);
230+
$files = array_keys(iterator_to_array($resource));
231+
$this->assertSame([], $files);
232+
}
208233
}

src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ protected function matches($message): bool
5555
*/
5656
protected function failureDescription($message): string
5757
{
58-
return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message));
58+
return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message) ?? 'null');
5959
}
6060

61-
private function getHeaderValue($message): string
61+
private function getHeaderValue($message): ?string
6262
{
63-
$header = $message->getHeaders()->get($this->headerName);
63+
if (null === $header = $message->getHeaders()->get($this->headerName)) {
64+
return null;
65+
}
6466

6567
return $header instanceof UnstructuredHeader ? $header->getValue() : $header->getBodyAsString();
6668
}

src/Symfony/Component/Mime/Tests/EmailTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Mime\Tests;
1313

14+
use PHPUnit\Framework\ExpectationFailedException;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Mime\Address;
1617
use Symfony\Component\Mime\Email;
@@ -19,6 +20,7 @@
1920
use Symfony\Component\Mime\Part\Multipart\MixedPart;
2021
use Symfony\Component\Mime\Part\Multipart\RelatedPart;
2122
use Symfony\Component\Mime\Part\TextPart;
23+
use Symfony\Component\Mime\Test\Constraint\EmailHeaderSame;
2224
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
2325
use Symfony\Component\Serializer\Encoder\JsonEncoder;
2426
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
@@ -466,4 +468,14 @@ public function testSymfonySerialize()
466468
$this->assertEquals($expected->getHeaders(), $n->getHeaders());
467469
$this->assertEquals($expected->getBody(), $n->getBody());
468470
}
471+
472+
public function testMissingHeaderDoesNotThrowError()
473+
{
474+
$this->expectException(ExpectationFailedException::class);
475+
$this->expectExceptionMessage('Failed asserting that the Email has header "foo" with value "bar" (value is null).');
476+
477+
$e = new Email();
478+
$emailHeaderSame = new EmailHeaderSame('foo', 'bar');
479+
$emailHeaderSame->evaluate($e);
480+
}
469481
}

src/Symfony/Component/PropertyInfo/Tests/Fixtures/ConstructorDummy.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
413

514
/**

src/Symfony/Component/PropertyInfo/Tests/Fixtures/DockBlockFallback.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
4-
53
/*
64
* This file is part of the Symfony package.
75
*

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Extractor/DummyNamespace.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace A {
413
class Property {
514

src/Symfony/Component/PropertyInfo/Tests/Fixtures/NoProperties.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
4-
53
/*
64
* This file is part of the Symfony package.
75
*

0 commit comments

Comments
 (0)