Repository navigation
Add Symfony 7.4 support - #34
Conversation
On Symfony 7 Request::$query is typed InputBag and HttpKernelInterface::MASTER_REQUEST is gone, so seven listener tests failed there. They now take the query bag from a real Request, which gives each Symfony line its own bag type, and pass MAIN_REQUEST where it exists. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Configuration::getConfigTreeBuilder() declares TreeBuilder: Symfony 7's ConfigurationInterface requires it, and without it the class cannot be loaded, so no Symfony 7 application could build its container. The getRootNode() fallback for Symfony older than 4.2 goes; no allowed version needs it. PayseraRestBundle::build(), PayseraRestExtension::load() and ApiCompilerPass::process() declare void, and the extension extends the DependencyInjection component's Extension instead of HttpKernel's, which Symfony 7.1 marks internal. Tests cover the configuration tree and the compiler pass the bundle registers; neither was loaded by a test before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Symfony 7.4 deprecates the XML configuration format, so every container build of an application logged a deprecation from the bundle. The 38 services of Resources/config/services.xml and its two imports are now defined in PayseraRestExtension with Definition and Reference objects, which work on every supported Symfony line, and the XML files are removed. The anonymous JsonpCallbackValidator argument becomes an inline definition, which is what the container compiles the XML service into. The new test compares every definition the extension registers, field by field, with a fixture dumped from 5.2.0's XML definitions; the dump is identical on Symfony 4.4, 5.4, 6.4 and 7.4. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PHP 8.4 deprecates a typed parameter that is nullable only through its null default. 5.2.0 fixed this elsewhere, but DefaultCacheStrategy::__construct() $provider and ValidatorAwareDenormalizer::validate() $groups still raised the deprecation when their classes were loaded. Both declare the nullable type now; the accepted values do not change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The seven Symfony components the bundle's code imports also allow ^7.4. doctrine/orm leaves require: nothing in the bundle uses it, and it held applications on ORM 2. The workflow runs the tests on Symfony 7 on PHP 8.2, 8.3 and 8.4, with the lowest and the highest dependencies; PHP 7.4, 8.0 and 8.1 are excluded because Symfony 7 requires PHP 8.2. CHANGELOG entry for 5.3.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ValidatorAwareDenormalizer::validate($entity, $groups) passed $groups as the validator's second argument, which is the list of constraints, so any call with groups ended in a TypeError from GenericMetadata::addConstraint() on every supported Symfony line. It now passes them as the third argument, the groups. A call without groups validates the Default group as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An empty $groups list reached the validator as an empty list of constraints and validated nothing; it now validates the Default group, like null. A data set pins that, and the CHANGELOG says exactly which inputs change: group names, an empty list, and constraint objects, which a caller could pass as $groups before and which are now rejected. The docblock types the list. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The constructor's $provider became explicitly nullable, and no test loaded the class. The new test covers the defaults, a max age without a provider and a max age with one, and checks that the strategy hands back the provider's own date object. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
HttpKernel's Extension extends the DependencyInjection one, so putting the old parent back would pass every other test while bringing back the Symfony 7.4 notice that the class is internal. The new test fails in that case. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The error codes in the ErrorConfig definition come from ApiException's constants instead of repeated strings. The new code gets trailing commas in its multi-line calls and sorted imports, the test helpers are instance methods, the test entity's properties are typed, and the three CHANGELOG lines that break subclasses carry the BREAKING marker. No definition changes: the definition test and the comparison with 5.2.0's XML definitions still match. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mSprunskas
left a comment
There was a problem hiding this comment.
1. Medium — validate() now validates the Default group when the group list is empty. The bundle uses an empty list to mean "do not validate".
- Issue Type: Backwards Compatibility – Logic Inconsistency
- Location: Normalizer/ValidatorAwareDenormalizer.php:41
- Problem: The new code sends $groups to validate($entity, null, $groups). Symfony's RecursiveContextualValidator::validate() does $groups ? normalizeGroups($groups) : $this->defaultGroups. Thus, [] becomes the Default
group. In other parts of the bundle, an empty group list stops validation:
- RestApi.php:400 returns null when the configured groups are [].
- Listener/RestListener.php:284 validates only when count($validationGroups) > 0.
With the old code, validate($entity, []) sent [] as constraints, and Symfony validated nothing. That old result agreed with the bundle convention.
- Impact: Subclasses in applications that call $this->validate($entity, $groups) with an empty $groups now get Default-group violations. Requests that passed before now fail with InvalidDataException, which is an HTTP 400
response. No error tells you that the behavior changed. The CHANGELOG puts this change under "Fixed", not under "BREAKING".
- Fix: Pick one of these options:
- Return without validation when $groups === [], as RestListener does.
- Keep the new behavior, but move it to the BREAKING list in the CHANGELOG.
2. Low — The GIF encoder uses the PNG factory method, so GIF responses have the image/png content type
- Issue Type: Logic Error (it existed before this change, and the change kept it)
- Location: DependencyInjection/PayseraRestExtension.php:166
- Problem: paysera_rest.encoding.gif uses createPngEncoder, which returns new Plain('image/png'). EncoderFactory::createGifEncoder() exists and returns image/gif. The old XML had the same error. The new code keeps it on
purpose ("unchanged").
- Impact: Responses in the gif format send an incorrect Content-Type: image/png header.
- Fix: Use 'createGifEncoder'. Put this fix in a separate change, so that this change keeps exact parity with the old XML.
Issue 2 can be fixed with separate PR
The bundle uses an empty list of groups to mean "do not validate": RestApi::getValidationGroups() returns null for it and RestListener::validateEntity() validates only a non-empty list. 5.2.0 validated nothing for it too, and 8451bd2 made it validate the Default group. validate() now returns before calling the validator when the list is empty. Group names still select their groups, and a call without groups still validates the Default group. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Symfony 7.4 declares no native return type on BundleInterface::build(), ExtensionInterface::load() or CompilerPassInterface::process(), only @return void. A native : void on the three overrides therefore fixed nothing on any supported Symfony line and broke every subclass that overrides one of them without it. The @return void tag keeps the debug class loader quiet, which is what the native type was there for, and the BREAKING line for these three methods leaves the CHANGELOG. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks for the review.
I also removed All 40 workflow jobs pass locally at a726aad, 67 tests each. |
Summary
This allows Symfony 7.4. On Symfony 7 the bundle could not load at all:
Configuration::getConfigTreeBuilder()lacked theTreeBuilderreturn type Symfony 7 requires, so an application failed while building its container. The change also defines the services in the extension instead of XML, drops the unuseddoctrine/ormrequirement, and fixes two PHP 8.4 notices andValidatorAwareDenormalizer::validate()with groups. I propose releasing it as 5.3.0. It builds on my CI-only pull request, #33.Why
Configurationdoes not.ParameterBagtoRequest::$query(typedInputBagon 7) and usedHttpKernelInterface::MASTER_REQUEST(removed in 7.0).build(),load()andprocess()without a declaredvoidreturn, the extension's HttpKernel parent (internal since 7.1), and the XML service format (deprecated in 7.4). It logs none now.validate($entity, $groups)passed$groupsto the validator as constraints, so group names ended in aTypeError. I found it while making that parameter explicitly nullable.Changes
composer.json:|| ^7.4onconfig,dependency-injection,validator,security-core,routing,http-foundationandhttp-kernel, every Symfony component the code imports.doctrine/ormremoved: the only Doctrine import isDoctrine\Persistence\ObjectRepository.Configuration::getConfigTreeBuilder(): TreeBuilder(the fallback for Symfony below 4.2 goes);@return voidonbuild(),load()andprocess(), which keeps Symfony's debug class loader quiet without changing their signatures; the extension extends DependencyInjection'sExtension.PayseraRestExtensionwithDefinitionandReferenceobjects, which work on every supported Symfony line; the XML files are removed. The error codes come fromApiException's constants.?onDefaultCacheStrategy::__construct()$providerandvalidate()$groups;validate()passes the groups as groups, and returns without validating when the list is empty.DefaultCacheStrategyandvalidate(). Workflow: Symfony7.*on PHP 8.2–8.4, lowest and highest (34 → 40 jobs). CHANGELOG 5.3.0.Backward compatibility
paysera_rest.encoding.gif, which 5.2.0 builds withcreatePngEncoder, so gif responses keepimage/png; I left it unchanged here and will fix it in a separate pull request after this one.TreeBuilderreturn type and the extension's new parent break a subclass that overridesgetConfigTreeBuilder()untyped or calls HttpKernel's deprecatedaddAnnotatedClassesToCompile(); the CHANGELOG marks both BREAKING.build(),load()andprocess()keep their 5.2.0 signatures. I know of no application that extends these classes, so I propose a minor, as Symfony 5 and 6 support were (5.1.1, 5.2.0).validate()with group names now validates those groups (before: aTypeError), and constraint objects passed as$groupsare rejected (before: applied as constraints). An empty list still validates nothing, the meaning it has in the rest of the bundle, andnullstill validates the Default group. An application that uses Doctrine ORM keeps it through its own requirement.Test plan
'10'; each new test fails when the code it covers is broken. The empty-list case ofvalidate()fails without the early return, and thenullcase fails when the guard is written asempty($groups).@return voidtags it logs one for each ofbuild(),load()andprocess().TreeBuilderreturn type makes the 7.4 one crash.🤖 Generated with Claude Code