1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 05:21:02 +02:00
Files
archived-php-src/ext/sodium/tests/sodium_error_001.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

24 lines
639 B
PHP

--TEST--
TypeErrors will not contain param values in backtrace
--SKIPIF--
<?php if (!extension_loaded("sodium")) die("skip ext/sodium required"); ?>
--FILE--
<?php
declare(strict_types=1);
function do_crypto_shorthash($message, $key) {
return sodium_crypto_shorthash($message, $key);
}
$m = 12;
$key = random_bytes(SODIUM_CRYPTO_SHORTHASH_KEYBYTES);
$hash = do_crypto_shorthash($m, $key);
?>
--EXPECTF--
Fatal error: Uncaught TypeError: sodium_crypto_shorthash() expects parameter 1 to be string, int given in %s:%d
Stack trace:
#0 %s(%d): sodium_crypto_shorthash()
#1 %s(%d): do_crypto_shorthash()
#2 {main}
thrown in %s on line %d