Skip to content

Enforce "self" usage #88

Description

@aik099

Detect class name usage inside that class declaration and suggest replacing it with self.

<?php

class TheExample
{
    const EXAMPLE = 1;

    public function createMe()
    {
        $instance = new TheExample();
        $constant = TheExample::EXAMPLE;
    }

}

Original idea came from Phabricator Xphast, where sniff was called Self Class Reference and in there only new ClassName constructs were checked. Error message was:

Use `self` to instantiate the current class.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions