Skip to content

Skip check for negatable input options on symfony/console < 5.3 #305

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

Merged
merged 1 commit into from
Aug 26, 2022
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
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
parameters:
ignoreErrors:
-
message: "#^Call to function method_exists\\(\\) with Symfony\\\\Component\\\\Console\\\\Input\\\\InputOption and 'isNegatable' will always evaluate to true\\.$#"
count: 1
path: src/Type/Symfony/GetOptionTypeHelper.php

-
message: "#^Accessing PHPStan\\\\Rules\\\\Methods\\\\CallMethodsRule\\:\\:class is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#"
count: 1
Expand Down
3 changes: 2 additions & 1 deletion src/Type/Symfony/GetOptionTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\UnionType;
use Symfony\Component\Console\Input\InputOption;
use function method_exists;

class GetOptionTypeHelper
{

public function getOptionType(Scope $scope, InputOption $option): Type
{
if (!$option->acceptValue()) {
if ($option->isNegatable()) {
if (method_exists($option, 'isNegatable') && $option->isNegatable()) {
return new UnionType([new BooleanType(), new NullType()]);
}

Expand Down