3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PilotId { protected $pid; /** * @param PilotId|string $pid */ public function __construct($pid){ $this->pid = (string)$pid; if(!preg_match("/^(AFA|PAY)([0-9]{4})$/", $this->pid)) throw new \InvalidArgumentException('Invalid PID'); } function __toString(){ return $this->pid; } } echo new PilotId("AFA1111") . "\n"; echo new PilotId(new PilotId("AFA1111")) . "\n"; var_dump( (string)(new PilotId("PAY9999")) == (string)(new PilotId("PAY9999")) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZXAjn
function name:  (null)
number of ops:  27
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'pilotid'
   21     1        NEW                                              $0      'PilotId'
          2        SEND_VAL_EX                                              'AFA1111'
          3        DO_FCALL                                      0          
          4        CONCAT                                           ~2      $0, '%0A'
          5        ECHO                                                     ~2
   23     6        NEW                                              $3      'PilotId'
          7        NEW                                              $4      'PilotId'
          8        SEND_VAL_EX                                              'AFA1111'
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $4
         11        DO_FCALL                                      0          
         12        CONCAT                                           ~7      $3, '%0A'
         13        ECHO                                                     ~7
   25    14        INIT_FCALL                                               'var_dump'
   26    15        NEW                                              $8      'PilotId'
         16        SEND_VAL_EX                                              'PAY9999'
         17        DO_FCALL                                      0          
         18        CAST                                          6  ~10     $8
   27    19        NEW                                              $11     'PilotId'
         20        SEND_VAL_EX                                              'PAY9999'
         21        DO_FCALL                                      0          
         22        CAST                                          6  ~13     $11
         23        IS_EQUAL                                         ~14     ~10, ~13
         24        SEND_VAL                                                 ~14
         25        DO_ICALL                                                 
   28    26      > RETURN                                                   1

Class PilotId:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZXAjn
function name:  __construct
number of ops:  16
compiled vars:  !0 = $pid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        CAST                                          6  ~2      !0
          2        ASSIGN_OBJ                                               'pid'
          3        OP_DATA                                                  ~2
   12     4        INIT_FCALL                                               'preg_match'
          5        SEND_VAL                                                 '%2F%5E%28AFA%7CPAY%29%28%5B0-9%5D%7B4%7D%29%24%2F'
          6        FETCH_OBJ_R                                      ~3      'pid'
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9        BOOL_NOT                                         ~5      $4
         10      > JMPZ                                                     ~5, ->15
   13    11    >   NEW                                              $6      'InvalidArgumentException'
         12        SEND_VAL_EX                                              'Invalid+PID'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $6
   14    15    > > RETURN                                                   null

End of function __construct

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

End of function __tostring

End of class PilotId.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.06 ms | 1405 KiB | 17 Q