Skip to content

Apply conservative Rector cleanup#35

Merged
dereuromark merged 12 commits into
masterfrom
rector-cleanup-20260524
May 25, 2026
Merged

Apply conservative Rector cleanup#35
dereuromark merged 12 commits into
masterfrom
rector-cleanup-20260524

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

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.

  • dead-code and code-quality simplifications only
  • excludes the same unsafe / opinionated ruleset areas
  • keeps the PR scope to generated cleanup changes in src/ and tests/

This was generated with a temporary local Rector config and followed with CS fixes where needed.

Copilot AI review requested due to automatic review settings May 24, 2026 17:02
Copy link
Copy Markdown

Copilot AI left a 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 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.

Comment thread src/Controller/Admin/AppController.php
Comment thread src/Service/FeatureService.php Outdated
Comment thread src/Model/Table/RolesTable.php Outdated
Comment thread src/Controller/Admin/AclController.php Outdated
Comment thread src/Controller/Admin/ResourcesController.php Outdated
Comment thread src/Service/ImportExportService.php Outdated
Copilot AI review requested due to automatic review settings May 24, 2026 18:13
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 24, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 70.51282% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.18%. Comparing base (5fcf3da) to head (32ad96f).

Files with missing lines Patch % Lines
src/Controller/Admin/ResourcesController.php 47.36% 10 Missing ⚠️
src/Controller/Admin/AclController.php 71.42% 6 Missing ⚠️
src/Service/ImportExportService.php 81.81% 2 Missing ⚠️
src/Service/RoleSourceService.php 71.42% 2 Missing ⚠️
src/Auth/AclAdapter/DbAclAdapter.php 0.00% 1 Missing ⚠️
src/Auth/AllowAdapter/DbAllowAdapter.php 0.00% 1 Missing ⚠️
src/Service/FeatureService.php 80.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 else branch, $permission = $permissionsTable->newEntity([...]) is indented too deeply compared to the surrounding control flow. Please align it to the correct indentation level (one level inside the else) 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 else branch, $permission = $resourceAclTable->newEntity([...]) is indented too deeply relative to the else { 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,
				]);

Comment thread src/Service/FeatureService.php Outdated
Comment thread src/Controller/Admin/AclController.php
Comment thread src/Controller/Admin/ResourcesController.php
Copilot AI review requested due to automatic review settings May 25, 2026 02:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings May 25, 2026 12:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)$rolesList cast 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 $rolesList is 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 @var annotation 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();

Comment thread src/Service/ImportExportService.php Outdated
Comment thread src/Controller/Admin/AclController.php Outdated
Comment thread src/Controller/Admin/ResourcesController.php Outdated
Comment thread src/Model/Table/RolesTable.php Outdated
Copilot AI review requested due to automatic review settings May 25, 2026 12:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread src/Controller/Admin/AclController.php
Comment thread src/Controller/Admin/ResourcesController.php
Comment thread src/Model/Table/RolesTable.php
Copilot AI review requested due to automatic review settings May 25, 2026 12:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

@dereuromark dereuromark merged commit 2f34f34 into master May 25, 2026
22 checks passed
@dereuromark dereuromark deleted the rector-cleanup-20260524 branch May 25, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants