1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 09:42:22 +01:00
Files
archived-php-src/ext/standard/tests/assert/assert_error1.phpt
Gabriel Caruso ce1d69a1f6 Use int instead of integer in type errors
PHP requires integer typehints to be written "int" and does not
allow "integer" as an alias. This changes type error messages to
match the actual type name and avoids confusing messages like
"must be of the type integer, integer given".
2018-02-04 19:08:23 +01:00

47 lines
1.1 KiB
PHP

--TEST--
assert() - error - invalid params
--INI--
assert.active = 1
assert.warning = 1
assert.callback = f1
assert.quiet_eval = 1
assert.bail = 0
--FILE--
<?php
function f1()
{
echo "f1 called\n";
}
function handler($errno, $errstr) {
echo "in handler()\n\n";
assert(E_RECOVERABLE_ERROR === $errno);
var_dump($errstr);
}
//Wrong number of parameters for assert_options()
assert_options(ASSERT_WARNING, 1);
var_dump($rao = assert_options(ASSERT_CALLBACK, "f1", 1));
//Unknown option for assert_options()
var_dump($rao=assert_options("F1", "f1"));
//Wrong number of parameters for assert()
$sa="0 != 0";
var_dump($r2 = assert($sa, "message", 1));
//Catch recoverable error with handler
var_dump($rc = assert('aa=sd+as+safsafasfaçsafçsafç'));
--EXPECTF--
Warning: assert_options() expects at most 2 parameters, 3 given in %s on line %d
NULL
Warning: assert_options() expects parameter 1 to be int, string given in %s on line %d
NULL
Warning: assert() expects at most 2 parameters, 3 given in %s on line %d
NULL
Deprecated: assert(): Calling assert() with a string argument is deprecated in %s on line %d