Skip to content

Commit 4e80753

Browse files
authored
Merge pull request #458 from loic425/sf8
Test with Symfony 8
2 parents 036c31a + 28938f0 commit 4e80753

9 files changed

Lines changed: 54 additions & 14 deletions

File tree

.github/workflows/test-application.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,24 @@ jobs:
3232
- sqlite
3333
dependencies:
3434
- highest
35+
symfony-version:
36+
- '*'
3537
include:
3638
- php-version: '8.0'
3739
dependencies: lowest
40+
symfony-version: '*'
3841
db: sqlite
3942
- php-version: '8.0'
4043
dependencies: lowest
44+
symfony-version: '5.*'
4145
db: mysql
4246
- php-version: '8.0'
4347
dependencies: lowest
48+
symfony-version: '5.*'
49+
db: pgsql
50+
- php-version: '8.5'
51+
dependencies: lowest
52+
symfony-version: '8.*'
4453
db: pgsql
4554

4655
services:
@@ -73,13 +82,17 @@ jobs:
7382
with:
7483
php-version: ${{ matrix.php-version }}
7584
extensions: "pdo, pdo_sqlite, pdo_mysql, mysql, pdo_pgsql"
76-
tools: 'composer:v2'
85+
tools: 'composer:v2, flex'
7786

7887
- name: PHP 8.0 simple cache
7988
# Symfony 5 is not compatible with SimpleCache 3 but does not declare a conflict. Symfony 6 can not be installed on PHP 8.0.
8089
if: ${{ '8.0' == matrix.php-version }}
8190
run: composer require psr/simple-cache "^2.0" --no-update
8291

92+
- name: Symfony version
93+
if: matrix.symfony-version != '*'
94+
run: composer config extra.symfony.require ${{ matrix.symfony-version }}
95+
8396
- name: Install dependencies with Composer
8497
uses: ramsey/composer-install@v2
8598
with:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
2.0.3
5+
-----
6+
7+
* Allow installation with Symfony 8.
8+
* Test with PHP 8.5.
9+
410
2.0.2
511
-----
612

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"ext-simplexml": "*",
3535
"psr/log": "^1 || ^2 || ^3",
3636
"phpcr/phpcr-api-tests": "2.1.25",
37-
"phpunit/phpunit": "^9.0",
38-
"symfony/cache": "^5.4 || ^6.2 || ^7.0",
37+
"phpunit/phpunit": "^9.6.16",
38+
"symfony/cache": "^5.4 || ^6.2 || ^7.0 || ^8.0",
3939
"phpstan/phpstan": "^2.0"
4040
},
4141
"autoload": {

src/Jackalope/Transport/DoctrineDBAL/Client.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public function __construct(FactoryInterface $factory, Connection $conn)
166166
*/
167167
private function registerSqliteFunctions(\PDO $sqliteConnection): void
168168
{
169-
$sqliteConnection->sqliteCreateFunction(
169+
$this->sqliteCreateFunction(
170+
$sqliteConnection,
170171
'EXTRACTVALUE',
171172
function ($string, $expression) {
172173
if (null === $string) {
@@ -208,14 +209,29 @@ function ($string, $expression) {
208209
2
209210
);
210211

211-
$sqliteConnection->sqliteCreateFunction(
212+
$this->sqliteCreateFunction(
213+
$sqliteConnection,
212214
'CONCAT',
213215
function () {
214216
return implode('', func_get_args());
215217
}
216218
);
217219
}
218220

221+
/**
222+
* BC hack for PHP < 8.4. After that version we always talk with a \Pdo\Sqlite object.
223+
*/
224+
private function sqliteCreateFunction(\PDO $sqliteConnection, string $name, callable $function, int $numArgs = -1): void
225+
{
226+
if (class_exists(\Pdo\Sqlite::class) && $sqliteConnection instanceof \Pdo\Sqlite) {
227+
$sqliteConnection->createFunction($name, $function, $numArgs);
228+
229+
return;
230+
}
231+
232+
$sqliteConnection->sqliteCreateFunction($name, $function, $numArgs);
233+
}
234+
219235
public function getConnection(): Connection
220236
{
221237
$this->initConnection();

src/Jackalope/Transport/DoctrineDBAL/XmlParser/XmlToPropsParser.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public function parse(): \stdClass
6060
\xml_set_character_data_handler($parser, [$this, 'dataHandler']);
6161

6262
\xml_parse($parser, $this->xml, true);
63-
\xml_parser_free($parser);
64-
// avoid memory leaks and unset the parser see: https://www.php.net/manual/de/function.xml-parser-free.php
65-
unset($parser);
6663

6764
return $this->data;
6865
}

src/Jackalope/Transport/DoctrineDBAL/XmlPropsRemover/XmlPropsRemover.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ public function removeProps(): array
7575
\xml_set_character_data_handler($parser, [$this, 'dataHandler']);
7676

7777
\xml_parse($parser, $this->xml, true);
78-
\xml_parser_free($parser);
79-
// avoid memory leaks and unset the parser see: https://www.php.net/manual/de/function.xml-parser-free.php
80-
unset($parser);
8178

8279
return [
8380
$this->newXml.PHP_EOL,

tests/Tools/Console/InitDoctrineDbalCommandTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ public function setUp(): void
7979
$this->application->setHelperSet($this->helperSet);
8080

8181
$command = new InitDoctrineDbalCommand();
82-
$this->application->add($command);
82+
83+
if (method_exists($this->application, 'addCommand')) {
84+
$this->application->addCommand($command);
85+
} else {
86+
$this->application->add($command);
87+
}
8388
}
8489

8590
/**

tests/Transport/DoctrineDBAL/CachedClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public function testDefaultKeySanitizer(): void
4747
$client = $this->getClient($this->getConnection());
4848
$reflection = new \ReflectionClass($client);
4949
$keySanitizerProperty = $reflection->getProperty('keySanitizer');
50-
$keySanitizerProperty->setAccessible(true);
50+
// remove when we drop PHP 8.0 support
51+
if (PHP_VERSION_ID < 80100) {
52+
$keySanitizerProperty->setAccessible(true);
53+
}
5154
$defaultKeySanitizer = $keySanitizerProperty->getValue($client);
5255

5356
$result = $defaultKeySanitizer(' :{}().@/"\\'); // not allowed PSR16 keys

tests/Transport/DoctrineDBAL/ClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ public function testUuid(): void
341341
{
342342
$class = new \ReflectionClass(Client::class);
343343
$method = $class->getMethod('generateUuid');
344-
$method->setAccessible(true);
344+
// remove when we drop PHP 8.0 support
345+
if (PHP_VERSION_ID < 80100) {
346+
$method->setAccessible(true);
347+
}
345348

346349
self::assertIsString($method->invoke($this->transport));
347350

0 commit comments

Comments
 (0)