Doc #66897 [Opn->Ana]: stream_set_read_buffer / stream_set_write_buffer return EOF

From: Date: Wed, 22 Jul 2015 21:24:29 +0000
Subject: Doc #66897 [Opn->Ana]: stream_set_read_buffer / stream_set_write_buffer return EOF
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12541@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66897&edit=1 ID: 66897 Updated by: cmb@php.net Reported by: php-bugs at allenjb dot me dot uk Summary: stream_set_read_buffer / stream_set_write_buffer return EOF -Status: Open +Status: Analyzed Type: Documentation Problem -Package: Documentation problem +Package: Streams related -Operating System: +Operating System: * -PHP Version: Irrelevant +PHP Version: n/a -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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> Previous Comments: ------------------------------------------------------------------------ [2014-03-13 10:02:33] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66897&edit=1

« previous php.doc.bugs (#12541) next »