3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); final class CreateStatementRequest { private ?DateTimeImmutable $startDate, $endDate; public function __construct( DateTimeImmutable $startDate = null, DateTimeImmutable $endDate = null ) { $this->startDate = $startDate; $this->endDate = $endDate; // error: Property CreateStatementRequest::$endDate (DateTimeImmutable) does not accept DateTimeImmutable|null. } public function hasFilterStartDate(): bool { return $this->startDate !== null; } public function getFilterStartDate(): DateTimeImmutable { if ($this->startDate === null) { throw new RuntimeException('The start date filter is not defined.'); } return $this->startDate; } public function hasFilterEndDate(): bool { return $this->endDate !== null; } public function getFilterEndDate(): DateTimeImmutable { if ($this->endDate === null) { // error: Strict comparison using === between DateTimeImmutable and null will always evaluate to false. throw new RuntimeException('The end date filter is not defined.'); } return $this->endDate; } } $ref = new \ReflectionClass(CreateStatementRequest::class); foreach ($ref->getProperties() as $refProperty) { var_dump($refProperty->getName()); $refType = $refProperty->getType(); var_dump($refType->getName()); var_dump($refType->allowsNull()); var_dump('---'); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 30
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 30
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/hITTk
function name:  (null)
number of ops:  32
compiled vars:  !0 = $ref, !1 = $refProperty, !2 = $refType
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   45     0  E >   NEW                                                  $3      'ReflectionClass'
          1        SEND_VAL_EX                                                  'CreateStatementRequest'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   46     4        INIT_METHOD_CALL                                             !0, 'getProperties'
          5        DO_FCALL                                          0  $6      
          6      > FE_RESET_R                                           $7      $6, ->30
          7    > > FE_FETCH_R                                                   $7, !1, ->30
   47     8    >   INIT_FCALL                                                   'var_dump'
          9        INIT_METHOD_CALL                                             !1, 'getName'
         10        DO_FCALL                                          0  $8      
         11        SEND_VAR                                                     $8
         12        DO_ICALL                                                     
   48    13        INIT_METHOD_CALL                                             !1, 'getType'
         14        DO_FCALL                                          0  $10     
         15        ASSIGN                                                       !2, $10
   49    16        INIT_FCALL                                                   'var_dump'
         17        INIT_METHOD_CALL                                             !2, 'getName'
         18        DO_FCALL                                          0  $12     
         19        SEND_VAR                                                     $12
         20        DO_ICALL                                                     
   50    21        INIT_FCALL                                                   'var_dump'
         22        INIT_METHOD_CALL                                             !2, 'allowsNull'
         23        DO_FCALL                                          0  $14     
         24        SEND_VAR                                                     $14
         25        DO_ICALL                                                     
   52    26        INIT_FCALL                                                   'var_dump'
         27        SEND_VAL                                                     '---'
         28        DO_ICALL                                                     
   46    29      > JMP                                                          ->7
         30    >   FE_FREE                                                      $7
   53    31      > RETURN                                                       1

Class CreateStatementRequest:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hITTk
function name:  __construct
number of ops:  7
compiled vars:  !0 = $startDate, !1 = $endDate
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV_INIT                                            !0      null
   10     1        RECV_INIT                                            !1      null
   12     2        ASSIGN_OBJ                                                   'startDate'
          3        OP_DATA                                                      !0
   13     4        ASSIGN_OBJ                                                   'endDate'
          5        OP_DATA                                                      !1
   14     6      > RETURN                                                       null

End of function __construct

Function hasfilterstartdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hITTk
function name:  hasFilterStartDate
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                          ~0      'startDate'
          1        TYPE_CHECK                                      1020  ~1      ~0
          2        VERIFY_RETURN_TYPE                                           ~1
          3      > RETURN                                                       ~1
   19     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function hasfilterstartdate

Function getfilterstartdate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hITTk
function name:  getFilterStartDate
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                          ~0      'startDate'
          1        TYPE_CHECK                                        2          ~0
          2      > JMPZ                                                         ~1, ->7
   24     3    >   NEW                                                  $2      'RuntimeException'
          4        SEND_VAL_EX                                                  'The+start+date+filter+is+not+defined.'
          5        DO_FCALL                                          0          
          6      > THROW                                             0          $2
   27     7    >   FETCH_OBJ_R                                          ~4      'startDate'
          8        VERIFY_RETURN_TYPE                                           ~4
          9      > RETURN                                                       ~4
   28    10*       VERIFY_RETURN_TYPE                                           
         11*     > RETURN                                                       null

End of function getfilterstartdate

Function hasfilterenddate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hITTk
function name:  hasFilterEndDate
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   FETCH_OBJ_R                                          ~0      'endDate'
          1        TYPE_CHECK                                      1020  ~1      ~0
          2        VERIFY_RETURN_TYPE                                           ~1
          3      > RETURN                                                       ~1
   33     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function hasfilterenddate

Function getfilterenddate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hITTk
function name:  getFilterEndDate
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   FETCH_OBJ_R                                          ~0      'endDate'
          1        TYPE_CHECK                                        2          ~0
          2      > JMPZ                                                         ~1, ->7
   38     3    >   NEW                                                  $2      'RuntimeException'
          4        SEND_VAL_EX                                                  'The+end+date+filter+is+not+defined.'
          5        DO_FCALL                                          0          
          6      > THROW                                             0          $2
   41     7    >   FETCH_OBJ_R                                          ~4      'endDate'
          8        VERIFY_RETURN_TYPE                                           ~4
          9      > RETURN                                                       ~4
   42    10*       VERIFY_RETURN_TYPE                                           
         11*     > RETURN                                                       null

End of function getfilterenddate

End of class CreateStatementRequest.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
219.41 ms | 2145 KiB | 14 Q