Skip to content

ReferenceUsedNamesOnly does not detect references without leading "\" namespace separator #1570

@klausi

Description

@klausi

Hi, not sure if this is a bug or intended behavior. Give this test file:

<?php

$x = new Vendor\DateTools\Erm();

and executing

./vendor/bin/phpcbf --standard=SlevomatCodingStandard --sniffs=SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly Test.php

I would expect this to be fixed to

<?php
use Vendor\DateTools\Erm;

$x = new Erm();

Am I missing something why this does not work?

Background: trying to replace Drupal Coder's custom use statement sniff with your upstream code to avoid maintaining it in pfrenssen/coder#199

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions