Skip to content

Conversation

@dereuromark
Copy link
Member

Summary

Adds a Rector rule to migrate RouteBuilder method calls for CakePHP 6.0.

This supports cakephp/cakephp#19095 which removes argument overloading from RouteBuilder methods.

Changes

  • scope('/path', $params, $callback)scope('/path', $callback, $params)
  • prefix('name', $params, $callback)prefix('name', $callback, $params)
  • plugin('name', $params, $callback)plugin('name', $callback, $params)
  • resources('name', $options)resources('name', null, $options)

Empty param arrays are automatically removed when the new signature only needs two arguments.

Test plan

  • Rector unit test passes
  • phpcs passes

🤖 Generated with Claude Code

Reorders RouteBuilder scope/prefix/plugin/resources method arguments
to have callback second and params/options third.

Changes:
- scope('/path', $params, $callback) -> scope('/path', $callback, $params)
- prefix('name', $params, $callback) -> prefix('name', $callback, $params)
- plugin('name', $params, $callback) -> plugin('name', $callback, $params)
- resources('name', $options) -> resources('name', null, $options)

Empty param arrays are automatically removed.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@dereuromark dereuromark force-pushed the 6.x-routebuilder-callback-first branch from 2114279 to 06d57bc Compare November 26, 2025 20:36
@ADmad
Copy link
Member

ADmad commented Nov 27, 2025

resources('name', $options) → resources('name', null, $options)

Not a big deal, but resources('name', options: $options) looks cleaner to me.

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@LordSimal LordSimal merged commit 56dc4ed into 6.x Dec 22, 2025
5 of 6 checks passed
@LordSimal LordSimal deleted the 6.x-routebuilder-callback-first branch December 22, 2025 09:09
@dereuromark
Copy link
Member Author

Isnt the main PR still open?

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.

5 participants