Skip to content

Commit

Permalink
ENH Add generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 17, 2024
1 parent e8e40a8 commit 8ec5b93
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/Model/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public function canEditContributors($member = null)
* @param null|int $month
* @param null|int $day
*
* @return DataList
* @return DataList<BlogPost>
*/
public function getArchivedBlogPosts($year, $month = null, $day = null)
{
Expand Down Expand Up @@ -574,7 +574,7 @@ public function getArchivedBlogPosts($year, $month = null, $day = null)
/**
* Return blog posts.
*
* @return DataList of BlogPost objects
* @return DataList<BlogPost> of BlogPost objects
*/
public function getBlogPosts()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Model/BlogCommentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
13 changes: 7 additions & 6 deletions src/Model/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
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
{
/**
Expand Down Expand Up @@ -58,7 +62,7 @@ class BlogController extends PageController
/**
* The current Blog Post DataList query.
*
* @var DataList
* @var DataList<BlogPost>
*/
protected $blogPosts;

Expand All @@ -67,9 +71,6 @@ class BlogController extends PageController
*/
public function index(HTTPRequest $request)
{
/**
* @var Blog $dataRecord
*/
$dataRecord = $this->dataRecord;

$this->blogPosts = $dataRecord->getBlogPosts();
Expand Down Expand Up @@ -128,7 +129,7 @@ public function getCurrentProfile()
/**
* Get posts related to the current Member profile.
*
* @return null|DataList
* @return null|DataList<BlogPost>
*/
public function getCurrentProfilePosts()
{
Expand Down Expand Up @@ -443,7 +444,7 @@ public function getFilterDescription()
/**
* Returns a list of paginated blog posts based on the BlogPost dataList.
*
* @return PaginatedList
* @return PaginatedList<SS_List, BlogPost>
*/
public function PaginatedList()
{
Expand Down
1 change: 0 additions & 1 deletion src/Model/BlogFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
/**
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
* filtering only published posts.
*
*/
class BlogFilter extends Lumberjack
{
Expand Down
2 changes: 2 additions & 0 deletions src/Model/BlogMemberExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*
* @method SilverStripe\ORM\ManyManyList<BlogPost> BlogPosts()
* @method Image BlogProfileImage()
*
* @extends DataExtension<Member>
*/
class BlogMemberExtension extends DataExtension
{
Expand Down
2 changes: 1 addition & 1 deletion src/Model/BlogObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Model/BlogPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use PageController;

/**
* @extends PageController<BlogPost>
*/
class BlogPostController extends PageController
{

Expand Down
2 changes: 2 additions & 0 deletions src/Model/BlogPostFeaturedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Adds a checkbox field for featured blog posts widget.
*
* @extends DataExtension<BlogPost>
*/
class BlogPostFeaturedExtension extends DataExtension
{
Expand Down
1 change: 1 addition & 0 deletions src/Model/BlogPostFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* 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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Model/BlogPostNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* Customise blog post to support comment notifications.
*
* Extends {@see BlogPost} with extensions to {@see CommentNotifiable}.
*
* @extends DataExtension<BlogPost>
*/
class BlogPostNotifications extends DataExtension
{
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/BlogArchiveWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getCMSFields()
/**
* Returns a list of months where blog posts are present.
*
* @return ArrayList
* @return ArrayList<ArrayData>
*/
public function getArchive()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/BlogCategoriesWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -106,7 +107,7 @@ public function getCMSFields()
}

/**
* @return DataList
* @return DataList<BlogCategory>
*/
public function getCategories()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/BlogTagsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -106,7 +107,7 @@ public function getCMSFields()
}

/**
* @return DataList
* @return DataList<BlogTag>
*/
public function getTags()
{
Expand Down

0 comments on commit 8ec5b93

Please sign in to comment.