Skip to content

Commit

Permalink
Merge branch '4.4' into 5.1
Browse files Browse the repository at this point in the history
* 4.4:
  fix merge
  Remove branch-version (keep them for contracts only)
  [HttpClient] relax auth bearer format requirements
  [PHPUnitBridge] Silence errors from mkdir()
  [DependencyInjection] Preload classes with union types correctly.
  [Serializer] fix decoding float XML attributes starting with 0
  add missing dutch translations
  Support PHPUnit 8 and PHPUnit 9 in constraint compatibility trait
  Add expectDeprecation, expectNotice, expectWarning, and expectError to TestCase polyfill
  Add missing exporter function for PHPUnit 7
  [Validator] Add missing romanian translations
  [Cache] Use correct expiry in ChainAdapter
  do not translate null placeholders or titles
  • Loading branch information
nicolas-grekas committed Oct 24, 2020
2 parents a930a36 + b296fd4 commit fe00d94
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dumper/Preloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static function doPreload(string $class, array &$preloaded): void

private static function preloadType(?\ReflectionType $t, array &$preloaded): void
{
if (!$t || $t->isBuiltin()) {
if (!$t) {
return;
}

Expand Down
53 changes: 53 additions & 0 deletions Tests/Dumper/PreloaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Dumper;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Dumper\Preloader;

class PreloaderTest extends TestCase
{
/**
* @requires PHP 7.4
*/
public function testPreload()
{
$r = new \ReflectionMethod(Preloader::class, 'doPreload');
$r->setAccessible(true);

$preloaded = [];

$r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', &$preloaded]);

self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', false));
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\A', false));
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\B', false));
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\C', false));
}

/**
* @requires PHP 8
*/
public function testPreloadUnion()
{
$r = new \ReflectionMethod(Preloader::class, 'doPreload');
$r->setAccessible(true);

$preloaded = [];

$r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', &$preloaded]);

self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', false));
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\D', false));
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\E', false));
}
}
16 changes: 16 additions & 0 deletions Tests/Fixtures/Preload/A.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class A
{
}
16 changes: 16 additions & 0 deletions Tests/Fixtures/Preload/B.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class B
{
}
16 changes: 16 additions & 0 deletions Tests/Fixtures/Preload/C.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class C
{
}
16 changes: 16 additions & 0 deletions Tests/Fixtures/Preload/D.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class D
{
}
30 changes: 30 additions & 0 deletions Tests/Fixtures/Preload/Dummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class Dummy
{
public A $a;

public function doSomething(B $b): ?C
{
return null;
}

public function noTypes($foo)
{
}

public function builtinTypes(int $foo): ?string
{
}
}
16 changes: 16 additions & 0 deletions Tests/Fixtures/Preload/E.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class E
{
}
21 changes: 21 additions & 0 deletions Tests/Fixtures/Preload/UnionDummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;

final class UnionDummy
{
public D|E $de;

public function builtinTypes(int|float $foo): string|\Stringable|null
{
}
}
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,5 @@
"/Tests/"
]
},
"minimum-stability": "dev",
"extra": {
"branch-version": "5.1"
}
"minimum-stability": "dev"
}

0 comments on commit fe00d94

Please sign in to comment.