Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self link #293

Merged
merged 3 commits into from Apr 22, 2024
Merged

Self link #293

merged 3 commits into from Apr 22, 2024

Conversation

koriym
Copy link
Member

@koriym koriym commented Apr 4, 2024

通常時

通常

#[Embed(rel: "foo", src: "app://self/bar")]

のアトリビュートだと$this->body['foo']app://self/barRequestオブジェクトがアサインされます。

提案

それに対してrelで自己リンク_selfを指定すると

#[Embed(rel: "_self", src: "app://self/bar")]

自身のリソースのbodyがsrcで指定したリソースになります。通常の場合と違ってリクエストオブジェクトではなく、即実行されてその結果が代入されます。

ユースケース

appリソースと同じ値をpageリソースに代入したい時

モチベーション

  • 外部データを"pull"することを減らしたい
  • 宣言的になる
  • 簡素

検討点

リンクのselfとは関係がありません。これと混同しないか。

    "_links": {
        "self": { "href": "/user" }
    }

Summary by CodeRabbit

  • New Features

    • Added self-linking functionality to resources, enhancing navigation and integration within the application.
  • Bug Fixes

    • Removed an outdated dependency to ensure compatibility and performance.
  • Tests

    • Introduced new tests to verify the functionality of self-linking in resources.
  • Refactor

    • Updated PHP code style settings to exclude specific naming conventions for better clarity and consistency in method declarations.

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b333494) to head (dd77b62).

Additional details and impacted files
@@             Coverage Diff             @@
##                 1.x      #293   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       501       504    +3     
===========================================
  Files             83        83           
  Lines           1335      1346   +11     
===========================================
+ Hits            1335      1346   +11     

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

@koriym
Copy link
Member Author

koriym commented Apr 5, 2024

codeも移すべきでしょうか?

Copy link

coderabbitai bot commented Apr 21, 2024

Walkthrough

The update involves refining the EmbedInterceptor class by introducing self-linking capabilities and enhancing type safety. A dependency was removed, and adjustments were made to PHP_CodeSniffer rules. New test cases and classes within the FakeVendor namespace support these enhancements, focusing on embedding and resource handling functionalities.

Changes

File Path Change Summary
composer.json Removed dependency on "nikic/php-parser": "^4.10"
phpcs.xml Excluded PSR2.Methods.MethodDeclaration.Underscore rule
src/EmbedInterceptor.php Added SELF_LINK constant, linkSelf method; updated embedResource method; added type hinting in linkSelf
tests/EmbedInterceptorTest.php Added testSelfLink() to test self-link functionality
tests/Fake/.../App/Bird/Child.php, tests/Fake/.../App/Bird/SelfLink.php Added new classes Child and SelfLink with methods for handling resource responses and embedding

Poem

🐇💻

In the realm of code, changes take flight,
A rabbit's touch, enhancing with might.
Self-links bound, tests in their nest,
Old strings removed, for the code's very best.
Hop along, dear changes, take pride,
In the world of code, where you brightly reside.
🌟📜


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b333494 and dd77b62.
Files selected for processing (5)
  • phpcs.xml (1 hunks)
  • src/EmbedInterceptor.php (3 hunks)
  • tests/EmbedInterceptorTest.php (1 hunks)
  • tests/Fake/FakeVendor/Sandbox/Resource/App/Bird/Child.php (1 hunks)
  • tests/Fake/FakeVendor/Sandbox/Resource/App/Bird/SelfLink.php (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • phpcs.xml
  • src/EmbedInterceptor.php
  • tests/EmbedInterceptorTest.php
  • tests/Fake/FakeVendor/Sandbox/Resource/App/Bird/Child.php
  • tests/Fake/FakeVendor/Sandbox/Resource/App/Bird/SelfLink.php

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@koriym
Copy link
Member Author

koriym commented Apr 21, 2024

@jingu @NaokiTsuchiya Gentle reminder

Copy link
Member

@jingu jingu left a comment

Choose a reason for hiding this comment

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

👍

@koriym koriym merged commit 0a3cd1d into bearsunday:1.x Apr 22, 2024
17 checks passed
@koriym koriym deleted the link-self branch April 22, 2024 08:00
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.

None yet

2 participants