diff --git a/src/Document/GarbageCollection.php b/src/Document/GarbageCollection.php index 120fd750..0a8244b7 100644 --- a/src/Document/GarbageCollection.php +++ b/src/Document/GarbageCollection.php @@ -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 @@ -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(); } } diff --git a/src/Document/Group.php b/src/Document/Group.php index 7eb9d0e9..6bc3012b 100644 --- a/src/Document/Group.php +++ b/src/Document/Group.php @@ -14,6 +14,9 @@ class Group { const TAXONOMY_NAME = 'graphql_document_group'; + /** + * @return void + */ public function init() { register_taxonomy( self::TAXONOMY_NAME, @@ -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 : ''; } }