Skip to content

Commit

Permalink
Update CDA, guard ext-simplexml (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored Dec 30, 2024
1 parent ba0e2fc commit a609311
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

return (new Configuration())
->ignoreErrorsOnPath(__DIR__ . '/src/Provider', [ErrorType::DEV_DEPENDENCY_IN_PROD]) // providers are designed that way
->ignoreErrorsOnExtensionAndPath('ext-simplexml', __DIR__ . '/src/Provider/SymfonyUsageProvider.php', [ErrorType::SHADOW_DEPENDENCY]) // guarded with extension_loaded()
->addPathToExclude(__DIR__ . '/tests/Rule/data');
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"phpstan/phpstan-strict-rules": "^2.0.0",
"phpstan/phpstan-symfony": "^2.0.0",
"phpunit/phpunit": "^9.6.21",
"shipmonk/composer-dependency-analyser": "^1.6",
"shipmonk/composer-dependency-analyser": "^1.8.1",
"shipmonk/name-collision-detector": "^2.0.0",
"shipmonk/phpstan-rules": "^4.0.0",
"slevomat/coding-standard": "^8.15.0",
Expand Down
32 changes: 16 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Provider/SymfonyUsageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use function array_keys;
use function count;
use function explode;
use function extension_loaded;
use function file_get_contents;
use function in_array;
use function is_dir;
Expand Down Expand Up @@ -233,6 +234,10 @@ protected function fillDicClasses(string $containerXmlPath): void
throw new LogicException(sprintf('Container %s does not exist', $containerXmlPath));
}

if (!extension_loaded('simplexml')) { // should never happen as phpstan-doctrine requires that
throw new LogicException('Extension simplexml is required to parse DIC xml');
}

$xml = @simplexml_load_string($fileContents);

if ($xml === false) {
Expand Down

0 comments on commit a609311

Please sign in to comment.