-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] introduce __toString
method
annotation to InputInterface
#42056
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
Conversation
As a preparation for 6.0, we are adding `__toString` as method declaration. This avoids having BC-breaks in upstream projects as suggested by @wouterj. In 6.0, the `Stringable` interface will be implemented instead. Fixes symfony#42042 Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
__toString
method
annotation to InputInterface
__toString
method
annotation to InputInterface
Please add a changelog entry in the component. |
@nicolas-grekas 🤨 it already exists, I just added it to the interface. could you give me a little hint on how you expect that being documented? |
If we add the method, it means we're expect implementations to return something useful. |
src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php
Outdated
Show resolved
Hide resolved
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
ef230ca
to
7516c10
Compare
…when calling that method Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
…oString` method annotation Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
I've created a @derrabus I've added the return type-hint to the newly created method within the test-asset. |
Could you please open a PR on the |
So just to clarify so I understand the open TODOs: I have added exactly zero new functionality here and there are existing unit tests for those Regarding the docs - I will check that out tomorrow to see how this project is structured. Do you want me to add the description I've added to the interface to the documentation or do you have something specific in mind? |
@@ -18,6 +18,9 @@ | |||
* InputInterface is the interface implemented by all input classes. | |||
* | |||
* @author Fabien Potencier <fabien@symfony.com> | |||
* | |||
* @method string __toString() Returns a stringified representation of the args passed to the command. |
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.
AFAIK if someone does not implement this method, a deprecation is thrown.
I would like to have a test case which asserts this deprecation (a missing implementation) and has the "@group legacy".
Not sure I missed sth.
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'll see how to achieved that. Thanks for clarification.
The unit test to verify the deprecation should be part of the docs repo?
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 also adjust UPGRADE-5.4.md
and UPGRADE-6.0.md
. If we introduce a deprecation, it must be documented there.
@@ -5,6 +5,7 @@ CHANGELOG | |||
--- | |||
|
|||
* Add `TesterTrait::assertCommandIsSuccessful()` to test command | |||
* Add `InputInterface::__toString()` method annotation. This will be replaced by the extension of the `Stringable` interface in 6.0. |
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.
* Add `InputInterface::__toString()` method annotation. This will be replaced by the extension of the `Stringable` interface in 6.0. | |
* Add method `__toString()` to `InputInterface` |
Friendly ping @boesing |
Thanks for pinging me, @nicolas-grekas
so in the end, the amount of work I have to put into this is not aligned with the benefit of the outcome. Thank you all for the guiding, sorry if I wasted your time with this. |
@boesing writing a unit test that pass a Input implementation without |
@OskarStark Do you have time to take over? |
…` (boesing) This PR was merged into the 6.1 branch. Discussion ---------- [Console] Add method `__toString()` to `InputInterface` | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #42042 | License | MIT | Doc PR | - Continues #42056. No test added because adding one for the deprecation feels like testing DebugClassLoader, which is not the point here. Commits ------- 224f3e3 [Console] Add method `__toString()` to `InputInterface`
As a preparation for 6.0, we are adding
__toString
as method declaration. This avoids having BC-breaks in upstream projects as suggested by @wouterj.In 6.0, the
Stringable
interface will be implemented instead.Fixes #42042
If this feature will be accepted, I'm willing to create the PR for 6.0 which adds the
Stringable
interface. 👍🏼