Apply conservative Rector cleanup#501
Conversation
There was a problem hiding this comment.
Pull request overview
This PR applies conservative, cleanup-only refactors consistent with Rector-style modernization across the Queue plugin and its test suite, primarily to leverage PHP 8.2+ language features and reduce legacy patterns without changing intended behavior.
Changes:
- Replace legacy string functions (
strpos(),substr()) with PHP 8+ helpers (str_contains(),str_starts_with()) and add safe casts where helpful. - Simplify control flow and boolean/ternary logic (early returns, inline returns, null-coalescing assignment, first-class callables).
- Add/adjust a few PHPDoc type hints to improve static analysis in table/query result handling.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TestCase/View/Helper/QueueProgressHelperTest.php | Modernizes driver detection using str_contains() for skip logic. |
| tests/TestCase/Queue/Task/EmailTaskTest.php | Uses str_contains() to simplify Postgres skip condition. |
| tests/TestCase/Queue/ProcessorTest.php | Modernizes driver detection using str_contains() for skip logic. |
| tests/TestCase/Model/Table/QueuedJobsTableTest.php | Fixes test docblock return type and modernizes driver detection. |
| tests/TestCase/Controller/Admin/QueuedJobsControllerTest.php | Modernizes driver detection using str_contains() for skip logic. |
| tests/TestCase/Controller/Admin/QueueControllerTest.php | Modernizes driver detection using str_contains() for skip logic. |
| tests/TestCase/Command/RunCommandTest.php | Modernizes driver detection using str_contains() for skip logic. |
| tests/schema.php | Uses catch-without-variable for ReflectionException. |
| tests/bootstrap.php | Replaces OS prefix check with str_starts_with(). |
| src/View/Helper/QueueHelper.php | Simplifies boolean return logic for job state helpers. |
| src/Queue/TaskFinder.php | Removes unused foreach value variable. |
| src/Queue/Task/ProgressExampleTask.php | Simplifies ternary assignment for duration. |
| src/Queue/Task/MonitorExampleTask.php | Replaces strpos() check with str_contains(). |
| src/Queue/Task/ExecuteTask.php | Simplifies conditional command escaping into a ternary. |
| src/Queue/Task/EmailTask.php | Casts method key to string before building setter name. |
| src/Queue/Processor.php | Uses first-class callables for signal handlers; removes unused exception variables; simplifies PID retrieval. |
| src/Queue/Config.php | Uses null-coalescing assignment for default timeout. |
| src/Model/Table/QueueProcessesTable.php | Adds a result-shape PHPDoc for improved static analysis. |
| src/Model/Table/QueuedJobsTable.php | Adds PHPDoc for query results, minor style simplifications, and safer string handling. |
| src/Model/Behavior/JsonableBehavior.php | Flattens nested conditionals in JSON input handling. |
| src/Mailer/Transport/SimpleQueueTransport.php | Removes redundant check when pruning empty message settings. |
| src/Generator/Task/QueuedJobTask.php | Simplifies iteration to keys only; inlines return from TaskFinder. |
| src/Controller/Admin/QueueProcessesController.php | Uses catch-without-variable for generic exception handling. |
| src/Controller/Admin/QueuedJobsController.php | Iterates task keys directly where values are unused. |
| src/Controller/Admin/QueueController.php | Adds string casts for mb_substr() inputs in referer validation. |
| src/Controller/Admin/LoadHelperTrait.php | Simplifies helper selection into a ternary. |
| src/Command/InfoCommand.php | Iterates task keys directly where values are unused. |
| src/Command/BakeQueueTaskCommand.php | Uses str_contains() and returns heredoc directly. |
| src/Command/AddCommand.php | Iterates task keys directly where values are unused. |
💡 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. Additional details and impacted files@@ Coverage Diff @@
## master #501 +/- ##
=========================================
Coverage 78.32% 78.32%
Complexity 977 977
=========================================
Files 45 45
Lines 3313 3313
=========================================
Hits 2595 2595
Misses 718 718 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f4f7b73 to
e84f370
Compare
Cleanup-only Rector follow-up PR. No Rector dependency or config is added here; this keeps the branch focused on conservative code cleanup only.