3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DataCollector { protected static $CollectionData = array(); static function setData( $data ) { self::$CollectionData[] = $data; } static function getCollectedData() { return DataCollector::$CollectionData; } } class dataHandler { use DataCollector { getCollectedData as public; } } class Form {} class Field extends Form { use DataCollector { getCollectedData as private; } public function __construct( $type, $text = NULL ) { self::setData( $type ); } } $Field1 = new Field( 'text' ); $Field2 = new Field( 'html', 'hello' ); var_dump( dataHandler::getCollectedData() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99EH5
function name:  (null)
number of ops:  17
compiled vars:  !0 = $Field1, !1 = $Field2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                            'datahandler'
   20     1        DECLARE_CLASS                                            'field', 'form'
   28     2        NEW                                              $2      'Field'
          3        SEND_VAL_EX                                              'text'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   29     6        NEW                                              $5      'Field'
          7        SEND_VAL_EX                                              'html'
          8        SEND_VAL_EX                                              'hello'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $5
   30    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/99EH5
function name:  setData
number of ops:  5
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        FETCH_STATIC_PROP_W          global              $1      'CollectionData'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
    7     4      > 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/99EH5
function name:  getCollectedData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'CollectionData'
          1      > RETURN                                                   ~0
   11     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/99EH5
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   24     2        INIT_STATIC_METHOD_CALL                                  'setData'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   25     5      > RETURN                                                   null

End of function __construct

End of class Field.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.64 ms | 1400 KiB | 15 Q