When you test your magento code with PHPStan then facing some issue for code qaulity like PHPStan: __construct() has parameter $components with no value type specified initerable type array.

Might be your code is like below:

PHP
    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        array $components = [],
        array $data = [],
    ) {
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }


And error like below:

Makefile
Method Vendor\Module\Ui\Component\Listing\Column\Category::__construct() has parameter $components with no value type specified in iterable type array.
💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type

Method Vendor\Module\Ui\Component\Listing\Column\Category::__construct() has parameter $data with no value type specified in iterable type array.
💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type

Method Vendor\Module\Ui\Component\Listing\Column\Category::prepareDataSource() has parameter $dataSource with no value type specified in iterable type array.
💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type

Method Vendor\Module\Ui\Component\Listing\Column\Category::prepareDataSource() return type has no value type specified in iterable type array.
💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type

We don’t know array format of $components and $data so we need to ingore this errors in phpstan-baseline.neon

Need to run below command for fix error:

ShellScript
vendor/bin/phpstan analyse   --configuration phpstan.neon   src/  --generate-baseline


I hope you like this solution.

Write A Comment