3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Comparable { abstract public function isGreaterThan($other); public function isLesserThan($other) { return $other->isGreaterThan($this); } public function equals($other) { return !($this->isGreaterThan($other) || $this->isLesserThan($other)); } } class SimpleInt { use Comparable; private $value; public function __construct($value) { $this->value = $value; } public function isGreaterThan($other) { return $this->value > $other->value; } } $i = new SimpleInt(10); echo (int)($i->equals($i));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ph7pK
function name:  (null)
number of ops:  11
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_CLASS                                            'simpleint'
   35     1        NEW                                              $1      'SimpleInt'
          2        SEND_VAL_EX                                              10
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   37     5        INIT_METHOD_CALL                                         !0, 'equals'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $4      
          8        CAST                                          4  ~5      $4
          9        ECHO                                                     ~5
         10      > RETURN                                                   1

Class Comparable:
Function isgreaterthan:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ph7pK
function name:  isGreaterThan
number of ops:  2
compiled vars:  !0 = $other
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function isgreaterthan

Function islesserthan:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ph7pK
function name:  isLesserThan
number of ops:  7
compiled vars:  !0 = $other
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_METHOD_CALL                                         !0, 'isGreaterThan'
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
   10     6*     > RETURN                                                   null

End of function islesserthan

Function equals:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/ph7pK
function name:  equals
number of ops:  12
compiled vars:  !0 = $other
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        INIT_METHOD_CALL                                         'isGreaterThan'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > JMPNZ_EX                                         ~2      $1, ->9
          5    >   INIT_METHOD_CALL                                         'isLesserThan'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $3      
          8        BOOL                                             ~2      $3
          9    >   BOOL_NOT                                         ~4      ~2
         10      > RETURN                                                   ~4
   15    11*     > RETURN                                                   null

End of function equals

End of class Comparable.

Class SimpleInt:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ph7pK
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
   27     3      > RETURN                                                   null

End of function __construct

Function isgreaterthan:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ph7pK
function name:  isGreaterThan
number of ops:  6
compiled vars:  !0 = $other
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        FETCH_OBJ_R                                      ~1      'value'
          2        FETCH_OBJ_R                                      ~2      !0, 'value'
          3        IS_SMALLER                                       ~3      ~2, ~1
          4      > RETURN                                                   ~3
   32     5*     > RETURN                                                   null

End of function isgreaterthan

End of class SimpleInt.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.84 ms | 1390 KiB | 13 Q