3v4l.org

run code in 300+ PHP versions simultaneously
<?php function instantiable($className) { if (! $className) { return true; } $reflection = new ReflectionClass($className); if ($reflection->isAbstract()) { return false; } $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/OF15Z
function name:  (null)
number of ops:  23
compiled vars:  !0 = $negate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOF15Z%3A26%240'
          1        ASSIGN                                                   !0, ~1
   32     2        INIT_FCALL                                               'var_dump'
   33     3        INIT_FCALL                                               'array_filter'
          4        INIT_FCALL                                               'get_declared_classes'
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        SEND_VAL                                                 'instantiable'
          8        DO_ICALL                                         $4      
          9        INIT_ARRAY                                       ~5      $4, 'instantiable'
   34    10        INIT_FCALL                                               'array_filter'
         11        INIT_FCALL                                               'get_declared_classes'
         12        DO_ICALL                                         $6      
         13        SEND_VAR                                                 $6
         14        INIT_DYNAMIC_CALL                                        !0
         15        SEND_VAL_EX                                              'instantiable'
         16        DO_FCALL                                      0  $7      
         17        SEND_VAR                                                 $7
         18        DO_ICALL                                         $8      
         19        ADD_ARRAY_ELEMENT                                ~5      $8, 'not_instantiable'
         20        SEND_VAL                                                 ~5
         21        DO_ICALL                                                 
   35    22      > RETURN                                                   1

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

End of function instantiable

Function %00%7Bclosure%7D%2Fin%2FOF15Z%3A26%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OF15Z
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOF15Z%3A27%241'
          2        BIND_LEXICAL                                             ~1, !0
   29     3      > RETURN                                                   ~1
   30     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOF15Z%3A26%240

Function %00%7Bclosure%7D%2Fin%2FOF15Z%3A27%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OF15Z
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $args, !1 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
   28     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
   29     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOF15Z%3A27%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.53 ms | 1396 KiB | 19 Q