Skip to content

Response path always out of bounds on Windows #13

@wimski

Description

@wimski

ResponseBuilder:174 will always throw an exception on Windows even if the path is valid.

if (realpath(\dirname($file)) !== \dirname($file)) { throw new \RuntimeException(sprintf('Path to file "%s" is out of bounds.', $file)); }

This is because realpath in Windows will have backslashes as a directory separator between all directories, whereas dirname will only have backslashes for the part that's not already in the $file path.

realpath(\dirname($file)); // C:\dev\my-project\tests\stubs\responses\some-website.com\endpoint\123.get.mock \dirname($file); // C:\dev\my-project\tests\stubs\responses/some-website.com/endpoint/123.get.mock

Is there a reason for this specific condition instead of just file_exists()?

if (! file_exists($file)) { throw new \RuntimeException(sprintf('Path to file "%s" is out of bounds.', $file)); }

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions