3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace App\Entity; abstract class Entity { protected $repository; protected $transformColumns = []; protected $transformValues = []; protected $properites = []; public function __construct () { $this->transformColumns = [ 'archivedAt' => (function ($column) { return 'archived_at'; }) ]; } public function set (string $column, $value) { if (isset($this->transformColumns[$column])) { $column = $this->transformColumns[$column]($column); } if (isset($this->transformValues[$column])) { $value = $this->transformValues[$column]($value); } $this->properites[$column] = $value; return; } public function __set ($column, $value) { return $this->set($column, $value); } public function get(string $column) { if (isset($this->transformColumns[$column])) { $column = $this->transformColumns[$column]($column); } return $this->properites[$column]; } public function __get ($column) { return $this->get($column); } } $o = new Entity(); $o->archived_at = (new DateTime())->format('d-m-Y H:i:s'); echo '<pre>', var_dump($o), '</pre>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXohP
function name:  (null)
number of ops:  17
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   NEW                                              $1      'App%5CEntity%5CEntity'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   48     3        NEW                                              $5      'App%5CEntity%5CDateTime'
          4        DO_FCALL                                      0          
          5        INIT_METHOD_CALL                                         $5, 'format'
          6        SEND_VAL_EX                                              'd-m-Y+H%3Ai%3As'
          7        DO_FCALL                                      0  $7      
          8        ASSIGN_OBJ                                               !0, 'archived_at'
          9        OP_DATA                                                  $7
   49    10        ECHO                                                     '%3Cpre%3E'
         11        INIT_NS_FCALL_BY_NAME                                    'App%5CEntity%5Cvar_dump'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $8      
         14        ECHO                                                     $8
         15        ECHO                                                     '%3C%2Fpre%3E'
         16      > RETURN                                                   1

Function %00app%5Centity%5C%7Bclosure%7D%2Fin%2FFXohP%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXohP
function name:  App\Entity\{closure}
number of ops:  3
compiled vars:  !0 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1      > RETURN                                                   'archived_at'
   13     2*     > RETURN                                                   null

End of function %00app%5Centity%5C%7Bclosure%7D%2Fin%2FFXohP%3A11%240

Class App\Entity\Entity:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXohP
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00app%5Centity%5C%7Bclosure%7D%2Fin%2FFXohP%3A11%240'
   13     1        INIT_ARRAY                                       ~2      ~1, 'archivedAt'
   10     2        ASSIGN_OBJ                                               'transformColumns'
   13     3        OP_DATA                                                  ~2
   15     4      > RETURN                                                   null

End of function __construct

Function set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 11
filename:       /in/FXohP
function name:  set
number of ops:  25
compiled vars:  !0 = $column, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        FETCH_OBJ_IS                                     ~2      'transformColumns'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, !0
          4      > JMPZ                                                     ~3, ->11
   19     5    >   FETCH_OBJ_R                                      ~4      'transformColumns'
          6        FETCH_DIM_R                                      ~5      ~4, !0
          7        INIT_DYNAMIC_CALL                                        ~5
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $6      
         10        ASSIGN                                                   !0, $6
   21    11    >   FETCH_OBJ_IS                                     ~8      'transformValues'
         12        ISSET_ISEMPTY_DIM_OBJ                         0          ~8, !0
         13      > JMPZ                                                     ~9, ->20
   22    14    >   FETCH_OBJ_R                                      ~10     'transformValues'
         15        FETCH_DIM_R                                      ~11     ~10, !0
         16        INIT_DYNAMIC_CALL                                        ~11
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $12     
         19        ASSIGN                                                   !1, $12
   25    20    >   FETCH_OBJ_W                                      $14     'properites'
         21        ASSIGN_DIM                                               $14, !0
         22        OP_DATA                                                  !1
   27    23      > RETURN                                                   null
   28    24*     > RETURN                                                   null

End of function set

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXohP
function name:  __set
number of ops:  8
compiled vars:  !0 = $column, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     2        INIT_METHOD_CALL                                         'set'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   32     7*     > RETURN                                                   null

End of function __set

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/FXohP
function name:  get
number of ops:  14
compiled vars:  !0 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   35     1        FETCH_OBJ_IS                                     ~1      'transformColumns'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->10
   36     4    >   FETCH_OBJ_R                                      ~3      'transformColumns'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        INIT_DYNAMIC_CALL                                        ~4
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !0, $5
   39    10    >   FETCH_OBJ_R                                      ~7      'properites'
         11        FETCH_DIM_R                                      ~8      ~7, !0
         12      > RETURN                                                   ~8
   40    13*     > RETURN                                                   null

End of function get

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXohP
function name:  __get
number of ops:  6
compiled vars:  !0 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
   43     1        INIT_METHOD_CALL                                         'get'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   44     5*     > RETURN                                                   null

End of function __get

End of class App\Entity\Entity.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.86 ms | 1404 KiB | 15 Q