xref: /PHP-8.0/ext/opcache/tests/opt/sccp_026.phpt (revision 0684b9fc)
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:
23     ; (lines=1, args=0, vars=0, tmps=0)
24     ; (after optimizer)
25     ; %s:1-10
260000 RETURN int(1)
27
28test:
29     ; (lines=9, args=1, vars=2, tmps=1)
30     ; (after optimizer)
31     ; %s:2-8
320000 CV0($var) = RECV 1
330001 T2 = TYPE_CHECK (string) CV0($var)
340002 JMPZ T2 0004
350003 JMP 0005
360004 RETURN null
370005 INIT_FCALL 1 %d string("var_dump")
380006 SEND_VAR CV1($username) 1
390007 DO_ICALL
400008 RETURN null
41