Skip to content

PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument #2895

Closed
@gsherwood

Description

@gsherwood

I have a problem.
Using 3.5.4 with PHP 7.4.2.

Code example:

<?php

declare(strict_types=1);

namespace Examples;

class ExampleClass
{
    public function doSomething(): void
    {
        print_r($this->filter());
    }

    private function cleanString(string $string, string $except): string
    {
        return str_replace($except, '', $string);
    }

    /**
     * @return array|string[]
     */
    private function filter(): array
    {
        $stringValues = [
            'foo',
            'bar',
        ];

        return array_filter(
            $stringValues,
            fn (string $value): string => $this->cleanString($value, 'b')
        );
    }
}
# vagrant @ homestead in ~/projects/php-quality-tools [14:00:15] C:2
$ ./vendor/bin/phpcs --version
PHP_CodeSniffer version 3.5.4 (stable) by Squiz (http://www.squiz.net)

# vagrant @ homestead in ~/projects/php-quality-tools [14:00:17]
$ ./vendor/bin/phpcs --standard="PSR2" testo.php -s

FILE: /home/vagrant/projects/php-quality-tools/testo.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------
 31 | ERROR | [x] Only one argument is allowed per line in a multi-line function call
    |       |     (PSR2.Methods.FunctionCallSignature.MultipleArguments)
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Time: 209ms; Memory: 6MB

Originally posted by @zlodes in #2523 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions