Open
Description
Description
I wonder why the file_put_contents
emitts a Exclusive locks are not supported for this stream
error and putting the very same stream into stream_supports_lock
does not return false
, but also errors.
The following code:
<?php
var_dump(stream_supports_lock("php://stdout"));
file_put_contents(
"php://stdout",
"x",
FILE_APPEND | LOCK_EX,
);
Resulted in this output:
$ php test.php
PHP Fatal error: Uncaught TypeError: stream_supports_lock(): Argument #1 ($stream) must be of type resource, string given in C:\dvl\Workspace\phpunit\test.php:3
Stack trace:
#0 C:\dvl\Workspace\phpunit\test.php(3): stream_supports_lock()
#1 {main}
thrown in C:\dvl\Workspace\phpunit\test.php on line 3
Fatal error: Uncaught TypeError: stream_supports_lock(): Argument #1 ($stream) must be of type resource, string given in C:\dvl\Workspace\phpunit\test.php:3
Stack trace:
#0 C:\dvl\Workspace\phpunit\test.php(3): stream_supports_lock()
#1 {main}
thrown in C:\dvl\Workspace\phpunit\test.php on line 3
But I expected this output instead:
$ php test.php
bool(false)
PHP Warning: file_put_contents(): Exclusive locks are not supported for this stream in C:\dvl\Workspace\phpunit\test.php on line 5
Warning: file_put_contents(): Exclusive locks are not supported for this stream in C:\dvl\Workspace\phpunit\test.php on line 5
might be a windows only error, because 3v4l.org does not report the same error
https://3v4l.org/98p6T
PHP Version
$ php -v
PHP 8.2.12 (cli) (built: Oct 24 2023 21:15:35) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
Operating System
windows11