Add typehints to form renderer

[MAILPOET-2665]
This commit is contained in:
Rostislav Wolny
2020-01-29 16:14:03 +01:00
committed by Jack Kitterhing
parent 5193d4641c
commit f559d5f479

View File

@@ -7,7 +7,7 @@ use MailPoet\Subscription\Captcha;
use MailPoet\WP\Functions as WPFunctions; use MailPoet\WP\Functions as WPFunctions;
class Renderer { class Renderer {
public function renderStyles($form = [], $prefix = null) { public function renderStyles(array $form = [], string $prefix = null): string {
$styles = new Util\Styles(); $styles = new Util\Styles();
$html = '<style type="text/css">'; $html = '<style type="text/css">';
@@ -18,14 +18,14 @@ class Renderer {
return $html; return $html;
} }
public function renderHTML($form = []) { public function renderHTML(array $form = []): string {
if (isset($form['body']) && !empty($form['body'])) { if (isset($form['body']) && !empty($form['body'])) {
return $this->renderBlocks($form['body']); return $this->renderBlocks($form['body']);
} }
return ''; return '';
} }
public function getStyles($form = []) { public function getStyles(array $form = []): string {
if (isset($form['styles']) if (isset($form['styles'])
&& strlen(trim($form['styles'])) > 0) { && strlen(trim($form['styles'])) > 0) {
return strip_tags($form['styles']); return strip_tags($form['styles']);
@@ -35,7 +35,7 @@ class Renderer {
} }
} }
public function renderBlocks($blocks = [], $honeypotEnabled = true) { public function renderBlocks(array $blocks = [], bool $honeypotEnabled = true): string {
$settings = SettingsController::getInstance(); $settings = SettingsController::getInstance();
// add honeypot for spambots // add honeypot for spambots
$html = ($honeypotEnabled) ? $html = ($honeypotEnabled) ?
@@ -69,7 +69,7 @@ class Renderer {
return $html; return $html;
} }
private function renderBlock($block = []) { private function renderBlock(array $block = []): string {
$html = ''; $html = '';
switch ($block['type']) { switch ($block['type']) {
case 'html': case 'html':