From 26c42c59007cb6fb4672fd4a2ab8b28ac616fffe Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 12 May 2026 16:45:40 +0200 Subject: [PATCH 1/3] Align PolicyCommand::buildOptionParser visibility with parent Cake\Console\Command declares buildOptionParser() as protected; the override on PolicyCommand was public. Rector's MakeInheritedMethodVisibilitySameAsParentRector flags this and the cs-stan workflow is currently red on master. Drop the override visibility to protected to match the parent. Behavior is unchanged for callers, since the Bake/Command runner invokes the parent's protected getOptionParser() pipeline. --- src/Command/PolicyCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/PolicyCommand.php b/src/Command/PolicyCommand.php index 6bbb6f5..02f0e38 100644 --- a/src/Command/PolicyCommand.php +++ b/src/Command/PolicyCommand.php @@ -119,7 +119,7 @@ public function templateData(Arguments $arguments): array * @param \Cake\Console\ConsoleOptionParser $parser The parser to update. * @return \Cake\Console\ConsoleOptionParser */ - public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser + protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser { $parser = $this->_setCommonOptions($parser); From 849799319ef16bec036bec6636e61acc433d6a73 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 12 May 2026 16:53:36 +0200 Subject: [PATCH 2/3] Bump cakephp/bake minimum to ^3.6.4 The previous protected-visibility change on PolicyCommand::buildOptionParser fails the (8.2, lowest) matrix: cakephp/bake < 3.6.4 still declares SimpleBakeCommand::buildOptionParser as public, and PHP forbids narrowing visibility in a subclass. Bake 3.6.4 (the same release that introduced its own rector setup) switched the parent to protected; align our lowest bound accordingly so both ends of the matrix are consistent. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8dce7d7..8cd9482 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "require-dev": { "cakephp/authentication": "^3.0 || ^4.0", - "cakephp/bake": "^3.2", + "cakephp/bake": "^3.6.4", "cakephp/cakephp": "^5.1", "cakephp/cakephp-codesniffer": "^5.1", "phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4 || ^13.0" From fc2226de1559c602c99af3b9e05b493b2bb89c50 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 12 May 2026 17:00:12 +0200 Subject: [PATCH 3/3] Switch approach: skip rector rule on PolicyCommand instead of narrowing visibility The earlier two commits on this branch narrowed PolicyCommand::buildOptionParser to protected and bumped cakephp/bake's minimum to ^3.6.4 to keep CI green. That introduces a real (if narrow) BC break: users on cakephp/bake 3.2 - 3.6.3 who upgrade authorization to this revision hit a PHP fatal when loading PolicyCommand, because PHP forbids narrowing a parent's visibility. Revert both code changes and instead add a per-file skip to rector.php for MakeInheritedMethodVisibilitySameAsParentRector on src/Command/PolicyCommand.php. The override stays public, which is forward- and backward-compatible against any bake version - widening is always allowed. Net diff vs 3.x is a single addition to rector.php. --- composer.json | 2 +- rector.php | 10 ++++++++++ src/Command/PolicyCommand.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8cd9482..8dce7d7 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "require-dev": { "cakephp/authentication": "^3.0 || ^4.0", - "cakephp/bake": "^3.6.4", + "cakephp/bake": "^3.2", "cakephp/cakephp": "^5.1", "cakephp/cakephp-codesniffer": "^5.1", "phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4 || ^13.0" diff --git a/rector.php b/rector.php index e9c2d8d..3290f03 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,7 @@ use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector; use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; +use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector; @@ -52,4 +53,13 @@ NewlineAfterStatementRector::class, ExplicitBoolCompareRector::class, TypedPropertyFromCreateMockAssignRector::class, + + // Parent SimpleBakeCommand::buildOptionParser() switched from public + // to protected in cakephp/bake 3.6.4. Narrowing this override would + // break installs on bake 3.2 - 3.6.3 since PHP forbids reducing a + // parent's visibility. Keeping the override public is forward- and + // backward-compatible (widening is always allowed). + MakeInheritedMethodVisibilitySameAsParentRector::class => [ + __DIR__ . '/src/Command/PolicyCommand.php', + ], ]); diff --git a/src/Command/PolicyCommand.php b/src/Command/PolicyCommand.php index 02f0e38..6bbb6f5 100644 --- a/src/Command/PolicyCommand.php +++ b/src/Command/PolicyCommand.php @@ -119,7 +119,7 @@ public function templateData(Arguments $arguments): array * @param \Cake\Console\ConsoleOptionParser $parser The parser to update. * @return \Cake\Console\ConsoleOptionParser */ - protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser + public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser { $parser = $this->_setCommonOptions($parser);