Skip to content

Commit 9ac52c6

Browse files
Update src/Routing/RouteScanner.php
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 795976e commit 9ac52c6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Routing/RouteScanner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ protected function scanMethod(
159159
protected function findClassesInDirectory( string $directory, string $namespace ): array
160160
{
161161
$classes = [];
162+
$directory = rtrim( $directory, '/\\' );
162163
$iterator = new \RecursiveIteratorIterator(
163164
new \RecursiveDirectoryIterator( $directory )
164165
);
@@ -167,9 +168,13 @@ protected function findClassesInDirectory( string $directory, string $namespace
167168
{
168169
if( $file->isFile() && $file->getExtension() === 'php' )
169170
{
170-
$relativePath = str_replace( $directory . '/', '', $file->getPathname() );
171+
$relativePath = str_replace(
172+
$directory . DIRECTORY_SEPARATOR,
173+
'',
174+
$file->getPathname()
175+
);
171176
$relativePath = str_replace( '.php', '', $relativePath );
172-
$className = $namespace . '\\' . str_replace( '/', '\\', $relativePath );
177+
$className = $namespace . '\\' . str_replace( DIRECTORY_SEPARATOR, '\\', $relativePath );
173178

174179
if( class_exists( $className ) )
175180
{

0 commit comments

Comments
 (0)