Skip to content

No classes should DSL #315

Description

@pfazzi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions