3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class FullName implements JsonSerializable { public $forename; public $surname; public function __construct(string $forename, string $surname) { $this->forename = $this->validateAndNormalize($forename); $this->surname = $this->validateAndNormalize($surname); } private function validateAndNormalize($name) : string { return ucwords($name); } public function jsonSerialize() { return $this->forename . ' ' . $this->surname; } } $o = new FullName('aaa', 'bbb'); $returnValues = array( 'id' => 42, 'name' => $o, 'message' => 'The professional has been updated' ); echo json_encode($returnValues);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3OPa3
function name:  (null)
number of ops:  15
compiled vars:  !0 = $o, !1 = $returnValues
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'fullname'
   28     1        NEW                                              $2      'FullName'
          2        SEND_VAL_EX                                              'aaa'
          3        SEND_VAL_EX                                              'bbb'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   30     6        INIT_ARRAY                                       ~5      42, 'id'
   31     7        ADD_ARRAY_ELEMENT                                ~5      !0, 'name'
   32     8        ADD_ARRAY_ELEMENT                                ~5      'The+professional+has+been+updated', 'message'
   29     9        ASSIGN                                                   !1, ~5
   34    10        INIT_FCALL                                               'json_encode'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $7      
         13        ECHO                                                     $7
         14      > RETURN                                                   1

Class FullName:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3OPa3
function name:  __construct
number of ops:  13
compiled vars:  !0 = $forename, !1 = $surname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_METHOD_CALL                                         'validateAndNormalize'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN_OBJ                                               'forename'
          6        OP_DATA                                                  $3
   14     7        INIT_METHOD_CALL                                         'validateAndNormalize'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $5      
         10        ASSIGN_OBJ                                               'surname'
         11        OP_DATA                                                  $5
   15    12      > RETURN                                                   null

End of function __construct

Function validateandnormalize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3OPa3
function name:  validateAndNormalize
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'ucwords'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   20     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function validateandnormalize

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3OPa3
function name:  jsonSerialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~0      'forename'
          1        CONCAT                                           ~1      ~0, '+'
          2        FETCH_OBJ_R                                      ~2      'surname'
          3        CONCAT                                           ~3      ~1, ~2
          4      > RETURN                                                   ~3
   25     5*     > RETURN                                                   null

End of function jsonserialize

End of class FullName.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
280.24 ms | 1016 KiB | 15 Q