-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix(docs): Update README.md
to include Behavior
integration section and example usage.
#74
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
Conversation
…on and example usage.
Warning Rate limit exceeded@terabytesoftw has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 33 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (1)
WalkthroughAdds documentation for Behavior integration to README (behaviors ServiceMap, hierarchical resolution where model properties override behavior properties, and behavior property/method inference); updates CHANGELOG.md 0.3.2 entry to note README Behavior integration. No functional code changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Code as User Code
participant Model as Model Instance
participant Behavior as Attached Behavior
Note over Model,Behavior #EFEFEF: Resolution order for properties/methods
Code->>Model: access $property / call method()
alt Model defines property/method
Model-->>Code: return model property/method
else Model does not define
Model->>Behavior: delegate property/method lookup
alt Behavior defines property/method
Behavior-->>Model: provide property/method
Model-->>Code: return behavior-provided property/method
else
Model-->>Code: undefined (no resolution)
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
README.md (3)
49-53
: Minor copy tweak for clarity and cross-reference.Recommend tightening the phrasing and pointing readers to the detailed section below.
Apply this diff:
-✅ **Behavior Integration** -- Hierarchical type resolution: model properties override behavior properties. -- Property and method resolution from attached behaviors. -- Support for behavior configuration through ServiceMap. +✅ **Behavior Integration** +- Hierarchical type resolution: model properties override behavior properties. +- Property and method resolution from attached behaviors. +- Behavior configuration via ServiceMap (see Behaviors below).
109-115
: Clarify that this configuration is for static analysis only.A short inline comment avoids confusion for users who might expect runtime effects.
Apply this diff:
return [ - 'behaviors' => [ + // PHPStan-only: used by this extension for behavior property/method type inference + 'behaviors' => [ app\models\User::class => [ app\behaviors\SoftDeleteBehavior::class, yii\behaviors\TimestampBehavior::class, ], ],
175-196
: Make the behavior example copy‑pasteable by importing Behavior.Add the missing import so the snippet runs as-is.
Apply this diff:
```php /** * @property string $slug * @property-read int $created_at */ -class SoftDeleteBehavior extends Behavior +use yii\base\Behavior; + +class SoftDeleteBehavior extends Behavior { public function softDelete(): bool { /* ... */ } }</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** **💡 Knowledge Base configuration:** - MCP integration is disabled by default for public repositories - Jira integration is disabled by default for public repositories - Linear integration is disabled by default for public repositories You can enable these sources in your CodeRabbit configuration. <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 41d606ad3bd0edc49f679de1d011af93b8d077f7 and 549593870783d24d951cf640456b09c8492e2277. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `CHANGELOG.md` (1 hunks) * `README.md` (3 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 LanguageTool</summary> <details> <summary>README.md</summary> [grammar] ~50-~50: There might be a mistake here. Context: ...properties override behavior properties. - Property and method resolution from atta... (QB_NEW_EN) </details> </details> </details> <details> <summary>🔇 Additional comments (2)</summary><blockquote> <details> <summary>CHANGELOG.md (1)</summary> `8-8`: **Changelog entry looks good and consistent.** Matches existing style and clearly references the docs-only change tied to the PR. </details> <details> <summary>README.md (1)</summary> `109-115`: **Behaviors configuration support confirmed** The `behaviors` key is fully supported end-to-end: • ServiceMap.processBehaviors() reads and validates the `behaviors` section (src/ServiceMap.php:421–435) • getBehaviorsByClassName() returns the mapped behavior class names (src/ServiceMap.php:170–173) • All reflection extensions (methods, properties, dynamic return types) invoke ServiceMap#getBehaviorsByClassName to include behavior definitions (e.g., src/type/ActiveRecordGetAttributeDynamicMethodReturnTypeExtension.php:185–190; src/method/BehaviorMethodsClassReflectionExtension.php:119–124; src/property/BehaviorPropertiesClassReflectionExtension.php:135–140) • Comprehensive tests verify behavior loading and error handling (tests/ServiceMapBehaviorTest.php) No further changes needed. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
…prove type inference examples.
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
README.md (3)
49-53
: Use a direct section link and keep wording consistent with earlier bullet.Tighten the phrasing and hyperlink to the section. Also align wording with Line 35 (“take precedence over”) for consistency.
- - Behavior configuration via ServiceMap (see Behaviors below). - - Hierarchical type resolution: model properties override behavior properties. + - Behavior configuration via ServiceMap (see [Behaviors](#behaviors)). + - Hierarchical type resolution: model properties take precedence over behavior properties.
109-116
: Minor grammar/punctuation in comment.Add a colon after “PHPStan-only” for clarity.
- // PHPStan-only used by this extension for behavior property/method type inference + // PHPStan-only: used by this extension for behavior property/method type inference
176-200
: Clarify behavior origin and fully qualify base class in example.The example reads better if we:
- Fully qualify the Yii Behavior base class to avoid implying an import in the snippet.
- Clarify in the docblock that created_at is provided by TimestampBehavior.
- Add a short in-line note that the behaviors are attached via the phpstan-config.php mapping, so readers understand why methods/properties resolve on User.
/** * @property string $slug * @property-read int $created_at + * Note: `created_at` is provided by `TimestampBehavior`. */ -class SoftDeleteBehavior extends Behavior +class SoftDeleteBehavior extends \yii\base\Behavior { public function softDelete(): bool { /* ... */ } } // ✅ Typed based on your configuration $user = new User(); - +// Behaviors attached via phpstan-config.php 'behaviors' map // ✅ Typed as string (inferred from behavior property) $slug = $user->getAttribute('slug'); // ✅ Typed as int (inferred from behavior property) $createdAt = $user->getAttribute('created_at'); // ✅ Typed as bool (method defined in attached behavior) $result = $user->softDelete();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
README.md
(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-14T17:41:48.820Z
Learnt from: terabytesoftw
PR: yii2-extensions/phpstan#40
File: src/ServiceMap.php:0-0
Timestamp: 2025-06-14T17:41:48.820Z
Learning: The yii2-extensions/phpstan repository contains a PHPStan extension specifically designed for static analysis of Yii framework applications.
Applied to files:
README.md
🪛 LanguageTool
README.md
[grammar] ~50-~50: There might be a mistake here.
Context: ...on via ServiceMap (see Behaviors below). - Hierarchical type resolution: model prop...
(QB_NEW_EN)
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
README.md (3)
49-53
: Make “Behaviors” cross-reference clickable and reduce repetition
- Turn “see Behaviors below” into an in-doc link.
- Optional: the precedence bullet repeats the same statement already listed under “ActiveRecord & ActiveQuery Analysis” (Line 35). Consider removing to keep Features succinct.
Apply:
-✅ **Behavior Integration** -- Behavior configuration via ServiceMap (see Behaviors below). -- Hierarchical type resolution: model properties take precedence over behavior properties. -- Property and method resolution from attached behaviors. +✅ **Behavior Integration** +- Behavior configuration via ServiceMap (see [Behaviors](#behaviors)). +- Property and method resolution from attached behaviors.
110-116
: Clarify “PHPStan-only” and trim trailing whitespaceThe comment is good; make it explicit that it has no runtime effect, and remove trailing spaces after the closing bracket.
- // PHPStan only: used by this extension for behavior property/method type inference + // PHPStan-only: used by this extension for behavior property/method type inference; no effect at runtime 'behaviors' => [ app\models\User::class => [ app\behaviors\SoftDeleteBehavior::class, yii\behaviors\TimestampBehavior::class, ], - ], + ],
176-203
: Show direct property access, and confirm method-collision precedence
- Add a direct property access example ($user->slug) alongside getAttribute(), since both patterns are common in Yii2 codebases and the extension claims to reflect behavior properties.
- Please confirm whether method precedence (model vs attached behavior) is also hierarchical like properties. If yes, consider adding one sentence in the docs for clarity.
// ✅ Typed based on your configuration // Behaviors attached via phpstan-config.php 'behaviors' map $user = new User(); // ✅ Typed as string (inferred from behavior property) $slug = $user->getAttribute('slug'); +// ✅ Direct property access is also inferred (behavior property) +$slug2 = $user->slug; + // ✅ Typed as int (inferred from behavior property) $createdAt = $user->getAttribute('created_at'); // ✅ Typed as bool (method defined in attached behavior) $result = $user->softDelete();If method-name collisions occur between the model and its behaviors, does the model method take precedence? If so, I can propose a one-liner note to document that behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
README.md
(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-14T17:41:48.820Z
Learnt from: terabytesoftw
PR: yii2-extensions/phpstan#40
File: src/ServiceMap.php:0-0
Timestamp: 2025-06-14T17:41:48.820Z
Learning: The yii2-extensions/phpstan repository contains a PHPStan extension specifically designed for static analysis of Yii framework applications.
Applied to files:
README.md
🪛 LanguageTool
README.md
[grammar] ~50-~50: There might be a mistake here.
Context: ...on via ServiceMap (see Behaviors below). - Hierarchical type resolution: model prop...
(QB_NEW_EN)
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
README.md (2)
49-53
: Nit: small grammar tweak for clarityRecommend a tiny wording improvement in the first bullet.
Apply this diff:
-- Behavior configuration via ServiceMap (see Behaviors below). +- Behavior configuration via ServiceMap (see the Behaviors section below).
176-206
: Tighten the behavior example (namespace/use, clarify TimestampBehavior note, wording)Adding namespace/use improves copy-pasteability. Also, TimestampBehavior typically populates an AR attribute rather than “providing” a property—adjust wording to avoid confusion. Minor wording tweak in the inline comment improves readability.
Apply these diffs within the code block:
-/** - * @property string $slug - * @property-read int $created_at - * - * Note: `created_at` is provided by `TimestampBehavior`. - */ -class SoftDeleteBehavior extends \yii\base\Behavior -{ - public function softDelete(): bool { /* ... */ } -} +<?php +namespace app\behaviors; + +use yii\base\Behavior; + +/** + * @property string $slug + * @property-read int $created_at + * + * Note: `created_at` is populated by `TimestampBehavior` on the owner model. + */ +class SoftDeleteBehavior extends Behavior +{ + public function softDelete(): bool { /* ... */ } +}-// Behaviors attached via phpstan-config.php 'behaviors' map +// Behaviors are attached via the phpstan-config.php behaviors map (PHPStan-only)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
README.md
(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-14T17:41:48.820Z
Learnt from: terabytesoftw
PR: yii2-extensions/phpstan#40
File: src/ServiceMap.php:0-0
Timestamp: 2025-06-14T17:41:48.820Z
Learning: The yii2-extensions/phpstan repository contains a PHPStan extension specifically designed for static analysis of Yii framework applications.
Applied to files:
README.md
🪛 LanguageTool
README.md
[grammar] ~50-~50: There might be a mistake here.
Context: ...on via ServiceMap (see Behaviors below). - Hierarchical type resolution: model prop...
(QB_NEW_EN)
🔇 Additional comments (2)
README.md (2)
49-53
: Behavior Integration section is a solid additionClear, concise bullets. Nicely surfaces the new capability and its interaction with models.
110-116
: Config snippet looks correct and scoped as PHPStan-onlyUsing a top-level 'behaviors' map with FQCNs is clear, and the in-code comment disambiguates runtime vs. analysis. Good.
Summary by CodeRabbit