ENH Add generic types (#739)

This commit is contained in:
Guy Sartorelli 2024-01-19 09:58:02 +13:00 committed by GitHub
parent e8e40a808d
commit 3b8092272b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 28 additions and 13 deletions

View File

@ -533,7 +533,7 @@ class Blog extends Page implements PermissionProvider
* @param null|int $month
* @param null|int $day
*
* @return DataList
* @return DataList<BlogPost>
*/
public function getArchivedBlogPosts($year, $month = null, $day = null)
{
@ -574,7 +574,7 @@ class Blog extends Page implements PermissionProvider
/**
* Return blog posts.
*
* @return DataList of BlogPost objects
* @return DataList<BlogPost> of BlogPost objects
*/
public function getBlogPosts()
{

View File

@ -2,10 +2,13 @@
namespace SilverStripe\Blog\Model;
use SilverStripe\Comments\Model\Comment;
use SilverStripe\ORM\DataExtension;
/**
* Adds Blog specific behaviour to Comment.
*
* @extends DataExtension<Comment>
*/
class BlogCommentExtension extends DataExtension
{

View File

@ -15,7 +15,11 @@ use SilverStripe\Blog\Model\BlogTag;
use SilverStripe\Blog\Model\BlogCategory;
use SilverStripe\View\Parsers\URLSegmentFilter;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\ORM\SS_List;
/**
* @extends PageController<Blog>
*/
class BlogController extends PageController
{
/**
@ -58,7 +62,7 @@ class BlogController extends PageController
/**
* The current Blog Post DataList query.
*
* @var DataList
* @var DataList<BlogPost>
*/
protected $blogPosts;
@ -67,9 +71,6 @@ class BlogController extends PageController
*/
public function index(HTTPRequest $request)
{
/**
* @var Blog $dataRecord
*/
$dataRecord = $this->dataRecord;
$this->blogPosts = $dataRecord->getBlogPosts();
@ -128,7 +129,7 @@ class BlogController extends PageController
/**
* Get posts related to the current Member profile.
*
* @return null|DataList
* @return null|DataList<BlogPost>
*/
public function getCurrentProfilePosts()
{
@ -443,7 +444,7 @@ class BlogController extends PageController
/**
* Returns a list of paginated blog posts based on the BlogPost dataList.
*
* @return PaginatedList
* @return PaginatedList<SS_List, BlogPost>
*/
public function PaginatedList()
{

View File

@ -16,7 +16,6 @@ use SilverStripe\Versioned\Versioned;
/**
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
* filtering only published posts.
*
*/
class BlogFilter extends Lumberjack
{

View File

@ -19,6 +19,8 @@ use SilverStripe\View\Requirements;
*
* @method SilverStripe\ORM\ManyManyList<BlogPost> BlogPosts()
* @method Image BlogProfileImage()
*
* @extends DataExtension<Member>
*/
class BlogMemberExtension extends DataExtension
{

View File

@ -21,7 +21,7 @@ trait BlogObject
{
/**
* @param int|array|null $id Optional ID(s) for parent of this relation, if not the current record
* @return DataList
* @return DataList<BlogPost>
*/
public function BlogPosts($id = null)
{

View File

@ -4,6 +4,9 @@ namespace SilverStripe\Blog\Model;
use PageController;
/**
* @extends PageController<BlogPost>
*/
class BlogPostController extends PageController
{

View File

@ -8,6 +8,8 @@ use SilverStripe\Forms\CheckboxField;
/**
* Adds a checkbox field for featured blog posts widget.
*
* @extends DataExtension<BlogPost>
*/
class BlogPostFeaturedExtension extends DataExtension
{

View File

@ -17,6 +17,7 @@ use SilverStripe\Versioned\Versioned;
* This is responsible for filtering only published posts to users who do not have permission to
* view non-published posts.
*
* @extends DataExtension<BlogPost>
*/
class BlogPostFilter extends DataExtension
{

View File

@ -12,6 +12,8 @@ use SilverStripe\Security\Member;
* Customise blog post to support comment notifications.
*
* Extends {@see BlogPost} with extensions to {@see CommentNotifiable}.
*
* @extends DataExtension<BlogPost>
*/
class BlogPostNotifications extends DataExtension
{

View File

@ -108,7 +108,7 @@ class BlogArchiveWidget extends Widget
/**
* Returns a list of months where blog posts are present.
*
* @return ArrayList
* @return ArrayList<ArrayData>
*/
public function getArchive()
{

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Blog\Widgets;
use SilverStripe\Blog\Model\Blog;
use SilverStripe\Blog\Model\BlogCategory;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
@ -106,7 +107,7 @@ class BlogCategoriesWidget extends Widget
}
/**
* @return DataList
* @return DataList<BlogCategory>
*/
public function getCategories()
{

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Blog\Widgets;
use SilverStripe\Blog\Model\Blog;
use SilverStripe\Blog\Model\BlogTag;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
@ -106,7 +107,7 @@ class BlogTagsWidget extends Widget
}
/**
* @return DataList
* @return DataList<BlogTag>
*/
public function getTags()
{