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

[BUG] Class dependencies leak between files #389

Open
simivar opened this issue Jun 6, 2023 · 0 comments
Open

[BUG] Class dependencies leak between files #389

simivar opened this issue Jun 6, 2023 · 0 comments

Comments

@simivar
Copy link
Contributor

simivar commented Jun 6, 2023

Bug Report

Q A
BC Break -
Library Version main branch
PHP version 8.1.17

Summary

We are building our app as a modular monolith. We've defined a rule that each module can NOT depend on another module's namespace.

Rule::allClasses()
            ->that(new ResideInOneOfTheseNamespaces($namespace))
            ->should(new NotDependsOnTheseNamespaces(...$otherModulesNamespaces)
            ->because('modules should NOT share code between each-other');

Each module can define its routes in a dedicated routes.php file in its directory where we use Laravel to define our routes with static calls to, for example, Route::post(). It means there is no class definition in the routes.php file.

Today after creating a second module, we received an error that our Controller in Module A depends on Module B when there's no import, static call, method call, or anything between the two. After a quick investigation, we've discovered a leak of the dependencies list in FileVisitor if one of the files has no class defined.

Current behavior

Arkitect reports violations:

App\DependenciesLeak\SecondModule\SomeClass has 1 violations
  depends on App\DependenciesLeak\FirstModule\Router, but should not depend on these namespaces: App\DependenciesLeak\FirstModule because modules should be independent (on line 7)

How to reproduce

Please see #388 for the code snippets.

Expected behavior

No violations are reported and dependencies are not leaked between files

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

No branches or pull requests

1 participant