You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the README, you're using each expression FQCN directly.
What I've done is add an alias to the ForClasses namespace, allowing me to use expressions without cluttering up the import map, this convention is used in Symfony for attributes from Doctrine, Validator, Serializer, etc.
My config file
<?phpdeclare(strict_types=1);
useArkitect\ClassSet;
useArkitect\CLI\Config;
useArkitect\Expression\ForClassesasAssert;
useArkitect\Rules\Rule;
returnstaticfunction (Config$config): void {
$src = ClassSet::fromDir(__DIR__.'/src');
$naming = [
Rule::allClasses()
->that(newAssert\IsInterface())
->should(newAssert\NotHaveNameMatching('*Interface'))
->because('we do not use the Interface suffix for interfaces'),
Rule::allClasses()
->that(newAssert\IsAbstract())
->should(newAssert\HaveNameMatching('Abstract*'))
->because('we want abstract classes to have a Abstract prefix'),
Rule::allClasses()
->that(newAssert\IsTrait())
->should(newAssert\HaveNameMatching('*Trait'))
->because('we want traits to have a Trait suffix'),
Rule::allClasses()
->that(newAssert\ResideInOneOfTheseNamespaces('App'))
->should(newAssert\NotHaveNameMatching('*Manager'))
->because('*Manager is too vague in naming classes'),
];
$config->add($src, ...$naming);
};
The text was updated successfully, but these errors were encountered:
In the README, you're using each expression FQCN directly.
What I've done is add an alias to the
ForClasses
namespace, allowing me to use expressions without cluttering up the import map, this convention is used in Symfony for attributes from Doctrine, Validator, Serializer, etc.My config file
The text was updated successfully, but these errors were encountered: