3v4l.org

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

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

End of function getcollecteddata

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

End of function collecteddata

End of class dataHandler.

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.28 ms | 1404 KiB | 17 Q