Skip to content

Commit

Permalink
fix: Restore the previous IO::getArgument() and ::getOption() (#183)
Browse files Browse the repository at this point in the history
behaviour
  • Loading branch information
theofidry authored Oct 14, 2023
1 parent f14dc99 commit 813e9a1
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
<file name="stubs/StyledOutput.php"/>
</errorLevel>
</MissingReturnType>

<MoreSpecificImplementedParamType>
<errorLevel type="suppress">
<file name="src/IO.php"/>
</errorLevel>
</MoreSpecificImplementedParamType>

<PossiblyUnusedMethod errorLevel="suppress"/>

Expand Down
41 changes: 41 additions & 0 deletions src/Deprecation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Fidry\Console package.
*
* (c) Théo FIDRY <[email protected]>
*
* 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()
{
}
}
26 changes: 26 additions & 0 deletions src/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 2 additions & 3 deletions src/Input/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down

0 comments on commit 813e9a1

Please sign in to comment.