Debugger/src/SourceLocationResolver.php
public function resolve(SourceLocation $location)
    {
        $origPath = str_replace('/', DIRECTORY_SEPARATOR, $location->path());
        $basename = basename($origPath);
        $prefixes = $this->searchPrefixes($origPath);

        $includePaths = array_filter($this->includePaths, function ($path) {
            return file_exists($path);
        });

        // Phase 1: search for an exact file match and try stripping off extra
        // folders
        foreach ($prefixes as $prefix) {
            foreach ($includePaths as $path) {
                $file = implode(DIRECTORY_SEPARATOR, [$path, $prefix, $basename]);
                if (file_exists($file)) {
                    return new SourceLocation($this->realRelativePath($file, $path), $location->line());
                }
            }
        }

        // Phase 2: recursively search folders for a matching file
        foreach ($includePaths as $includePath) {
            $iterator = new MatchingFileIterator(
                $includePath,
                $origPath
            );
            foreach ($iterator as $file => $info) {
                return new SourceLocation($this->realRelativePath($file, $includePath), $location->line());
            }
        }

        return null;
    }
public function resolve(SourceLocation $location)
    {
        $origPath = str_replace('/', DIRECTORY_SEPARATOR, $location->path());
        $basename = basename($origPath);
        $prefixes = $this->searchPrefixes($origPath);

        $includePaths = array_filter($this->includePaths, function ($path) {
            return file_exists($path);
        });

        // Phase 1: search for an exact file match and try stripping off extra
        // folders
        foreach ($prefixes as $prefix) {
            foreach ($includePaths as $path) {
                $file = implode(DIRECTORY_SEPARATOR, [$path, $prefix, $basename]);
                if (file_exists($file)) {
                    return new SourceLocation($this->realRelativePath($file, $path), $location->line());
                }
            }
        }

        // Phase 2: recursively search folders for a matching file
        foreach ($includePaths as $includePath) {
            $iterator = new MatchingFileIterator(
                $includePath,
                $origPath
            );
            foreach ($iterator as $file => $info) {
                return new SourceLocation($this->realRelativePath($file, $includePath), $location->line());
            }
        }

        return null;
    }
public function resolve ( SourceLocation $ location ) { $ origPath = str_replace ( '/' , DIRECTORY_SEPARATOR , $ location -> path ( ) ) ; $ basename = basename ( $ origPath ) ; $ prefixes = $ this -> searchPrefixes ( $ origPath ) ; $ includePaths = array_filter ( $ this -> includePaths , function ( $ path ) { return file_exists ( $ path ) ; } ) ; // Phase 1: search for an exact file match and try stripping off extra // folders foreach ( $ prefixes as $ prefix ) { foreach ( $ includePaths as $ path ) { $ file = implode ( DIRECTORY_SEPARATOR , [ $ path , $ prefix , $ basename ] ) ; if ( file_exists ( $ file ) ) { return new SourceLocation ( $ this -> realRelativePath ( $ file , $ path ) , $ location -> line ( ) ) ; } } } // Phase 2: recursively search folders for a matching file foreach ( $ includePaths as $ includePath ) { $ iterator = new MatchingFileIterator ( $ includePath , $ origPath ) ; foreach ( $ iterator as $ file => $ info ) { return new SourceLocation ( $ this -> realRelativePath ( $ file , $ includePath ) , $ location -> line ( ) ) ; } } return null ; }
Resolve the full path of an existing file in the application's source.
If no matching source file is found, then return null. If found, the
resolved location will include the full, absolute path to the source
file.

There are 3 cases for resolving a SourceLocation:

Case 1: The exact path is found

Example:
```
$location = new SourceLocation('Debugger/src/DebuggerClient.php', 1);
$resolver = new SourceLocationResolver();
$resolvedLocation = $resolver->resolve($location);
```

Case 2: There are extra folder(s) in the requested breakpoint path

Example:
```
$location = new SourceLocation('extra/folder/Debugger/src/DebuggerClient.php', 1);
$resolver = new SourceLocationResolver();
$resolvedLocation = $resolver->resolve($location);
```

Case 3: There are fewer folders in the requested breakpoint path

Example:
```
$location = new SourceLocation('src/DebuggerClient.php', 1);
$resolver = new SourceLocationResolver();
$resolvedLocation = $resolver->resolve($location);

@param SourceLocation $location The location to resolve.
@return SourceLocation|null
Resolve the full path of an existing file in the application s source . If no matching source file is found then return null . If found the resolved location will include the full absolute path to the source file .