Doc #64139 [NEW]: Misleading warning in documentation of readdir

From: Date: Mon, 04 Feb 2013 11:09:28 +0000
Subject: Doc #64139 [NEW]: Misleading warning in documentation of readdir
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9504@lists.php.net to get a copy of this message
From: jens at bremmekamp dot com Operating system: Debian Squeeze, Ubuntu 12.10 PHP version: Irrelevant Package: Documentation problem Bug Type: Documentation Problem Bug description:Misleading warning in documentation of readdir Description: ------------ --- From manual page: http://www.php.net/function.readdir --- The documentation on readdir's return values is wrong for PHP >= 5.3. The warning correctly states that on failure readdir() may return boolean false or other values equivalent to boolean false. It then suggests to use type safe operators to check readdir's return values. The examples given follow this advice. In PHP >= 5.3 this makes no sense. If the return value of a function is not always boolean false, but just falsy, a type safe comparison will not give you any clue if the function failed or not. Witnessed in both 5.3.3-7+squeeze14 and 5.4.6-1ubuntu1.1. PLEASE NOTE: This is not a request to change readdir's return value behaviour. This is a DOCUMENTATION BUG for this specific function's documentation. Test script: --------------- <?php $handle = opendir('/non_existent_dir'); $filename = readdir($handle); // readdir() returns NULL instead of false if(false !== $filename) { unlink($filename); // fails, because $filename is null instead of false } ?> Expected result: ---------------- No warning for the unlink call. Actual result: -------------- PHP Warning: unlink(): No such file or directory in php shell code on line 2 -- Edit bug report at https://bugs.php.net/bug.php?id=64139&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64139&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64139&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64139&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64139&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64139&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64139&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64139&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64139&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64139&r=support Expected behavior: https://bugs.php.net/fix.php?id=64139&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64139&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64139&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64139&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64139&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64139&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64139&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64139&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64139&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64139&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64139&r=mysqlcfg

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