Skip to content

LOG-10069: Symfony 7.4 / psr/log v3 compatibility fixes - #22

Open
justenj wants to merge 1 commit into
auto1-oss:masterfrom
justenj:LOG-10069-symfony-7-compat
Open

justenj wants to merge 1 commit into
auto1-oss:masterfrom
justenj:LOG-10069-symfony-7-compat

Conversation

@justenj

@justenj justenj commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Compatibility fixes required for Symfony 7.4 and psr/log v3.

  • LoggerAwareTrait::setLogger(): void — psr/log v3 LoggerAwareInterface::setLogger(): void requires a void return. The previous implementation returned $this, which is a fatal compile error under strict interface checking.
  • JsonEncoder::supportsEncoding(string $format): bool and supportsDecoding(string $format): bool — Symfony 7 JsonEncoder parent class declares string type on $format; child class must match.
  • UrlEncode, UrlEncoder, VoidEncoder — encode(mixed $data, string $format, ...) and supportsEncoding(string $format, array $context = []): bool — Symfony 7 EncoderInterface declares typed parameters; subclass declarations must be compatible.

Context

These fixes are needed as part of a Symfony 5.4→7.4 upgrade of wkda/eta-management-service (LOG-10069). The EndpointsDebugCommand::execute(): int and ArrayAccessNormalizer fixes were already merged in PR #19. This PR covers the remaining compatibility gaps.

Related to open PR #20 (PUR1-3530) which also fixes LoggerAwareTrait::setLogger(): void.

🤖 Generated with Claude Code

- LoggerAwareTrait::setLogger() returns void (psr/log v3 LoggerAwareInterface)
- JsonEncoder::supportsEncoding/supportsDecoding: add string type to $format
- UrlEncode::encode: add mixed/string types; supportsEncoding: add string+context
- UrlEncoder::encode: add mixed/string types; supportsEncoding: add string+context
- VoidEncoder::encode: add mixed/string types; supportsEncoding: add string+context

Required for Symfony 7.4 which enforces EncoderInterface and LoggerAwareInterface
type declarations strictly.
@aivus

aivus commented Jul 24, 2026

Copy link
Copy Markdown
Member

Review

Blocking: CI is already red on PHP 7.4

The 7.4 job fails (all 8.x pass). The cause is structural:

  • mixed requires PHP 8.0, but composer.json still declares "php": "^7.4|^8.0" and the CI matrix includes 7.4 — these classes now fatal at load time on 7.4.
  • string $format breaks Symfony 4.x support. In Symfony 4.2–4.4, EncoderInterface::encode($data, $format, ...) and supportsEncoding($format) are fully untyped (verified against upstream tags). PHP forbids adding a parameter type in an implementation (narrowing), so these classes fatal under symfony/serializer ~4.x, which composer.json still allows. CI doesn't catch this because it only tests "latest" Symfony per PHP version.

Two consistent ways to resolve; the PR currently sits between them:

  1. Keep broad compat (smallest diff): don't add the parameter types at all. PHP allows parameter widening, so the original untyped encode($data, $format, ...): string and supportsEncoding($format): bool are already legal implementations of the Symfony 7 typed interface. Strictly speaking, only the setLogger(): void change is required — return types can't be omitted when the parent declares one (psr/log v3), but untyped parameters are always compatible.
  2. Intentionally drop legacy support: keep the typed signatures, but then bump composer.json to "php": "^8.0" (arguably ^8.2 for Symfony 7), drop ~4.x from the Symfony constraints, and remove 7.4 from the CI matrix — in this PR, so the package metadata doesn't lie.

Given the goal is just unblocking the Symfony 7.4 upgrade downstream, option 1 is the lower-risk choice unless dropping PHP 7.4/Symfony 4 is a deliberate decision.

Other notes

  • setLogger(): void — correct and genuinely required for psr/log v3; also remains compatible with psr/log v1/v2. Note this is a BC break for consumers: downstream code chaining ->setLogger($logger)->… on classes using this trait (EndpointRegistry, EndpointFactory, ChainUrlResolver, ParameterAwareUrlResolver) will fatal. Deserves a version-bump/release note.
  • Overlap with PR Drop PHP 7.4 & Symfony 4 support to unblock monolog 3 upgrade #20 — same setLogger fix; coordinate merge order to avoid a needless conflict.
  • Inconsistency: UrlEncode/UrlEncoder/VoidEncoder::supportsEncoding() gained the optional array $context = [] param, but JsonEncoder::supportsEncoding/supportsDecoding did not. Both are runtime-legal (Symfony 7 keeps $context commented out in the interface), but pick one style.
  • Minor: the now-empty /** @param LoggerInterface $logger */ docblock in LoggerAwareTrait can be dropped.

Verdict

Request changes. The setLogger(): void fix is correct and necessary, but the encoder signature changes break the package's own declared support matrix (PHP 7.4 CI is already failing) while not actually being required for Symfony 7. Either revert the parameter-type additions (keeping only setLogger), or make the support-drop explicit in composer.json and the CI matrix within this PR.

@aivus aivus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes — see detailed review in #22 (comment)

TL;DR: the setLogger(): void fix is correct and required for psr/log v3, but the encoder parameter-type additions (mixed $data, string $format) break the package's own declared support matrix — PHP 7.4 CI is already failing, and Symfony ~4.x (still allowed in composer.json) would fatal on narrowed parameter types. Either revert the parameter-type additions (they aren't required for Symfony 7 — parameter widening is legal), or explicitly drop PHP 7.4 / Symfony 4 support in composer.json and the CI matrix within this PR.

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.

2 participants