Skip to content

refactor: upgrade to PHP 8.1+, remove deprecated annotations#7

Merged
koriym merged 12 commits into1.xfrom
php81-upgrade
Jan 28, 2026
Merged

refactor: upgrade to PHP 8.1+, remove deprecated annotations#7
koriym merged 12 commits into1.xfrom
php81-upgrade

Conversation

@koriym
Copy link
Member

@koriym koriym commented Jan 28, 2026

  • Require PHP ^8.1
  • Remove doctrine/annotations and koriym/attributes
  • Remove ray/aop from direct dependencies
  • Convert UploadFiles annotation to PHP 8 Attribute
  • Update LICENSE copyright year

Summary by Sourcery

Raise the minimum supported PHP version to 8.1 and modernize the package to use PHP 8 attributes and updated dependency configuration.

Enhancements:

  • Convert the UploadFiles doctrine-style annotation to a native PHP 8 attribute qualifier.
  • Scope HTTP request and URI bindings as singletons in the PSR-7 DI module.

Build:

  • Update composer constraints to require PHP ^8.1, drop ray/aop, and narrow phpunit to ^9.5.
  • Define a PHP 8.1 platform configuration and reformat Composer scripts as array notation.

Documentation:

  • Update the LICENSE copyright year.

Tests:

  • Simplify the test bootstrap by removing the runtime attribute reader setup.

Summary by CodeRabbit

  • Chores

    • Minimum PHP requirement raised to 8.1
    • Removed aop package as an explicit dependency
  • New Features

    • Added PHP 8 attribute support for UploadFiles
  • Documentation

    • Added changelog and a Lazy Loading example in the README
  • Deprecated

    • Marked legacy request/provider APIs as deprecated

✏️ Tip: You can customize this high-level summary in your review settings.

- Bind ServerRequestInterface, ServerRequest, UriInterface, and UploadFiles to Scope::SINGLETON
- This prevents re-parsing of globals on every injection, improving performance
- Require PHP ^8.1
- Remove doctrine/annotations and koriym/attributes
- Remove ray/aop from direct dependencies
- Convert UploadFiles annotation to PHP 8 Attribute
- Update LICENSE copyright year
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 28, 2026

Reviewer's Guide

Raises minimum PHP version to 8.1, removes legacy annotation/attribute infrastructure, converts UploadFiles from a Doctrine-style annotation to a native PHP 8 attribute, tightens Ray DI bindings to singletons, and cleans up tooling/config including platform PHP constraint and LICENSE metadata.

Sequence diagram for Ray DI singleton resolution of ServerRequest

sequenceDiagram
    participant Client
    participant Injector
    participant Psr7Module
    participant HttpRequestRayProvider
    participant ServerRequest

    Client->>Injector: getInstance(ServerRequest)
    Injector->>Psr7Module: loadBindings()
    Psr7Module-->>Injector: bind(ServerRequest).toProvider(HttpRequestRayProvider).in(Scope::SINGLETON)

    alt first_resolution
        Injector->>HttpRequestRayProvider: get()
        HttpRequestRayProvider-->>Injector: new ServerRequest
        Injector->>ServerRequest: store_in_singleton_scope
        Injector-->>Client: ServerRequest instance A
    else subsequent_resolution
        Client->>Injector: getInstance(ServerRequest)
        Injector-->>Client: same ServerRequest instance A
    end
Loading

Class diagram for Ray DI bindings and UploadFiles attribute refactor

classDiagram
    class AbstractModule
    class Psr7Module {
        +configure() void
    }

    Psr7Module --|> AbstractModule

    class RequestProviderInterface
    class HttpRequestProvider
    RequestProviderInterface <|.. HttpRequestProvider

    class ServerRequest
    class ServerRequestInterface
    class HttpRequestRayProvider
    ServerRequestInterface <|.. ServerRequest
    HttpRequestRayProvider ..> ServerRequest : provides
    HttpRequestRayProvider ..> ServerRequestInterface : provides

    class UriInterface
    class UriProvider
    UriInterface <|.. UriProvider
    UriProvider ..> UriInterface : provides

    class UploadFiles {
        <<attribute>>
    }

    class UploadfilesProvider
    UploadfilesProvider ..> UploadFiles : qualified_by

    class Scope {
        <<enum>>
        SINGLETON
    }

    Psr7Module ..> RequestProviderInterface : bind
    Psr7Module ..> HttpRequestProvider : to
    Psr7Module ..> ServerRequest : bind
    Psr7Module ..> ServerRequestInterface : bind
    Psr7Module ..> HttpRequestRayProvider : toProvider
    Psr7Module ..> UriInterface : bind
    Psr7Module ..> UriProvider : toProvider
    Psr7Module ..> UploadFiles : annotatedWith
    Psr7Module ..> UploadfilesProvider : toProvider
    Psr7Module ..> Scope : in SINGLETON
Loading

File-Level Changes

Change Details Files
Bump platform requirements and adjust Composer configuration for PHP 8.1+ ecosystem.
  • Raise PHP requirement from ^7.3
Tighten DI configuration to singleton scope for HTTP-related providers.
  • Import Ray\Di\Scope into Psr7Module
  • Change bindings for ServerRequest, ServerRequestInterface, UriInterface, and UploadFiles provider to use ->in(Scope::SINGLETON) so containers reuse single instances
src/Psr7Module.php
Migrate UploadFiles from Doctrine-style annotation to PHP 8 attribute and remove legacy attribute reader bootstrapping.
  • Replace docblock-based @Annotation/@Target/@qualifier metadata with native PHP 8 attribute syntax on UploadFiles
  • Remove runtime setup of Koriym AttributeReader via ServiceLocator now that native attributes are used directly
src/Annotation/UploadFiles.php
tests/bootstrap.php
Update legal metadata.
  • Adjust LICENSE content (likely year or holder update) to reflect current project status
LICENSE

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Warning

Rate limit exceeded

@koriym has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Modernizes project to target PHP 8.1, migrates docblock annotations to PHP 8 attributes, adjusts DI provider bindings and deprecations, updates CI matrix and composer metadata, updates license year range, and adds CHANGELOG and README edits. No public API signatures were removed.

Changes

Cohort / File(s) Summary
Composer & CI
composer.json, .github/workflows/continuous-integration.yml, vendor-bin/tools/composer.json
Targets PHP 8.1 (config.platform + php constraint), raises PHPUnit to ^9.5, removes ray/aop, refactors scripts (adds post-install/update hooks), trims CI old_stable matrix to ["8.1","8.2","8.3"], and bumps doctrine/coding-standard in vendor-bin.
Annotations → Attributes
src/Annotation/UploadFiles.php, README.md, CHANGELOG.md
Replaces PHPDoc-based annotation with native PHP 8 attribute (#[Attribute(...), Qualifier]), updates README examples and documents change in CHANGELOG.
Providers & DI bindings
src/HttpRequestProvider.php, src/HttpRequestRayProvider.php, src/Psr7Module.php, src/RequestProviderInterface.php, src/UploadfilesProvider.php, src/UriProvider.php
HttpRequestProvider now implements ProviderInterface; Psr7Module binds ServerRequest/ServerRequestInterface to HttpRequestProvider; added deprecation docblocks for legacy providers/interfaces; minor docblock standardizations ({@inheritdoc}{@inheritdoc}).
Tests & Bootstrap
tests/bootstrap.php, tests/Psr7HttpModuleTest.php
Removes AttributeReader/ServiceLocator conditional setup from bootstrap; updates PHPDoc return-type annotations in tests (formatting and types).
License
LICENSE
Updates copyright year range from 2018-2021 to 2018-2026.
Docs & Changelog
CHANGELOG.md, README.md
Adds CHANGELOG with Unreleased notes (attribute support, PHP 8.1 requirement, deprecations, removed dependencies) and README lazy-loading example and attribute usage updates.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
A gentle hop to PHP eight-one,
Attributes gleam like morning sun.
Bindings shifted, old flags fall,
CI trimmed, changelog tells it all.
I nibble code and dance—updates done!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main changes: upgrading to PHP 8.1+ and removing deprecated annotations, which are the primary objectives reflected across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (26f5523) to head (026cd2a).
⚠️ Report is 1 commits behind head on 1.x.

Additional details and impacted files
@@             Coverage Diff             @@
##                 1.x        #7   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
+ Complexity         5         4    -1     
===========================================
  Files              5         4    -1     
  Lines             21        19    -2     
===========================================
- Hits              21        19    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In Psr7Module, setting ServerRequest, ServerRequestInterface, UriInterface, and the UploadFiles-qualified binding to Scope::SINGLETON changes them from per-request to shared instances; for request-specific objects you may want to leave them unscoped or use a per-request scope instead to avoid leaking state between requests.
  • The tests/bootstrap.php file now only contains a commented-out ServiceLocator::setReader(new AttributeReader()); referencing removed imports; consider either removing this line entirely or replacing it with whatever minimal bootstrap is still required so the file reflects the current setup.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Psr7Module`, setting `ServerRequest`, `ServerRequestInterface`, `UriInterface`, and the `UploadFiles`-qualified binding to `Scope::SINGLETON` changes them from per-request to shared instances; for request-specific objects you may want to leave them unscoped or use a per-request scope instead to avoid leaking state between requests.
- The `tests/bootstrap.php` file now only contains a commented-out `ServiceLocator::setReader(new AttributeReader());` referencing removed imports; consider either removing this line entirely or replacing it with whatever minimal bootstrap is still required so the file reflects the current setup.

## Individual Comments

### Comment 1
<location> `src/Psr7Module.php:19-22` </location>
<code_context>
-        $this->bind(ServerRequestInterface::class)->toProvider(HttpRequestRayProvider::class);
-        $this->bind(UriInterface::class)->toProvider(UriProvider::class);
-        $this->bind()->annotatedWith(UploadFiles::class)->toProvider(UploadfilesProvider::class);
+        $this->bind(ServerRequest::class)->toProvider(HttpRequestRayProvider::class)->in(Scope::SINGLETON);
+        $this->bind(ServerRequestInterface::class)->toProvider(HttpRequestRayProvider::class)->in(Scope::SINGLETON);
+        $this->bind(UriInterface::class)->toProvider(UriProvider::class)->in(Scope::SINGLETON);
+        $this->bind()->annotatedWith(UploadFiles::class)->toProvider(UploadfilesProvider::class)->in(Scope::SINGLETON);
     }
 }
</code_context>

<issue_to_address>
**issue (bug_risk):** Using SINGLETON scope for request-scoped objects risks shared mutable state across HTTP requests.

Binding these HTTP-related types as singletons reuses the same instance for all consumers, so per-request data can leak between requests in long-running processes (e.g. PHP-FPM with shared containers, Swoole, RoadRunner). Prefer the default (non-singleton) scope or a dedicated per-request scope so each request receives a fresh instance.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- Revert bindings to prototype scope to avoid shared state in long-running processes
- Clean up unused code in tests/bootstrap.php
- Update CI workflow to test only PHP 8.1+
…ider

- Deprecate RequestProviderInterface and HttpRequestRayProvider
- Make HttpRequestProvider implement Ray\Di\ProviderInterface (idiomatic) AND RequestProviderInterface (compat)
- Update Psr7Module to bind ServerRequestInterface to HttpRequestProvider directly
- Preserve RequestProviderInterface binding for backward compatibility
- Run phpcbf
- Add @codeCoverageIgnore to RequestProviderInterface and HttpRequestRayProvider
- Run 'composer bin all install' with --ignore-platform-reqs to ensure CI has access to tools like phpcs in vendor/bin
- Update vendor-bin/tools dependencies
- Apply new coding standard fixes
- Fix malformed docblock in Psr7HttpModuleTest
- Suppress erroneous report for intentional implementation of deprecated interface for backward compatibility
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@vendor-bin/tools/composer.json`:
- Line 3: Upgrade to doctrine/coding-standard 13.0 enforces two new sniffs; run
the coding standard checks (e.g., ./vendor/bin/phpcs --standard=./phpcs.xml) and
fix violations: add explicit type declarations for any class constants to
satisfy SlevomatCodingStandard.TypeHints.ClassConstantTypeHint and adjust enum
case formatting/spacing to satisfy
SlevomatCodingStandard.Classes.EnumCaseSpacing (search for class constants and
enum declarations in the codebase and update their declarations/spacing until
phpcs reports no errors).
🧹 Nitpick comments (2)
README.md (1)

85-101: Consider using consistent code block delimiters.

The new Lazy Loading section uses triple backticks (```) while other code blocks in this file use quadruple backticks (````). Consider using quadruple backticks for consistency throughout the README.

📝 Suggested fix for consistency
-```php
+````php
 use Ray\Di\Di\Set;
 use Ray\Di\ProviderInterface;
 use Psr\Http\Message\ServerRequestInterface;

 class Foo
 {
     public function __construct(
         #[Set(ServerRequestInterface::class)] private ProviderInterface $requestProvider
     ) {}

     public function onGet()
     {
         $request = $this->requestProvider->get();
     }
 }
-```
+````
composer.json (1)

77-82: Consider removing --ignore-platform-reqs from post-install/update hooks.

Using --ignore-platform-reqs in automated hooks may mask platform compatibility issues with vendor-bin tools. If a tool doesn't support PHP 8.1, this flag will silently allow installation, potentially causing runtime failures.

Suggested change
     "post-install-cmd": [
-        "@composer bin all install --ansi --ignore-platform-reqs"
+        "@composer bin all install --ansi"
     ],
     "post-update-cmd": [
-        "@composer bin all install --ansi --ignore-platform-reqs"
+        "@composer bin all install --ansi"
     ]

@koriym koriym merged commit d55f873 into 1.x Jan 28, 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.

1 participant