Skip to content

Commit

Permalink
fix phpstan suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
markkelnar committed Aug 9, 2023
1 parent 92dbc42 commit 7923d53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Document/GarbageCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GarbageCollection {
/**
* @param integer $number_of_posts Number of post ids matching criteria.
*
* @return [int] Array of post ids
* @return int[] Array of post ids
*/
public static function get_documents_by_age( $number_of_posts = 100 ) {
// $days_ago Posts older than this many days ago
Expand Down Expand Up @@ -51,6 +51,11 @@ public static function get_documents_by_age( $number_of_posts = 100 ) {
]
);

/**
* Because 'fields' returns 'ids', this returns array of post ints. Satisfy phpstan.
*
* @var int[]
*/
return $wp_query->get_posts();
}
}
8 changes: 6 additions & 2 deletions src/Document/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class Group {

const TAXONOMY_NAME = 'graphql_document_group';

/**
* @return void
*/
public function init() {
register_taxonomy(
self::TAXONOMY_NAME,
Expand Down Expand Up @@ -41,10 +44,11 @@ public function init() {
/**
* Look up the first group for a post
*
* @param int The post id
* @param int $post_id The post id
* @return string
*/
public static function get( $post_id ) {
$item = get_the_terms( $post_id, self::TAXONOMY_NAME );
return ! is_wp_error( $item ) && isset( $item[0]->name ) ? $item[0]->name : '';
return ! is_wp_error( $item ) && isset( $item[0] ) && property_exists( $item[0], 'name' ) ? $item[0]->name : '';
}
}

0 comments on commit 7923d53

Please sign in to comment.