Skip to content

[4.x] Throw an ArgumentCountError when a get<Filter>() shorthand is called without a name - #62

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-call-missing-name
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-call-missing-name

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

The get<Filter>() shorthands (getInt(), getString(), …) are resolved by Input::__call(), which reads $arguments[0] without checking it. $input->getInt() without a name raises Warning: Undefined array key 0 and then calls get(null), which returns the default — a programming error that only shows up as a warning. It now throws an ArgumentCountError, which is what PHP throws for a real method called with too few arguments.

Not changed: unknown filter names (getFoobar()) still fall back to the string filter. Rejecting or warning about them would need a list of the filter names InputFilter (or a subclass such as the CMS's) supports, which it does not expose; the docs already describe this behaviour.

Testing Instructions

New InputTest::test__callThrowsAnErrorIfTheNameIsMissing() fails before the change (warning, no exception) and passes after it.

Documentation Changes Required

docs/overview.md ("Reading values"): one sentence that the name is required.

🤖 Generated with Claude Code

Input::__call() read $arguments[0] unchecked, so $input->getInt() without
a name raised an "Undefined array key 0" warning and went on to get(null),
returning the default. It now throws an ArgumentCountError, as PHP does
for a real method called with too few arguments.

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