Skip to content
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,22 @@ parameters:
- identifier: new.static
- identifier: trait.unused
checkMissingOverrideMethodAttribute: true
polluteScopeWithLoopInitialAssignments: true
polluteScopeWithAlwaysIterableForeach: true
polluteScopeWithBlock: true
checkExplicitMixedMissingReturn: false
checkFunctionNameCase: true
checkInternalClassCaseSensitivity: true
reportMaybesInMethodSignatures: false
reportMaybesInPropertyPhpDocTypes: true
reportStaticMethodSignatures: true
checkTooWideReturnTypesInProtectedAndPublicMethods: false
checkTooWideParameterOutInProtectedAndPublicMethods: true
checkTooWideThrowTypesInProtectedAndPublicMethods: true
rememberPossiblyImpureFunctionValues: true
reportPossiblyNonexistentGeneralArrayOffset: true
reportAlwaysTrueInLastCondition: true
reportNonIntStringArrayKey: false
reportWrongPhpDocTypeInVarTag: false
reportAnyTypeWideningInVarTag: true
checkStrictPrintfPlaceholderTypes: true
5 changes: 0 additions & 5 deletions wcfsetup/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,6 @@ public function close()
}
}

#[\Override]
public function getContentList()
{
if (!$this->read) {
Expand All @@ -896,7 +895,6 @@ public function getContentList()
return $this->contentList;
}

#[\Override]
public function getFileInfo($fileIndex)
{
if (!is_int($fileIndex)) {
Expand All @@ -909,7 +907,6 @@ public function getFileInfo($fileIndex)
return $this->contentList[$fileIndex];
}

#[\Override]
public function getIndexByFilename($filename)
{
foreach ($this->contentList as $index => $file) {
Expand All @@ -920,7 +917,6 @@ public function getIndexByFilename($filename)
return false;
}

#[\Override]
public function extractToString($index)
{
if (!$this->read) {
Expand All @@ -947,7 +943,6 @@ public function extractToString($index)
return $content;
}

#[\Override]
public function extract($index, $destination)
{
if (!$this->read) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,9 @@ public function execute(): ResponseInterface
* Exports the list of stored ip addresses for this user using the IPv4 representation
* whenever possible.
*
* @param string $databaseTable
* @param string $ipAddressColumn
* @param string $timeColumn
* @param string $userIDColumn
* @return mixed[]
*/
public function exportIpAddresses($databaseTable, $ipAddressColumn, $timeColumn, $userIDColumn)
public function exportIpAddresses(string $databaseTable, string $ipAddressColumn, string $timeColumn, string $userIDColumn)
{
$sql = "SELECT {$ipAddressColumn}, {$timeColumn}
FROM {$databaseTable}
Expand All @@ -261,11 +257,9 @@ public function exportIpAddresses($databaseTable, $ipAddressColumn, $timeColumn,
}

/**
* @param string $tableName
* @param string $userIDColumn
* @return mixed[]
*/
protected function dumpTable($tableName, $userIDColumn)
protected function dumpTable(string $tableName, string $userIDColumn)
{
$sql = "SELECT *
FROM {$tableName}
Expand All @@ -282,11 +276,9 @@ protected function dumpTable($tableName, $userIDColumn)
}

/**
* @param string $ipAddressColumn
* @param string $timeColumn
* @return array{ipAddress: string, time: mixed}[]
*/
protected function fetchIpAddresses(PreparedStatement $statement, $ipAddressColumn, $timeColumn)
protected function fetchIpAddresses(PreparedStatement $statement, string $ipAddressColumn, string $timeColumn)
{
$ipAddresses = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ public function execute()
/**
* Sends a JSON-encoded response.
*
* @param int $progress
* @param ?array<string, mixed> $parameters
* @param string $proceedURL
* @return void
*/
#[\Override]
protected function sendResponse($progress = 0, ?array $parameters = null, $proceedURL = '')
protected function sendResponse(int $progress = 0, ?array $parameters = null, string $proceedURL = '')
{
if ($parameters === null) {
$parameters = $this->parameters;
Expand Down
6 changes: 2 additions & 4 deletions wcfsetup/install/files/lib/acp/form/AbstractAcpForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public function registerI18nValue(I18nValue $value)
/**
* Retrieves an i18n value object.
*
* @param string $fieldName
* @return I18nValue|null
*/
public function getI18nValue($fieldName)
public function getI18nValue(string $fieldName)
{
return $this->i18nValues[$fieldName] ?? null;
}
Expand Down Expand Up @@ -157,10 +156,9 @@ public function beforeSaveI18n(DatabaseObject $databaseObject)
*
* @template TDatabaseObject of DatabaseObject
* @param TDatabaseObject $databaseObject
* @param string $editorClass
* @return void
*/
public function saveI18n(DatabaseObject $databaseObject, $editorClass)
public function saveI18n(DatabaseObject $databaseObject, string $editorClass)
{
$data = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,9 @@ protected function setFormObjectData()
}

/**
* @param bool $available
* @return void
*/
protected function tooglePackageXmlFieldAvailabilty($available)
protected function tooglePackageXmlFieldAvailabilty(bool $available)
{
/** @var TabMenuFormContainer $tabMenu */
$tabMenu = $this->form->getNodeById('project');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ public function validate()
/**
* Validates the upload package input.
*
* @param string $filename
* @return void
* @throws UserInputException
*/
protected function validateUploadPackage($filename = '')
protected function validateUploadPackage(string $filename = '')
{
$this->activeTabMenuItem = 'upload';

Expand Down
4 changes: 1 addition & 3 deletions wcfsetup/install/files/lib/acp/form/PageAddForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,11 @@ protected function validateCustomUrls()
/**
* Validates given custom url.
*
* @param int $languageID
* @param string $customURL
* @return void
*
* @throws UserInputException
*/
protected function validateCustomUrl($languageID, $customURL)
protected function validateCustomUrl(int $languageID, string $customURL)
{
if (empty($customURL)) {
if ($this->pageType != 'system') {
Expand Down
2 changes: 1 addition & 1 deletion wcfsetup/install/files/lib/acp/form/PageEditForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function validateParentPageID()
}

#[\Override]
protected function validateCustomUrl($languageID, $customURL)
protected function validateCustomUrl(int $languageID, string $customURL)
{
if (!$this->supportsCustomUrl) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,9 @@ public function save()
/**
* Saves i18n values.
*
* @param PaidSubscription $subscription
* @param string $columnName
* @return void
*/
public function saveI18nValue(PaidSubscription $subscription, $columnName)
public function saveI18nValue(PaidSubscription $subscription, string $columnName)
{
if (!I18nHandler::getInstance()->isPlainValue($columnName)) {
I18nHandler::getInstance()->save(
Expand Down
3 changes: 1 addition & 2 deletions wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,10 @@ protected function validateUploads()
* If an override is invalid, unknown or matches a variable covered by
* the style editor itself, it will be silently discarded.
*
* @param string $variableName
* @return void
* @throws UserInputException
*/
protected function parseOverrides($variableName = 'overrideScss')
protected function parseOverrides(string $variableName = 'overrideScss')
{
static $colorNames = null;
if ($colorNames === null) {
Expand Down
3 changes: 1 addition & 2 deletions wcfsetup/install/files/lib/acp/form/UserAddForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,10 @@ public function save()
/**
* Throws a UserInputException if the username is not unique or not valid.
*
* @param string $username
* @return void
* @throws UserInputException
*/
protected function validateUsername($username)
protected function validateUsername(string $username)
{
if (empty($username)) {
throw new UserInputException('username');
Expand Down
2 changes: 1 addition & 1 deletion wcfsetup/install/files/lib/acp/form/UserEditForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public function save()
}

#[\Override]
protected function validateUsername($username)
protected function validateUsername(string $username)
{
try {
if (\mb_strtolower($this->user->username) != \mb_strtolower($username)) {
Expand Down
6 changes: 1 addition & 5 deletions wcfsetup/install/files/lib/acp/page/CacheListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,9 @@ public function readData()
/**
* Reads the information of cached files
*
* @param string $cacheType
* @param string $cacheDir
* @param ?Regex $ignore
* @param string $extension
* @return void
*/
protected function readCacheFiles($cacheType, $cacheDir, ?Regex $ignore = null, $extension = 'php')
protected function readCacheFiles(string $cacheType, string $cacheDir, ?Regex $ignore = null, string $extension = 'php')
{
if (!isset($this->cacheData[$cacheType])) {
$this->cacheData[$cacheType] = [];
Expand Down
6 changes: 2 additions & 4 deletions wcfsetup/install/files/lib/acp/page/LicensePage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,13 @@ static function ($packageUpdateServerID) use ($trustedServerIDs) {
*
* Stolen from PackageUpdateAction::canInstall()
*
* @param int $packageUpdateID
* @param string|null $minVersion
* @param string[] $installedPackages
* @param string[] $excludedPackagesOfInstalledPackages
* @return string[][]
*/
protected function canInstall(
$packageUpdateID,
$minVersion,
int $packageUpdateID,
?string $minVersion,
array &$installedPackages,
array &$excludedPackagesOfInstalledPackages
) {
Expand Down
13 changes: 5 additions & 8 deletions wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ protected function validateMysql()
$innerConditionBuilder = new PreparedStatementConditionBuilder(false);
$innerConditionBuilder->add('REFERENCED_TABLE_SCHEMA = ?', [WCF::getDB()->getDatabaseName()]);
$innerConditionBuilder->add('REFERENCED_TABLE_NAME = ?', [
ApplicationHandler::insertRealDatabaseTableNames($reference['referenceTable'])
ApplicationHandler::insertRealDatabaseTableNames($reference['referenceTable'])
]);
$innerConditionBuilder->add('REFERENCED_COLUMN_NAME = ?', [$reference['referenceColumn']]);
$innerConditionBuilder->add('TABLE_NAME = ?', [
ApplicationHandler::insertRealDatabaseTableNames($table)
ApplicationHandler::insertRealDatabaseTableNames($table)
]);
$innerConditionBuilder->add('COLUMN_NAME = ?', [$column]);

Expand Down Expand Up @@ -481,10 +481,9 @@ protected function validateWritableDirectories()
}

/**
* @param string $path
* @return bool
*/
protected function checkDirectory($path)
protected function checkDirectory(string $path)
{
if (!$this->createDirectoryIfNotExists($path)) {
$this->results['directories'][] = FileUtil::unifyDirSeparator($path);
Expand All @@ -496,10 +495,9 @@ protected function checkDirectory($path)
}

/**
* @param string $path
* @return bool
*/
protected function createDirectoryIfNotExists($path)
protected function createDirectoryIfNotExists(string $path)
{
if (!\file_exists($path) && !FileUtil::makePath($path)) {
// FileUtil::makePath() returns false if either the directory cannot be created
Expand All @@ -513,10 +511,9 @@ protected function createDirectoryIfNotExists($path)
}

/**
* @param string $path
* @return bool
*/
protected function makeDirectoryWritable($path)
protected function makeDirectoryWritable(string $path)
{
try {
FileUtil::makeWritable($path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private function getForm(AbstractGridView $gridView, array $values): Psr15Dialog
foreach ($gridView->getAvailableFilters() as $filter) {
$formField = $filter->getFormField();

if (isset($values[$filter->getID()])) {
$value = $filter->unserializeValue($values[$filter->getID()]);
if (isset($values[$filter->getId()])) {
$value = $filter->unserializeValue($values[$filter->getId()]);
$formField->value($value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private function getForm(AbstractListView $listView, array $values): Psr15Dialog
foreach ($listView->getAvailableFilters() as $filter) {
$formField = $filter->getFormField();

if (isset($values[$filter->getID()])) {
$value = $filter->unserializeValue($values[$filter->getID()]);
if (isset($values[$filter->getId()])) {
$value = $filter->unserializeValue($values[$filter->getId()]);
$formField->value($value);
}

Expand Down
4 changes: 1 addition & 3 deletions wcfsetup/install/files/lib/action/TAJAXException.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
use wcf\system\exception\ValidateActionException;
use wcf\util\StringUtil;

/**
* Default implementation for the AJAXException throw method.
Expand All @@ -26,13 +25,12 @@ trait TAJAXException
/**
* Throws an previously caught exception while maintaining the propriate stacktrace.
*
* @param \Exception|\Throwable $e
* @return never
* @throws AJAXException
* @throws \Exception
* @throws \Throwable
*/
protected function throwException($e)
protected function throwException(\Exception|\Throwable $e)
{
if ($e instanceof InvalidSecurityTokenException) {
throw $e;
Expand Down
Loading
Loading