reactphp / filesystem

Evented filesystem access.
MIT License
135 stars 40 forks source link

Fix file stat for cases when file doesn't exist #19

Closed seregazhuk closed 6 years ago

seregazhuk commented 6 years ago

When calling exists() or stat() on file object and a specified file doesn't exists the code fails. The reason is that everywhere in React\Filesystem\WoolTrait for rejecting promises is being used error_get_last() function. But when checking for existence you specify a custom array that has some different structure than the result of error_get_last(). In this case here it fails:

https://github.com/reactphp/filesystem/blob/master/src/ChildProcess/Adapter.php#L134

because there is no such key as message.

clue commented 6 years ago

@seregazhuk Thanks for reporting! I'm not too familiar with this particular code, can we add a test for this? :+1:

seregazhuk commented 6 years ago

@clue Done! I was a bit confused because the test for this use case already exists. But it only checks that the promise rejects. So, when the code fails, the promise rejects as it was expected in the test but with Illegal string offset 'message' message. I've updated the test to check the rejection reason of the promise.

WyriHaximus commented 6 years ago

@clue yeah it is an functional test that fails (works on my machine) so I'm working on it in my labs fork to find out how to fix it.