Skip to content

Fix demo: use PHP 8 attribute instead of docblock annotation#11

Merged
koriym merged 1 commit into2.xfrom
fix-demo-attribute
Apr 9, 2026
Merged

Fix demo: use PHP 8 attribute instead of docblock annotation#11
koriym merged 1 commit into2.xfrom
fix-demo-attribute

Conversation

@koriym
Copy link
Copy Markdown
Member

@koriym koriym commented Apr 9, 2026

Summary

  • demo/src/Admin.php still used the docblock @RequiresRoles({\"login\"}) which was left over from PR Remove doctrine/annotations dependency, use native PHP 8 attributes #9
  • After dropping `doctrine/annotations` and removing the `@Annotation` marker from `RequiresRoles`, the demo was broken:
    • PHP 8.0 CI: Doctrine's `AnnotationReader` throws `Semantical Error ... not annotated with @Annotation` (hard failure)
    • PHP 8.4 local: silently ignored, ACL check was bypassed entirely
  • Replaced with `#[RequiresRoles(['login'])]` — demo now throws `RequiredRolesException` again and prints `It works !`

Test plan

  • `php demo/run.php` prints `It works !` locally
  • CI green on PHP 8.0–8.5

Summary by Sourcery

Bug Fixes:

  • Restore the demo access control check by replacing the outdated docblock RequiresRoles annotation with the corresponding PHP 8 attribute.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 27 minutes and 14 seconds.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c19fde51-4459-4be3-b5fb-0570f7604ed7

📥 Commits

Reviewing files that changed from the base of the PR and between 48626ed and 0da6037.

📒 Files selected for processing (1)
  • demo/src/Admin.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-demo-attribute

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.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 9, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the demo Admin controller to use the PHP 8 attribute-based RequiresRoles access control instead of the legacy Doctrine docblock annotation, restoring the intended ACL behavior in the demo under PHP 8+.

Class diagram for updated Admin ACL attribute usage

classDiagram

class Admin {
  +createUser(id string) void
}

class RequiresRoles {
  +roles array
}

Admin ..> RequiresRoles : attribute
Loading

File-Level Changes

Change Details Files
Switch demo access control from Doctrine-style docblock annotation to PHP 8 attribute syntax for RequiresRoles.
  • Remove the old @RequiresRoles docblock annotation from the createUser method.
  • Add the PHP 8 attribute #[RequiresRoles(['login'])] to the createUser method to enforce the login role via attributes.
  • Aligns the demo with the library’s attribute-based RequiresRoles implementation now that doctrine/annotations and @annotation markers are removed.
demo/src/Admin.php

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

Copy link
Copy Markdown

@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 reviewed your changes and they look great!


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.

@koriym koriym merged commit f681413 into 2.x Apr 9, 2026
13 checks passed
@koriym koriym deleted the fix-demo-attribute branch April 9, 2026 03:37
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