3v4l.org

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

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

End of function setdata

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

End of function collecteddata

Function getcollecteddata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tUaYR
function name:  getCollectedData
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'DataCollector', 'collectedData'
          1        SEND_VAL                                                 'get'
          2        DO_FCALL                                      0          
   21     3      > 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/tUaYR
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   30     2        INIT_STATIC_METHOD_CALL                                  'DataCollector', 'setData'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0          
   31     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/tUaYR
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   38     2        INIT_STATIC_METHOD_CALL                                  'DataCollector', 'setData'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0          
   39     5      > RETURN                                                   null

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.59 ms | 1396 KiB | 17 Q