-
Notifications
You must be signed in to change notification settings - Fork 27
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
Create own codegen #205
Create own codegen #205
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #205 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 168 189 +21
===========================================
Files 30 26 -4
Lines 470 503 +33
===========================================
+ Hits 470 503 +33 ☔ View full report in Codecov by Sentry. |
Create aop class without php parser
but not implemented for parent "use" namespace.
The parent class also called generate to get the method string in the same way, but type resolution of the arguments proved difficult and was done by reflection.
100% test passed in this point
Still old test code exists
This reverts commit 99a28a7.
It's hard for this codegen.
from 10 to 11
リファクタリングしてAopCodeGenを廃止し、AopCode(GeneratedCode)に集約しました。(OOP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
手元のプロジェクトではメソッドの戻り値がstaticでエラーが出ましたのでsuggestしました。
Co-authored-by: Yoshitaka Jingu <yoshitaka.jingu@gmail.com>
Co-authored-by: Yoshitaka Jingu <yoshitaka.jingu@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The commit introduces `is_string` function in a condition in `MethodSignatureString.php`. Several tools in `composer.lock` have been updated to newer versions, including packages like `amphp/amp`, `amphp/byte-stream`, and others. This commit thus refactors the code for improved validation and updates dependencies for enhanced project features.
WalkthroughThis update focuses on enhancing the Ray.Aop library by upgrading to PHP 8.2, refining the coding standards, and optimizing aspect-oriented programming capabilities. Notable changes include the addition of new classes for AOP, adjustments to existing functionalities, and a shift from using an external PHP-Parser to a custom code generation engine, aiming for significant performance improvements. Changes
Assessment against linked issues
Poem
Recent Review DetailsConfiguration used: CodeRabbit UI Files ignored due to path filters (1)
Files selected for processing (42)
Files skipped from review due to trivial changes (6)
Additional comments not posted (47)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai 日本語でもう一度お願いでします。 |
Tip For best results, initiate chat on the files or code changes. @koriym, 以下はプルリクエスト #205の概要です: プルリクエストの目的このプルリクエストは、既存の これらの課題に対処するために、トークンとリフレクションを組み合わせたハイブリッドソリューションが提案されています。これには、クラス宣言にトークンを使用し、特にトークンベースの引数名解決が問題となる場合にメソッド情報を取得するためにリフレクションを使用することが含まれます。 プルリクエストでは、Ray.Aopの10周年を記念するリンクされた問題(#206)も参照されており、この新しいcodegenエンジンの採用に向けたプロジェクトの進化と将来の方向性について議論されています。初期のベンチマークでは、新しいエンジンが現在のPHP-Parserベースのシステムに比べて40倍以上のパフォーマンス向上を提供する可能性が示唆されています。 コメント要約プルリクエストのコメントで、コントリビューターの
このプルリクエストは、プロジェクトをカスタムコード生成システムに更新するだけでなく、最新のPHP機能との互換性を向上させ、リファクタリングによってプロジェクト構造を改善し、パフォーマンスを大幅に向上させる可能性があります。 |
@coderabbitai Recent Review Detailsの部分も日本語でお願いします。 |
Tip For best results, initiate chat on the files or code changes. @koriym, 以下は「Recent Review Details」の日本語訳です: 最近のレビュー詳細プルリクエストのコメントで、コントリビューターの
このプルリクエストは、プロジェクトをカスタムコード生成システムに更新するだけでなく、最新のPHP機能との互換性を向上させ、リファクタリングによってプロジェクト構造を改善し、パフォーマンスを大幅に向上させる可能性があります。 |
@NaokiTsuchiya mergeしました! |
独自のcodegen実装が困難な理由
nikic/php-parserを使わないで独自のcodegenでオリジナルのコードを変更するのは困難です。以下がその理由。
解決策
* token_get_allで得られるtokenとリフレクションのハイブリッドで行う
* classの宣言まではtokenとその改変で行う
* メソッド情報はリフレクションから取得。これは引数の名前解決がtokenでは困難なため。
そもそもこの実装が最適化されたとしてもどの程度パフォーマンスアップ、低メモリになるかは未知数ですが実装してみないことにはわかりません。いうまでもありませんがプロダクションではコンパイルされたコードが使われるのでAOPによるパフォーマンスインパクトはほとんどありません。このPRは開発時やディプロイの時の最初のヘルスチェックでコンパイルを行う時のパフォーマンス向上です。
Not easy
It is difficult to modify the original code with our own codegen without using nikic/php-parser. Here is why.
use
cannot be obtained.Solution
Even if this implementation is optimized, it is unknown how much performance and memory reduction will be achieved. Needless to say, the performance impact of AOP will be negligible in production, where compiled code is used. The PR is a performance improvement when compiling at the first health check during development and deployment.
Todo
Related: #206
Closes #206
パーサトークンの一覧
Summary by CodeRabbit
New Features
ReflectionClass
and other components to improve code handling and type management.Bug Fixes
Refactor
Tests
Documentation