Skip to content

Can't use empty, isset, unset as method names #3614

@pchapl

Description

@pchapl

Describe the bug
When empty (or isset, unset) is used as method name, phpcs doesn't recognize it and produce weird error messages

Code sample

<?php

declare(strict_types=1);

namespace App;

abstract class Temp
{
    abstract public function empty(): void;
    abstract public function isset(): void;
    abstract public function unset(): Temp; // <- another error for CamelCased return type
}

To reproduce

  1. Create a file called Temp.php with the code sample above...
  2. Run phpcs Temp.php ...
  3. See error message displayed
FILE: Temp.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
  9 | ERROR | Expected "function abc(...)"; found "function abc(...)"
 10 | ERROR | Expected "function abc(...)"; found "function abc(...)"
 11 | ERROR | Method name "Temp::Temp" is not in camel caps format
 11 | ERROR | Expected "function abc(...)"; found "function abc(...)"
----------------------------------------------------------------------

Expected behavior
No errors OR message about inappropriate method name

Versions (please complete the following information):

  • OS: Linux 5.17.12-200.fc35.x86_64
  • PHP: 8.1.7
  • PHPCS: 3.7.0
  • Standard: PSR12

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