Skip to content

[5.x] Require ControllerInterface for controller classes in ControllerResolver - #170

Open
Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-controller-resolver-require-interface
Open

Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-controller-resolver-require-interface

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

ControllerResolver resolves a controller given as a class name to [$instance, 'execute'] for any existing class, although it is meant to resolve Joomla\Controller\ControllerInterface implementations. #163 deprecates resolving other classes in 4.x; in 5.0 they now raise an InvalidArgumentException (Controller Xdoes not implementJoomla\Controller\ControllerInterface, …). Other classes can still be used with an explicit [SomeClass::class, 'method'] route.

Testing Instructions

testResolvingAClassWithoutControllerInterfaceFails (new stub Tests/Stubs/PlainController.php, the same as in #163) fails without the change in src/. The other resolver tests are unchanged.

Documentation Changes Required

docs/routing-and-controllers.md (resolution table) and a new section in docs/v4-to-v5-update.md.

Depends on #169 (adds docs/v4-to-v5-update.md; its commit is included here until it is merged) and on #163 (the 4.x deprecation). When 4.x-dev is merged into 5.x-dev after #163, ControllerResolver::resolve() and ControllerResolverTest conflict: keep the 4.x structure (non-string check, class before function, is_callable() check), replace its trigger_deprecation() block with the exception from this PR, and replace the 4.x deprecation test with testResolvingAClassWithoutControllerInterfaceFails. The deprecation note in docs/routing-and-controllers.md from #163 must be dropped.

🤖 Generated with Claude Code

Hackwar and others added 2 commits November 12, 2026 23:20
Several 5.0 changes need an entry in the update guide; adding the page
first keeps those pull requests from conflicting over creating it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ControllerResolver resolved any existing class name to [$instance,
'execute'], although it is meant to resolve ControllerInterface
implementations. 4.x deprecates resolving other classes; 5.0 now throws
an InvalidArgumentException for them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant