FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL, E_WARNING, "%d is not a valid Directory resource", dirp->res->handle);
- RETURN_FALSE;
+ zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
+ return;
}
res = dirp->res;
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL, E_WARNING, "%d is not a valid Directory resource", dirp->res->handle);
- RETURN_FALSE;
+ zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
+ return;
}
php_stream_rewinddir(dirp);
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL, E_WARNING, "%d is not a valid Directory resource", dirp->res->handle);
- RETURN_FALSE;
+ zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
+ return;
}
if (php_stream_readdir(dirp, &entry)) {
ZEND_PARSE_PARAMETERS_END();
if (dirn_len < 1) {
- php_error_docref(NULL, E_WARNING, "Directory name cannot be empty");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Directory name cannot be empty");
+ return;
}
if (zcontext) {
var_dump($fp = fopen(__FILE__, 'r'));
echo "\n-- Try to close the file pointer using closedir() --\n";
-var_dump(closedir($fp));
-
+try {
+ var_dump(closedir($fp));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . "\n";
+}
echo "\n-- Check file pointer: --\n";
var_dump($fp);
resource(%d) of type (stream)
-- Try to close the file pointer using closedir() --
-
-Warning: closedir(): %d is not a valid Directory resource in %s on line %d
-bool(false)
+%d is not a valid Directory resource
-- Check file pointer: --
resource(%d) of type (stream)
// get a resource variable
var_dump($fp = fopen(__FILE__, "r"));
-var_dump( readdir($fp) );
+try {
+ var_dump( readdir($fp) );
+} catch (\TypeError $e) {
+ echo $e->getMessage() . "\n";
+}
?>
===DONE===
--EXPECTF--
*** Testing readdir() : usage variations ***
resource(%d) of type (stream)
-
-Warning: readdir(): %d is not a valid Directory resource in %s on line %d
-bool(false)
+%d is not a valid Directory resource
===DONE===
var_dump($fp = fopen(__FILE__, 'r'));
$result1 = fread($fp, 5);
-var_dump(rewinddir($fp));
+
+try {
+ var_dump(rewinddir($fp));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . "\n";
+}
$result2 = fread($fp, 5);
echo "\n-- Check if rewinddir() has repositioned the file pointer --\n";
-- Open a file using fopen --
resource(%d) of type (stream)
-
-Warning: rewinddir(): %d is not a valid Directory resource in %s on line %d
-bool(false)
+%d is not a valid Directory resource
-- Check if rewinddir() has repositioned the file pointer --
rewinddir() does not work on file pointers