8000 Merge branch '6.3' into 6.4 · symfony/symfony@4ba0137 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ba0137

Browse files
Merge branch '6.3' into 6.4
* 6.3: [GHA] Remove deprecations-baseline [DependencyInjection] Support PHP 8.2 `true` type
2 parents 42d43b7 + c973874 commit 4ba0137

File tree

6 files changed

+41
-879
lines changed

6 files changed

+41
-879
lines changed

.github/deprecations-baseline.json

Lines changed: 0 additions & 877 deletions
This file was deleted.

.github/workflows/integration-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ jobs:
157157
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
158158
export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev
159159
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
160-
echo SYMFONY_DEPRECATIONS_HELPER="baselineFile=$(pwd)/.github/deprecations-baseline.json" >> $GITHUB_ENV
161160
162161
echo "::group::composer update"
163162
composer require --dev --no-update mongodb/mongodb

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ jobs:
8888
8989
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
9090
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
91-
echo SYMFONY_DEPRECATIONS_HELPER="baselineFile=$(pwd)/.github/deprecations-baseline.json" >> $GITHUB_ENV
9291
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
9392
else
9493
echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ private function checkType(Definition $checkedDefinition, mixed $value, \Reflect
311311
if (false === $value) {
312312
return;
313313
}
314+
} elseif ('true' === $type) {
315+
if (true === $value) {
316+
return;
317+
}
314318
} elseif ($reflectionType->isBuiltin()) {
315319
$checkFunction = sprintf('is_%s', $type);
316320
if ($checkFunction($value)) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
3333
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\IntersectionConstructor;
3434
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructor;
35+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructorPHP82;
3536
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Waldo;
3637
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\WaldoFoo;
3738
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Wobble;
@@ -859,6 +860,26 @@ public function testUnionTypePassesWithFalse()
859860
$this->addToAssertionCount(1);
860861
}
861862

863+
/**
864+
* @requires PHP 8.2
865+
*/
866+
public function testUnionTypePassesWithTrue()
867+
{
868+
$container = new ContainerBuilder();
869+
870+
$container->register('unionTrue', UnionConstructorPHP82::class)
871+
->setFactory([UnionConstructorPHP82::class, 'createTrue'])
872+
->setArguments([true]);
873+
874+
$container->register('unionNull', UnionConstructorPHP82::class)
875+
->setFactory([UnionConstructorPHP82::class, 'createNull'])
876+
->setArguments([null]);
877+
878+
(new CheckTypeDeclarationsPass(true))->process($container);
879+
880+
$this->addToAssertionCount(1);
881+
}
882+
862883
public function testUnionTypeFailsWithReference()
863884
{
864885
$container = new ContainerBuilder();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
class UnionConstructorPHP82
6+
{
7+
public static function createTrue(array|true $arg): static
8+
{
9+
return new static(0);
10+
}
11+
12+
public static function createNull(null $arg): static
13+
{
14+
return new static(0);
15+
}
16+
}

0 commit comments

Comments
 (0)
0