1--TEST--
2Type inference 001: Invalid type narrowing warning
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7--FILE--
8<?php
9function test() {
10    for ($i = 0; $i < 2; $i++) {
11        $obj->x;
12        $obj = new stdClass;
13    }
14}
15test();
16
17class Test {
18    public int $x = 1;
19}
20
21function test2() {
22    for ($i = 0; $i < 2; $i++) {
23        $obj->x;
24        $obj = new Test;
25    }
26}
27test2();
28?>
29DONE
30--EXPECTF--
31Warning: Undefined variable $obj in %s on line %d
32
33Warning: Attempt to read property "x" on null in %s on line %d
34
35Warning: Undefined property: stdClass::$x in %s on line %d
36
37Warning: Undefined variable $obj in %s on line %d
38
39Warning: Attempt to read property "x" on null in %s on line %d
40DONE
41