Skip to content

Since 3.7.0 methods named empty are failing Squiz.Functions.FunctionDeclaration.Found #3613

@bburnichon

Description

@bburnichon

Describe the bug
A clear and concise description of what the bug is.

Code sample

<?php

namespace Foo;

class Foo
{
    public function empty(): bool
    {
        return true;
    }
}

Custom ruleset
Using PSR12 ruleset

To reproduce
Steps to reproduce the behavior:

  1. Create a file called Foo.php with the code sample above...
  2. Run phpcs --standard=psr12 Foo.php
  3. See error message displayed
$ ./vendor/bin/phpcs --standard=psr12 -s Foo.php 

FILE: /projects/PHPCS_Issue/Foo.php
-----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 7 | ERROR | Expected "function abc(...)"; found "function abc(...)"
   |       | (Squiz.Functions.FunctionDeclaration.Found)
-----------------------------------------------------------------------------------------------------------------

Time: 49ms; Memory: 14MB

Expected behavior
No error should occur. It wasn't with previous version

Versions (please complete the following information):

  • OS: Linux
  • PHP: 7.4
  • PHPCS: 3.7.0
  • Standard: PSR12

Additional context
Detected by my CI when upgrading PHPCodesniffer to latest release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions