3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); final class Custom extends \RuntimeException { public static int $counter = 0; private function __construct(string $reason) { parent::__construct($reason); ++self::$counter; } public static function reason(string $reason): self { return new self($reason); } } printf("%d\n", Custom::$counter); assert(true === true, Custom::reason("Should never fail")); printf("%d (if increased, pointless throwable instantiation)\n", Custom::$counter); try { assert(true === false, Custom::reason("Should always fail")); } catch (\Throwable $t) { printf("%d (if increased, expected throwable instantiation) <%s>\n", Custom::$counter, $t->getMessage()); } printf("%d\n", Custom::$counter);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 27
Branch analysis from position: 27
2 jumps found. (Code = 107) Position 1 = 28, Position 2 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NRghG
function name:  (null)
number of ops:  42
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'printf'
          1        SEND_VAL                                                 '%25d%0A'
          2        FETCH_STATIC_PROP_R          global lock         ~1      'counter'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   24     5        ASSERT_CHECK                                             
          6        INIT_FCALL                                               'assert'
          7        SEND_VAL                                                 <true>
          8        INIT_STATIC_METHOD_CALL                                  'Custom', 'reason'
          9        SEND_VAL                                                 'Should+never+fail'
         10        DO_FCALL                                      0  $3      
         11        SEND_VAR                                                 $3
         12        DO_ICALL                                                 
   26    13        INIT_FCALL                                               'printf'
         14        SEND_VAL                                                 '%25d+%28if+increased%2C+pointless+throwable+instantiation%29%0A'
         15        FETCH_STATIC_PROP_R          unknown             ~5      'counter'
         16        SEND_VAL                                                 ~5
         17        DO_ICALL                                                 
   29    18        ASSERT_CHECK                                             
         19        INIT_FCALL                                               'assert'
         20        SEND_VAL                                                 <false>
         21        INIT_STATIC_METHOD_CALL                                  'Custom', 'reason'
         22        SEND_VAL                                                 'Should+always+fail'
         23        DO_FCALL                                      0  $7      
         24        SEND_VAR                                                 $7
         25        DO_ICALL                                                 
         26      > JMP                                                      ->36
   30    27  E > > CATCH                                       last         'Throwable'
   31    28    >   INIT_FCALL                                               'printf'
         29        SEND_VAL                                                 '%25d+%28if+increased%2C+expected+throwable+instantiation%29+%3C%25s%3E%0A'
         30        FETCH_STATIC_PROP_R          unknown             ~9      'counter'
         31        SEND_VAL                                                 ~9
         32        INIT_METHOD_CALL                                         !0, 'getMessage'
         33        DO_FCALL                                      0  $10     
         34        SEND_VAR                                                 $10
         35        DO_ICALL                                                 
   34    36    >   INIT_FCALL                                               'printf'
         37        SEND_VAL                                                 '%25d%0A'
         38        FETCH_STATIC_PROP_R          unknown             ~12     'counter'
         39        SEND_VAL                                                 ~12
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Class Custom:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NRghG
function name:  __construct
number of ops:  6
compiled vars:  !0 = $reason
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   13     4        PRE_INC_STATIC_PROP                                      'counter'
   14     5      > RETURN                                                   null

End of function __construct

Function reason:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NRghG
function name:  reason
number of ops:  8
compiled vars:  !0 = $reason
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   19     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function reason

End of class Custom.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.05 ms | 1400 KiB | 17 Q