summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/extract_typed_ref.phpt
blob: 8b697d5ccb2441929c3ac28e219fbc7ebaa02a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--TEST--
extract() into typed references must respect their type
--FILE--
<?php
  
class Test {
	public int $i = 0;
	public string $s = "";
}

$test = new Test;
$i =& $test->i;
$s =& $test->s;
try {
	extract(['i' => 'foo', 's' => 42]);
} catch (TypeError $e) { echo $e->getMessage(), "\n"; }
var_dump($test->i, $test->s);

?>
--EXPECT--
Cannot assign string to reference held by property Test::$i of type int
int(0)
string(0) ""