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

Add AsCommand attributes to console commands #31

Merged
merged 2 commits into from
Nov 12, 2024
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
2 changes: 2 additions & 0 deletions src/Symfony/Command/ToggleGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
use SolidWorx\Toggler\ToggleInterface;
use function sprintf;
use function strpos;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'toggler:get', description: 'Get the status of a specific feature')]
class ToggleGetCommand extends Command
{
protected static $defaultName = 'toggler:get';
Expand Down Expand Up @@ -72,11 +74,11 @@
$context = [];

foreach ((array) $input->getOption('context') as $parameter) {
if (false === strpos(strval($parameter), '=')) {

Check failure on line 77 in src/Symfony/Command/ToggleGetCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.
throw new Exception(sprintf('The context "%s" is invalid. The format needs to be key=value', strval($parameter)));

Check failure on line 78 in src/Symfony/Command/ToggleGetCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.
}

[$key, $value] = explode('=', strval($parameter));

Check failure on line 81 in src/Symfony/Command/ToggleGetCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.

$context[$key] = $value;
}
Expand All @@ -92,7 +94,7 @@
$table->setHeaders($headers);

foreach ($features as $feature) {
$active = $this->toggle->isActive(strval($feature), $context);

Check failure on line 97 in src/Symfony/Command/ToggleGetCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.

$row = [
$feature,
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Command/ToggleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
use Symfony\Component\Console\Input\InputOption;
use function explode;
use function sprintf;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use function strpos;

#[AsCommand(name: 'toggler:list', description: 'List all the configured features')]
class ToggleListCommand extends Command
{
protected static $defaultName = 'toggler:list';
Expand Down Expand Up @@ -59,11 +61,11 @@
$context = [];

foreach ((array) $input->getOption('context') as $parameter) {
if (false === strpos(strval($parameter), '=')) {

Check failure on line 64 in src/Symfony/Command/ToggleListCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.
throw new Exception(sprintf('The context "%s" is invalid. The format needs to be key=value', strval($parameter)));

Check failure on line 65 in src/Symfony/Command/ToggleListCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.
}

[$key, $value] = explode('=', strval($parameter));

Check failure on line 68 in src/Symfony/Command/ToggleListCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $var of function strval expects bool|float|int|resource|string|null, mixed given.

$context[$key] = $value;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Command/ToggleSetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
use SolidWorx\Toggler\Storage\StorageInterface;
use SolidWorx\Toggler\Util;
use function sprintf;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'toggler:set', description: 'Change the status of a specific feature')]
class ToggleSetCommand extends Command
{
protected static $defaultName = 'toggler:set';
Expand Down
Loading