3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Role { public $public; protected $protected; private $private; public function __construct($prop) { $this->public = $prop; $this->protected = $prop; $this->private = $prop; } } $test = [(new Role(false)), (new Role(1)), (new Role(null)), (new Role("1")), (new Role(2)), (new Role(0))]; var_export( array_unique($test, SORT_REGULAR) ); echo "\n---\n"; var_export( array_filter( $test, fn($o, $k) => array_search($o, $test, true) === $k, ARRAY_FILTER_USE_BOTH ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4BglS
function name:  (null)
number of ops:  44
compiled vars:  !0 = $test
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   NEW                                                  $1      'Role'
          1        SEND_VAL_EX                                                  <false>
          2        DO_FCALL                                          0          
          3        INIT_ARRAY                                           ~3      $1
          4        NEW                                                  $4      'Role'
          5        SEND_VAL_EX                                                  1
          6        DO_FCALL                                          0          
          7        ADD_ARRAY_ELEMENT                                    ~3      $4
          8        NEW                                                  $6      'Role'
          9        SEND_VAL_EX                                                  null
         10        DO_FCALL                                          0          
         11        ADD_ARRAY_ELEMENT                                    ~3      $6
         12        NEW                                                  $8      'Role'
         13        SEND_VAL_EX                                                  '1'
         14        DO_FCALL                                          0          
         15        ADD_ARRAY_ELEMENT                                    ~3      $8
         16        NEW                                                  $10     'Role'
         17        SEND_VAL_EX                                                  2
         18        DO_FCALL                                          0          
         19        ADD_ARRAY_ELEMENT                                    ~3      $10
         20        NEW                                                  $12     'Role'
         21        SEND_VAL_EX                                                  0
         22        DO_FCALL                                          0          
         23        ADD_ARRAY_ELEMENT                                    ~3      $12
         24        ASSIGN                                                       !0, ~3
   18    25        INIT_FCALL                                                   'var_export'
   19    26        INIT_FCALL                                                   'array_unique'
         27        SEND_VAR                                                     !0
         28        SEND_VAL                                                     0
         29        DO_ICALL                                             $15     
         30        SEND_VAR                                                     $15
   18    31        DO_ICALL                                                     
   22    32        ECHO                                                         '%0A---%0A'
   24    33        INIT_FCALL                                                   'var_export'
   25    34        INIT_FCALL                                                   'array_filter'
   26    35        SEND_VAR                                                     !0
   27    36        DECLARE_LAMBDA_FUNCTION                              ~17     [0]
         37        BIND_LEXICAL                                                 ~17, !0
         38        SEND_VAL                                                     ~17
   28    39        SEND_VAL                                                     1
   25    40        DO_ICALL                                             $18     
   28    41        SEND_VAR                                                     $18
   24    42        DO_ICALL                                                     
   30    43      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4BglS
function name:  {closure:/in/4BglS:27}
number of ops:  11
compiled vars:  !0 = $o, !1 = $k, !2 = $test
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        INIT_FCALL                                                   'array_search'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !2
          6        SEND_VAL                                                     <true>
          7        DO_ICALL                                             $3      
          8        IS_IDENTICAL                                         ~4      !1, $3
          9      > RETURN                                                       ~4
         10*     > RETURN                                                       null

End of Dynamic Function 0

Class Role:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4BglS
function name:  __construct
number of ops:  8
compiled vars:  !0 = $prop
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
   10     1        ASSIGN_OBJ                                                   'public'
          2        OP_DATA                                                      !0
   11     3        ASSIGN_OBJ                                                   'protected'
          4        OP_DATA                                                      !0
   12     5        ASSIGN_OBJ                                                   'private'
          6        OP_DATA                                                      !0
   13     7      > RETURN                                                       null

End of function __construct

End of class Role.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.56 ms | 1735 KiB | 17 Q