-
Notifications
You must be signed in to change notification settings - Fork 193
fix: php composer test resulting in error code 1 #1270
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughCI workflow for PHP now runs Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/sdk-build-validation.ymltemplates/php/composer.json.twigtemplates/php/src/Services/Service.php.twig
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
- GitHub Check: build (8.3, Node18)
- GitHub Check: build (8.3, AppleSwift56)
- GitHub Check: build (8.3, Swift56)
- GitHub Check: build (8.3, Node20)
- GitHub Check: build (8.3, Python313)
- GitHub Check: build (8.3, FlutterStable)
- GitHub Check: build (8.3, DartBeta)
- GitHub Check: build (8.3, Android5Java17)
- GitHub Check: build (8.3, Python311)
- GitHub Check: build (8.3, KotlinJava17)
- GitHub Check: build (8.3, Android14Java17)
- GitHub Check: build (8.3, DartStable)
- GitHub Check: kotlin (server)
- GitHub Check: go (server)
- GitHub Check: cli (console)
- GitHub Check: flutter (client)
- GitHub Check: apple (client)
- GitHub Check: swift (server)
- GitHub Check: android (client)
🔇 Additional comments (2)
.github/workflows/sdk-build-validation.yml (1)
175-176: LGTM! Enhanced validation from linting to testing.The change from
php -l(syntax linting) tocomposer test(running the full PHPUnit test suite) provides more comprehensive validation of the generated PHP SDK. This aligns with the PR objective of fixing composer test errors and ensures that the generated code is not only syntactically correct but also functionally tested.templates/php/composer.json.twig (1)
25-25: Downgrade is appropriate; the 1.6.x constraint is justified.Mockery 1.6.8+ includes PHPUnit 10+ attribute support, ensuring full compatibility with
phpunit/phpunit: ^10. The constraint1.6.*properly pins to the stable 1.6.x series, which is more conservative than^1.6.12that would allow future major versions. No compatibility issues with phpunit 10 exist in the 1.6.x range.
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.
Pull request overview
This PR fixes PHP composer test failures by addressing type declaration issues in generated service method signatures. The main fix is making the onProgress callback parameter properly nullable to support modern PHP type checking (PHP 8.0+), along with refactoring the method signature generation logic and correcting a variable reference bug.
Key changes:
- Refactored method signature generation to use a centralized
getMethodParametersmethod with proper nullable type support for theonProgresscallback - Corrected hardcoded variable reference from
$fileto the actual parameter name in file upload template - Updated Mockery dependency version constraint and changed PHP build validation from syntax check to running full test suite
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/php/src/Services/Service.php.twig | Replaced inline parameter generation with centralized methodParameters filter for cleaner, more maintainable code |
| templates/php/composer.json.twig | Changed Mockery version constraint from ^1.6.12 to 1.6.* |
| templates/php/base/requests/file.twig | Fixed hardcoded $file variable to use the actual parameter name from template context |
| src/SDK/Language/PHP.php | Added escapeKeyword and getMethodParameters methods, plus methodParameters filter for generating properly typed method signatures |
| .github/workflows/sdk-build-validation.yml | Updated PHP validation to run composer test instead of just syntax checking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
♻️ Duplicate comments (1)
templates/php/composer.json.twig (1)
25-25: Consider using^1.6.12instead of exact version pinning.Pinning to exact version
1.6.12prevents all updates, including patch releases that may contain bug fixes and security patches. This creates maintenance burden and potential security risks.Using
^1.6.12allows patch updates (e.g., 1.6.13, 1.6.14) while maintaining compatibility, which is the standard practice for dev dependencies.🔎 Recommended change
- "mockery/mockery": "1.6.12" + "mockery/mockery": "^1.6.12"
🧹 Nitpick comments (1)
src/SDK/Language.php (1)
161-174: Consider using strict comparison inin_array().The keyword escape logic is correct. However, using strict comparison (
in_array($value, $this->getKeywords(), true)) would be more defensive against edge cases involving type coercion.🔎 Proposed refinement
public function escapeKeyword(string $value): string { - if (in_array($value, $this->getKeywords())) { + if (in_array($value, $this->getKeywords(), true)) { return 'x' . $value; } return $value; }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/SDK/Language.phpsrc/SDK/Language/PHP.phpsrc/SDK/SDK.phptemplates/php/composer.json.twig
🚧 Files skipped from review as they are similar to previous changes (1)
- src/SDK/Language/PHP.php
🧰 Additional context used
🧬 Code graph analysis (2)
src/SDK/SDK.php (1)
src/SDK/Language.php (1)
escapeKeyword(167-174)
src/SDK/Language.php (9)
src/SDK/Language/PHP.php (1)
getKeywords(53-123)src/SDK/Language/DotNet.php (1)
getKeywords(24-136)src/SDK/Language/Go.php (1)
getKeywords(23-45)src/SDK/Language/Dart.php (1)
getKeywords(41-108)src/SDK/Language/JS.php (1)
getKeywords(42-111)src/SDK/Language/Python.php (1)
getKeywords(39-77)src/SDK/Language/Ruby.php (1)
getKeywords(38-79)src/SDK/Language/Kotlin.php (1)
getKeywords(23-92)src/SDK/Language/Swift.php (1)
getKeywords(23-92)
🔇 Additional comments (1)
src/SDK/SDK.php (1)
191-193: LGTM! Good refactoring to delegate keyword escaping.The change to delegate keyword escaping to the language-specific implementation (
$language->escapeKeyword($value)) improves maintainability and follows the Single Responsibility Principle. Language-specific logic is now properly encapsulated in the Language class.
Summary by CodeRabbit
Tests
Chores
Bug Fixes
Compatibility
✏️ Tip: You can customize this high-level summary in your review settings.