Skip to content

Commit f289483

Browse files
committed
Promote warrnings to exceptions in chgrp() function
1 parent e1eb864 commit f289483

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ext/standard/filestat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
354354
option = PHP_STREAM_META_GROUP_NAME;
355355
value = Z_STRVAL_P(group);
356356
} else {
357-
php_error_docref(NULL, E_WARNING, "parameter 2 should be string or int, %s given", zend_zval_type_name(group));
357+
zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group));
358358
RETURN_FALSE;
359359
}
360360
if(wrapper->wops->stream_metadata(wrapper, filename, option, value, NULL)) {
@@ -383,7 +383,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
383383
RETURN_FALSE;
384384
}
385385
} else {
386-
php_error_docref(NULL, E_WARNING, "parameter 2 should be string or int, %s given", zend_zval_type_name(group));
386+
zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group));
387387
RETURN_FALSE;
388388
}
389389

ext/standard/tests/file/chgrp.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ if(substr(PHP_OS, 0, 3) == "WIN")
77
?>
88
--FILE--
99
<?php
10-
chgrp("sjhgfskhagkfdgskjfhgskfsdgfkdsajf", NULL);
11-
echo "ALIVE\n";
10+
try {
11+
chgrp("sjhgfskhagkfdgskjfhgskfsdgfkdsajf", null);
12+
} catch (TypeError $exception) {
13+
echo $exception->getMessage() . "\n";
14+
}
1215
?>
1316
--EXPECTF--
14-
Warning: chgrp(): parameter 2 should be string or int, null given in %schgrp.php on line 2
15-
ALIVE
17+
Parameter 2 should be string or int, null given

0 commit comments

Comments
 (0)