3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DataCollector { static function setData( $data ) { static $CollectionData = array(); echo self::$CollectionData[] = $data; echo "\n"; } static function getCollectedData() { return self::$CollectionData; } } class dataHandler { use DataCollector {} } class Form { use DataCollector { getCollectedData as private; } } class Field extends Form { public function __construct( $type ) { self::setData( $type ); } } $Field1 = new Field( 'text' ); $Field2 = new Field( 'email' ); var_dump( dataHandler::getCollectedData() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TgmMs
function name:  (null)
number of ops:  17
compiled vars:  !0 = $Field1, !1 = $Field2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'datahandler'
   17     1        DECLARE_CLASS                                            'form'
   19     2        DECLARE_CLASS                                            'field', 'form'
   25     3        NEW                                              $2      'Field'
          4        SEND_VAL_EX                                              'text'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $2
   26     7        NEW                                              $5      'Field'
          8        SEND_VAL_EX                                              'email'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $5
   27    11        INIT_FCALL                                               'var_dump'
         12        INIT_STATIC_METHOD_CALL                                  'dataHandler', 'getCollectedData'
         13        DO_FCALL                                      0  $8      
         14        SEND_VAR                                                 $8
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class DataCollector:
Function setdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TgmMs
function name:  setData
number of ops:  8
compiled vars:  !0 = $data, !1 = $CollectionData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        BIND_STATIC                                              !1
    6     2        FETCH_STATIC_PROP_W          global              $2      'CollectionData'
          3        ASSIGN_DIM                                       ~3      $2
          4        OP_DATA                                                  !0
          5        ECHO                                                     ~3
    7     6        ECHO                                                     '%0A'
    8     7      > RETURN                                                   null

End of function setdata

Function getcollecteddata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TgmMs
function name:  getCollectedData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'CollectionData'
          1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function getcollecteddata

End of class DataCollector.

Class dataHandler: [no user functions]
Class Form: [no user functions]
Class Field:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TgmMs
function name:  __construct
number of ops:  5
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_STATIC_METHOD_CALL                                  'setData'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   22     4      > RETURN                                                   null

End of function __construct

End of class Field.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.9 ms | 1400 KiB | 15 Q