#42032 [Opn->Csd]: Return value of dir() not tested in example code
| From: | vrana@php.net | Date: | Thu, 16 Aug 2007 11:41:17 +0000 |
| Subject: | #42032 [Opn->Csd]: Return value of dir() not tested in example code | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969377397@lists.php.net to get a copy of this message | ||
ID: 42032
Updated by: vrana@php.net
Reported By: michael dot mauch at gmx dot de
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
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.
Only dir::read() return value note changed. Example is simplified code
- it doesn't need to cover everything - I remain it intact.
Previous Comments:
------------------------------------------------------------------------
[2007-07-18 15:19:03] michael dot mauch at gmx dot de
Description:
------------
http://www.php.net/manual/en/class.dir.php
has example code which does
not check the return value of the dir() constructor. This causes a fatal
error if the directory does not exist.
Reproduce code:
---------------
$d = dir("/not/existing");
echo "Handle: " . $d->handle . "\n";
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
echo $entry."\n";
}
$d->close();
Expected result:
----------------
The value of $d should be tested in the example code, e.g.
$d = dir("/etc/php5");
if (!$d)
die("cannot read directory");
echo "Handle: " . $d->handle . "\n";
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
echo $entry."\n";
}
$d->close();
Also, the first sentence of the description for that example could be
changed to something like:
"Please note the fashion in which the return value of $d->read() is
checked in the example below."
Actual result:
--------------
Handle:
Path:
Fatal error: Call to a member function read() on a non-object in
Command line code on line 4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42032&edit=1