3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait HasTimestamps { protected $timestamps = true; public function setCreatedAt($value) { echo 'HasTimestamps::setCreatedAt'.PHP_EOL; return $this; } public function setUpdatedAt($value) { echo 'HasTimestamps::setUpdatedAt'.PHP_EOL; return $this; } } trait ExtendHasTimestamps { public function setCreatedAt($value) { echo 'ExtendHasTimestamps::setCreatedAt'.PHP_EOL; if ($value !== '') return $this; return parent::setCreatedAt($value); } public function setUpdatedAt($value) { echo 'ExtendHasTimestamps::setUpdatedAt'.PHP_EOL; if ($value !== '') return $this; return parent::setUpdatedAt($value); } } class Model { use HasTimestamps; } class MyModel extends Model { use ExtendHasTimestamps; } (new MyModel)->setCreatedAt(''); echo PHP_EOL; (new MyModel)->setCreatedAt('time');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DqZQ
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   DECLARE_CLASS                                            'model'
   46     1        DECLARE_CLASS                                            'mymodel', 'model'
   51     2        NEW                                              $0      'MyModel'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $0, 'setCreatedAt'
          5        SEND_VAL_EX                                              ''
          6        DO_FCALL                                      0          
   53     7        ECHO                                                     '%0A'
   55     8        NEW                                              $3      'MyModel'
          9        DO_FCALL                                      0          
         10        INIT_METHOD_CALL                                         $3, 'setCreatedAt'
         11        SEND_VAL_EX                                              'time'
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

Class HasTimestamps:
Function setcreatedat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DqZQ
function name:  setCreatedAt
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ECHO                                                     'HasTimestamps%3A%3AsetCreatedAt%0A'
   10     2        FETCH_THIS                                       ~1      
          3      > RETURN                                                   ~1
   11     4*     > RETURN                                                   null

End of function setcreatedat

Function setupdatedat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DqZQ
function name:  setUpdatedAt
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ECHO                                                     'HasTimestamps%3A%3AsetUpdatedAt%0A'
   16     2        FETCH_THIS                                       ~1      
          3      > RETURN                                                   ~1
   17     4*     > RETURN                                                   null

End of function setupdatedat

End of class HasTimestamps.

Class ExtendHasTimestamps:
Function setcreatedat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DqZQ
function name:  setCreatedAt
number of ops:  11
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        ECHO                                                     'ExtendHasTimestamps%3A%3AsetCreatedAt%0A'
   26     2        IS_NOT_IDENTICAL                                         !0, ''
          3      > JMPZ                                                     ~1, ->6
          4    >   FETCH_THIS                                       ~2      
          5      > RETURN                                                   ~2
   28     6    >   INIT_STATIC_METHOD_CALL                                  'setCreatedAt'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $3      
          9      > RETURN                                                   $3
   29    10*     > RETURN                                                   null

End of function setcreatedat

Function setupdatedat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DqZQ
function name:  setUpdatedAt
number of ops:  11
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   33     1        ECHO                                                     'ExtendHasTimestamps%3A%3AsetUpdatedAt%0A'
   35     2        IS_NOT_IDENTICAL                                         !0, ''
          3      > JMPZ                                                     ~1, ->6
          4    >   FETCH_THIS                                       ~2      
          5      > RETURN                                                   ~2
   37     6    >   INIT_STATIC_METHOD_CALL                                  'setUpdatedAt'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $3      
          9      > RETURN                                                   $3
   38    10*     > RETURN                                                   null

End of function setupdatedat

End of class ExtendHasTimestamps.

Class Model: [no user functions]
Class MyModel: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.2 ms | 1004 KiB | 13 Q