3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Vehicle { private static $counts = []; public static function getCount() { return self::$counts[static::class]; } public function __construct() { $target =& self::$counts[static::class]; $target++; } } class Bike extends Vehicle {} class Car extends Vehicle {} new Bike; new Bike; new Car; var_dump(Bike::getCount()); var_dump(Car::getCount());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $0      'Bike'
          1        DO_FCALL                                      0          
          2        FREE                                                     $0
   23     3        NEW                                              $2      'Bike'
          4        DO_FCALL                                      0          
          5        FREE                                                     $2
   24     6        NEW                                              $4      'Car'
          7        DO_FCALL                                      0          
          8        FREE                                                     $4
   26     9        INIT_FCALL                                               'var_dump'
         10        INIT_STATIC_METHOD_CALL                                  'Bike', 'getCount'
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
   27    14        INIT_FCALL                                               'var_dump'
         15        INIT_STATIC_METHOD_CALL                                  'Car', 'getCount'
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class Vehicle:
Function getcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  getCount
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_CLASS_NAME                                 ~1      
          1        FETCH_STATIC_PROP_R          unknown             ~0      'counts'
          2        FETCH_DIM_R                                      ~2      ~0, ~1
          3      > RETURN                                                   ~2
   10     4*     > RETURN                                                   null

End of function getcount

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  __construct
number of ops:  6
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_CLASS_NAME                                 ~2      
          1        FETCH_STATIC_PROP_W          global              $1      'counts'
          2        FETCH_DIM_W                                      $3      $1, ~2
          3        ASSIGN_REF                                               !0, $3
   15     4        PRE_INC                                                  !0
   16     5      > RETURN                                                   null

End of function __construct

End of class Vehicle.

Class Bike:
Function getcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  getCount
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_CLASS_NAME                                 ~1      
          1        FETCH_STATIC_PROP_R          unknown             ~0      'counts'
          2        FETCH_DIM_R                                      ~2      ~0, ~1
          3      > RETURN                                                   ~2
   10     4*     > RETURN                                                   null

End of function getcount

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  __construct
number of ops:  6
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_CLASS_NAME                                 ~2      
          1        FETCH_STATIC_PROP_W          global              $1      'counts'
          2        FETCH_DIM_W                                      $3      $1, ~2
          3        ASSIGN_REF                                               !0, $3
   15     4        PRE_INC                                                  !0
   16     5      > RETURN                                                   null

End of function __construct

End of class Bike.

Class Car:
Function getcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  getCount
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_CLASS_NAME                                 ~1      
          1        FETCH_STATIC_PROP_R          unknown             ~0      'counts'
          2        FETCH_DIM_R                                      ~2      ~0, ~1
          3      > RETURN                                                   ~2
   10     4*     > RETURN                                                   null

End of function getcount

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qibd7
function name:  __construct
number of ops:  6
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_CLASS_NAME                                 ~2      
          1        FETCH_STATIC_PROP_W          global              $1      'counts'
          2        FETCH_DIM_W                                      $3      $1, ~2
          3        ASSIGN_REF                                               !0, $3
   15     4        PRE_INC                                                  !0
   16     5      > RETURN                                                   null

End of function __construct

End of class Car.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.23 ms | 1400 KiB | 15 Q