Repository navigation
Conversation
ControllerResolver resolved any existing class name to [$instance, 'execute'] although it is documented to resolve ControllerInterface classes; a class without execute() then failed with a TypeError from the callable return type. A string matching a function name resolved to that function before the class lookup, and function_exists() was called with non-string values. Non-string values are now rejected up front, class names are looked up before function names, a class without a callable execute() raises the usual InvalidArgumentException, and resolving a class that does not implement ControllerInterface triggers a deprecation (to become an exception in 5.0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the lowest dependencies the PHPUnit bridge handles deprecations itself, so PHPUnit's deprecation expectation never saw it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
ControllerResolver::resolve()says it resolves "a class name if it implements our ControllerInterface", but any existing class is instantiated and returned as[$obj, 'execute']without checking the interface or the method (a class withoutexecute()then fails with aTypeErrorfrom thecallablereturn type). A string controller that matches a function name resolves to that function before the class lookup, andfunction_exists()is called with non-string values (nullraises a deprecation).This PR:
InvalidArgumentException,InvalidArgumentExceptionwhen the resolved[$instance, 'execute']is not callable,trigger_deprecation('joomla/application', …)) when the class does not implementJoomla\Controller\ControllerInterface. A follow-up 5.x PR turns this into an exception.Route definitions are developer-controlled, so the impact is limited.
Behaviour change in 4.x: a string that is both a class and a function name now resolves to the class.
Testing Instructions
New tests in
ControllerResolverTest: class before same-named function (new stubSameNameController.phpdeclares both), the deprecation for a class without the interface (new stubPlainController), a class withoutexecute(), and anullcontroller. The first three fail without the change insrc/.Documentation Changes Required
docs/routing-and-controllers.md: the resolution order table, the failure cases and a deprecation note. The 5.x update guide entry comes with the 5.x PR that removes the fallback.🤖 Generated with Claude Code