com php-src: Promote warnings to errors in dir stdlib extension: ext/standard/dir.c ext/standard/tests/dir/closedir_variation 3.phpt
ext/standard/tests/dir/readdir_variation7.ph pt ext/standard/tests/dir/rewinddir_variation3.phpt
| From: | Joe Watkins | Date: | Fri, 30 Aug 2019 07:50:04 +0000 |
| Subject: | com php-src: Promote warnings to errors in dir stdlib extension: ext/standard/dir.c ext/standard/tests/dir/closedir_variation 3.phpt ext/standard/tests/dir/readdir_variation7.ph pt ext/standard/tests/dir/rewinddir_variation3.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108146@lists.php.net to get a copy of this message | ||
Commit: b3d725218d881cb26028af04140f66617df3a06a
Author: George Peter Banyard <girgias@php.net> Thu, 29 Aug 2019 01:14:17 +0200
Committer: Joe Watkins <krakjoe@php.net> Fri, 30 Aug 2019 09:50:04 +0200
Parents: 9bd0cce8192d296ab247c6408a2a969fbc064c45
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b3d725218d881cb26028af04140f66617df3a06a
Log:
Promote warnings to errors in dir stdlib extension
Changed paths:
M ext/standard/dir.c
M ext/standard/tests/dir/closedir_variation3.phpt
M ext/standard/tests/dir/readdir_variation7.phpt
M ext/standard/tests/dir/rewinddir_variation3.phpt
Diff:
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 207b02f..31ef72c 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -266,8 +266,8 @@ PHP_FUNCTION(closedir)
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;
@@ -382,8 +382,8 @@ PHP_FUNCTION(rewinddir)
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);
@@ -401,8 +401,8 @@ PHP_NAMED_FUNCTION(php_if_readdir)
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)) {
@@ -566,8 +566,8 @@ PHP_FUNCTION(scandir)
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) {
diff --git a/ext/standard/tests/dir/closedir_variation3.phpt
b/ext/standard/tests/dir/closedir_variation3.phpt
index 7d7fdcb..7c65f5f 100644
--- a/ext/standard/tests/dir/closedir_variation3.phpt
+++ b/ext/standard/tests/dir/closedir_variation3.phpt
@@ -18,8 +18,11 @@ echo "\n-- Open a file using fopen() --\n";
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);
@@ -35,9 +38,7 @@ if(is_resource($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)
diff --git a/ext/standard/tests/dir/readdir_variation7.phpt
b/ext/standard/tests/dir/readdir_variation7.phpt
index 2cd23b8..7950d58 100644
--- a/ext/standard/tests/dir/readdir_variation7.phpt
+++ b/ext/standard/tests/dir/readdir_variation7.phpt
@@ -15,14 +15,16 @@ echo "*** Testing readdir() : usage variations ***\n";
// 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===
diff --git a/ext/standard/tests/dir/rewinddir_variation3.phpt
b/ext/standard/tests/dir/rewinddir_variation3.phpt
index a1ec7f8..920e493 100644
--- a/ext/standard/tests/dir/rewinddir_variation3.phpt
+++ b/ext/standard/tests/dir/rewinddir_variation3.phpt
@@ -18,7 +18,12 @@ echo "\n-- Open a file using fopen --\n";
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";
@@ -34,9 +39,7 @@ if ($result1 === $result2) {
-- 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