3v4l.org

run code in 300+ PHP versions simultaneously
<?php class bar { public static function foo($data) { return $data; } } class post { public static function respond($status, $values = NULL) { if($values != NULL){ echo json_encode(['status' => $status, 'values' => $values]); return true; }else{ echo json_encode(['status' => $status]); return true; } return false; } public static function respond_catch($function) { try{ $values = $function(); } catch(Exception $e) { if($e->getMessage() != NULL ){ //There is a message echo json_encode(['status' => $default_message]); return false; }else{ //otherwise echo json_encode(['status' => 'Nastala chyba. Skúste to znova prosím.']); return false; } } echo json_encode(['status' => 'OK', 'values' => $values]); return true; } } $data = ['some','data']; post::respond_catch( function($data){ return bar::foo($data); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHWgT
function name:  (null)
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   ASSIGN                                                   !0, <array>
   48     1        INIT_STATIC_METHOD_CALL                                  'post', 'respond_catch'
   49     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FbHWgT%3A49%240'
   51     3        SEND_VAL                                                 ~2
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FbHWgT%3A49%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHWgT
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   50     1        INIT_STATIC_METHOD_CALL                                  'bar', 'foo'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   51     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FbHWgT%3A49%240

Class bar:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHWgT
function name:  foo
number of ops:  3
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1      > RETURN                                                   !0
    7     2*     > RETURN                                                   null

End of function foo

End of class bar.

Class post:
Function respond:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHWgT
function name:  respond
number of ops:  20
compiled vars:  !0 = $status, !1 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   14     2        IS_NOT_EQUAL                                             !1, null
          3      > JMPZ                                                     ~2, ->12
   15     4    >   INIT_FCALL                                               'json_encode'
          5        INIT_ARRAY                                       ~3      !0, 'status'
          6        ADD_ARRAY_ELEMENT                                ~3      !1, 'values'
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9        ECHO                                                     $4
   16    10      > RETURN                                                   <true>
         11*       JMP                                                      ->18
   18    12    >   INIT_FCALL                                               'json_encode'
         13        INIT_ARRAY                                       ~5      !0, 'status'
         14        SEND_VAL                                                 ~5
         15        DO_ICALL                                         $6      
         16        ECHO                                                     $6
   19    17      > RETURN                                                   <true>
   22    18*       RETURN                                                   <false>
   23    19*     > RETURN                                                   null

End of function respond

Function respond_catch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 5
Branch analysis from position: 5
2 jumps found. (Code = 107) Position 1 = 6, Position 2 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHWgT
function name:  respond_catch
number of ops:  30
compiled vars:  !0 = $function, !1 = $values, !2 = $e, !3 = $default_message
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   28     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                                   !1, $4
          4      > JMP                                                      ->22
   29     5  E > > CATCH                                       last         'Exception'
   30     6    >   INIT_METHOD_CALL                                         !2, 'getMessage'
          7        DO_FCALL                                      0  $6      
          8        IS_NOT_EQUAL                                             $6, null
          9      > JMPZ                                                     ~7, ->17
   32    10    >   INIT_FCALL                                               'json_encode'
         11        INIT_ARRAY                                       ~8      !3, 'status'
         12        SEND_VAL                                                 ~8
         13        DO_ICALL                                         $9      
         14        ECHO                                                     $9
   33    15      > RETURN                                                   <false>
         16*       JMP                                                      ->22
   36    17    >   INIT_FCALL                                               'json_encode'
         18        SEND_VAL                                                 <array>
         19        DO_ICALL                                         $10     
         20        ECHO                                                     $10
   37    21      > RETURN                                                   <false>
   41    22    >   INIT_FCALL                                               'json_encode'
         23        INIT_ARRAY                                       ~11     'OK', 'status'
         24        ADD_ARRAY_ELEMENT                                ~11     !1, 'values'
         25        SEND_VAL                                                 ~11
         26        DO_ICALL                                         $12     
         27        ECHO                                                     $12
   42    28      > RETURN                                                   <true>
   43    29*     > RETURN                                                   null

End of function respond_catch

End of class post.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.01 ms | 1404 KiB | 15 Q