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

Skip to content

Commit 1255cff

Browse files
Merge branch '6.0' into 6.1
* 6.0: [HttpClient] fix resetting DNS/etc when calling CurlHttpClient::reset() Fix invalid guess with enumType [HttpClient] Remove deprecated usage of GuzzleHttp\Promise\promise_for [HttpClient] Remove deprecated usage of `GuzzleHttp\Promise\queue` [PropertyAccess] Fix handling of uninitialized property of anonymous class [FrameworkBundle] Allow default cache pools to be overwritten by user [DependencyInjection] fix test ResolveBindingsPass remove loading of class iterable [Serializer] Fix AbstractObjectNormalizer TypeError on denormalization [FrameworkBundle] Avoid calling rtrim(null, '/') in AssetsInstallCommand Optimization of resolveEnvPlaceholders Fix incorrect format [DependencyInjection] Fix nested env var with resolve processor Allow OutputFormatter::escape() to be used for escaping URLs used in <href> allow a zero time-limit Use correct tag for ExpoTransportFactory service [DependencyInjection] Ignore argument type check in CheckTypeDeclarationsPass if it's a Definition with a factory [Validators] Add translations for Slovak #43735
2 parents 37328e3 + adc8a55 commit 1255cff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+512
-157
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,17 @@ public function getTypes(string $class, string $property, array $context = []):
135135
}
136136

137137
if ($metadata->hasField($property)) {
138+
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
139+
if (null !== $enumClass = $metadata->getFieldMapping($property)['enumType'] ?? null) {
140+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $enumClass)];
141+
}
142+
138143
$typeOfField = $metadata->getTypeOfField($property);
139144

140145
if (!$builtinType = $this->getPhpType($typeOfField)) {
141146
return null;
142147
}
143148

144-
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
145-
146149
switch ($builtinType) {
147150
case Type::BUILTIN_TYPE_OBJECT:
148151
switch ($typeOfField) {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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\Bridge\Doctrine\Tests\Fixtures;
13+
14+
use Doctrine\ORM\Mapping as ORM;
15+
16+
/**
17+
* @ORM\Entity
18+
*/
19+
class DoctrineLoaderEnum
20+
{
21+
/**
22+
* @ORM\Id
23+
* @ORM\Column
24+
*/
25+
public $id;
26+
27+
/**
28+
* @ORM\Column(type="string", enumType="Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumString", length=1)
29+
*/
30+
public $enumString;
31+
32+
/**
33+
* @ORM\Column(type="integer", enumType="Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumInt")
34+
*/
35+
public $enumInt;
36+
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
use Doctrine\Common\Collections\Collection;
1515
use Doctrine\DBAL\Types\Type as DBALType;
1616
use Doctrine\ORM\EntityManager;
17+
use Doctrine\ORM\Mapping\Column;
1718
use Doctrine\ORM\Tools\Setup;
1819
use PHPUnit\Framework\TestCase;
1920
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
2021
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy;
22+
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEnum;
2123
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineGeneratedValue;
2224
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation;
25+
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumInt;
26+
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumString;
2327
use Symfony\Component\PropertyInfo\Type;
2428

2529
/**
@@ -124,6 +128,18 @@ public function testExtractWithEmbedded()
124128
$this->assertEquals($expectedTypes, $actualTypes);
125129
}
126130

131+
/**
132+
* @requires PHP 8.1
133+
*/
134+
public function testExtractEnum()
135+
{
136+
if (!property_exists(Column::class, 'enumType')) {
137+
$this->markTestSkipped('The "enumType" requires doctrine/orm 2.11.');
138+
}
139+
$this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', []));
140+
$this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumInt', []));
141+
}
142+
127143
public function typesProvider()
128144
{
129145
$provider = [
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
use Doctrine\ORM\Mapping\Id;
15+
use Doctrine\ORM\Mapping\Column;
16+
use Doctrine\ORM\Mapping\Entity;
17+
18+
/**
19+
* @Entity
20+
*/
21+
class DoctrineEnum
22+
{
23+
/**
24+
* @Id
25+
* @Column(type="smallint")
26+
*/
27+
public $id;
28+
29+
/**
30+
* @Column(type="string", enumType="Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumString")
31+
*/
32+
protected $enumString;
33+
34+
/**
35+
* @Column(type="integer", enumType="Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumInt")
36+
*/
37+
protected $enumInt;
38+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
enum EnumInt: int
15+
{
16+
case Foo = 0;
17+
case Bar = 1;
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
enum EnumString: string
15+
{
16+
case Foo = 'f';
17+
case Bar = 'b';
18+
}

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\Validator;
1313

14+
use Doctrine\ORM\Mapping\Column;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
1617
use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser;
1718
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEmbed;
1819
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEntity;
20+
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEnum;
1921
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderNestedEmbed;
2022
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderNoAutoMappingEntity;
2123
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderParentEntity;
@@ -149,6 +151,31 @@ public function testLoadClassMetadata()
149151
$this->assertSame(AutoMappingStrategy::DISABLED, $noAutoMappingMetadata[0]->getAutoMappingStrategy());
150152
}
151153

154+
/**
155+
* @requires PHP 8.1
156+
*/
157+
public function testExtractEnum()
158+
{
159+
if (!property_exists(Column::class, 'enumType')) {
160+
$this->markTestSkipped('The "enumType" requires doctrine/orm 2.11.');
161+
}
162+
163+
$validator = Validation::createValidatorBuilder()
164+
->addMethodMapping('loadValidatorMetadata')
165+
->enableAnnotationMapping()
166+
->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}'))
167+
->getValidator()
168+
;
169+
170+
$classMetadata = $validator->getMetadataFor(new DoctrineLoaderEnum());
171+
172+
$enumStringMetadata = $classMetadata->getPropertyMetadata('enumString');
173+
$this->assertCount(0, $enumStringMetadata); // asserts the length constraint is not added to an enum
174+
175+
$enumStringMetadata = $classMetadata->getPropertyMetadata('enumInt');
176+
$this->assertCount(0, $enumStringMetadata); // asserts the length constraint is not added to an enum
177+
}
178+
152179
public function testFieldMappingsConfiguration()
153180
{
154181
$validator = Validation::createValidatorBuilder()

src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
1717
use Doctrine\Persistence\Mapping\MappingException;
1818
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
19+
use Symfony\Component\PropertyInfo\Type;
1920
use Symfony\Component\Validator\Constraints\Length;
2021
use Symfony\Component\Validator\Constraints\Valid;
2122
use Symfony\Component\Validator\Mapping\AutoMappingStrategy;
@@ -99,7 +100,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
99100
$loaded = true;
100101
}
101102

102-
if (null === ($mapping['length'] ?? null) || !\in_array($mapping['type'], ['string', 'text'], true)) {
103+
if (null === ($mapping['length'] ?? null) || null !== ($mapping['enumType'] ?? null) || !\in_array($mapping['type'], ['string', 'text'], true)) {
103104
continue;
104105
}
105106

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9494
{
9595
/** @var KernelInterface $kernel */
9696
$kernel = $this->getApplication()->getKernel();
97-
$targetArg = rtrim($input->getArgument('target'), '/');
98-
97+
$targetArg = rtrim($input->getArgument('target') ?? '', '/');
9998
if (!$targetArg) {
10099
$targetArg = $this->getPublicDirectory($kernel->getContainer());
101100
}

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

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -336,34 +336,10 @@ public function load(array $configs, ContainerBuilder $container)
336336
}
337337
}
338338

339-
// register cache before session so both can share the connection services
340-
$this->registerCacheConfiguration($config['cache'], $container);
341-
342-
if ($this->isConfigEnabled($container, $config['session'])) {
343-
if (!\extension_loaded('session')) {
344-
throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
345-
}
346-
347-
$this->sessionConfigEnabled = true;
348-
$this->registerSessionConfiguration($config['session'], $container, $loader);
349-
if (!empty($config['test'])) {
350-
// test listener will replace the existing session listener
351-
// as we are aliasing to avoid duplicated registered events
352-
$container->setAlias('session_listener', 'test.session.listener');
353-
}
354-
} elseif (!empty($config['test'])) {
355-
$container->removeDefinition('test.session.listener');
356-
}
357-
358339
if ($this->isConfigEnabled($container, $config['request'])) {
359340
$this->registerRequestConfiguration($config['request'], $container, $loader);
360341
}
361342

362-
if (null === $config['csrf_protection']['enabled']) {
363-
$config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && ContainerBuilder::willBeAvailable('symfony/security-csrf', CsrfTokenManagerInterface::class, ['symfony/framework-bundle']);
364-
}
365-
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
366-
367343
if ($this->isConfigEnabled($container, $config['form'])) {
368344
if (!class_exists(Form::class)) {
369345
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
@@ -494,6 +470,31 @@ public function load(array $configs, ContainerBuilder $container)
494470
$this->registerUidConfiguration($config['uid'], $container, $loader);
495471
}
496472

473+
// register cache before session so both can share the connection services
474+
$this->registerCacheConfiguration($config['cache'], $container);
475+
476+
if ($this->isConfigEnabled($container, $config['session'])) {
477+
if (!\extension_loaded('session')) {
478+
throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
479+
}
480+
481+
$this->sessionConfigEnabled = true;
482+
$this->registerSessionConfiguration($config['session'], $container, $loader);
483+
if (!empty($config['test'])) {
484+
// test listener will replace the existing session listener
485+
// as we are aliasing to avoid duplicated registered events
486+
$container->setAlias('session_listener', 'test.session.listener');
487+
}
488+
} elseif (!empty($config['test'])) {
489+
$container->removeDefinition('test.session.listener');
490+
}
491+
492+
// csrf depends on session being registered
493+
if (null === $config['csrf_protection']['enabled']) {
494+
$config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && ContainerBuilder::willBeAvailable('symfony/security-csrf', CsrfTokenManagerInterface::class, ['symfony/framework-bundle']);
495+
}
496+
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
497+
497498
$this->addAnnotatedClassesToCompile([
498499
'**\\Controller\\',
499500
'**\\Entity\\',

src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,6 @@
240240

241241
->set('notifier.transport_factory.expo', ExpoTransportFactory::class)
242242
->parent('notifier.transport_factory.abstract')
243-
->tag('chatter.transport_factory')
243+
->tag('texter.transport_factory')
244244
;
245245
};

src/Symfony/Component/Console/Formatter/OutputFormatter.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public function __clone()
3434
}
3535

3636
/**
37-
* Escapes "<" special char in given text.
37+
* Escapes "<" and ">" special chars in given text.
3838
*/
3939
public static function escape(string $text): string
4040
{
41-
$text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
41+
$text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
4242

4343
return self::escapeTrailingBackslash($text);
4444
}
@@ -140,9 +140,10 @@ public function formatAndWrap(?string $message, int $width)
140140
{
141141
$offset = 0;
142142
$output = '';
143-
$tagRegex = '[a-z][^<>]*+';
143+
$openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';
144+
$closeTagRegex = '[a-z][^<>]*+';
144145
$currentLineLength = 0;
145-
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE);
146+
preg_match_all("#<(($openTagRegex) | /($closeTagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE);
146147
foreach ($matches[0] as $i => $match) {
147148
$pos = $match[1];
148149
$text = $match[0];
@@ -176,11 +177,7 @@ public function formatAndWrap(?string $message, int $width)
176177

177178
$output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength);
178179

179-
if (str_contains($output, "\0")) {
180-
return strtr($output, ["\0" => '\\', '\\<' => '<']);
181-
}
182-
183-
return str_replace('\\<', '<', $output);
180+
return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
184181
}
185182

186183
public function getStyleStack(): OutputFormatterStyleStack
@@ -211,7 +208,8 @@ private function createStyleFromString(string $string): ?OutputFormatterStyleInt
211208
} elseif ('bg' == $match[0]) {
212209
$style->setBackground(strtolower($match[1]));
213210
} elseif ('href' === $match[0]) {
214-
$style->setHref($match[1]);
211+
$url = preg_replace('{\\\\([<>])}', '$1', $match[1]);
212+
$style->setHref($url);
215213
} elseif ('options' === $match[0]) {
216214
preg_match_all('([^,;]+)', strtolower($match[1]), $options);
217215
$options = array_shift($options);

src/Symfony/Component/Console/Tests/Fixtures/command_2.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
command 2 description
33

44
<comment>Usage:</comment>
5-
descriptor:command2 [options] [--] \<argument_name>
6-
descriptor:command2 -o|--option_name \<argument_name>
7-
descriptor:command2 \<argument_name>
5+
descriptor:command2 [options] [--] \<argument_name\>
6+
descriptor:command2 -o|--option_name \<argument_name\>
7+
descriptor:command2 \<argument_name\>
88

99
<comment>Arguments:</comment>
1010
<info>argument_name</info>

src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
command åèä description
33

44
<comment>Usage:</comment>
5-
descriptor:åèä [options] [--] \<argument_åèä>
6-
descriptor:åèä -o|--option_name \<argument_name>
7-
descriptor:åèä \<argument_name>
5+
descriptor:åèä [options] [--] \<argument_åèä\>
6+
descriptor:åèä -o|--option_name \<argument_name\>
7+
descriptor:åèä \<argument_name\>
88

99
<comment>Arguments:</comment>
1010
<info>argument_åèä</info>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<info>argument_name</info> argument description<comment> [default: "\<comment>style\</>"]</comment>
1+
<info>argument_name</info> argument description<comment> [default: "\<comment\>style\</\>"]</comment>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<info>-o, --option_name=OPTION_NAME</info> option description<comment> [default: "\<comment>style\</>"]</comment>
1+
<info>-o, --option_name=OPTION_NAME</info> option description<comment> [default: "\<comment\>style\</\>"]</comment>

0 commit comments

Comments
 (0)