3v4l.org

run code in 300+ PHP versions simultaneously
<?php // native PHPStan class AbstractClass { public $attributes; public function getAttribute(string $name) { return $this->attributes[$name] ?? null; } public function setAttribute(string $name, $value): void { $this->attributes[$name] = $value; } } // Rector faking trait AttributesTrait { public $attributes; public function getAttribute(string $name) { return $this->attributes[$name] ?? null; } public function setAttribute(string $name, $value): void { $this->attributes[$name] = $value; } } final class SomeNode extends AbstractClass { use AttributesTrait; } $someNode = new SomeNode(); $someNode->setAttribute('test', 'yes'); var_dump($someNode->getAttribute('test'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D4PkT
function name:  (null)
number of ops:  15
compiled vars:  !0 = $someNode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   DECLARE_CLASS                                            'somenode', 'abstractclass'
   43     1        NEW                                              $1      'SomeNode'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   44     4        INIT_METHOD_CALL                                         !0, 'setAttribute'
          5        SEND_VAL_EX                                              'test'
          6        SEND_VAL_EX                                              'yes'
          7        DO_FCALL                                      0          
   46     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'getAttribute'
         10        SEND_VAL_EX                                              'test'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class AbstractClass:
Function getattribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D4PkT
function name:  getAttribute
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        FETCH_OBJ_IS                                     ~1      'attributes'
          2        FETCH_DIM_IS                                     ~2      ~1, !0
          3        COALESCE                                         ~3      ~2
          4        QM_ASSIGN                                        ~3      null
          5      > RETURN                                                   ~3
   11     6*     > RETURN                                                   null

End of function getattribute

Function setattribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D4PkT
function name:  setAttribute
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        FETCH_OBJ_W                                      $2      'attributes'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   16     5      > RETURN                                                   null

End of function setattribute

End of class AbstractClass.

Class AttributesTrait:
Function getattribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D4PkT
function name:  getAttribute
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        FETCH_OBJ_IS                                     ~1      'attributes'
          2        FETCH_DIM_IS                                     ~2      ~1, !0
          3        COALESCE                                         ~3      ~2
          4        QM_ASSIGN                                        ~3      null
          5      > RETURN                                                   ~3
   28     6*     > RETURN                                                   null

End of function getattribute

Function setattribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D4PkT
function name:  setAttribute
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        FETCH_OBJ_W                                      $2      'attributes'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   33     5      > RETURN                                                   null

End of function setattribute

End of class AttributesTrait.

Class SomeNode: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.98 ms | 1010 KiB | 14 Q