Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de1a7bf

Browse files
Merge branch '4.4' into 5.4
* 4.4: [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 be7edea + 6a93d11 commit de1a7bf

File tree

13 files changed

+101
-16
lines changed

13 files changed

+101
-16
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class CollectionToArrayTransformer implements DataTransformerInterface
2424
/**
2525
* Transforms a collection into an array.
2626
*
27-
* @return mixed
28-
*
2927
* @throws TransformationFailedException
3028
*/
3129
public function transform($collection)
@@ -48,9 +46,7 @@ public function transform($collection)
4846
}
4947

5048
/**
51-
* Transforms choice keys into entities.
52-
*
53-
* @param mixed $array An array of entities
49+
* Transforms an array into a collection.
5450
*
5551
* @return Collection
5652
*/

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

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

112-
if (!str_starts_with($this->prefix, 'phar://') && !str_contains($this->pattern, '/**/')) {
112+
if ('' === $this->pattern && is_file($prefix)) {
113+
$paths = [$this->prefix];
114+
} elseif (!str_starts_with($this->prefix, 'phar://') && !str_contains($this->pattern, '/**/')) {
113115
if ($this->globBrace || !str_contains($this->pattern, '{')) {
114116
$paths = glob($this->prefix.$this->pattern, \GLOB_NOSORT | $this->globBrace);
115117
} elseif (!str_contains($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
@@ -170,14 +172,21 @@ function (\SplFileInfo $file, $path) {
170172
throw new \LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $this->pattern));
171173
}
172174

175+
if (is_file($prefix = $this->prefix)) {
176+
$prefix = \dirname($prefix);
177+
$pattern = basename($prefix).$this->pattern;
178+
} else {
179+
$pattern = $this->pattern;
180+
}
181+
173182
$finder = new Finder();
174-
$regex = Glob::toRegex($this->pattern);
183+
$regex = Glob::toRegex($pattern);
175184
if ($this->recursive) {
176185
$regex = substr_replace($regex, '(/|$)', -2, 1);
177186
}
178187

179-
$prefixLen = \strlen($this->prefix);
180-
foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) {
188+
$prefixLen = \strlen($prefix);
189+
foreach ($finder->followLinks()->sortByName()->in($prefix) as $path => $info) {
181190
$normalizedPath = str_replace('\\', '/', $path);
182191
if (!preg_match($regex, substr($normalizedPath, $prefixLen)) || !$info->isFile()) {
183192
continue;
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
@@ -208,4 +208,29 @@ public function testSerializeUnserialize()
208208

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

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;
@@ -458,4 +460,14 @@ public function testSymfonySerialize()
458460
$this->assertEquals($expected->getHeaders(), $n->getHeaders());
459461
$this->assertEquals($expected->getBody(), $n->getBody());
460462
}
463+
464+
public function testMissingHeaderDoesNotThrowError()
465+
{
466+
$this->expectException(ExpectationFailedException::class);
467+
$this->expectExceptionMessage('Failed asserting that the Email has header "foo" with value "bar" (value is null).');
468+
469+
$e = new Email();
470+
$emailHeaderSame = new EmailHeaderSame('foo', 'bar');
471+
$emailHeaderSame->evaluate($e);
472+
}
461473
}

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 <[email protected]>
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 <[email protected]>
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
*

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.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 <[email protected]>
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
class Php80Dummy

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php81Dummy.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 <[email protected]>
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
class Php81Dummy

src/Symfony/Component/PropertyInfo/Tests/Fixtures/PseudoTypeDummy.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 <[email protected]>
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
class PseudoTypeDummy

0 commit comments

Comments
 (0)