Skip to content

Commit 6bb2989

Browse files
Fix findModuleRoot to handle directory paths correctly
Co-authored-by: robertvansteen <14931924+robertvansteen@users.noreply.github.com>
1 parent dd17c24 commit 6bb2989

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Rules/RestrictImplicitDependencyUsage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public function isRestrictedClassNameUsage(ClassReflection $classReflection, Sco
122122

123123
private function findModuleRoot(string $file): string
124124
{
125-
$dir = dirname($file);
125+
// Start from the file's directory, or the path itself if it's already a directory
126+
$dir = is_dir($file) ? $file : dirname($file);
127+
126128
while ($dir !== '/') {
127129
if (file_exists($dir . '/composer.json')) {
128130
return $dir;

0 commit comments

Comments
 (0)