3v4l.org

run code in 300+ PHP versions simultaneously
<?php @ini_set('display_errors', 'on'); class Configuration { public static function get($param) { return true; } } class Cart { public function getProducts() { return array(1); } } class Context { public $cart; public function __construct() { $this->cart = new Cart(); } public static function getContext() { return new Context(); } } if (Configuration::get('LEGAL_SHIPTAXMETH') && $cart = Context::getContext()->cart && $products = $cart->getProducts() && !empty($products)) { echo "OK"; } /** * The above code snippet fails, because I think the condition is parsed like this: * * Configuration::get('LEGAL_SHIPTAXMETH') && * $cart = (Context::getContext()->cart && $products = $cart->getProducts()) * && !empty($products) * * so $cart is undefined when getProducts is called * */
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 20
Branch analysis from position: 22
Branch analysis from position: 24
filename:       /in/trEeK
function name:  (null)
number of ops:  27
compiled vars:  !0 = $cart, !1 = $products
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   BEGIN_SILENCE                                    ~2      
          1        INIT_FCALL                                               'ini_set'
          2        SEND_VAL                                                 'display_errors'
          3        SEND_VAL                                                 'on'
          4        DO_ICALL                                                 
          5        END_SILENCE                                              ~2
   36     6        INIT_STATIC_METHOD_CALL                                  'Configuration', 'get'
          7        SEND_VAL                                                 'LEGAL_SHIPTAXMETH'
          8        DO_FCALL                                      0  $4      
          9      > JMPZ_EX                                          ~5      $4, ->24
   37    10    >   INIT_STATIC_METHOD_CALL                                  'Context', 'getContext'
         11        DO_FCALL                                      0  $6      
         12        FETCH_OBJ_R                                      ~7      $6, 'cart'
         13      > JMPZ_EX                                          ~7      ~7, ->22
   38    14    >   INIT_METHOD_CALL                                         !0, 'getProducts'
         15        DO_FCALL                                      0  $8      
         16      > JMPZ_EX                                          ~9      $8, ->20
   39    17    >   ISSET_ISEMPTY_CV                                 ~10     !1
         18        BOOL_NOT                                         ~11     ~10
         19        BOOL                                             ~9      ~11
   38    20    >   ASSIGN                                           ~12     !1, ~9
         21        BOOL                                             ~7      ~12
   37    22    >   ASSIGN                                           ~13     !0, ~7
         23        BOOL                                             ~5      ~13
         24    > > JMPZ                                                     ~5, ->26
   41    25    >   ECHO                                                     'OK'
   53    26    > > RETURN                                                   1

Class Configuration:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/trEeK
function name:  get
number of ops:  3
compiled vars:  !0 = $param
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1      > RETURN                                                   <true>
   10     2*     > RETURN                                                   null

End of function get

End of class Configuration.

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

End of function getproducts

End of class Cart.

Class Context:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/trEeK
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'Cart'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'cart'
          3        OP_DATA                                                  $1
   28     4      > RETURN                                                   null

End of function __construct

Function getcontext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/trEeK
function name:  getContext
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $0      'Context'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   33     3*     > RETURN                                                   null

End of function getcontext

End of class Context.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.35 ms | 1400 KiB | 15 Q