Skip to content

Commit

Permalink
add stricter types
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Aug 8, 2024
1 parent 42d2ca1 commit 7a2a3ca
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions files/lib/acp/form/FaqQuestionAddForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class FaqQuestionAddForm extends AbstractFormBuilderForm
* list of available languages
* @var Language[]
*/
protected $availableLanguages = [];
protected array $availableLanguages = [];

protected $isMultilingual = 0;
protected int $isMultilingual = 0;

#[Override]
public function readParameters()
Expand Down
11 changes: 4 additions & 7 deletions files/lib/acp/page/FaqQuestionListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,20 @@ class FaqQuestionListPage extends SortablePage

/**
* category id
* @var integer
*/
public $categoryID = 0;
public int $categoryID = 0;

/**
* question
* @var string
*/
public $question = '';
public string $question = '';

/**
* answer
* @var string
*/
public $answer = '';
public string $answer = '';

public $showFaqAddDialog = 0;
public int $showFaqAddDialog = 0;

#[Override]
public function readParameters()
Expand Down
12 changes: 6 additions & 6 deletions files/lib/data/faq/Question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ public function getTitle(): string
return WCF::getLanguage()->get($this->question);
}

public function getAnswer()
public function getAnswer(): string
{
return WCF::getLanguage()->get($this->answer);
}

public function getFormattedOutput()
public function getFormattedOutput(): string
{
$processor = new HtmlOutputProcessor();
$processor->process($this->getAnswer(), 'dev.tkirch.wsc.faq.question', $this->questionID);

return $processor->getHtml();
}

public function getPlainOutput()
public function getPlainOutput(): string
{
$processor = new HtmlOutputProcessor();
$processor->setOutputType('text/plain');
Expand All @@ -69,7 +69,7 @@ public function getPlainOutput()
return $processor->getHtml();
}

public function getCategory()
public function getCategory(): FaqCategory
{
if (!isset($this->category)) {
$category = new Category($this->categoryID);
Expand All @@ -79,7 +79,7 @@ public function getCategory()
return $this->category;
}

public function isAccessible(?User $user = null)
public function isAccessible(?User $user = null): bool
{
if ($this->isDisabled && !WCF::getSession()->getPermission('admin.faq.canViewQuestion')) {
return false;
Expand All @@ -92,7 +92,7 @@ public function isAccessible(?User $user = null)
return WCF::getSession()->getPermission('user.faq.canViewFAQ');
}

public function getAttachments()
public function getAttachments(): GroupedAttachmentList
{
if (empty($this->attachmentList)) {
$this->attachmentList = new GroupedAttachmentList('dev.tkirch.wsc.faq.question');
Expand Down
10 changes: 2 additions & 8 deletions files/lib/data/faq/QuestionEditor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ final class QuestionEditor extends DatabaseObjectEditor

/**
* Returns the new show order for a object
*
* @param integer $showOrder
*
* @return integer
*/
public function updateShowOrder($showOrder)
public function updateShowOrder(int $showOrder): int
{
if ($showOrder === null) {
$showOrder = \PHP_INT_MAX;
Expand Down Expand Up @@ -68,10 +64,8 @@ public function updateShowOrder($showOrder)

/**
* Returns the show order for a new object
*
* @return integer
*/
public static function getShowOrder()
public static function getShowOrder(): int
{
$sql = "SELECT MAX(showOrder) AS showOrder
FROM " . static::getDatabaseTableName();
Expand Down
2 changes: 1 addition & 1 deletion files/lib/page/FaqQuestionListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FaqQuestionListPage extends AbstractPage
*/
public $neededPermissions = ['user.faq.canViewFAQ'];

public $showFaqAddDialog = 0;
public int $showFaqAddDialog = 0;

#[Override]
public function readParameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function execute()
}
}

private function getLanguageCache()
private function getLanguageCache(): array
{
$languageVariables = [];
/** @var Question $question */
Expand Down

0 comments on commit 7a2a3ca

Please sign in to comment.