3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This file is part of the Nette Framework (http://nette.org) * Copyright (c) 2004 David Grudl (http://davidgrudl.com) */ namespace Nette\Utils; use Nette; if (PHP_VERSION_ID < 70000) { /** @internal */ abstract class DateTimeWorkaround extends \DateTime { public static function createFromFormat($format, $time, $timezone = NULL) { return static::_createFromFormat($format, $time, $timezone); } } } else { /** @internal */ abstract class DateTimeWorkaround extends \DateTime { public static function createFromFormat($format, $time, \DateTimeZone $timezone = NULL) { return static::_createFromFormat($format, $time, $timezone); } } } /** * DateTime. * * @author David Grudl */ class DateTime extends DateTimeWorkaround { /** minute in seconds */ const MINUTE = 60; /** hour in seconds */ const HOUR = 3600; /** day in seconds */ const DAY = 86400; /** week in seconds */ const WEEK = 604800; /** average month in seconds */ const MONTH = 2629800; /** average year in seconds */ const YEAR = 31557600; /** * DateTime object factory. * @param string|int|\DateTime * @return DateTime */ public static function from($time) { if ($time instanceof \DateTime || $time instanceof \DateTimeInterface) { return new static($time->format('Y-m-d H:i:s'), $time->getTimezone()); } elseif (is_numeric($time)) { if ($time <= self::YEAR) { $time += time(); } $tmp = new static('@' . $time); return $tmp->setTimeZone(new \DateTimeZone(date_default_timezone_get())); } else { // textual or NULL return new static($time); } } /** * @return string */ public function __toString() { return $this->format('Y-m-d H:i:s'); } /** * @param string * @return self */ public function modifyClone($modify = '') { $dolly = clone $this; return $modify ? $dolly->modify($modify) : $dolly; } /** * @param int * @return self */ public function setTimestamp($timestamp) { $zone = $this->getTimezone(); $this->__construct('@' . $timestamp); return $this->setTimeZone($zone); } /** * @return int|string */ public function getTimestamp() { $ts = $this->format('U'); return is_float($tmp = $ts * 1) ? $ts : $tmp; } /** * Returns new DateTime object formatted according to the specified format. * @param string The format the $time parameter should be in * @param string String representing the time * @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed) * @return DateTime|FALSE */ public static function _createFromFormat($format, $time, $timezone = NULL) { if ($timezone === NULL) { $timezone = new \DateTimeZone(date_default_timezone_get()); } elseif (is_string($timezone)) { $timezone = new \DateTimeZone($timezone); } elseif (!$timezone instanceof \DateTimeZone) { throw new Nette\InvalidArgumentException('Invalid timezone given'); } $date = \DateTime::createFromFormat($format, $time, $timezone); return $date ? static::from($date) : FALSE; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_CONSTANT                                   ~0      'Nette%5CUtils%5CPHP_VERSION_ID'
          1        IS_SMALLER                                               ~0, 70000
          2      > JMPZ                                                     ~1, ->5
   10     3    >   DECLARE_CLASS                                            'nette%5Cutils%5Cdatetimeworkaround', 'datetime'
          4      > JMP                                                      ->6
   19     5    >   DECLARE_CLASS                                            'nette%5Cutils%5Cdatetimeworkaround', 'datetime'
   32     6    >   DECLARE_CLASS                                            'nette%5Cutils%5Cdatetime', 'nette%5Cutils%5Cdatetimeworkaround'
  118     7      > RETURN                                                   1

Class Nette\Utils\DateTimeWorkaround:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  createFromFormat
number of ops:  10
compiled vars:  !0 = $format, !1 = $time, !2 = $timezone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   14     3        INIT_STATIC_METHOD_CALL                                  '_createFromFormat'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   15     9*     > RETURN                                                   null

End of function createfromformat

End of class Nette\Utils\DateTimeWorkaround.

Class Nette\Utils\DateTimeWorkaround:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  createFromFormat
number of ops:  10
compiled vars:  !0 = $format, !1 = $time, !2 = $timezone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   23     3        INIT_STATIC_METHOD_CALL                                  '_createFromFormat'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   24     9*     > RETURN                                                   null

End of function createfromformat

End of class Nette\Utils\DateTimeWorkaround.

Class Nette\Utils\DateTime:
Function from:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 42
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/j6R1o
function name:  from
number of ops:  47
compiled vars:  !0 = $time, !1 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
   53     1        INSTANCEOF                                       ~2      !0, 'DateTime'
          2      > JMPNZ_EX                                         ~2      ~2, ->5
          3    >   INSTANCEOF                                       ~3      !0, 'DateTimeInterface'
          4        BOOL                                             ~2      ~3
          5    > > JMPZ                                                     ~2, ->17
   54     6    >   NEW                          static              $4      
          7        INIT_METHOD_CALL                                         !0, 'format'
          8        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR_NO_REF_EX                                       $5
         11        INIT_METHOD_CALL                                         !0, 'getTimezone'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR_NO_REF_EX                                       $6
         14        DO_FCALL                                      0          
         15      > RETURN                                                   $4
         16*       JMP                                                      ->46
   55    17    >   INIT_NS_FCALL_BY_NAME                                    'Nette%5CUtils%5Cis_numeric'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0  $8      
         20      > JMPZ                                                     $8, ->42
   56    21    >   FETCH_CLASS_CONSTANT                             ~9      'YEAR'
         22        IS_SMALLER_OR_EQUAL                                      !0, ~9
         23      > JMPZ                                                     ~10, ->27
   57    24    >   INIT_NS_FCALL_BY_NAME                                    'Nette%5CUtils%5Ctime'
         25        DO_FCALL                                      0  $11     
         26        ASSIGN_OP                                     1          !0, $11
   59    27    >   NEW                          static              $13     
         28        CONCAT                                           ~14     '%40', !0
         29        SEND_VAL_EX                                              ~14
         30        DO_FCALL                                      0          
         31        ASSIGN                                                   !1, $13
   60    32        INIT_METHOD_CALL                                         !1, 'setTimeZone'
         33        NEW                                              $17     'DateTimeZone'
         34        INIT_NS_FCALL_BY_NAME                                    'Nette%5CUtils%5Cdate_default_timezone_get'
         35        DO_FCALL                                      0  $18     
         36        SEND_VAR_NO_REF_EX                                       $18
         37        DO_FCALL                                      0          
         38        SEND_VAR_NO_REF_EX                                       $17
         39        DO_FCALL                                      0  $20     
         40      > RETURN                                                   $20
         41*       JMP                                                      ->46
   62    42    >   NEW                          static              $21     
         43        SEND_VAR_EX                                              !0
         44        DO_FCALL                                      0          
         45      > RETURN                                                   $21
   64    46*     > RETURN                                                   null

End of function from

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  __toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   INIT_METHOD_CALL                                         'format'
          1        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
          2        DO_FCALL                                      0  $0      
          3        VERIFY_RETURN_TYPE                                       $0
          4      > RETURN                                                   $0
   71     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function __tostring

Function modifyclone:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  modifyClone
number of ops:  13
compiled vars:  !0 = $modify, !1 = $dolly
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV_INIT                                        !0      ''
   78     1        FETCH_THIS                                       ~2      
          2        CLONE                                            ~3      ~2
          3        ASSIGN                                                   !1, ~3
   79     4      > JMPZ                                                     !0, ->10
          5    >   INIT_METHOD_CALL                                         !1, 'modify'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $5      
          8        QM_ASSIGN                                        ~6      $5
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~6      !1
         11    > > RETURN                                                   ~6
   80    12*     > RETURN                                                   null

End of function modifyclone

Function settimestamp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  setTimestamp
number of ops:  13
compiled vars:  !0 = $timestamp, !1 = $zone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   85     0  E >   RECV                                             !0      
   87     1        INIT_METHOD_CALL                                         'getTimezone'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
   88     4        INIT_METHOD_CALL                                         '__construct'
          5        CONCAT                                           ~4      '%40', !0
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0          
   89     8        INIT_METHOD_CALL                                         'setTimeZone'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $6      
         11      > RETURN                                                   $6
   90    12*     > RETURN                                                   null

End of function settimestamp

Function gettimestamp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j6R1o
function name:  getTimestamp
number of ops:  15
compiled vars:  !0 = $ts, !1 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   INIT_METHOD_CALL                                         'format'
          1        SEND_VAL_EX                                              'U'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   97     4        INIT_NS_FCALL_BY_NAME                                    'Nette%5CUtils%5Cis_float'
          5        MUL                                              ~4      !0, 1
          6        ASSIGN                                           ~5      !1, ~4
          7        SEND_VAL_EX                                              ~5
          8        DO_FCALL                                      0  $6      
          9      > JMPZ                                                     $6, ->12
         10    >   QM_ASSIGN                                        ~7      !0
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~7      !1
         13    > > RETURN                                                   ~7
   98    14*     > RETURN                                                   null

End of function gettimestamp

Function _createfromformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 28
filename:       /in/j6R1o
function name:  _createFromFormat
number of ops:  43
compiled vars:  !0 = $format, !1 = $time, !2 = $timezone, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  106     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
  108     3        TYPE_CHECK                                    2          !2
          4      > JMPZ                                                     ~4, ->12
  109     5    >   NEW                                              $5      'DateTimeZone'
          6        INIT_NS_FCALL_BY_NAME                                    'Nette%5CUtils%5Cdate_default_timezone_get'
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR_NO_REF_EX                                       $6
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $5
         11      > JMP                                                      ->28
  110    12    >   INIT_NS_FCALL_BY_NAME                                    'Nette%5CUtils%5Cis_string'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $9      
         15      > JMPZ                                                     $9, ->21
  111    16    >   NEW                                              $10     'DateTimeZone'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !2, $10
         20      > JMP                                                      ->28
  112    21    >   INSTANCEOF                                       ~13     !2, 'DateTimeZone'
         22        BOOL_NOT                                         ~14     ~13
         23      > JMPZ                                                     ~14, ->28
  113    24    >   NEW                                              $15     'Nette%5CInvalidArgumentException'
         25        SEND_VAL_EX                                              'Invalid+timezone+given'
         26        DO_FCALL                                      0          
         27      > THROW                                         0          $15
  115    28    >   INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         29        SEND_VAR                                                 !0
         30        SEND_VAR                                                 !1
         31        SEND_VAR                                                 !2
         32        DO_FCALL                                      0  $17     
         33        ASSIGN                                                   !3, $17
  116    34      > JMPZ                                                     !3, ->40
         35    >   INIT_STATIC_METHOD_CALL                                  'from'
         36        SEND_VAR_EX                                              !3
         37        DO_FCALL                                      0  $19     
         38        QM_ASSIGN                                        ~20     $19
         39      > JMP                                                      ->41
         40    >   QM_ASSIGN                                        ~20     <false>
         41    > > RETURN                                                   ~20
  117    42*     > RETURN                                                   null

End of function _createfromformat

End of class Nette\Utils\DateTime.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.93 ms | 1412 KiB | 23 Q