3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataCollector { private static $CollectionData = array(); private static function collectedData( $type, $value = NULL ) { if( strtolower( $type ) === 'set' ) { $CollectionData[] = $value; var_dump($CollectionData); } elseif( strtolower( $type ) === 'get' ) return self::$CollectionData; } } trait setData { static function setData( $data ) { DataCollector::collectedData( 'set', $data ); } } trait dataHandler { static function getCollectedData() { DataCollector::collectedData( 'get' ); } } class Form { use setData {} } class Field extends Form { public function __construct( $type, $text = NULL ) { DataCollector::setData( $type ); } } class A { use setData{} public function __construct( $type, $text = NULL ) { self::setData( $type ); } } $Field1 = new Field( '1' ); $Field2 = new Field( '2' ); $A = new A( '3' ); DataCollector::setData('4'); dataHandler::setData('5'); var_dump( dataHandler::getCollectedData() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMA60
function name:  (null)
number of ops:  27
compiled vars:  !0 = $Field1, !1 = $Field2, !2 = $A
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   DECLARE_CLASS                                            'form'
   29     1        DECLARE_CLASS                                            'field', 'form'
   35     2        DECLARE_CLASS                                            'a'
   43     3        NEW                                              $3      'Field'
          4        SEND_VAL_EX                                              '1'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   44     7        NEW                                              $6      'Field'
          8        SEND_VAL_EX                                              '2'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $6
   45    11        NEW                                              $9      'A'
         12        SEND_VAL_EX                                              '3'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $9
   46    15        INIT_STATIC_METHOD_CALL                                  'DataCollector', 'setData'
         16        SEND_VAL_EX                                              '4'
         17        DO_FCALL                                      0          
   47    18        INIT_STATIC_METHOD_CALL                                  'dataHandler', 'setData'
         19        SEND_VAL_EX                                              '5'
         20        DO_FCALL                                      0          
   49    21        INIT_FCALL                                               'var_dump'
         22        INIT_STATIC_METHOD_CALL                                  'dataHandler', 'getCollectedData'
         23        DO_FCALL                                      0  $14     
         24        SEND_VAR                                                 $14
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Class DataCollector:
Function collecteddata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/tMA60
function name:  collectedData
number of ops:  21
compiled vars:  !0 = $type, !1 = $value, !2 = $CollectionData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    6     2        INIT_FCALL                                               'strtolower'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        IS_IDENTICAL                                             $3, 'set'
          6      > JMPZ                                                     ~4, ->13
    7     7    >   ASSIGN_DIM                                               !2
          8        OP_DATA                                                  !1
    8     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
         12      > JMP                                                      ->20
   10    13    >   INIT_FCALL                                               'strtolower'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $7      
         16        IS_IDENTICAL                                             $7, 'get'
         17      > JMPZ                                                     ~8, ->20
   11    18    >   FETCH_STATIC_PROP_R          unknown             ~9      'CollectionData'
         19      > RETURN                                                   ~9
   12    20    > > RETURN                                                   null

End of function collecteddata

End of class DataCollector.

Class setData:
Function setdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMA60
function name:  setData
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_STATIC_METHOD_CALL                                  'DataCollector', 'collectedData'
          2        SEND_VAL_EX                                              'set'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   18     5      > RETURN                                                   null

End of function setdata

End of class setData.

Class dataHandler:
Function getcollecteddata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMA60
function name:  getCollectedData
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_STATIC_METHOD_CALL                                  'DataCollector', 'collectedData'
          1        SEND_VAL_EX                                              'get'
          2        DO_FCALL                                      0          
   24     3      > RETURN                                                   null

End of function getcollecteddata

End of class dataHandler.

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/tMA60
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   31     2        INIT_STATIC_METHOD_CALL                                  'DataCollector', 'setData'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   32     5      > RETURN                                                   null

End of function __construct

End of class Field.

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMA60
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   39     2        INIT_STATIC_METHOD_CALL                                  'setData'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   40     5      > RETURN                                                   null

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.79 ms | 1404 KiB | 17 Q