symfony/contracts
56.8
Adequate · 19 September 2026
1.7k
lines of production code
PHP
primary language
1
measurement over time
What this system is
This system is a collection of PHP interfaces and base classes that define stable, versioned contracts for core Symfony components, including caching, event dispatching, HTTP client operations, service location, and translation. It provides standardized abstractions for these functionalities, allowing developers to depend on decoupled APIs rather than concrete implementations. The system also includes infrastructure for testing these contracts and managing deprecations, ensuring consistent behavior across different Symfony packages.
How it got here
2018 — Symfony Contracts v3.8 modernization
7 changes.
This period focused on updating the Symfony Contracts package to version 3.8, raising the minimum PHP requirement to 8.1 and consolidating various sub-packages into a unified distribution. Significant features included the introduction of new service and cache contracts with advanced capabilities like stampede protection and tag invalidation, alongside the extraction of standalone translation contracts. The work also involved modernizing service location mechanisms to support PHP 8.4 features and expanding test coverage for these new interfaces.
2019–2020 — Introduction of component contracts
9 changes.
This period focused on extracting standalone contract interfaces for key Symfony components, including HttpClient, EventDispatcher, and Service, to enable dependency on abstractions rather than concrete implementations. The work established standardized APIs for HTTP client operations and exception handling, alongside new PHP 8 attributes for service dependency injection. Comprehensive test infrastructure and fixture servers were also introduced to validate these new contracts and ensure consistent behavior across implementations.
Features
Extracted Translation contracts and added locale-aware pluralization support
The Translation component now exposes a set of standalone contracts (interfaces and traits) that define the core translation API, including \TranslatorInterface\, \LocaleAwareInterface\, and \TranslatableInterface\. This change decouples the translation contracts from the main Symfony components, allowing them to be used independently. For users, this means the \trans\ method now supports pluralization rules based on the locale, with specific handling for edge cases like \en\_US\_POSIX\. The \TranslatorTrait\ provides a default implementation that handles plural form selection using ICU-style rules, ensuring consistent behavior across different locales.
Translation · high confidence
Introduce HttpClient contracts for HTTP client abstractions
This release adds the HttpClient contracts, providing a standardized interface for HTTP clients. The new \HttpClientInterface\ defines the \request()\ and \stream()\ methods, along with a comprehensive set of request options including authentication (basic and bearer), JSON body handling, timeouts, TLS configuration, and proxy settings. The \ResponseInterface\ specifies methods for retrieving status codes, headers, content, and JSON-decoded arrays, while also introducing a \cancel()\ method to abort requests and a \getInfo()\ method to access transport-layer details. Additionally, the \ChunkInterface\ and \ResponseStreamInterface\ support streaming responses by yielding chunks of data as they arrive.
HttpClient · high confidence
Introduce HttpClient exception contracts
This change introduces a new set of exception interfaces in the \Symfony\\Contracts\\HttpClient\\Exception\ namespace, defining a structured hierarchy for HTTP client errors. The diff adds \ExceptionInterface\ as the base, \HttpExceptionInterface\ (which provides a \getResponse()\ method), and specific interfaces for \ClientExceptionInterface\ (4xx), \ServerExceptionInterface\ (5xx), \RedirectionExceptionInterface\ (3xx), \TransportExceptionInterface\ (transport errors), \TimeoutExceptionInterface\ (idle timeouts), and \DecodingExceptionInterface\ (content-type decoding failures). This provides a standardized contract for handling and catching specific HTTP error scenarios.
HttpClient/Exception · high confidence
Introduction of EventDispatcher contract interfaces and base classes
The EventDispatcher component now exposes a set of standalone contracts (interfaces and base classes) in the Symfony Contracts namespace, allowing developers to depend on abstractions rather than concrete implementations. This includes the EventDispatcherInterface, which extends PSR-14 and defines the dispatch method, the ListenerIntrospectionInterface for inspecting registered listeners and priorities, and the base Event class implementing StoppableEventInterface. These contracts provide a stable, versioned API layer that can be used independently of the full Symfony framework.
EventDispatcher · high confidence
New Cache contracts with stampede protection, tag invalidation, and namespace support
The Cache contracts now provide an extended caching API built on top of PSR-6. Users can use CacheInterface::get() with a callback that supports stampede protection via a probabilistic early-expiration beta parameter, and can optionally skip saving the computed value by setting a $save flag. ItemInterface adds metadata access (expiry, creation time, tags) and reserved character constants. TagAwareCacheInterface introduces invalidateTags() for tag-based invalidation, and NamespacedPoolInterface allows creating sub-namespaced pools via withSubNamespace() for namespace-based invalidation.
Cache · high confidence
Behavioural changes
Introduce generic trigger\_deprecation() function
The Deprecation contract now provides a global \trigger\_deprecation()\ function, replacing the previous use of \assert()\ for triggering deprecation notices. This function accepts the package name, version, and a message (with optional printf-style arguments) to generate silenced \E\_USER\_DEPRECATED\ errors, allowing developers to catch and log deprecations via custom error handlers or ignore them by defining an empty function.
Deprecation · high confidence
New PHP 8 attributes for service dependency injection
The Service contracts now include \#\[Required\] and \#\[SubscribedService\] attributes to replace legacy traits and interfaces for declaring dependencies. The \#\[Required\] attribute marks properties or methods as mandatory dependencies and supports a priority argument to control execution order when multiple methods are involved. The \#\[SubscribedService\] attribute allows developers to define subscribed services directly on methods or properties, specifying the service key, type, nullability, and additional DI attributes, facilitating a more modern, attribute-based approach to service subscription.
Service/Attribute · high confidence
Service contracts introduce new interfaces and traits for service location and subscription
The Service contracts package now includes \ContainerProviderInterface\ (with a deprecated \ContainerAwareInterface\ alias) to expose service containers, \ServiceProviderInterface\ to declare provided service types, and \ServiceCollectionInterface\ for countable/iterable service providers. The \ServiceLocatorTrait\ has been rewritten to use constructor property promotion and improved type reflection for \getProvidedServices()\. The old \ServiceSubscriberTrait\ is deprecated in favor of \ServiceMethodsSubscriberTrait\, which extends service subscription to support PHP 8.4 property hooks and stricter type checking. \ResetInterface\ now explicitly returns void.
Service · high confidence
Update PHPUnit configuration and clarify package implementation guidelines
The repository's test configuration has been updated to use the PHPUnit 13.1 schema, enabling strict deprecation handling via \failOnDeprecation\ and configuring the deprecation trigger system to ignore undefined triggers. The test suite scope has been expanded to include \Service/Test\ and \Translation/Test\ directories, and the Symfony PHPUnit bridge extension is now bootstrapped. Additionally, the README has been clarified to specify that packages implementing specific contracts should list them in the \provide\ section of their \composer.json\ using the \symfony/\*-implementation\ convention.
(repo-wide) · high confidence
Test coverage
Added HTTP test fixture server for HttpClient tests; Added test cases for ServiceLocator behavior; Added tests for CacheTrait behavior; Added tests for ServiceMethodsSubscriberTrait and legacy ServiceSubscriberTrait; Added translator test suite for pluralization and locale handling; Introduction of HttpClient test suite infrastructure.
Dependencies
Symfony Contracts v3.8: PHP 8.1 requirement and PSR-3/1.1/1.0 updates
The symfony/contracts package has been updated to version 3.8, raising the minimum PHP requirement to 8.1. This release aligns with modern standards by requiring psr/cache ^3.0, psr/container ^1.1\|^2.0, and psr/event-dispatcher ^1.0, while introducing a conflict rule for incompatible ext-psr versions. The package now replaces several sub-packages (cache-contracts, deprecation-contracts, event-dispatcher-contracts, http-client-contracts, service-contracts, and translation-contracts) and includes the deprecation function file in its autoload configuration.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 57.
Lenses
- Code Health 99
- Architecture 100
- Maturity 41
- Readiness 42
- Security 100
Changes since last survey
- 300 commits — 262 feature/other, 38 fixes
By area
- (repo) — 147 commits
- (root) — 35 commits
- HttpClient/Test — 34 commits
- Tests/Service — 12 commits
- Service/ServiceSubscriberTrait.php — 8 commits
- Translation/Test — 8 commits
- Cache/CacheTrait.php — 6 commits
- HttpClient/HttpClientInterface.php — 6 commits
- Service/Test — 5 commits
- Tests/Cache — 5 commits
- Cache/.github — 4 commits
- Cache/CacheInterface.php — 4 commits
- Translation/TranslatorTrait.php — 4 commits
- Service/ServiceProviderInterface.php — 3 commits
- Deprecation/function.php — 2 commits
- HttpClient/ResponseInterface.php — 2 commits
- Service/ServiceLocatorTrait.php — 2 commits
- Service/ServiceMethodsSubscriberTrait.php — 2 commits
- Service/composer.json — 2 commits
- Cache/README.md — 1 commit
Notable commits
- fix: Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
- fix: CS fix
- fix: CS fixes
- fix: CS fixes
- fix: CS fixes
- fix: CS fixes
- fix: CS fixes - native_function_invocation & static_lambda
- fix: Fix @var phpdoc
- fix: Fix CS
- fix: Fix ServiceMethodsSubscriberTrait for nullable service
- fix: Fix ServiceMethodsSubscriberTrait for nullable service
- fix: Fix merge
- fix: Fix multiple CS errors
- fix: Fix split.sh config name
- fix: Fix test class name
- fix: Minor CS fixes
- fix: More CS fixes
- fix: Revert "minor #54653 Auto-close PRs on subtree-splits (nicolas-grekas)"
- fix: Revert bumping contract version
- fix: Various CS fix for consistency
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
symfony/contracts was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 7e119d2299d6445cafb5f4ff854ac169ef035c60 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.