diff --git a/lib/classes/I18N.php b/lib/classes/I18N.php index 4ed94b78396ee92eda92091d3f7d300462e90a3a..18e1e7aa74926977951103f85df9174013838303 100644 --- a/lib/classes/I18N.php +++ b/lib/classes/I18N.php @@ -66,7 +66,7 @@ class I18N * @param array_merge $attributes Additional variables for the * element */ - protected function __construct($template, $name, $value, array $attributes) + final protected function __construct($template, $name, $value, array $attributes) { $this->template = $GLOBALS['template_factory']->open($template); $this->name = $name; diff --git a/lib/classes/Interactable.class.php b/lib/classes/Interactable.class.php index b401115d976f42db5d8e09f6a46c68c08141fc23..6ba7c25ab7e2eb4eed63e34292e5ac88f93f5767 100644 --- a/lib/classes/Interactable.class.php +++ b/lib/classes/Interactable.class.php @@ -15,7 +15,6 @@ namespace Studip; */ abstract class Interactable { - public $label, $attributes; /** @@ -107,7 +106,7 @@ abstract class Interactable * @param string $trait the specific trait of the current element * @param array $attributes the attributes of the button element * - * @return Interactable a Interactable element + * @return Interactable element */ public static function create($label = NULL, $trait = NULL, $attributes = []) { diff --git a/lib/classes/LicenseAvatar.php b/lib/classes/LicenseAvatar.php index 9d48f0a83d06542de6ded0b5606b0e9db1d1b43a..27072abcbfe72c513617b232467d491e1d670559 100644 --- a/lib/classes/LicenseAvatar.php +++ b/lib/classes/LicenseAvatar.php @@ -25,7 +25,7 @@ class LicenseAvatar extends Avatar */ public static function getAvatar($id) { - return new static($id); + return new self($id); } /** @@ -35,7 +35,7 @@ class LicenseAvatar extends Avatar */ public static function getNobody() { - return new static('nobody'); + return new self('nobody'); } /** diff --git a/lib/classes/MultiDimArrayObject.class.php b/lib/classes/MultiDimArrayObject.class.php index bcbdee49fe54354696f86c1f6e585259b7dd8112..8af74a7ea74bbe35d5fab1d6e9ecf077c2c0a100 100644 --- a/lib/classes/MultiDimArrayObject.class.php +++ b/lib/classes/MultiDimArrayObject.class.php @@ -99,7 +99,8 @@ class MultiDimArrayObject extends StudipArrayObject { $new_value = $this->recursiveArrayToArrayObjects($value); if (is_array($new_value)) { - $new_value = new static($new_value, $this->getFlags(), $this->getIteratorClass()); + $class = get_called_class(); + $new_value = new $class($new_value, $this->getFlags(), $this->getIteratorClass()); } if (is_null($key)) { return $this->storage[] = $new_value; @@ -117,7 +118,8 @@ class MultiDimArrayObject extends StudipArrayObject foreach ($data as $key => $value) { $new_value = $this->recursiveArrayToArrayObjects($value); if (is_array($new_value)) { - $new_data[$key] = new static($new_value, $this->getFlags(), $this->getIteratorClass()); + $class = get_called_class(); + $new_data[$key] = new $class($new_value, $this->getFlags(), $this->getIteratorClass()); } else { $new_data[$key] = $value; } diff --git a/lib/classes/QuestionBox.php b/lib/classes/QuestionBox.php index d4d33be5fe64b270c1e735fffb3dd1f41d937d7a..8c335b1599ab5710aa2f7e299edf36f486c8af3f 100644 --- a/lib/classes/QuestionBox.php +++ b/lib/classes/QuestionBox.php @@ -60,7 +60,7 @@ class QuestionBox implements LayoutMessage * * @param string $question The question that should be confirmed */ - protected function __construct($question, $accept_url, $decline_url) + final protected function __construct($question, $accept_url, $decline_url) { $this->question = $question; $this->setAcceptURL($accept_url); diff --git a/lib/classes/QuickSearch.class.php b/lib/classes/QuickSearch.class.php index e0e57d306a10c8a007f33fbb44272d65ef45175e..b058c53a2d0a3086e8982ddb7c425caf2868f557 100644 --- a/lib/classes/QuickSearch.class.php +++ b/lib/classes/QuickSearch.class.php @@ -174,7 +174,7 @@ class QuickSearch * * @return void */ - public function __construct($name, $search = NULL) + final public function __construct($name, $search = NULL) { self::$count_QS++; $this->name = $name; diff --git a/lib/classes/RangeConfig.class.php b/lib/classes/RangeConfig.class.php index 17375d15e70c03ed0fa49a77da0edf7e99bb7e60..b1030e3961520682efd3b15a1d4c1adfc8d65ccd 100644 --- a/lib/classes/RangeConfig.class.php +++ b/lib/classes/RangeConfig.class.php @@ -78,7 +78,7 @@ class RangeConfig extends Config * @param string $range_id * @param array $data */ - public function __construct($range_id = null, $data = null) + final public function __construct($range_id = null, $data = null) { $this->range_id = $range_id; if ($range_id !== null || $data !== null) { diff --git a/lib/classes/WidgetContainer.php b/lib/classes/WidgetContainer.php index 39665a9a6cb822df35269563f2cd8df3cc88c71e..b4aaa8cdd058508a31bdd0382c29c9d9783a02bb 100644 --- a/lib/classes/WidgetContainer.php +++ b/lib/classes/WidgetContainer.php @@ -9,6 +9,14 @@ */ abstract class WidgetContainer { + /** + * Protected constructor to ensure that the singleton Get() method is always + * used. + * + * @see WidgetContainer::Get + */ + abstract protected function __construct(); + /** * The singleton instance of the container */ @@ -30,16 +38,6 @@ abstract class WidgetContainer return static::$instances[$class]; } - /** - * Private constructor to ensure that the singleton Get() method is always - * used. - * - * @see WidgetContainer::Get - */ - protected function __construct() - { - } - /** * Contains the widgets of the container */ diff --git a/lib/classes/forms/Form.php b/lib/classes/forms/Form.php index 06331901cc1b287ff51f100453cdcf1285dec8c7..569eb1fa32af6ae5248d5132e754d44fdea09190 100644 --- a/lib/classes/forms/Form.php +++ b/lib/classes/forms/Form.php @@ -49,6 +49,15 @@ class Form extends Part return $form; } + /** + * Finalized constructor. + * + * @param mixed[] ...$parts + */ + final public function __construct(...$parts) + { + parent::__construct($parts); + } /** * Adds a new Fieldset to the Form object with the SORM object's fields as diff --git a/lib/classes/forms/Input.php b/lib/classes/forms/Input.php index 3018a5baf391c8d18aed8aa0dc64408f01779259..aa3069b70b1224c560d9337a1d0eb8c562158b93 100644 --- a/lib/classes/forms/Input.php +++ b/lib/classes/forms/Input.php @@ -88,7 +88,7 @@ abstract class Input * @param $value * @param $attributes */ - public function __construct($name, $title, $value, array $attributes = []) + final public function __construct($name, $title, $value, array $attributes = []) { $this->name = $name; $this->title = $title; diff --git a/lib/classes/helpbar/Helpbar.php b/lib/classes/helpbar/Helpbar.php index 4725a782b7d524a910236426a6168ca69c38dd5c..cfa98a34b8f6a8a6ab8ac93b5a38bc6a2430fe80 100644 --- a/lib/classes/helpbar/Helpbar.php +++ b/lib/classes/helpbar/Helpbar.php @@ -17,10 +17,8 @@ class Helpbar extends WidgetContainer /** * Constructs the helpbar */ - public function __construct() + protected function __construct() { - parent::__construct(); - $this->help_admin = isset($GLOBALS['perm']) && ($GLOBALS['perm']->have_perm('root') || RolePersistence::isAssignedRole($GLOBALS['user']->id, 'Hilfe-Administrator(in)')); } diff --git a/lib/classes/sidebar/Sidebar.php b/lib/classes/sidebar/Sidebar.php index d91578654cfc61a3b531ff6036817794bca4bb99..7536a7f9df0ab10e1fed05f194dbad57e9718013 100644 --- a/lib/classes/sidebar/Sidebar.php +++ b/lib/classes/sidebar/Sidebar.php @@ -18,10 +18,8 @@ class Sidebar extends WidgetContainer /** * Constructor, tries to automagically set the sidebar's title. */ - public function __construct() + protected function __construct() { - parent::__construct(); - $this->setTitle(); } diff --git a/lib/models/OERDownloadcounter.php b/lib/models/OERDownloadcounter.php index 0c918dc1d87c012ddd3bada25b6c5b4c052ed875..fa603a380a5c170a8dd2b0fe3df79fade5bc9226 100755 --- a/lib/models/OERDownloadcounter.php +++ b/lib/models/OERDownloadcounter.php @@ -9,7 +9,7 @@ class OERDownloadcounter extends SimpleORMap public static function addCounter($material_id) { - $counter = new static(); + $counter = new self(); $counter['material_id'] = $material_id; if (Config::get()->oer_GEOLOCATOR_API) { list($url, $lon, $lat) = explode(" ", Config::get()->oer_GEOLOCATOR_API); diff --git a/lib/models/OERHost.php b/lib/models/OERHost.php index bba555d1e76e494747a1df86188930e8e847fca7..7cb2ba5c9d4d9e04dd50221a581fba1e438f357c 100755 --- a/lib/models/OERHost.php +++ b/lib/models/OERHost.php @@ -21,7 +21,7 @@ class OERHost extends OERIdentity } return $host; } else { - $host = new static(); + $host = new self(); $host['name'] = Config::get()->UNI_NAME_CLEAN; $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"; $host['last_updated'] = time(); diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 3eeac13f6434c1d9941c4af06a245dd04ca67fbc..ab2c332a63590ec9ae535a15d26621b5c52ffbe5 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -458,7 +458,8 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate */ public static function create($data) { - $record = new static(); + $class = get_called_class(); + $record = new $class(); $record->setData($data, false); if ($record->store()) { return $record; @@ -653,7 +654,8 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate $sql = "WHERE {$sql}"; } - $record = new static(); + $class = get_called_class(); + $record = new $class(); $record->setNew(false); $db_table = static::config('db_table'); diff --git a/lib/models/StudipNews.class.php b/lib/models/StudipNews.class.php index 643f9eba6bbccf6f2f905e23e70b53baa9684536..2d5652aa14fd14be0f642bc2f32c0fb56b86ec72 100644 --- a/lib/models/StudipNews.class.php +++ b/lib/models/StudipNews.class.php @@ -305,7 +305,7 @@ class StudipNews extends SimpleORMap implements PrivacyObject $objects[$area][$id]['title'] = _('Ankündigungen auf der Stud.IP Startseite'); } if ($as_objects) { - $objects[$area][$id]['object'] = new static(); + $objects[$area][$id]['object'] = new self(); $objects[$area][$id]['object']->setData($result, true); $objects[$area][$id]['object']->setNew(false); } @@ -441,25 +441,6 @@ class StudipNews extends SimpleORMap implements PrivacyObject } } - /** - * DEPRECATED - */ - public static function TouchNews($news_id, $touch_stamp = null) - { - $ret = false; - if (!$touch_stamp) { - $touch_stamp = time(); - } - $news = new static($news_id); - if (!$news->isNew()) { - $news->date = strtotime('today 0:00:00', $touch_stamp); - if (!$news->store()) { - $news->triggerChdate(); - } - } - return $ret; - } - public static function DeleteNewsRanges($range_id) { $query = "DELETE FROM news_range WHERE range_id = :id"; diff --git a/lib/models/Token.php b/lib/models/Token.php index dd52602f9a34f77835f347621cd47ac9aa87d912..f2fd6fa683b8a1124c87277a25bd93fdcfa708a1 100644 --- a/lib/models/Token.php +++ b/lib/models/Token.php @@ -50,7 +50,7 @@ class Token extends SimpleORMap */ public static function create($duration = 30, $user_id = null) { - $token = new static(); + $token = new self(); $token->user_id = $user_id ?? $GLOBALS['user']->id; $token->expiration = strtotime("+{$duration} seconds"); $token->store();