When is CASE_STRICT generated?

Viewed 42

I am trying to find an example where PHP 8.1 generates the CASE_STRICT opcode.

I found this message from @IluTov: https://chat.stackoverflow.com/transcript/message/50366061#50366061

@Derick When no jump table can be generated.

function foo($value) {
    return match ($value) {
        true => 'foo',
        null => 'bar',
    };
}

But that example only generates IS_IDENTICAL/JMPNZ/QM_ASSIGN for each case. I tried different cases and types, but only got either the regular MATCH code with jump table or the same IS_IDENTICAL/JMPNZ/QM_ASSIGN combination.

0002 T1 = IS_IDENTICAL CV0($value) bool(true)
0003 JMPNZ T1 0008
0004 T1 = IS_IDENTICAL CV0($value) null
0005 JMPNZ T1 0010
0006 JMP 0007
0007 MATCH_ERROR CV0($value)
0008 T2 = QM_ASSIGN string("foo")
0009 JMP 0012
0010 T2 = QM_ASSIGN string("bar")
0011 JMP 0012
0012 RETURN T2

What am I missing? When is CASE_STRICT generated?

0 Answers
Related