Skip to content

Commit 7529d13

Browse files
Merge branch '3.4' into 4.4
* 3.4: [Filesystem] fix for PHP 8
2 parents 911e120 + a432444 commit 7529d13

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,13 @@ public function isAbsolutePath($file)
597597
@trigger_error(sprintf('Calling "%s()" with a null in the $file argument is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED);
598598
}
599599

600-
return strspn($file, '/\\', 0, 1)
600+
return '' !== (string) $file && (strspn($file, '/\\', 0, 1)
601601
|| (\strlen($file) > 3 && ctype_alpha($file[0])
602602
&& ':' === $file[1]
603603
&& strspn($file, '/\\', 2, 1)
604604
)
605605
|| null !== parse_url($file, \PHP_URL_SCHEME)
606-
;
606+
);
607607
}
608608

609609
/**

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Doctrine\DBAL\Connection;
1515
use Doctrine\DBAL\DBALException;
16-
use Doctrine\DBAL\Driver\Result;
1716
use Doctrine\DBAL\DriverManager;
1817
use Doctrine\DBAL\Exception;
1918
use Doctrine\DBAL\Schema\Schema;
@@ -173,7 +172,7 @@ public function putOffExpiration(Key $key, $ttl)
173172
$result = $stmt->execute();
174173

175174
// If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner
176-
if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this->exists($key)) {
175+
if (!(\is_object($result) ? $result : $stmt)->rowCount() && !$this->exists($key)) {
177176
throw new LockConflictedException();
178177
}
179178

@@ -205,7 +204,7 @@ public function exists(Key $key)
205204
$stmt->bindValue(':token', $this->getUniqueToken($key));
206205
$result = $stmt->execute();
207206

208-
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn());
207+
return (bool) (\is_object($result) ? $result->fetchOne() : $stmt->fetchColumn());
209208
}
210209

211210
/**

src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
namespace Symfony\Component\Messenger\Tests\Transport\Doctrine;
1313

14-
use Doctrine\DBAL\Abstraction\Result;
14+
use Doctrine\DBAL\Abstraction\Result as AbstractionResult;
1515
use Doctrine\DBAL\DBALException;
1616
use Doctrine\DBAL\Exception;
1717
use Doctrine\DBAL\Platforms\AbstractPlatform;
1818
use Doctrine\DBAL\Query\QueryBuilder;
19+
use Doctrine\DBAL\Result;
1920
use Doctrine\DBAL\Schema\AbstractSchemaManager;
2021
use Doctrine\DBAL\Schema\SchemaConfig;
2122
use Doctrine\DBAL\Statement;
@@ -153,10 +154,10 @@ private function getQueryBuilderMock()
153154

154155
private function getResultMock($expectedResult)
155156
{
156-
$stmt = $this->createMock(interface_exists(Result::class) ? Result::class : Statement::class);
157+
$stmt = $this->createMock(class_exists(Result::class) ? Result::class : (interface_exists(AbstractionResult::class) ? AbstractionResult::class : Statement::class));
157158

158159
$stmt->expects($this->once())
159-
->method(interface_exists(Result::class) ? 'fetchAssociative' : 'fetch')
160+
->method(interface_exists(AbstractionResult::class) || class_exists(Result::class) ? 'fetchAssociative' : 'fetch')
160161
->willReturn($expectedResult);
161162

162163
return $stmt;
@@ -309,9 +310,9 @@ public function testFindAll()
309310
'headers' => json_encode(['type' => DummyMessage::class]),
310311
];
311312

312-
$stmt = $this->createMock(interface_exists(Result::class) ? Result::class : Statement::class);
313+
$stmt = $this->createMock(class_exists(Result::class) ? Result::class : (interface_exists(AbstractionResult::class) ? AbstractionResult::class : Statement::class));
313314
$stmt->expects($this->once())
314-
->method(interface_exists(Result::class) ? 'fetchAllAssociative' : 'fetchAll')
315+
->method(interface_exists(AbstractionResult::class) || class_exists(Result::class) ? 'fetchAllAssociative' : 'fetchAll')
315316
->willReturn([$message1, $message2]);
316317

317318
$driverConnection

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
namespace Symfony\Component\Messenger\Tests\Transport\Doctrine;
1313

14-
use Doctrine\DBAL\Driver\Result;
14+
use Doctrine\DBAL\Driver\Result as DriverResult;
1515
use Doctrine\DBAL\DriverManager;
16+
use Doctrine\DBAL\Result;
1617
use Doctrine\DBAL\Version;
1718
use PHPUnit\Framework\TestCase;
1819
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
@@ -72,7 +73,7 @@ public function testSendWithDelay()
7273
->setParameter(':body', '{"message": "Hi i am delayed"}')
7374
->execute();
7475

75-
$available_at = new \DateTime($stmt instanceof Result ? $stmt->fetchOne() : $stmt->fetchColumn());
76+
$available_at = new \DateTime($stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchOne() : $stmt->fetchColumn());
7677

7778
$now = new \DateTime();
7879
$now->modify('+60 seconds');

src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
use Doctrine\DBAL\Connection as DBALConnection;
1515
use Doctrine\DBAL\DBALException;
16-
use Doctrine\DBAL\Driver\Result;
16+
use Doctrine\DBAL\Driver\Result as DriverResult;
1717
use Doctrine\DBAL\Exception;
1818
use Doctrine\DBAL\Exception\TableNotFoundException;
1919
use Doctrine\DBAL\Query\QueryBuilder;
20+
use Doctrine\DBAL\Result;
2021
use Doctrine\DBAL\Schema\Comparator;
2122
use Doctrine\DBAL\Schema\Schema;
2223
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
@@ -166,7 +167,7 @@ public function get(): ?array
166167
$query->getParameters(),
167168
$query->getParameterTypes()
168169
);
169-
$doctrineEnvelope = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch();
170+
$doctrineEnvelope = $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchAssociative() : $stmt->fetch();
170171

171172
if (false === $doctrineEnvelope) {
172173
$this->driverConnection->commit();
@@ -254,7 +255,7 @@ public function getMessageCount(): int
254255

255256
$stmt = $this->executeQuery($queryBuilder->getSQL(), $queryBuilder->getParameters(), $queryBuilder->getParameterTypes());
256257

257-
return $stmt instanceof Result ? $stmt->fetchOne() : $stmt->fetchColumn();
258+
return $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchOne() : $stmt->fetchColumn();
258259
}
259260

260261
public function findAll(int $limit = null): array
@@ -265,7 +266,7 @@ public function findAll(int $limit = null): array
265266
}
266267

267268
$stmt = $this->executeQuery($queryBuilder->getSQL(), $queryBuilder->getParameters(), $queryBuilder->getParameterTypes());
268-
$data = $stmt instanceof Result ? $stmt->fetchAllAssociative() : $stmt->fetchAll();
269+
$data = $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchAllAssociative() : $stmt->fetchAll();
269270

270271
return array_map(function ($doctrineEnvelope) {
271272
return $this->decodeEnvelopeHeaders($doctrineEnvelope);
@@ -278,7 +279,7 @@ public function find($id): ?array
278279
->where('m.id = ?');
279280

280281
$stmt = $this->executeQuery($queryBuilder->getSQL(), [$id]);
281-
$data = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch();
282+
$data = $stmt instanceof Result || $stmt instanceof DriverResult ? $stmt->fetchAssociative() : $stmt->fetch();
282283

283284
return false === $data ? null : $this->decodeEnvelopeHeaders($data);
284285
}

0 commit comments

Comments
 (0)