Allow doctrine/annotations ^2.0 for PHP 8.2+ / modern doctrine/lexer compat#87
Open
CapturedMomentum wants to merge 1 commit into
Open
Allow doctrine/annotations ^2.0 for PHP 8.2+ / modern doctrine/lexer compat#87CapturedMomentum wants to merge 1 commit into
CapturedMomentum wants to merge 1 commit into
Conversation
…compat
In modern PHP projects (Laravel 11+, Symfony 7+, etc.), `doctrine/lexer`
is commonly pinned to 3.x by transitive dependencies. The SDK's
`doctrine/annotations: ^1.9` constraint excludes the 1.x range that
allows lexer 3.x, so Composer either:
- falls back to an older SDK tag (pre-1.27.0) that doesn't require
doctrine/annotations at all, leaving JMS Serializer 3.x without
an annotation reader, or
- refuses to resolve at all on stricter projects.
Either way, downstream consumers on PHP 8.2+ hit JMS deserialization
errors like:
RuntimeException: You must define a type for
Eversign\Business::$businessId.
…because the @type docblocks go unread without doctrine/annotations
installed. (Reproduced in a Laravel 11 install requiring
`eversign/eversign-php-sdk: ^1.27`.)
Two minimal changes:
1. composer.json — widen the constraint to allow doctrine/annotations
2.x: `^1.9 || ^2.0`. doctrine/annotations 2.x is PHP 8.0+ clean and
works with doctrine/lexer 3.x.
2. Client.php — guard the existing `AnnotationRegistry::registerLoader`
call with `method_exists` since doctrine/annotations 2.x removed
that method (autoloading via Composer handles class discovery in
modern setups; the call was already a backstop for very old PHP
installs, guarded by `class_exists`).
No DTO code changes, no PHP version bump, no new dependencies — the
existing @type / @var docblock annotations continue to work via
doctrine/annotations on every supported PHP version. The fix is
upward-compatible for consumers on doctrine/annotations 1.x as well
(method_exists short-circuits cleanly).
Verified: in a Laravel 11 environment with doctrine/lexer 3.0.1
locked, the SDK now installs at 1.27.0 alongside doctrine/annotations
2.0.2, and `new Eversign\Client('fake-key')` constructs cleanly +
reaches the live API (where it then fails on the bogus key, proving
the JMS deserialization path executed to completion).
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.
Problem
In modern PHP projects (Laravel 11+, Symfony 7+, etc.),
doctrine/lexeris commonly pinned to 3.x by transitive dependencies. The SDK'sdoctrine/annotations: ^1.9constraint can only resolve to 1.x versions, all of which require lexer 1.x or^1 || ^2— and so are unreachable when lexer 3.x is locked. Composer then either:doctrine/annotationsat all, leaving JMS Serializer 3.x without an annotation reader, orEither way, downstream consumers on PHP 8.2+ hit:
…because the
@Typedocblocks go unread withoutdoctrine/annotationsinstalled. Reproduced in a Laravel 11 install requiringeversign/eversign-php-sdk: ^1.27.Fix (2 lines)
"doctrine/annotations": "^1.9 || ^2.0". Doctrine annotations 2.x is PHP 8.0+ clean and compatible withdoctrine/lexer 3.x.AnnotationRegistry::registerLoader('class_exists')call withmethod_existssincedoctrine/annotations 2.xremoved that method. Composer-based autoloading handles class discovery for modern setups; the call was already a backstop for very old installs (already guarded byclass_exists).What this does NOT change
@Type/@vardocblock annotations continue to workdoctrine/annotations 1.x(themethod_existsshort-circuit is a no-op there)Verified
In a Laravel 11 environment with
doctrine/lexer 3.0.1locked, the SDK now installs at 1.27.0 alongsidedoctrine/annotations 2.0.2, andnew Eversign\Client('fake-key')constructs cleanly + reaches the live API (where it then fails on the bogus key — proving the JMS deserialization path executed to completion).