Skip to content

[5.x] Add native types to the remaining untyped API - #42

Open
Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-native-types
Open

Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-native-types

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Several signatures were still typed only in doc blocks. This adds the native types:

Method Before After
Application::execute() no return type : void
AbstractCommand::addArgument() $default = null mixed $default = null
AbstractCommand::addOption() $shortcut = null, …, $description = '', $default = null string|array|null $shortcut = null, …, string $description = '', mixed $default = null
AbstractCommand::setDefinition() $definition array|InputDefinition $definition
DescriptorHelper::describe() $object, no return type object $object, : void
LoaderInterface::has() / ContainerLoader::has() $name string $name

All private properties are typed as well (AbstractCommand::$definition stays nullable so that a command whose constructor skips parent::__construct() still gets the existing "not correctly initialised" LogicException). AbstractCommand::$defaultName is left alone; it is removed in a separate 5.x PR.

Adding types to interface methods and overridable methods breaks implementers (a custom LoaderInterface, an Application subclass overriding execute()), hence 5.x.

Depends on #41 (the update guide this PR adds to); the branch contains its commit, please review only the last commit.

Testing Instructions

vendor/bin/phpunit, phpcs and PHPStan pass. New tests in tests/Command/AbstractCommandTest.php cover addOption() with an array of shortcuts, setDefinition() with an array, and the TypeError for an invalid definition.

Documentation Changes Required

docs/v4-to-v5-update.md: new "Native types" section listing the changed signatures.

🤖 Generated with Claude Code

Hackwar and others added 2 commits November 13, 2026 01:03
Two 5.x changes add entries to it; creating the file once keeps them
from conflicting over its creation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Several public signatures were typed only in doc blocks:
AbstractCommand::addOption() and addArgument() defaults,
AbstractCommand::setDefinition(), LoaderInterface::has(),
DescriptorHelper::describe() and Application::execute(). Add the native
types and type all private properties. Adding types to interface and
overridable methods breaks implementers, so this goes to 5.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar

Hackwar commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Approved. We should strive towards typed methods everywhere. However, this is a hurdle in updating. This would need a discussion in the maintainer team.

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