Skip to content

[4.x] Resolve Input magic properties without the autoloader, case-insensitively, and add __isset() - #63

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-get-input-map
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-get-input-map

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Input::__get() builds a class name from every property name (__NAMESPACE__ . '\' . ucfirst($name)) and calls class_exists() on it before looking at the superglobals. As a result:

  • the first access to $input->get, ->post, ->server, ->env and ->request queries the autoloader for Joomla\Input\Get etc., and any name — including one with backslashes, $input->{'Foo\Bar'} → Joomla\Input\Foo\Bar — reaches the autoloader;
  • the cache is keyed by the name as written, so $input->get and $input->GET are two different objects, and $input->FILES is a Files object on case-insensitive file systems but a plain Input elsewhere;
  • isset($input->get) returns false although the property works, because there is no __isset().

The subclasses (files, cookie, json) are now looked up in a fixed map, the names are case-insensitive (the cache key is lowercased), and __isset() returns whether a property is available.

One side effect: $input->input used to resolve to Joomla\Input\Input by accident and returned a new $_REQUEST input. It is not in the map, so it now throws like any other unknown property; $input->request is the documented way to get that.

Testing Instructions

New tests in InputTest: test__getIsCaseInsensitive(), test__getDoesNotQueryTheAutoloader() (registers a spy autoloader) and test__isset(). All fail before the change and pass after it.

Documentation Changes Required

docs/overview.md ("The sub-inputs"): the note that isset() returns false is replaced by the case-insensitivity and isset() behaviour.

🤖 Generated with Claude Code

__get() turned every property name into a class name and called
class_exists() on it, so the first access to $input->get, ->post,
->server etc. queried the autoloader for Joomla\Input\Get and friends,
and arbitrary names (including ones with backslashes) reached it as well.
The cache was keyed by the name as written, so $input->get and
$input->GET were two separate objects, and isset($input->get) returned
false although the property works.

The subclasses are now looked up in a fixed map, names are
case-insensitive, and __isset() reports the available properties.

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