From fedb755378c4f95127824294d83dd3d2425e6bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 11 Jul 2021 12:26:00 +0200 Subject: [PATCH 1/5] feature: introduce `__toString` `method` annotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/Symfony/Component/Console/Input/InputInterface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index d01da852fc6f1..8c01bbd60dc90 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -18,6 +18,8 @@ * InputInterface is the interface implemented by all input classes. * * @author Fabien Potencier + * + * @method string __toString() */ interface InputInterface { From e59336dbd41f6d5be2d99ddeb9da365c470486e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 11 Jul 2021 12:35:48 +0200 Subject: [PATCH 2/5] qa: add `__toString` to test asset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- .../Console/Tests/EventListener/ErrorListenerTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php index 2bafab040f8b6..e34d7f7826533 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php @@ -143,4 +143,9 @@ public function getParameterOption($values, $default = false, $onlyParams = fals public function parse() { } + + public function __toString() + { + return ''; + } } From f93f3f18571172cb5eb52957274ea0861a353163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:48:30 +0200 Subject: [PATCH 3/5] qa: add return type to test asset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- .../Component/Console/Tests/EventListener/ErrorListenerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php index e34d7f7826533..01f08a2b24d82 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php @@ -144,7 +144,7 @@ public function parse() { } - public function __toString() + public function __toString(): string { return ''; } From 246e081ca224f61f577b51b19018064e70c82410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:49:05 +0200 Subject: [PATCH 4/5] documentation: add `__toString` method description on what to expect when calling that method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/Symfony/Component/Console/Input/InputInterface.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index 8c01bbd60dc90..12250d3e51c0e 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -19,7 +19,8 @@ * * @author Fabien Potencier * - * @method string __toString() + * @method string __toString() Returns a stringified representation of the args passed to the command. + * InputArguments MUST be escaped as well as the InputOption values passed to the command. */ interface InputInterface { From 7516c10e1457f98a2a75d577eb0f02dbbc6d7480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:50:32 +0200 Subject: [PATCH 5/5] documentation: add `CHANGELOG` entry for the new `InputInterface::__toString` method annotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/Symfony/Component/Console/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index c8180dcc7911c..dab5a53dd838d 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -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. 5.3 ---