3v4l.org

run code in 300+ PHP versions simultaneously
<?php function converTo($date, $format = 'Y-m-d', $default = null, callable $funcExc = null ) { if (empty($date)) { return $default; } if (!is_string($format)) { throw new \InvalidArgumentException("Неверный формат"); } try { if (!($date instanceof \DateTime)) { if (is_numeric($date) && ( strlen($timestamp) == 13 || strlen($timestamp) == 10 )) { $date = new \DateTime("@" . $date); } elseif (is_string($date) && (strtotime($date) !== false)) { $date = new \DateTime("@" . strtotime($date)); } elseif(is_string($date)) { $date = new \DateTime($date); } else { throw new \InvalidArgumentException("Не удалось распознать формат входящей даты"); } } if(!($date = $date->format($format))) { throw new \InvalidArgumentException("Произошла ошибка при приведению к заданному формату: " . $format); } } catch (\Exception $e) { if ($funcExc !== null) { call_user_func($funcExc, $date); } throw $e; } return $date->format($format) ; } var_dump(converTo(['asda'])); die; abstract class T { static public $instanses; final private function __construct(){ } public static function getInstance() { if (!(static::$instanses instanceof static)) { static::$instanses = new static; } return static::$instanses; } } class A extends T { static public $instanses; } class B extends A { static public $instanses; } $t = A::getInstance(); var_dump($t); $t1 = B::getInstance(); var_dump($t1); new B(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/MWd1K
function name:  (null)
number of ops:  23
compiled vars:  !0 = $t, !1 = $t1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'converto'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $2      
          4        SEND_VAR                                                 $2
          5        DO_ICALL                                                 
   35     6      > EXIT                                                     
   65     7*       INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          8*       DO_FCALL                                      0  $4      
          9*       ASSIGN                                                   !0, $4
   66    10*       INIT_FCALL                                               'var_dump'
         11*       SEND_VAR                                                 !0
         12*       DO_ICALL                                                 
   68    13*       INIT_STATIC_METHOD_CALL                                  'B', 'getInstance'
         14*       DO_FCALL                                      0  $7      
         15*       ASSIGN                                                   !1, $7
   69    16*       INIT_FCALL                                               'var_dump'
         17*       SEND_VAR                                                 !1
         18*       DO_ICALL                                                 
   71    19*       NEW                                              $10     'B'
         20*       DO_FCALL                                      0          
         21*       FREE                                                     $10
   73    22*     > RETURN                                                   1

Function converto:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 63
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 35
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 74
Branch analysis from position: 69
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 52
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 59
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 59
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 27
Branch analysis from position: 28
Branch analysis from position: 63
Found catch point at position: 75
Branch analysis from position: 75
2 jumps found. (Code = 107) Position 1 = 76, Position 2 = -2
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 81
Branch analysis from position: 78
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 81
filename:       /in/MWd1K
function name:  converTo
number of ops:  87
compiled vars:  !0 = $date, !1 = $format, !2 = $default, !3 = $funcExc, !4 = $timestamp, !5 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'Y-m-d'
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      null
    4     4        ISSET_ISEMPTY_CV                                         !0
          5      > JMPZ                                                     ~6, ->7
    5     6    > > RETURN                                                   !2
    7     7    >   TYPE_CHECK                                   64  ~7      !1
          8        BOOL_NOT                                         ~8      ~7
          9      > JMPZ                                                     ~8, ->14
    8    10    >   NEW                                              $9      'InvalidArgumentException'
         11        SEND_VAL_EX                                              '%D0%9D%D0%B5%D0%B2%D0%B5%D1%80%D0%BD%D1%8B%D0%B9+%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $9
   11    14    >   INSTANCEOF                                       ~11     !0, 'DateTime'
         15        BOOL_NOT                                         ~12     ~11
         16      > JMPZ                                                     ~12, ->63
   12    17    >   INIT_FCALL                                               'is_numeric'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $13     
         20      > JMPZ_EX                                          ~14     $13, ->28
         21    >   STRLEN                                           ~15     !4
         22        IS_EQUAL                                         ~16     ~15, 13
         23      > JMPNZ_EX                                         ~16     ~16, ->27
         24    >   STRLEN                                           ~17     !4
         25        IS_EQUAL                                         ~18     ~17, 10
         26        BOOL                                             ~16     ~18
         27    >   BOOL                                             ~14     ~16
         28    > > JMPZ                                                     ~14, ->35
   13    29    >   NEW                                              $19     'DateTime'
         30        CONCAT                                           ~20     '%40', !0
         31        SEND_VAL_EX                                              ~20
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !0, $19
         34      > JMP                                                      ->63
   14    35    >   TYPE_CHECK                                   64  ~23     !0
         36      > JMPZ_EX                                          ~23     ~23, ->42
         37    >   INIT_FCALL                                               'strtotime'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                         $24     
         40        TYPE_CHECK                                  1018  ~25     $24
         41        BOOL                                             ~23     ~25
         42    > > JMPZ                                                     ~23, ->52
   15    43    >   NEW                                              $26     'DateTime'
         44        INIT_FCALL                                               'strtotime'
         45        SEND_VAR                                                 !0
         46        DO_ICALL                                         $27     
         47        CONCAT                                           ~28     '%40', $27
         48        SEND_VAL_EX                                              ~28
         49        DO_FCALL                                      0          
         50        ASSIGN                                                   !0, $26
         51      > JMP                                                      ->63
   16    52    >   TYPE_CHECK                                   64          !0
         53      > JMPZ                                                     ~31, ->59
   17    54    >   NEW                                              $32     'DateTime'
         55        SEND_VAR_EX                                              !0
         56        DO_FCALL                                      0          
         57        ASSIGN                                                   !0, $32
         58      > JMP                                                      ->63
   19    59    >   NEW                                              $35     'InvalidArgumentException'
         60        SEND_VAL_EX                                              '%D0%9D%D0%B5+%D1%83%D0%B4%D0%B0%D0%BB%D0%BE%D1%81%D1%8C+%D1%80%D0%B0%D1%81%D0%BF%D0%BE%D0%B7%D0%BD%D0%B0%D1%82%D1%8C+%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82+%D0%B2%D1%85%D0%BE%D0%B4%D1%8F%D1%89%D0%B5%D0%B9+%D0%B4%D0%B0%D1%82%D1%8B'
         61        DO_FCALL                                      0          
         62      > THROW                                         0          $35
   22    63    >   INIT_METHOD_CALL                                         !0, 'format'
         64        SEND_VAR_EX                                              !1
         65        DO_FCALL                                      0  $37     
         66        ASSIGN                                           ~38     !0, $37
         67        BOOL_NOT                                         ~39     ~38
         68      > JMPZ                                                     ~39, ->74
   23    69    >   NEW                                              $40     'InvalidArgumentException'
         70        CONCAT                                           ~41     '%D0%9F%D1%80%D0%BE%D0%B8%D0%B7%D0%BE%D1%88%D0%BB%D0%B0+%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B0+%D0%BF%D1%80%D0%B8+%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%B8%D1%8E+%D0%BA+%D0%B7%D0%B0%D0%B4%D0%B0%D0%BD%D0%BD%D0%BE%D0%BC%D1%83+%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D1%83%3A+', !1
         71        SEND_VAL_EX                                              ~41
         72        DO_FCALL                                      0          
         73      > THROW                                         0          $40
         74    > > JMP                                                      ->82
   25    75  E > > CATCH                                       last         'Exception'
   26    76    >   TYPE_CHECK                                  1020          !3
         77      > JMPZ                                                     ~43, ->81
   27    78    >   INIT_USER_CALL                                1          'call_user_func', !3
         79        SEND_USER                                                !0
         80        DO_FCALL                                      0          
   29    81    > > THROW                                         0          !5
   32    82    >   INIT_METHOD_CALL                                         !0, 'format'
         83        SEND_VAR_EX                                              !1
         84        DO_FCALL                                      0  $45     
         85      > RETURN                                                   $45
   33    86*     > RETURN                                                   null

End of function converto

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

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/MWd1K
function name:  getInstance
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instanses'
          1        INSTANCEOF                                       ~1      ~0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
   48     4    >   NEW                          static              $4      
          5        DO_FCALL                                      0          
          6        ASSIGN_STATIC_PROP                                       'instanses'
          7        OP_DATA                                                  $4
   51     8    >   FETCH_STATIC_PROP_R          unknown             ~6      'instanses'
          9      > RETURN                                                   ~6
   52    10*     > RETURN                                                   null

End of function getinstance

End of class T.

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

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/MWd1K
function name:  getInstance
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instanses'
          1        INSTANCEOF                                       ~1      ~0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
   48     4    >   NEW                          static              $4      
          5        DO_FCALL                                      0          
          6        ASSIGN_STATIC_PROP                                       'instanses'
          7        OP_DATA                                                  $4
   51     8    >   FETCH_STATIC_PROP_R          unknown             ~6      'instanses'
          9      > RETURN                                                   ~6
   52    10*     > RETURN                                                   null

End of function getinstance

End of class A.

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

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/MWd1K
function name:  getInstance
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instanses'
          1        INSTANCEOF                                       ~1      ~0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
   48     4    >   NEW                          static              $4      
          5        DO_FCALL                                      0          
          6        ASSIGN_STATIC_PROP                                       'instanses'
          7        OP_DATA                                                  $4
   51     8    >   FETCH_STATIC_PROP_R          unknown             ~6      'instanses'
          9      > RETURN                                                   ~6
   52    10*     > RETURN                                                   null

End of function getinstance

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.31 ms | 1415 KiB | 20 Q