Skip to content

Commit 4d84436

Browse files
committed
Update dependency support
- Workaround for TreeBuilder deprecation in Symfony 4.3+ - Add psalm-baseline to circumvent deprecation warnings
1 parent 3b9de38 commit 4d84436

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"symfony/finder": "^4.0",
3030
"symfony/config": "^4.0",
3131
"squirrelphp/queries-bundle": "^0.8",
32-
"squirrelphp/entities": "^0.5"
32+
"squirrelphp/entities": "^0.5.3"
3333
},
3434
"require-dev": {
3535
"captainhook/plugin-composer": "^4.0",
@@ -56,9 +56,11 @@
5656
},
5757
"scripts": {
5858
"phpstan": "vendor/bin/phpstan analyse src --level=7",
59-
"psalm": "vendor/bin/psalm",
59+
"psalm": "vendor/bin/psalm --show-info=false",
60+
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
6061
"phpunit": "vendor/bin/phpunit --colors=always",
6162
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --ignore=tests/TestEntities,tests/TestEntities2 src tests",
63+
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --ignore=tests/TestEntities,tests/TestEntities2 src tests",
6264
"codecoverage": "vendor/bin/phpunit --coverage-html tests/_reports"
6365
}
6466
}

psalm-baseline.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="3.4.7@caf7737bbe5a5e9cbdfcc1ada83ea576ca07c9ff" php-version="php:7.3.5; bcmath:7.3.5; bz2:7.3.5; calendar:7.3.5; Core:7.3.5; ctype:7.3.5; curl:7.3.5; date:7.3.5; dom:20031129; exif:7.3.5; fileinfo:7.3.5; filter:7.3.5; ftp:7.3.5; gd:7.3.5; gettext:7.3.5; hash:7.3.5; iconv:7.3.5; imagick:3.4.4; imap:7.3.5; intl:7.3.5; json:1.7.0; libxml:7.3.5; mailparse:3.0.3; mbstring:7.3.5; mysqli:7.3.5; mysqlnd:mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $; openssl:7.3.5; pcntl:7.3.5; pcre:7.3.5; PDO:7.3.5; pdo_mysql:7.3.5; pdo_pgsql:7.3.5; pdo_sqlite:7.3.5; pgsql:7.3.5; Phar:7.3.5; posix:7.3.5; Reflection:7.3.5; session:7.3.5; SimpleXML:7.3.5; soap:7.3.5; sockets:7.3.5; SPL:7.3.5; sqlite3:7.3.5; standard:7.3.5; sysvsem:7.3.5; sysvshm:7.3.5; tokenizer:7.3.5; xml:7.3.5; xmlreader:7.3.5; xmlrpc:7.3.5; xmlwriter:7.3.5; xsl:7.3.5; Zend OPcache:7.3.5; Zend OPcache:7.3.5; zip:1.15.4; zlib:7.3.5">
3+
<file src="src/DependencyInjection/Configuration.php">
4+
<DeprecatedMethod occurrences="1">
5+
<code>root</code>
6+
</DeprecatedMethod>
7+
</file>
8+
</files>

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
66
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7+
errorBaseline="psalm-baseline.xml"
78
>
89
<projectFiles>
910
<directory name="src" />

src/DependencyInjection/Configuration.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ public function __construct(string $alias)
2222
*/
2323
public function getConfigTreeBuilder()
2424
{
25-
$treeBuilder = new TreeBuilder();
26-
$rootNode = $treeBuilder->root($this->alias);
25+
$treeBuilder = new TreeBuilder($this->alias);
26+
27+
// Symfony 4.2+ (where root() method is deprecated)
28+
if (method_exists($treeBuilder, 'getRootNode')) {
29+
$rootNode = $treeBuilder->getRootNode();
30+
} else { // Symfony 4.1 and below (where one needs to use the root() method)
31+
$rootNode = $treeBuilder->root($this->alias);
32+
}
2733

2834
/**
2935
* The only configuration options are:

src/DependencyInjection/SquirrelEntitiesExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getAlias()
8787
private function findEntitiesAndProcess(ContainerBuilder $container, ?array $config): void
8888
{
8989
// No directories defined - this is mandatory
90-
if (\count($config['directories'] ?? []) === 0) {
90+
if (!isset($config) || \count($config['directories'] ?? []) === 0) {
9191
return;
9292
}
9393

0 commit comments

Comments
 (0)