Skip to content

Make doctrine/annotations optional - #1156

Closed
DeyV wants to merge 1 commit into
phpbench:masterfrom
DeyV:optional-doctrine-annotations
Closed

DeyV wants to merge 1 commit into
phpbench:masterfrom
DeyV:optional-doctrine-annotations

Conversation

@DeyV

@DeyV DeyV commented Sep 25, 2026

Copy link
Copy Markdown

Closes #1068

doctrine/annotations is abandoned and PHP attributes are fully supported, so this makes the package optional:

  • Move doctrine/annotations from require to require-dev and add it to suggest.
  • AnnotationReader works without Doctrine. If it finds a PHPBench annotation, it throws a CouldNotLoadMetadataException that says how to fix it (install the package, migrate to attributes, or disable runner.annotations). It does not ignore the annotation silently. Detection follows the DocParser rules: case-insensitive names, and an @ preceded by whitespace, * or nothing. With runner.annotation_import_use the reader detects the use PhpBench\Benchmark\Metadata\Annotations... import, because aliases can be anything.
  • The PHAR still bundles doctrine/annotations: the release workflow adds it before compiling.
  • Docs and CHANGELOG updated. The change is listed as a B/C break for Composer users who rely on annotations.

The constructor takes a new optional ?bool $doctrineAvailable argument (auto-detected when null), so the no-Doctrine path can be unit tested.

🤖 Generated with Claude Code

Move doctrine/annotations to require-dev and suggest. Without it the
annotation reader throws a helpful error when it finds PHPBench
annotations instead of silently ignoring them. The PHAR still bundles
the package.

Closes phpbench#1068

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dantleech

Copy link
Copy Markdown
Member

this would be a B/C break. the only clean way to do this would be in PHPBench 2.x

is there a concrete problem that having this dependency has for you?

@dantleech dantleech closed this Sep 25, 2026
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.

Make doctrine/annotations optional

2 participants