3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait tSB_FormFieldObject { } interface iSB_FormFieldObject { } class SB_FormFieldObject implements iSB_FormFieldObject { use tSB_FormFieldObject; public $Test2 = "aa"; } function test($a=null) { echo "trait: " .($a instanceof tSB_FormFieldObject) . PHP_EOL; echo "interface: " .($a instanceof iSB_FormFieldObject) . PHP_EOL; echo "using: " .(is_using($a, "tSB_FormFieldObject")) . PHP_EOL; } function is_using($class, $trait) { return in_array($trait, (new ReflectionClass($class))->getTraitNames()); } $a = new SB_FormFieldObject(); test($a); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kFQBE
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'sb_formfieldobject'
   20     1        NEW                                              $1      'SB_FormFieldObject'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   21     4        INIT_FCALL                                               'test'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0          
   22     7      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kFQBE
function name:  test
number of ops:  17
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      null
   12     1        INSTANCEOF                                       ~1      !0, 'tSB_FormFieldObject'
          2        CONCAT                                           ~2      'trait%3A+', ~1
          3        CONCAT                                           ~3      ~2, '%0A'
          4        ECHO                                                     ~3
   13     5        INSTANCEOF                                       ~4      !0, 'iSB_FormFieldObject'
          6        CONCAT                                           ~5      'interface%3A+', ~4
          7        CONCAT                                           ~6      ~5, '%0A'
          8        ECHO                                                     ~6
   14     9        INIT_FCALL_BY_NAME                                       'is_using'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              'tSB_FormFieldObject'
         12        DO_FCALL                                      0  $7      
         13        CONCAT                                           ~8      'using%3A+', $7
         14        CONCAT                                           ~9      ~8, '%0A'
         15        ECHO                                                     ~9
   15    16      > RETURN                                                   null

End of function test

Function is_using:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kFQBE
function name:  is_using
number of ops:  13
compiled vars:  !0 = $class, !1 = $trait
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !1
          4        NEW                                              $2      'ReflectionClass'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        INIT_METHOD_CALL                                         $2, 'getTraitNames'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11      > RETURN                                                   $5
   18    12*     > RETURN                                                   null

End of function is_using

Class tSB_FormFieldObject: [no user functions]
Class iSB_FormFieldObject: [no user functions]
Class SB_FormFieldObject: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
192.81 ms | 948 KiB | 17 Q