Bug->Req #75836 [Opn->Csd]: fwrite() should accept null for chunk size
Edit report at https://bugs.php.net/bug.php?id=75836&edit=1
ID: 75836
Updated by: cmb@php.net
Reported by: kelunik@php.net
Summary: fwrite() should accept null for chunk size
-Status: Open
+Status: Closed
-Type: Bug
+Type: Feature/Change Request
Package: Streams related
PHP Version: 7.2.1
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
All mentioned parameters are nullable as of PHP 8.0.0.
Previous Comments:
------------------------------------------------------------------------
[2018-01-19 08:04:49] spam2 at rhsoft dot net
bad idea - the param is defined as int which means in weak mode it will be casted and NULL becomes 0
(what you don't want) while with strict_types it is a fatal error to pass NULL - that is the
expected behavior from each and every function and should stay consistent
------------------------------------------------------------------------
[2018-01-18 23:50:18] cmb@php.net
> How would that be a BC break?
Presently, passing NULL as third parameter to fwrite() causes
nothing to be written. If I understand you correctly, you want
that to change so that the whole $string is written instead.
------------------------------------------------------------------------
[2018-01-18 20:09:33] kelunik@php.net
How would that be a BC break?
------------------------------------------------------------------------
[2018-01-18 17:13:52] cmb@php.net
> fwrite() should accept null for chunk size
That would constitute a BC break, though.
> for an example where this is annoying.
$written = @\fwrite($stream, $data, $chunkSize ?: $length);
------------------------------------------------------------------------
[2018-01-17 18:57:25] daverandom@php.net
Additional filesystem functions that have the same or similar problems:
Optional $context arg emits warning when explicit NULL is passed to all of: copy(), mkdir(),
rename(), rmdir(), unlink()
fgetss(), fgets() - NULL passed to $length is cast to int(0), emits warning
file_get_contents() - NULL passed to $maxlen results in empty string returned
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=75836
--
Edit this bug report at https://bugs.php.net/bug.php?id=75836&edit=1
Thread (7 messages)