xref: /PHP-7.4/ext/opcache/tests/opt/sccp_026.phpt (revision ea115a61)
1--TEST--
2SCCP 026: Elimination of dead code due to conflicting type checks
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 test($var) {
14    if (!is_string($var) || (is_object($var) && !method_exists($var, '__toString'))) {
15        return;
16    }
17
18    var_dump($username);
19}
20?>
21--EXPECTF--
22$_main: ; (lines=1, args=0, vars=0, tmps=0)
23    ; (after optimizer)
24    ; %s:1-10
25L0 (10):    RETURN int(1)
26
27test: ; (lines=9, args=1, vars=2, tmps=1)
28    ; (after optimizer)
29    ; %s:2-8
30L0 (2):     CV0($var) = RECV 1
31L1 (3):     T2 = TYPE_CHECK (string) CV0($var)
32L2 (3):     JMPZ T2 L4
33L3 (3):     JMP L5
34L4 (4):     RETURN null
35L5 (7):     INIT_FCALL 1 %d string("var_dump")
36L6 (7):     SEND_VAR CV1($username) 1
37L7 (7):     DO_ICALL
38L8 (8):     RETURN null
39