Using Rector for checking namespace isolation #7110
dorrogeray
started this conversation in
Ideas
Replies: 2 comments 5 replies
|
Hi, thanks for the question. Rector is rather A → B refacotring tool. What you look for is reporting tool - PHPStan. It does not specifically check the namespaces, but you can easily extend to handle that. |
2 replies
|
@dorrogeray With deptrac you can configure advanced rules for that and even generate an image of your dependencies and errors in the dependencies of one layer on the other layer. |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I would like to create a tool which will enforce a rule where only classes from specified namespaces are allowed in some namespaces. Something along the lines of:
App\Services\<SomeNameSpace>\**App\Services\<SomeNameSpace>\**App\Models\<SomeNameSpace>\**App\Exceptions\**This would mean that any class inside
App\Services\<SomeNameSpace>\**namespace could only use classes from following namespaces (+vendor):App\Services\<SomeNameSpace>\**App\Models\<SomeNameSpace>\**App\Exceptions\**If a violation is found, it would be reported.
I like the power of Rector very much, but I am not sure if it makes sense to try to implement this as a rector rule. These violations will not be something that can be fixed automatically, only thing I can think of is Rector adding comments like
// WARNING: Usage of class XXX in namespace YYY is not allowed, but it seems a bit obnoxious.What do you think, should I try to create a dedicated tool or is there a way to fit this rule into rector in some reasonable fashion?
Thanks for your feedback!
All reactions