3v4l.org

run code in 500+ PHP versions simultaneously
<?php # Given two classes with the same property name but different visibility class WithPublic { public $property; function __construct( $p ) { $this->property = $p; } function getProperty() { return $this->property; } } class WithPrivate { private $property; function __construct( $p ) { $this->property = $p; } function getProperty() { return $this->property; } } $priv = new WithPrivate( 'value' ); $cache = serialize( $priv ); $mut_priv_to_pub = unserialize( str_replace( '11:"WithPrivate"', '10:"WithPublic"', $cache) ); var_dump( $mut_priv_to_pub ); # class WithPublic#4 (2) { # public $property => # NULL # private $property => # string(5) "value" # } var_export( $mut_priv_to_pub->getProperty() ); # On Zend PHP: NULL # On HHVM 3.15.4, 3.17.1: 'value'
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmrO
function name:  (null)
number of ops:  23
compiled vars:  !0 = $priv, !1 = $cache, !2 = $mut_priv_to_pub
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                                                  $3      'WithPrivate'
          1        SEND_VAL_EX                                                  'value'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   16     4        INIT_FCALL                                                   'serialize'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $6      
          7        ASSIGN                                                       !1, $6
   18     8        INIT_FCALL                                                   'unserialize'
   19     9        FRAMELESS_ICALL_3                str_replace         ~8      '11%3A%22WithPrivate%22', '10%3A%22WithPublic%22'
         10        OP_DATA                                                      !1
         11        SEND_VAL                                                     ~8
   18    12        DO_ICALL                                             $9      
         13        ASSIGN                                                       !2, $9
   21    14        INIT_FCALL                                                   'var_dump'
         15        SEND_VAR                                                     !2
         16        DO_ICALL                                                     
   29    17        INIT_FCALL                                                   'var_export'
         18        INIT_METHOD_CALL                                             !2, 'getProperty'
         19        DO_FCALL                                          0  $12     
         20        SEND_VAR                                                     $12
         21        DO_ICALL                                                     
   31    22      > RETURN                                                       1

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

End of function __construct

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

End of function getproperty

End of class WithPublic.

Class WithPrivate:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrmrO
function name:  __construct
number of ops:  4
compiled vars:  !0 = $p
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        ASSIGN_OBJ                                                   'property'
          2        OP_DATA                                                      !0
          3      > RETURN                                                       null

End of function __construct

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

End of function getproperty

End of class WithPrivate.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.94 ms | 2139 KiB | 17 Q