feat(deps): drop doctrine/annotations - #320
Merged
Merged
Conversation
All serializer metadata in src/ is declared with PHP 8 attributes (#[Serializer\...]); there are no docblock @serializer annotations left. JMS Serializer's DefaultDriverFactory only requires doctrine/annotations below PHP 8.0 -- above that it registers AnnotationOrAttributeDriver with a null reader, and that driver reads attributes via reflection unconditionally. Since this package requires PHP ^8.2, the annotation reader was never doing any work. Nothing else in the dependency graph requires doctrine/annotations at runtime (jms/serializer and jms-serializer-uri-handler both list it under require-dev), so this removes it, and its psr/cache dependency, from consumers' installs rather than leaving it behind transitively. Released as a minor rather than a patch because of one downstream edge case: getSerializerBuilder() is public API, and anyone who takes that builder and serializes their own docblock-annotated classes will silently lose that metadata rather than get an error. Such consumers should add doctrine/annotations to their own composer.json. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013DMMmSMemViyZXtmDwQgvk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
doctrine/annotationsfromrequire.Why it's safe
src/are PHP 8 attributes (#[Serializer\Type(...)],#[Serializer\PostDeserialize], …). There are zero docblock@Serializerannotations.DefaultDriverFactory::createDriver()only throws the "doctrine/annotations must be installed" error whenPHP_VERSION_ID < 80000. Above that it registersAnnotationOrAttributeDriverwith a null reader, and that driver callsgetAttributes(SerializerAttribute::class, IS_INSTANCEOF)unconditionally — the reader is only an extraarray_mergewhen non-null. This package requiresphp: ^8.2, so that branch is unreachable.composer validate --strictpasses, andcomposer install --no-dev(what the PHAR builds from) resolves.Lock impact
The lock diff removes exactly two packages:
doctrine/annotationsandpsr/cache(its only dependent here).doctrine/lexerstays, sincejms/serializerrequires it directly.This library was the sole runtime requirer —
jms/serializeranddeviantintegral/jms-serializer-uri-handlerboth list it underrequire-dev. So this genuinely uninstalls it downstream rather than leaving it behind transitively.Compatibility note
No break to this library's own API or behavior. One downstream edge case is worth a release note:
Serializer::getSerializerBuilder()is public API, so anyone who takes that builder and serializes their own docblock-annotated classes will silently lose that metadata (empty metadata viaNullDriver) rather than get an error. Those consumers should adddoctrine/annotationsto their owncomposer.json.Typed as
featso release-please cuts a minor and the entry is visible in the changelog. Retype tobuild/choreif you'd rather it be a hidden patch.🤖 Generated with Claude Code
https://claude.ai/code/session_013DMMmSMemViyZXtmDwQgvk