Skip to content

Commit f636c8b

Browse files
committed
Fix FilepathNamespaceExtractor on Windows
1 parent 4156b80 commit f636c8b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

SlevomatCodingStandard/Sniffs/Files/FilepathNamespaceExtractor.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public function __construct(
3232
*/
3333
public function getTypeNameFromProjectPath($path)
3434
{
35+
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
36+
return null;
37+
}
38+
3539
$pathParts = explode(DIRECTORY_SEPARATOR, $path);
3640
$rootNamespace = null;
3741
while (count($pathParts) > 0) {
@@ -56,21 +60,13 @@ public function getTypeNameFromProjectPath($path)
5660
return null;
5761
}
5862

59-
if (pathinfo($pathParts[count($pathParts) - 1], PATHINFO_EXTENSION) !== 'php') {
60-
return null;
61-
}
62-
63-
if (count($pathParts) === 0) {
64-
return null;
65-
}
66-
6763
array_unshift($pathParts, $rootNamespace);
6864

6965
$typeName = implode('\\', array_filter($pathParts, function ($pathPart) {
7066
return !isset($this->skipDirs[$pathPart]);
7167
}));
7268

73-
return pathinfo($typeName, PATHINFO_FILENAME);
69+
return substr($typeName, 0, -strlen('.php'));
7470
}
7571

7672
}

0 commit comments

Comments
 (0)