Skip to content

Commit

Permalink
Skip check for negatable input options on symfony/console < 5.3
Browse files Browse the repository at this point in the history
Related: #300
  • Loading branch information
eliashaeussler authored and ondrejmirtes committed Aug 26, 2022
1 parent a14d467 commit e7767d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
@@ -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
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

0 comments on commit e7767d9

Please sign in to comment.