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

No classes should DSL #315

Open
pfazzi opened this issue Nov 22, 2022 · 0 comments · May be fixed by #316
Open

No classes should DSL #315

pfazzi opened this issue Nov 22, 2022 · 0 comments · May be fixed by #316

Comments

@pfazzi
Copy link
Collaborator

pfazzi commented Nov 22, 2022

Feature Request

I would enforce a rule on a deprecated namespace.

Q A
New Feature yes
RFC yes
BC Break no

Summary

I would like to have a DSL like this:

Rule::noClass()
  ->should(new ResideInOneOfTheseNamespaces(
      "Prima\Service",
      "Prima\Entity"
  ))->because("Those namespaces have been deprecated in favor of the new modular architecture");

This rule is already implementable in the following way:

Rule::allClasses()
  ->that(new ResideInOneOfTheseNamespaces(
      "Prima\Service",
      "Prima\Entity"
  ))->should(
      new NotResideInTheseNamespaces(
          "Prima\Service",
          "Prima\Entity"
      )
  )->because("Those namespaces have been deprecated in favor of the new modular architecture");

But it looks awkward to me to read.

Furthermore, it would be easier to express rules like the following:

Rule::noClass()
  ->should(new HaveNameMatching("*Manager"))
  ->because("of our naming convention services should be named with a more self-explanatory name");

What do you think?

@pfazzi pfazzi linked a pull request Nov 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant