Skip to content

Make error messages more consistent #5066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Zend/tests/bug30998.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ set_error_handler('my_error');
$f = fopen("/tmp/blah", "r");
?>
--EXPECTF--
fopen(/tmp/blah): failed to open stream: %s (2) in %s:%d
fopen(/tmp/blah): Failed to open stream: %s (2) in %s:%d

Warning: fopen(/tmp/blah): failed to open stream: %s in %s on line %d
Warning: fopen(/tmp/blah): Failed to open stream: %s in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug60909_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set_error_handler(function($errno, $errstr, $errfile, $errline){

require 'notfound.php';
--EXPECTF--
error(require(notfound.php): failed to open stream: %s)
error(require(notfound.php): Failed to open stream: %s)
Fatal error: Uncaught Exception: Foo in %sbug60909_1.php:5
Stack trace:
#0 %sbug60909_1.php(8): {closure}(2, 'require(notfoun...', '%s', 8)
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug64960.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set_error_handler(function()
$a['waa'];
?>
--EXPECTF--
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %sbug64960.php on line 3
Notice: ob_end_flush(): Failed to delete and flush buffer. No buffer to delete or flush in %sbug64960.php on line 3

Fatal error: Uncaught Exception in %sbug64960.php:19
Stack trace:
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/debug_backtrace_with_include_and_this.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ try {
echo $e."\n";
}
--EXPECTF--
ERR#2: include(class://non.existent.Class): failed to open stream: "CLWrapper::stream_open" call failed @ include
ERR#2: include(class://non.existent.Class): Failed to open stream: "CLWrapper::stream_open" call failed @ include
ERR#2: include(): Failed opening 'class://non.existent.Class' for inclusion (include_path='%s') @ include

Fatal error: Uncaught Exception: Failed loading class://non.existent.Class in %s
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/include_stat_is_quiet.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ try {

?>
--EXPECTF--
Warning: require_once(doesnt_exist.php): failed to open stream: No such file or directory in %s on line %d
Warning: require_once(doesnt_exist.php): Failed to open stream: No such file or directory in %s on line %d

Fatal error: require_once(): Failed opening required 'doesnt_exist.php' (include_path='test://foo:test://bar') in %s on line %d
2 changes: 1 addition & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ ZEND_METHOD(exception, getTraceAsString)

trace = zend_read_property_ex(base_ce, object, ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
if (Z_TYPE_P(trace) != IS_ARRAY) {
zend_type_error("trace is not an array");
zend_type_error("Trace is not an array");
return;
}
ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(trace), index, frame) {
Expand Down
4 changes: 2 additions & 2 deletions ext/bcmath/libbcmath/src/raise.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale)

/* Check the exponent for scale digits and convert to a long. */
if (num2->n_scale != 0)
php_error_docref (NULL, E_WARNING, "non-zero scale in exponent");
php_error_docref (NULL, E_WARNING, "Non-zero scale in exponent");
exponent = bc_num2long (num2);
if (exponent == 0 && (num2->n_len > 1 || num2->n_value[0] != 0))
php_error_docref (NULL, E_WARNING, "exponent too large");
php_error_docref (NULL, E_WARNING, "Exponent too large");

/* Special case if exponent is a zero. */
if (exponent == 0)
Expand Down
6 changes: 3 additions & 3 deletions ext/bcmath/libbcmath/src/raisemod.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale)
/* Check the base for scale digits. */
if (power->n_scale != 0)
{
php_error_docref (NULL, E_WARNING, "non-zero scale in base");
php_error_docref (NULL, E_WARNING, "Non-zero scale in base");
_bc_truncate (&power);
}

/* Check the exponent for scale digits. */
if (exponent->n_scale != 0)
{
php_error_docref (NULL, E_WARNING, "non-zero scale in exponent");
php_error_docref (NULL, E_WARNING, "Non-zero scale in exponent");
_bc_truncate (&exponent);
}

/* Check the modulus for scale digits. */
if (modulus->n_scale != 0)
{
php_error_docref (NULL, E_WARNING, "non-zero scale in modulus");
php_error_docref (NULL, E_WARNING, "Non-zero scale in modulus");
_bc_truncate (&modulus);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/bcmath/tests/bcpow_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension is not available');
var_dump(bcpow('1', '1.1', 2));
?>
--EXPECTF--
Warning: bcpow(): non-zero scale in exponent in %s on line %d
Warning: bcpow(): Non-zero scale in exponent in %s on line %d
string(4) "1.00"
2 changes: 1 addition & 1 deletion ext/bcmath/tests/bcpow_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension is not available');
var_dump(bcpow('0', '9223372036854775808', 2));
?>
--EXPECTF--
Warning: bcpow(): exponent too large in %s on line %d
Warning: bcpow(): Exponent too large in %s on line %d
string(4) "1.00"
2 changes: 1 addition & 1 deletion ext/bcmath/tests/bug72093.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ var_dump(bcpowmod(1, 1.2, 1, 1));
--EXPECTF--
string(1) "1"

Warning: bcpowmod(): non-zero scale in exponent in %s on line %d
Warning: bcpowmod(): Non-zero scale in exponent in %s on line %d
string(3) "0.0"
4 changes: 2 additions & 2 deletions ext/bcmath/tests/bug75178.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var_dump(bcpowmod('4.1', '4', '3', 3));
var_dump(bcpowmod('4', '4', '3.1', 3));
?>
--EXPECTF--
Warning: bcpowmod(): non-zero scale in base in %s on line %d
Warning: bcpowmod(): Non-zero scale in base in %s on line %d
string(5) "1.000"

Warning: bcpowmod(): non-zero scale in modulus in %s on line %d
Warning: bcpowmod(): Non-zero scale in modulus in %s on line %d
string(5) "1.000"
10 changes: 5 additions & 5 deletions ext/bz2/bz2.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ static PHP_FUNCTION(bzopen)
/* If it's not a resource its a string containing the filename to open */
if (Z_TYPE_P(file) == IS_STRING) {
if (Z_STRLEN_P(file) == 0) {
php_error_docref(NULL, E_WARNING, "filename cannot be empty");
php_error_docref(NULL, E_WARNING, "Filename cannot be empty");
RETURN_FALSE;
}

if (CHECK_ZVAL_NULL_PATH(file)) {
zend_type_error("filename must not contain null bytes");
zend_type_error("Filename must not contain null bytes");
RETURN_THROWS();
}

Expand All @@ -393,18 +393,18 @@ static PHP_FUNCTION(bzopen)
stream_mode_len = strlen(stream->mode);

if (stream_mode_len != 1 && !(stream_mode_len == 2 && memchr(stream->mode, 'b', 2))) {
php_error_docref(NULL, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);
php_error_docref(NULL, E_WARNING, "Cannot use stream opened in mode '%s'", stream->mode);
RETURN_FALSE;
} else if (stream_mode_len == 1 && stream->mode[0] != 'r' && stream->mode[0] != 'w' && stream->mode[0] != 'a' && stream->mode[0] != 'x') {
php_error_docref(NULL, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);
php_error_docref(NULL, E_WARNING, "Cannot use stream opened in mode '%s'", stream->mode);
RETURN_FALSE;
}

switch(mode[0]) {
case 'r':
/* only "r" and "rb" are supported */
if (stream->mode[0] != mode[0] && !(stream_mode_len == 2 && stream->mode[1] != mode[0])) {
php_error_docref(NULL, E_WARNING, "cannot read from a stream opened in write only mode");
php_error_docref(NULL, E_WARNING, "Cannot read from a stream opened in write only mode");
RETURN_FALSE;
}
break;
Expand Down
6 changes: 3 additions & 3 deletions ext/bz2/tests/001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ var_dump(bzopen($fp, "r"));
--EXPECTF--
'' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.

Warning: bzopen(): filename cannot be empty in %s on line %d
Warning: bzopen(): Filename cannot be empty in %s on line %d
bool(false)

Warning: bzopen(): filename cannot be empty in %s on line %d
Warning: bzopen(): Filename cannot be empty in %s on line %d
bool(false)
'x' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.
'rw' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.

Warning: bzopen(no_such_file): failed to open stream: No such file or directory in %s on line %d
Warning: bzopen(no_such_file): Failed to open stream: No such file or directory in %s on line %d
bool(false)
resource(%d) of type (stream)
26 changes: 13 additions & 13 deletions ext/bz2/tests/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -85,47 +85,47 @@ resource(%d) of type (stream)
resource(%d) of type (stream)
resource(%d) of type (stream)

Warning: bzopen(): cannot read from a stream opened in write only mode in %s on line %d
Warning: bzopen(): Cannot read from a stream opened in write only mode in %s on line %d
bool(false)
resource(%d) of type (stream)
resource(%d) of type (stream)

Warning: fopen(bz_open_002.txt): failed to open stream: Bad file %s in %s on line %d
Warning: fopen(bz_open_002.txt): Failed to open stream: Bad file %s in %s on line %d
First parameter has to be string or file-resource

Warning: fopen(bz_open_002.txt): failed to open stream: Bad file %s in %s on line %d
Warning: fopen(bz_open_002.txt): Failed to open stream: Bad file %s in %s on line %d
First parameter has to be string or file-resource

Warning: bzopen(): cannot write to a stream opened in read only mode in %s on line %d
bool(false)

Warning: bzopen(): cannot read from a stream opened in write only mode in %s on line %d
Warning: bzopen(): Cannot read from a stream opened in write only mode in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'rw' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'rw' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'rw' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'rw' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'wr' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'wr' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'wr' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'wr' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'r+' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'r+' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'r+' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'r+' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'w+' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'w+' in %s on line %d
bool(false)

Warning: bzopen(): cannot use stream opened in mode 'w+' in %s on line %d
Warning: bzopen(): Cannot use stream opened in mode 'w+' in %s on line %d
bool(false)

Warning: bzopen(): cannot read from a stream opened in write only mode in %s on line %d
Warning: bzopen(): Cannot read from a stream opened in write only mode in %s on line %d
bool(false)
resource(%d) of type (stream)
4 changes: 2 additions & 2 deletions ext/bz2/tests/bzopen_string_filename_with_null_bytes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ try {

?>
--EXPECT--
filename must not contain null bytes
filename must not contain null bytes
Filename must not contain null bytes
Filename must not contain null bytes
2 changes: 1 addition & 1 deletion ext/calendar/cal_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PHP_FUNCTION(unixtojd)
if (!ts) {
ts = time(NULL);
} else if (ts < 0) {
zend_value_error("timestamp must not be negative");
zend_value_error("Timestamp must not be negative");
RETURN_THROWS();
}

Expand Down
10 changes: 5 additions & 5 deletions ext/calendar/calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ PHP_FUNCTION(cal_info)


if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) {
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal);
RETURN_THROWS();
}

Expand All @@ -239,7 +239,7 @@ PHP_FUNCTION(cal_days_in_month)
}

if (cal < 0 || cal >= CAL_NUM_CALS) {
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal);
RETURN_THROWS();
}

Expand All @@ -248,7 +248,7 @@ PHP_FUNCTION(cal_days_in_month)
sdn_start = calendar->to_jd(year, month, 1);

if (sdn_start == 0) {
zend_value_error("invalid date");
zend_value_error("Invalid date");
RETURN_THROWS();
}

Expand Down Expand Up @@ -285,7 +285,7 @@ PHP_FUNCTION(cal_to_jd)
}

if (cal < 0 || cal >= CAL_NUM_CALS) {
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal);
RETURN_THROWS();
}

Expand All @@ -306,7 +306,7 @@ PHP_FUNCTION(cal_from_jd)
}

if (cal < 0 || cal >= CAL_NUM_CALS) {
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal);
RETURN_THROWS();
}
calendar = &cal_conversion_table[cal];
Expand Down
4 changes: 2 additions & 2 deletions ext/calendar/tests/cal_days_in_month_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ try{
}
?>
--EXPECT--
invalid calendar ID -1
invalid date
Invalid calendar ID: -1
Invalid date
2 changes: 1 addition & 1 deletion ext/calendar/tests/cal_from_jd_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ try {
}
?>
--EXPECT--
invalid calendar ID -1
Invalid calendar ID: -1
2 changes: 1 addition & 1 deletion ext/calendar/tests/cal_info.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ Array
[calname] => Julian
[calsymbol] => CAL_JULIAN
)
invalid calendar ID 99999
Invalid calendar ID: 99999
2 changes: 1 addition & 1 deletion ext/calendar/tests/cal_to_jd_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ try {
}
?>
--EXPECT--
invalid calendar ID -1
Invalid calendar ID: -1
2 changes: 1 addition & 1 deletion ext/calendar/tests/unixtojd_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var_dump(unixtojd(null)) . PHP_EOL;
var_dump(unixtojd(time())) . PHP_EOL;
?>
--EXPECTF--
timestamp must not be negative
Timestamp must not be negative
int(%d)
int(%d)
int(%d)
2 changes: 1 addition & 1 deletion ext/com_dotnet/com_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b
obj = CDNO_FETCH(object);

if (V_VT(&obj->v) != VT_DISPATCH && !V_ISARRAY(&obj->v)) {
php_error_docref(NULL, E_WARNING, "variant is not an object or array VT=%d", V_VT(&obj->v));
php_error_docref(NULL, E_WARNING, "Variant is not an object or array VT=%d", V_VT(&obj->v));
return NULL;
}

Expand Down
8 changes: 4 additions & 4 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ PHP_FUNCTION(curl_version)
ZEND_PARSE_PARAMETERS_END();

if (uversion == CURLVERSION_NOW) {
php_error_docref(NULL, E_DEPRECATED, "the $version parameter is deprecated");
php_error_docref(NULL, E_DEPRECATED, "The $version parameter is deprecated");
} else if (ZEND_NUM_ARGS() > 0) {
php_error_docref(NULL, E_WARNING, "$version argument ignored");
}
Expand Down Expand Up @@ -2576,7 +2576,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
ch->handlers->write->method = PHP_CURL_FILE;
ZVAL_COPY(&ch->handlers->write->stream, zvalue);
} else {
php_error_docref(NULL, E_WARNING, "the provided file handle is not writable");
php_error_docref(NULL, E_WARNING, "The provided file handle is not writable");
return FAILURE;
}
break;
Expand All @@ -2594,7 +2594,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
ch->handlers->write_header->method = PHP_CURL_FILE;
ZVAL_COPY(&ch->handlers->write_header->stream, zvalue);
} else {
php_error_docref(NULL, E_WARNING, "the provided file handle is not writable");
php_error_docref(NULL, E_WARNING, "The provided file handle is not writable");
return FAILURE;
}
break;
Expand Down Expand Up @@ -2623,7 +2623,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
zval_ptr_dtor(&ch->handlers->std_err);
ZVAL_COPY(&ch->handlers->std_err, zvalue);
} else {
php_error_docref(NULL, E_WARNING, "the provided file handle is not writable");
php_error_docref(NULL, E_WARNING, "The provided file handle is not writable");
return FAILURE;
}
/* break omitted intentionally */
Expand Down
2 changes: 1 addition & 1 deletion ext/curl/tests/bug48207.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ is_file($tempfile) and @unlink($tempfile);
isset($tempname) and is_file($tempname) and @unlink($tempname);
?>
--EXPECTF--
Warning: curl_setopt(): the provided file handle is not writable in %s on line %d
Warning: curl_setopt(): The provided file handle is not writable in %s on line %d
Hello World!
Hello World!
2 changes: 1 addition & 1 deletion ext/curl/tests/curl_version_error_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ curl_version(CURLVERSION_NOW);
curl_version(0);
?>
--EXPECTF--
Deprecated: curl_version(): the $version parameter is deprecated in %s on line %d
Deprecated: curl_version(): The $version parameter is deprecated in %s on line %d

Warning: curl_version(): $version argument ignored in %s on line %d
Loading