summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/internal_function_strict_mode.phpt
blob: 04c59ae3410ef7ea72334933b2d2e21f0d6d4737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--TEST--
Scalar type - internal function strict mode
--FILE--
<?php
declare(strict_types=1);

echo "*** Trying Ord With Integer" . PHP_EOL;
try {
    var_dump(ord(1));
} catch (TypeError $e) {
    echo "*** Caught " . $e->getMessage() . PHP_EOL;
}

echo "*** Trying Array Map With Invalid Callback" . PHP_EOL;
try {
    array_map([null, "bar"], []);
} catch (TypeError $e) {
    echo "*** Caught " . $e->getMessage() . PHP_EOL;
}

echo "*** Trying Strlen With Float" . PHP_EOL;
try {
    var_dump(strlen(1.5));
} catch (TypeError $e) {
    echo "*** Caught " . $e->getMessage() . PHP_EOL;
}

?>
--EXPECT--
*** Trying Ord With Integer
*** Caught ord(): Argument #1 ($character) must be of type string, int given
*** Trying Array Map With Invalid Callback
*** Caught array_map(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
*** Trying Strlen With Float
*** Caught strlen(): Argument #1 ($str) must be of type string, float given