-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Include Constructor to be a part of CommandListInterface
API, extend inline documentation
#37901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.4-develop
Are you sure you want to change the base?
Include Constructor to be a part of CommandListInterface
API, extend inline documentation
#37901
Conversation
Hi @engcom-Echo. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@api
to ensure backwards compatibilityCommandListInterface
API, extend inline documentation
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is the reference of the PR #29762, we have just changed the target branch to 2.4-develop from 2.5-develop.
Hence approving this PR to move forward.
Thanks
Hello @lbajsarowicz, Thanks for the contribution! ✔️ QA Passed As in this PR, the changes are related to making the There is nothing to reproduce in this issue but it is a good to have feature. Hence moving this PR further process. Due to SVC failure, moving this PR for approval. Thanks |
@magento run Functional Tests EE, Unit Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
Created an approval JIRA from approval of SVC failure. |
@magento run Semantic Version Checker |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lbajsarowicz,
Please have a look into the below review comment. The change has been suggested by the internal team due to BiC.
Thanks
*/ | ||
public function getCommands() | ||
public function getCommands(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this return type as this change is Backward incompatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it make sense to slowly add in type hinting like this? PHP 5.3 is quite some time ago. And you can always add stronger typing to a class without breaking the interface. As I see it, nothing is breaking backward compatibility here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jissereitsma, I guess this change breaks compatibility with existing code that:
- Calls getCommands() and expects a return type other than an array.
- Extends or implements the
CommandList
class orCommandListInterface
without updating overridden/implemented methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether these arguments make sense. Yes, indeed somebody could create a DI plugin and return a string from the getCommands()
method. But that will break the entire Magento CLI anyway! The same way counts for rewriting the CommandList
class or CommandListInterface
interface. So, the choice is between opting for the possibility that somebody has hacked the Magento core to an extend where the CLI does not work properly anymore, or sticking to modern-day PHP standards. I would opt for the future instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calls getCommands() and expects a return type other than an array.
It was always returning an erray, so no code can expect it
Extends or implements the CommandList class or CommandListInterface without updating overridden/implemented methods.
Technically you’re right, but if we’ll treat all changes as this - we can’t add return types to anywhere --> we’ll never have strict types
Since this class was previously not marked as API, we can still change its interface.
But after merging this PR, we can’t. So I suggest adding the return type now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ihor-sviziev & @jissereitsma,
Let me discuss this with the internal team. Meanwhile moving this PR On Hold
.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ihor-sviziev & @jissereitsma,
We got reply from the internal team, according to them adhering to BIC checks should remain the standard unless there is a highly compelling justification to deviate from it. In this instance, I don't find the justification sufficiently convincing.
@magento run all tests |
@lbajsarowicz as per our discussion over Slack, I worked on the review comments & failed static cases. @engcom-Hotel Could you please review it? Thanks! |
@engcom-Dash, we still have not resolved discussion #37901 (comment), let's agree on the final version before moving to review |
Description (*)
This PR is copy of 29762. As in original PR target branch was 2.5-develop we have modified to point to 2.4-develop.
In my personal opinion usingCommandListInterface
is invalid way of adding new Commands to interface.It is because Constructor is not a part of Interface (Service Contract), thus it is not "guaranteed" part of Interface.
UsingCommandList
is against Magento rules, thus it's implementation is not guaranteed and can change in backwards-incompatible way.I'm extending theCommandList
with@api
to ensure developers that this class won't change backwards-incompatible way and this way - they can either add new classes using:Argument injection toCommandList
classPlugin ongetCommands
onCommandListInterface
.I'd love to get your feedback there.After discussion with @kandy I decided to add the
__construct()
to the API.Answering the main concerns: https://3v4l.org/8ug8i

As it affects you (community) I need your 👍🏻 or comments to pass the change:

Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)
Thanks
Resolved issues:
CommandListInterface
API, extend inline documentation #31102: Include Constructor to be a part ofCommandListInterface
API, extend inline documentation