3v4l.org

run code in 300+ PHP versions simultaneously
<?php $instantiable = function($className) use (& $instantiable) { if (! $className) { return true; } $reflection = new ReflectionClass($className); $hasFinalConstruct = false; if ($reflection->hasMethod('__construct')) { $hasFinalConstruct = $reflection->getMethod('__construct')->isFinal(); } $parentClass = $reflection->getParentClass(); return $instantiable($parentClass ? $parentClass->getName() : null) && ! ($reflection->isInternal() && $hasFinalConstruct); }; $negate = function ($function) { return function (...$args) use ($function) { return ! $function(...$args); }; }; var_dump([ 'instantiable' => array_filter(get_declared_classes(), $instantiable), 'not_instantiable' => array_filter(get_declared_classes(), $negate($instantiable)), ]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rAOrK
function name:  (null)
number of ops:  26
compiled vars:  !0 = $instantiable, !1 = $negate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrAOrK%3A3%240'
          1        BIND_LEXICAL                                             ~2, !0
          2        ASSIGN                                                   !0, ~2
   21     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrAOrK%3A21%241'
          4        ASSIGN                                                   !1, ~4
   27     5        INIT_FCALL                                               'var_dump'
   28     6        INIT_FCALL                                               'array_filter'
          7        INIT_FCALL                                               'get_declared_classes'
          8        DO_ICALL                                         $6      
          9        SEND_VAR                                                 $6
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        INIT_ARRAY                                       ~8      $7, 'instantiable'
   29    13        INIT_FCALL                                               'array_filter'
         14        INIT_FCALL                                               'get_declared_classes'
         15        DO_ICALL                                         $9      
         16        SEND_VAR                                                 $9
         17        INIT_DYNAMIC_CALL                                        !1
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0  $10     
         20        SEND_VAR                                                 $10
         21        DO_ICALL                                         $11     
         22        ADD_ARRAY_ELEMENT                                ~8      $11, 'not_instantiable'
         23        SEND_VAL                                                 ~8
         24        DO_ICALL                                                 
   30    25      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FrAOrK%3A3%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 39
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
Branch analysis from position: 39
Branch analysis from position: 20
filename:       /in/rAOrK
function name:  {closure}
number of ops:  41
compiled vars:  !0 = $className, !1 = $instantiable, !2 = $reflection, !3 = $hasFinalConstruct, !4 = $parentClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    4     2        BOOL_NOT                                         ~5      !0
          3      > JMPZ                                                     ~5, ->5
    5     4    > > RETURN                                                   <true>
    8     5    >   NEW                                              $6      'ReflectionClass'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $6
    9     9        ASSIGN                                                   !3, <false>
   11    10        INIT_METHOD_CALL                                         !2, 'hasMethod'
         11        SEND_VAL_EX                                              '__construct'
         12        DO_FCALL                                      0  $10     
         13      > JMPZ                                                     $10, ->20
   12    14    >   INIT_METHOD_CALL                                         !2, 'getMethod'
         15        SEND_VAL_EX                                              '__construct'
         16        DO_FCALL                                      0  $11     
         17        INIT_METHOD_CALL                                         $11, 'isFinal'
         18        DO_FCALL                                      0  $12     
         19        ASSIGN                                                   !3, $12
   15    20    >   INIT_METHOD_CALL                                         !2, 'getParentClass'
         21        DO_FCALL                                      0  $14     
         22        ASSIGN                                                   !4, $14
   17    23        INIT_DYNAMIC_CALL                                        !1
         24      > JMPZ                                                     !4, ->29
         25    >   INIT_METHOD_CALL                                         !4, 'getName'
         26        DO_FCALL                                      0  $16     
         27        QM_ASSIGN                                        ~17     $16
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~17     null
         30    >   SEND_VAL_EX                                              ~17
         31        DO_FCALL                                      0  $18     
         32      > JMPZ_EX                                          ~19     $18, ->39
   18    33    >   INIT_METHOD_CALL                                         !2, 'isInternal'
         34        DO_FCALL                                      0  $20     
         35      > JMPZ_EX                                          ~21     $20, ->37
         36    >   BOOL                                             ~21     !3
         37    >   BOOL_NOT                                         ~22     ~21
         38        BOOL                                             ~19     ~22
         39    > > RETURN                                                   ~19
   19    40*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrAOrK%3A3%240

Function %00%7Bclosure%7D%2Fin%2FrAOrK%3A21%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rAOrK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrAOrK%3A22%242'
          2        BIND_LEXICAL                                             ~1, !0
   24     3      > RETURN                                                   ~1
   25     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrAOrK%3A21%241

Function %00%7Bclosure%7D%2Fin%2FrAOrK%3A22%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rAOrK
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $args, !1 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
   23     2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1  $2      
          6        BOOL_NOT                                         ~3      $2
          7      > RETURN                                                   ~3
   24     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrAOrK%3A22%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.44 ms | 952 KiB | 20 Q