3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(E_ALL); final class foo { private int $pageId = 0; private array $pageRecord = []; private bool $isListView = false; public static function forPage(int $pageId, bool $isListView = false): self { $foo = new self(); $foo->pageId = $pageId; $foo->pageRecord = ['uid' => 0, /* retrieved from database */]; $foo->isListView = $isListView; return $foo; } public function debug(): array { return [ 'pageId' => $this->pageId, 'pageRecord' => $this->pageRecord, 'isListView' => $this->isListView, ]; } } $test1 = new foo(); $test2 = $test1::forPage(1, true); $test3 = foo::forPage(1, true); var_dump($test2->debug()); var_dump($test3->debug());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjdRo
function name:  (null)
number of ops:  28
compiled vars:  !0 = $test1, !1 = $test2, !2 = $test3
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     30719
          2        DO_ICALL                                                     
   33     3        NEW                                                  $4      'foo'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !0, $4
   34     6        FETCH_CLASS                                       0  $7      !0
          7        INIT_STATIC_METHOD_CALL                                      $7, 'forPage'
          8        SEND_VAL_EX                                                  1
          9        SEND_VAL_EX                                                  <true>
         10        DO_FCALL                                          0  $8      
         11        ASSIGN                                                       !1, $8
   35    12        INIT_STATIC_METHOD_CALL                                      'foo', 'forPage'
         13        SEND_VAL                                                     1
         14        SEND_VAL                                                     <true>
         15        DO_FCALL                                          0  $10     
         16        ASSIGN                                                       !2, $10
   37    17        INIT_FCALL                                                   'var_dump'
         18        INIT_METHOD_CALL                                             !1, 'debug'
         19        DO_FCALL                                          0  $12     
         20        SEND_VAR                                                     $12
         21        DO_ICALL                                                     
   38    22        INIT_FCALL                                                   'var_dump'
         23        INIT_METHOD_CALL                                             !2, 'debug'
         24        DO_FCALL                                          0  $14     
         25        SEND_VAR                                                     $14
         26        DO_ICALL                                                     
         27      > RETURN                                                       1

Class foo:
Function forpage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjdRo
function name:  forPage
number of ops:  15
compiled vars:  !0 = $pageId, !1 = $isListView, !2 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      <false>
   15     2        NEW                              self                $3      
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !2, $3
   16     5        ASSIGN_OBJ                                                   !2, 'pageId'
          6        OP_DATA                                                      !0
   17     7        ASSIGN_OBJ                                                   !2, 'pageRecord'
          8        OP_DATA                                                      <array>
   18     9        ASSIGN_OBJ                                                   !2, 'isListView'
         10        OP_DATA                                                      !1
   19    11        VERIFY_RETURN_TYPE                                           !2
         12      > RETURN                                                       !2
   20    13*       VERIFY_RETURN_TYPE                                           
         14*     > RETURN                                                       null

End of function forpage

Function debug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjdRo
function name:  debug
number of ops:  10
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                          ~0      'pageId'
          1        INIT_ARRAY                                           ~1      ~0, 'pageId'
   26     2        FETCH_OBJ_R                                          ~2      'pageRecord'
          3        ADD_ARRAY_ELEMENT                                    ~1      ~2, 'pageRecord'
   27     4        FETCH_OBJ_R                                          ~3      'isListView'
          5        ADD_ARRAY_ELEMENT                                    ~1      ~3, 'isListView'
          6        VERIFY_RETURN_TYPE                                           ~1
          7      > RETURN                                                       ~1
   29     8*       VERIFY_RETURN_TYPE                                           
          9*     > RETURN                                                       null

End of function debug

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
151.48 ms | 492 KiB | 11 Q