Skip to content

Methods/constants with name empty/isset/unset are always reported as error #3609

Closed
@dlakomski

Description

@dlakomski

Describe the bug
PHPCS considers methods with name empty to be incorrect

Code sample

<?php

declare(strict_types=1);

namespace App;

class Foo
{
    public function empty()
    {
        return;
    }
}

Custom ruleset
No custom rules. Just PSR12 standard

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs --standard=PSR12 test.php
  3. See error message displayed
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | Expected "function abc(...)"; found "function abc(...)"
----------------------------------------------------------------------

If you change method name to basically anything else - empty1, createEmpty etc - there is no error

Expected behavior
No complains.

Versions (please complete the following information):

  • OS: Ubuntu 20.04
  • PHP: 8.1.6
  • PHPCS: 3.7.0
  • Standard: PSR12

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