3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private DateTimeImmutable $bar; private ?string $foo; public function getBar(): DateTimeImmutable { return $this->bar ??= new DateTimeImmutable(); } public function getFoo(): ?string { return $this->foo ??= null; } public function setFoo(string $foo): self { $this->foo = $foo; return $this; } } $foo = new Foo(); var_dump($foo->getBar()); var_dump($foo->getBar()); var_dump($foo->getFoo()); $foo->setFoo('test'); var_dump($foo->getFoo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U02G2
function name:  (null)
number of ops:  27
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'getBar'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   28     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'getBar'
         10        DO_FCALL                                      0  $6      
         11        SEND_VAR                                                 $6
         12        DO_ICALL                                                 
   29    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !0, 'getFoo'
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                                 
   30    18        INIT_METHOD_CALL                                         !0, 'setFoo'
         19        SEND_VAL_EX                                              'test'
         20        DO_FCALL                                      0          
   31    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !0, 'getFoo'
         23        DO_FCALL                                      0  $11     
         24        SEND_VAR                                                 $11
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

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

End of function getbar

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U02G2
function name:  getFoo
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_IS                                     ~0      'foo'
          1        COALESCE                                         ~1      ~0
          2        ASSIGN_OBJ                                       ~2      'foo'
          3        OP_DATA                                                  null
          4        QM_ASSIGN                                        ~1      ~2
          5        VERIFY_RETURN_TYPE                                       ~1
          6      > RETURN                                                   ~1
   15     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function getfoo

Function setfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U02G2
function name:  setFoo
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   21     3        FETCH_THIS                                       ~2      
          4        VERIFY_RETURN_TYPE                                       ~2
          5      > RETURN                                                   ~2
   22     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function setfoo

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.93 ms | 1400 KiB | 15 Q