Comments (8)
I've checked it again, and instead of @$this->native(), just put it into try-catch block and it will enough solution.
from bypass-finals.
@dg Is it possible to fix it soon? Your package is really useful, but without these changes I cannot use it anymore. :(
from bypass-finals.
That's strange that it doesn't work, because there is a test for that and it passes even in PHP 8.0
from bypass-finals.
public function url_stat(string $path, int $flags)
{
$func = $flags & STREAM_URL_STAT_LINK ? 'lstat' : 'stat';
return $flags & STREAM_URL_STAT_QUIET
? @$this->native($func, $path)
: $this->native($func, $path);
}
@PierwszyTV, current implementation url_stat uses error control operator "@" and gets PHP_STREAM_URL_STAT_QUIET flag for is_file function (see https://github.com/php/php-src/blob/master/ext/standard/filestat.c#L793)
So exception can't be thrown
Please provide more info for debug
from bypass-finals.
Finally I found a way how to reproduce a bug.
Try the following code:
(new SplFileInfo('filename'))->isFile()
Result: RuntimeException: stat(): stat failed for filename
SplFileInfo::isFile
can't throw an exception by guide (link)
@dg any thought how to resolve bug?
from bypass-finals.
Please check https://github.com/dg/bypass-finals/pull/34/files
from bypass-finals.
@dg This is indeed strange. With one liners on Windows with PHP 8.1.0
$ php -n -r 'require __DIR__ . "/vendor/autoload.php"; DG\BypassFinals::enable(); stat("filename");'
Warning: stat(): stat failed for filename in D:\Web\dev\bypass-finals\src\BypassFinals.php on line 247
Warning: stat(): stat failed for filename in Command line code on line 1
but
$ php -n -r 'require __DIR__ . "/vendor/autoload.php"; DG\BypassFinals::enable(); (new SplFileInfo("filename"))->isFile();'
Fatal error: Uncaught RuntimeException: stat(): stat failed for filename in D:\Web\dev\bypass-finals\src\BypassFinals.php:247
Stack trace:
#0 D:\Web\dev\bypass-finals\src\BypassFinals.php(247): stat('filename')
#1 D:\Web\dev\bypass-finals\src\BypassFinals.php(238): DG\BypassFinals->native('stat', 'filename')
#2 [internal function]: DG\BypassFinals->url_stat('filename', 6)
#3 Command line code(1): SplFileInfo->isFile()
#4 {main}
thrown in D:\Web\dev\bypass-finals\src\BypassFinals.php on line 247
Looks like an SPL throws an exception. Similar case described here: https://stackoverflow.com/questions/25296178/why-would-phps-stat-throw-a-runtimeexception
Didn't find any PHP bug.
from bypass-finals.
@milo It normally changes the error handler 🤦♂️ (in spl_directory.c)
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);\
php_stat(intern->file_name, func_num, return_value); \
zend_restore_error_handling(&error_handling); \
from bypass-finals.
Related Issues (20)
- Bypass finals not work because token `final` is elsewhere HOT 1
- Segmentation fault with 1.4.0 when running phpunit with code coverage HOT 6
- Bypassing finals does not work with PHPUnit's --order-by set to random HOT 1
- "Solution" is not compatible with PHPStan HOT 1
- Phpunit 10 doesn't works with bypass-finals HOT 6
- Support bypass readonly in PHP 82 HOT 17
- Doesn't work with amphp/process HOT 5
- Getting this on running my tests. HOT 3
- Causes issues passing descriptors to subprocesses HOT 5
- Warnings converted to ErrorExceptions make url_stat fail on non-existent files HOT 3
- New release HOT 1
- stat(): stat failed for vendor/pestphp/pest/src/Plugins/../../.temp/only.lock HOT 1
- Bypassing readonly properties without visibilty can change behavior HOT 1
- Unsure of the true cause, but enabling BypassFinals causes unrelated test to fail in our project HOT 4
- Cannot bootstrap extension because class DG\BypassFinals\PHPUnitExtension does not exist HOT 1
- stat(): stat failed for HOT 3
- PHPUnit 11 incompatibility HOT 5
- phpunit Depends attribute broken with BypassFinals and cache enabled HOT 1
- I got a warning message from `composer validate -A`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bypass-finals.