From 754b245516253f15ee3184524a0568e77bbea686 Mon Sep 17 00:00:00 2001
From: Benjamin Mack <benni@typo3.org>
Date: Wed, 29 Jul 2015 20:48:33 +0200
Subject: [PATCH] [BUGFIX] IfViewHelpers use method signature from parent

In order to become PHP7 compliant, the IfViewHelpers should
register their arguments via the registerArgument() method
instead of extending the render() method with additional
parameters. This is not allowed in PHP7 and is therefore
changed in order to be compatible with PHP7.

Releases: master
Resolves: #68634
Change-Id: Ia3fa86541d5e112813da3c1d32edfe6180f6f621
Reviewed-on: http://review.typo3.org/42115
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
---
 .../ViewHelpers/Be/Security/IfHasRoleViewHelper.php   | 11 +++++------
 .../sysext/fluid/Classes/ViewHelpers/IfViewHelper.php | 11 ++++-------
 .../ViewHelpers/Security/IfHasRoleViewHelper.php      | 11 +++++------
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php
index 4f3aefdb6c75..fcf99b38b639 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php
@@ -63,15 +63,14 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Security;
 class IfHasRoleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper {
 
 	/**
-	 * renders <f:then> child if the current logged in BE user belongs to the specified role (aka usergroup)
+	 * Initializes the "role" argument.
+	 * Renders <f:then> child if the current logged in BE user belongs to the specified role (aka usergroup)
 	 * otherwise renders <f:else> child.
 	 *
-	 * @param string $role The usergroup (either the usergroup uid or its title)
-	 * @return string the rendered string
-	 * @api
+	 * @return void
 	 */
-	public function render($role) {
-		return parent::render();
+	public function initializeArguments() {
+		$this->registerArgument('role', 'string', 'The usergroup (either the usergroup uid or its title).');
 	}
 
 	/**
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/IfViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/IfViewHelper.php
index 2db8da491cc4..24ac60561ea1 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/IfViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/IfViewHelper.php
@@ -84,13 +84,10 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
 class IfViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper {
 
 	/**
-	 * renders <f:then> child if $condition is true, otherwise renders <f:else> child.
-	 *
-	 * @param bool $condition View helper condition
-	 * @return string the rendered string
-	 * @api
+	 * @return void
 	 */
-	public function render($condition) {
-		return parent::render();
+	public function initializeArguments() {
+		$this->registerArgument('condition', 'boolean', 'Condition to be evaluated.');
 	}
+
 }
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php
index 818d9630f3b6..02fa90e9b206 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php
@@ -63,15 +63,14 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Security;
 class IfHasRoleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper {
 
 	/**
-	 * renders <f:then> child if the current logged in FE user belongs to the specified role (aka usergroup)
+	 * Initializes the "role" argument.
+	 * Renders <f:then> child if the current logged in FE user belongs to the specified role (aka usergroup)
 	 * otherwise renders <f:else> child.
 	 *
-	 * @param string $role The usergroup (either the usergroup uid or its title)
-	 * @return string the rendered string
-	 * @api
+	 * @return void
 	 */
-	public function render($role) {
-		return parent::render();
+	public function initializeArguments() {
+		$this->registerArgument('role', 'string', 'The usergroup (either the usergroup uid or its title).');
 	}
 
 	/**
-- 
GitLab