3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[AllowDynamicProperties] final class WP_Term { /** * Term ID. * * @since 4.4.0 * @var int */ public $term_id; /** * The term's name. * * @since 4.4.0 * @var string */ public $name = ''; /** * The term's slug. * * @since 4.4.0 * @var string */ public $slug = ''; /** * The term's term_group. * * @since 4.4.0 * @var int */ public $term_group = ''; /** * Term Taxonomy ID. * * @since 4.4.0 * @var int */ public $term_taxonomy_id = 0; /** * The term's taxonomy name. * * @since 4.4.0 * @var string */ public $taxonomy = ''; /** * The term's description. * * @since 4.4.0 * @var string */ public $description = ''; /** * ID of a term's parent term. * * @since 4.4.0 * @var int */ public $parent = 0; /** * Cached object count for this term. * * @since 4.4.0 * @var int */ public $count = 0; /** * Stores the term object's sanitization level. * * Does not correspond to a database field. * * @since 4.4.0 * @var string */ public $filter = 'raw'; /** * Constructor. * * @since 4.4.0 * * @param WP_Term|object $term Term object. */ public function __construct( $term ) { foreach ( get_object_vars( $term ) as $key => $value ) { $this->$key = $value; } } /** * Sanitizes term fields, according to the filter type provided. * * @since 4.4.0 * * @param string $filter Filter context. Accepts 'edit', 'db', 'display', 'attribute', 'js', 'rss', or 'raw'. */ public function filter( $filter ) { sanitize_term( $this, $this->taxonomy, $filter ); } /** * Converts an object to array. * * @since 4.4.0 * * @return array Object as array. */ public function to_array() { return get_object_vars( $this ); } /** * Getter. * * @since 4.4.0 * * @param string $key Property to get. * @return mixed Property value. */ public function __get( $key ) { switch ( $key ) { case 'data': $data = new stdClass(); $columns = array( 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count' ); foreach ( $columns as $column ) { $data->{$column} = isset( $this->{$column} ) ? $this->{$column} : null; } return $data; // return sanitize_term( $data, $data->taxonomy, 'raw' ); } } } $data = (object) array( 'term_id' => 1, 'name' => 'Uncategorized', 'slug' => 'uncategorized', 'term_group' => 0, 'term_taxonomy_id' => 1, 'taxonomy' => 'category', 'description' => '', 'parent' => 1, 'count' => 1, ); $term = new WP_Term( $data ); echo '$term->data ...' . "\n\n"; var_dump( $term->data ); echo "\n\n" . '(array) $term->data ...' . "\n\n"; var_dump( (array) $term->data ); echo "\n\n" . '$term->to_array() ...' . "\n\n"; var_dump( $term->to_array() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQDU3
function name:  (null)
number of ops:  24
compiled vars:  !0 = $data, !1 = $term
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  151     0  E >   CAST                                          8  ~2      <array>
  150     1        ASSIGN                                                   !0, ~2
  162     2        NEW                                              $4      'WP_Term'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $4
  164     6        ECHO                                                     '%24term-%3Edata+...%0A%0A'
  165     7        INIT_FCALL                                               'var_dump'
          8        FETCH_OBJ_R                                      ~7      !1, 'data'
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                                 
  167    11        ECHO                                                     '%0A%0A%28array%29+%24term-%3Edata+...%0A%0A'
  168    12        INIT_FCALL                                               'var_dump'
         13        FETCH_OBJ_R                                      ~9      !1, 'data'
         14        CAST                                          7  ~10     ~9
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                                 
  170    17        ECHO                                                     '%0A%0A%24term-%3Eto_array%28%29+...%0A%0A'
  171    18        INIT_FCALL                                               'var_dump'
         19        INIT_METHOD_CALL                                         !1, 'to_array'
         20        DO_FCALL                                      0  $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Class WP_Term:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/AQDU3
function name:  __construct
number of ops:  12
compiled vars:  !0 = $term, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   95     0  E >   RECV                                             !0      
   96     1        INIT_FCALL                                               'get_object_vars'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4      > FE_RESET_R                                       $4      $3, ->10
          5    > > FE_FETCH_R                                       ~5      $4, !1, ->10
          6    >   ASSIGN                                                   !2, ~5
   97     7        ASSIGN_OBJ                                               !2
          8        OP_DATA                                                  !1
   96     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $4
   99    11      > RETURN                                                   null

End of function __construct

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQDU3
function name:  filter
number of ops:  10
compiled vars:  !0 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  108     0  E >   RECV                                             !0      
  109     1        INIT_FCALL_BY_NAME                                       'sanitize_term'
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $2      'taxonomy'
          6        SEND_FUNC_ARG                                            $2
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
  110     9      > RETURN                                                   null

End of function filter

Function to_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AQDU3
function name:  to_array
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  120     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
  121     5*     > RETURN                                                   null

End of function to_array

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/AQDU3
function name:  __get
number of ops:  22
compiled vars:  !0 = $key, !1 = $data, !2 = $columns, !3 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  131     0  E >   RECV                                             !0      
  133     1        IS_EQUAL                                                 !0, 'data'
          2      > JMPNZ                                                    ~4, ->4
          3    > > JMP                                                      ->21
  134     4    >   NEW                                              $5      'stdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
  135     7        ASSIGN                                                   !2, <array>
  136     8      > FE_RESET_R                                       $9      !2, ->19
          9    > > FE_FETCH_R                                               $9, !3, ->19
  137    10    >   ISSET_ISEMPTY_PROP_OBJ                                   !3
         11      > JMPZ                                                     ~11, ->15
         12    >   FETCH_OBJ_R                                      ~12     !3
         13        QM_ASSIGN                                        ~13     ~12
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~13     null
         16    >   ASSIGN_OBJ                                               !1, !3
         17        OP_DATA                                                  ~13
  136    18      > JMP                                                      ->9
         19    >   FE_FREE                                                  $9
  140    20      > RETURN                                                   !1
  144    21    > > RETURN                                                   null

End of function __get

End of class WP_Term.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.74 ms | 1469 KiB | 15 Q