Skip to content

Commit

Permalink
Merge branch 'typehints' into 'trunk'
Browse files Browse the repository at this point in the history
Additional typehints

Closes #6

See merge request ntheen/ilias-certificates!162
  • Loading branch information
mjansenDatabay committed Sep 18, 2018
2 parents eff71d7 + 34f4b37 commit c902f5c
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ilCertificateFactory
* @return ilCertificate
* @throws ilException
*/
public function create(ilObject $object)
public function create(ilObject $object) : ilCertificate
{
$type = $object->getType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -76,7 +76,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null)
*
* @return mixed - [PLACEHOLDER] => 'description'
*/
public function getPlaceholderDescriptions()
public function getPlaceholderDescriptions() : array
{
return $this->placeholder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -78,7 +78,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null)
*
* @return mixed - [PLACEHOLDER] => 'description'
*/
public function getPlaceholderDescriptions()
public function getPlaceholderDescriptions() : array
{
return $this->placeholder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -79,7 +79,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null)
*
* @return mixed - [PLACEHOLDER] => 'description'
*/
public function getPlaceholderDescriptions()
public function getPlaceholderDescriptions() : array
{
return $this->placeholder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -140,7 +140,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null)
*
* @return mixed - [PLACEHOLDER] => 'description'
*/
public function getPlaceholderDescriptions()
public function getPlaceholderDescriptions() : array
{
return $this->placeholder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -84,7 +84,7 @@ public function createPlaceholderHtmlDescription(ilTemplate $template = null)
*
* @return mixed - [PLACEHOLDER] => 'description'
*/
public function getPlaceholderDescriptions()
public function getPlaceholderDescriptions() : array
{
return $this->placeholder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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")',
Expand Down Expand Up @@ -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")',
Expand All @@ -302,6 +307,7 @@ private function fetchLatestVersion($objId, $userId)
$objId,
$version
));

return $version;
}

Expand All @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -73,9 +70,4 @@ protected function fillRow($dataSet)
$this->tpl->setVariable('LINK_TEXT', $text);
$this->tpl->parseCurrentBlock();
}

public function download()
{
echo "hello";
}
}

0 comments on commit c902f5c

Please sign in to comment.