Skip to content

ReservedFunctionNames: ignore deprecated methods by design #911

@jrfnl

Description

@jrfnl

Functions and methods should not use a double underscore prefix in the function name as all functions and methods with that prefix are reserved by PHP Core.

When a (public/protected) method/function is renamed, however, it breaks backward-compatibility, so it is common to deprecate the old method name and add a new method with a name which does comply.

I'm proposing that if a function/method is marked as deprecated in the function docblock, that the sniff should not throw an error.

class Example {
    public function newName() {
    }

    /**
     * @deprecated x.x.x Use Example::new_Name() instead.
     */
    public function __oldName() {
        return self::newName();
    }
}

Currently the sniff would throw an error for the __oldName() method. Once this enhancement has been implemented, it no longer should.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions