182 integrate php stan into quantum starter project#183
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR integrates PHPStan into the project (composer, config, CI), adds a Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
.github/workflows/php.yml (1)
48-49: Run PHPStan once to avoid redundant CI work.Since this job is matrixed, Line 48–49 executes static analysis three times. You can keep tests matrixed and gate PHPStan to one PHP version to reduce build time.
⚙️ Suggested workflow tweak
- name: Run PHPStan + if: matrix.php-versions == '8.1' run: composer phpstan🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/php.yml around lines 48 - 49, The PHPStan step ("Run PHPStan" invoking "composer phpstan") is running for every matrix entry and causing redundant CI runs; modify the workflow so PHPStan runs only once by gating that step to a single PHP version (e.g., add a condition like if: matrix.php == '8.1' for the "Run PHPStan" step) or move the "Run PHPStan" step into a separate non-matrix job that runs once, keeping the test jobs matrixed.phpstan.neon.dist (1)
3-3: Note: Analysis level exceeds stated objective.The PR objectives mentioned starting at level 1, but this configuration sets
level: 5. While this is commendable, ensure all team members are aware of the stricter analysis and that the codebase can maintain this level going forward.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@phpstan.neon.dist` at line 3, The PHPStan configuration in phpstan.neon.dist sets a stricter analysis level (level: 5) than the PR objective (level 1); change the `level` value in phpstan.neon.dist from 5 to 1 (or align it with the agreed project standard) so CI and local tooling match the stated objective, and if you intended to raise the teamwide level keep level: 5 but add a note in the PR or a dedicated config change explaining the decision and coordinating with the team.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@helpers/functions.php`:
- Around line 37-38: The regex is matching current_lang() anywhere in
route_uri(), which can replace substrings inside other path segments; update the
preg_replace call that uses preg_quote(current_lang(), '/') and route_uri() so
it only matches the language when it appears as a full path segment (i.e.,
preceded by start or '/' and followed by end or '/'), and keep the limit of 1
replacement; adjust the preg_match check similarly to use the segment-aware
pattern so current_lang() is only detected/replaced as its own path segment.
In `@phpstan.neon.dist`:
- Line 12: The excludePaths entry for "modules" in phpstan.neon.dist is treated
as required and causes CI validation to fail because the directory doesn't
exist; update the excludePaths entry that currently references the string
modules to append "(?)" so the path becomes optional per PHPStan syntax,
ensuring PHPStan will not error if the modules directory is missing.
In `@shared/Models/Post.php`:
- Around line 31-32: PostTransformer is concatenating $item->user_directory with
$item->image without a null guard, which can cause a type error; update the
output mapping (the 'image' key in PostTransformer) to only concatenate when
both $item->image and $item->user_directory are truthy (e.g., change the
conditional to require both before doing $item->user_directory . '/' .
$item->image) so it returns null otherwise.
In `@shared/Services/CommentService.php`:
- Around line 83-85: The getComment() method currently returns the result of
$this->model->criteria(...)->first() as a Comment even when the model is empty;
update getComment() to mirror AuthService::get()/update() by checking the
returned model's isEmpty() and return null for empty results (or change the
method signature to ?Comment and return null on isEmpty()), ensuring callers
receive null instead of an empty Comment instance; reference the getComment()
method and use the isEmpty() check before returning.
---
Nitpick comments:
In @.github/workflows/php.yml:
- Around line 48-49: The PHPStan step ("Run PHPStan" invoking "composer
phpstan") is running for every matrix entry and causing redundant CI runs;
modify the workflow so PHPStan runs only once by gating that step to a single
PHP version (e.g., add a condition like if: matrix.php == '8.1' for the "Run
PHPStan" step) or move the "Run PHPStan" step into a separate non-matrix job
that runs once, keeping the test jobs matrixed.
In `@phpstan.neon.dist`:
- Line 3: The PHPStan configuration in phpstan.neon.dist sets a stricter
analysis level (level: 5) than the PR objective (level 1); change the `level`
value in phpstan.neon.dist from 5 to 1 (or align it with the agreed project
standard) so CI and local tooling match the stated objective, and if you
intended to raise the teamwide level keep level: 5 but add a note in the PR or a
dedicated config change explaining the decision and coordinating with the team.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7c3e4a17-8e11-477c-b961-cf90b106c25a
📒 Files selected for processing (23)
.gitattributes.github/workflows/php.ymlcomposer.jsonhelpers/functions.phpphpstan.neon.distpublic/assets/shared/css/materialize.min.cssshared/Commands/CommentCreateCommand.phpshared/Commands/CommentDeleteCommand.phpshared/Commands/DemoCommand.phpshared/Commands/PostCreateCommand.phpshared/Commands/PostDeleteCommand.phpshared/Commands/PostShowCommand.phpshared/Commands/PostUpdateCommand.phpshared/Commands/UserCreateCommand.phpshared/Commands/UserDeleteCommand.phpshared/Commands/UserShowCommand.phpshared/Models/Comment.phpshared/Models/Post.phpshared/Models/User.phpshared/Services/AuthService.phpshared/Services/CommentService.phpshared/Services/PostService.phpshared/Transformers/PostTransformer.php
- Mark modules excludePath as optional in phpstan.neon.dist for CI compatibility - Add null guard for user_directory in PostTransformer image concatenation Made-with: Cursor
Closes #182
Summary by CodeRabbit
Bug Fixes
Chores