xref: /PHP-8.0/ext/opcache/tests/opt/sccp_022.phpt (revision 1b33da5d)
1--TEST--
2SCCP 022: Invalid types
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7opcache.opt_debug_level=0x20000
8opcache.preload=
9--SKIPIF--
10<?php require_once('skipif.inc'); ?>
11--FILE--
12<?php
13function foo(int $x) {
14    $a[0] = $x;
15    $a[1] = 5;
16    echo $a[1];
17    $a->foo = 5;
18    echo $a[1];
19}
20function bar() {
21    foreach ($a as $v) {
22        foreach ($v as $v2) {}
23    }
24}
25?>
26--EXPECTF--
27$_main:
28     ; (lines=1, args=0, vars=0, tmps=0)
29     ; (after optimizer)
30     ; %s
310000 RETURN int(1)
32
33foo:
34     ; (lines=11, args=1, vars=2, tmps=1)
35     ; (after optimizer)
36     ; %s
370000 CV0($x) = RECV 1
380001 ASSIGN_DIM CV1($a) int(0)
390002 OP_DATA CV0($x)
400003 ASSIGN_DIM CV1($a) int(1)
410004 OP_DATA int(5)
420005 ECHO string("5")
430006 ASSIGN_OBJ CV1($a) string("foo")
440007 OP_DATA int(5)
450008 T2 = FETCH_DIM_R CV1($a) int(1)
460009 ECHO T2
470010 RETURN null
48
49bar:
50     ; (lines=9, args=0, vars=3, tmps=2)
51     ; (after optimizer)
52     ; %s
530000 V3 = FE_RESET_R CV0($a) 0007
540001 FE_FETCH_R V3 CV1($v) 0007
550002 V4 = FE_RESET_R CV1($v) 0005
560003 FE_FETCH_R V4 CV2($v2) 0005
570004 JMP 0003
580005 FE_FREE V4
590006 JMP 0001
600007 FE_FREE V3
610008 RETURN null
62LIVE RANGES:
63     3: 0001 - 0007 (loop)
64     4: 0003 - 0005 (loop)
65