Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f1e9aa

Browse filesBrowse files
committed
Merge branch '6.4' into 7.0
* 6.4: (29 commits) fix tests add missing method fix merge fix test fix merge fix test change test to use a real ObjectManager [Mailer] Document the usage of custom headers in Infobip bridge [SecurityBundle] Add `provider` XML attribute to the authenticators it’s missing from [DoctrineBridge] Test reset with a true manager Sync php-cs-fixer config file with 7.2 [HttpClient] Fix parsing SSE [Notifier] Fix thread key in GoogleChat bridge [HttpKernel][Security] Fix accessing session for stateless request [Serializer] Fix `ObjectNormalizer` with property path test handling of special "value" constraint option [PhpUnitBridge] Add missing import [FrameworkBundle] Fix setting default context for certain normalizers [57251] Missing translations for Romanian (ro) [ErrorHandler] Fix rendered exception code highlighting on PHP 8.3 ...
2 parents 110ff59 + 5fe9ba0 commit 1f1e9aa
Copy full SHA for 1f1e9aa

File tree

Expand file treeCollapse file tree

54 files changed

+591
-246
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

54 files changed

+591
-246
lines changed

‎.php-cs-fixer.dist.php

Copy file name to clipboardExpand all lines: .php-cs-fixer.dist.php
+8-12Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@
2929
'@Symfony' => true,
3030
'@Symfony:risky' => true,
3131
'protected_to_private' => false,
32-
'native_constant_invocation' => ['strict' => false],
3332
'no_superfluous_phpdoc_tags' => [
3433
'remove_inheritdoc' => true,
3534
'allow_unused_params' => true, // for future-ready params, to be replaced with https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7377
3635
],
37-
'nullable_type_declaration_for_default_null_value' => true,
3836
'header_comment' => ['header' => $fileHeaderComment],
37+
// TODO: Remove once the "compiler_optimized" set includes "sprintf"
38+
'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'namespaced', 'strict' => true],
39+
'nullable_type_declaration' => true,
40+
'nullable_type_declaration_for_default_null_value' => true,
3941
'modernize_strpos' => true,
4042
'get_class_to_class_keyword' => true,
41-
'nullable_type_declaration' => true,
4243
])
4344
->setRiskyAllowed(true)
4445
->setFinder(
@@ -47,11 +48,6 @@
4748
->append([__FILE__])
4849
->notPath('#/Fixtures/#')
4950
->exclude([
50-
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
51-
// fixture templates
52-
'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom',
53-
// resource templates
54-
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
5551
// explicit trigger_error tests
5652
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
5753
'Symfony/Component/Intl/Resources/data/',
@@ -65,10 +61,6 @@
6561
->notPath('#Symfony/Bridge/PhpUnit/.*Legacy#')
6662
// file content autogenerated by `var_export`
6763
->notPath('Symfony/Component/Translation/Tests/Fixtures/resources.php')
68-
// file content autogenerated by `VarExporter::export`
69-
->notPath('Symfony/Component/Serializer/Tests/Fixtures/serializer.class.metadata.php')
70-
// test template
71-
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
7264
// explicit trigger_error tests
7365
->notPath('Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php')
7466
// stop removing spaces on the end of the line in strings
@@ -79,6 +71,10 @@
7971
->notPath('Symfony/Component/Cache/Traits/Redis6Proxy.php')
8072
->notPath('Symfony/Component/Cache/Traits/RedisCluster5Proxy.php')
8173
->notPath('Symfony/Component/Cache/Traits/RedisCluster6Proxy.php')
74+
// svg
75+
->notPath('Symfony/Component/ErrorHandler/Resources/assets/images/symfony-ghost.svg.php')
76+
// HTML templates
77+
->notPath('#Symfony/.*\.html\.php#')
8278
)
8379
->setCacheFile('.php-cs-fixer.cache')
8480
;
+69Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
4+
5+
use Doctrine\Persistence\Mapping\ClassMetadata;
6+
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
7+
use Doctrine\Persistence\ObjectManager;
8+
use Doctrine\Persistence\ObjectRepository;
9+
10+
class DummyManager implements ObjectManager
11+
{
12+
public $bar;
13+
14+
public function find($className, $id): ?object
15+
{
16+
}
17+
18+
public function persist($object): void
19+
{
20+
}
21+
22+
public function remove($object): void
23+
{
24+
}
25+
26+
public function merge($object)
27+
{
28+
}
29+
30+
public function clear($objectName = null): void
31+
{
32+
}
33+
34+
public function detach($object): void
35+
{
36+
}
37+
38+
public function refresh($object): void
39+
{
40+
}
41+
42+
public function flush(): void
43+
{
44+
}
45+
46+
public function getRepository($className): ObjectRepository
47+
{
48+
}
49+
50+
public function getClassMetadata($className): ClassMetadata
51+
{
52+
}
53+
54+
public function getMetadataFactory(): ClassMetadataFactory
55+
{
56+
}
57+
58+
public function initializeObject($obj): void
59+
{
60+
}
61+
62+
public function contains($object): bool
63+
{
64+
}
65+
66+
public function isUninitializedObject($value): bool
67+
{
68+
}
69+
}

‎src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests;
1313

14+
use Doctrine\Persistence\ObjectManager;
1415
use PHPUnit\Framework\TestCase;
16+
use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager;
1517
use Symfony\Component\DependencyInjection\ContainerBuilder;
1618
use Symfony\Component\DependencyInjection\ContainerInterface;
1719
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
@@ -24,8 +26,8 @@ public static function setUpBeforeClass(): void
2426
{
2527
$container = new ContainerBuilder();
2628

27-
$container->register('foo', \stdClass::class)->setPublic(true);
28-
$container->getDefinition('foo')->setLazy(true)->addTag('proxy', ['interface' => \stdClass::class]);
29+
$container->register('foo', DummyManager::class)->setPublic(true);
30+
$container->getDefinition('foo')->setLazy(true)->addTag('proxy', ['interface' => ObjectManager::class]);
2931
$container->compile();
3032

3133
$dumper = new PhpDumper($container);
@@ -46,8 +48,8 @@ public function testResetService()
4648
$registry->resetManager();
4749

4850
$this->assertSame($foo, $container->get('foo'));
49-
$this->assertInstanceOf(\stdClass::class, $foo);
50-
$this->assertFalse(property_exists($foo, 'bar'));
51+
$this->assertInstanceOf(ObjectManager::class, $foo);
52+
$this->assertFalse(isset($foo->bar));
5153
}
5254

5355
/**
@@ -79,7 +81,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
7981

8082
$service = $container->get('foo');
8183

82-
self::assertInstanceOf(\stdClass::class, $service);
84+
self::assertInstanceOf(ObjectManager::class, $service);
8385
self::assertInstanceOf(LazyObjectInterface::class, $service);
8486
self::assertFalse($service->isLazyObjectInitialized());
8587

@@ -92,7 +94,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
9294
$service->initializeLazyObject();
9395

9496
$wrappedValue = $service->initializeLazyObject();
95-
self::assertInstanceOf(\stdClass::class, $wrappedValue);
97+
self::assertInstanceOf(DummyManager::class, $wrappedValue);
9698
self::assertNotInstanceOf(LazyObjectInterface::class, $wrappedValue);
9799
}
98100

@@ -104,10 +106,10 @@ private function dumpLazyServiceDoctrineBridgeContainerAsFiles()
104106

105107
$container = new ContainerBuilder();
106108

107-
$container->register('foo', \stdClass::class)
109+
$container->register('foo', DummyManager::class)
108110
->setPublic(true)
109111
->setLazy(true)
110-
->addTag('proxy', ['interface' => \stdClass::class]);
112+
->addTag('proxy', ['interface' => ObjectManager::class]);
111113
$container->compile();
112114

113115
$fileSystem = new Filesystem();

‎src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public function testAttributeWithGroupsAndPaylod()
6060
self::assertSame('some attached data', $constraint->payload);
6161
self::assertSame(['some_group'], $constraint->groups);
6262
}
63+
64+
public function testValueOptionConfiguresFields()
65+
{
66+
$constraint = new UniqueEntity(['value' => 'email']);
67+
68+
$this->assertSame('email', $constraint->fields);
69+
}
6370
}
6471

6572
#[UniqueEntity(['email'], message: 'myMessage')]

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\PhpUnit;
1313

14+
use PHPUnit\Framework\TestCase;
1415
use PHPUnit\Framework\TestResult;
1516
use PHPUnit\Runner\ErrorHandler;
1617
use PHPUnit\Util\Error\Handler;

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,18 +1917,20 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
19171917
}
19181918

19191919
$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
1920-
$context = [];
1920+
$context = $arguments[6] ?? $defaultContext;
19211921

19221922
if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
1923-
$context += ($arguments[6] ?? $defaultContext) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
1923+
$context += ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
19241924
$container->getDefinition('serializer.normalizer.object')->setArgument(5, null);
19251925
}
19261926

19271927
if ($config['max_depth_handler'] ?? false) {
1928-
$context += ($arguments[6] ?? $defaultContext) + ['max_depth_handler' => new Reference($config['max_depth_handler'])];
1928+
$context += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
19291929
}
19301930

19311931
$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
1932+
1933+
$container->getDefinition('serializer.normalizer.property')->setArgument(5, $defaultContext);
19321934
}
19331935

19341936
private function registerPropertyInfoConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@
140140
service('property_info')->ignoreOnInvalid(),
141141
service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(),
142142
null,
143-
[],
144143
])
145144

146145
->set('serializer.denormalizer.array', ArrayDenormalizer::class)

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected static function getKernelClass(): string
5353

5454
protected static function createKernel(array $options = []): KernelInterface
5555
{
56-
$class = self::getKernelClass();
56+
$class = static::getKernelClass();
5757

5858
if (!isset($options['test_case'])) {
5959
throw new \InvalidArgumentException('The option "test_case" must be set.');

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php
+47-25Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

1414
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\TranslatableBackedEnum;
15+
use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel;
16+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1518

1619
/**
1720
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -35,39 +38,58 @@ public function testDeserializeArrayOfObject()
3538
$this->assertEquals($expected, $result);
3639
}
3740

38-
/**
39-
* @dataProvider provideNormalizersAndEncodersWithDefaultContextOption
40-
*/
41-
public function testNormalizersAndEncodersUseDefaultContextConfigOption(string $normalizerId)
41+
public function testNormalizersAndEncodersUseDefaultContextConfigOption()
4242
{
43-
static::bootKernel(['test_case' => 'Serializer']);
43+
/** @var SerializerKernel $kernel */
44+
$kernel = static::bootKernel(['test_case' => 'Serializer', 'root_config' => 'default_context.yaml']);
45+
46+
foreach ($kernel->normalizersAndEncoders as $normalizerOrEncoderId) {
47+
if (!static::getContainer()->has($normalizerOrEncoderId)) {
48+
continue;
49+
}
50+
51+
$normalizerOrEncoder = static::getContainer()->get($normalizerOrEncoderId);
4452

45-
$normalizer = static::getContainer()->get($normalizerId);
53+
$reflectionObject = new \ReflectionObject($normalizerOrEncoder);
54+
$property = $reflectionObject->getProperty('defaultContext');
4655

47-
$reflectionObject = new \ReflectionObject($normalizer);
48-
$property = $reflectionObject->getProperty('defaultContext');
56+
$defaultContext = $property->getValue($normalizerOrEncoder);
4957

50-
$defaultContext = $property->getValue($normalizer);
58+
self::assertArrayHasKey('fake_context_option', $defaultContext);
59+
self::assertEquals('foo', $defaultContext['fake_context_option']);
60+
}
61+
}
5162

52-
self::assertArrayHasKey('fake_context_option', $defaultContext);
53-
self::assertEquals('foo', $defaultContext['fake_context_option']);
63+
protected static function getKernelClass(): string
64+
{
65+
return SerializerKernel::class;
5466
}
67+
}
68+
69+
class SerializerKernel extends AppKernel implements CompilerPassInterface
70+
{
71+
public $normalizersAndEncoders = [
72+
'serializer.normalizer.property.alias', // Special case as this normalizer isn't tagged
73+
];
5574

56-
public static function provideNormalizersAndEncodersWithDefaultContextOption(): array
75+
public function process(ContainerBuilder $container): void
5776
{
58-
return [
59-
['serializer.normalizer.constraint_violation_list.alias'],
60-
['serializer.normalizer.dateinterval.alias'],
61-
['serializer.normalizer.datetime.alias'],
62-
['serializer.normalizer.json_serializable.alias'],
63-
['serializer.normalizer.problem.alias'],
64-
['serializer.normalizer.uid.alias'],
65-
['serializer.normalizer.translatable.alias'],
66-
['serializer.normalizer.object.alias'],
67-
['serializer.encoder.xml.alias'],
68-
['serializer.encoder.yaml.alias'],
69-
['serializer.encoder.csv.alias'],
70-
];
77+
$services = array_merge(
78+
$container->findTaggedServiceIds('serializer.normalizer'),
79+
$container->findTaggedServiceIds('serializer.encoder')
80+
);
81+
foreach ($services as $serviceId => $attributes) {
82+
$class = $container->getDefinition($serviceId)->getClass();
83+
if (null === $reflectionConstructor = (new \ReflectionClass($class))->getConstructor()) {
84+
continue;
85+
}
86+
foreach ($reflectionConstructor->getParameters() as $reflectionParam) {
87+
if ('array $defaultContext' === $reflectionParam->getType()->getName().' $'.$reflectionParam->getName()) {
88+
$this->normalizersAndEncoders[] = $serviceId.'.alias';
89+
break;
90+
}
91+
}
92+
}
7193
}
7294

7395
public function testSerializeTranslatableBackedEnum()

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public function __construct($varDir, $testCase, $rootConfig, $environment, $debu
4949
parent::__construct($environment, $debug);
5050
}
5151

52+
protected function getContainerClass(): string
53+
{
54+
return parent::getContainerClass().substr(md5($this->rootConfig), -16);
55+
}
56+
5257
public function registerBundles(): iterable
5358
{
5459
if (!file_exists($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.