Skip to content

Show error when class name does not match the containing file name #609

@jrmajor

Description

@jrmajor

Sometimes I rename a class but forget to rename the file. The editor does not warn me about it, but it results in a runtime error, since the class now cannot be autoloaded correctly. PhpStorm has such warning and I miss it after switching to VS Code.

Edit: The error I've described above is for classname–filename discrepancy. Directory–namespace discrepancy should also be validated. In such cases, PhpStorm shows a „namespace doesn't match the PSR-0/PSR-4 project structure” error.

Would also be nice if there were automatic fixes for that: “rename class”/“rename file” and “change namespace to match folder structure”/“move file to correct directory”.

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