From:             michael dot mauch at gmx dot de
Operating system: 
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  Return value of dir() not tested in example code

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 bug report at http://bugs.php.net/?id=42032&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42032&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42032&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42032&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42032&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42032&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42032&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42032&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42032&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42032&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42032&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42032&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42032&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42032&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42032&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42032&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42032&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42032&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42032&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42032&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42032&r=mysqlcfg

Reply via email to