php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66897 stream_set_read_buffer / stream_set_write_buffer return EOF
Submitted: 2014-03-13 10:02 UTC Modified: 2015-07-23 11:40 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: php-bugs at allenjb dot me dot uk Assigned: cmb (profile)
Status: Closed Package: Streams related
PHP Version: n/a OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php-bugs at allenjb dot me dot uk
New email:
PHP Version: OS:

 

 [2014-03-13 10:02 UTC] php-bugs at allenjb dot me dot uk
Description:
------------
The stream_set_read_buffer and stream_set_write_buffer functions are documented to return EOF on failure, but there is no EOF constant and there is no example of how to correctly check for this.

Expected result:
----------------
There should be a documented example of how to correctly check the return value of these functions.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-22 21:24 UTC] cmb@php.net
-Status: Open +Status: Analyzed -Package: Documentation problem +Package: Streams related -Operating System: +Operating System: * -PHP Version: Irrelevant +PHP Version: n/a -Assigned To: +Assigned To: cmb
 [2015-07-22 21:24 UTC] cmb@php.net
Well, looking at the code shows that the functions return either
zero or the value of the C constant EOF[1][2], which is AFAIK not
clearly defined by the C standards. glibc defines it as -1, but
other libraries may use some other value. So it seems best to
check for `=== 0` (success) resp. `!== 0` (failure).

Anyhow, it seems that it would have been more PHPish to return
TRUE on success, FALSE on failure, and NULL for argument
mismatches.

[1] <https://github.com/php/php-src/blob/php-5.6.11/ext/standard/streamsfuncs.c#L1426>
[2] <https://github.com/php/php-src/blob/php-5.6.11/ext/standard/streamsfuncs.c#L1489>
 [2015-07-23 11:40 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=337225
Log: corrected return value documentation (fixes #66897)
 [2015-07-23 11:40 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 [2015-07-23 11:40 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 03:01:28 2024 UTC