3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DataCollector { static function setData( $data ) { $this->collectedData( 'set', $data ); } private function collectedData( $type, $value = NULL ) { static $CollectionData = array(); if( strtolower( $type ) === 'set' ) $CollectionData[] = $value; elseif( strtolower( $type ) === 'get' ) return $CollectionData; } private static function getCollectedData() { self::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 ); } } $Field1 = new Field( 'text' ); $Field2 = new Field( 'html' ); var_dump( 'Collected Data', dataHandler::getCollectedData() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BqFjb
function name:  (null)
number of ops:  18
compiled vars:  !0 = $Field1, !1 = $Field2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   DECLARE_CLASS                                            'datahandler'
   24     1        DECLARE_CLASS                                            'form'
   26     2        DECLARE_CLASS                                            'field', 'form'
   32     3        NEW                                              $2      'Field'
          4        SEND_VAL_EX                                              'text'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $2
   33     7        NEW                                              $5      'Field'
          8        SEND_VAL_EX                                              'html'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $5
   35    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAL                                                 'Collected+Data'
         13        INIT_STATIC_METHOD_CALL                                  'dataHandler', 'getCollectedData'
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR                                                 $8
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

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

End of function __construct

End of class Field.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.87 ms | 1400 KiB | 17 Q