Skip to content

Commit fe21832

Browse files
committed
Test strict types behavior
1 parent e95a877 commit fe21832

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
First class callables and strict types
3+
--FILE--
4+
<?php
5+
declare(strict_types=1);
6+
7+
function test(int $i) {
8+
var_dump($i);
9+
}
10+
11+
require __DIR__ . '/first_class_callable_015_weak.inc';
12+
require __DIR__ . '/first_class_callable_015_strict.inc';
13+
$fn = test(...);
14+
do_weak_call($fn);
15+
try {
16+
do_strict_call($fn);
17+
} catch (Error $e) {
18+
echo $e->getMessage(), "\n";
19+
}
20+
21+
?>
22+
--EXPECTF--
23+
int(42)
24+
test(): Argument #1 ($i) must be of type int, string given, called in %s on line %d
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php declare(strict_types=1);
2+
3+
function do_strict_call(Closure $fn) {
4+
$fn("42");
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
function do_weak_call(Closure $fn) {
4+
$fn("42");
5+
}

0 commit comments

Comments
 (0)