3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class Email { public function __construct(public string $emailString){} public function __toString() {return trim($this->emailString);} } readonly class ValidEmail extends Email {} function validateEmail(Email $email): ValidEmail {return new ValidEmail($email);} function saveToDatabase(ValidEmail $email) {return 'Saved succesfully';} $email = new Email('vasya@pupkin.com'); $validatedEmail = validateEmail($email); var_dump(saveToDatabase($validatedEmail)); var_dump(saveToDatabase($email));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hkTDp
function name:  (null)
number of ops:  23
compiled vars:  !0 = $email, !1 = $validatedEmail
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'email'
    8     1        DECLARE_CLASS                                            'validemail', 'email'
   13     2        NEW                                              $2      'Email'
          3        SEND_VAL_EX                                              'vasya%40pupkin.com'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   14     6        INIT_FCALL                                               'validateemail'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
   16    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'savetodatabase'
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   17    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'savetodatabase'
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0  $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function validateemail:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hkTDp
function name:  validateEmail
number of ops:  8
compiled vars:  !0 = $email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        NEW                                              $1      'ValidEmail'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
          6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function validateemail

Function savetodatabase:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hkTDp
function name:  saveToDatabase
number of ops:  3
compiled vars:  !0 = $email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1      > RETURN                                                   'Saved+succesfully'
          2*     > RETURN                                                   null

End of function savetodatabase

Class Email:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hkTDp
function name:  __construct
number of ops:  4
compiled vars:  !0 = $emailString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'emailString'
          2        OP_DATA                                                  !0
          3      > 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/hkTDp
function name:  __toString
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'trim'
          1        FETCH_OBJ_R                                      ~0      'emailString'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
          6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function __tostring

End of class Email.

Class ValidEmail: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.18 ms | 1006 KiB | 18 Q