Apply conservative Rector cleanup#35
Conversation
There was a problem hiding this comment.
Pull request overview
This PR applies a conservative Rector/code-quality cleanup pass across src/ and tests/, aiming to keep behavior unchanged while simplifying small constructs and modernizing a few PHP idioms.
Changes:
- Simplifies exception handling (unused catch variables), constant access (
static::→self::), and small string/array operations. - Refactors several controller view assignments away from
compact()and simplifies some conditional branches. - Tightens a few type checks (
instanceof) and minor validation patterns (regex simplification,get_debug_type()for error context).
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TestCase/CspComplianceTest.php | Uses self:: for class constant access in tests. |
| tests/schema.php | Removes unused exception variable in catch. |
| src/Service/RoleSourceService.php | Removes unused exception variables in catch blocks. |
| src/Service/ImportExportService.php | Adds string casts around INI parsing inputs to avoid type errors. |
| src/Service/FeatureService.php | Refactors feature auto-detection branching and removes unused exception variable. |
| src/Policy/TinyAuthResolver.php | Improves missing-policy exception context using get_debug_type(). |
| src/Policy/TinyAuthPolicy.php | Tightens identity/user type checks using instanceof. |
| src/Model/Table/ScopesTable.php | Simplifies field-name regex using \w. |
| src/Model/Table/RolesTable.php | Simplifies parent validation return logic. |
| src/Identity/EntityIdentity.php | Tightens authorization service checks via instanceof. |
| src/Controller/Admin/SyncController.php | Replaces compact() with explicit array in set(). |
| src/Controller/Admin/ScopesController.php | Replaces compact() with explicit array in set(). |
| src/Controller/Admin/RolesController.php | Replaces compact() with explicit array in set(). |
| src/Controller/Admin/ResourcesController.php | Replaces compact() with explicit array in set() and simplifies toggle branching. |
| src/Controller/Admin/DashboardController.php | Replaces compact() with explicit array in set(). |
| src/Controller/Admin/AppController.php | Simplifies runGate() exception handling. |
| src/Controller/Admin/AllowController.php | Replaces compact() with explicit array in set(). |
| src/Controller/Admin/AclController.php | Replaces compact() with explicit array in set() and simplifies toggle branching. |
| src/Auth/AllowAdapter/DbAllowAdapter.php | Minor string concatenation simplification. |
| src/Auth/AclAdapter/DbAclAdapter.php | Minor string concatenation simplification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
============================================
+ Coverage 82.02% 82.18% +0.15%
+ Complexity 597 595 -2
============================================
Files 46 46
Lines 2286 2284 -2
============================================
+ Hits 1875 1877 +2
+ Misses 411 407 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
src/Controller/Admin/AclController.php:91
- Inside the
elsebranch,$permission = $permissionsTable->newEntity([...])is indented too deeply compared to the surrounding control flow. Please align it to the correct indentation level (one level inside theelse) to match PSR-2 / the repo's PHPCS rules.
} else {
$permission = $permissionsTable->newEntity([
'action_id' => $actionId,
'role_id' => $roleId,
'type' => $type,
'description' => $description,
]);
src/Controller/Admin/ResourcesController.php:129
- In this
elsebranch,$permission = $resourceAclTable->newEntity([...])is indented too deeply relative to theelse {scope. Please align it with the rest of the block to keep the file compliant with the repo's PSR2R PHPCS rules.
} else {
$permission = $resourceAclTable->newEntity([
'resource_ability_id' => $abilityId,
'role_id' => $roleId,
'type' => $type,
'scope_id' => $scopeId,
]);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
src/Service/ImportExportService.php:245
- The
(string)$rolesListcast can hide invalid INI shapes (e.g. roles defined as an INI array), turning them into the literal string "Array" and potentially creating misleading "Unknown role" errors or importing incorrect data. Consider validating that$rolesListis a string (or stringable) and adding a clear error/skip when it is not, instead of casting.
// Parse roles
$roleAliases = array_map('trim', explode(',', (string)$rolesList));
foreach ($roleAliases as $alias) {
src/Service/ImportExportService.php:257
- Same indentation issue here: the
@varannotation and$existing = ...are indented deeper than the rest of the code in this loop. Please align them with the surrounding statements for consistency/readability.
$roleId = $roleLookup[$alias];
/** @var \TinyAuthBackend\Model\Entity\AclPermission|null $existing */
$existing = $permissionsTable->find()
->where(['action_id' => $action->id, 'role_id' => $roleId])
->first();
Applies the same conservative, behavior-neutral Rector cleanup pass as used in dereuromark/cakephp-ide-helper#452, but without committing Rector config or dependency wiring here.
src/andtests/This was generated with a temporary local Rector config and followed with CS fixes where needed.