phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

Task phpcs can not set config warning_severity to 0 #466

Closed Kanti closed 6 years ago

Kanti commented 6 years ago
Q A
Version 0.13.1
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets -

If I set warning_severity to 0 in my grumphp.yml than the argument --warning-severity is not given to the phpcs command.

parameters:
  tasks:
    phpcs:
      standard: "PSR2"
      warning_severity: 0
      tab_width: 4

Or with this Config:

parameters:
  tasks:
    phpcs:
      standard: "PSR2"
      warning_severity: "0"
      tab_width: 4

Result: Error: The option "warning_severity" with value "0" is expected to be of type "null" or "int", but is of type "string".

Steps to reproduce:

mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml
composer require --dev phpro/grumphp

# Run GrumpHP:
./vendor/bin/grumphp run
SerkanYildiz commented 6 years ago

Thanks, I will look into this.

lasselehtinen commented 6 years ago

Having the same issue. I would ignore the phpcs warnings in the older versions with "show_warnings: false" and I was scratching my head why "warning_severity: 0" is still reporting warnings.

jyrkidn commented 6 years ago

I have the same issue. I now changed the following in the PHPCS task:

if ($config['warning_severity'] !== null) {
    $arguments->add(sprintf('--warning-severity=%s', $config['warning_severity']));
}

I can make a pull request if this is a good solution.

veewee commented 6 years ago

@jyrkidn, The suggested solution seems OK. However, I would prefer to create a new method \GrumPHP\Collection\ProcessArgumentsCollection::addOptionalIntegerArgument() which performs the null check and adds the argument if it is not null. Feel free to create a PR.

lasselehtinen commented 6 years ago

Pull request created, hope it is done correctly.