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

Skip to content

Commit 8bf9a64

Browse files
Merge branch '4.4' into 5.3
* 4.4: [DependencyInjection][HttpKernel] Fix enum typed bindings [CI] Remove macOS jobs Suppress psalm error for UndefinedDocblockClass for PHP 8.1 classes
2 parents 3b3f87f + 30594b2 commit 8bf9a64

File tree

12 files changed

+62
-40
lines changed

12 files changed

+62
-40
lines changed

.github/workflows/unit-tests.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,16 @@ jobs:
2020
matrix:
2121
include:
2222
- php: '7.2'
23-
os: ubuntu-20.04
2423
- php: '7.4'
25-
os: ubuntu-20.04
26-
- php: '8.0'
27-
os: macos-11
2824
- php: '8.0'
2925
mode: high-deps
30-
os: ubuntu-20.04
3126
- php: '8.1'
3227
mode: low-deps
33-
os: ubuntu-20.04
3428
- php: '8.2'
3529
mode: experimental
36-
os: ubuntu-20.04
3730
fail-fast: false
3831

39-
runs-on: "${{ matrix.os }}"
32+
runs-on: ubuntu-20.04
4033

4134
steps:
4235
- name: Checkout
@@ -58,11 +51,6 @@ jobs:
5851
extensions: "${{ env.extensions }}"
5952
tools: flex
6053

61-
- name: Install Homebrew packages
62-
if: "matrix.os == 'macos-11'"
63-
run: |
64-
brew install parallel
65-
6654
- name: Configure environment
6755
run: |
6856
git config --global user.email ""
@@ -74,7 +62,7 @@ jobs:
7462
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
7563
7664
echo COLUMNS=120 >> $GITHUB_ENV
77-
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data$([[ ${{ matrix.os }} = macos* ]] && echo ',transient-on-macos')" >> $GITHUB_ENV
65+
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data" >> $GITHUB_ENV
7866
echo COMPOSER_UP='composer update --no-progress --ansi' >> $GITHUB_ENV
7967
8068
SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
@@ -148,7 +136,7 @@ jobs:
148136
echo "::endgroup::"
149137
150138
- name: Patch return types
151-
if: "matrix.php == '8.1' && ! matrix.mode && matrix.os != 'macos-11'"
139+
if: "matrix.php == '8.1' && ! matrix.mode"
152140
run: |
153141
sed -i 's/"\*\*\/Tests\/"//' composer.json
154142
composer install -q --optimize-autoloader
@@ -225,7 +213,7 @@ jobs:
225213
[[ ! $X ]] || (exit 1)
226214
227215
- name: Run tests with SIGCHLD enabled PHP
228-
if: "matrix.php == '7.2' && ! matrix.mode && matrix.os != 'macos-11'"
216+
if: "matrix.php == '7.2' && ! matrix.mode"
229217
run: |
230218
mkdir build
231219
cd build

psalm.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,13 @@
2727
<referencedClass name="UnitEnum"/>
2828
</errorLevel>
2929
</UndefinedClass>
30+
<UndefinedDocblockClass>
31+
<errorLevel type="suppress">
32+
<!-- These classes have been added in PHP 8.1 -->
33+
<referencedClass name="BackedEnum"/>
34+
<referencedClass name="ReflectionIntersectionType"/>
35+
<referencedClass name="UnitEnum"/>
36+
</errorLevel>
37+
</UndefinedDocblockClass>
3038
</issueHandlers>
3139
</psalm>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ protected function processValue($value, bool $isRoot = false)
134134
continue;
135135
}
136136

137+
if (is_subclass_of($m[1], \UnitEnum::class)) {
138+
$bindingNames[substr($key, \strlen($m[0]))] = $binding;
139+
continue;
140+
}
141+
137142
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) {
138143
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected "%s", "%s", "%s", "%s" or null, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, ServiceLocatorArgument::class, get_debug_type($bindingValue)));
139144
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
use Symfony\Component\DependencyInjection\Reference;
2626
use Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface;
2727
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
28+
use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum;
2829
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
30+
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedEnumArgumentDummy;
2931
use Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists;
3032
use Symfony\Component\DependencyInjection\Tests\Fixtures\WithTarget;
3133
use Symfony\Component\DependencyInjection\TypedReference;
@@ -65,6 +67,27 @@ public function testProcess()
6567
$this->assertEquals([['setSensitiveClass', [new Reference('foo')]]], $definition->getMethodCalls());
6668
}
6769

70+
/**
71+
* @requires PHP 8.1
72+
*/
73+
public function testProcessEnum()
74+
{
75+
$container = new ContainerBuilder();
76+
77+
$bindings = [
78+
FooUnitEnum::class.' $bar' => new BoundArgument(FooUnitEnum::BAR),
79+
];
80+
81+
$definition = $container->register(NamedEnumArgumentDummy::class, NamedEnumArgumentDummy::class);
82+
$definition->setBindings($bindings);
83+
84+
$pass = new ResolveBindingsPass();
85+
$pass->process($container);
86+
87+
$expected = [FooUnitEnum::BAR];
88+
$this->assertEquals($expected, $definition->getArguments());
89+
}
90+
6891
public function testUnusedBinding()
6992
{
7093
$this->expectException(InvalidArgumentException::class);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
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+
12+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
13+
14+
class NamedEnumArgumentDummy
15+
{
16+
public function __construct(FooUnitEnum $bar)
17+
{
18+
}
19+
}

src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public function request(string $method, string $url, array $options = []): Respo
5454
};
5555
}
5656

57-
/**
58-
* @group transient-on-macos
59-
*/
6057
public function testTimeoutOnDestruct()
6158
{
6259
if (HttpClient::create() instanceof NativeHttpClient) {

src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
3232
{
3333
private static $vulcainStarted = false;
3434

35-
/**
36-
* @group transient-on-macos
37-
*/
3835
public function testTimeoutOnDestruct()
3936
{
4037
if (!method_exists(parent::class, 'testTimeoutOnDestruct')) {

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ public function process(ContainerBuilder $container)
140140
$type = ltrim($target = (string) ProxyHelper::getTypeHint($r, $p), '\\');
141141
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
142142

143-
if (is_subclass_of($type, \UnitEnum::class)) {
144-
// do not attempt to register enum typed arguments
145-
continue;
146-
}
147-
148143
if (isset($arguments[$r->name][$p->name])) {
149144
$target = $arguments[$r->name][$p->name];
150145
if ('?' !== $target[0]) {
@@ -169,6 +164,9 @@ public function process(ContainerBuilder $container)
169164
$args[$p->name] = $bindingValue;
170165
}
171166

167+
continue;
168+
} elseif (is_subclass_of($type, \UnitEnum::class)) {
169+
// do not attempt to register enum typed arguments if not already present in bindings
172170
continue;
173171
} elseif (!$type || !$autowire || '\\' !== $target[0]) {
174172
continue;

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineIntegrationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
/**
2323
* @requires extension pdo_sqlite
24-
* @group transient-on-macos
2524
*/
2625
class DoctrineIntegrationTest extends TestCase
2726
{

src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public function testDumpForwardsToWrappedDumperWhenServerIsUnavailable()
3737
$dumper->dump($data);
3838
}
3939

40-
/**
41-
* @group transient-on-macos
42-
*/
4340
public function testDump()
4441
{
4542
$wrappedDumper = $this->createMock(DataDumperInterface::class);

src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ class ConnectionTest extends TestCase
2222
{
2323
private const VAR_DUMPER_SERVER = 'tcp://127.0.0.1:9913';
2424

25-
/**
26-
* @group transient-on-macos
27-
*/
2825
public function testDump()
2926
{
3027
$cloner = new VarCloner();

src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,6 @@ public function testTimeoutWithActiveConcurrentStream()
835835
}
836836
}
837837

838-
/**
839-
* @group transient-on-macos
840-
*/
841838
public function testTimeoutOnInitialize()
842839
{
843840
$p1 = TestHttpServer::start(8067);
@@ -871,9 +868,6 @@ public function testTimeoutOnInitialize()
871868
}
872869
}
873870

874-
/**
875-
* @group transient-on-macos
876-
*/
877871
public function testTimeoutOnDestruct()
878872
{
879873
$p1 = TestHttpServer::start(8067);

0 commit comments

Comments
 (0)