Skip to content

Add Symfony LSP diagnostics to CI - #88

Open
loevgaard wants to merge 3 commits into
2.2.xfrom
symfony-lsp-check-2.2.x
Open

Add Symfony LSP diagnostics to CI#88
loevgaard wants to merge 3 commits into
2.2.xfrom
symfony-lsp-check-2.2.x

Conversation

@loevgaard

@loevgaard loevgaard commented Sep 9, 2026

Copy link
Copy Markdown
Member

Integrates symfony lsp:check into the build workflow as a step of the coding-standards job, right after the setono/sylius-plugin/coding-standards@v2 action. It runs symfony lsp:check --format=github, so unknown routes/services/templates/translation keys, deprecated config keys etc. show up as annotations on pull requests. The Symfony CLI is downloaded from its GitHub release because the composite action does not install it; moving both into that action so every plugin gets the check would be a natural follow-up.

Repository changes needed for symfony-lsp to find and boot the test application

symfony-lsp discovers an application only if its composer.json requires symfony/framework-bundle, locates the kernel through a PSR-4 entry in that composer.json, and boots it via <project>/vendor/autoload.php. The test application is not a standalone Composer project, hence:

  • tests/Application/composer.json now declares the symfony/framework-bundle requirement and the PSR-4 namespace of the kernel. Nothing is ever installed from this file; it is only a marker (as it already was for project-dir resolving).
  • tests/Application/vendor is a symlink to the root vendor directory. PHPUnit 11 only scans tests/Unit and tests/Functional, and ECS/PHPStan/Rector do not follow symlinks, so no other tooling is affected.
  • .symfony-lsp.json points symfony-lsp at tests/Application and enables translation diagnostics.
  • CLAUDE.md documents the command.

Dependency pins needed to make the test application work at all

Two upstream releases had already broken the test application on this branch. Nothing in CI noticed, because tests/Functional is empty and no job loaded the API routes until this check. Both pins are in require-dev, so they affect only this repository and the plugins generated from it, never projects installing a plugin.

  1. symfony/type-info: <7.4.6 and symfony/property-info: ^6.4 || >=7.4 <7.4.7. type-info 7.4.6 / 8.0.6 started collecting @phpstan-template tags and rejects the Loggable|object bound that gedmo declares on AbstractLogEntry, which Sylius' AddressLogEntry extends. API Platform hits it while building identifier metadata for that resource, so loading the routes, cache:warmup and every request failed on Symfony 7.4. property-info 7.4.7+ requires type-info 7.4.7+, hence the second pin. Upstream: Incompatibility with symfony/type-info > 8.0.4 doctrine-extensions/DoctrineExtensions#3044, fix pending in Fix Loggable template bounds for Symfony TypeInfo compatibility doctrine-extensions/DoctrineExtensions#3046. Drop both pins once that ships.
  2. doctrine/orm: <3.7. ORM 3.7.0 added a schema validation (SchemaValidator should report inverseBy targeting a different entity doctrine/orm#12460) that Sylius' ShipmentUnit#shipment / Shipment#units mapping fails, which broke the doctrine:schema:validate step of every functional-tests job. Sylius already conflicts with other broken ORM patch releases, so this pin can go once Sylius handles 3.7.

Verification (local, PHP 8.4, symfony-lsp 0.20.0, Symfony packages pinned to 7.4 like CI does)

  • bin/console cache:warmup fails before the pins and succeeds after; debug:router lists 393 routes
  • doctrine:schema:validate --skip-sync: mapping files are correct
  • symfony-lsp check: runtime metadata, 0 diagnostics, exit code 0
  • composer validate --strict and composer normalize --dry-run pass

Running the check locally requires the Symfony CLI 5.20 or newer (symfony lsp:check), or the standalone symfony-lsp binary from https://github.com/symfony/language-tools/releases.

Run `symfony lsp:check` (https://symfony.com/blog/introducing-symfony-lsp-check-symfony-aware-diagnostics-in-your-ci)
as a new "symfony-diagnostics" job so that unknown routes, services,
templates, translation keys, deprecated configuration keys etc. are
reported as GitHub annotations.

symfony-lsp only discovers a Symfony application when its composer.json
requires symfony/framework-bundle and, to boot it, needs a PSR-4 entry
pointing at the kernel plus <project>/vendor/autoload.php. The test
application is not a standalone Composer project, so:

- tests/Application/composer.json declares the framework-bundle
  requirement and the PSR-4 namespace of the kernel (nothing is ever
  installed from this file)
- tests/Application/vendor is a symlink to the root vendor directory
- .symfony-lsp.json points symfony-lsp at tests/Application and enables
  translation diagnostics
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.00%. Comparing base (4f0ae67) to head (729a0e6).

Additional details and impacted files
@@            Coverage Diff            @@
##              2.2.x      #88   +/-   ##
=========================================
  Coverage     75.00%   75.00%           
  Complexity        3        3           
=========================================
  Files             3        3           
  Lines             8        8           
=========================================
  Hits              6        6           
  Misses            2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Two dependency releases broke the test application, independent of the
Symfony LSP integration. Nothing in CI noticed, because tests/Functional
is empty and no job loaded the API routes until now.

- symfony/type-info >= 7.4.6 (and >= 8.0.6) collects @phpstan-template
  tags and rejects the "Loggable|object" template bound that
  gedmo/doctrine-extensions declares on AbstractLogEntry, which Sylius'
  AddressLogEntry extends. API Platform runs into it while building the
  identifier metadata of that resource, so loading the routes, and with
  it cache:warmup and every request, fails on Symfony 7.4. Until
  doctrine-extensions/DoctrineExtensions#3046
  is released, symfony/type-info is kept below 7.4.6, which in turn
  requires symfony/property-info below 7.4.7.
  See doctrine-extensions/DoctrineExtensions#3044

- doctrine/orm 3.7.0 validates that the inverse side of an association
  targets the owning entity (doctrine/orm#12460).
  Sylius' ShipmentUnit#shipment / Shipment#units mapping does not
  satisfy that, so doctrine:schema:validate fails. doctrine/orm is kept
  below 3.7 until Sylius handles it.

Both pins live in require-dev and therefore only affect this repository
and plugins generated from it, never projects installing a plugin.
The check belongs with the other lint steps rather than in a job of its
own. The Symfony CLI is downloaded from its GitHub release because the
coding-standards composite action does not install it.
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