From 813e9a1154f1a8e8ace8158c407ffbae8d37e8b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20FIDRY?=
<5175937+theofidry@users.noreply.github.com>
Date: Sat, 14 Oct 2023 12:37:40 +0200
Subject: [PATCH] fix: Restore the previous `IO::getArgument()` and
`::getOption()` (#183)
behaviour
---
psalm.xml | 6 ++++++
src/Deprecation.php | 41 +++++++++++++++++++++++++++++++++++++++++
src/IO.php | 26 ++++++++++++++++++++++++++
src/Input/IO.php | 5 ++---
4 files changed, 75 insertions(+), 3 deletions(-)
create mode 100644 src/Deprecation.php
diff --git a/psalm.xml b/psalm.xml
index d40c6931..60ea1305 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -71,6 +71,12 @@
+
+
+
+
+
+
diff --git a/src/Deprecation.php b/src/Deprecation.php
new file mode 100644
index 00000000..45eaf63f
--- /dev/null
+++ b/src/Deprecation.php
@@ -0,0 +1,41 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Fidry\Console;
+
+use function trigger_deprecation;
+
+/**
+ * @codeCoverageIgnore
+ * @internal
+ */
+final class Deprecation
+{
+ /**
+ * @param string $message The message of the deprecation
+ * @param mixed ...$args Values to insert in the message using printf() formatting
+ */
+ public static function trigger(string $message, string $version, mixed ...$args): void
+ {
+ trigger_deprecation(
+ 'fidry/console',
+ $version,
+ $message,
+ $args,
+ );
+ }
+
+ private function __construct()
+ {
+ }
+}
diff --git a/src/IO.php b/src/IO.php
index ce4318ee..364cce4a 100644
--- a/src/IO.php
+++ b/src/IO.php
@@ -294,4 +294,30 @@ public function getTypedOption(string $name): TypedInput
$name,
);
}
+
+ /**
+ * @param non-empty-string $name
+ */
+ public function getArgument(string $name): TypedInput
+ {
+ Deprecation::trigger(
+ '::getArgument() will be reverted to return the traditional Symfony argument raw value. Use ::getTypedArgument() instead.',
+ '0.6.0',
+ );
+
+ return $this->getTypedArgument($name);
+ }
+
+ /**
+ * @param non-empty-string $name
+ */
+ public function getOption(string $name): TypedInput
+ {
+ Deprecation::trigger(
+ '::getArgument() will be reverted to return the traditional Symfony argument raw value. Use ::getTypedArgument() instead.',
+ '0.6.0',
+ );
+
+ return $this->getTypedOption($name);
+ }
}
diff --git a/src/Input/IO.php b/src/Input/IO.php
index 0d97857d..81cf050d 100644
--- a/src/Input/IO.php
+++ b/src/Input/IO.php
@@ -13,15 +13,14 @@
namespace Fidry\Console\Input;
+use Fidry\Console\Deprecation;
use function class_alias;
use function sprintf;
-use function trigger_deprecation;
$alias = \Fidry\Console\Input\IO::class;
$newClass = \Fidry\Console\IO::class;
-@trigger_deprecation(
- 'fidry/console',
+Deprecation::trigger(
'0.6.0',
sprintf(
'Using the class "%s" is deprecated. Use "%s" instead.',