Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@gsherwood

Description

@gsherwood
Issue body actions

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)

zlodeszlodes

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.