3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Singleton { private static ?object $instance = null; public static function GetInstance(): object { // Reflection better here for Dependency Injection into the instance return self::$instance ?? (self::$instance = new self()); } public function __set(string $property, string $value) { $this->{$property} = $value; } public function __get(string $property): mixed { return $this->{$property} ?? null; } protected function __construct() {} private function __clone() {} } class User { use Singleton; protected function __construct() { // Change this to the select inner join query foreach(['id' => 1, 'column' => 'test', 'points' => 3] as $column => $value) $this->$column = $value; } public function save(): mixed { // Change this to an update query return get_object_vars($this); } } User::getInstance()->points = 5; // Dynamically change values var_dump(User::getInstance()->save()); // Then update
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3WrMs
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   DECLARE_CLASS                                            'user'
   40     1        INIT_STATIC_METHOD_CALL                                  'User', 'getInstance'
          2        DO_FCALL                                      0  $0      
          3        SEPARATE                                         $0      $0
          4        ASSIGN_OBJ                                               $0, 'points'
          5        OP_DATA                                                  5
   41     6        INIT_FCALL                                               'var_dump'
          7        INIT_STATIC_METHOD_CALL                                  'User', 'getInstance'
          8        DO_FCALL                                      0  $2      
          9        INIT_METHOD_CALL                                         $2, 'save'
         10        DO_FCALL                                      0  $3      
         11        SEND_VAR                                                 $3
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class Singleton:
Function getinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3WrMs
function name:  GetInstance
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_STATIC_PROP_IS                             ~0      'instance'
          1        COALESCE                                         ~1      ~0
          2        NEW                          self                $3      
          3        DO_FCALL                                      0          
          4        ASSIGN_STATIC_PROP                               ~2      'instance'
          5        OP_DATA                                                  $3
          6        QM_ASSIGN                                        ~1      ~2
          7        VERIFY_RETURN_TYPE                                       ~1
          8      > RETURN                                                   ~1
   10     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function getinstance

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3WrMs
function name:  __set
number of ops:  5
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   14     4      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3WrMs
function name:  __get
number of ops:  7
compiled vars:  !0 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        FETCH_OBJ_IS                                     ~1      !0
          2        COALESCE                                         ~2      ~1
          3        QM_ASSIGN                                        ~2      null
          4      > RETURN                                                   ~2
   18     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function __get

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

End of function __construct

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

End of function __clone

End of class Singleton.

Class User:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 6
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 6
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/3WrMs
function name:  __construct
number of ops:  8
compiled vars:  !0 = $value, !1 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E > > FE_RESET_R                                       $2      <array>, ->6
          1    > > FE_FETCH_R                                       ~3      $2, !0, ->6
          2    >   ASSIGN                                                   !1, ~3
   31     3        ASSIGN_OBJ                                               !1
          4        OP_DATA                                                  !0
   30     5      > JMP                                                      ->1
          6    >   FE_FREE                                                  $2
   32     7      > RETURN                                                   null

End of function __construct

Function save:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3WrMs
function name:  save
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   37     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function save

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.23 ms | 1004 KiB | 15 Q