3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Permissions { public function isReadable(); public function isWritable(); } class ReadOnly implements Permissions { public function isReadable() { return true; } public function isWritable() { return false; } } class WriteOnly implements Permissions { public function isReadable() { return false; } public function isWritable() { return true; } } class ReadWrite implements Permissions { public function isReadable() { return true; } public function isWritable() { return true; } } class Field { private $name; private $permissions; public function __construct($name, Permissions $permissions = null) { $this->name = (string) $name; $this->permissions = $permissions ?: new ReadOnly; } public function getName() { return $this->name; } public function isReadable() { return $this->permissions->isReadable(); } public function isWritable() { return $this->permissions->isWritable(); } } $a = new Field('a'); var_dump($a->isReadable()); var_dump($a->isWritable());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  (null)
number of ops:  18
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'readonly'
   23     1        DECLARE_CLASS                                            'writeonly'
   35     2        DECLARE_CLASS                                            'readwrite'
   71     3        NEW                                              $1      'Field'
          4        SEND_VAL_EX                                              'a'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
   72     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'isReadable'
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                                 
   73    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !0, 'isWritable'
         14        DO_FCALL                                      0  $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class Permissions:
Function isreadable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isReadable
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   null

End of function isreadable

Function iswritable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isWritable
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   null

End of function iswritable

End of class Permissions.

Class ReadOnly:
Function isreadable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isReadable
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E > > RETURN                                                   <true>
   15     1*     > RETURN                                                   null

End of function isreadable

Function iswritable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isWritable
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   <false>
   19     1*     > RETURN                                                   null

End of function iswritable

End of class ReadOnly.

Class WriteOnly:
Function isreadable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isReadable
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E > > RETURN                                                   <false>
   27     1*     > RETURN                                                   null

End of function isreadable

Function iswritable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isWritable
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E > > RETURN                                                   <true>
   31     1*     > RETURN                                                   null

End of function iswritable

End of class WriteOnly.

Class ReadWrite:
Function isreadable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isReadable
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E > > RETURN                                                   <true>
   39     1*     > RETURN                                                   null

End of function isreadable

Function iswritable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isWritable
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E > > RETURN                                                   <true>
   43     1*     > RETURN                                                   null

End of function iswritable

End of class ReadWrite.

Class Field:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  __construct
number of ops:  12
compiled vars:  !0 = $name, !1 = $permissions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   53     2        CAST                                          6  ~3      !0
          3        ASSIGN_OBJ                                               'name'
          4        OP_DATA                                                  ~3
   54     5        JMP_SET                                          ~5      !1, ->9
          6        NEW                                              $6      'ReadOnly'
          7        DO_FCALL                                      0          
          8        QM_ASSIGN                                        ~5      $6
          9        ASSIGN_OBJ                                               'permissions'
         10        OP_DATA                                                  ~5
   55    11      > RETURN                                                   null

End of function __construct

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

End of function getname

Function isreadable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isReadable
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   FETCH_OBJ_R                                      ~0      'permissions'
          1        INIT_METHOD_CALL                                         ~0, 'isReadable'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   63     4*     > RETURN                                                   null

End of function isreadable

Function iswritable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nWqvn
function name:  isWritable
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   FETCH_OBJ_R                                      ~0      'permissions'
          1        INIT_METHOD_CALL                                         ~0, 'isWritable'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   67     4*     > RETURN                                                   null

End of function iswritable

End of class Field.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.1 ms | 1404 KiB | 15 Q