Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sniff to enforce naming conventions for namespace names #231

Open
jrfnl opened this issue Jun 12, 2023 · 0 comments
Open

Sniff to enforce naming conventions for namespace names #231

jrfnl opened this issue Jun 12, 2023 · 0 comments

Comments

@jrfnl
Copy link
Member

jrfnl commented Jun 12, 2023

Is your feature request related to a problem?

It would be nice to have a sniff which could check that the name in a namespace declarations complies with certain naming conventions.

The most common naming convention would probably be StudlyCaps/PascalCase, but supporting other naming conventions should also be considered.

Describe the solution you'd like

A new sniff with a choice of which naming convention to enforce.
The naming convention would need to be applied to each part of the namespace declaration.

Some examples:

// StudlyCaps/PascalCase.
namespace VendorName\PackageName\SubCategory\SubLevel; // OK.
namespace Vendor_Name\package_name\subCategory\sublevel; // Not OK.

// Camel_Caps with underscores.
namespace Vendor_Name\Package_Name\Sub_Category\Sub_Level; // OK.
namespace VendorName\package_name\subCategory\sublevel; // Not OK.

// snake_case.
namespace vendor_name\package_name\sub_category\sub_level; // OK.
namespace Vendor_Name\packageName\subCategory\Sublevel; // Not OK.

Additional context (optional)

Might be a good idea for the sniff to also check that each part of the name complies with the following additional conventions:

  • No leading underscore(s).
  • No trailing underscore(s).
namespace VendorName\PackageName\SubCategory\SubLevel; // OK.
namespace _VendorName\_PackageName__\SubLevel_; // Not OK.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant