Skip to content

Commit

Permalink
Fix FilepathNamespaceExtractor on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 20, 2015
1 parent 4156b80 commit f636c8b
Showing 1 changed file with 5 additions and 9 deletions.
Expand Up @@ -32,6 +32,10 @@ public function __construct(
*/
public function getTypeNameFromProjectPath($path)
{
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
return null;
}

$pathParts = explode(DIRECTORY_SEPARATOR, $path);
$rootNamespace = null;
while (count($pathParts) > 0) {
Expand All @@ -56,21 +60,13 @@ public function getTypeNameFromProjectPath($path)
return null;
}

if (pathinfo($pathParts[count($pathParts) - 1], PATHINFO_EXTENSION) !== 'php') {
return null;
}

if (count($pathParts) === 0) {
return null;
}

array_unshift($pathParts, $rootNamespace);

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

return pathinfo($typeName, PATHINFO_FILENAME);
return substr($typeName, 0, -strlen('.php'));
}

}

0 comments on commit f636c8b

Please sign in to comment.