3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait setData { static function setData( $data ) { DataCollector::collectedData( 'set', $data ); } } trait dataHandler { use setData; static function getCollectedData() { DataCollector::collectedData( 'get' ); } private static function collectedData( $type, $value = NULL ) { if( strtolower( $type ) === 'set' ) { DataCollector::$CollectionData[] = $value; var_dump( new DataCollector() ); } elseif( strtolower( $type ) === 'get' ) return DataCollector::$CollectionData; } } class DataCollector { use dataHandler { collectedData as public; } public function __construct() { return $this; } 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/9USIB
function name:  (null)
number of ops:  23
compiled vars:  !0 = $Field1, !1 = $Field2, !2 = $A
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'datahandler'
   25     1        DECLARE_CLASS                                            'datacollector'
   31     2        DECLARE_CLASS                                            'form'
   33     3        DECLARE_CLASS                                            'field', 'form'
   39     4        DECLARE_CLASS                                            'a'
   47     5        NEW                                              $3      'Field'
          6        SEND_VAL_EX                                              '1'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $3
   48     9        NEW                                              $6      'Field'
         10        SEND_VAL_EX                                              '2'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $6
   49    13        NEW                                              $9      'A'
         14        SEND_VAL_EX                                              '3'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $9
   53    17        INIT_FCALL                                               'var_dump'
         18        INIT_STATIC_METHOD_CALL                                  'DataCollector', 'getCollectedData'
         19        DO_FCALL                                      0  $12     
         20        SEND_VAR                                                 $12
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

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

End of function collecteddata

End of class dataHandler.

Class DataCollector:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9USIB
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_THIS                                       ~0      
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function __construct

End of class DataCollector.

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/9USIB
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   35     2        INIT_STATIC_METHOD_CALL                                  'setData'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   36     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/9USIB
function name:  __construct
number of ops:  6
compiled vars:  !0 = $type, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   43     2        INIT_STATIC_METHOD_CALL                                  'setData'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   44     5      > RETURN                                                   null

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.37 ms | 1404 KiB | 17 Q