Skip to content
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

fix: Restore the previous IO::getArgument() and ::getOption() behaviour #183

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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