Wildcard (asterisk) notation in Arch Plugin? #728
Replies: 6 comments
-
Hi @michael-rubel we are internally evaluating if it's worth to adopt this feature 😉 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Wildcards would be a useful feature in a project I'm working on. It is using nWidart/laravel-modules so files are scattered between namespaces, for example I've added a function to Pest.php which reads all module names from the directory, so the tests look like this: test('services', function () {
getModules()->each(
fn ($module) => expect("Modules\\{$module}\Services")
->classes()
->toHaveSuffix('Service')
);
}); Wildcard would make them much more concise: test('services')->expect("Modules\*\Services")->classes()->toHaveSuffix('Service'); |
Beta Was this translation helpful? Give feedback.
-
I second that, came to the repository to make the suggestion as well. Would be very useful in module-based architectures. Support for double-wildcard on uses(LazilyRefreshDatabase::class, Tests\TestCase::class)->in(
'../src/Feature/**/Tests/**/*Test.php',
); That would allow me to catch these tests files:
|
Beta Was this translation helpful? Give feedback.
-
When using a DDD folder structure, it would be well-needed to allow wildcards in the provided namespace because then the classes are not sorted by "type" but by domain. F.e. Actions are not located under |
Beta Was this translation helpful? Give feedback.
-
PR for non-globstar implementation: pestphp/pest-plugin-arch#12 |
Beta Was this translation helpful? Give feedback.
-
About
It seems that the arch plugin doesn't work with specifying wildcards (*) in the target.
I have different bounded contexts with the same architecture, like
App\BoundedContext\*\Infrastructure\Eloquent\Models
andApp\BoundedContext\*\Infrastructure\Repositories
, so we'll need to hardcode rules for each context individually.Any plans to address this?
Beta Was this translation helpful? Give feedback.
All reactions