-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue #52 #54
Fix issue #52 #54
Conversation
@oruborus I used your code on a Laravel 10 project is using this repo: https://github.com/nunomaduro/mock-final-classes |
Just to add an argument for this approach: "The problem is caused by an incorrectly written handler, the solution is to fix the handler, not this library." Originally posted by @dg in #45 (comment) I agree with the statement that error handlers should be correctly setup. But in this special case #define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS || (__t) == FS_IS_W || (__t) == FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || (__t) == FS_IS_LINK || (__t) == FS_LPERMS)
// in php_stat()
if (IS_EXISTS_CHECK(type)) {
flags |= PHP_STREAM_URL_STAT_QUIET;
}
// ...
if (ZSTR_LEN(filename) && !IS_EXISTS_CHECK(type)) {
php_error_docref(NULL, E_WARNING, "Filename contains null byte");
}
// ...
if (!IS_EXISTS_CHECK(type)) {
php_error_docref(NULL, E_WARNING, "%sstat failed for %s", IS_LINK_OPERATION(type) ? "L" : "", ZSTR_VAL(filename));
} https://github.com/php/php-src/blob/fd73681c86bb69163abacc202f96306864f82cbe/ext/standard/filestat.c#L702 If we can observe |
This adds `file_exists`, `is_writable`, `is_readable`, `is_executable`, `is_file` and `is_link` to the test.
I am currently revising my aproach. I am positive that this could be achived with the only caveat that some of the overloaded functions will trigger an |
Really curious what will come out here - Your fork does work and I hope the changes will be merged to the original repo or at least an alternative solution (like example configuration like phpunit.xml.dist) can be provided for this issue |
@oruborus Thanks for the beautifully crafted PR, rationale and solution. |
Suppresses warning triggered by `stat`/`lstat` when file does not exit. By injecting another error handler which resets error reporting the suppressed warning gets caught and does not appear in error logs. As certain testing frameworks establish error handlers to pick up on suppressed errors, exceptions and warnings, the warning generated by `stat`/`lstat` when provided an unknown path is recorded.
Suppresses warning triggered by `stat`/`lstat` when file does not exit. By injecting another error handler which resets error reporting the suppressed warning gets caught and does not appear in error logs. As certain testing frameworks establish error handlers to pick up on suppressed errors, exceptions and warnings, the warning generated by `stat`/`lstat` when provided an unknown path is recorded.
Suppresses warning triggered by `stat`/`lstat` when file does not exit. By injecting another error handler which resets error reporting the suppressed warning gets caught and does not appear in error logs. As certain testing frameworks establish error handlers to pick up on suppressed errors, exceptions and warnings, the warning generated by `stat`/`lstat` when provided an unknown path is recorded.
Suppresses warning triggered by
stat
/lstat
when file does not exit.By injecting another error handler which resets error reporting the suppressed warning gets caught and does not appear in error logs.