Skip to content

Commit

Permalink
API Strong typing for the view layer (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Aug 27, 2024
1 parent ff0cbd6 commit d63e213
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/Controllers/ElementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ public function getElement()
/**
* Renders the managed {@link BaseElement} wrapped with the current
* {@link ElementController}.
*
* @return string HTML
*/
public function forTemplate()
public function forTemplate(): string
{
$defaultStyles = $this->config()->get('default_styles');
$this->extend('updateForTemplateDefaultStyles', $defaultStyles);
Expand Down
6 changes: 2 additions & 4 deletions src/Models/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,18 +600,16 @@ private function getFieldNamesExcludedFromCmsSearch(): array
* Default way to render element in templates. Note that all blocks should
* be rendered through their {@link ElementController} class as this
* contains the holder styles.
*
* @return string|null HTML
*/
public function forTemplate($holder = true)
public function forTemplate($holder = true): string
{
$templates = $this->getRenderTemplates();

if ($templates) {
return $this->renderWith($templates);
}

return null;
return '';
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Models/ElementalArea.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ public function supportedPageTypes()
return $elementalClasses;
}

/**
* @return DBHTMLText
*/
public function forTemplate()
public function forTemplate(): string
{
return $this->renderWith(static::class);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/FieldType/DBObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct()
/**
* Add the field to the underlying database.
*/
public function requireField()
public function requireField(): void
{
// noop - This class exists only to bind to a custom GraphQL type
}
Expand Down

0 comments on commit d63e213

Please sign in to comment.