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

FIX: clean up documentation and modernise code #159

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions src/Forms/GridFieldSiteTreeAddNewButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ class GridFieldSiteTreeAddNewButton extends GridFieldAddNewButton implements Gri
* Determine the list of classnames and titles allowed for a given parent object
*
* @param SiteTree $parent
* @return boolean
* @return array
*/
public function getAllowedChildren(SiteTree $parent = null)
public function getAllowedChildren(SiteTree $parent = null) : array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't strictly type the return type outside of a major release.

{
if (!$parent || !$parent->canAddChildren()) {
return array();
return [];
}

$nonHiddenPageTypes = SiteTree::page_type_classes();
$allowedChildren = $parent->allowedChildren();
$children = array();
$children = [];
foreach ($allowedChildren as $class) {
if (Config::inst()->get($class, 'show_in_sitetree') === false) {
$instance = Injector::inst()->get($class);
Expand All @@ -59,7 +59,7 @@ public function getAllowedChildren(SiteTree $parent = null)
}
}
}
return $children;
return (array) $children;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already an array? Why are you casting this here?

}

public function getHTMLFragments($gridField)
Expand Down