3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private ?int $id; private ?string $name; /** * @param null|int<1, 20> $id */ private function __construct(?int $id = null, ?string $name = null) { $this->id = $id; $this->name = $name; } final public static function withId(int $id) : self { if ($id < 1 || $id > 20) { throw new \Exception(); } $self = new self; $self->__construct($id); return $self; } } class Bar { private ?int $id; private ?string $name; /** * @param null|int<1, 20> $id */ private function __construct(?int $id = null, ?string $name = null) { $this->id = $id; $this->name = $name; } final public static function withId(int $id) : self { if ($id < 1 || $id > 20) { throw new \Exception(); } return new self($id); } } $foo = Foo::withId(1); var_dump($foo); $bar = Bar::withId(1); var_dump($bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v25j9
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   INIT_STATIC_METHOD_CALL                                  'Foo', 'withId'
          1        SEND_VAL                                                 1
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   55     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   57     7        INIT_STATIC_METHOD_CALL                                  'Bar', 'withId'
          8        SEND_VAL                                                 1
          9        DO_FCALL                                      0  $5      
         10        ASSIGN                                                   !1, $5
   58    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v25j9
function name:  __construct
number of ops:  7
compiled vars:  !0 = $id, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
   13     2        ASSIGN_OBJ                                               'id'
          3        OP_DATA                                                  !0
   14     4        ASSIGN_OBJ                                               'name'
          5        OP_DATA                                                  !1
   15     6      > RETURN                                                   null

End of function __construct

Function withid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/v25j9
function name:  withId
number of ops:  19
compiled vars:  !0 = $id, !1 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        IS_SMALLER                                       ~2      !0, 1
          2      > JMPNZ_EX                                         ~2      ~2, ->5
          3    >   IS_SMALLER                                       ~3      20, !0
          4        BOOL                                             ~2      ~3
          5    > > JMPZ                                                     ~2, ->9
   20     6    >   NEW                                              $4      'Exception'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $4
   23     9    >   NEW                          self                $6      
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $6
   24    12        INIT_METHOD_CALL                                         !1, '__construct'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   26    15        VERIFY_RETURN_TYPE                                       !1
         16      > RETURN                                                   !1
   27    17*       VERIFY_RETURN_TYPE                                       
         18*     > RETURN                                                   null

End of function withid

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v25j9
function name:  __construct
number of ops:  7
compiled vars:  !0 = $id, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
   40     2        ASSIGN_OBJ                                               'id'
          3        OP_DATA                                                  !0
   41     4        ASSIGN_OBJ                                               'name'
          5        OP_DATA                                                  !1
   42     6      > RETURN                                                   null

End of function __construct

Function withid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/v25j9
function name:  withId
number of ops:  16
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   46     1        IS_SMALLER                                       ~1      !0, 1
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   IS_SMALLER                                       ~2      20, !0
          4        BOOL                                             ~1      ~2
          5    > > JMPZ                                                     ~1, ->9
   47     6    >   NEW                                              $3      'Exception'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $3
   50     9    >   NEW                          self                $5      
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        VERIFY_RETURN_TYPE                                       $5
         13      > RETURN                                                   $5
   51    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function withid

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.15 ms | 1020 KiB | 14 Q