1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 07:28:09 +02:00
Files
archived-php-src/ext/opcache/tests/jit/assign_obj_002.phpt
T
Nikita Popov f4bcf8c393 Check for undef var in typed property assignment
Without this check the assignment would actually silently succeed,
not just skip the warning.
2021-09-21 14:09:26 +02:00

37 lines
679 B
PHP

--TEST--
JIT ASSIGN_OBJ: Assign undefined vatiable to property
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.jit=function
--FILE--
<?php
class Test {
public $prop;
public int $prop2;
}
function test() {
$o = new Test;
$o->prop = $undef;
var_dump($o->prop);
}
function test2() {
$o = new Test;
$o->prop2 = $undef;
}
test();
try {
test2();
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Warning: Undefined variable $undef in %s on line %d
NULL
Warning: Undefined variable $undef in %s on line %d
Cannot assign null to property Test::$prop2 of type int