Skip to content

Declare the dependencies the main code really uses - #72

Merged
tattali merged 2 commits into
mainfrom
check-dependencies-with-composer-dependency-analyser-main
Oct 18, 2026
Merged

tattali merged 2 commits into
mainfrom
check-dependencies-with-composer-dependency-analyser-main

Conversation

@tattali

@tattali tattali commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Stacked on #71.

Nothing checked that composer.json lists what the code uses, so a package installed only through another one could disappear in a dependency update.

shipmonk/composer-dependency-analyser (^1.8, require-dev) now runs in the CI job that lints (PHP 8.4, Symfony 8.1) and reports 0 issues. Before this change it found 2 shadow dependencies and 2 unused dependencies.

  • Now required: ext-filter (FILTER_VALIDATE_URL in the extension and the listener).
  • Removed from require: symfony/event-dispatcher. No class of the package is used (the listener is registered with kernel.event_listener tags), and symfony/http-kernel requires it anyway (^7.4|^8.0), so applications keep it.
  • Removed from require-dev: symfony/dotenv, not used anywhere.
  • Kept, with a reasoned ignore in composer-dependency-analyser.php:
    • symfony/yaml (reported unused): no class of it is referenced in PHP code, but the extension loads Resources/config/services.yaml with it at runtime.
    • symfony/var-dumper (reported shadow): DeviceDataCollector::getData() only names its Data class in the array|Data return type copied from DataCollector::$data of symfony/http-kernel, and PHP does not load a class named only in a return type.
  • .github/workflows/ci.yml is regenerated with the CI generator; it now has the full set of current-job checks (php-cs-fixer, PHPStan, dependencies, PHPUnit with coverage, Infection, SonarCloud).

Local checks (local PHPs are 8.3, 8.4 and 8.5; the 8.6 nightly is covered by CI only): PHPUnit passes (120 tests) on PHP 8.4 and 8.5 with Symfony 8.0 (v8.0.15) and 8.1 (v8.1.9) and with lowest dependencies (Symfony 8.0.0) on PHP 8.4; on PHP 8.4 with Symfony 8.1, PHPStan (0 errors), php-cs-fixer, Infection (MSI 87.43%, thresholds 87 of #71) and the dependency analyser (0 issues) pass.

The tests passing says nothing about whether they would notice a wrong
change in the code. Infection mutates src and fails the run when the
tests catch fewer mutants than today.

infection.json5 sets minMsi and minCoveredMsi to 87, the score measured
on PHP 8.4 with Symfony 8.1 (313 of 358 mutants killed, 87.43%), rounded
down. The current CI job runs it after PHPUnit; ci.yml is regenerated
with the CI generator.
Nothing checked that composer.json lists what the code uses, so a
package installed only through another one could disappear in a
dependency update.

shipmonk/composer-dependency-analyser now runs in the current CI job
and reports no issue. Before this change it found 2 shadow and 2 unused
dependencies:

- ext-filter is now required (FILTER_VALIDATE_URL).
- symfony/event-dispatcher leaves require: no class of it is used, the
  listener is registered with kernel.event_listener tags, and
  symfony/http-kernel requires it anyway.
- symfony/dotenv leaves require-dev: nothing uses it.
- symfony/yaml stays: the extension loads services.yaml with it at
  runtime, so its "unused" report is ignored with that reason.
- symfony/var-dumper is not added: its Data class is only named in the
  return type copied from DataCollector, so its "shadow" report is
  ignored with that reason.

ci.yml is regenerated with the CI generator.
@sonarqubecloud

Copy link
Copy Markdown

@tattali
tattali changed the base branch from mutation-tests-with-infection-main to main October 18, 2026 22:18
@tattali
tattali merged commit 7fc3ada into main Oct 18, 2026
8 checks passed
@tattali
tattali deleted the check-dependencies-with-composer-dependency-analyser-main branch October 18, 2026 22:19

This branch was successfully deployed

1 active deployment
main — 1319ca51 Deployed Oct 18, 2026 by tattali via PHP 8.4 - Symfony 8.0.* #99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant