3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); namespace GetObjectVars; // use function PHPStan\Testing\assertType; function assertType($_, $a) {var_dump($a);} class Base { public int $a = 1; public string $b = ''; protected string $c = ''; private bool $d = false; public function getVars(): void { assertType('array{a: int, b: string, c: string, d: bool}', get_object_vars($this)); } } class Extended extends Base { public string $foo = 'foo'; public function getExtendedVars(): void { assertType('array{a: int, b: string, c: string}', get_object_vars($this)); } } (new Base)->getVars(); (new Extended)->getVars(); (new Extended)->getExtendedVars();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hM8MU
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $0      'GetObjectVars%5CBase'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'getVars'
          3        DO_FCALL                                      0          
   35     4        NEW                                              $3      'GetObjectVars%5CExtended'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $3, 'getVars'
          7        DO_FCALL                                      0          
   36     8        NEW                                              $6      'GetObjectVars%5CExtended'
          9        DO_FCALL                                      0          
         10        INIT_METHOD_CALL                                         $6, 'getExtendedVars'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Function getobjectvars%5Casserttype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hM8MU
function name:  GetObjectVars\assertType
number of ops:  6
compiled vars:  !0 = $_, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5Cvar_dump'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
          5      > RETURN                                                   null

End of function getobjectvars%5Casserttype

Class GetObjectVars\Base:
Function getvars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hM8MU
function name:  getVars
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5CassertType'
          1        SEND_VAL_EX                                              'array%7Ba%3A+int%2C+b%3A+string%2C+c%3A+string%2C+d%3A+bool%7D'
          2        INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5Cget_object_vars'
          3        FETCH_THIS                                       $0      
          4        SEND_VAR_EX                                              $0
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0          
   19     8      > RETURN                                                   null

End of function getvars

End of class GetObjectVars\Base.

Class GetObjectVars\Extended:
Function getextendedvars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hM8MU
function name:  getExtendedVars
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5CassertType'
          1        SEND_VAL_EX                                              'array%7Ba%3A+int%2C+b%3A+string%2C+c%3A+string%7D'
          2        INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5Cget_object_vars'
          3        FETCH_THIS                                       $0      
          4        SEND_VAR_EX                                              $0
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0          
   30     8      > RETURN                                                   null

End of function getextendedvars

Function getvars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hM8MU
function name:  getVars
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5CassertType'
          1        SEND_VAL_EX                                              'array%7Ba%3A+int%2C+b%3A+string%2C+c%3A+string%2C+d%3A+bool%7D'
          2        INIT_NS_FCALL_BY_NAME                                    'GetObjectVars%5Cget_object_vars'
          3        FETCH_THIS                                       $0      
          4        SEND_VAR_EX                                              $0
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0          
   19     8      > RETURN                                                   null

End of function getvars

End of class GetObjectVars\Extended.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.28 ms | 1010 KiB | 18 Q