8000 Merge branch '5.3' into 5.4 · symfony/symfony@2b31f0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b31f0b

Browse files
Merge branch '5.3' into 5.4
* 5.3: fix cs Update validators.lv.xlf Fix API gateway service name Fix CS in composer.json Update validators.uz.xlf [ExpressionLanguage] Fix LexerTest number types [Process] intersect with getenv() to populate default envs Improve CI script a bit Fix Loco Provider [Cache] fix dbindex Redis Fix typos in a test message Never rely on dynamic properties
2 parents 24c8c25 + f92f7bb commit 2b31f0b

File tree

33 files changed

+139
-64
lines changed

33 files changed

+139
-64
lines changed

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
6767
SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
6868
SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+')
69-
SYMFONY_FEATURE_BRANCH=$(curl -s https://flex.symfony.com/versions.json | jq -r '."dev-name"')
69+
SYMFONY_FEATURE_BRANCH=$(curl -s https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json | jq -r '.versions."dev-name"')
7070
7171
# Install the phpunit-bridge from a PR if required
7272
#
@@ -189,8 +189,8 @@ jobs:
189189
(cd src/Symfony/Component/HttpFoundation; mv composer.bak composer.json)
190190
PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
191191
192-
# for x.4 branches, checkout and test previous major with the patched components (only for patched components)
193-
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then
192+
# for 5.4 LTS, checkout and test previous major with the patched components (only for patched components)
193+
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = 5.4 ]]; then
194194
export FLIP='^'
195195
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
196196
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ function ($definition) {
187187

188188
final class DummyClass implements DummyInterface, SunnyInterface
189189
{
190+
private $ref;
191+
190192
public function dummy()
191193
{
192194
return $this;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
->parent('notifier.transport_factory.abstract')
119119
->tag('texter.transport_factory')
120120

121-
->set('notifier.transport_factory.all-my-sms', AllMySmsTransportFactory::class)
121+
->set('notifier.transport_factory.allmysms', AllMySmsTransportFactory::class)
122122
->parent('notifier.transport_factory.abstract')
123123
->tag('texter.transport_factory')
124124

@@ -190,7 +190,7 @@
190190
->parent('notifier.transport_factory.abstract')
191191
->tag('chatter.transport_factory')
192192

193-
->set('notifier.transport_factory.gateway-api', GatewayApiTransportFactory::class)
193+
->set('notifier.transport_factory.gatewayapi', GatewayApiTransportFactory::class)
194194
->parent('notifier.transport_factory.abstract')
195195
->tag('texter.transport_factory')
196196

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ public function testIfNotifierTransportsAreKnownByFrameworkExtension()
19851985

19861986
foreach ((new Finder())->in(\dirname(__DIR__, 4).'/Component/Notifier/Bridge')->directories()->depth(0)->exclude('Mercure') as $bridgeDirectory) {
19871987
$transportFactoryName = strtolower(preg_replace('/(.)([A-Z])/', '$1-$2', $bridgeDirectory->getFilename()));
1988-
$this->assertTrue($container->hasDefinition('notifier.transport_factory.'.$transportFactoryName), sprintf('Did you forget to add the TransportFactory: "%s" to the $classToServices array in the FrameworkBundleExtension?', $bridgeDirectory->getFilename()));
1988+
F42D $this->assertTrue($container->hasDefinition('notifier.transport_factory.'.$transportFactoryName), sprintf('Did you forget to add the "%s" TransportFactory to the $classToServices array in FrameworkExtension?', $bridgeDirectory->getFilename()));
19891989
}
19901990
}
19911991

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function testInvalidCreateConnection(string $dsn)
112112
public function provideInvalidCreateConnection(): array
113113
{
114114
return [
115+
['redis://localhost/foo'],
115116
['foo://localhost'],
116117
['redis://'],
117118
];

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ public static function createConnection(string $dsn, array $options = [])
147147
}
148148

149149
if (isset($params['host']) || isset($params['path'])) {
150-
if (!isset($params['dbindex']) && isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
151-
$params['dbindex'] = $m[1];
152-
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
150+
if (!isset($params['dbindex']) && isset($params['path'])) {
151+
if (preg_match('#/(\d+)$#', $params['path'], $m)) {
152+
$params['dbindex'] = $m[1];
153+
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
154+
} else {
155+
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s", the "dbindex" parameter must be a number.', $dsn));
156+
}
153157
}
154158

155159
if (isset($params['host'])) {

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ public function testGetServiceIds()
260260
{
261261
$builder = new ContainerBuilder();
262262
$builder->register('foo', 'stdClass');
263-
$builder->bar = $bar = new \stdClass();
264263
$builder->register('bar', 'stdClass');
265264
$this->assertEquals(
266265
[

src/Symfony/Component/DependencyInjection/Tests/Fixtures/StdClassDecorator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
final class StdClassDecorator
66
{
7+
public $foo;
8+
79
public function __construct(\stdClass $foo)
810
{
911
$this->foo = $foo;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ public static function create($config)
142142

143143
class FoobarCircular
144144
{
145+
public $foo;
146+
145147
public function __construct(FooCircular $foo)
146148
{
147149
$this->foo = $foo;
@@ -150,6 +152,8 @@ public function __construct(FooCircular $foo)
150152

151153
class FooCircular
152154
{
155+
public $bar;
156+
153157
public function __construct(BarCircular $bar)
154158
{
155159
$this->bar = $bar;
@@ -158,6 +162,8 @@ public function __construct(BarCircular $bar)
158162

159163
class BarCircular
160164
{
165+
public $foobar;
166+
161167
public function addFoobar(FoobarCircular $foobar)
162168
{
163169
$this->foobar = $foobar;

src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ public function __invoke()
416416

417417
class TestEventListener
418418
{
419+
public $name;
419420
public $preFooInvoked = false;
420421
public $postFooInvoked = false;
421422

src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getTokenizeData()
7070
'"foo"',
7171
],
7272
[
73-
[new Token('number', '3', 1)],
73+
[new Token('number', 3, 1)],
7474
'3',
7575
],
7676
[
@@ -84,9 +84,9 @@ public function getTokenizeData()
8484
[
8585
[
8686
new Token('punctuation', '(', 1),
87-
new Token('number', '3', 2),
87+
new Token('number', 3, 2),
8888
new Token('operator', '+', 4),
89-
new Token('number', '5', 6),
89+
new Token('number', 5, 6),
9090
new Token('punctuation', ')', 7),
9191
new Token('operator', '~', 9),
9292
new Token('name', 'foo', 11),
@@ -96,17 +96,25 @@ public function getTokenizeData()
9696
new Token('punctuation', '.', 21),
9797
new Token('name', 'baz', 22),
9898
new Token('punctuation', '[', 25),
99-
new Token('number', '4', 26),
99+
new Token('number', 4, 26),
100100
new Token('punctuation', ']', 27),
101101
new Token('operator', '-', 29),
102-
new Token('number', '1990', 31),
102+
new Token('number', 1990, 31),
103103
],
104104
'(3 + 5) ~ foo("bar").baz[4] - 1.99E+3',
105105
],
106106
[
107107
[new Token('operator', '..', 1)],
108108
'..',
109109
],
110+
[
111+
[
112+
new Token('number', 23, 1),
113+
new Token('operator', '..', 3),
114+
new Token('number', 26, 5),
115+
],
116+
'23..26',
117+
],
110118
[
111119
[new Token('string', '#foo', 1)],
112120
"'#foo'",

src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public function getParseData()
185185
'not foo or foo.not',
186186
['foo'],
187187
],
188+
[
189+
new Node\BinaryNode('..', new Node\ConstantNode(0), new Node\ConstantNode(3)),
190+
'0..3',
191+
],
188192
];
189193
}
190194

src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(string $environment, bool $debug, bool $fakeContaine
2828

2929
public function getBundleMap()
3030
{
31-
return $this->bundleMap;
31+
return [];
3232
}
3333

3434
public function registerBundles(): iterable

src/Symfony/Component/Mime/Part/DataPart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
class DataPart extends TextPart
2222
{
23+
/** @internal */
24+
protected $_parent;
25+
2326
private static $mimeTypes;
2427

2528
private $filename;
@@ -32,6 +35,8 @@ class DataPart extends TextPart
3235
*/
3336
public function __construct($body, string $filename = null, string $contentType = null, string $encoding = null)
3437
{
38+
unset($this->_parent);
39+
3540
if (null === $contentType) {
3641
$contentType = 'application/octet-stream';
3742
}

src/Symfony/Component/Mime/Part/SMimePart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
class SMimePart extends AbstractPart
2020
{
21+
/** @internal */
22+
protected $_headers;
23+
2124
private $body;
2225
private $type;
2326
private $subtype;
@@ -28,6 +31,8 @@ class SMimePart extends AbstractPart
2831
*/
2932
public function __construct($body, string $type, string $subtype, array $parameters)
3033
{
34+
unset($this->_headers);
35+
3136
parent::__construct();
3237

3338
if (!\is_string($body) && !is_iterable($body)) {

src/Symfony/Component/Mime/Part/TextPart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
*/
2424
class TextPart extends AbstractPart
2525
{
26+
/** @internal */
27+
protected $_headers;
28+
2629
private static $encoders = [];
2730

2831
private $body;
@@ -41,6 +44,8 @@ class TextPart extends AbstractPart
4144
*/
4245
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain', string $encoding = null)
4346
{
47+
unset($this->_headers);
48+
4449
parent::__construct();
4550

4651
if (!\is_string($body) && !\is_resource($body)) {

src/Symfony/Component/Notifier/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"symfony/event-dispatcher-contracts": "^2",
2525
"symfony/http-client-contracts": "^2",
26-
"symfony/messenger": "^4.4 || ^5.0|^6.0"
26+
"symfony/messenger": "^4.4|^5.0|^6.0"
2727
},
2828
"conflict": {
2929
"symfony/http-kernel": "<4.4",

src/Symfony/Component/Process/Process.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,13 +1661,8 @@ private function replacePlaceholders(string $commandline, array $env)
16611661

16621662
private function getDefaultEnv(): array
16631663
{
1664-
$env = [];
1665-
1666-
foreach ($_SERVER as $k => $v) {
1667-
if (\is_string($v) && false !== $v = getenv($k)) {
1668-
$env[$k] = $v;
1669-
}
1670-
}
1664+
$env = getenv();
1665+
$env = array_intersect_key($env, $_SERVER) ?: $env;
16711666

16721667
foreach ($_ENV as $k => $v) {
16731668
if (\is_string($v)) {

src/Symfony/Component/Security/Core/Exception/AuthenticationException.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@
2121
*/
2222
class AuthenticationException extends RuntimeException
2323
{
24+
/** @internal */
25+
protected $serialized;
26+
2427
private $token;
2528

29+
public function __construct(string $message = '', int $code = 0, \Throwable $previous = null)
30+
{
31+
unset($this->serialized);
32+
parent::__construct($message, $code, $previous);
33+
}
34+
2635
/**
2736
* @return TokenInterface|null
2837
*/

src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
class ChildCustomUserMessageAuthenticationException extends CustomUserMessageAuthenticationException
2020
{
21+
public $childMember;
22+
2123
public function __serialize(): array
2224
{
2325
return [$this->childMember, parent::__serialize()];

src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Psr\Log\LoggerInterface;
1515
use Symfony\Component\Translation\Exception\ProviderException;
1616
use Symfony\Component\Translation\Loader\LoaderInterface;
17+
use Symfony\Component\Translation\MessageCatalogue;
1718
use Symfony\Component\Translation\Provider\ProviderInterface;
1819
use Symfony\Component\Translation\TranslatorBag;
1920
use Symfony\Component\Translation\TranslatorBagInterface;
@@ -58,7 +59,7 @@ public function write(TranslatorBagInterface $translatorBag): void
5859
}
5960

6061
foreach ($catalogue->all() as $domain => $messages) {
61-
$createdIds = $this->createAssets(array_keys($messages));
62+
$createdIds = $this->createAssets(array_keys($messages), $domain);
6263
if ($createdIds) {
6364
$this->tagsAssets($createdIds, $domain);
6465
}
@@ -115,7 +116,18 @@ public function read(array $domains, array $locales): TranslatorBag
115116
throw new ProviderException('Unable to read the Loco response: '.$responseContent, $response);
116117
}
117118

118-
$translatorBag->addCatalogue($this->loader->load($responseContent, $locale, $domain));
119+
$locoCatalogue = $this->loader->load($responseContent, $locale, $domain);
120+
$catalogue = new MessageCatalogue($locale);
121+
122+
foreach ($locoCatalogue->all($domain) as $key => $message) {
123+
if (str_starts_with($key, $domain.'__')) {
124+
$key = substr($key, \strlen($domain) + 2);
125+
}
126+
127+
$catalogue->set($key, $message, $domain);
128+
}
129+
130+
$translatorBag->addCatalogue($catalogue);
119131
}
120132

121133
return $translatorBag;
@@ -164,14 +176,14 @@ private function getAssetsIds(string $domain): array
164176
}, $response->toArray(false));
165177
}
166178

167-
private function createAssets(array $keys): array
179+
private function createAssets(array $keys, string $domain): array
168180
{
169181
$responses = $createdIds = [];
170182

171183
foreach ($keys as $key) {
172184
$responses[$key] = $this->client->request('POST', 'assets', [
173185
'body' => [
174-
'id' => $key,
186+
'id' => $domain.'__'.$key, // must be globally unique, not only per domain
175187
'text' => $key,
176188
'type' => 'text',
177189
'default' => 'untranslated',

0 commit comments

Comments
 (0)
0