From ea355bcf41d31a79118116574c0b30536f211871 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 1 Jul 2022 14:39:01 +0000 Subject: [PATCH] make constructor final and use new static(), fixes #1250 Closes #1250 Merge request studip/studip!766 --- lib/classes/Interactable.class.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/classes/Interactable.class.php b/lib/classes/Interactable.class.php index 3904baec9b8..b401115d976 100644 --- a/lib/classes/Interactable.class.php +++ b/lib/classes/Interactable.class.php @@ -24,7 +24,7 @@ abstract class Interactable * @param string $label the label of the button * @param array $attributes the attributes of the button element */ - function __construct($label, $attributes) + final public function __construct($label, $attributes) { $this->label = $label; $this->attributes = $attributes; @@ -107,9 +107,9 @@ abstract class Interactable * @param string $trait the specific trait of the current element * @param array $attributes the attributes of the button element * - * @return returns a Interactable element + * @return Interactable a Interactable element */ - static function create($label = NULL, $trait = NULL, $attributes = []) + public static function create($label = NULL, $trait = NULL, $attributes = []) { $argc = func_num_args(); @@ -126,8 +126,7 @@ abstract class Interactable list($attributes, $trait) = [$trait, NULL]; } - $called = get_called_class(); - $interactable = new $called($label, $attributes); + $interactable = new static($label, $attributes); $interactable->initialize($label, $trait, $attributes); return $interactable; @@ -154,7 +153,7 @@ abstract class Interactable * @param string $trait the specific trait of the current element * @param array $attributes the attributes of the button element */ - static function createAccept($label = NULL, $trait = NULL, $attributes = []) + public static function createAccept($label = NULL, $trait = NULL, $attributes = []) { $args = func_num_args() ? func_get_args() : [_('Ãœbernehmen')]; return self::__callStatic(__FUNCTION__, $args); @@ -170,7 +169,7 @@ abstract class Interactable * @param string $trait the specific trait of the current element * @param array $attributes the attributes of the button element */ - static function createEdit($label = NULL, $trait = NULL, $attributes = []) + public static function createEdit($label = NULL, $trait = NULL, $attributes = []) { $args = func_num_args() ? func_get_args() : [_('Bearbeiten')]; return self::__callStatic(__FUNCTION__, $args); @@ -186,7 +185,7 @@ abstract class Interactable * @param string $trait the specific trait of the current element * @param array $attributes the attributes of the button element */ - static function createCancel($label = NULL, $trait = NULL, $attributes = []) + public static function createCancel($label = NULL, $trait = NULL, $attributes = []) { $args = func_num_args() ? func_get_args() : [_('Abbrechen')]; return self::__callStatic(__FUNCTION__, $args); -- GitLab