Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #739

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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