Fix newly reported PHPStan errors#142
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses newly reported PHPStan static analysis errors in the cron event command by removing an incorrect inline PHPDoc type assertion for callbacks.
Changes:
- Removed an overly-specific
@var array{0: string, 1: string}PHPDoc annotation informat_callback()that conflicts with valid callable array forms (e.g., object method callbacks).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request removes an inaccurate PHPDoc annotation in src/Cron_Event_Command.php that incorrectly restricted the first element of a callback array to a string. The reviewer suggests that instead of removing the annotation entirely, it should be updated to correctly reflect that the first element can be either an object or a string, which preserves the benefits of static analysis.
I am having trouble creating individual review comments. Click here to see my feedback.
src/Cron_Event_Command.php (864-866)
The removed @var annotation was incorrect because it specified that the first element of the array must be a string, whereas the code below correctly handles cases where it is an object (e.g., [$object, 'method']). Instead of removing the annotation entirely, it is better to provide an accurate type definition. This maintains the benefits of static analysis and provides clearer documentation for the expected structure of the $callback array.
/**
* @var array{0: object|string, 1: string} $callback
*/
No description provided.