Skip to content

Conversation

@dereuromark
Copy link
Member

Summary

This PR adds a new Rector rule to transform RouteBuilder method calls from the old argument order to the new CakePHP 6.0 order where callback comes second and params/options come third.

Affected methods:

  • scope(path, callback, params = [])
  • prefix(name, callback, params = [])
  • plugin(name, callback, params = [])
  • resources(name, callback = null, options = [])

Transformations:

// Before (CakePHP 5.x)
$routes->scope('/api', ['prefix' => 'Api'], function ($routes) { });
$routes->prefix('admin', [], function ($routes) { });
$routes->plugin('Blog', ['path' => '/blog'], function ($routes) { });
$routes->resources('Articles', ['only' => 'index']);

// After (CakePHP 6.0)
$routes->scope('/api', function ($routes) { }, ['prefix' => 'Api']);
$routes->prefix('admin', function ($routes) { });
$routes->plugin('Blog', function ($routes) { }, ['path' => '/blog']);
$routes->resources('Articles', null, ['only' => 'index']);

Changes:

  • New RouteBuilderToCallbackFirstRector class
  • New CakePHPSetList::CAKEPHP_60 constant
  • New cakephp60.php set file
  • Full test coverage with fixtures

Related:

🤖 Generated with Claude Code

This rector rule transforms RouteBuilder method calls from the old
argument order (params/options second, callback third) to the new
order (callback second, params/options third).

Affected methods:
- scope(path, callback, params)
- prefix(name, callback, params)
- plugin(name, callback, params)
- resources(name, callback, options)

Transformations:
- 3 args with array second, closure third: swap to callback second
- 3 args with empty array second: remove the empty array
- resources with 2 args (name + options): insert null as callback

Also adds:
- CakePHPSetList::CAKEPHP_60 constant
- cakephp60.php set file
- Full test coverage with fixtures

Refs cakephp/cakephp#19095

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dereuromark
Copy link
Member Author

Claude on its own didnt understand what target it should use ;)

@dereuromark dereuromark deleted the 6.x-routebuilder-args branch November 26, 2025 20:20
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.

2 participants