keboola / php-component

General library for PHP applications running in Keboola Connection environment
MIT License
0 stars 1 forks source link

Example config definition is not passing by PHPStan #8

Closed jakubbartel closed 6 years ago

jakubbartel commented 6 years ago

Config definition example in README:

class MyConfigDefinition extends \Keboola\Component\Config\BaseConfigDefinition
{
    protected function getParametersDefinition()
    {
        $parametersNode = parent::getParametersDefinition();
        $parametersNode
            ->isRequired()
            ->children()
                ->arrayNode('errorCount')
                    ->isRequired()
                    ->children()
                        ->integerNode('maximumAllowed')
                            ->isRequired();
        return $parametersNode;
    }
}

Due to return types (annotation) of BaseConfigDefinition::getParametersDefinition() PHPStan asserts following error

> phpstan analyse ./src ./tests --level=max --no-progress -c phpstan.neon
 ------ -------------------------------------------------------------------------
  Line   src/Keboola/OneDriveExtractor/ConfigDefinition.php
 ------ -------------------------------------------------------------------------
  19     Call to an undefined method
         Symfony\Component\Config\Definition\Builder\NodeDefinition::children().
 ------ -------------------------------------------------------------------------

 [ERROR] Found 1 error
jakubbartel commented 6 years ago

Ou, phpstan.neon in this library gives the answer. One needs to add the following ignore to the project's phpstan.neon:

parameters:
    ignoreErrors:
    - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\).#'

It would be nice to add this into README :)

tomasfejfar commented 6 years ago

Oh, sorry about that.

I was already aware of this issue (https://github.com/phpstan/phpstan/issues/844), but forgot to mention it in README.