xref: /PHP-8.2/ext/opcache/tests/opt/sccp_026.phpt (revision e48a5c14)
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=
9zend_test.observer.enabled=0
10--EXTENSIONS--
11opcache
12--FILE--
13<?php
14function test($var) {
15    if (!is_string($var) || (is_object($var) && !method_exists($var, '__toString'))) {
16        return;
17    }
18
19    var_dump($username);
20}
21?>
22--EXPECTF--
23$_main:
24     ; (lines=1, args=0, vars=0, tmps=0)
25     ; (after optimizer)
26     ; %s:1-10
270000 RETURN int(1)
28
29test:
30     ; (lines=9, args=1, vars=2, tmps=1)
31     ; (after optimizer)
32     ; %s:2-8
330000 CV0($var) = RECV 1
340001 T2 = TYPE_CHECK (string) CV0($var)
350002 JMPZ T2 0004
360003 JMP 0005
370004 RETURN null
380005 INIT_FCALL 1 %d string("var_dump")
390006 SEND_VAR CV1($username) 1
400007 DO_ICALL
410008 RETURN null
42