3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Fluent interface marker */ interface FluentInterface { } interface Around{} interface Aspect{} //use Go\Aop\Intercept\MethodInvocation; class FluentInterfaceAspect implements Aspect { /** * Fluent interface advice * * @Around("within(FluentInterface+) && execution(public **->set*(*))") * * @param MethodInvocation $invocation * @return mixed|null|object */ protected function aroundMethodExecution(MethodInvocation $invocation) { $result = $invocation->proceed(); return $result!==null ? $result : $invocation->getThis(); } } class User implements FluentInterface { protected $name; protected $surname; protected $password; public function setName($name) { $this->name = $name; } public function setSurname($surname) { $this->surname = $surname; } public function setPassword($password) { if (!$password) { throw new InvalidArgumentException("Password shouldn't be empty"); } $this->password = $password; } } $user = new User; $user->setName('John')->setSurname('Doe')->setPassword('root');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uCUu9
function name:  (null)
number of ops:  15
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_CLASS                                            'fluentinterfaceaspect'
   33     1        DECLARE_CLASS                                            'user'
   58     2        NEW                                              $1      'User'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   59     5        INIT_METHOD_CALL                                         !0, 'setName'
          6        SEND_VAL_EX                                              'John'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'setSurname'
          9        SEND_VAL_EX                                              'Doe'
         10        DO_FCALL                                      0  $5      
         11        INIT_METHOD_CALL                                         $5, 'setPassword'
         12        SEND_VAL_EX                                              'root'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Class FluentInterface: [no user functions]
Class Around: [no user functions]
Class Aspect: [no user functions]
Class FluentInterfaceAspect:
Function aroundmethodexecution:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
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: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uCUu9
function name:  aroundMethodExecution
number of ops:  13
compiled vars:  !0 = $invocation, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        INIT_METHOD_CALL                                         !0, 'proceed'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
   29     4        TYPE_CHECK                                  1020          !1
          5      > JMPZ                                                     ~4, ->8
          6    >   QM_ASSIGN                                        ~5      !1
          7      > JMP                                                      ->11
          8    >   INIT_METHOD_CALL                                         !0, 'getThis'
          9        DO_FCALL                                      0  $6      
         10        QM_ASSIGN                                        ~5      $6
         11    > > RETURN                                                   ~5
   30    12*     > RETURN                                                   null

End of function aroundmethodexecution

End of class FluentInterfaceAspect.

Class User:
Function setname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uCUu9
function name:  setName
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   41     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
   42     3      > RETURN                                                   null

End of function setname

Function setsurname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uCUu9
function name:  setSurname
number of ops:  4
compiled vars:  !0 = $surname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   46     1        ASSIGN_OBJ                                               'surname'
          2        OP_DATA                                                  !0
   47     3      > RETURN                                                   null

End of function setsurname

Function setpassword:
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/uCUu9
function name:  setPassword
number of ops:  10
compiled vars:  !0 = $password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   51     1        BOOL_NOT                                         ~1      !0
          2      > JMPZ                                                     ~1, ->7
   52     3    >   NEW                                              $2      'InvalidArgumentException'
          4        SEND_VAL_EX                                              'Password+shouldn%27t+be+empty'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $2
   54     7    >   ASSIGN_OBJ                                               'password'
          8        OP_DATA                                                  !0
   55     9      > RETURN                                                   null

End of function setpassword

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.57 ms | 1399 KiB | 13 Q