From 34f4b3739d9d29e18f61739dad5a56553fcdc0a7 Mon Sep 17 00:00:00 2001 From: Niels Theen Date: Tue, 18 Sep 2018 11:54:31 +0200 Subject: [PATCH] Additional typehints --- .../File/Template/class.ilPageFormats.php | 2 +- .../File/Template/class.ilXlsFoParser.php | 4 +-- ...ertificateSettingsCourseFormRepository.php | 8 ++--- .../classes/Form/class.ilFormFieldParser.php | 2 +- .../Gui/class.ilCertificateFactory.php | 2 +- .../Gui/class.ilCertificateGUIFactory.php | 2 +- .../class.ilCoursePlaceholderDescription.php | 4 +-- .../class.ilDefaultPlaceholderDescription.php | 4 +-- ...class.ilExercisePlaceholderDescription.php | 4 +-- .../class.ilScormPlaceholderDescription.php | 4 +-- .../class.ilTestPlaceholderDescription.php | 4 +-- .../class.ilCertificateValueReplacement.php | 2 +- .../class.ilUserCertificateRepository.php | 30 +++++++++++-------- .../User/class.ilUserCertificateTableGUI.php | 10 +------ 14 files changed, 40 insertions(+), 42 deletions(-) diff --git a/Services/Certificate/classes/File/Template/class.ilPageFormats.php b/Services/Certificate/classes/File/Template/class.ilPageFormats.php index 5f24303a2b0f..bac756eb4fe4 100644 --- a/Services/Certificate/classes/File/Template/class.ilPageFormats.php +++ b/Services/Certificate/classes/File/Template/class.ilPageFormats.php @@ -21,7 +21,7 @@ public function __construct(ilLanguage $language) * * @return array Associative array containing available page formats */ - public function fetchPageFormats() + public function fetchPageFormats() : array { return array( 'a4' => array( diff --git a/Services/Certificate/classes/File/Template/class.ilXlsFoParser.php b/Services/Certificate/classes/File/Template/class.ilXlsFoParser.php index 253b96806dc2..57f17e83ec5d 100644 --- a/Services/Certificate/classes/File/Template/class.ilXlsFoParser.php +++ b/Services/Certificate/classes/File/Template/class.ilXlsFoParser.php @@ -157,9 +157,9 @@ public function parse(array $formData) : string /** * @param string $a_number - * @return float + * @return string */ - private function formatNumberString($a_number) + private function formatNumberString($a_number) : string { return str_replace(',', '.', $a_number); } diff --git a/Services/Certificate/classes/Form/Repository/class.ilCertificateSettingsCourseFormRepository.php b/Services/Certificate/classes/Form/Repository/class.ilCertificateSettingsCourseFormRepository.php index b78e0ca8539f..1d493fe2a86c 100644 --- a/Services/Certificate/classes/Form/Repository/class.ilCertificateSettingsCourseFormRepository.php +++ b/Services/Certificate/classes/Form/Repository/class.ilCertificateSettingsCourseFormRepository.php @@ -144,13 +144,13 @@ public function fetchFormFieldData(string $content) * @param int $a_parent_ref_id * @return array */ - private function getLPTypes(int $a_parent_ref_id) + private function getLPTypes(int $a_parent_ref_id) : array { global $DIC; $tree = $DIC['tree']; - $res = array(); + $result = array(); $root = $tree->getNodeData($a_parent_ref_id); $sub_items = $tree->getSubTree($root); @@ -162,12 +162,12 @@ private function getLPTypes(int $a_parent_ref_id) $modes = $class::getDefaultModes(ilObjUserTracking::_enabledLearningProgress()); if(sizeof($modes) > 1) { - $res[] = $node['type']; + $result[] = $node['type']; } } } - return $res; + return $result; } } diff --git a/Services/Certificate/classes/Form/class.ilFormFieldParser.php b/Services/Certificate/classes/Form/class.ilFormFieldParser.php index 213ed7338786..fbf5c10a0de7 100644 --- a/Services/Certificate/classes/Form/class.ilFormFieldParser.php +++ b/Services/Certificate/classes/Form/class.ilFormFieldParser.php @@ -10,7 +10,7 @@ class ilFormFieldParser * @param string $content * @return array */ - public function fetchDefaultFormFields(string $content) + public function fetchDefaultFormFields(string $content) : array { $pagewidth = "21cm"; if (preg_match("/page-width\=\"([^\"]+)\"/", $content, $matches)) { diff --git a/Services/Certificate/classes/Gui/class.ilCertificateFactory.php b/Services/Certificate/classes/Gui/class.ilCertificateFactory.php index 36d4a0387782..1be11fd02b90 100644 --- a/Services/Certificate/classes/Gui/class.ilCertificateFactory.php +++ b/Services/Certificate/classes/Gui/class.ilCertificateFactory.php @@ -11,7 +11,7 @@ class ilCertificateFactory * @return ilCertificate * @throws ilException */ - public function create(ilObject $object) + public function create(ilObject $object) : ilCertificate { $type = $object->getType(); diff --git a/Services/Certificate/classes/Gui/class.ilCertificateGUIFactory.php b/Services/Certificate/classes/Gui/class.ilCertificateGUIFactory.php index d015cc2305b5..ca2a552c44cd 100644 --- a/Services/Certificate/classes/Gui/class.ilCertificateGUIFactory.php +++ b/Services/Certificate/classes/Gui/class.ilCertificateGUIFactory.php @@ -28,7 +28,7 @@ public function __construct(\ILIAS\DI\Container $dic = null) * @return ilCertificateGUI * @throws ilException */ - public function create(\ilObject $object) + public function create(\ilObject $object) : ilCertificateGUI { global $DIC; diff --git a/Services/Certificate/classes/Placeholder/Description/class.ilCoursePlaceholderDescription.php b/Services/Certificate/classes/Placeholder/Description/class.ilCoursePlaceholderDescription.php index 77272f6836b7..7e3bf8aa9db6 100644 --- a/Services/Certificate/classes/Placeholder/Description/class.ilCoursePlaceholderDescription.php +++ b/Services/Certificate/classes/Placeholder/Description/class.ilCoursePlaceholderDescription.php @@ -51,7 +51,7 @@ public function __construct(ilDefaultPlaceholderDescription $defaultPlaceholderD * @param null $template * @return mixed - [PLACEHOLDER] => 'description' */ - public function createPlaceholderHtmlDescription(ilTemplate $template = null) + public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string { if (null === $template) { $template = new ilTemplate('tpl.default_description.html', true, true, 'Services/Certificate'); @@ -76,7 +76,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null) * * @return mixed - [PLACEHOLDER] => 'description' */ - public function getPlaceholderDescriptions() + public function getPlaceholderDescriptions() : array { return $this->placeholder; } diff --git a/Services/Certificate/classes/Placeholder/Description/class.ilDefaultPlaceholderDescription.php b/Services/Certificate/classes/Placeholder/Description/class.ilDefaultPlaceholderDescription.php index ee8b064dd6d1..7dc66bb22726 100644 --- a/Services/Certificate/classes/Placeholder/Description/class.ilDefaultPlaceholderDescription.php +++ b/Services/Certificate/classes/Placeholder/Description/class.ilDefaultPlaceholderDescription.php @@ -53,7 +53,7 @@ public function __construct(ilLanguage $language) * @param null $template * @return array|mixed */ - public function createPlaceholderHtmlDescription(ilTemplate $template = null) + public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string { if (null === $template) { $template = new ilTemplate('tpl.default_description.html', true, true, 'Services/Certificate'); @@ -78,7 +78,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null) * * @return mixed - [PLACEHOLDER] => 'description' */ - public function getPlaceholderDescriptions() + public function getPlaceholderDescriptions() : array { return $this->placeholder; } diff --git a/Services/Certificate/classes/Placeholder/Description/class.ilExercisePlaceholderDescription.php b/Services/Certificate/classes/Placeholder/Description/class.ilExercisePlaceholderDescription.php index cbe54137b5b8..45b99cd3d15c 100644 --- a/Services/Certificate/classes/Placeholder/Description/class.ilExercisePlaceholderDescription.php +++ b/Services/Certificate/classes/Placeholder/Description/class.ilExercisePlaceholderDescription.php @@ -54,7 +54,7 @@ public function __construct(ilDefaultPlaceholderDescription $defaultPlaceholderD * @param ilTemplate $template * @return mixed - [PLACEHOLDER] => 'description' */ - public function createPlaceholderHtmlDescription(ilTemplate $template = null) + public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string { if (null === $template) { $template = new ilTemplate('tpl.default_description.html', true, true, 'Services/Certificate'); @@ -79,7 +79,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null) * * @return mixed - [PLACEHOLDER] => 'description' */ - public function getPlaceholderDescriptions() + public function getPlaceholderDescriptions() : array { return $this->placeholder; } diff --git a/Services/Certificate/classes/Placeholder/Description/class.ilScormPlaceholderDescription.php b/Services/Certificate/classes/Placeholder/Description/class.ilScormPlaceholderDescription.php index 8029822218ae..030220530662 100644 --- a/Services/Certificate/classes/Placeholder/Description/class.ilScormPlaceholderDescription.php +++ b/Services/Certificate/classes/Placeholder/Description/class.ilScormPlaceholderDescription.php @@ -76,7 +76,7 @@ public function __construct( * @param ilTemplate|null $template * @return mixed - [PLACEHOLDER] => 'description' */ - public function createPlaceholderHtmlDescription(ilTemplate $template = null) + public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string { if (null === $template) { $template = new ilTemplate('tpl.scorm_description.html', true, true, 'Services/Certificate'); @@ -140,7 +140,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null) * * @return mixed - [PLACEHOLDER] => 'description' */ - public function getPlaceholderDescriptions() + public function getPlaceholderDescriptions() : array { return $this->placeholder; } diff --git a/Services/Certificate/classes/Placeholder/Description/class.ilTestPlaceholderDescription.php b/Services/Certificate/classes/Placeholder/Description/class.ilTestPlaceholderDescription.php index 2946aa6723f3..91795805027d 100644 --- a/Services/Certificate/classes/Placeholder/Description/class.ilTestPlaceholderDescription.php +++ b/Services/Certificate/classes/Placeholder/Description/class.ilTestPlaceholderDescription.php @@ -59,7 +59,7 @@ public function __construct(ilDefaultPlaceholderDescription $defaultPlaceholderD * @param ilTemplate|null $template * @return mixed - [PLACEHOLDER] => 'description' */ - public function createPlaceholderHtmlDescription(ilTemplate $template = null) + public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string { if (null === $template) { $template = new ilTemplate('tpl.default_description.html', true, true, 'Services/Certificate'); @@ -84,7 +84,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null) * * @return mixed - [PLACEHOLDER] => 'description' */ - public function getPlaceholderDescriptions() + public function getPlaceholderDescriptions() : array { return $this->placeholder; } diff --git a/Services/Certificate/classes/Placeholder/Replacement/class.ilCertificateValueReplacement.php b/Services/Certificate/classes/Placeholder/Replacement/class.ilCertificateValueReplacement.php index 2dc75eec4289..4d2b025c3729 100644 --- a/Services/Certificate/classes/Placeholder/Replacement/class.ilCertificateValueReplacement.php +++ b/Services/Certificate/classes/Placeholder/Replacement/class.ilCertificateValueReplacement.php @@ -15,7 +15,7 @@ class ilCertificateValueReplacement * @param string $backgroundPath * @return string */ - public function replace(array $placeholderValues, string $certificateContent, string $backgroundPath) + public function replace(array $placeholderValues, string $certificateContent, string $backgroundPath) : string { foreach ($placeholderValues as $placeholder => $value) { $certificateContent = str_replace('[' . $placeholder . ']', $value, $certificateContent); diff --git a/Services/Certificate/classes/User/class.ilUserCertificateRepository.php b/Services/Certificate/classes/User/class.ilUserCertificateRepository.php index 23d39b92d723..e44228d1443e 100644 --- a/Services/Certificate/classes/User/class.ilUserCertificateRepository.php +++ b/Services/Certificate/classes/User/class.ilUserCertificateRepository.php @@ -70,7 +70,7 @@ public function save(ilUserCertificate $userCertificate) * @param $userId * @return array */ - public function fetchActiveCertificates($userId) + public function fetchActiveCertificates(int $userId) : array { $this->logger->info(sprintf('START - Fetching all active certificates for user: "%s"', $userId)); @@ -104,7 +104,7 @@ public function fetchActiveCertificates($userId) return $result; } - public function fetchActiveCertificate($userId, $objectId) + public function fetchActiveCertificate(int $userId, int $objectId) : ilUserCertificate { $this->logger->info(sprintf('START - Fetching all active certificates for user: "%s" and object: "%s"', $userId, $objectId)); @@ -144,11 +144,11 @@ public function fetchActiveCertificate($userId, $objectId) } /** - * @param $userId - * @param $type + * @param int $userId + * @param string $type * @return array */ - public function fetchActiveCertificatesByType($userId, $type) + public function fetchActiveCertificatesByType(int $userId, string $type) : array { $this->logger->info(sprintf('START - Fetching all active certificates for user: "%s" and type: "%s"', $userId, $type)); @@ -186,11 +186,11 @@ public function fetchActiveCertificatesByType($userId, $type) } /** - * @param $id + * @param int $id * @return ilUserCertificate * @throws ilException */ - public function fetchCertificate($id) + public function fetchCertificate(int $id) : ilUserCertificate { $this->logger->info(sprintf('START - Fetch certificate by id: "%s"', $id)); @@ -225,11 +225,11 @@ public function fetchCertificate($id) } /** - * @param $objId - * @param $userId + * @param int $objId + * @param int $userId * @return array */ - private function fetchCertificatesOfObject($objId, $userId) + private function fetchCertificatesOfObject(int $objId, int $userId) : array { $this->logger->info(sprintf( 'START - fetching all certificates of object(user id: "%s", object id: "%s")', @@ -279,7 +279,12 @@ private function fetchCertificatesOfObject($objId, $userId) return $result; } - private function fetchLatestVersion($objId, $userId) + /** + * @param int $objId + * @param int $userId + * @return string + */ + private function fetchLatestVersion(int $objId, int $userId) : string { $this->logger->info(sprintf( 'START - fetching of latest certificates of object(user id: "%s", object id: "%s")', @@ -302,6 +307,7 @@ private function fetchLatestVersion($objId, $userId) $objId, $version )); + return $version; } @@ -310,7 +316,7 @@ private function fetchLatestVersion($objId, $userId) * @param $userId * @throws ilDatabaseException */ - private function deactivatePreviousCertificates($objId, $userId) + private function deactivatePreviousCertificates(int $objId, int $userId) { $this->logger->info(sprintf('START - deactivating previous certificates for user id: "%s" and object id: "%s"', $userId, $objId)); diff --git a/Services/Certificate/classes/User/class.ilUserCertificateTableGUI.php b/Services/Certificate/classes/User/class.ilUserCertificateTableGUI.php index b55bccaac20f..0d06c6a94c0a 100644 --- a/Services/Certificate/classes/User/class.ilUserCertificateTableGUI.php +++ b/Services/Certificate/classes/User/class.ilUserCertificateTableGUI.php @@ -44,12 +44,9 @@ public function __construct( $this->addColumn($this->lng->txt('title'), '', ''); $this->addColumn($this->lng->txt('date'), '', ''); $this->addColumn($this->lng->txt('action'), '', ''); - -// $this->addMultiCommand('saveAttachments', $this->lng->txt('adopt')); -// $this->addMultiCommand('deleteAttachments', $this->lng->txt('delete')); } - protected function fillRow($dataSet) + protected function fillRow(array $dataSet) { $this->enable('select_all'); $this->setSelectAllCheckbox('conditions'); @@ -73,9 +70,4 @@ protected function fillRow($dataSet) $this->tpl->setVariable('LINK_TEXT', $text); $this->tpl->parseCurrentBlock(); } - - public function download() - { - echo "hello"; - } }