Skip to content

Commit 110ff59

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: send the recipient phone number as an array [DependencyInjection] Fix ternary in AutowireCallable attribute fix test Fix CS [Messenger] Added postgres asset filter integration test [AssetMapper] fix npm version constraint conversion
2 parents a240440 + e3b80f3 commit 110ff59

File tree

5 files changed

+147
-8
lines changed

5 files changed

+147
-8
lines changed

src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static function convertNpmConstraint(string $versionConstraint): ?string
137137
if (str_contains($segment, '-') && !preg_match('/-(alpha|beta|rc)\./', $segment)) {
138138
// This is a range
139139
[$start, $end] = explode('-', $segment);
140-
$processedSegments[] = '>='.self::cleanVersionSegment(trim($start)).' <='.self::cleanVersionSegment(trim($end));
140+
$processedSegments[] = self::cleanVersionSegment(trim($start)).' - '.self::cleanVersionSegment(trim($end));
141141
} elseif (preg_match('/^~(\d+\.\d+)$/', $segment, $matches)) {
142142
// Handle the tilde when only major.minor specified
143143
$baseVersion = $matches[1];

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,26 @@ public static function getCheckVersionsTests()
261261
new PackageVersionProblem('foo', 'bar', 'some/repo', '1.5.0'),
262262
],
263263
];
264+
265+
yield 'single with range constraint but no problem' => [
266+
[
267+
self::createRemoteEntry('foo', version: '1.0'),
268+
self::createRemoteEntry('bar', version: '2.0.3'),
269+
],
270+
[
271+
'foo' => ['bar'],
272+
'bar' => [],
273+
],
274+
[
275+
[
276+
'url' => '/foo/1.0',
277+
'response' => [
278+
'dependencies' => ['bar' => '1.11 - 2'],
279+
],
280+
],
281+
],
282+
[],
283+
];
264284
}
265285

266286
/**
@@ -297,22 +317,22 @@ public static function getNpmSpecificVersionConstraints()
297317
// Hyphen Ranges
298318
yield 'hyphen range simple' => [
299319
'1.0.0 - 2.0.0',
300-
'>=1.0.0 <=2.0.0',
320+
'1.0.0 - 2.0.0',
301321
];
302322

303323
yield 'hyphen range with v prefix' => [
304324
'v1.0.0 - 2.0.0',
305-
'>=1.0.0 <=2.0.0',
325+
'1.0.0 - 2.0.0',
306326
];
307327

308328
yield 'hyphen range without patch' => [
309329
'1.0 - 2.0',
310-
'>=1.0 <=2.0',
330+
'1.0 - 2.0',
311331
];
312332

313333
yield 'hyphen range with no spaces' => [
314334
'1.0-v2.0',
315-
'>=1.0 <=2.0',
335+
'1.0 - 2.0',
316336
];
317337

318338
// .x Wildcards
@@ -386,7 +406,7 @@ public static function getNpmSpecificVersionConstraints()
386406

387407
yield 'multiple constraints with space and or operator' => [
388408
'1.2.7 || 1.2.9- v2.0.0',
389-
'1.2.7 || >=1.2.9 <=2.0.0',
409+
'1.2.7 || 1.2.9 - 2.0.0',
390410
];
391411

392412
yield 'tilde constraint with patch version no change' => [

src/Symfony/Component/DependencyInjection/Attribute/AutowireCallable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(
4242

4343
public function buildDefinition(mixed $value, ?string $type, \ReflectionParameter $parameter): Definition
4444
{
45-
return (new Definition($type = \is_string($this->lazy) ? $this->lazy : ($type ?: 'Closure')))
45+
return (new Definition($type = \is_array($this->lazy) ? current($this->lazy) : ($type ?: 'Closure')))
4646
->setFactory(['Closure', 'fromCallable'])
4747
->setArguments([\is_array($value) ? $value + [1 => '__invoke'] : $value])
4848
->setLazy($this->lazy || 'Closure' !== $type && 'callable' !== (string) $parameter->getType());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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\Messenger\Bridge\Doctrine\Tests\Transport;
13+
14+
use Doctrine\DBAL\Configuration;
15+
use Doctrine\DBAL\Connection;
16+
use Doctrine\DBAL\DriverManager;
17+
use Doctrine\DBAL\Schema\Column;
18+
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
19+
use Doctrine\DBAL\Schema\Sequence;
20+
use Doctrine\DBAL\Schema\Table;
21+
use Doctrine\DBAL\Tools\DsnParser;
22+
use Doctrine\DBAL\Types\Type;
23+
use PHPUnit\Framework\TestCase;
24+
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection;
25+
26+
/**
27+
* This test checks on a postgres connection whether the doctrine asset filter works as expected.
28+
*
29+
* @requires extension pdo_pgsql
30+
*
31+
* @group integration
32+
*/
33+
class DoctrinePostgreSqlFilterIntegrationTest extends TestCase
34+
{
35+
private Connection $driverConnection;
36+
37+
protected function setUp(): void
38+
{
39+
if (!$host = getenv('POSTGRES_HOST')) {
40+
$this->markTestSkipped('Missing POSTGRES_HOST env variable');
41+
}
42+
43+
$url = "pdo-pgsql://postgres:password@$host";
44+
$params = (new DsnParser())->parse($url);
45+
$config = new Configuration();
46+
if (class_exists(DefaultSchemaManagerFactory::class)) {
47+
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
48+
}
49+
50+
$this->driverConnection = DriverManager::getConnection($params, $config);
51+
52+
$this->createAssets();
53+
}
54+
55+
protected function tearDown(): void
56+
{
57+
$this->removeAssets();
58+
59+
$this->driverConnection->close();
60+
}
61+
62+
public function testFilterAssets()
63+
{
64+
$schemaManager = $this->driverConnection->createSchemaManager();
65+
66+
$this->assertFalse($schemaManager->tablesExist(['queue_table']));
67+
$this->assertTrue($schemaManager->tablesExist(['app_table']));
68+
$this->assertTrue($this->hasSequence('app_table_id'));
69+
70+
$connection = new PostgreSqlConnection(['table_name' => 'queue_table'], $this->driverConnection);
71+
$connection->setup();
72+
73+
$schemaManager = $this->driverConnection->createSchemaManager();
74+
75+
$this->assertTrue($schemaManager->tablesExist(['queue_table']));
76+
$this->assertTrue($schemaManager->tablesExist(['app_table']));
77+
$this->assertTrue($this->hasSequence('app_table_id'));
78+
}
79+
80+
private function createAssets(): void
81+
{
82+
$this->removeAssets();
83+
84+
$schemaManager = $this->driverConnection->createSchemaManager();
85+
$schemaManager->createTable(new Table('app_table', [new Column('id', Type::getType('integer'))]));
86+
$schemaManager->createSequence(new Sequence('app_table_id'));
87+
}
88+
89+
private function removeAssets(): void
90+
{
91+
$schemaManager = $this->driverConnection->createSchemaManager();
92+
93+
if ($schemaManager->tablesExist(['queue_table'])) {
94+
$schemaManager->dropTable('queue_table');
95+
}
96+
97+
if ($schemaManager->tablesExist(['app_table'])) {
98+
$schemaManager->dropTable('app_table');
99+
}
100+
101+
if ($this->hasSequence('app_table_id')) {
102+
$schemaManager->dropSequence('app_table_id');
103+
}
104+
}
105+
106+
private function hasSequence(string $name): bool
107+
{
108+
$schemaManager = $this->driverConnection->createSchemaManager();
109+
110+
$sequences = $schemaManager->listSequences();
111+
foreach ($sequences as $sequence) {
112+
if ($sequence->getName() === $name) {
113+
return true;
114+
}
115+
}
116+
117+
return false;
118+
}
119+
}

src/Symfony/Component/Notifier/Bridge/Clickatell/ClickatellTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function doSend(MessageInterface $message): SentMessage
6363

6464
$options = [];
6565
$options['from'] = $message->getFrom() ?: $this->from;
66-
$options['to'] = $message->getPhone();
66+
$options['to'] = [$message->getPhone()];
6767
$options['text'] = $message->getSubject();
6868

6969
$response = $this->client->request('POST', $endpoint, [

0 commit comments

Comments
 (0)