Skip to content

Commit e82d922

Browse files
committed
Code Quality: Add conditional return typing for term_exists().
Developed as subset of WordPress#12201 Props westonruter, gziolo. See #64898, #65476. git-svn-id: https://develop.svn.wordpress.org/trunk@62680 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8cb025e commit e82d922

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/wp-includes/taxonomy.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,13 +1581,26 @@ function unregister_term_meta( $taxonomy, $meta_key ) {
15811581
*
15821582
* @global bool $_wp_suspend_cache_invalidation
15831583
*
1584-
* @param int|string $term The term to check. Accepts term ID, slug, or name.
1585-
* @param string $taxonomy Optional. The taxonomy name to use.
1586-
* @param int $parent_term Optional. ID of parent term under which to confine the exists search.
1584+
* @param int|string|null $term The term to check. Accepts term ID, slug, or name.
1585+
* @param string $taxonomy Optional. The taxonomy name to use.
1586+
* @param int $parent_term Optional. ID of parent term under which to confine the exists search.
15871587
* @return mixed Returns null if the term does not exist.
15881588
* Returns the term ID if no taxonomy is specified and the term ID exists.
15891589
* Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists.
15901590
* Returns 0 if term ID 0 is passed to the function.
1591+
*
1592+
* @phpstan-return (
1593+
* $term is null ? null : (
1594+
* $term is 0 ? 0 : (
1595+
* $taxonomy is '' ? int|null : (
1596+
* array{
1597+
* term_id: numeric-string,
1598+
* term_taxonomy_id: numeric-string,
1599+
* }|null
1600+
* )
1601+
* )
1602+
* )
1603+
* )
15911604
*/
15921605
function term_exists( $term, $taxonomy = '', $parent_term = null ) {
15931606
global $_wp_suspend_cache_invalidation;

0 commit comments

Comments
 (0)