[wp-trac] [WordPress Trac] #52297: Custom WP types params - remove or fix to fix inconsistent typing

WordPress Trac noreply at wordpress.org
Thu Jan 14 14:09:45 UTC 2021


#52297: Custom WP types params - remove or fix to fix inconsistent typing
--------------------------+-----------------------------
 Reporter:  malthert      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 e.g.


 {{{
  * @return string[]|WP_Taxonomy[] The names or objects of all taxonomies
 of `$object_type`.
  */
 function get_object_taxonomies($object, $output = 'names')
 }}}

 Returns WP_Taxonomy type.
 But functions that are commonly used with this, do not accept this type.
 e.g.


 {{{
  * @param string|string[] $taxonomies The taxonomy names to retrieve terms
 from.
  * @param array|string    $args       See WP_Term_Query::__construct() for
 supported arguments.
  * @return array|WP_Error The requested term data or empty array if no
 terms found.
  *                        WP_Error if any of the taxonomies don't exist.
  */
 function wp_get_object_terms($object_ids, $taxonomies, $args = array())
 }}}

 $taxonomies does not accept WP_Taxonomy.

 In general it's a bad idea to use these custom types like WP_Taxonomy. But
 if we use it, we must use it consistently, which is not the case currently

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52297>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list