Repository navigation
Conversation
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>
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. |
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
Several signatures were still typed only in doc blocks. This adds the native types:
Application::execute(): voidAbstractCommand::addArgument()$default = nullmixed $default = nullAbstractCommand::addOption()$shortcut = null, …, $description = '', $default = nullstring|array|null $shortcut = null, …, string $description = '', mixed $default = nullAbstractCommand::setDefinition()$definitionarray|InputDefinition $definitionDescriptorHelper::describe()$object, no return typeobject $object,: voidLoaderInterface::has()/ContainerLoader::has()$namestring $nameAll private properties are typed as well (
AbstractCommand::$definitionstays nullable so that a command whose constructor skipsparent::__construct()still gets the existing "not correctly initialised"LogicException).AbstractCommand::$defaultNameis left alone; it is removed in a separate 5.x PR.Adding types to interface methods and overridable methods breaks implementers (a custom
LoaderInterface, anApplicationsubclass overridingexecute()), 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 intests/Command/AbstractCommandTest.phpcoveraddOption()with an array of shortcuts,setDefinition()with an array, and theTypeErrorfor an invalid definition.Documentation Changes Required
docs/v4-to-v5-update.md: new "Native types" section listing the changed signatures.🤖 Generated with Claude Code