From d7cc52c1826e3f09a42fc616c5c63434504e21cd Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 14 Feb 2025 22:33:06 +0100 Subject: [PATCH 01/31] Improve the typing for the util classes --- phpstan.neon | 3 +- .../DevtoolsPackageXmlWriter.class.php | 15 +- .../files/lib/util/ArrayUtil.class.php | 81 ++++----- .../install/files/lib/util/CLIUtil.class.php | 10 +- .../files/lib/util/CronjobUtil.class.php | 129 +++++-------- .../install/files/lib/util/DateUtil.class.php | 1 + .../install/files/lib/util/Diff.class.php | 17 +- .../files/lib/util/DirectoryUtil.class.php | 16 +- .../install/files/lib/util/ExifUtil.class.php | 38 ++-- .../files/lib/util/FileReader.class.php | 24 ++- .../files/lib/util/HTTPRequest.class.php | 55 +++--- .../files/lib/util/HeaderUtil.class.php | 28 +-- .../install/files/lib/util/JSON.class.php | 16 +- .../install/files/lib/util/MathUtil.class.php | 8 +- .../files/lib/util/OptionUtil.class.php | 10 +- .../files/lib/util/PasswordUtil.class.php | 73 ++++---- .../files/lib/util/StringStack.class.php | 30 ++-- .../files/lib/util/StringUtil.class.php | 169 ++++++------------ wcfsetup/install/files/lib/util/Url.class.php | 3 +- .../files/lib/util/UserAgent.class.php | 2 + .../install/files/lib/util/UserUtil.class.php | 8 +- wcfsetup/install/files/lib/util/XML.class.php | 12 +- .../files/lib/util/XMLWriter.class.php | 12 +- .../util/exception/CryptoException.class.php | 3 +- wcfsetup/install/files/proxy_sourcemap.php | 2 +- 25 files changed, 332 insertions(+), 433 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 48c845db327..8f7a3ea04e3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 5 + level: 6 paths: - wcfsetup/install/files excludePaths: @@ -12,6 +12,7 @@ parameters: - constants.php ignoreErrors: - identifier: match.unhandled + - identifier: method.unused - identifier: new.static - identifier: trait.unused universalObjectCratesClasses: diff --git a/wcfsetup/install/files/lib/system/devtools/package/DevtoolsPackageXmlWriter.class.php b/wcfsetup/install/files/lib/system/devtools/package/DevtoolsPackageXmlWriter.class.php index c3d6922d586..23690bb79ca 100644 --- a/wcfsetup/install/files/lib/system/devtools/package/DevtoolsPackageXmlWriter.class.php +++ b/wcfsetup/install/files/lib/system/devtools/package/DevtoolsPackageXmlWriter.class.php @@ -38,7 +38,7 @@ class DevtoolsPackageXmlWriter * Creates a new `DevtoolsPackageXmlWriter` object. * * @param DevtoolsProject $project - * @param array $packageXmlData + * @param mixed[][] $packageXmlData */ public function __construct(DevtoolsProject $project, array $packageXmlData) { @@ -85,6 +85,8 @@ public function write() /** * Writes the `authorinformation` element. + * + * @return void */ protected function writeAuthorInformation() { @@ -110,6 +112,8 @@ protected function writeAuthorInformation() /** * Writes the `optionalpackages` element. + * + * @return void */ protected function writeExcludedPackages() { @@ -136,6 +140,8 @@ protected function writeExcludedPackages() /** * Writes the `instructions` elements. + * + * @return void */ protected function writeInstructions() { @@ -169,6 +175,8 @@ protected function writeInstructions() /** * Writes the `optionalpackages` element. + * + * @return void */ protected function writeOptionalPackages() { @@ -193,6 +201,7 @@ protected function writeOptionalPackages() * * @param string $information * @param null|string $elementName is set to lowercase version of `$information` if missing + * @return void */ protected function writeI18nPackageInformation($information, $elementName = null) { @@ -243,6 +252,8 @@ protected function writeI18nPackageInformation($information, $elementName = null /** * Writes the `packageinformation` element. + * + * @return void */ protected function writePackageInformation() { @@ -296,6 +307,8 @@ protected function writePackageInformation() /** * Writes the `optionalpackages` element. + * + * @return void */ protected function writeRequiredPackages() { diff --git a/wcfsetup/install/files/lib/util/ArrayUtil.class.php b/wcfsetup/install/files/lib/util/ArrayUtil.class.php index c44e35924cb..8041af1ba1f 100644 --- a/wcfsetup/install/files/lib/util/ArrayUtil.class.php +++ b/wcfsetup/install/files/lib/util/ArrayUtil.class.php @@ -16,11 +16,10 @@ final class ArrayUtil /** * Applies StringUtil::trim() to all elements of the given array. * - * @param array|string $array - * @param bool $removeEmptyElements - * @return array|string + * @param string[]|string $array + * @return string[]|string */ - public static function trim($array, $removeEmptyElements = true) + public static function trim(array|string $array, bool $removeEmptyElements = true): array|string { if (!\is_array($array)) { return StringUtil::trim($array); @@ -41,10 +40,10 @@ public static function trim($array, $removeEmptyElements = true) /** * Applies intval() to all elements of the given array. * - * @param array|string $array - * @return array|int + * @param string[]|string $array + * @return int[]|int */ - public static function toIntegerArray($array) + public static function toIntegerArray(array|string $array): array|int { if (!\is_array($array)) { return \intval($array); @@ -60,10 +59,10 @@ public static function toIntegerArray($array) /** * Converts html special characters in the given array. * - * @param array|string $array - * @return array|string + * @param string[]|string $array + * @return string[]|string */ - public static function encodeHTML($array) + public static function encodeHTML(array|string $array): array|string { if (!\is_array($array)) { return StringUtil::encodeHTML($array); @@ -79,10 +78,10 @@ public static function encodeHTML($array) /** * Applies stripslashes on all elements of the given array. * - * @param array|string $array - * @return array|string + * @param string[]|string $array + * @return string[]|string */ - public static function stripslashes($array) + public static function stripslashes(array|string $array): array|string { if (!\is_array($array)) { return \stripslashes($array); @@ -98,11 +97,10 @@ public static function stripslashes($array) /** * Appends a suffix to all elements of the given array. * - * @param array $array - * @param string $suffix - * @return array + * @param string[] $array + * @return string[] */ - public static function appendSuffix($array, $suffix) + public static function appendSuffix(array $array, string $suffix): array { foreach ($array as $key => $value) { $array[$key] = $value . $suffix; @@ -114,10 +112,10 @@ public static function appendSuffix($array, $suffix) /** * Converts dos to unix newlines. * - * @param array|string $array - * @return array|string + * @param string[]|string $array + * @return string[]|string */ - public static function unifyNewlines($array) + public static function unifyNewlines(array|string $array): array|string { if (!\is_array($array)) { return StringUtil::unifyNewlines($array); @@ -132,14 +130,12 @@ public static function unifyNewlines($array) /** * Converts a array of strings to requested character encoding. - * @param string $inCharset - * @param string $outCharset - * @param array|string $array - * @return array|string - * @see mb_convert_encoding() * + * @param string[]|string $array + * @return string[]|string + * @see mb_convert_encoding() */ - public static function convertEncoding($inCharset, $outCharset, $array) + public static function convertEncoding(string $inCharset, string $outCharset, array|string $array): array|string { if (!\is_array($array)) { return StringUtil::convertEncoding($inCharset, $outCharset, $array); @@ -155,12 +151,10 @@ public static function convertEncoding($inCharset, $outCharset, $array) /** * Returns true when array1 has the same values as array2. * - * @param array $array1 - * @param array $array2 - * @param callable $callback - * @return bool + * @param mixed[] $array1 + * @param mixed[] $array2 */ - public static function compare(array $array1, array $array2, ?callable $callback = null) + public static function compare(array $array1, array $array2, ?callable $callback = null): bool { return static::compareHelper('value', $array1, $array2, $callback); } @@ -168,12 +162,10 @@ public static function compare(array $array1, array $array2, ?callable $callback /** * Returns true when array1 has the same keys as array2. * - * @param array $array1 - * @param array $array2 - * @param callable $callback - * @return bool + * @param mixed[] $array1 + * @param mixed[] $array2 */ - public static function compareKey(array $array1, array $array2, ?callable $callback = null) + public static function compareKey(array $array1, array $array2, ?callable $callback = null): bool { return static::compareHelper('key', $array1, $array2, $callback); } @@ -181,12 +173,10 @@ public static function compareKey(array $array1, array $array2, ?callable $callb /** * Compares array1 with array2 and returns true when they are identical. * - * @param array $array1 - * @param array $array2 - * @param callable $callback - * @return bool + * @param mixed[] $array1 + * @param mixed[] $array2 */ - public static function compareAssoc(array $array1, array $array2, ?callable $callback = null) + public static function compareAssoc(array $array1, array $array2, ?callable $callback = null): bool { return static::compareHelper('assoc', $array1, $array2, $callback); } @@ -194,14 +184,11 @@ public static function compareAssoc(array $array1, array $array2, ?callable $cal /** * Does the actual comparison of the above compare methods. * - * @param string $method - * @param array $array1 - * @param array $array2 - * @param callable $callback - * @return bool + * @param mixed[] $array1 + * @param mixed[] $array2 * @throws SystemException */ - protected static function compareHelper($method, array $array1, array $array2, ?callable $callback = null) + protected static function compareHelper(string $method, array $array1, array $array2, ?callable $callback = null): bool { // get function name $function = null; diff --git a/wcfsetup/install/files/lib/util/CLIUtil.class.php b/wcfsetup/install/files/lib/util/CLIUtil.class.php index 56b37142401..98d5c5987ca 100644 --- a/wcfsetup/install/files/lib/util/CLIUtil.class.php +++ b/wcfsetup/install/files/lib/util/CLIUtil.class.php @@ -17,10 +17,9 @@ final class CLIUtil /** * Generates a table. * - * @param array $table - * @return string + * @param string[][] $table */ - public static function generateTable(array $table) + public static function generateTable(array $table): string { $columnSize = []; foreach ($table as $row) { @@ -68,10 +67,9 @@ public static function generateTable(array $table) /** * Generates a list. * - * @param array $list - * @return string + * @param string[] $list */ - public static function generateList(array $list) + public static function generateList(array $list): string { $result = ''; foreach ($list as $row) { diff --git a/wcfsetup/install/files/lib/util/CronjobUtil.class.php b/wcfsetup/install/files/lib/util/CronjobUtil.class.php index a9b82f1438c..05e23cb7c2d 100644 --- a/wcfsetup/install/files/lib/util/CronjobUtil.class.php +++ b/wcfsetup/install/files/lib/util/CronjobUtil.class.php @@ -11,34 +11,31 @@ final class CronjobUtil { /** * indicates if day of month is restricted (not '*') - * @var bool */ - protected static $domRestricted = false; + private static bool $domRestricted = false; /** * indicates if day of week is restricted (not '*') - * @var bool */ - protected static $dowRestricted = false; + private static bool $dowRestricted = false; /** * result date * @var int[] */ - protected static $result = []; + private static array $result = []; /** * time base used as reference for finding the next execution time - * @var int */ - protected static $timeBase = 0; + private static int $timeBase = 0; /** * valid ranges for each known field (range for 'day of month' is missing * since it varies from month to month) * @var array */ - public static $ranges = [ + public static array $ranges = [ 'minute' => [0, 59], 'hour' => [0, 23], 'dom' => [1, 31], @@ -48,17 +45,15 @@ final class CronjobUtil /** * Calculates timestamp for next execution based on cron-like expressions and a given time base. - * - * @param string $minute - * @param string $hour - * @param string $dom - * @param string $month - * @param string $dow - * @param int $timeBase - * @return int */ - public static function calculateNextExec($minute, $hour, $dom, $month, $dow, $timeBase = TIME_NOW) - { + public static function calculateNextExec( + string $minute, + string $hour, + string $dom, + string $month, + string $dow, + int $timeBase = TIME_NOW + ): int { // using the native `date()` and `mktime()` functions is dangerous // unless we explicitly set the correct timezone $originalTimezone = \date_default_timezone_get(); @@ -146,9 +141,9 @@ public static function calculateNextExec($minute, $hour, $dom, $month, $dow, $ti /** * Calculates the date of next execution. * - * @param array $values + * @param mixed[] $values */ - protected static function calculateTime(array &$values) + private static function calculateTime(array &$values): void { self::calculateDay($values); } @@ -156,12 +151,10 @@ protected static function calculateTime(array &$values) /** * Calculates the next month and year to match given criteria. * - * @param int $month - * @param int $year - * @param array $values - * @return array + * @param mixed[] $values + * @return int[] */ - protected static function calculateMonth($month, $year, array &$values) + private static function calculateMonth(int $month, int $year, array &$values): array { $index = self::findKey($month, $values['month']); @@ -183,10 +176,10 @@ protected static function calculateMonth($month, $year, array &$values) * of month, and day of week. If both fields are restricted , that is not '*', the * command will be run when either field matches the current time. -- crontab(5) * - * @param array $values + * @param mixed[] $values * @see \wcf\util\CronjobUtil::getDom() */ - protected static function calculateDay(array &$values) + private static function calculateDay(array &$values): void { $addAnDay = self::calculateHour($values, self::$timeBase); $timeBase = self::$timeBase; @@ -262,13 +255,10 @@ protected static function calculateDay(array &$values) /** * Calculates the date of next execution based upon a given set for day of week. * - * @param int $month - * @param int $year - * @param array $values - * @param int $day - * @return array + * @param mixed[] $values + * @return int[] */ - protected static function calculateDow($month, $year, array &$values, $day = 1) + private static function calculateDow(int $month, int $year, array &$values, int $day = 1): array { $days = \date('t', \mktime(0, 0, 1, $month, $day, $year)); @@ -294,13 +284,10 @@ protected static function calculateDow($month, $year, array &$values, $day = 1) /** * Calculates the date of next execution based upon a given set for day of month. * - * @param int $month - * @param int $year - * @param array $values - * @param int $day - * @return array + * @param mixed[] $values + * @return int[] */ - protected static function calculateDom($month, $year, array &$values, $day = 1) + private static function calculateDom(int $month, int $year, array &$values, int $day = 1): array { $days = \date('t', \mktime(0, 0, 1, $month, $day, $year)); @@ -324,11 +311,9 @@ protected static function calculateDom($month, $year, array &$values, $day = 1) * Calculates hour of next execution. Returns true if hour-declaration * has already elapsed, thus requiring at least one day to be added. * - * @param array $values - * @param int $timeBase - * @return bool + * @param mixed[] $values */ - protected static function calculateHour(array &$values, &$timeBase) + private static function calculateHour(array &$values, int &$timeBase): bool { $addAnDay = false; @@ -367,12 +352,9 @@ protected static function calculateHour(array &$values, &$timeBase) * Calculates minutes of next execution. Returns true if minute-declaration * has already elapsed, thus requiring at least one hour to be added. * - * @param array $values - * @param int $timeBase - * @param bool $addAnDay - * @return bool + * @param mixed[] $values */ - protected static function calculateMinute(array &$values, &$timeBase, $addAnDay) + private static function calculateMinute(array &$values, int &$timeBase, bool $addAnDay): bool { $addAnHour = false; @@ -401,12 +383,9 @@ protected static function calculateMinute(array &$values, &$timeBase, $addAnDay) * needle. If $continue is not set to false and foreach-loop is out of bounds, * then the array-index '0' is returned, referring the first item. * - * @param int $needle - * @param array $haystack - * @param bool $continue - * @return mixed + * @param mixed[] $haystack */ - protected static function findKey($needle, array &$haystack, $continue = true) + private static function findKey(int $needle, array &$haystack, bool $continue = true): int|string|bool { $index = \array_search($needle, $haystack); @@ -429,11 +408,9 @@ protected static function findKey($needle, array &$haystack, $continue = true) /** * Calculates all values matching possible expressions. * - * @param string $fieldName - * @param string $fieldValue - * @return array + * @return int[] */ - protected static function calculateValue($fieldName, $fieldValue) + private static function calculateValue(string $fieldName, string $fieldValue): array { $values = []; @@ -467,10 +444,9 @@ protected static function calculateValue($fieldName, $fieldValue) /** * Tries to parse list items separated by a comma. * - * @param string $fieldValue - * @return array + * @return list */ - protected static function getListItems($fieldValue) + private static function getListItems(string $fieldValue): array { if (\str_contains($fieldValue, ',')) { return \explode(',', $fieldValue); @@ -482,14 +458,13 @@ protected static function getListItems($fieldValue) /** * Parses a possible range of values including a step value. * - * @param string $value - * @return array + * @return list */ - protected static function getRanges($value) + private static function getRanges(string $value): array { // this is a single value if (!\str_contains($value, '-')) { - return [$value]; + return [(int)$value]; } $step = 1; @@ -507,12 +482,9 @@ protected static function getRanges($value) /** * Calculates all values for a given range. * - * @param int $startValue - * @param int $endValue - * @param int $step - * @return array + * @return list */ - protected static function calculateRange($startValue, $endValue, $step = 1) + private static function calculateRange(int $startValue, int $endValue, int $step = 1): array { $values = []; @@ -525,15 +497,14 @@ protected static function calculateRange($startValue, $endValue, $step = 1) /** * Validates all cronjob attributes. - * - * @param string $startMinute - * @param string $startHour - * @param string $startDom - * @param string $startMonth - * @param string $startDow */ - public static function validate($startMinute, $startHour, $startDom, $startMonth, $startDow) - { + public static function validate( + string $startMinute, + string $startHour, + string $startDom, + string $startMonth, + string $startDow + ): void { self::validateAttribute('startMinute', $startMinute); self::validateAttribute('startHour', $startHour); self::validateAttribute('startDom', $startDom); @@ -544,11 +515,9 @@ public static function validate($startMinute, $startHour, $startDom, $startMonth /** * Validates a cronjob attribute. * - * @param string $name - * @param string $value * @throws SystemException */ - public static function validateAttribute($name, $value) + public static function validateAttribute(string $name, string $value): void { if ($value === '') { throw new SystemException("invalid value '" . $value . "' given for cronjob attribute '" . $name . "'"); diff --git a/wcfsetup/install/files/lib/util/DateUtil.class.php b/wcfsetup/install/files/lib/util/DateUtil.class.php index 23146db385a..0deb6cd2aec 100644 --- a/wcfsetup/install/files/lib/util/DateUtil.class.php +++ b/wcfsetup/install/files/lib/util/DateUtil.class.php @@ -473,6 +473,7 @@ public static function getAge($date) * Validates if given date is valid ISO-8601. * * @param string $date + * @return void * @throws SystemException */ public static function validateDate($date) diff --git a/wcfsetup/install/files/lib/util/Diff.class.php b/wcfsetup/install/files/lib/util/Diff.class.php index 4ef06eb07aa..c7988a7cc24 100644 --- a/wcfsetup/install/files/lib/util/Diff.class.php +++ b/wcfsetup/install/files/lib/util/Diff.class.php @@ -36,13 +36,13 @@ class Diff /** * original array, as given by the user - * @var array + * @var list */ protected $a = []; /** * modified array, as given by the user - * @var array + * @var list */ protected $b = []; @@ -60,12 +60,15 @@ class Diff /** * calculated diff - * @var array + * @var ?list */ protected $d; /** * @deprecated 6.0 Use sebastian/diff instead. + * + * @param list $a + * @param list $b */ public function __construct(array $a, array $b) { @@ -77,6 +80,7 @@ public function __construct(array $a, array $b) } /** + * @return \SplFixedArray * @deprecated 6.0 Use sebastian/diff instead. */ public function getLCS() @@ -192,6 +196,8 @@ public function getLCS() /** * Builds the diff out of the longest common subsequence of `$this->a` * and `$this->b` and saves it in `$this->d`. + * + * @return void */ protected function calculateDiff() { @@ -230,6 +236,7 @@ protected function calculateDiff() } /** + * @return list * @deprecated 6.0 Use sebastian/diff instead. */ public function getRawDiff() @@ -240,6 +247,8 @@ public function getRawDiff() } /** + * @param int $context + * @return string * @deprecated 6.0 Use sebastian/diff instead. */ public function getUnixDiff($context = 2) @@ -328,6 +337,8 @@ public function getUnixDiff($context = 2) * Transforms the output of sebastian/diff's Differ::diffToArray() into * the output of self::getRawDiff(). * + * @param list $arrayDiff + * @return list * @since 6.0 */ public static function rawDiffFromSebastianDiff(array $arrayDiff): array diff --git a/wcfsetup/install/files/lib/util/DirectoryUtil.class.php b/wcfsetup/install/files/lib/util/DirectoryUtil.class.php index 2fa2e6e85fa..cc8fa83bc17 100644 --- a/wcfsetup/install/files/lib/util/DirectoryUtil.class.php +++ b/wcfsetup/install/files/lib/util/DirectoryUtil.class.php @@ -195,7 +195,7 @@ public function getFileObjects($order = \SORT_ASC, ?Regex $pattern = null, $nega /** * Fills the list of available files */ - protected function scanFiles() + protected function scanFiles(): void { // value is cached if (!empty($this->files)) { @@ -232,7 +232,7 @@ protected function scanFiles() /** * Fills the list of available files, with DirectoryIterator object as value */ - protected function scanFileObjects() + protected function scanFileObjects(): void { // value is cached if (!empty($this->fileObjects)) { @@ -271,9 +271,8 @@ protected function scanFileObjects() * * @param callable $callback * @param Regex $pattern callback is only applied to files matching the given pattern - * @return bool */ - public function executeCallback(callable $callback, ?Regex $pattern = null) + public function executeCallback(callable $callback, ?Regex $pattern = null): bool { if ($pattern !== null) { $files = $this->getFileObjects(self::SORT_NONE, $pattern); @@ -291,7 +290,7 @@ public function executeCallback(callable $callback, ?Regex $pattern = null) /** * Recursive remove of directory. */ - public function removeAll() + public function removeAll(): void { $this->removePattern(new Regex('.')); @@ -306,7 +305,7 @@ public function removeAll() * @param bool $negativeMatch should the pattern be inversed * @throws SystemException */ - public function removePattern(Regex $pattern, $negativeMatch = false) + public function removePattern(Regex $pattern, $negativeMatch = false): void { if (!$this->recursive) { throw new SystemException('Removing of files only works in recursive mode'); @@ -332,10 +331,9 @@ public function removePattern(Regex $pattern, $negativeMatch = false) /** * Calculates the size of the directory. * - * @return int directory size in bytes * @throws SystemException */ - public function getSize() + public function getSize(): int { if (!$this->recursive) { throw new SystemException('Calculating of size only works in recursive mode'); @@ -357,7 +355,7 @@ public function getSize() /** * Clears the caches of the current instance */ - public function clearCaches() + public function clearCaches(): void { // clear cached list of files $this->files = []; diff --git a/wcfsetup/install/files/lib/util/ExifUtil.class.php b/wcfsetup/install/files/lib/util/ExifUtil.class.php index 99516e50c5a..a454323e32e 100644 --- a/wcfsetup/install/files/lib/util/ExifUtil.class.php +++ b/wcfsetup/install/files/lib/util/ExifUtil.class.php @@ -79,10 +79,9 @@ private function __construct() * Returns the exif data of the image at the given location or an empty * array if the exif data can't be read. * - * @param string $filename - * @return array + * @return mixed[] */ - public static function getExifData($filename) + public static function getExifData(string $filename): array { if (\function_exists('exif_read_data')) { $exifData = @\exif_read_data($filename, '', true); @@ -97,10 +96,9 @@ public static function getExifData($filename) /** * Returns the name of the used camera based on the given exif data. * - * @param array $exifData - * @return string + * @param mixed[] $exifData */ - public static function getCamera(array $exifData) + public static function getCamera(array $exifData): string { $camera = ''; if (isset($exifData['IFD0'])) { @@ -123,10 +121,9 @@ public static function getCamera(array $exifData) /** * Returns the creation timestamp based on the given exif data. * - * @param array $exifData - * @return int + * @param mixed[] $exifData */ - public static function getCreationTime(array $exifData) + public static function getCreationTime(array $exifData): int { $creationTime = 0; if (isset($exifData['EXIF'])) { @@ -149,10 +146,9 @@ public static function getCreationTime(array $exifData) * Returns the longitude of the place the image with the given exif data * was taken. * - * @param array $exifData - * @return float + * @param mixed[] $exifData */ - public static function getLongitude(array $exifData) + public static function getLongitude(array $exifData): float { $longitude = 0; if (isset($exifData['GPS']) && isset($exifData['GPS']['GPSLongitudeRef']) && isset($exifData['GPS']['GPSLongitude'])) { @@ -176,10 +172,9 @@ public static function getLongitude(array $exifData) * Returns the latitude of the place the image with the given exif data * was taken. * - * @param array $exifData - * @return float + * @param mixed[] $exifData */ - public static function getLatitude(array $exifData) + public static function getLatitude(array $exifData): int|float { $latitude = 0; if (isset($exifData['GPS']) && isset($exifData['GPS']['GPSLatitudeRef']) && isset($exifData['GPS']['GPSLatitude'])) { @@ -202,10 +197,10 @@ public static function getLatitude(array $exifData) /** * Returns the formats exif data. * - * @param array $rawExifData - * @return array + * @param mixed[] $rawExifData + * @return array */ - public static function getFormattedExifData(array $rawExifData) + public static function getFormattedExifData(array $rawExifData): array { $exifData = []; @@ -236,10 +231,9 @@ public static function getFormattedExifData(array $rawExifData) /** * Returns the orientation of the image based on the given exif data. * - * @param array $exifData - * @return int + * @param mixed[] $exifData */ - public static function getOrientation(array $exifData) + public static function getOrientation(array $exifData): int { $orientation = self::ORIENTATION_ORIGINAL; if (isset($exifData['IFD0']['Orientation'])) { @@ -312,7 +306,7 @@ private static function simplifyRational(string $rational): string /** * Implements the Euclidian Algorithm to calculate the GCD. */ - private static function gcd(int $a, int $b) + private static function gcd(int $a, int $b): int { while ($b != 0) { $t = $b; diff --git a/wcfsetup/install/files/lib/util/FileReader.class.php b/wcfsetup/install/files/lib/util/FileReader.class.php index 0a1a260bf57..47515cd09fd 100644 --- a/wcfsetup/install/files/lib/util/FileReader.class.php +++ b/wcfsetup/install/files/lib/util/FileReader.class.php @@ -24,7 +24,7 @@ class FileReader /** * http options - * @var array + * @var array */ protected $options = [ 'filename' => '', @@ -39,7 +39,7 @@ class FileReader /** * list of header items - * @var array + * @var string[] */ protected $headers = []; @@ -65,7 +65,7 @@ class FileReader * Creates a new instance of the HTTPFileReader class. * * @param string $location - * @param array $options + * @param array $options * @throws SystemException */ public function __construct($location, array $options) @@ -83,6 +83,8 @@ public function __construct($location, array $options) /** * Sends the file to the client. + * + * @return void */ public function send() { @@ -109,6 +111,8 @@ public function send() /** * Handles the given range options. + * + * @return void */ protected function handleRange() { @@ -144,6 +148,8 @@ protected function handleRange() /** * Handles the given header items. + * + * @return void */ protected function handleHeaders() { @@ -215,6 +221,9 @@ protected function getAsciiFilename(string $filename): string /** * @deprecated 6.0 This method is unused internally. Use `wcf\http\ContentDisposition` instead. + * + * @param string $filename + * @return string */ protected function sanitizeFilename($filename) { @@ -223,6 +232,8 @@ protected function sanitizeFilename($filename) /** * Sends the headers of the file to the client. + * + * @return void */ protected function sendHeaders() { @@ -237,6 +248,8 @@ protected function sendHeaders() /** * Sends the actual file to the client. + * + * @return void */ protected function sendFile() { @@ -263,7 +276,8 @@ protected function sendFile() /** * Sets the options for the http response. * - * @param array $options + * @param array $options + * @return void */ public function setOptions(array $options) { @@ -279,6 +293,7 @@ public function setOptions(array $options) * * @param string $name * @param string $value + * @return void */ public function addHeader($name, $value) { @@ -289,6 +304,7 @@ public function addHeader($name, $value) * Removes the header with the given name. * * @param string $name + * @return void */ public function removeHeader($name) { diff --git a/wcfsetup/install/files/lib/util/HTTPRequest.class.php b/wcfsetup/install/files/lib/util/HTTPRequest.class.php index b5196dc6afb..b8a0d8aca1d 100644 --- a/wcfsetup/install/files/lib/util/HTTPRequest.class.php +++ b/wcfsetup/install/files/lib/util/HTTPRequest.class.php @@ -32,60 +32,53 @@ final class HTTPRequest { /** * given options - * @var array + * @var mixed[] */ - private $options = []; + private array $options = []; /** * given post parameters - * @var array + * @var mixed[] */ - private $postParameters = []; + private array $postParameters = []; /** * given files - * @var array + * @var mixed[] */ - private $files = []; + private array $files = []; /** * request URL - * @var string */ - private $url = ''; + private string $url = ''; /** * request headers * @var string[][] */ - private $headers = []; + private array $headers = []; /** * request body - * @var string */ - private $body = ''; + private string $body = ''; /** * reply body - * @var string */ - private $replyBody; + private ?string $replyBody = null; - /** - * @var ?ResponseInterface - */ - private $response; + private ?ResponseInterface $response = null; /** * Constructs a new instance of HTTPRequest. * - * @param string $url URL to connect to - * @param array $options - * @param mixed $postParameters Parameters to send via POST - * @param array $files Files to attach to the request + * @param mixed[] $options + * @param mixed[] $postParameters Parameters to send via POST + * @param mixed[] $files Files to attach to the request */ - public function __construct($url, array $options = [], $postParameters = [], array $files = []) + public function __construct(string $url, array $options = [], array|string $postParameters = [], array $files = []) { $this->url = $url; @@ -112,7 +105,7 @@ public function __construct($url, array $options = [], $postParameters = [], arr if (empty($this->files)) { if (\is_array($postParameters)) { $this->body = \http_build_query($this->postParameters, '', '&'); - } elseif (\is_string($postParameters) && !empty($postParameters)) { + } elseif (\is_string($postParameters) && !empty($postParameters)) { // @phpstan-ignore function.alreadyNarrowedType $this->body = $postParameters; } @@ -178,7 +171,7 @@ public function __construct($url, array $options = [], $postParameters = [], arr /** * Executes the HTTP request. */ - public function execute() + public function execute(): void { $redirectHandler = function (RequestInterface $request, ResponseInterface $response, UriInterface $uri) { $this->url = (string)$uri; @@ -282,9 +275,9 @@ public function execute() * Returns an array with the replied data. * Note that the 'headers' element is deprecated and may be removed in the future. * - * @return array + * @return array{statusCode: int|string, headers: string[]|string[][], httpHeaders: string[]|string[][], body: string, url: string} */ - public function getReply() + public function getReply(): array { if (!$this->response) { return [ @@ -342,10 +335,10 @@ public function getReply() /** * Sets options and applies default values when an option is omitted. * - * @param array $options + * @param mixed[] $options * @throws \InvalidArgumentException */ - private function setOptions(array $options) + private function setOptions(array $options): void { if (!isset($options['timeout'])) { $options['timeout'] = 10; @@ -375,12 +368,8 @@ private function setOptions(array $options) * Adds a header to this request. * When an empty value is given existing headers of this name will be removed. When append * is set to false existing values will be overwritten. - * - * @param string $name - * @param string $value - * @param bool $append */ - public function addHeader($name, $value, $append = false) + public function addHeader(string $name, string $value, bool $append = false): void { // 4.2 Field names are case-insensitive. $name = \strtolower($name); diff --git a/wcfsetup/install/files/lib/util/HeaderUtil.class.php b/wcfsetup/install/files/lib/util/HeaderUtil.class.php index 402e7c49543..0ba840d70b5 100644 --- a/wcfsetup/install/files/lib/util/HeaderUtil.class.php +++ b/wcfsetup/install/files/lib/util/HeaderUtil.class.php @@ -28,18 +28,13 @@ final class HeaderUtil /** * output HTML - * @var string */ - public static $output = ''; + public static string $output = ''; /** * Alias to php setcookie() function. - * - * @param string $name - * @param string $value - * @param int $expire */ - public static function setCookie($name, $value = '', $expire = 0) + public static function setCookie(string $name, string $value = '', int $expire = 0): void { $cookieDomain = self::getCookieDomain(); @@ -81,7 +76,7 @@ public static function getCookieDomain(): ?string /** * Sends the headers of a page. */ - public static function sendHeaders() + public static function sendHeaders(): void { // send content type @\header('Content-Type: text/html; charset=UTF-8'); @@ -97,7 +92,7 @@ public static function sendHeaders() /** * Sends no cache headers. */ - public static function sendNoCacheHeaders() + public static function sendNoCacheHeaders(): void { @\header('Last-Modified: ' . \gmdate('D, d M Y H:i:s') . ' GMT'); @\header('Cache-Control: max-age=0, no-cache, no-store, must-revalidate'); @@ -130,17 +125,12 @@ public static function withNoCacheHeaders(ResponseInterface $response): Response /** * @deprecated 5.4 - This method is a no-op, as gzip support was removed. */ - public static function exceptionDisableGzip() - { - } + public static function exceptionDisableGzip(): void {} /** * Parses the rendered output. - * - * @param string $output - * @return string */ - public static function parseOutput($output) + public static function parseOutput(string $output): string { self::$output = $output; @@ -235,12 +225,8 @@ public static function parseOutputStream(StreamInterface $input): StreamInterfac /** * Redirects the user agent to given location. - * - * @param string $location - * @param bool $sendStatusCode - * @param bool $temporaryRedirect */ - public static function redirect($location, $sendStatusCode = false, $temporaryRedirect = true) + public static function redirect(string $location, bool $sendStatusCode = false, bool $temporaryRedirect = true): void { // https://github.com/WoltLab/WCF/issues/2568 if (SessionHandler::getInstance()->isFirstVisit()) { diff --git a/wcfsetup/install/files/lib/util/JSON.class.php b/wcfsetup/install/files/lib/util/JSON.class.php index 78b09e1dd28..8da42a3abd8 100644 --- a/wcfsetup/install/files/lib/util/JSON.class.php +++ b/wcfsetup/install/files/lib/util/JSON.class.php @@ -15,12 +15,8 @@ final class JSON { /** * Returns the JSON representation of a value. - * - * @param mixed $data - * @param int $options - * @return string */ - public static function encode($data, $options = 0) + public static function encode(mixed $data, int $options = 0): string { return \json_encode($data, $options); } @@ -28,12 +24,10 @@ public static function encode($data, $options = 0) /** * Decodes a JSON string. * - * @param string $json - * @param bool $asArray - * @return array + * @return mixed[] * @throws SystemException */ - public static function decode($json, $asArray = true) + public static function decode(string $json, bool $asArray = true): array { $data = @\json_decode($json, $asArray); @@ -50,10 +44,8 @@ public static function decode($json, $asArray = true) /** * Returns the last error occurred. - * - * @return int */ - public static function getLastError() + public static function getLastError(): int { return \json_last_error(); } diff --git a/wcfsetup/install/files/lib/util/MathUtil.class.php b/wcfsetup/install/files/lib/util/MathUtil.class.php index 78bf9bc7f2c..4f06c5c7b97 100644 --- a/wcfsetup/install/files/lib/util/MathUtil.class.php +++ b/wcfsetup/install/files/lib/util/MathUtil.class.php @@ -14,7 +14,7 @@ final class MathUtil /** * @deprecated 5.5 - Use `\random_int()` or `\mt_rand()` directly. */ - public static function getRandomValue($min = null, $max = null) + public static function getRandomValue(?int $min = null, ?int $max = null): int { // generate random value return ($min !== null && $max !== null) ? \mt_rand($min, $max) : \mt_rand(); @@ -24,11 +24,9 @@ public static function getRandomValue($min = null, $max = null) * Transforms the given latitude and longitude into cartesian coordinates * (x, y, z). * - * @param float $latitude - * @param float $longitude - * @return float[] + * @return array{0: float, 1: float, 2: float} */ - public static function latitudeLongitudeToCartesian($latitude, $longitude) + public static function latitudeLongitudeToCartesian(float $latitude, float $longitude): array { $lambda = $longitude * \M_PI / 180; $phi = $latitude * \M_PI / 180; diff --git a/wcfsetup/install/files/lib/util/OptionUtil.class.php b/wcfsetup/install/files/lib/util/OptionUtil.class.php index a9d5c49966a..1eea56a2f12 100644 --- a/wcfsetup/install/files/lib/util/OptionUtil.class.php +++ b/wcfsetup/install/files/lib/util/OptionUtil.class.php @@ -14,10 +14,9 @@ final class OptionUtil /** * Returns a list of the available options. * - * @param string $selectOptions - * @return array + * @return array */ - public static function parseSelectOptions($selectOptions) + public static function parseSelectOptions(string $selectOptions): array { $result = []; $options = \explode("\n", StringUtil::trim(StringUtil::unifyNewlines($selectOptions))); @@ -38,10 +37,9 @@ public static function parseSelectOptions($selectOptions) /** * Returns a list of the enable options. * - * @param string $enableOptions - * @return array + * @return array */ - public static function parseMultipleEnableOptions($enableOptions) + public static function parseMultipleEnableOptions(string $enableOptions): array { $result = []; if (!empty($enableOptions)) { diff --git a/wcfsetup/install/files/lib/util/PasswordUtil.class.php b/wcfsetup/install/files/lib/util/PasswordUtil.class.php index 606edf363c6..0486d97e82c 100644 --- a/wcfsetup/install/files/lib/util/PasswordUtil.class.php +++ b/wcfsetup/install/files/lib/util/PasswordUtil.class.php @@ -18,12 +18,13 @@ final class PasswordUtil /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - private static $blowfishCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; + private static string $blowfishCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; /** * @deprecated 5.5 - After the removal of other deprecated methods this would effectively be empty. + * @var string[] */ - private static $supportedEncryptionTypes = [ + private static array $supportedEncryptionTypes = [ 'argon2', // vBulletin 5.x 'ipb2', // Invision Power Board 2.x 'ipb3', // Invision Power Board 3.x @@ -61,7 +62,7 @@ final class PasswordUtil /** * @deprecated 5.5 - After the removal of other deprecated methods this would effectively always return false. */ - public static function isSupported($type) + public static function isSupported(string $type): bool { if (\in_array($type, self::$supportedEncryptionTypes)) { return true; @@ -77,7 +78,7 @@ public static function isSupported($type) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - public static function isBlowfish($hash) + public static function isBlowfish(string $hash): bool { return Regex::compile('^\$2[afxy]\$')->match($hash) ? true : false; } @@ -85,7 +86,7 @@ public static function isBlowfish($hash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - public static function isDifferentBlowfish($hash) + public static function isDifferentBlowfish(string $hash): bool { $currentCost = \intval(self::BCRYPT_COST); $hashCost = \intval(\substr($hash, 4, 2)); @@ -100,7 +101,7 @@ public static function isDifferentBlowfish($hash) /** * @deprecated 5.5 - After the removal of other deprecated methods this would effectively always return false. */ - public static function checkPassword($username, $password, $dbHash) + public static function checkPassword(string $username, string $password, string $dbHash): bool { $type = self::detectEncryption($dbHash); if ($type === 'unknown') { @@ -131,7 +132,7 @@ public static function checkPassword($username, $password, $dbHash) /** * @deprecated 5.5 - After the removal of other deprecated methods this would effectively always return 'unknown'. */ - public static function detectEncryption($hash) + public static function detectEncryption(string $hash): string { if (($pos = \strpos($hash, ':')) !== false) { $type = \substr($hash, 0, $pos); @@ -146,7 +147,7 @@ public static function detectEncryption($hash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - public static function getDoubleSaltedHash($password, $salt = null) + public static function getDoubleSaltedHash(string $password, ?string $salt = null): string { if ($salt === null) { $salt = self::getRandomSalt(); @@ -158,7 +159,7 @@ public static function getDoubleSaltedHash($password, $salt = null) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - public static function getSaltedHash($password, $salt = null) + public static function getSaltedHash(string $password, ?string $salt = null): string { if ($salt === null) { $salt = self::getRandomSalt(); @@ -170,7 +171,7 @@ public static function getSaltedHash($password, $salt = null) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - public static function getRandomSalt() + public static function getRandomSalt(): string { $salt = ''; @@ -184,7 +185,7 @@ public static function getRandomSalt() /** * @deprecated 5.5 - Use some constant time encoder (e.g. Hex, Base32, or Base64) on the result of `\random_bytes()`. */ - public static function getRandomPassword($length = 12) + public static function getRandomPassword(int $length = 12): string { $charset = self::PASSWORD_CHARSET; $password = ''; @@ -199,7 +200,7 @@ public static function getRandomPassword($length = 12) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function getSalt($salt) + private static function getSalt(string $salt): string { $salt = \mb_substr($salt, 0, 22); @@ -209,7 +210,7 @@ protected static function getSalt($salt) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function argon2($username, $password, $salt, $dbHash) + private static function argon2(string $username, string $password, string $salt, string $dbHash): bool { return \password_verify($password, $dbHash); } @@ -217,7 +218,7 @@ protected static function argon2($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function ipb2($username, $password, $salt, $dbHash) + private static function ipb2(string $username, string $password, string $salt, string $dbHash): bool { return self::vb3($username, $password, $salt, $dbHash); } @@ -225,7 +226,7 @@ protected static function ipb2($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function ipb3($username, $password, $salt, $dbHash) + private static function ipb3(string $username, string $password, string $salt, string $dbHash): bool { return \hash_equals($dbHash, \md5(\md5($salt) . \md5($password))); } @@ -233,7 +234,7 @@ protected static function ipb3($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function mybb1($username, $password, $salt, $dbHash) + private static function mybb1(string $username, string $password, string $salt, string $dbHash): bool { return \hash_equals($dbHash, \md5(\md5($salt) . \md5($password))); } @@ -241,7 +242,7 @@ protected static function mybb1($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - public static function phpbb3($username, $password, $salt, $dbHash) + public static function phpbb3(string $username, string $password, string $salt, string $dbHash): bool { $phpassResult = self::phpass($username, $password, $salt, $dbHash); @@ -285,7 +286,7 @@ public static function phpbb3($username, $password, $salt, $dbHash) return \hash_equals($dbHash, $password); } - private static function phpassHashCryptPrivate($password, $setting) + private static function phpassHashCryptPrivate(string $password, string $setting): string { static $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; @@ -357,7 +358,7 @@ private static function phpassHashCryptPrivate($password, $setting) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function phpass($username, $password, $salt, $dbHash) + private static function phpass(string $username, string $password, string $salt, string $dbHash): bool { if (\mb_strlen($dbHash) !== 34) { return \hash_equals(\md5($password), $dbHash); @@ -369,7 +370,7 @@ protected static function phpass($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function smf1($username, $password, $salt, $dbHash) + private static function smf1(string $username, string $password, string $salt, string $dbHash): bool { return \hash_equals($dbHash, \sha1(\mb_strtolower($username) . $password)); } @@ -377,7 +378,7 @@ protected static function smf1($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function smf2($username, $password, $salt, $dbHash) + private static function smf2(string $username, string $password, string $salt, string $dbHash): bool { return self::smf1($username, $password, $salt, $dbHash); } @@ -385,7 +386,7 @@ protected static function smf2($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function vb3($username, $password, $salt, $dbHash) + private static function vb3(string $username, string $password, string $salt, string $dbHash): bool { return \hash_equals($dbHash, \md5(\md5($password) . $salt)); } @@ -393,7 +394,7 @@ protected static function vb3($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function vb4($username, $password, $salt, $dbHash) + private static function vb4(string $username, string $password, string $salt, string $dbHash): bool { return self::vb3($username, $password, $salt, $dbHash); } @@ -401,7 +402,7 @@ protected static function vb4($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function vb5($username, $password, $salt, $dbHash) + private static function vb5(string $username, string $password, string $salt, string $dbHash): bool { return self::vb3($username, $password, $salt, $dbHash); } @@ -409,7 +410,7 @@ protected static function vb5($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function wbb2($username, $password, $salt, $dbHash) + private static function wbb2(string $username, string $password, string $salt, string $dbHash): bool { if (\hash_equals($dbHash, \md5($password))) { return true; @@ -423,7 +424,7 @@ protected static function wbb2($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function wcf1($username, $password, $salt, $dbHash) + private static function wcf1(string $username, string $password, string $salt, string $dbHash): bool { return \hash_equals($dbHash, \sha1($salt . \sha1($salt . \sha1($password)))); } @@ -431,7 +432,7 @@ protected static function wcf1($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function wcf1e($type, $password, $salt, $dbHash) + private static function wcf1e(string $type, string $password, string $salt, string $dbHash): bool { \preg_match('~^wcf1e([cms])([01])([ab])([01])$~', $type, $matches); $enableSalting = $matches[2]; @@ -481,7 +482,7 @@ protected static function wcf1e($type, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function wcf2($username, $password, $salt, $dbHash) + private static function wcf2(string $username, string $password, string $salt, string $dbHash): bool { return \hash_equals($dbHash, self::getDoubleSaltedHash($password, $dbHash)); } @@ -489,7 +490,7 @@ protected static function wcf2($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function xf1($username, $password, $salt, $dbHash) + private static function xf1(string $username, string $password, string $salt, string $dbHash): bool { if (\hash_equals($dbHash, \sha1(\sha1($password) . $salt))) { return true; @@ -501,7 +502,7 @@ protected static function xf1($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function xf12($username, $password, $salt, $dbHash) + private static function xf12(string $username, string $password, string $salt, string $dbHash): bool { if (\hash_equals($dbHash, self::getSaltedHash($password, $dbHash))) { return true; @@ -513,7 +514,7 @@ protected static function xf12($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function joomla1($username, $password, $salt, $dbHash) + private static function joomla1(string $username, string $password, string $salt, string $dbHash): bool { if (\hash_equals($dbHash, \md5($password . $salt))) { return true; @@ -525,7 +526,7 @@ protected static function joomla1($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function joomla2($username, $password, $salt, $dbHash) + private static function joomla2(string $username, string $password, string $salt, string $dbHash): bool { return self::joomla1($username, $password, $salt, $dbHash); } @@ -533,7 +534,7 @@ protected static function joomla2($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function joomla3($username, $password, $salt, $dbHash) + private static function joomla3(string $username, string $password, string $salt, string $dbHash): bool { return self::joomla1($username, $password, $salt, $dbHash); } @@ -541,7 +542,7 @@ protected static function joomla3($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function phpfox3($username, $password, $salt, $dbHash) + private static function phpfox3(string $username, string $password, string $salt, string $dbHash): bool { if (\hash_equals($dbHash, \md5(\md5($password) . \md5($salt)))) { return true; @@ -553,7 +554,7 @@ protected static function phpfox3($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function cryptMD5($username, $password, $salt, $dbHash) + private static function cryptMD5(string $username, string $password, string $salt, string $dbHash): bool { if (\hash_equals($dbHash, self::getSaltedHash($password, $dbHash))) { return true; @@ -565,7 +566,7 @@ protected static function cryptMD5($username, $password, $salt, $dbHash) /** * @deprecated 5.4 - Use the new password algorithm framework in \wcf\system\user\authentication\password\*. */ - protected static function invalid($username, $password, $salt, $dbHash) + private static function invalid(string $username, string $password, string $salt, string $dbHash): bool { return false; } diff --git a/wcfsetup/install/files/lib/util/StringStack.class.php b/wcfsetup/install/files/lib/util/StringStack.class.php index aee3cb394f3..cd8de773871 100644 --- a/wcfsetup/install/files/lib/util/StringStack.class.php +++ b/wcfsetup/install/files/lib/util/StringStack.class.php @@ -13,26 +13,23 @@ final class StringStack { /** * hash index - * @var int */ - protected static $i = 0; + private static int $i = 0; /** * local string stack - * @var string[][] + * @var array> */ - protected static $stringStack = []; + private static array $stringStack = []; /** * Replaces a string with an unique hash value. - * - * @param string $string - * @param string $type - * @param string $delimiter - * @return string $hash */ - public static function pushToStringStack($string, $type = 'default', $delimiter = '@@') - { + public static function pushToStringStack( + string $string, + string $type = 'default', + string $delimiter = '@@' + ): string { self::$i++; $hash = $delimiter . StringUtil::getRandomID() . $delimiter; @@ -47,12 +44,8 @@ public static function pushToStringStack($string, $type = 'default', $delimiter /** * Reinserts strings that have been replaced by unique hash values. - * - * @param string $string - * @param string $type - * @return string */ - public static function reinsertStrings($string, $type = 'default') + public static function reinsertStrings(string $string, string $type = 'default'): string { if (isset(self::$stringStack[$type])) { foreach (self::$stringStack[$type] as $hash => $value) { @@ -69,10 +62,9 @@ public static function reinsertStrings($string, $type = 'default') /** * Returns the stack. * - * @param string $type - * @return array + * @return array */ - public static function getStack($type = 'default') + public static function getStack(string $type = 'default'): array { if (isset(self::$stringStack[$type])) { return self::$stringStack[$type]; diff --git a/wcfsetup/install/files/lib/util/StringUtil.class.php b/wcfsetup/install/files/lib/util/StringUtil.class.php index e69896add5d..9e20400d33f 100644 --- a/wcfsetup/install/files/lib/util/StringUtil.class.php +++ b/wcfsetup/install/files/lib/util/StringUtil.class.php @@ -31,17 +31,15 @@ final class StringUtil /** * @deprecated 5.5 - Use \sha1() directly. */ - public static function getHash($value) + public static function getHash(string $value): string { return \sha1($value); } /** * Returns a 40 character hexadecimal string generated using a CSPRNG. - * - * @return string */ - public static function getRandomID() + public static function getRandomID(): string { return Hex::encode(\random_bytes(20)); } @@ -73,10 +71,8 @@ public static function getUUID(): string /** * Converts dos to unix newlines. - * - * @param string $string */ - public static function unifyNewlines($string): string + public static function unifyNewlines(string $string): string { return \preg_replace("%(\r\n)|(\r)%", "\n", $string); } @@ -84,10 +80,8 @@ public static function unifyNewlines($string): string /** * Removes Unicode whitespace characters from the beginning * and ending of the given string. - * - * @param string $text */ - public static function trim($text): string + public static function trim(string $text): string { // $boundaryCharacters can always be removed when appearing at either the beginning // or the end of the input. @@ -142,13 +136,11 @@ public static function trim($text): string /** * Converts html special characters. - * - * @param string $string */ - public static function encodeHTML($string): string + public static function encodeHTML(string $string): string { return @\htmlspecialchars( - (string)$string, + $string, \ENT_QUOTES | \ENT_SUBSTITUTE | \ENT_HTML401, 'UTF-8' ); @@ -156,10 +148,8 @@ public static function encodeHTML($string): string /** * Converts javascript special characters. - * - * @param string $string */ - public static function encodeJS($string): string + public static function encodeJS(string $string): string { $string = self::unifyNewlines($string); @@ -168,10 +158,8 @@ public static function encodeJS($string): string /** * Decodes html entities. - * - * @param string $string */ - public static function decodeHTML($string): string + public static function decodeHTML(string $string): string { $string = \str_ireplace(' ', ' ', $string); // convert non-breaking spaces to ascii 32; not ascii 160 @@ -244,10 +232,8 @@ public static function addThousandsSeparator(int|float $number): string /** * Replaces the MINUS-HYPHEN with the MINUS SIGN. - * - * @param mixed $number */ - public static function formatNegative($number): string + public static function formatNegative(string $number): string { return \str_replace('-', self::MINUS, $number); } @@ -255,9 +241,9 @@ public static function formatNegative($number): string /** * Alias to php ucfirst() function with multibyte support. * - * @param string $string + * @deprecated 6.2 Use `\mb_ucfirst()` instead */ - public static function firstCharToUpperCase($string): string + public static function firstCharToUpperCase(string $string): string { return \mb_strtoupper(\mb_substr($string, 0, 1)) . \mb_substr($string, 1); } @@ -265,19 +251,17 @@ public static function firstCharToUpperCase($string): string /** * Alias to php lcfirst() function with multibyte support. * - * @param string $string + * @deprecated 6.2 Use `\mb_lcfirst()` instead */ - public static function firstCharToLowerCase($string): string + public static function firstCharToLowerCase(string $string): string { return \mb_strtolower(\mb_substr($string, 0, 1)) . \mb_substr($string, 1); } /** * Alias to php mb_convert_case() function. - * - * @param string $string */ - public static function wordsToUpperCase($string): string + public static function wordsToUpperCase(string $string): string { return \mb_convert_case($string, \MB_CASE_TITLE); } @@ -287,13 +271,8 @@ public static function wordsToUpperCase($string): string * * This function is considered to be slow, if $search contains * only ASCII characters, please use str_ireplace() instead. - * - * @param string $search - * @param string $replace - * @param string $subject - * @param int $count */ - public static function replaceIgnoreCase($search, $replace, $subject, &$count = 0): string + public static function replaceIgnoreCase(string $search, string $replace, string $subject, int &$count = 0): string { $startPos = \mb_strpos(\mb_strtolower($subject), \mb_strtolower($search)); if ($startPos === false) { @@ -312,9 +291,10 @@ public static function replaceIgnoreCase($search, $replace, $subject, &$count = } /** + * @return list * @deprecated 5.5 Use \mb_str_split() instead. */ - public static function split($string, $length = 1) + public static function split(string $string, int $length = 1): array { $result = []; for ($i = 0, $max = \mb_strlen($string); $i < $max; $i += $length) { @@ -327,7 +307,7 @@ public static function split($string, $length = 1) /** * @deprecated 5.5 Use \str_starts_with() instead. If a case-insensitive comparison is desired, manually call \mb_strtolower on both parameters. */ - public static function startsWith($haystack, $needle, $ci = false): bool + public static function startsWith(string $haystack, string $needle, bool $ci = false): bool { if ($ci) { $haystack = \mb_strtolower($haystack); @@ -340,7 +320,7 @@ public static function startsWith($haystack, $needle, $ci = false): bool /** * @deprecated 5.5 Use \str_ends_with() instead. If a case-insensitive comparison is desired, manually call \mb_strtolower on both parameters. */ - public static function endsWith($haystack, $needle, $ci = false): bool + public static function endsWith(string $haystack, string $needle, bool $ci = false): bool { if ($ci) { $haystack = \mb_strtolower($haystack); @@ -356,13 +336,8 @@ public static function endsWith($haystack, $needle, $ci = false): bool /** * Alias to php str_pad function with multibyte support. - * - * @param string $input - * @param int $padLength - * @param string $padString - * @param int $padType */ - public static function pad($input, $padLength, $padString = ' ', $padType = \STR_PAD_RIGHT): string + public static function pad(string $input, int $padLength, string $padString = ' ', int $padType = \STR_PAD_RIGHT): string { $additionalPadding = \strlen($input) - \mb_strlen($input); @@ -371,11 +346,8 @@ public static function pad($input, $padLength, $padString = ' ', $padType = \STR /** * Unescapes escaped characters in a string. - * - * @param string $string - * @param string $chars */ - public static function unescape($string, $chars = '"'): string + public static function unescape(string $string, string $chars = '"'): string { for ($i = 0, $j = \strlen($chars); $i < $j; $i++) { $string = \str_replace('\\' . $chars[$i], $chars[$i], $string); @@ -386,10 +358,8 @@ public static function unescape($string, $chars = '"'): string /** * Takes a numeric HTML entity value and returns the appropriate UTF-8 bytes. - * - * @param int $dec html entity value */ - public static function getCharacter($dec): string + public static function getCharacter(int $dec): string { if ($dec < 128) { $utf = \chr($dec); @@ -408,11 +378,8 @@ public static function getCharacter($dec): string /** * Converts UTF-8 to Unicode * @see http://www1.tip.nl/~t876506/utf8tbl.html - * - * @param string $c - * @return int */ - public static function getCharValue($c) + public static function getCharValue(string $c): int { $ud = 0; if (\ord($c[0]) <= 127) { @@ -442,10 +409,8 @@ public static function getCharValue($c) /** * Returns html entities of all characters in the given string. - * - * @param string $string */ - public static function encodeAllChars($string): string + public static function encodeAllChars(string $string): string { $result = ''; for ($i = 0, $j = \mb_strlen($string); $i < $j; $i++) { @@ -458,10 +423,8 @@ public static function encodeAllChars($string): string /** * Returns true if the given string contains only ASCII characters. - * - * @param string $string */ - public static function isASCII($string): bool + public static function isASCII(string $string): bool { return !!\preg_match('/^[\x00-\x7F]*$/', $string); } @@ -469,11 +432,8 @@ public static function isASCII($string): bool /** * Returns true if the given string is utf-8 encoded. * @see http://www.w3.org/International/questions/qa-forms-utf-8 - * - * @param string $string - * @return bool */ - public static function isUTF8($string): bool + public static function isUTF8(string $string): bool { return !!\preg_match('/^( [\x09\x0A\x0D\x20-\x7E]* # ASCII @@ -489,10 +449,8 @@ public static function isUTF8($string): bool /** * Escapes the closing cdata tag. - * - * @param string $string */ - public static function escapeCDATA($string): string + public static function escapeCDATA(string $string): string { return \str_replace(']]>', ']]]]>', $string); } @@ -500,17 +458,15 @@ public static function escapeCDATA($string): string /** * @deprecated 6.0 Use `\mb_convert_encoding()` directly. */ - public static function convertEncoding($inCharset, $outCharset, $string): string + public static function convertEncoding(string $inCharset, string $outCharset, string $string): string { return \mb_convert_encoding($string, $outCharset, $inCharset); } /** * Strips HTML tags from a string. - * - * @param string $string */ - public static function stripHTML($string): string + public static function stripHTML(string $string): string { $string = \preg_replace('~~', '', $string); @@ -533,11 +489,8 @@ public static function stripHTML($string): string /** * Returns false if the given word is forbidden by given word filter. - * - * @param string $word - * @param string $filter */ - public static function executeWordFilter($word, $filter): bool + public static function executeWordFilter(string $word, string $filter): bool { $filter = self::trim($filter); $word = \mb_strtolower($word); @@ -569,14 +522,13 @@ public static function executeWordFilter($word, $filter): bool /** * Truncates the given string to a certain number of characters. - * - * @param string $string string which shall be truncated - * @param int $length string length after truncating - * @param string $etc string to append when $string is truncated - * @param bool $breakWords should words be broken in the middle */ - public static function truncate($string, $length = 80, $etc = self::HELLIP, $breakWords = false): string - { + public static function truncate( + string $string, + int $length = 80, + string $etc = self::HELLIP, + bool $breakWords = false + ): string { if ($length == 0) { return ''; } @@ -596,14 +548,13 @@ public static function truncate($string, $length = 80, $etc = self::HELLIP, $bre /** * Truncates a string containing HTML code and keeps the HTML syntax intact. - * - * @param string $string string which shall be truncated - * @param int $length string length after truncating - * @param string $etc ending string which will be appended after truncating - * @param bool $breakWords if false words will not be split and the return string might be shorter than $length */ - public static function truncateHTML($string, $length = 500, $etc = self::HELLIP, $breakWords = false): string - { + public static function truncateHTML( + string $string, + int $length = 500, + string $etc = self::HELLIP, + bool $breakWords = false + ): string { if (\mb_strlen(self::stripHTML($string)) <= $length) { return $string; } @@ -696,14 +647,13 @@ public static function truncateHTML($string, $length = 500, $etc = self::HELLIP, /** * Generates an anchor tag from given URL. - * - * @param string $url - * @param string $title - * @param bool $encodeTitle - * @param bool $isUgc true to add rel=ugc to the anchor tag */ - public static function getAnchorTag($url, $title = '', $encodeTitle = true, $isUgc = false): string - { + public static function getAnchorTag( + string $url, + string $title = '', + bool $encodeTitle = true, + bool $isUgc = false + ): string { $url = self::trim($url); // cut visible url @@ -729,11 +679,9 @@ public static function getAnchorTag($url, $title = '', $encodeTitle = true, $isU /** * Generates the attributes for an anchor tag from given URL. * - * @param string $url - * @param bool $isUgc true to add rel=ugc to the attributes * @since 5.3 */ - public static function getAnchorTagAttributes($url, $isUgc = false): string + public static function getAnchorTagAttributes(string $url, bool $isUgc = false): string { $external = true; if (ApplicationHandler::getInstance()->isInternalURL($url)) { @@ -761,24 +709,16 @@ public static function getAnchorTagAttributes($url, $isUgc = false): string /** * Splits given string into smaller chunks. - * - * @param string $string - * @param int $length - * @param string $break */ - public static function splitIntoChunks($string, $length = 75, $break = "\r\n"): string + public static function splitIntoChunks(string $string, int $length = 75, string $break = "\r\n"): string { return \mb_ereg_replace('.{' . $length . '}', "\\0" . $break, $string); } /** * Simple multi-byte safe wordwrap() function. - * - * @param string $string - * @param int $width - * @param string $break */ - public static function wordwrap($string, $width = 50, $break = ' '): string + public static function wordwrap(string $string, int $width = 50, string $break = ' '): string { $result = ''; $substrings = \explode($break, $string); @@ -811,10 +751,8 @@ public static function wordwrap($string, $width = 50, $break = ' '): string /** * Shortens numbers larger than 1000 by using unit suffixes. - * - * @param int $number */ - public static function getShortUnit($number): string + public static function getShortUnit(int $number): string { $unitSuffix = ''; @@ -844,10 +782,9 @@ public static function getShortUnit($number): string * that the separator is just a comma, not a combination of whitespace and * a comma. * - * @param string $string * @since 3.1 */ - public static function normalizeCsv($string): string + public static function normalizeCsv(string $string): string { return \implode(',', ArrayUtil::trim(\explode(',', $string))); } diff --git a/wcfsetup/install/files/lib/util/Url.class.php b/wcfsetup/install/files/lib/util/Url.class.php index f9d387e2f9c..8c6cecc54ab 100644 --- a/wcfsetup/install/files/lib/util/Url.class.php +++ b/wcfsetup/install/files/lib/util/Url.class.php @@ -24,6 +24,7 @@ * query: string, * fragment: string, * } + * @implements \ArrayAccess */ final class Url implements \ArrayAccess { @@ -125,7 +126,7 @@ public function offsetExists(mixed $offset): bool } #[\Override] - public function offsetGet(mixed $offset): mixed + public function offsetGet(mixed $offset): int|string { return $this->components[$this->getIndex($offset)]; } diff --git a/wcfsetup/install/files/lib/util/UserAgent.class.php b/wcfsetup/install/files/lib/util/UserAgent.class.php index 132faefeaec..82ca71b5943 100644 --- a/wcfsetup/install/files/lib/util/UserAgent.class.php +++ b/wcfsetup/install/files/lib/util/UserAgent.class.php @@ -30,6 +30,8 @@ public function __construct(string $userAgent) /** * Detects the browser on the basis of the user agent. + * + * @return array{0: string, 1: string}|array{0: null, 1: null} */ private function detectBrowser(string $userAgent): array { diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index 9cba61d9fa7..6fc505dd72e 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -57,7 +57,7 @@ public static function isValidUsername(string $name): bool /** * @deprecated 5.5 Check whether `User::getUserByUsername()->userID` is falsy. */ - public static function isAvailableUsername($name): bool + public static function isAvailableUsername(string $name): bool { $sql = "SELECT COUNT(username) FROM wcf1_user @@ -65,7 +65,7 @@ public static function isAvailableUsername($name): bool $statement = WCF::getDB()->prepare($sql); $statement->execute([$name]); - return $statement->fetchSingleColumn() == 0; + return $statement->fetchSingleColumn() === 0; } /** @@ -91,7 +91,7 @@ public static function isValidEmail(string $email): bool /** * @deprecated 5.5 Check whether `User::getUserByEmail()->userID` is falsy. */ - public static function isAvailableEmail($email): bool + public static function isAvailableEmail(string $email): bool { $sql = "SELECT COUNT(email) FROM wcf1_user @@ -99,7 +99,7 @@ public static function isAvailableEmail($email): bool $statement = WCF::getDB()->prepare($sql); $statement->execute([$email]); - return $statement->fetchSingleColumn() == 0; + return $statement->fetchSingleColumn() === 0; } /** diff --git a/wcfsetup/install/files/lib/util/XML.class.php b/wcfsetup/install/files/lib/util/XML.class.php index c2d8e0f81c1..612be86943b 100644 --- a/wcfsetup/install/files/lib/util/XML.class.php +++ b/wcfsetup/install/files/lib/util/XML.class.php @@ -51,7 +51,7 @@ public function __construct() * Loads a xml file for processing. * * @param string $path - * @throws SystemException + * @return void */ public function load($path) { @@ -81,6 +81,7 @@ public function load($path) * * @param string $path * @param string $xml + * @return void */ public function loadXML($path, $xml) { @@ -103,6 +104,7 @@ public function loadXML($path, $xml) /** * Validate the loaded document against the specified xml schema definition. * + * @return void * @deprecated since 5.2 */ public function validate() @@ -123,6 +125,7 @@ public function validate() /** * Determines schema for given document. * + * @return void * @deprecated since 5.2 */ protected function getSchema() @@ -210,7 +213,8 @@ public function pollErrors() * Throws a SystemException providing details on xml errors if applicable. * * @param string $message - * @param array $errors + * @param array{line: int, message: string}[] $errors + * @return never * @throws SystemException */ protected function throwException($message, array $errors = []) @@ -244,6 +248,7 @@ public function getDocument() * * @param string $fileLocation location of file * @param bool $cdata indicates of values are escaped using cdata + * @return void * @since 5.2 */ public function write($fileLocation, $cdata = false) @@ -275,6 +280,7 @@ public function write($fileLocation, $cdata = false) * @param XMLWriter $writer xml writer * @param \DOMElement $element written element * @param bool $cdata indicates if element value is escaped using cdata + * @return void * @since 5.2 */ protected function writeElement(XMLWriter $writer, \DOMElement $element, $cdata) @@ -305,7 +311,7 @@ protected function writeElement(XMLWriter $writer, \DOMElement $element, $cdata) * (with the attribute names as array keys). * * @param \DOMElement $element elements whose attributes will be returned - * @return array attributes + * @return array attributes * @since 5.2 */ public function getAttributes(\DOMElement $element) diff --git a/wcfsetup/install/files/lib/util/XMLWriter.class.php b/wcfsetup/install/files/lib/util/XMLWriter.class.php index 7f006471fd6..089eca04b82 100644 --- a/wcfsetup/install/files/lib/util/XMLWriter.class.php +++ b/wcfsetup/install/files/lib/util/XMLWriter.class.php @@ -38,7 +38,7 @@ class XMLWriter * @param string $namespace * @param string $schemaLocation * @param string[] $attributes - * @throws SystemException + * @return void */ public function beginDocument($rootElement, $namespace, $schemaLocation, array $attributes = []) { @@ -77,7 +77,7 @@ public function beginDocument($rootElement, $namespace, $schemaLocation, array $ * elements will be automatically closed before flushing. * * @param string $filename - * @return mixed + * @return string|int|void */ public function endDocument($filename = '') { @@ -103,6 +103,7 @@ public function endDocument($filename = '') * * @param string $element * @param string[] $attributes + * @return void */ public function startElement($element, array $attributes = []) { @@ -116,6 +117,8 @@ public function startElement($element, array $attributes = []) /** * Ends the last opened element. + * + * @return void */ public function endElement() { @@ -132,6 +135,8 @@ public function endElement() * @param string $cdata * @param string[] $attributes * @param bool $writeAsCdata + * + * @return void */ public function writeElement($element, $cdata, array $attributes = [], $writeAsCdata = true) { @@ -158,6 +163,7 @@ public function writeElement($element, $cdata, array $attributes = [], $writeAsC * Writes a comment. * * @param string $comment + * @return void * @since 5.2 */ public function writeComment($comment) @@ -170,6 +176,7 @@ public function writeComment($comment) * * @param string $attribute * @param string $value + * @return void */ public function writeAttribute($attribute, $value) { @@ -180,6 +187,7 @@ public function writeAttribute($attribute, $value) * Writes a list of attributes to last opened element. * * @param string[] $attributes + * @return void */ public function writeAttributes(array $attributes) { diff --git a/wcfsetup/install/files/lib/util/exception/CryptoException.class.php b/wcfsetup/install/files/lib/util/exception/CryptoException.class.php index 6d5d9ab2d32..7c0f6cc4aef 100644 --- a/wcfsetup/install/files/lib/util/exception/CryptoException.class.php +++ b/wcfsetup/install/files/lib/util/exception/CryptoException.class.php @@ -13,7 +13,8 @@ class CryptoException extends \Exception { /** - * @inheritDoc + * @param string $message + * @param ?\Throwable $previous */ public function __construct($message, $previous = null) { diff --git a/wcfsetup/install/files/proxy_sourcemap.php b/wcfsetup/install/files/proxy_sourcemap.php index cfe5323a79a..8bde570a223 100644 --- a/wcfsetup/install/files/proxy_sourcemap.php +++ b/wcfsetup/install/files/proxy_sourcemap.php @@ -58,7 +58,7 @@ function verifySignature(string $map, string $signature): bool * Returns a string if a map name could be extracted. Returns a class implementing * ResponseInterface if the $query is invalid. */ -function getMapFromQuery(string $query) +function getMapFromQuery(string $query): string|ResponseInterface { try { // Step 1: Extract the signature and map name. From 41ba1b81cdd4918cc1b3f9b8630f6b409cc246bb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 15 Feb 2025 14:32:33 +0100 Subject: [PATCH 02/31] Improve the typing of the workers --- .../worker/RebuildWorkerCollecting.class.php | 5 +++- .../AbstractRebuildDataWorker.class.php | 2 ++ .../system/worker/AbstractWorker.class.php | 4 ++- .../worker/BulkProcessingWorker.class.php | 5 ++++ .../files/lib/system/worker/IWorker.class.php | 9 +++++-- .../lib/system/worker/ImportWorker.class.php | 2 +- .../lib/system/worker/MailWorker.class.php | 3 ++- .../worker/SendNewPasswordWorker.class.php | 4 ++- .../worker/SitemapRebuildWorker.class.php | 25 +++++++++++++------ .../StatDailyRebuildDataWorker.class.php | 2 ++ ...rActivityPointUpdateEventsWorker.class.php | 4 +-- .../worker/UserContentRemoveWorker.class.php | 2 +- .../worker/UserRebuildDataWorker.class.php | 1 + .../event/RebuildWorkerCollecting.class.php | 3 +++ 14 files changed, 53 insertions(+), 18 deletions(-) diff --git a/wcfsetup/install/files/lib/event/worker/RebuildWorkerCollecting.class.php b/wcfsetup/install/files/lib/event/worker/RebuildWorkerCollecting.class.php index 141d8b92ccc..49a840a3791 100644 --- a/wcfsetup/install/files/lib/event/worker/RebuildWorkerCollecting.class.php +++ b/wcfsetup/install/files/lib/event/worker/RebuildWorkerCollecting.class.php @@ -17,7 +17,10 @@ */ final class RebuildWorkerCollecting extends \wcf\system\worker\event\RebuildWorkerCollecting implements IPsr14Event { - private \SplPriorityQueue $queue; + /** + * @var \SplPriorityQueue + */ + private readonly \SplPriorityQueue $queue; public function __construct() { diff --git a/wcfsetup/install/files/lib/system/worker/AbstractRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/AbstractRebuildDataWorker.class.php index a152fa6a4ab..44d1aa704b9 100644 --- a/wcfsetup/install/files/lib/system/worker/AbstractRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/AbstractRebuildDataWorker.class.php @@ -97,6 +97,8 @@ public function getProceedURL() /** * Initializes DatabaseObjectList instance. + * + * @return void */ protected function initObjectList() { diff --git a/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php b/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php index 471d1b7019c..1f9f5383d55 100644 --- a/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php @@ -31,7 +31,7 @@ abstract class AbstractWorker implements IWorker /** * list of additional parameters - * @var array + * @var mixed[] */ protected $parameters = []; @@ -53,6 +53,8 @@ public function setLoopCount($loopCount) /** * Counts objects applicable for worker action. + * + * @return void */ abstract protected function countObjects(); diff --git a/wcfsetup/install/files/lib/system/worker/BulkProcessingWorker.class.php b/wcfsetup/install/files/lib/system/worker/BulkProcessingWorker.class.php index 0f4f71a267d..7466ea1aaf1 100644 --- a/wcfsetup/install/files/lib/system/worker/BulkProcessingWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/BulkProcessingWorker.class.php @@ -20,7 +20,12 @@ final class BulkProcessingWorker extends AbstractWorker * @inheritDoc */ protected $limit = 100; + + /** + * @var array + */ protected array $bulkProcessingData; + protected IBulkProcessingAction $action; #[\Override] diff --git a/wcfsetup/install/files/lib/system/worker/IWorker.class.php b/wcfsetup/install/files/lib/system/worker/IWorker.class.php index 67b8d150ec4..039fb49c4a8 100644 --- a/wcfsetup/install/files/lib/system/worker/IWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/IWorker.class.php @@ -14,7 +14,7 @@ interface IWorker /** * Creates a new worker object with additional parameters * - * @param array $parameters + * @param mixed[] $parameters */ public function __construct(array $parameters); @@ -22,6 +22,7 @@ public function __construct(array $parameters); * Sets current loop count. * * @param int $loopCount + * @return void */ public function setLoopCount($loopCount); @@ -35,18 +36,22 @@ public function getProgress(); /** * Executes worker action. + * + * @return void */ public function execute(); /** * Returns parameters previously given within __construct(). * - * @return array + * @return mixed[] */ public function getParameters(); /** * Validates parameters. + * + * @return void */ public function validate(); diff --git a/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php b/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php index 56d8c512879..42dc5ff59fb 100644 --- a/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php @@ -19,7 +19,7 @@ class ImportWorker extends AbstractWorker { /** * import data - * @var array + * @var array */ protected $importData; diff --git a/wcfsetup/install/files/lib/system/worker/MailWorker.class.php b/wcfsetup/install/files/lib/system/worker/MailWorker.class.php index ceaa4ee49eb..0c28d864a00 100644 --- a/wcfsetup/install/files/lib/system/worker/MailWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/MailWorker.class.php @@ -37,7 +37,7 @@ class MailWorker extends AbstractWorker /** * mail data - * @var array + * @var array{action: string, enableHTML: 1|0, from: string, fromName?: string, groupIDs: int[], 'message-id': string, subject: string, text: string, userIDs: int[]} */ protected $mailData; @@ -173,6 +173,7 @@ public function execute() * * @param Email $blueprint * @param User $user + * @return void */ protected function sendMail(Email $blueprint, User $user) { diff --git a/wcfsetup/install/files/lib/system/worker/SendNewPasswordWorker.class.php b/wcfsetup/install/files/lib/system/worker/SendNewPasswordWorker.class.php index a9dbd3f9954..a5bba896989 100644 --- a/wcfsetup/install/files/lib/system/worker/SendNewPasswordWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/SendNewPasswordWorker.class.php @@ -39,7 +39,7 @@ public function countObjects() $userList = new UserList(); $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$this->parameters['userIDs']]); - return $userList->countObjects(); + $this->count = $userList->countObjects(); } /** @@ -102,6 +102,7 @@ public function getProgress() * Resets the password of the given user. * * @param UserEditor $userEditor + * @return void */ protected function resetPassword(UserEditor $userEditor) { @@ -121,6 +122,7 @@ protected function resetPassword(UserEditor $userEditor) * Send links. * * @param User $user + * @return void */ protected function sendLink(User $user) { diff --git a/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php b/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php index 3b98af9d380..b2f6d888e96 100755 --- a/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php @@ -269,6 +269,8 @@ public function execute() /** * Checks if the sitemap has to be rebuilt. If not, this method marks the sitemap as built. + * + * @return void */ protected function checkCache() { @@ -308,6 +310,7 @@ protected function checkCache() * Writes the sitemap.xml index file and links all sitemaps. * * @param bool $closeFile Close a previously opened handle. + * @return void */ protected function writeIndexFile($closeFile = true) { @@ -335,6 +338,7 @@ protected function writeIndexFile($closeFile = true) * Generates a new temporary file and appends the sitemap start. * * @param bool $closeFile Close a previously opened handle. + * @return void */ protected function generateTmpFile($closeFile = true) { @@ -351,6 +355,8 @@ protected function generateTmpFile($closeFile = true) /** * Open the current temporary file. + * + * @return void */ protected function openFile() { @@ -363,6 +369,8 @@ protected function openFile() /** * Closes the current temporary file, iff a File is opened. + * + * @return void */ protected function closeFile() { @@ -377,6 +385,8 @@ protected function closeFile() * * @param string $filename * @param int $packageID + * + * @return void */ protected function finishSitemap($filename, $packageID) { @@ -395,7 +405,7 @@ protected function finishSitemap($filename, $packageID) $this->workerData['filesToPackage'][$packageID][] = 'sitemaps/' . $filename; } - private function registerSitemapFiles() + private function registerSitemapFiles(): void { $sql = "INSERT IGNORE INTO wcf1_package_installation_file_log (packageID, filename, application) @@ -417,6 +427,8 @@ private function registerSitemapFiles() /** * Stores the current worker data in a session. + * + * @return void */ protected function storeWorkerData() { @@ -425,6 +437,8 @@ protected function storeWorkerData() /** * Load the current worker data and set the default values, if isn't any data stored. + * + * @return void */ protected function loadWorkerData() { @@ -485,10 +499,8 @@ public static function getSitemapURL() /** * Unlink the sitemap files for a given object type name. - * - * @param string $objectTypeName */ - private function deleteSitemaps($objectTypeName) + private function deleteSitemaps(string $objectTypeName): void { $files = @\glob(self::getSitemapPath() . $objectTypeName . '*.xml'); if (\is_array($files)) { @@ -504,7 +516,7 @@ private function deleteSitemaps($objectTypeName) /** * Saves the actual user and changes the session owner to a guest. */ - private function changeUserToGuest() + private function changeUserToGuest(): void { $this->actualUser = WCF::getUser(); @@ -515,7 +527,7 @@ private function changeUserToGuest() /** * Changes the session back to the actual user. */ - private function changeToActualUser() + private function changeToActualUser(): void { WCF::getSession()->changeUser($this->actualUser, true); } @@ -523,7 +535,6 @@ private function changeToActualUser() /** * Reads the columns changed by the user for this sitemap object from the registry. * - * @param ObjectType $object * @since 5.3 */ private function prepareSitemapObject(ObjectType $object): void diff --git a/wcfsetup/install/files/lib/system/worker/StatDailyRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/StatDailyRebuildDataWorker.class.php index 1f9fe906c67..df4c30bdd22 100644 --- a/wcfsetup/install/files/lib/system/worker/StatDailyRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/StatDailyRebuildDataWorker.class.php @@ -89,6 +89,8 @@ public function execute() /** * Determines the start timestamp. + * + * @return void */ protected function getStartDate() { diff --git a/wcfsetup/install/files/lib/system/worker/UserActivityPointUpdateEventsWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserActivityPointUpdateEventsWorker.class.php index 18ede548da6..7934cab6a48 100644 --- a/wcfsetup/install/files/lib/system/worker/UserActivityPointUpdateEventsWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserActivityPointUpdateEventsWorker.class.php @@ -27,9 +27,7 @@ class UserActivityPointUpdateEventsWorker extends AbstractWorker */ public $objectTypes = []; - /** - * @inheritDoc - */ + #[\Override] public function __construct(array $parameters) { parent::__construct($parameters); diff --git a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php index 53c062a0476..253c9d00efc 100644 --- a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php @@ -129,7 +129,7 @@ public function validate() /** * Generate the data variable. */ - private function generateData() + private function generateData(): void { $this->data = [ 'provider' => [], diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index 951fc1a7943..1c31d80a24a 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -30,6 +30,7 @@ * @license GNU Lesser General Public License * * @method UserList getObjectList() + * @property UserList $objectList */ final class UserRebuildDataWorker extends AbstractLinearRebuildDataWorker { diff --git a/wcfsetup/install/files/lib/system/worker/event/RebuildWorkerCollecting.class.php b/wcfsetup/install/files/lib/system/worker/event/RebuildWorkerCollecting.class.php index a35ebd53020..a4b0efb092a 100644 --- a/wcfsetup/install/files/lib/system/worker/event/RebuildWorkerCollecting.class.php +++ b/wcfsetup/install/files/lib/system/worker/event/RebuildWorkerCollecting.class.php @@ -18,6 +18,9 @@ */ class RebuildWorkerCollecting implements IEvent { + /** + * @var \SplPriorityQueue + */ private \SplPriorityQueue $queue; public function __construct() From 9870d1c1749707dbdecef503dc10477bced0dfe0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 15 Feb 2025 19:44:30 +0100 Subject: [PATCH 03/31] Improve the typing of the template engine and notifications --- .../comment/StructuredCommentList.class.php | 2 +- .../object/type/ObjectTypeCache.class.php | 22 ++--- .../template/ACPTemplateEngine.class.php | 1 + .../template/TemplateCompiler.class.php | 6 +- .../system/template/TemplateEngine.class.php | 92 +++++++++++++------ .../TemplateScriptingCompiler.class.php | 24 +++-- .../CounterFunctionTemplatePlugin.class.php | 2 +- .../CycleFunctionTemplatePlugin.class.php | 2 +- ...ascontentPrefilterTemplatePlugin.class.php | 2 +- ...tmlOptionsFunctionTemplatePlugin.class.php | 2 +- .../plugin/IBlockTemplatePlugin.class.php | 5 +- .../plugin/ICompilerTemplatePlugin.class.php | 2 +- .../plugin/IFunctionTemplatePlugin.class.php | 2 +- .../plugin/IModifierTemplatePlugin.class.php | 2 +- .../PluralFunctionTemplatePlugin.class.php | 2 + .../TrophyConditionHandler.class.php | 2 + .../DefaultUploadFileSaveStrategy.class.php | 9 +- .../upload/IUploadFileSaveStrategy.class.php | 1 + .../lib/system/upload/UploadFile.class.php | 10 +- .../lib/system/upload/UploadHandler.class.php | 3 +- .../lib/system/user/GroupedUserList.class.php | 1 + .../system/user/UserBirthdayCache.class.php | 1 + .../system/user/UserProfileHandler.class.php | 4 +- .../event/IUserActivityEvent.class.php | 1 + ...CommentResponseUserActivityEvent.class.php | 1 + .../event/UserActivityEventHandler.class.php | 9 +- .../point/UserActivityPointHandler.class.php | 6 ++ .../DefaultUserAuthentication.class.php | 14 +++ .../user/authentication/oauth/User.class.php | 9 +- .../StateValidationException.class.php | 2 +- .../password/algorithm/Bcrypt.class.php | 9 +- .../password/algorithm/DoubleBcrypt.class.php | 36 ++------ .../password/algorithm/TPhpass.class.php | 2 +- .../UserCollapsibleContentHandler.class.php | 2 + .../system/user/command/SetAvatar.class.php | 5 +- .../provider/IUserContentProvider.class.php | 1 + .../UserGroupAssignmentHandler.class.php | 1 + .../group/command/CopyUserGroup.class.php | 2 +- .../BackupMultifactorMethod.class.php | 8 ++ .../EmailMultifactorMethod.class.php | 3 + .../multifactor/IMultifactorMethod.class.php | 2 + .../system/user/multifactor/Setup.class.php | 9 +- .../TotpMultifactorMethod.class.php | 2 + .../multifactor/totp/CodeFormField.class.php | 1 + .../multifactor/totp/DeviceNode.class.php | 4 +- ...ableUserNotificationEventHandler.class.php | 4 +- .../UserNotificationHandler.class.php | 12 ++- ...tractSharedUserNotificationEvent.class.php | 2 + ...ArticleLikeUserNotificationEvent.class.php | 2 + .../ITestableUserNotificationEvent.class.php | 3 +- .../event/IUserNotificationEvent.class.php | 5 +- ...entResponseUserNotificationEvent.class.php | 1 + ...ueueCommentUserNotificationEvent.class.php | 1 + ...entResponseUserNotificationEvent.class.php | 1 + ...PageCommentUserNotificationEvent.class.php | 1 + ...icleCommentUserNotificationEvent.class.php | 1 + ...CategorizedUserNotificationEvent.class.php | 2 +- ...CommentLikeUserNotificationEvent.class.php | 2 + ...esponseLikeUserNotificationEvent.class.php | 2 + ...establePageUserNotificationEvent.class.php | 2 +- ...CommentLikeUserNotificationEvent.class.php | 1 + ...esponseLikeUserNotificationEvent.class.php | 1 + ...sponseOwnerUserNotificationEvent.class.php | 1 + ...entResponseUserNotificationEvent.class.php | 1 + ...fileCommentUserNotificationEvent.class.php | 1 + .../object/watch/IUserObjectWatch.class.php | 2 + .../watch/UserObjectWatchHandler.class.php | 13 ++- .../location/IUserOnlineLocation.class.php | 1 + .../user/signature/SignatureCache.class.php | 1 + .../user/storage/UserStorageHandler.class.php | 18 ++-- .../version/IVersionTrackerProvider.class.php | 1 + .../system/version/VersionTracker.class.php | 5 +- .../version/VersionTrackerEntry.class.php | 6 +- .../lib/system/view/CommentsView.class.php | 5 + .../visitTracker/VisitTracker.class.php | 9 +- 75 files changed, 293 insertions(+), 142 deletions(-) diff --git a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php index 635f4f2fce2..24844259573 100644 --- a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php @@ -190,7 +190,7 @@ public function readObjects() /** * Fetches the like data. * - * @return LikeObject[][] + * @return array{comment: LikeObject[], response?: LikeObject[]} */ public function getLikeData() { diff --git a/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php b/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php index 059101989f7..232153fea75 100644 --- a/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php +++ b/wcfsetup/install/files/lib/data/object/type/ObjectTypeCache.class.php @@ -17,31 +17,31 @@ class ObjectTypeCache extends SingletonFactory { /** * object type definitions - * @var ObjectTypeDefinition[] + * @var array */ protected $definitions = []; /** * object type definition ids grouped by category name - * @var int[][] + * @var array> */ protected $definitionsByCategory = []; /** * object type definitions sorted by name - * @var ObjectTypeDefinition[] + * @var array */ protected $definitionsByName = []; /** * object types - * @var ObjectType[] + * @var array */ protected $objectTypes = []; /** * object types grouped by definition - * @var array + * @var array> */ protected $groupedObjectTypes = []; @@ -67,7 +67,7 @@ protected function init() * object type definition exists. * * @param int $definitionID - * @return ObjectTypeDefinition|null + * @return ?ObjectTypeDefinition */ public function getDefinition($definitionID) { @@ -79,7 +79,7 @@ public function getDefinition($definitionID) * such object type definition exists. * * @param string $definitionName - * @return ObjectTypeDefinition|null + * @return ?ObjectTypeDefinition */ public function getDefinitionByName($definitionName) { @@ -91,7 +91,7 @@ public function getDefinitionByName($definitionName) * category name is invalid. * * @param string $categoryName - * @return ObjectTypeDefinition[]|null + * @return ObjectTypeDefinition[]|null */ public function getDefinitionsByCategory($categoryName) { @@ -112,7 +112,7 @@ public function getDefinitionsByCategory($categoryName) * exists. * * @param int $objectTypeID - * @return ObjectType|null + * @return ?ObjectType */ public function getObjectType($objectTypeID) { @@ -123,7 +123,7 @@ public function getObjectType($objectTypeID) * Returns the list of object type with the given definition name. * * @param string $definitionName - * @return ObjectType[] + * @return array */ public function getObjectTypes($definitionName) { @@ -140,7 +140,7 @@ public function getObjectTypes($definitionName) * * @param string $definitionName * @param string $objectTypeName - * @return ObjectType|null + * @return ?ObjectType */ public function getObjectTypeByName($definitionName, $objectTypeName) { diff --git a/wcfsetup/install/files/lib/system/template/ACPTemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/ACPTemplateEngine.class.php index 0b8b48629ac..983e1dac828 100644 --- a/wcfsetup/install/files/lib/system/template/ACPTemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/ACPTemplateEngine.class.php @@ -33,6 +33,7 @@ protected function init() * Deletes all compiled acp templates. * * @param string $compileDir + * @return void */ public static function deleteCompiledACPTemplates($compileDir = '') { diff --git a/wcfsetup/install/files/lib/system/template/TemplateCompiler.class.php b/wcfsetup/install/files/lib/system/template/TemplateCompiler.class.php index ae0f5275a9b..ab59a386ce6 100644 --- a/wcfsetup/install/files/lib/system/template/TemplateCompiler.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateCompiler.class.php @@ -19,7 +19,8 @@ class TemplateCompiler extends TemplateScriptingCompiler * @param string $templateName * @param string $sourceContent * @param string $compiledFilename - * @param array $metaData + * @param array $metaData + * @return void */ public function compile($templateName, $sourceContent, $compiledFilename, $metaData) { @@ -46,7 +47,8 @@ public function compile($templateName, $sourceContent, $compiledFilename, $metaD * * @param string $templateName * @param string $filename - * @param string $content + * @param mixed[] $content + * @return void */ public function saveMetaData($templateName, $filename, $content) { diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index bfc318f6215..dee1cb60485 100755 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -4,6 +4,7 @@ use Laminas\Diactoros\Stream; use Psr\Http\Message\StreamInterface; +use wcf\data\template\group\TemplateGroup; use wcf\data\template\Template; use wcf\system\cache\builder\TemplateGroupCacheBuilder; use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder; @@ -11,6 +12,7 @@ use wcf\system\exception\SystemException; use wcf\system\Regex; use wcf\system\SingletonFactory; +use wcf\system\template\plugin\IBlockTemplatePlugin; use wcf\system\template\plugin\IPrefilterTemplatePlugin; use wcf\system\WCF; use wcf\util\DirectoryUtil; @@ -187,7 +189,7 @@ class TemplateEngine extends SingletonFactory /** * cached list of known template groups - * @var array + * @var array */ protected $templateGroupCache = []; @@ -240,8 +242,14 @@ class TemplateEngine extends SingletonFactory */ protected $environment = 'user'; + /** + * @var array + */ protected $pluginObjects = []; + /** + * @var list}> + */ protected $tagStack = []; private int $sharedTemplateGroupID; @@ -264,6 +272,7 @@ protected function init() * * @param string $abbreviation * @param string $templatePath + * @return void */ public function addApplication($abbreviation, $templatePath) { @@ -274,6 +283,7 @@ public function addApplication($abbreviation, $templatePath) * Sets active language id. * * @param int $languageID + * @return void */ public function setLanguageID($languageID) { @@ -282,6 +292,8 @@ public function setLanguageID($languageID) /** * Assigns some system variables. + * + * @return void */ protected function assignSystemVariables() { @@ -300,6 +312,7 @@ protected function assignSystemVariables() * * @param mixed $variable * @param mixed $value + * @return void */ public function assign($variable, $value = '') { @@ -321,6 +334,7 @@ public function assign($variable, $value = '') * * @param mixed $variable * @param mixed $value + * @return void */ public function append($variable, $value = '') { @@ -357,6 +371,7 @@ public function append($variable, $value = '') * * @param mixed $variable * @param mixed $value + * @return void */ public function prepend($variable, $value = '') { @@ -393,6 +408,7 @@ public function prepend($variable, $value = '') * * @param string $variable * @param mixed $value + * @return void */ public function assignByRef($variable, &$value) { @@ -403,6 +419,9 @@ public function assignByRef($variable, &$value) /** * Clears an assignment of template variables. + * + * @param string[] $variables + * @return void */ public function clearAssign(array $variables) { @@ -414,6 +433,8 @@ public function clearAssign(array $variables) /** * Clears assignment of all template variables. This should not be called * during runtime as it could leed to an unexpected behaviour. + * + * @return void */ public function clearAllAssign() { @@ -426,6 +447,7 @@ public function clearAllAssign() * @param string $templateName * @param string $application * @param bool $sendHeaders + * @return void */ public function display($templateName, $application = 'wcf', $sendHeaders = true) { @@ -565,37 +587,37 @@ public function getMetaDataFilename($templateName) * @param string $sourceFilename * @param string $compiledFilename * @param string $application - * @param array $metaData + * @param mixed[] $metaData * @return bool */ protected function isCompiled($templateName, $sourceFilename, $compiledFilename, $application, array $metaData) { if ($this->forceCompile || !\file_exists($compiledFilename)) { return false; - } else { - $sourceMTime = @\filemtime($sourceFilename); - $compileMTime = @\filemtime($compiledFilename); + } - if ($sourceMTime >= $compileMTime) { - return false; - } else { - // check for meta data - if (!empty($metaData['include'])) { - foreach ($metaData['include'] as $application => $includedTemplates) { - foreach ($includedTemplates as $includedTemplate) { - $includedTemplateFilename = $this->getSourceFilename($includedTemplate, $application); - $includedMTime = @\filemtime($includedTemplateFilename); - - if ($includedMTime >= $compileMTime) { - return false; - } - } + $sourceMTime = @\filemtime($sourceFilename); + $compileMTime = @\filemtime($compiledFilename); + + if ($sourceMTime >= $compileMTime) { + return false; + } + + // check for meta data + if (!empty($metaData['include'])) { + foreach ($metaData['include'] as $application => $includedTemplates) { + foreach ($includedTemplates as $includedTemplate) { + $includedTemplateFilename = $this->getSourceFilename($includedTemplate, $application); + $includedMTime = @\filemtime($includedTemplateFilename); + + if ($includedMTime >= $compileMTime) { + return false; } } - - return true; } } + + return true; } /** @@ -604,7 +626,8 @@ protected function isCompiled($templateName, $sourceFilename, $compiledFilename, * @param string $templateName * @param string $sourceFilename * @param string $compiledFilename - * @param array $metaData + * @param array{application: string, data: string[], filename: string} $metaData + * @return void */ protected function compileTemplate($templateName, $sourceFilename, $compiledFilename, array $metaData) { @@ -661,6 +684,8 @@ public function getPluginClassName($type, $tag) /** * Enables execution in sandbox. + * + * @return void */ public function enableSandbox() { @@ -673,6 +698,8 @@ public function enableSandbox() /** * Disables execution in sandbox. + * + * @return void */ public function disableSandbox() { @@ -690,7 +717,7 @@ public function disableSandbox() * * @param string $templateName * @param string $application - * @param array $variables + * @param array $variables * @param bool $sandbox enables execution in sandbox * @return string * @@ -723,6 +750,7 @@ public function fetch($templateName, $application = 'wcf', array $variables = [] /** * Returns the output of a template. * + * @param array $variables * @since 6.2 */ public function render(string $application, string $templateName, array $variables): string @@ -738,6 +766,7 @@ public function render(string $application, string $templateName, array $variabl \ob_start(); $this->display($templateName, $application, false); $output = \ob_get_contents(); + \assert($output !== false); } finally { \ob_end_clean(); } @@ -750,6 +779,7 @@ public function render(string $application, string $templateName, array $variabl /** * Renders the template into a fresh PSR-7 StreamInterface. * + * @param array $variables * @since 6.0 */ public function fetchStream( @@ -797,7 +827,7 @@ public function fetchStream( * Executes a compiled template scripting source and returns the result. * * @param string $compiledSource - * @param array $variables + * @param array $variables * @param bool $sandbox enables execution in sandbox * @return string */ @@ -831,6 +861,7 @@ public function fetchString($compiledSource, array $variables = [], $sandbox = t * Deletes all compiled templates. * * @param string $compileDir + * @return void */ public static function deleteCompiledTemplates($compileDir = '') { @@ -866,6 +897,7 @@ public function getTemplateGroupID() * Sets the active template group id. * * @param int $templateGroupID + * @return void */ public function setTemplateGroupID($templateGroupID) { @@ -878,6 +910,8 @@ public function setTemplateGroupID($templateGroupID) /** * Loads cached template group information. + * + * @return void */ protected function loadTemplateGroupCache() { @@ -888,6 +922,7 @@ protected function loadTemplateGroupCache() * Registers prefilters. * * @param string[] $prefilters + * @return void */ public function registerPrefilter(array $prefilters) { @@ -900,6 +935,7 @@ public function registerPrefilter(array $prefilters) * Removes a prefilter by its internal name. * * @param string $name internal prefilter identifier + * @return void */ public function removePrefilter($name) { @@ -910,6 +946,7 @@ public function removePrefilter($name) * Sets the dir for the compiled templates. * * @param string $compileDir + * @return void * @throws SystemException */ public function setCompileDir($compileDir) @@ -926,8 +963,9 @@ public function setCompileDir($compileDir) * * @param string $templateName * @param string $application - * @param array $variables + * @param array $variables * @param bool $sandbox enables execution in sandbox + * @return void */ protected function includeTemplate($templateName, $application, array $variables = [], $sandbox = true) { @@ -965,6 +1003,8 @@ public function get($varname) /** * Loads template listener code. + * + * @return void */ protected function loadTemplateListenerCode() { @@ -1004,7 +1044,7 @@ public function getTemplateListenerCode($templateName, $eventName) * * @param string $templateName * @param string $filename - * @return array|null + * @return mixed[]|null */ protected function getMetaData($templateName, $filename) { diff --git a/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php b/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php index 070fea954d1..7d66d4969cb 100644 --- a/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php @@ -206,7 +206,7 @@ class TemplateScriptingCompiler /** * stack used to compile the capture tag - * @var array + * @var list */ protected $captureStack = []; @@ -273,10 +273,10 @@ public function __construct(TemplateEngine $template) * * @param string $identifier * @param string $sourceContent - * @param array $metaData + * @param array $metaData * @param bool $isolated - * @return array|bool - * @throws SystemException + * @return array{meta: array{include: string[][]}, template: string}|bool + * @throws SystemException */ public function compileString($identifier, $sourceContent, array $metaData = [], $isolated = false) { @@ -393,7 +393,7 @@ public function compileString($identifier, $sourceContent, array $metaData = [], * * @param string $tag * @param string $identifier - * @param array $metaData + * @param string[] $metaData * @return string * @throws SystemException * @phpstan-impure @@ -967,7 +967,7 @@ protected function compileForeachEndTag() * * @param string $includeTag * @param string $identifier - * @param array $metaData + * @param string[] $metaData * @return string * @throws SystemException */ @@ -1026,7 +1026,9 @@ protected function compileIncludeTag($includeTag, $identifier, array $metaData) unset($args['sandbox']); } - $sandbox = ($sandbox === 'true' || $sandbox === true || $sandbox == 1); + if (\is_string($sandbox)) { + $sandbox = $sandbox === 'true' || $sandbox === '1'; + } $staticInclude = true; if ( @@ -1124,7 +1126,7 @@ protected function compileIncludeTag($includeTag, $identifier, array $metaData) * * @param string $tagArgs * @param string $tag - * @return array + * @return array * @throws SystemException */ public function parseTagArgs($tagArgs, $tag) @@ -1177,7 +1179,7 @@ public function parseTagArgs($tagArgs, $tag) * Takes an array created by TemplateCompiler::parseTagArgs() and creates * a string. * - * @param array $args + * @param array $args * @return string $args */ public static function makeArgString($args) @@ -1433,7 +1435,7 @@ protected function compileSimpleVariable($variable, $type = '', $allowConstants /** * Compiles a modifier tag and returns the compiled PHP code. * - * @param array $data + * @param array{className: string, parameter: list}|array{name: string, parameter: list} $data * @return string */ protected function compileModifier($data) @@ -1889,6 +1891,8 @@ public function compileVariableTag($tag, $replaceQuotes = true) /** * Generates the regexp pattern. + * + * @return void */ protected function buildPattern() { diff --git a/wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php index a74be2a27fb..25ec05e8e1e 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php @@ -19,7 +19,7 @@ class CounterFunctionTemplatePlugin implements IFunctionTemplatePlugin { /** * counter data - * @var array + * @var array */ protected $counters = []; diff --git a/wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php index 2e7c60f06ac..fb3af0f3e08 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php @@ -19,7 +19,7 @@ class CycleFunctionTemplatePlugin implements IFunctionTemplatePlugin { /** * cycle data - * @var array + * @var array> */ protected $cycles = []; diff --git a/wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php index 96356617542..01c0eea0eac 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php @@ -47,7 +47,7 @@ public function execute($templateName, $sourceContent, TemplateScriptingCompiler * the content during runtime, safely determining whether content is empty * or not. * - * @param array $matches + * @param array{before: string, content: string, after: string, else?: string, assign?: string} $matches * @return string */ protected static function replaceContentCallback(array $matches) diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php index 2e952dade4b..a9b1b4981d6 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php @@ -106,7 +106,7 @@ public function execute($tagArgs, TemplateEngine $tplObj) * Makes the HTML for an option group. * * @param ?string $key - * @param array|DatabaseObjectList $values + * @param array>|DatabaseObjectList $values * @return string */ protected function makeOptionGroup($key, $values) diff --git a/wcfsetup/install/files/lib/system/template/plugin/IBlockTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/IBlockTemplatePlugin.class.php index dd634579cd0..9fd8e4f1565 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/IBlockTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/IBlockTemplatePlugin.class.php @@ -16,7 +16,7 @@ interface IBlockTemplatePlugin /** * Executes this template block. * - * @param array $tagArgs + * @param array $tagArgs * @param string $blockContent * @param TemplateEngine $tplObj * @return string @@ -26,8 +26,9 @@ public function execute($tagArgs, $blockContent, TemplateEngine $tplObj); /** * Initialises this template block. * - * @param array $tagArgs + * @param array $tagArgs * @param TemplateEngine $tplObj + * @return void */ public function init($tagArgs, TemplateEngine $tplObj); diff --git a/wcfsetup/install/files/lib/system/template/plugin/ICompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/ICompilerTemplatePlugin.class.php index cdae58cb3e6..783c5cc4117 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/ICompilerTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/ICompilerTemplatePlugin.class.php @@ -16,7 +16,7 @@ interface ICompilerTemplatePlugin /** * Executes the start tag of this compiler function. * - * @param array $tagArgs + * @param array $tagArgs * @param TemplateScriptingCompiler $compiler * @return string */ diff --git a/wcfsetup/install/files/lib/system/template/plugin/IFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/IFunctionTemplatePlugin.class.php index f1a0c643a42..7b234700b9c 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/IFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/IFunctionTemplatePlugin.class.php @@ -16,7 +16,7 @@ interface IFunctionTemplatePlugin /** * Executes this template function. * - * @param array $tagArgs + * @param array $tagArgs * @param TemplateEngine $tplObj * @return string */ diff --git a/wcfsetup/install/files/lib/system/template/plugin/IModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/IModifierTemplatePlugin.class.php index 510d9280ae5..d752ff03ae0 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/IModifierTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/IModifierTemplatePlugin.class.php @@ -17,7 +17,7 @@ interface IModifierTemplatePlugin /** * Executes this modifier. * - * @param array $tagArgs + * @param array $tagArgs * @param TemplateEngine $tplObj * @return string */ diff --git a/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php index d32d16138f9..7c10984fd70 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php @@ -84,6 +84,8 @@ public function execute($tagArgs, TemplateEngine $tplObj) * This extra step is required because the existing implementation for * plurals resolved the category and then picked the appropriate value * itself. + * + * @param array $values */ private function createMessageFromValues(array $values): string { diff --git a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php index 00d743d5dfc..259065e8d90 100644 --- a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php +++ b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php @@ -66,6 +66,7 @@ public function getGroupedObjectTypes() * Assign trophies based on rules. * * @param int $maxAssigns + * @return void */ public function assignTrophies($maxAssigns = 500) { @@ -99,6 +100,7 @@ public function assignTrophies($maxAssigns = 500) * Revoke user trophies which are not longer fulfills the conditions. * * @param int $maxRevokes + * @return void * @since 5.2 */ public function revokeTrophies($maxRevokes = 500) diff --git a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php index 0e83c05a723..96e99de2335 100644 --- a/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/DefaultUploadFileSaveStrategy.class.php @@ -40,7 +40,7 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy /** * additional data stored with the default file data - * @var array + * @var mixed[] */ public $data = []; @@ -56,7 +56,7 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy * - bool rotateImages: if true, images are automatically rotated * - bool generateThumbnails: if true, thumbnails are automatically generated after saving file * - * @var array + * @var mixed[] */ public $options = []; @@ -64,8 +64,8 @@ class DefaultUploadFileSaveStrategy implements IUploadFileSaveStrategy * Creates a new instance of DefaultUploadFileSaveStrategy. * * @param string $actionClassName - * @param array $options - * @param array $data + * @param mixed[] $options + * @param mixed[] $data * @throws ImplementationException * @throws ParentClassException */ @@ -287,6 +287,7 @@ public function save(UploadFile $uploadFile) * Generates thumbnails for the given file. * * @param IThumbnailFile $file + * @return void */ public function generateThumbnails(IThumbnailFile $file) { diff --git a/wcfsetup/install/files/lib/system/upload/IUploadFileSaveStrategy.class.php b/wcfsetup/install/files/lib/system/upload/IUploadFileSaveStrategy.class.php index 887500124aa..3c4abcee61c 100644 --- a/wcfsetup/install/files/lib/system/upload/IUploadFileSaveStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/IUploadFileSaveStrategy.class.php @@ -15,6 +15,7 @@ interface IUploadFileSaveStrategy * Saves the given file. * * @param UploadFile $uploadFile + * @return void */ public function save(UploadFile $uploadFile); } diff --git a/wcfsetup/install/files/lib/system/upload/UploadFile.class.php b/wcfsetup/install/files/lib/system/upload/UploadFile.class.php index 1564dbe82e2..84c475e8796 100644 --- a/wcfsetup/install/files/lib/system/upload/UploadFile.class.php +++ b/wcfsetup/install/files/lib/system/upload/UploadFile.class.php @@ -55,7 +55,7 @@ class UploadFile /** * additional data for validation errors - * @var array + * @var mixed[] */ protected $validationErrorAdditionalData = []; @@ -184,7 +184,8 @@ public function getErrorCode() * Sets the validation error type. * * @param string $validationErrorType - * @param array $additionalData + * @param mixed[] $additionalData + * @return void */ public function setValidationErrorType($validationErrorType, array $additionalData = []) { @@ -205,7 +206,7 @@ public function getValidationErrorType() /** * Returns the validation error additional data array. * - * @return array + * @return mixed[] */ public function getValidationErrorAdditionalData() { @@ -215,7 +216,7 @@ public function getValidationErrorAdditionalData() /** * Returns the image data of the file or `null` if the file is no image. * - * @return array|null + * @return array{width: int, height: int, mimeType: string}|null */ public function getImageData() { @@ -235,6 +236,7 @@ public function getImageData() * and the internal filename value to the new filename derived from the given location. * * @param string $newLocation new file location + * @return void */ public function moveUploadedFile($newLocation) { diff --git a/wcfsetup/install/files/lib/system/upload/UploadHandler.class.php b/wcfsetup/install/files/lib/system/upload/UploadHandler.class.php index 8993b22af4f..f242555718b 100644 --- a/wcfsetup/install/files/lib/system/upload/UploadHandler.class.php +++ b/wcfsetup/install/files/lib/system/upload/UploadHandler.class.php @@ -21,7 +21,7 @@ class UploadHandler /** * list of validation errors. - * @var array + * @var UploadFile[] */ protected $erroneousFiles = []; @@ -123,6 +123,7 @@ public function getErroneousFiles() * Saves the uploaded files. * * @param IUploadFileSaveStrategy $saveStrategy + * @return void */ public function saveFiles(IUploadFileSaveStrategy $saveStrategy) { diff --git a/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php b/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php index 48d141b6eef..b007d2ac28c 100644 --- a/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php +++ b/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php @@ -12,6 +12,7 @@ * @author Alexander Ebert * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License + * @implements \Iterator */ class GroupedUserList implements \Countable, \Iterator { diff --git a/wcfsetup/install/files/lib/system/user/UserBirthdayCache.class.php b/wcfsetup/install/files/lib/system/user/UserBirthdayCache.class.php index 009ef4ef2af..65cfc490a78 100644 --- a/wcfsetup/install/files/lib/system/user/UserBirthdayCache.class.php +++ b/wcfsetup/install/files/lib/system/user/UserBirthdayCache.class.php @@ -31,6 +31,7 @@ class UserBirthdayCache extends SingletonFactory * Loads the birthday cache. * * @param int $month + * @return void */ protected function loadMonth($month) { diff --git a/wcfsetup/install/files/lib/system/user/UserProfileHandler.class.php b/wcfsetup/install/files/lib/system/user/UserProfileHandler.class.php index 17cd56d5eeb..6a7b6a225c0 100644 --- a/wcfsetup/install/files/lib/system/user/UserProfileHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/UserProfileHandler.class.php @@ -37,7 +37,7 @@ protected function init() * Delegates method calls to the user profile object. * * @param string $name - * @param array $arguments + * @param mixed[] $arguments * @return mixed */ public function __call($name, $arguments) @@ -59,6 +59,8 @@ public function __get($name) /** * Reloads the user profile object with data directly from the database. + * + * @return void */ public function reloadUserProfile() { diff --git a/wcfsetup/install/files/lib/system/user/activity/event/IUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/IUserActivityEvent.class.php index 2bc68946479..75341a8fd1d 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/IUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/IUserActivityEvent.class.php @@ -17,6 +17,7 @@ interface IUserActivityEvent * Prepares a list of events for output. * * @param ViewableUserActivityEvent[] $events + * @return void */ public function prepare(array $events); } diff --git a/wcfsetup/install/files/lib/system/user/activity/event/TCommentResponseUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/TCommentResponseUserActivityEvent.class.php index 24d6642fd8c..4aeb542f2a3 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/TCommentResponseUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/TCommentResponseUserActivityEvent.class.php @@ -51,6 +51,7 @@ trait TCommentResponseUserActivityEvent * Reads the data of the comment responses the given events belong to. * * @param ViewableUserActivityEvent[] $events + * @return void */ protected function readResponseData(array $events) { diff --git a/wcfsetup/install/files/lib/system/user/activity/event/UserActivityEventHandler.class.php b/wcfsetup/install/files/lib/system/user/activity/event/UserActivityEventHandler.class.php index 49d7d0a4842..4842c9c5dbb 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/UserActivityEventHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/UserActivityEventHandler.class.php @@ -69,7 +69,7 @@ public function getObjectTypeID($objectType) * @param int $languageID * @param int $userID * @param int $time - * @param array $additionalData + * @param mixed[] $additionalData * @return \wcf\data\user\activity\event\UserActivityEvent * @throws SystemException */ @@ -111,7 +111,8 @@ public function fireEvent( * This method is intended for bulk processing. * * @param string $objectType - * @param array $eventData + * @param mixed[] $eventData + * @return void * @throws SystemException */ public function fireEvents($objectType, array $eventData) @@ -155,6 +156,7 @@ public function fireEvents($objectType, array $eventData) * @param string $objectType * @param int $objectID * @param int $userID + * @return void * @throws SystemException */ public function removeEvent($objectType, $objectID, $userID = null) @@ -185,6 +187,7 @@ public function removeEvent($objectType, $objectID, $userID = null) * * @param string $objectType * @param int[] $objectIDs + * @return void * @throws SystemException */ public function removeEvents($objectType, array $objectIDs) @@ -211,7 +214,7 @@ public function removeEvents($objectType, array $objectIDs) /** * Validates an event list and removes orphaned events. * - * @param ViewableUserActivityEventList $eventList + * @return void */ public static function validateEvents(ViewableUserActivityEventList $eventList) { diff --git a/wcfsetup/install/files/lib/system/user/activity/point/UserActivityPointHandler.class.php b/wcfsetup/install/files/lib/system/user/activity/point/UserActivityPointHandler.class.php index a70c8229a88..b720ba3d688 100644 --- a/wcfsetup/install/files/lib/system/user/activity/point/UserActivityPointHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/point/UserActivityPointHandler.class.php @@ -52,6 +52,7 @@ protected function init() * @param int $objectID * @param int $userID * @param mixed[] $additionalData + * @return void * @throws InvalidObjectTypeException * @throws SystemException */ @@ -110,6 +111,7 @@ public function fireEvent($objectType, $objectID, $userID = null, array $additio * @param string $objectType * @param int[] $itemsToUser * @param bool $updateUsers + * @return void * @throws InvalidObjectTypeException */ public function fireEvents($objectType, array $itemsToUser, $updateUsers = true) @@ -165,6 +167,7 @@ public function fireEvents($objectType, array $itemsToUser, $updateUsers = true) * * @param string $objectType * @param int[] $userToItems + * @return void * @throws InvalidObjectTypeException */ public function removeEvents($objectType, array $userToItems) @@ -204,6 +207,7 @@ public function removeEvents($objectType, array $userToItems) * Updates total activity points and ranks for given user ids. * * @param int[] $userIDs + * @return void */ public function updateUsers(array $userIDs) { @@ -230,6 +234,7 @@ public function updateUsers(array $userIDs) * Resets activity points and items for a given object type. * * @param string $objectType + * @return void * @throws InvalidObjectTypeException */ public function reset($objectType) @@ -280,6 +285,7 @@ public function getObjectTypeByName($objectType) * Updates the user ranks for the given users. * * @param int[] $userIDs + * @return void */ protected function updateUserRanks(array $userIDs) { diff --git a/wcfsetup/install/files/lib/system/user/authentication/DefaultUserAuthentication.class.php b/wcfsetup/install/files/lib/system/user/authentication/DefaultUserAuthentication.class.php index f91b30fdd75..0e7c1a3a380 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/DefaultUserAuthentication.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/DefaultUserAuthentication.class.php @@ -15,6 +15,7 @@ class DefaultUserAuthentication extends AbstractUserAuthentication { /** + * @return false * @deprecated 5.4 - This method always returns false, as the legacy automated login was removed. */ public function supportsPersistentLogins() @@ -23,6 +24,9 @@ public function supportsPersistentLogins() } /** + * @param string $username + * @param string $password + * @return void * @deprecated 5.4 - This method is a noop, as user sessions are long-lived now. */ public function storeAccessData(User $user, $username, $password) @@ -55,6 +59,9 @@ public function loginManually( } /** + * @param bool $persistent + * @param string $userClassname + * @return void * @deprecated 5.4 - This method always returns null, as user sessions are long-lived now. */ public function loginAutomatically($persistent = false, $userClassname = User::class) @@ -73,6 +80,10 @@ protected function getUserByLogin($login) } /** + * @param int $userID + * @param string $password + * @param string $userClassname + * @return void * @deprecated 5.4 - This method always returns null, as user sessions are long-lived now. */ protected function getUserAutomatically($userID, $password, $userClassname = User::class) @@ -80,6 +91,9 @@ protected function getUserAutomatically($userID, $password, $userClassname = Use } /** + * @param string $user + * @param string $password + * @return false * @deprecated 5.4 - This method always returns false, as user sessions are long-lived now. */ protected function checkCookiePassword($user, $password) diff --git a/wcfsetup/install/files/lib/system/user/authentication/oauth/User.class.php b/wcfsetup/install/files/lib/system/user/authentication/oauth/User.class.php index 916d13f981e..dfdfa7660e2 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/oauth/User.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/oauth/User.class.php @@ -9,11 +9,18 @@ * @copyright 2001-2021 WoltLab GmbH * @license GNU Lesser General Public License * @since 5.4 + * @implements \ArrayAccess */ final class User implements \ArrayAccess { - private $data = []; + /** + * @var array + */ + private array $data = []; + /** + * @param array $data + */ public function __construct(array $data) { if (empty($data['__id'])) { diff --git a/wcfsetup/install/files/lib/system/user/authentication/oauth/exception/StateValidationException.class.php b/wcfsetup/install/files/lib/system/user/authentication/oauth/exception/StateValidationException.class.php index 97c6dcd7f52..65f2ddbafa6 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/oauth/exception/StateValidationException.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/oauth/exception/StateValidationException.class.php @@ -12,7 +12,7 @@ */ final class StateValidationException extends \UnexpectedValueException { - public function __construct($message, ?\Throwable $previous = null) + public function __construct(string $message, ?\Throwable $previous = null) { parent::__construct($message, 0, $previous); } diff --git a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Bcrypt.class.php b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Bcrypt.class.php index 0c7c48137bb..6f5789c1ad0 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Bcrypt.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Bcrypt.class.php @@ -14,10 +14,7 @@ */ final class Bcrypt implements IPasswordAlgorithm { - /** - * @var int - */ - private $cost; + private int $cost; /** * @param int $cost The BCrypt 'cost' option for newly created hashes. It is recommended not to change this option. @@ -71,8 +68,10 @@ public function needsRehash(string $hash): bool /** * Returns the value to be used for password_*'s `$options` parameter. + * + * @return array{cost: int} */ - private function getOptions() + private function getOptions(): array { return [ 'cost' => $this->cost, diff --git a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/DoubleBcrypt.class.php b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/DoubleBcrypt.class.php index 407263e05b2..31be718f4cd 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/DoubleBcrypt.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/DoubleBcrypt.class.php @@ -15,7 +15,7 @@ */ final class DoubleBcrypt implements IPasswordAlgorithm { - private static $blowfishCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; + private static string $blowfishCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; /** * blowfish cost factor @@ -68,16 +68,12 @@ public static function isLegacyDoubleBcrypt(string $hash): bool /** * Returns a double salted bcrypt hash. - * - * @param string $password - * @param string $salt - * @return string */ private static function getDoubleSaltedHash( #[\SensitiveParameter] - $password, - $salt = null - ) { + string $password, + ?string $salt = null + ): string { if ($salt === null) { $salt = self::getRandomSalt(); } @@ -87,16 +83,12 @@ private static function getDoubleSaltedHash( /** * Returns a simple salted bcrypt hash. - * - * @param string $password - * @param string $salt - * @return string */ private static function getSaltedHash( #[\SensitiveParameter] - $password, - $salt = null - ) { + string $password, + ?string $salt = null + ): string { if ($salt === null) { $salt = self::getRandomSalt(); } @@ -106,10 +98,8 @@ private static function getSaltedHash( /** * Returns a random blowfish-compatible salt. - * - * @return string */ - private static function getRandomSalt() + private static function getRandomSalt(): string { $salt = ''; @@ -122,11 +112,8 @@ private static function getRandomSalt() /** * Returns a blowfish salt, e.g. $2a$07$usesomesillystringforsalt$ - * - * @param string $salt - * @return string */ - private static function getSalt($salt) + private static function getSalt(string $salt): string { $salt = \mb_substr($salt, 0, 22, '8bit'); @@ -135,11 +122,8 @@ private static function getSalt($salt) /** * Returns true if given bcrypt hash uses a different cost factor and should be re-computed. - * - * @param string $hash - * @return bool */ - private static function isDifferentBlowfish($hash) + private static function isDifferentBlowfish(string $hash): bool { $currentCost = \intval(self::BCRYPT_COST); $hashCost = \intval(\mb_substr($hash, 4, 2, '8bit')); diff --git a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/TPhpass.class.php b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/TPhpass.class.php index 1878caa6f39..0309db29fea 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/TPhpass.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/TPhpass.class.php @@ -14,7 +14,7 @@ */ trait TPhpass { - private $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + private string $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; /** * Returns the hashed password, with the given settings. diff --git a/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php b/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php index 70bdf0c1edf..cc38435731b 100644 --- a/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php @@ -223,6 +223,7 @@ public function markAsOpened(int $objectTypeID, string $objectID, ?int $userID = * Deletes all saved states for a specific object type. * * @param int $objectTypeID + * @return void */ public function reset($objectTypeID) { @@ -258,6 +259,7 @@ public function reset($objectTypeID) * * @param string $objectType * @param int $objectID + * @return void * @throws InvalidObjectTypeException */ public function resetAll($objectType, $objectID = null) diff --git a/wcfsetup/install/files/lib/system/user/command/SetAvatar.class.php b/wcfsetup/install/files/lib/system/user/command/SetAvatar.class.php index b77ee30e6be..e4bbd648c4b 100644 --- a/wcfsetup/install/files/lib/system/user/command/SetAvatar.class.php +++ b/wcfsetup/install/files/lib/system/user/command/SetAvatar.class.php @@ -25,10 +25,9 @@ final class SetAvatar public function __construct( private readonly User $user, private readonly ?File $file = null - ) { - } + ) {} - public function __invoke() + public function __invoke(): void { if ($this->file === null && $this->user->avatarFileID !== null) { (new FileAction([$this->user->avatarFileID], 'delete'))->executeAction(); diff --git a/wcfsetup/install/files/lib/system/user/content/provider/IUserContentProvider.class.php b/wcfsetup/install/files/lib/system/user/content/provider/IUserContentProvider.class.php index 85b7fcf07f8..cc1f2dce619 100644 --- a/wcfsetup/install/files/lib/system/user/content/provider/IUserContentProvider.class.php +++ b/wcfsetup/install/files/lib/system/user/content/provider/IUserContentProvider.class.php @@ -27,6 +27,7 @@ public function getContentListForUser(User $user); * Delete the content for the given object ids. * * @param int[] $objectIDs + * @return void */ public function deleteContent(array $objectIDs); } diff --git a/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php b/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php index 724467a8708..affd2528056 100644 --- a/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php @@ -34,6 +34,7 @@ class UserGroupAssignmentHandler extends SingletonFactory * on purpose to make sure the latest data of the users are fetched. * * @param int[] $userIDs + * @return void */ public function checkUsers(array $userIDs) { diff --git a/wcfsetup/install/files/lib/system/user/group/command/CopyUserGroup.class.php b/wcfsetup/install/files/lib/system/user/group/command/CopyUserGroup.class.php index 3e73ecb5492..0ee849fcb77 100644 --- a/wcfsetup/install/files/lib/system/user/group/command/CopyUserGroup.class.php +++ b/wcfsetup/install/files/lib/system/user/group/command/CopyUserGroup.class.php @@ -26,7 +26,7 @@ public function __construct( ) { } - public function __invoke() + public function __invoke(): UserGroup { // fetch user group option values if ($this->copyUserGroupOptions) { diff --git a/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php index 1c7eff7ae90..9a6c36b8a51 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php @@ -173,6 +173,8 @@ static function (ButtonFormField $field) { /** * Generates a list of codes. + * + * @return array */ private function generateCodes(): array { @@ -199,6 +201,7 @@ private function generateCodes(): array /** * @inheritDoc + * @return array */ public function processManagementForm(IFormDocument $form, Setup $setup): array { @@ -232,6 +235,9 @@ public function processManagementForm(IFormDocument $form, Setup $setup): array /** * Returns a code from $codes matching the $userCode. `null` is returned if * no matching code could be found. + * + * @param mixed[][] $codes + * @return mixed[]|null */ private function findValidCode(string $userCode, array $codes): ?array { @@ -348,6 +354,8 @@ public function processAuthenticationForm(IFormDocument $form, Setup $setup): vo /** * Notifies the user that an backup code has been used. + * + * @param mixed[] $usedCode */ private function sendAuthenticationEmail(Setup $setup, array $usedCode): void { diff --git a/wcfsetup/install/files/lib/system/user/multifactor/EmailMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/EmailMultifactorMethod.class.php index 81beaee932f..c6c0297cb6b 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/EmailMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/EmailMultifactorMethod.class.php @@ -95,6 +95,9 @@ public function processManagementForm(IFormDocument $form, Setup $setup): void /** * Returns a code from $codes matching the $userCode. `null` is returned if * no matching code could be found. + * + * @param mixed[][] $codes + * @return mixed[] */ private function findValidCode(string $userCode, array $codes): ?array { diff --git a/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php index ed34acd680b..3d185c557c5 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php @@ -23,6 +23,8 @@ public function getStatusText(Setup $setup): string; /** * Populates the form to set-up and manage this method. + * + * @param ?mixed $returnData */ public function createManagementForm(IFormDocument $form, ?Setup $setup, $returnData = null): void; diff --git a/wcfsetup/install/files/lib/system/user/multifactor/Setup.class.php b/wcfsetup/install/files/lib/system/user/multifactor/Setup.class.php index 8859669ae22..f02df7fbad2 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/Setup.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/Setup.class.php @@ -20,12 +20,15 @@ final class Setup implements IIDObject { /** - * @var array + * @var mixed[] */ - private $row; + private array $row; - private $isDeleted = false; + private bool $isDeleted = false; + /** + * @param mixed[] $row + */ private function __construct(array $row) { $this->row = $row; diff --git a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php index 7540a6cb1e2..7daf2e1c3c8 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php @@ -140,6 +140,7 @@ public function createManagementForm(IFormDocument $form, ?Setup $setup, $return } else { $button = new class extends FormButton { + /** @var string */ protected $templateName = '__multifactorTotpDeviceNoDeleteButton'; }; $button->id('no-delete-' . $row['deviceID']) @@ -155,6 +156,7 @@ public function createManagementForm(IFormDocument $form, ?Setup $setup, $return /** * @inheritDoc + * @return array{action: string, deviceName: string} */ public function processManagementForm(IFormDocument $form, Setup $setup): array { diff --git a/wcfsetup/install/files/lib/system/user/multifactor/totp/CodeFormField.class.php b/wcfsetup/install/files/lib/system/user/multifactor/totp/CodeFormField.class.php index b001aaab209..c146a956afc 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/totp/CodeFormField.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/totp/CodeFormField.class.php @@ -56,6 +56,7 @@ public function minCounter(int $minCounter): static /** * @inheritDoc + * @return array{value: mixed, minCounter: number} */ public function getSaveValue(): array { diff --git a/wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php b/wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php index 71ebf44cd15..2ccf62252c1 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php @@ -26,12 +26,13 @@ class DeviceNode implements IFormChildNode, IFormParentNode } /** - * @var ?array + * @var (string|int)[]|null */ protected $data; /** * @inheritDoc + * @var string */ protected $templateName = '__multifactorTotpDeviceNode'; @@ -53,6 +54,7 @@ public function getHtml(): string /** * Sets the device data. * + * @param (string|int)[] $device * @return $this */ public function setData(array $device): static diff --git a/wcfsetup/install/files/lib/system/user/notification/TestableUserNotificationEventHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/TestableUserNotificationEventHandler.class.php index 9d7148b273a..0fa93c6047f 100644 --- a/wcfsetup/install/files/lib/system/user/notification/TestableUserNotificationEventHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/TestableUserNotificationEventHandler.class.php @@ -187,7 +187,7 @@ public function getRecipient(?Language $language = null) * @param UserProfile $author * @param int $timesTriggered * @param int $guestTimesTriggered - * @param array $additionalData + * @param mixed[] $additionalData * @return UserNotification */ protected function getUserNotification( @@ -304,7 +304,7 @@ public function getUserNotificationEvents(UserNotificationEvent $userNotificatio * data within the same request. This is crucial as during testing, objects * are created and used within the same request. * - * @param ICacheBuilder $cacheBuilder + * @return void */ public function resetCacheBuilder(ICacheBuilder $cacheBuilder) { diff --git a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php index 86b26723da9..ea67829e387 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -92,6 +92,7 @@ protected function init() * @param mixed[] $additionalData * @param int $baseObjectID * @param int $contentLanguageID + * @return void * @throws SystemException */ public function fireEvent( @@ -416,7 +417,7 @@ public function getNotifications($limit = 5, $offset = 0, $showConfirmedNotifica * Returns a mixed list of notifications, containing leading unconfirmed notifications in their chronological * order regardless of the overall order of already confirmed items. * - * @return array + * @return mixed[] */ public function getMixedNotifications() { @@ -747,6 +748,7 @@ public function getObjectTypeProcessor($objectType) * @param UserNotification $notification * @param User $user * @param IUserNotificationEvent $event + * @return void */ public function sendInstantMailNotification( UserNotification $notification, @@ -856,8 +858,8 @@ public function sendInstantMailNotification( * @param string $objectType * @param int[] $recipientIDs * @param int[] $objectIDs + * @return void * @deprecated - * */ public function deleteNotifications($eventName, $objectType, array $recipientIDs, array $objectIDs = []) { @@ -869,6 +871,7 @@ public function deleteNotifications($eventName, $objectType, array $recipientIDs * * @param string $objectType * @param int[] $objectIDs + * @return void * @throws SystemException */ public function removeNotifications($objectType, array $objectIDs) @@ -930,6 +933,7 @@ public function removeNotifications($objectType, array $objectIDs) * @param string $objectType * @param int[] $recipientIDs * @param int[] $objectIDs + * @return void * @throws SystemException */ public function markAsConfirmed($eventName, $objectType, array $recipientIDs, array $objectIDs = []) @@ -985,6 +989,7 @@ public function markAsConfirmed($eventName, $objectType, array $recipientIDs, ar * Marks a single notification id as confirmed. * * @param int $notificationID + * @return void * @deprecated 5.2 Please use `UserNotificationHandler::markAsConfirmedByIDs()` instead. */ public function markAsConfirmedByID($notificationID) @@ -996,6 +1001,7 @@ public function markAsConfirmedByID($notificationID) * Marks a list of notification ids as confirmed. * * @param int[] $notificationIDs + * @return void */ public function markAsConfirmedByIDs(array $notificationIDs) { @@ -1031,7 +1037,7 @@ public function markAsConfirmedByIDs(array $notificationIDs) * * @param string $objectType * @param string $eventName - * @return mixed + * @return int|false */ public function getEventSetting($objectType, $eventName) { diff --git a/wcfsetup/install/files/lib/system/user/notification/event/AbstractSharedUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/AbstractSharedUserNotificationEvent.class.php index 1ea082da7c9..8555eb2d832 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/AbstractSharedUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/AbstractSharedUserNotificationEvent.class.php @@ -32,6 +32,8 @@ public function setObject( /** * Provide specialized handlers with object ids, these ids will be collected and should be * read once the first time data is requested from the notification event. + * + * @return void */ abstract protected function prepare(); } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ArticleLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ArticleLikeUserNotificationEvent.class.php index c204fbdd4a8..3a8d563527e 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ArticleLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ArticleLikeUserNotificationEvent.class.php @@ -153,6 +153,7 @@ public function isVisible() /** * @inheritDoc + * @return LikeableArticle */ protected static function createTestLikeObject(UserProfile $recipient, UserProfile $author) { @@ -163,6 +164,7 @@ protected static function createTestLikeObject(UserProfile $recipient, UserProfi /** * @inheritDoc + * @return string */ protected static function getTestLikeableObjectTypeName() { diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ITestableUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ITestableUserNotificationEvent.class.php index 70541c00a5a..0eea0c0c776 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ITestableUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ITestableUserNotificationEvent.class.php @@ -34,6 +34,7 @@ public function getTestCaseDescription(); * Sets the description of the covered test case. * * @param string $description + * @return void */ public function setTestCaseDescription($description); @@ -47,7 +48,7 @@ public static function canBeTriggeredByGuests(); * The test data has to be the same data given when an actual event is fired. * * @param IUserNotificationObject $object - * @return array + * @return mixed[] */ public static function getTestAdditionalData(IUserNotificationObject $object); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php index 8ec29df982d..6f212b4ae14 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php @@ -105,6 +105,7 @@ public function isVisible(); * Sets a list of authors for stacked notifications. * * @param UserProfile[] $authors + * @return void */ public function setAuthors(array $authors); @@ -121,7 +122,8 @@ public function getEventHash(); * @param UserNotification $notification * @param IUserNotificationObject $object * @param UserProfile $author - * @param array $additionalData + * @param mixed[] $additionalData + * @return void */ public function setObject( UserNotification $notification, @@ -134,6 +136,7 @@ public function setObject( * Sets the language for the event * * @param Language $language + * @return void */ public function setLanguage(Language $language); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php index f80e501147f..af1f977be27 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php @@ -207,6 +207,7 @@ public static function canBeTriggeredByGuests() /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php index 41cf6597a0f..31ae286a715 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php @@ -169,6 +169,7 @@ public static function canBeTriggeredByGuests() /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/PageCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/PageCommentResponseUserNotificationEvent.class.php index 0f1e1216331..15d476c08e0 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/PageCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/PageCommentResponseUserNotificationEvent.class.php @@ -134,6 +134,7 @@ protected function getObjectTitle(): string /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) { diff --git a/wcfsetup/install/files/lib/system/user/notification/event/PageCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/PageCommentUserNotificationEvent.class.php index 868faa35bf2..76d6f60a481 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/PageCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/PageCommentUserNotificationEvent.class.php @@ -105,6 +105,7 @@ protected function getObjectTitle(): string /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) { diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php index f9d4493f849..cfa79c56ce6 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestableArticleCommentUserNotificationEvent.class.php @@ -23,6 +23,7 @@ trait TTestableArticleCommentUserNotificationEvent use TTestableCategorizedUserNotificationEvent; /** + * @return array{objectID: int, objectTypeID: ?int} * @see TTestableCommentUserNotificationEvent::createTestComment() */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCategorizedUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCategorizedUserNotificationEvent.class.php index 264e6c26852..5bbafe45f22 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCategorizedUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCategorizedUserNotificationEvent.class.php @@ -23,7 +23,7 @@ trait TTestableCategorizedUserNotificationEvent * Returns a newly created test category of the given object type. * * @param string $objectTypeName - * @param array $additionalData + * @param mixed[] $additionalData * @return Category */ protected static function createTestCategory($objectTypeName, array $additionalData = []) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentLikeUserNotificationEvent.class.php index 427061032ba..c6589f6df4c 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentLikeUserNotificationEvent.class.php @@ -26,6 +26,7 @@ trait TTestableCommentLikeUserNotificationEvent /** * @inheritDoc + * @return LikeableComment */ protected static function createTestLikeObject(UserProfile $recipient, UserProfile $author) { @@ -48,6 +49,7 @@ public static function getTestAdditionalData(IUserNotificationObject $object) /** * @inheritDoc + * @return string */ protected static function getTestLikeableObjectTypeName() { diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseLikeUserNotificationEvent.class.php index 4653e74db45..422c414c3d7 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseLikeUserNotificationEvent.class.php @@ -26,6 +26,7 @@ trait TTestableCommentResponseLikeUserNotificationEvent /** * @inheritDoc + * @return LikeableCommentResponse */ protected static function createTestLikeObject(UserProfile $recipient, UserProfile $author) { @@ -49,6 +50,7 @@ public static function getTestAdditionalData(IUserNotificationObject $object) /** * @inheritDoc + * @return string */ protected static function getTestLikeableObjectTypeName() { diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestablePageUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestablePageUserNotificationEvent.class.php index f0ebf84b9e0..759317bd2e0 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestablePageUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestablePageUserNotificationEvent.class.php @@ -64,7 +64,7 @@ public static function getTestPage() return $page; } - private static function resetPageCache() + private static function resetPageCache(): void { // reset cache builders TestableUserNotificationEventHandler::getInstance()->resetCacheBuilder(PageCacheBuilder::getInstance()); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php index c1a59497e2d..235a2e340f8 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php @@ -135,6 +135,7 @@ protected function getCommentID() /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php index c79e4a9dd1f..63ef007cde0 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php @@ -151,6 +151,7 @@ protected function getResponseID() /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php index 4939d0d0c59..124f312e8ca 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php @@ -132,6 +132,7 @@ protected function getObjectTitle(): string /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php index 36d8c2085bc..ff710e65874 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php @@ -114,6 +114,7 @@ protected function getObjectTitle(): string /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php index b58d089753b..ac60f447318 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php @@ -103,6 +103,7 @@ protected function getObjectTitle(): string /** * @inheritDoc + * @return array{objectID: int, objectTypeID: ?int} * @since 3.1 */ protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) diff --git a/wcfsetup/install/files/lib/system/user/object/watch/IUserObjectWatch.class.php b/wcfsetup/install/files/lib/system/user/object/watch/IUserObjectWatch.class.php index 8453c418d47..8330378237c 100644 --- a/wcfsetup/install/files/lib/system/user/object/watch/IUserObjectWatch.class.php +++ b/wcfsetup/install/files/lib/system/user/object/watch/IUserObjectWatch.class.php @@ -15,6 +15,7 @@ interface IUserObjectWatch * Validates the given object id. Throws an exception on error. * * @param int $objectID + * @return void * @throws \wcf\system\exception\UserException */ public function validateObjectID($objectID); @@ -23,6 +24,7 @@ public function validateObjectID($objectID); * Resets the user storage for given users. * * @param int[] $userIDs + * @return void */ public function resetUserStorage(array $userIDs); } diff --git a/wcfsetup/install/files/lib/system/user/object/watch/UserObjectWatchHandler.class.php b/wcfsetup/install/files/lib/system/user/object/watch/UserObjectWatchHandler.class.php index 54f07b7a8dc..5bbe3f7a186 100644 --- a/wcfsetup/install/files/lib/system/user/object/watch/UserObjectWatchHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/object/watch/UserObjectWatchHandler.class.php @@ -38,7 +38,9 @@ public function getObjectTypeID($objectTypeName) } /** - * @inheritDoc + * @param string $objectType + * @param int $objectID + * @return void */ public function resetObject($objectType, $objectID) { @@ -50,6 +52,7 @@ public function resetObject($objectType, $objectID) * * @param string $objectType * @param int[] $objectIDs + * @return void */ public function resetObjects($objectType, array $objectIDs) { @@ -80,6 +83,7 @@ public function resetObjects($objectType, array $objectIDs) * @param string $objectType * @param int[] $objectIDs * @param int[] $userIDs + * @return void */ public function deleteObjects($objectType, array $objectIDs, array $userIDs = []) { @@ -109,7 +113,8 @@ public function deleteObjects($objectType, array $objectIDs, array $userIDs = [] * @param string $notificationEventName * @param string $notificationObjectType * @param IUserNotificationObject $notificationObject - * @param array $additionalData + * @param mixed[] $additionalData + * @return void */ public function updateObject( $objectType, @@ -154,6 +159,7 @@ static function ($notification, $userID) use ($notificationObject) { * the notification status (`1` = should get a notification, * `0` = should not get a notification). * + * @return array * @since 5.5 */ public function getSubscribers(string $objectType, int $objectID): array @@ -168,6 +174,7 @@ public function getSubscribers(string $objectType, int $objectID): array $statement = WCF::getDB()->prepare($sql); $statement->execute([$objectTypeObj->objectTypeID, $objectID]); + // @phpstan-ignore return.type return $statement->fetchMap('userID', 'notification'); } @@ -175,6 +182,8 @@ public function getSubscribers(string $objectType, int $objectID): array * Updates a watched object for all subscribers including subscribers * of the parent object. * + * @param mixed[] $additionalData + * @return void * @since 5.5 */ public function updateObjectWithParent( diff --git a/wcfsetup/install/files/lib/system/user/online/location/IUserOnlineLocation.class.php b/wcfsetup/install/files/lib/system/user/online/location/IUserOnlineLocation.class.php index 93e77de2b36..fc8d146d91f 100644 --- a/wcfsetup/install/files/lib/system/user/online/location/IUserOnlineLocation.class.php +++ b/wcfsetup/install/files/lib/system/user/online/location/IUserOnlineLocation.class.php @@ -18,6 +18,7 @@ interface IUserOnlineLocation * Caches the information of a page location. * * @param UserOnline $user + * @return void */ public function cache(UserOnline $user); diff --git a/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php b/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php index c77ae7e83ae..dbcac13398d 100644 --- a/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php +++ b/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php @@ -61,6 +61,7 @@ public function getSignature(User $user) * Loads the embedded objects for the given users. * * @param int[] $userIDs + * @return void * @since 5.2 */ public function cacheUserSignature(array $userIDs) diff --git a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php index 242aea1bf60..f2eec49b8e8 100644 --- a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php @@ -29,11 +29,7 @@ final class UserStorageHandler extends SingletonFactory */ private $log = []; - /** - * redis instance - * @var ?Redis - */ - private $redis; + private ?Redis $redis = null; /** * Checks whether Redis is available. @@ -51,7 +47,7 @@ protected function init() * * @param int[] $userIDs */ - public function loadStorage(array $userIDs) + public function loadStorage(array $userIDs): void { $this->validateUserIDs($userIDs); @@ -175,7 +171,7 @@ public function getField(string $field, ?int $userID = null) /** * Inserts new data records into database. */ - public function update(int $userID, string $field, string $fieldValue) + public function update(int $userID, string $field, string $fieldValue): void { $this->validateUserIDs([$userID]); @@ -202,7 +198,7 @@ public function update(int $userID, string $field, string $fieldValue) * * @param int[] $userIDs */ - public function reset(array $userIDs, string $field) + public function reset(array $userIDs, string $field): void { $this->validateUserIDs($userIDs); @@ -227,7 +223,7 @@ public function reset(array $userIDs, string $field) /** * Removes a specific data record for all users. */ - public function resetAll(string $field) + public function resetAll(string $field): void { if ($this->redis) { $this->redis->del($this->getRedisFieldName($field)); @@ -336,7 +332,7 @@ public function shutdown() /** * Removes the entire user storage data. */ - public function clear() + public function clear(): void { if ($this->redis) { $this->redis->setnx('ush:_flush', TIME_NOW); @@ -376,7 +372,7 @@ private function getRedisFieldName(string $fieldName): string * @param int[] $userIDs * @since 5.2 */ - private function validateUserIDs(array $userIDs) + private function validateUserIDs(array $userIDs): void { foreach ($userIDs as $userID) { if (!$userID) { diff --git a/wcfsetup/install/files/lib/system/version/IVersionTrackerProvider.class.php b/wcfsetup/install/files/lib/system/version/IVersionTrackerProvider.class.php index d0fa0400f12..b1940bc07fb 100644 --- a/wcfsetup/install/files/lib/system/version/IVersionTrackerProvider.class.php +++ b/wcfsetup/install/files/lib/system/version/IVersionTrackerProvider.class.php @@ -82,6 +82,7 @@ public function isI18n(IVersionTrackerObject $object); * * @param IVersionTrackerObject $object target object * @param VersionTrackerEntry $entry previous version + * @return void */ public function revert(IVersionTrackerObject $object, VersionTrackerEntry $entry); } diff --git a/wcfsetup/install/files/lib/system/version/VersionTracker.class.php b/wcfsetup/install/files/lib/system/version/VersionTracker.class.php index a80f79299d7..091bd48e6fd 100644 --- a/wcfsetup/install/files/lib/system/version/VersionTracker.class.php +++ b/wcfsetup/install/files/lib/system/version/VersionTracker.class.php @@ -41,7 +41,7 @@ protected function init() * Adds a new entry to the version history. * * @param string $objectTypeName object type name - * @param IVersionTrackerObject $object target object + * @return void */ public function add($objectTypeName, IVersionTrackerObject $object) { @@ -160,6 +160,8 @@ public function getVersion($objectTypeName, $versionID) /** * Creates the database tables to store each version. + * + * @return void */ public function createStorageTables() { @@ -205,6 +207,7 @@ public function getObjectType($name) * * @param string $objectTypeName object type name * @param int $objectID object id + * @return void */ public function reset($objectTypeName, $objectID) { diff --git a/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php b/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php index 28e84ce090e..d54f13c1fc2 100644 --- a/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php +++ b/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php @@ -20,13 +20,13 @@ class VersionTrackerEntry { /** * object data - * @var array + * @var mixed[] */ protected $data = []; /** * list of stored properties and their values - * @var array + * @var mixed[] */ protected $payload = []; @@ -34,7 +34,7 @@ class VersionTrackerEntry * VersionTrackerEntry constructor. * * @param ?int $id id - * @param array $data version data + * @param mixed[] $data version data */ public function __construct($id, array $data) { diff --git a/wcfsetup/install/files/lib/system/view/CommentsView.class.php b/wcfsetup/install/files/lib/system/view/CommentsView.class.php index 281f80e64f0..56efa590df5 100644 --- a/wcfsetup/install/files/lib/system/view/CommentsView.class.php +++ b/wcfsetup/install/files/lib/system/view/CommentsView.class.php @@ -3,6 +3,7 @@ namespace wcf\system\view; use wcf\data\comment\StructuredCommentList; +use wcf\data\like\object\LikeObject; use wcf\system\comment\CommentHandler; use wcf\system\comment\manager\ICommentManager; use wcf\system\exception\SystemException; @@ -64,11 +65,15 @@ public function getCommentList(): StructuredCommentList return $this->commentList; } + public function getLastCommentTime(): int { return $this->commentList->getMinCommentTime(); } + /** + * @return array{}|array{comment: LikeObject[], response?: LikeObject[]} + */ public function getLikeData(): array { if (!MODULE_LIKE) { diff --git a/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php b/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php index 1af07a7366c..08cc1fefb3b 100644 --- a/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php +++ b/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php @@ -2,6 +2,7 @@ namespace wcf\system\visitTracker; +use wcf\data\object\type\ObjectType; use wcf\data\object\type\ObjectTypeCache; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; @@ -30,13 +31,13 @@ class VisitTracker extends SingletonFactory /** * list of available object types - * @var array + * @var array */ protected $availableObjectTypes = []; /** * user visits - * @var array + * @var ?array */ protected $userVisits; @@ -147,6 +148,7 @@ public function getObjectVisitTime($objectType, $objectID) * Deletes all tracked visits of a specific object type. * * @param string $objectType + * @return void */ public function deleteObjectVisits($objectType) { @@ -166,6 +168,7 @@ public function deleteObjectVisits($objectType) * @param int $objectID * @param int[] $userIDs * @param int $time + * @return void */ public function trackObjectVisitByUserIDs($objectType, $objectID, array $userIDs, $time = TIME_NOW) { @@ -190,6 +193,7 @@ public function trackObjectVisitByUserIDs($objectType, $objectID, array $userIDs * @param string $objectType * @param int $objectID * @param int $time + * @return void */ public function trackObjectVisit($objectType, $objectID, $time = TIME_NOW) { @@ -209,6 +213,7 @@ public function trackObjectVisit($objectType, $objectID, $time = TIME_NOW) * * @param string $objectType * @param int $time + * @return void */ public function trackTypeVisit($objectType, $time = TIME_NOW) { From 8c635412e61a9bfec37ed58e2f915f11fed8b8e0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 15 Feb 2025 22:26:21 +0100 Subject: [PATCH 04/31] Improve the typing on the session system, search and request handling --- .../system/request/ControllerMap.class.php | 36 +++++++----- .../lib/system/request/LinkHandler.class.php | 3 + .../lib/system/request/Request.class.php | 8 ++- .../lib/system/request/RouteHandler.class.php | 42 ++++++-------- .../route/DynamicRequestRoute.class.php | 11 ++-- .../request/route/IRequestRoute.class.php | 8 +-- .../route/LookupRequestRoute.class.php | 4 +- .../route/StaticRequestRoute.class.php | 5 ++ .../AbstractSearchIndexManager.class.php | 2 + .../lib/system/search/ArticleSearch.class.php | 3 + .../IContextAwareSearchEngine.class.php | 6 ++ .../IContextAwareSearchProvider.class.php | 3 + .../lib/system/search/ISearchEngine.class.php | 7 ++- .../search/ISearchIndexManager.class.php | 9 +++ .../system/search/ISearchProvider.class.php | 7 +++ .../search/ISearchableObjectType.class.php | 7 ++- .../lib/system/search/SearchHandler.class.php | 11 +++- .../search/SearchIndexManager.class.php | 2 +- .../search/SearchResultHandler.class.php | 42 +++++++------- .../search/acp/ACPSearchResultList.class.php | 1 + ...tegorizedACPSearchResultProvider.class.php | 2 + ...oupOptionACPSearchResultProvider.class.php | 3 + .../search/exception/SearchFailed.class.php | 2 +- .../search/mysql/MysqlSearchEngine.class.php | 7 +++ .../session/ACPSessionFactory.class.php | 7 +++ .../session/AbstractSessionHandler.class.php | 2 + .../lib/system/session/Session.class.php | 6 +- .../system/session/SessionHandler.class.php | 58 +++++++++---------- .../lib/system/setup/IFileHandler.class.php | 6 +- .../lib/system/setup/Installer.class.php | 14 ++++- .../lib/system/setup/Uninstaller.class.php | 6 ++ .../stat/AbstractStatDailyHandler.class.php | 1 + .../system/stat/IStatDailyHandler.class.php | 2 +- .../system/style/FontAwesomeIcon.class.php | 2 + .../lib/system/style/StyleCompiler.class.php | 5 ++ .../lib/system/style/StyleHandler.class.php | 7 ++- .../exception/FontDownloadFailed.class.php | 7 ++- .../lib/system/tagging/TagCloud.class.php | 2 + .../lib/system/tagging/TagEngine.class.php | 23 ++++++-- .../system/tagging/TypedTagCloud.class.php | 2 + .../tagging/command/SetSynonym.class.php | 2 +- .../files/lib/util/ArrayUtil.class.php | 4 +- 42 files changed, 255 insertions(+), 132 deletions(-) diff --git a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php index 0eb9c9a2c05..51f0a7891f1 100644 --- a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php +++ b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php @@ -21,35 +21,39 @@ final class ControllerMap extends SingletonFactory { /** - * @var array + * @var array{ + * lookup: array>, + * reverse: array>, + * } * @since 5.2 */ - protected $applicationOverrides; + private array $applicationOverrides; /** - * @var array + * @var array>> */ - protected $ciControllers; + private array $ciControllers; /** - * @var array + * @var array{ + * lookup: array>, + * reverse: array>, + * } */ - protected $customUrls; + private array $customUrls; /** - * @var string[][] + * @var array> */ - protected $landingPages; + private array $landingPages; /** * list of to mappings * @var array */ - protected $lookupCache = []; + private array $lookupCache = []; - /** - * @inheritDoc - */ + #[\Override] protected function init() { $this->applicationOverrides = RoutingCacheBuilder::getInstance()->getData([], 'applicationOverrides'); @@ -130,7 +134,7 @@ public function resolve(string $application, string $controller, bool $isAcpRequ * * URL -> Controller * - * @return array empty array if there is no exact match + * @return array{}|array{className: string, controller: string}|array{className: string, controller: string, cmsPageID: string, cmsPageLanguageID: string} */ public function resolveCustomController(string $application, string $controller): array { @@ -287,7 +291,7 @@ public function isDefaultController(string $application, string $controller): bo /** * Returns true if currently active request represents the global landing page. * - * @param array $metaData + * @param array $metaData */ public function isLandingPage(string $className, array $metaData): bool { @@ -324,7 +328,7 @@ public function getApplicationOverride(string $application, string $controller): * * @return string[]|null className and controller, or null if this is not a legacy controller name */ - protected function getLegacyClassData(string $application, string $controller, bool $isAcpRequest) + private function getLegacyClassData(string $application, string $controller, bool $isAcpRequest) { $environment = $isAcpRequest ? 'acp' : 'frontend'; if (isset($this->ciControllers[$application][$environment][$controller])) { @@ -348,7 +352,7 @@ protected function getLegacyClassData(string $application, string $controller, b * @param $pageType page type, e.g. 'form' or 'action' * @return string[]|null className and controller */ - protected function getClassData(string $application, string $controller, bool $isAcpRequest, string $pageType) + private function getClassData(string $application, string $controller, bool $isAcpRequest, string $pageType) { $className = $application . '\\' . ($isAcpRequest ? 'acp\\' : '') . $pageType . '\\' . $controller . \ucfirst($pageType); if (!\class_exists($className)) { diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index c2fd3bfd4f9..7430d701ff1 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -72,6 +72,7 @@ protected function init() * Important: The controller class is not checked if it actually exists. * That check happens during the runtime. * + * @param array $parameters * @throws \InvalidArgumentException if the passed string is no controller class name * @since 5.2 */ @@ -93,6 +94,8 @@ public function getControllerLink(string $controllerClass, array $parameters = [ /** * Returns a relative link. + * + * @param array $parameters */ public function getLink(?string $controller = null, array $parameters = [], string $url = ''): string { diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index d62dbc979b0..29f9b4f8af1 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -20,6 +20,9 @@ final class Request implements RequestHandlerInterface private readonly bool $isLandingPage; + /** + * @var array{cms?: array{pageID: int, languageID: int}} + */ private readonly array $metaData; /** @@ -28,6 +31,9 @@ final class Request implements RequestHandlerInterface */ private $requestObject; + /** + * @param array{cms?: array{pageID: int, languageID: int}} $metaData + */ public function __construct(string $className, array $metaData, bool $isLandingPage) { $this->className = $className; @@ -76,7 +82,7 @@ public function getClassName(): string /** * Returns request meta data. * - * @return array + * @return array{cms?: array{pageID: int, languageID: int}} * @since 3.0 */ public function getMetaData() diff --git a/wcfsetup/install/files/lib/system/request/RouteHandler.class.php b/wcfsetup/install/files/lib/system/request/RouteHandler.class.php index adb6c970f35..26daced5e1b 100644 --- a/wcfsetup/install/files/lib/system/request/RouteHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RouteHandler.class.php @@ -24,33 +24,28 @@ final class RouteHandler extends SingletonFactory { /** * current host and protocol - * @var string */ - private static $host = ''; + private static string $host = ''; /** * current absolute path - * @var string */ - private static $path = ''; + private static string $path = ''; /** * current path info component - * @var string */ - private static $pathInfo; + private static string $pathInfo; /** * HTTP protocol, either 'http://' or 'https://' - * @var string */ - private static $protocol = ''; + private static string $protocol = ''; /** * HTTP encryption - * @var bool */ - private static $secure; + private static bool $secure; /** * true if the default controller is used (support for custom landing page) @@ -70,9 +65,9 @@ final class RouteHandler extends SingletonFactory /** * parsed route data - * @var array + * @var array */ - private $routeData; + private array $routeData; /** * Sets default routes. @@ -98,7 +93,7 @@ protected function init() * * @param IRequestRoute $route */ - public function addRoute(IRequestRoute $route) + public function addRoute(IRequestRoute $route): void { \array_unshift($this->routes, $route); } @@ -106,9 +101,9 @@ public function addRoute(IRequestRoute $route) /** * Returns all registered routes. * - * @return IRequestRoute[] + * @return IRequestRoute[] **/ - public function getRoutes() + public function getRoutes(): array { return $this->routes; } @@ -175,9 +170,9 @@ public function isRenamedController(): bool /** * Returns parsed route data * - * @return array + * @return array */ - public function getRouteData() + public function getRouteData(): array { return $this->routeData; } @@ -197,13 +192,10 @@ private function registerRouteData(): void * Builds a route based upon route components, this is nothing * but a reverse lookup. * - * @param string $application application identifier - * @param array $components - * @param bool $isACP - * @return string + * @param array $components * @throws SystemException */ - public function buildRoute($application, array $components, $isACP = null) + public function buildRoute(string $application, array $components, ?bool $isACP = null): string { if ($isACP === null) { $isACP = RequestHandler::getInstance()->isACPRequest(); @@ -248,7 +240,7 @@ public static function isValidCustomUrl($customUrl): bool */ public static function secureConnection(): bool { - if (self::$secure === null) { + if (!isset(self::$secure)) { self::$secure = false; if ( @@ -317,6 +309,8 @@ public static function getHost(): string /** * Returns absolute domain path. + * + * @param string[] $removeComponents */ public static function getPath(array $removeComponents = []): string { @@ -349,7 +343,7 @@ public static function getPath(array $removeComponents = []): string */ public static function getPathInfo(): string { - if (self::$pathInfo === null) { + if (!isset(self::$pathInfo)) { self::$pathInfo = ''; if (!empty($_SERVER['QUERY_STRING'])) { diff --git a/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php b/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php index e6777de47f8..d3050472bdc 100644 --- a/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php @@ -45,9 +45,6 @@ class DynamicRequestRoute implements IRequestRoute */ protected $routeData = []; - /** - * DynamicRequestRoute constructor. - */ public function __construct() { $this->init(); @@ -55,6 +52,8 @@ public function __construct() /** * Sets default routing information. + * + * @return void */ protected function init() { @@ -81,7 +80,8 @@ protected function init() } /** - * @inheritDoc + * @param bool $isACP + * @return void */ public function setIsACP($isACP) { @@ -92,6 +92,7 @@ public function setIsACP($isACP) * Sets the build schema used to build outgoing links. * * @param string $buildSchema + * @return void */ public function setBuildSchema($buildSchema) { @@ -124,6 +125,7 @@ public function setBuildSchema($buildSchema) * Sets the route pattern used to evaluate an incoming request. * * @param string $pattern + * @return void */ public function setPattern($pattern) { @@ -134,6 +136,7 @@ public function setPattern($pattern) * Sets the list of required components. * * @param string[] $requiredComponents + * @return void */ public function setRequiredComponents(array $requiredComponents) { diff --git a/wcfsetup/install/files/lib/system/request/route/IRequestRoute.class.php b/wcfsetup/install/files/lib/system/request/route/IRequestRoute.class.php index 9d51a6a3513..deebe94a02e 100644 --- a/wcfsetup/install/files/lib/system/request/route/IRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/IRequestRoute.class.php @@ -15,15 +15,15 @@ interface IRequestRoute /** * Builds a link upon route components. * - * @param array $components - * @return string + * @param array $components + * @return string */ public function buildLink(array $components); /** * Returns true if current route can handle the build request. * - * @param array $components + * @param array $components * @return bool */ public function canHandle(array $components); @@ -31,7 +31,7 @@ public function canHandle(array $components); /** * Returns parsed route data. * - * @return array + * @return array */ public function getRouteData(); diff --git a/wcfsetup/install/files/lib/system/request/route/LookupRequestRoute.class.php b/wcfsetup/install/files/lib/system/request/route/LookupRequestRoute.class.php index afc253bc5c6..70fa7d2a43c 100644 --- a/wcfsetup/install/files/lib/system/request/route/LookupRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/LookupRequestRoute.class.php @@ -19,9 +19,9 @@ final class LookupRequestRoute implements IRequestRoute { /** * list of parsed route information - * @var array + * @var array{id?: string, title?: string, controller?: string, isDefaultController?: boolean} */ - protected array $routeData = []; + private array $routeData = []; /** * @inheritDoc diff --git a/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php b/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php index 324910eb040..3957de846a8 100644 --- a/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php @@ -34,6 +34,9 @@ class StaticRequestRoute extends DynamicRequestRoute /** * Always throws. This method only exists because StaticRequestRoute inherits from DynamicRequestRoute. + * + * @param boolean $isACP + * @return void */ public function setIsACP($isACP) { @@ -53,6 +56,7 @@ public function isACP() * for controllers requiring a custom set of additional parameters. * * @param bool $matchController + * @return void */ public function setMatchController($matchController) { @@ -64,6 +68,7 @@ public function setMatchController($matchController) * * @param string $application * @param string $controller + * @return void */ public function setStaticController($application, $controller) { diff --git a/wcfsetup/install/files/lib/system/search/AbstractSearchIndexManager.class.php b/wcfsetup/install/files/lib/system/search/AbstractSearchIndexManager.class.php index 71adb13ea39..29913b3a974 100644 --- a/wcfsetup/install/files/lib/system/search/AbstractSearchIndexManager.class.php +++ b/wcfsetup/install/files/lib/system/search/AbstractSearchIndexManager.class.php @@ -41,6 +41,8 @@ public function createSearchIndices() /** * Creates the search index for given object type. + * + * @return bool */ abstract protected function createSearchIndex(ObjectType $objectType); diff --git a/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php b/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php index 1d85da01883..7cebe4ee3c2 100644 --- a/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php +++ b/wcfsetup/install/files/lib/system/search/ArticleSearch.class.php @@ -122,6 +122,9 @@ public function getConditionBuilder(array $parameters): ?PreparedStatementCondit return $conditionBuilder; } + /** + * @return list + */ private function getArticleCategoryIDs(int $categoryID): array { $categoryIDs = []; diff --git a/wcfsetup/install/files/lib/system/search/IContextAwareSearchEngine.class.php b/wcfsetup/install/files/lib/system/search/IContextAwareSearchEngine.class.php index 4c21b0fceff..6b371cc8e91 100644 --- a/wcfsetup/install/files/lib/system/search/IContextAwareSearchEngine.class.php +++ b/wcfsetup/install/files/lib/system/search/IContextAwareSearchEngine.class.php @@ -29,6 +29,7 @@ public function getConditionBuilderClassName(); * Returns the inner join query and the condition parameters. This method is allowed to return NULL for both the * 'fulltextCondition' and 'searchIndexCondition' index instead of a PreparedStatementConditionBuilder instance. * + * @param array{parentID?: int, containerID?: int} $contextFilter * @return array{ * fulltextCondition: ?PreparedStatementConditionBuilder, * searchIndexCondition: ?PreparedStatementConditionBuilder, @@ -47,6 +48,11 @@ public function getInnerJoinWithContext( /** * Searches for the given string and returns the data of the found messages. + * + * @param list $objectTypes + * @param array $contextFilter + * @param array $additionalConditions + * @return list */ public function searchWithContext( string $q, diff --git a/wcfsetup/install/files/lib/system/search/IContextAwareSearchProvider.class.php b/wcfsetup/install/files/lib/system/search/IContextAwareSearchProvider.class.php index 3c94596fde9..2ab48f32ac3 100644 --- a/wcfsetup/install/files/lib/system/search/IContextAwareSearchProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/IContextAwareSearchProvider.class.php @@ -19,6 +19,9 @@ interface IContextAwareSearchProvider extends ISearchProvider /** * Returns the context filter that is being applied * to the inner search query. + * + * @param array $parameters + * @return array */ public function getContextFilter(array $parameters): array; } diff --git a/wcfsetup/install/files/lib/system/search/ISearchEngine.class.php b/wcfsetup/install/files/lib/system/search/ISearchEngine.class.php index 72032884a9a..e5a75a2956e 100644 --- a/wcfsetup/install/files/lib/system/search/ISearchEngine.class.php +++ b/wcfsetup/install/files/lib/system/search/ISearchEngine.class.php @@ -49,6 +49,7 @@ public function getInnerJoin( * Removes engine-specific special characters from a string. * * @param string $string + * @return string */ public function removeSpecialCharacters($string); @@ -56,13 +57,13 @@ public function removeSpecialCharacters($string); * Searches for the given string and returns the data of the found messages. * * @param string $q - * @param array $objectTypes + * @param string[] $objectTypes * @param bool $subjectOnly * @param PreparedStatementConditionBuilder $searchIndexCondition - * @param array $additionalConditions + * @param array $additionalConditions * @param string $orderBy * @param int $limit - * @return array + * @return list */ public function search( $q, diff --git a/wcfsetup/install/files/lib/system/search/ISearchIndexManager.class.php b/wcfsetup/install/files/lib/system/search/ISearchIndexManager.class.php index cdfc5e7705c..c509b55e1d5 100644 --- a/wcfsetup/install/files/lib/system/search/ISearchIndexManager.class.php +++ b/wcfsetup/install/files/lib/system/search/ISearchIndexManager.class.php @@ -23,6 +23,7 @@ interface ISearchIndexManager * @param string $username * @param int $languageID * @param string $metaData + * @return void */ public function set( $objectType, @@ -41,6 +42,7 @@ public function set( * * @param string $objectType * @param int[] $objectIDs + * @return void */ public function delete($objectType, array $objectIDs); @@ -48,21 +50,28 @@ public function delete($objectType, array $objectIDs); * Resets the search index. * * @param string $objectType + * @return void */ public function reset($objectType); /** * Creates the search index for all searchable objects. + * + * @return void */ public function createSearchIndices(); /** * Begins the bulk operation. + * + * @return void */ public function beginBulkOperation(); /** * Commits the bulk operation. + * + * @return void */ public function commitBulkOperation(); } diff --git a/wcfsetup/install/files/lib/system/search/ISearchProvider.class.php b/wcfsetup/install/files/lib/system/search/ISearchProvider.class.php index 1a1c3f8fec2..e13ff972215 100644 --- a/wcfsetup/install/files/lib/system/search/ISearchProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/ISearchProvider.class.php @@ -17,6 +17,9 @@ interface ISearchProvider { /** * Caches the data for the given object ids. + * + * @param int[] $objectIDs + * @param mixed[] $additionalData */ public function cacheObjects(array $objectIDs, ?array $additionalData = null): void; @@ -38,6 +41,8 @@ public function getApplication(): string; /** * Returns the search conditions of this provider or `null` if no special search conditions are necessary. * If this provider is the only provider that is searched, the search parameters are passed. + * + * @param array $parameters */ public function getConditionBuilder(array $parameters): ?PreparedStatementConditionBuilder; @@ -73,6 +78,8 @@ public function getTimeFieldName(): string; /** * Returns additional search information. + * + * @return mixed[] */ public function getAdditionalData(): ?array; diff --git a/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php index 3e0d3a433a4..9c4602b01df 100644 --- a/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php +++ b/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php @@ -19,8 +19,9 @@ interface ISearchableObjectType /** * Caches the data for the given object ids. * - * @param array $objectIDs - * @param array $additionalData + * @param int[] $objectIDs + * @param mixed[]|null $additionalData + * @return void */ public function cacheObjects(array $objectIDs, ?array $additionalData = null); @@ -36,6 +37,7 @@ public function getObject($objectID); * Shows the form part of this object type. * * @param IForm $form instance of the form class where the search has taken place + * @return void */ public function show(?IForm $form = null); @@ -135,6 +137,7 @@ public function getOuterSQLQuery( /** * Sets the location in menu/breadcrumbs. * + * @return void * @since 3.0 */ public function setLocation(); diff --git a/wcfsetup/install/files/lib/system/search/SearchHandler.class.php b/wcfsetup/install/files/lib/system/search/SearchHandler.class.php index 31557569bfe..a9772d50c9c 100644 --- a/wcfsetup/install/files/lib/system/search/SearchHandler.class.php +++ b/wcfsetup/install/files/lib/system/search/SearchHandler.class.php @@ -63,12 +63,15 @@ final class SearchHandler */ private $results = []; + /** + * @param mixed[] $parameters + */ public function __construct(array $parameters) { $this->parameters = $parameters; } - public function search() + public function search(): ?Search { $this->initParameters(); $this->buildConditions(); @@ -266,6 +269,9 @@ private function getSearchFormEmulation(): SearchForm return $form; } + /** + * @return int[] + */ private function getUserIDs(): array { if ($this->userIDs === null) { @@ -383,6 +389,9 @@ private function saveSearch(): Search return $resultValues['returnValues']; } + /** + * @return mixed[] + */ private function getAdditionalData(): array { $additionalData = []; diff --git a/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php b/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php index 08f9d0bb04c..ad97c79cd4d 100644 --- a/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php +++ b/wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php @@ -21,7 +21,7 @@ class SearchIndexManager extends SingletonFactory implements IContextAwareSearch { /** * list of available object types - * @var array + * @var array */ protected $availableObjectTypes = []; diff --git a/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php b/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php index 0a44cb797d4..5a281b516b2 100644 --- a/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php +++ b/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php @@ -6,6 +6,7 @@ use wcf\data\search\Search; use wcf\page\SearchResultPage; use wcf\system\exception\ImplementationException; +use wcf\system\exception\SystemException; /** * Provides the results of a full-text search. @@ -17,35 +18,28 @@ */ final class SearchResultHandler { - /** - * @var Search - */ - private $search; + private readonly Search $search; /** - * @var array + * @var array{ + * query: string, + * objectTypeNames: string[], + * results: list, + * additionalData: array + * } */ - private $searchData; + private array $searchData; /** - * @var array + * @var list */ - private $messages = []; + private array $messages = []; - /** - * @var int - */ - private $startIndex = 0; + private int $startIndex = 0; - /** - * @var int - */ - private $limit = 0; + private int $limit = 0; - /** - * @var int - */ - private $endIndex = 0; + private int $endIndex = 0; public function __construct(Search $search, int $startIndex = 0, int $limit = SEARCH_RESULTS_PER_PAGE) { @@ -74,6 +68,9 @@ public function loadSearchResults(): void $this->readMessages(); } + /** + * @return list + */ public function getSearchResults(): array { return $this->messages; @@ -123,6 +120,9 @@ public function getQuery(): string return $this->searchData['query']; } + /** + * @return array{templateName: string, application: string} + */ public function getTemplateName(): array { if (\count($this->searchData['objectTypeNames']) === 1) { @@ -157,6 +157,8 @@ public function getCustomIcons(): array /** * Will be removed with 6.0 once all search providers have switched to ISearchProvider. + * + * @return array{templateName: string, application: string} * @deprecated 5.5 */ private function getLegacyTemplateName(): array diff --git a/wcfsetup/install/files/lib/system/search/acp/ACPSearchResultList.class.php b/wcfsetup/install/files/lib/system/search/acp/ACPSearchResultList.class.php index cdfeb98f90e..411b552d28a 100644 --- a/wcfsetup/install/files/lib/system/search/acp/ACPSearchResultList.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/ACPSearchResultList.class.php @@ -10,6 +10,7 @@ * @author Alexander Ebert * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License + * @implements \Iterator */ class ACPSearchResultList implements \Countable, \Iterator { diff --git a/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php index 758b4e3fbc0..5eb0c4f610b 100644 --- a/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php @@ -90,6 +90,8 @@ protected function getTopCategory($categoryName) /** * Loads categories. + * + * @return void */ protected function loadCategories() { diff --git a/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php index bd7e61b136a..afbe0484db2 100644 --- a/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php @@ -24,6 +24,9 @@ class UserGroupOptionACPSearchResultProvider extends AbstractCategorizedACPSearc */ protected $listClassName = UserGroupOptionCategoryList::class; + /** + * @var list + */ private array $restrictedOptionNames = [ 'admin.configuration.package.canUpdatePackage', 'admin.configuration.package.canEditServer', diff --git a/wcfsetup/install/files/lib/system/search/exception/SearchFailed.class.php b/wcfsetup/install/files/lib/system/search/exception/SearchFailed.class.php index e0ed1663d13..ae895e4388d 100644 --- a/wcfsetup/install/files/lib/system/search/exception/SearchFailed.class.php +++ b/wcfsetup/install/files/lib/system/search/exception/SearchFailed.class.php @@ -13,7 +13,7 @@ */ final class SearchFailed extends \RuntimeException { - public function __construct($message, ?\Throwable $previous = null) + public function __construct(string $message, ?\Throwable $previous = null) { parent::__construct($message, 0, $previous); } diff --git a/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php b/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php index adf9b31ce9d..0b5e22e66ed 100644 --- a/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php +++ b/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php @@ -23,6 +23,7 @@ class MysqlSearchEngine extends AbstractSearchEngine { /** + * @var int * @deprecated 5.4 - This property is used for the deprecated getFulltextMinimumWordLength(). */ protected $ftMinWordLen; @@ -179,6 +180,9 @@ public function getInnerJoin( * - `test -foo bar` becomes `+test* -foo +bar*` * - `test * @see https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html * @see https://github.com/mysql/mysql-server/blob/ee4455a33b10f1b1886044322e4893f587b319ed/storage/innobase/fts/fts0pars.y * @see https://github.com/mysql/mysql-server/blob/ee4455a33b10f1b1886044322e4893f587b319ed/storage/innobase/fts/fts0blex.l @@ -546,6 +552,7 @@ protected function splitIntoTerms($query) } /** + * @return int * @deprecated 5.4 - This method was required for use in parseSearchQuery(). */ protected function getFulltextMinimumWordLength() diff --git a/wcfsetup/install/files/lib/system/session/ACPSessionFactory.class.php b/wcfsetup/install/files/lib/system/session/ACPSessionFactory.class.php index 56ff9cbe63c..073ca0c6896 100644 --- a/wcfsetup/install/files/lib/system/session/ACPSessionFactory.class.php +++ b/wcfsetup/install/files/lib/system/session/ACPSessionFactory.class.php @@ -15,17 +15,21 @@ class ACPSessionFactory { /** + * @var string * @deprecated 5.4 - This property is not read any longer. */ protected $cookieSuffix = 'acp_'; /** + * @var string * @deprecated 5.4 - This property is not read any longer. */ protected $sessionEditor = ACPSessionEditor::class; /** * Loads the object of the active session. + * + * @return void */ public function load() { @@ -45,6 +49,7 @@ public function load() } /** + * @return bool * @deprecated 5.4 - Sessions are fully managed by SessionHandler. */ public function hasValidCookie() @@ -54,6 +59,8 @@ public function hasValidCookie() /** * Initializes the session system. + * + * @return void */ protected function init() { diff --git a/wcfsetup/install/files/lib/system/session/AbstractSessionHandler.class.php b/wcfsetup/install/files/lib/system/session/AbstractSessionHandler.class.php index 521864fcc2d..c8dc0f63509 100644 --- a/wcfsetup/install/files/lib/system/session/AbstractSessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/AbstractSessionHandler.class.php @@ -43,6 +43,8 @@ public function __get($key) /** * Initializes this session. + * + * @return void */ abstract protected function initSession(); } diff --git a/wcfsetup/install/files/lib/system/session/Session.class.php b/wcfsetup/install/files/lib/system/session/Session.class.php index ff5fe11872e..fbb8ee48a3d 100644 --- a/wcfsetup/install/files/lib/system/session/Session.class.php +++ b/wcfsetup/install/files/lib/system/session/Session.class.php @@ -16,14 +16,14 @@ final class Session { /** - * @var array + * @var array */ - private $data; + private array $data; private UserAgent $userAgent; /** - * Session constructor. + * @param array $data */ public function __construct(array $data) { diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 2f54a478aee..98bb294f534 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -66,26 +66,21 @@ final class SessionHandler extends SingletonFactory /** * language id for active user - * @var int */ - private $languageID = 0; + private int $languageID = 0; - /** - * @var string - */ private string $sessionID; private ?LegacySession $legacySession = null; /** * user object - * @var User */ private User $user; /** * session variables - * @var array + * @var array */ private $variables = []; @@ -100,7 +95,7 @@ final class SessionHandler extends SingletonFactory * list of names of permissions only available for users * @var string[] */ - private $usersOnlyPermissions = []; + private array $usersOnlyPermissions = []; private string $xsrfToken; @@ -182,6 +177,8 @@ protected function init() * Parses the session cookie value, returning an array with the stored fields. * * The return array is guaranteed to have a `sessionId` key. + * + * @return array{sessionId: string}&array */ private function parseCookie(string $value): array { @@ -220,6 +217,7 @@ private function parseCookie(string $value): array /** * Extracts the data from the session cookie. * + * @return array{sessionId: string}&array * @see SessionHandler::parseCookie() * @since 5.4 */ @@ -253,6 +251,8 @@ private function getParsedCookieData(): ?array /** * Returns the session ID stored in the session cookie or `null`. + * + * @param ?(array{sessionId: string}&array) $cookieData */ private function getSessionIdFromCookie(?array $cookieData): ?string { @@ -307,7 +307,7 @@ public function hasValidCookie(): bool /** * @deprecated 5.4 - Sessions are managed automatically. Use loadFromCookie(). */ - public function load($sessionEditorClassName, $sessionID) + public function load(string $sessionEditorClassName, string $sessionID): void { $hasSession = false; if (!empty($sessionID)) { @@ -322,7 +322,7 @@ public function load($sessionEditorClassName, $sessionID) /** * Loads the session matching the session cookie. */ - public function loadFromCookie() + public function loadFromCookie(): void { $cookieData = $this->getParsedCookieData(); $sessionID = $this->getSessionIdFromCookie($cookieData); @@ -341,6 +341,8 @@ public function loadFromCookie() /** * Refreshes the session cookie, extending the expiry. + * + * @param array{timestep?: int} $cookieData */ private function maybeRefreshCookie(array $cookieData): void { @@ -365,7 +367,7 @@ private function maybeRefreshCookie(array $cookieData): void /** * Initializes session system. */ - public function initSession() + public function initSession(): void { // assign language $this->languageID = $this->getVar('languageID') ?: $this->user->languageID; @@ -380,7 +382,7 @@ public function initSession() /** * Disables update on shutdown. */ - public function disableUpdate() + public function disableUpdate(): void { $this->doNotUpdate = true; } @@ -704,10 +706,8 @@ private function createLegacySession(): LegacySession /** * Returns the value of the permission with the given name. - * - * @return mixed permission value */ - public function getPermission(string $permission) + public function getPermission(string $permission): mixed { // check if a users only permission is checked for a guest and return // false if that is the case @@ -727,10 +727,8 @@ public function getPermission(string $permission) /** * Returns true if a permission was set to 'Never'. This is required to preserve * compatibility, while preventing ACLs from overruling a 'Never' setting. - * - * @return bool */ - public function getNeverPermission(string $permission) + public function getNeverPermission(string $permission): bool { $this->loadGroupData(); @@ -744,7 +742,7 @@ public function getNeverPermission(string $permission) * @param string[] $permissions list of permissions where each one must pass * @throws PermissionDeniedException */ - public function checkPermissions(array $permissions) + public function checkPermissions(array $permissions): void { foreach ($permissions as $permission) { if (!$this->getPermission($permission)) { @@ -756,7 +754,7 @@ public function checkPermissions(array $permissions) /** * Loads group data from cache. */ - private function loadGroupData() + private function loadGroupData(): void { if ($this->groupData !== null) { return; @@ -779,9 +777,10 @@ private function loadGroupData() } /** + * @return int[] * @deprecated 6.0 Use User::getLanguageIDs() instead. */ - public function getLanguageIDs() + public function getLanguageIDs(): array { if (!$this->user->userID) { return []; @@ -893,7 +892,7 @@ public function clearPendingUserChange(): void * * @param $hideSession if true, database won't be updated */ - public function changeUser(User $user, bool $hideSession = false) + public function changeUser(User $user, bool $hideSession = false): void { $eventParameters = ['user' => $user, 'hideSession' => $hideSession]; @@ -925,8 +924,6 @@ public function changeUser(User $user, bool $hideSession = false) /** * Changes the user stored in the session. - * - * @param User $user */ private function changeUserVirtual(User $user): void { @@ -1202,7 +1199,7 @@ public function update(): void /** * @deprecated 5.4 - This method is a noop. The lastActivityTime is always updated immediately after loading. */ - public function keepAlive() {} + public function keepAlive(): void {} /** * Deletes this session and its related data. @@ -1265,20 +1262,16 @@ public function deleteIfNew(): void /** * Returns currently active language id. - * - * @return int */ - public function getLanguageID() + public function getLanguageID(): int { return $this->languageID; } /** * Sets the currently active language id. - * - * @param int $languageID */ - public function setLanguageID($languageID) + public function setLanguageID(int $languageID): void { $this->languageID = $languageID; $this->register('languageID', $this->languageID); @@ -1290,7 +1283,7 @@ public function setLanguageID($languageID) * @param int[] $userIDs * @deprecated 6.1 see https://github.com/WoltLab/WCF/pull/3767 */ - public static function resetSessions(array $userIDs = []) + public static function resetSessions(array $userIDs = []): void { if (!empty($userIDs)) { UserStorageHandler::getInstance()->reset($userIDs, 'groupIDs'); @@ -1391,6 +1384,7 @@ public function deleteUserSession(string $sessionID): void /** * Returns the session variables. * + * @return array * @since 6.1 */ public function getVariables(): array diff --git a/wcfsetup/install/files/lib/system/setup/IFileHandler.class.php b/wcfsetup/install/files/lib/system/setup/IFileHandler.class.php index 6bb11215c42..a1d6cb9d257 100644 --- a/wcfsetup/install/files/lib/system/setup/IFileHandler.class.php +++ b/wcfsetup/install/files/lib/system/setup/IFileHandler.class.php @@ -14,14 +14,16 @@ interface IFileHandler /** * Checks the overwriting rights of the given files. * - * @param array $files + * @param list $files + * @return void */ public function checkFiles(array $files); /** * Logs the given list of files. * - * @param array $files + * @param list $files + * @return void */ public function logFiles(array $files); } diff --git a/wcfsetup/install/files/lib/system/setup/Installer.class.php b/wcfsetup/install/files/lib/system/setup/Installer.class.php index 4a26148ebb9..cd7d693fd19 100644 --- a/wcfsetup/install/files/lib/system/setup/Installer.class.php +++ b/wcfsetup/install/files/lib/system/setup/Installer.class.php @@ -59,6 +59,8 @@ public function __construct($targetDir, $source, $fileHandler = null, $folder = /** * Creates the target directory if necessary. + * + * @return void */ protected function createTargetDir() { @@ -76,6 +78,7 @@ protected function createTargetDir() * Creates a directory in the target directory. * * @param string $dir + * @return void * @throws SystemException */ protected function createDir($dir) @@ -96,6 +99,7 @@ protected function createDir($dir) * Touches a file in the target directory. * * @param string $file + * @return void */ public function touchFile($file) { @@ -109,6 +113,7 @@ public function touchFile($file) * @param string $file * @param int $index * @param Tar $tar + * @return void */ protected function createFile($file, $index, Tar $tar) { @@ -120,6 +125,8 @@ protected function createFile($file, $index, Tar $tar) /** * Starts the extracting of the files. + * + * @return void */ protected function install() { @@ -192,7 +199,8 @@ protected function getTar($source) /** * Checks whether the given files overwriting locked existing files. * - * @param array $files + * @param list $files + * @return void */ protected function checkFiles(&$files) { @@ -202,7 +210,8 @@ protected function checkFiles(&$files) /** * Logs the given files. * - * @param array $files + * @param list $files + * @return void */ protected function logFiles(&$files) { @@ -213,6 +222,7 @@ protected function logFiles(&$files) * Makes a file or directory writeable. * * @param string $target + * @return void */ protected function makeWriteable($target) { diff --git a/wcfsetup/install/files/lib/system/setup/Uninstaller.class.php b/wcfsetup/install/files/lib/system/setup/Uninstaller.class.php index 46c18eab03e..21d86808edd 100644 --- a/wcfsetup/install/files/lib/system/setup/Uninstaller.class.php +++ b/wcfsetup/install/files/lib/system/setup/Uninstaller.class.php @@ -54,6 +54,8 @@ public function __construct($targetDir, $files, $deleteEmptyTargetDir, $deleteEm /** * Checks if the target directory is a valid directory. + * + * @return bool */ protected function checkTargetDir() { @@ -80,6 +82,7 @@ protected function isEmpty($dir) * Deletes a file. * * @param string $file + * @return void */ protected function deleteFile($file) { @@ -90,6 +93,7 @@ protected function deleteFile($file) * Deletes a directory. * * @param string $dir + * @return void */ protected function deleteDir($dir) { @@ -98,6 +102,8 @@ protected function deleteDir($dir) /** * Starts the deletion of the files. + * + * @return void */ protected function uninstall() { diff --git a/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php index 20fa2ae83a6..322ead46324 100644 --- a/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php +++ b/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php @@ -74,6 +74,7 @@ public function getFormattedCounter($counter) * Adds additional conditions to the given condition builder. * * @param PreparedStatementConditionBuilder $conditionBuilder + * @return void * @since 3.1 */ protected function addConditions(PreparedStatementConditionBuilder $conditionBuilder) diff --git a/wcfsetup/install/files/lib/system/stat/IStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/IStatDailyHandler.class.php index b90a37930ee..ae9d35cd166 100644 --- a/wcfsetup/install/files/lib/system/stat/IStatDailyHandler.class.php +++ b/wcfsetup/install/files/lib/system/stat/IStatDailyHandler.class.php @@ -15,7 +15,7 @@ interface IStatDailyHandler * Returns the stats. * * @param int $date - * @return array + * @return array{counter: int, total: int} */ public function getData($date); diff --git a/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php b/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php index ca3a20f1f20..b37d3fa1650 100644 --- a/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php +++ b/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php @@ -21,6 +21,8 @@ final class FontAwesomeIcon implements IFontAwesomeIcon, \Stringable /** * Uses the icon name as the key and a boolean value that * indicates that an icon has a non-solid variant. + * + * @var array */ private static array $icons; diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index fec130f974e..08fbfc371de 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -331,6 +331,8 @@ public function compile(Style $style): void * Builds the preload manifest from the given iterable containing * preload requests. * + * @param iterable $requests + * @return array{http: list, html: list} * @see StyleCompiler::extractPreloadRequests() * @since 5.4 */ @@ -370,6 +372,7 @@ private function buildPreloadManifest(iterable $requests): array /** * Extracts preload requests from the given CSS string. * + * @return iterable * @since 5.4 */ private function extractPreloadRequests(string $css): iterable @@ -741,6 +744,8 @@ private function convertToRtl(string $css): string /** * Writes the given css into the file with the given prefix. + * + * @param ?array{http: list, html: list} $preloadManifest */ private function writeCss(string $filePrefix, string $css, ?array $preloadManifest = null): void { diff --git a/wcfsetup/install/files/lib/system/style/StyleHandler.class.php b/wcfsetup/install/files/lib/system/style/StyleHandler.class.php index 8657ae7fd33..a9ec91bd326 100644 --- a/wcfsetup/install/files/lib/system/style/StyleHandler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleHandler.class.php @@ -23,7 +23,7 @@ class StyleHandler extends SingletonFactory { /** * style information cache - * @var array + * @var array{}|array{default: int, styles: array} */ protected $cache = []; @@ -89,6 +89,7 @@ public function getStyle() * * @param int $styleID * @param bool $ignorePermissions + * @return void * @throws SystemException */ public function changeStyle($styleID = 0, $ignorePermissions = false) @@ -174,6 +175,7 @@ public function getStylesheet($isACP = false) * Resets stylesheet for given style. * * @param Style $style + * @return void */ public function resetStylesheet(Style $style) { @@ -201,6 +203,7 @@ public function countStyles() * Resets all stylesheets. * * @param bool $resetACP + * @return void */ public static function resetStylesheets($resetACP = true) { @@ -271,6 +274,8 @@ public function showColorSchemeSelector(): bool } /** + * @param boolean $toJSON + * @return array{}|string * @deprecated 6.0 Unsupported, this exists temporarily for development purposes. */ public function getIcons($toJSON = false) diff --git a/wcfsetup/install/files/lib/system/style/exception/FontDownloadFailed.class.php b/wcfsetup/install/files/lib/system/style/exception/FontDownloadFailed.class.php index 76c841763ed..89ea61aa614 100644 --- a/wcfsetup/install/files/lib/system/style/exception/FontDownloadFailed.class.php +++ b/wcfsetup/install/files/lib/system/style/exception/FontDownloadFailed.class.php @@ -12,11 +12,12 @@ */ class FontDownloadFailed extends \Exception { + private string $reason = ''; + /** - * @var string + * @param string $message + * @param string $reason */ - private $reason = ''; - public function __construct($message, $reason = '', ?\Throwable $previous = null) { parent::__construct($message, 0, $previous); diff --git a/wcfsetup/install/files/lib/system/tagging/TagCloud.class.php b/wcfsetup/install/files/lib/system/tagging/TagCloud.class.php index 8d7a7e7d765..e0750053697 100644 --- a/wcfsetup/install/files/lib/system/tagging/TagCloud.class.php +++ b/wcfsetup/install/files/lib/system/tagging/TagCloud.class.php @@ -57,6 +57,8 @@ public function __construct(array $languageIDs = []) /** * Loads the tag cloud cache. + * + * @return void */ protected function loadCache() { diff --git a/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php b/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php index 565515a9565..8def7f454f1 100644 --- a/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php +++ b/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php @@ -27,16 +27,25 @@ class TagEngine extends SingletonFactory * * @param string $objectType * @param int $objectID - * @param array $tags + * @param string[] $tags * @param int $languageID * @param bool $replace + * @return void */ public function addObjectTags($objectType, $objectID, array $tags, $languageID, $replace = true) { $objectTypeID = $this->getObjectTypeID($objectType); - $tags = \array_unique(\array_reduce(ArrayUtil::trim(\array_map(static function ($tag) { - return \explode(',', $tag); - }, $tags)), 'array_merge', [])); + $tags = \array_unique( + \array_reduce( + ArrayUtil::trim( + \array_map(static function ($tag) { + return \explode(',', $tag); + }, $tags) + ), + 'array_merge', + [] + ) + ); // remove tags prior to apply the new ones (prevents duplicate entries) if ($replace) { @@ -108,6 +117,7 @@ public function addObjectTags($objectType, $objectID, array $tags, $languageID, * @param string $objectType * @param int $objectID * @param int $languageID + * @return void */ public function deleteObjectTags($objectType, $objectID, $languageID = null) { @@ -136,6 +146,7 @@ public function deleteObjectTags($objectType, $objectID, $languageID = null) * * @param string $objectType * @param int[] $objectIDs + * @return void */ public function deleteObjects($objectType, array $objectIDs) { @@ -172,7 +183,7 @@ public function getObjectTags($objectType, $objectID, array $languageIDs = []) * @param string $objectType * @param int[] $objectIDs * @param int[] $languageIDs - * @return array + * @return array> */ public function getObjectsTags($objectType, array $objectIDs, array $languageIDs = []) { @@ -289,7 +300,7 @@ public function getTagIDs($tags) * * @param string $objectType * @param Tag[] $tags - * @return array + * @return array{sql: string, parameters: mixed[]} * @since 5.2 */ public function getSubselectForObjectsByTags($objectType, array $tags) diff --git a/wcfsetup/install/files/lib/system/tagging/TypedTagCloud.class.php b/wcfsetup/install/files/lib/system/tagging/TypedTagCloud.class.php index 93638a2d329..5159429cd69 100644 --- a/wcfsetup/install/files/lib/system/tagging/TypedTagCloud.class.php +++ b/wcfsetup/install/files/lib/system/tagging/TypedTagCloud.class.php @@ -37,6 +37,8 @@ public function __construct($objectType, array $languageIDs = []) /** * Loads the tag cloud cache. + * + * @return void */ protected function loadCache() { diff --git a/wcfsetup/install/files/lib/system/tagging/command/SetSynonym.class.php b/wcfsetup/install/files/lib/system/tagging/command/SetSynonym.class.php index a7e7771bd8b..9a0b63dd594 100644 --- a/wcfsetup/install/files/lib/system/tagging/command/SetSynonym.class.php +++ b/wcfsetup/install/files/lib/system/tagging/command/SetSynonym.class.php @@ -23,7 +23,7 @@ public function __construct( private readonly array $tags ) {} - public function __invoke() + public function __invoke(): void { $tagEditor = new TagEditor($this->mainTag); diff --git a/wcfsetup/install/files/lib/util/ArrayUtil.class.php b/wcfsetup/install/files/lib/util/ArrayUtil.class.php index 8041af1ba1f..ef7feb5741d 100644 --- a/wcfsetup/install/files/lib/util/ArrayUtil.class.php +++ b/wcfsetup/install/files/lib/util/ArrayUtil.class.php @@ -16,8 +16,8 @@ final class ArrayUtil /** * Applies StringUtil::trim() to all elements of the given array. * - * @param string[]|string $array - * @return string[]|string + * @param mixed[]|string $array + * @return mixed[]|string */ public static function trim(array|string $array, bool $removeEmptyElements = true): array|string { From 99f8734797400cc95b176bdf1ce472c57334bc71 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 16 Feb 2025 10:34:27 +0100 Subject: [PATCH 05/31] Improve the typing for PIPs --- ...TXmlGuiPackageInstallationPlugin.class.php | 4 +- ...LOptionPackageInstallationPlugin.class.php | 5 +++ ...ACPMenuPackageInstallationPlugin.class.php | 3 ++ ...roviderPackageInstallationPlugin.class.php | 5 +++ ...eDeletePackageInstallationPlugin.class.php | 6 +++ ...actMenuPackageInstallationPlugin.class.php | 6 +++ ...tOptionPackageInstallationPlugin.class.php | 6 +++ ...bstractPackageInstallationPlugin.class.php | 4 +- ...eDeletePackageInstallationPlugin.class.php | 1 + ...ractXMLPackageInstallationPlugin.class.php | 19 +++++---- .../BBCodePackageInstallationPlugin.class.php | 5 +++ .../BoxPackageInstallationPlugin.class.php | 5 +++ ...dActionPackageInstallationPlugin.class.php | 5 +++ ...eObjectPackageInstallationPlugin.class.php | 4 ++ ...CronjobPackageInstallationPlugin.class.php | 5 +++ ...istenerPackageInstallationPlugin.class.php | 5 +++ .../IPackageInstallationPlugin.class.php | 6 +++ ...NameXMLPackageInstallationPlugin.class.php | 2 + ...anguagePackageInstallationPlugin.class.php | 5 +++ ...roviderPackageInstallationPlugin.class.php | 5 +++ ...enuItemPackageInstallationPlugin.class.php | 5 +++ .../MenuPackageInstallationPlugin.class.php | 5 +++ ...initionPackageInstallationPlugin.class.php | 5 +++ ...ectTypePackageInstallationPlugin.class.php | 5 +++ .../OptionPackageInstallationPlugin.class.php | 3 ++ .../PIPPackageInstallationPlugin.class.php | 5 +++ .../PagePackageInstallationPlugin.class.php | 5 +++ .../SmileyPackageInstallationPlugin.class.php | 5 +++ ...istenerPackageInstallationPlugin.class.php | 5 +++ ...pOptionPackageInstallationPlugin.class.php | 3 ++ ...serMenuPackageInstallationPlugin.class.php | 3 ++ ...onEventPackageInstallationPlugin.class.php | 5 +++ ...rOptionPackageInstallationPlugin.class.php | 3 ++ ...ileMenuPackageInstallationPlugin.class.php | 6 +++ .../PackageValidationArchive.class.php | 20 ++++------ .../PackageValidationException.class.php | 2 + .../PackageValidationManager.class.php | 2 +- .../system/page/PageLocationManager.class.php | 12 +++--- .../CategoryArticleListPageHandler.class.php | 1 + .../IOnlineLocationPageHandler.class.php | 1 + .../TOnlineLocationPageHandler.class.php | 4 +- .../TUserOnlineLocationPageHandler.class.php | 1 + .../handler/TrophyListPageHandler.class.php | 1 + .../payment/type/IPaymentType.class.php | 3 +- .../lib/system/poll/IPollHandler.class.php | 1 + .../lib/system/poll/PollManager.class.php | 10 ++++- .../system/reaction/ReactionHandler.class.php | 39 ++++++++++++++----- 47 files changed, 223 insertions(+), 43 deletions(-) diff --git a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php index 442b44f3c0d..687f5eae856 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php @@ -86,6 +86,7 @@ public function addEntry(IFormDocument $form) * Adds all fields to the given form to add or edit an entry. * * @param IFormDocument $form + * @return void */ abstract protected function addFormFields(IFormDocument $form); @@ -347,7 +348,7 @@ protected function getElementByIdentifier(XML $xml, $identifier) * * @param \DOMElement $element element whose data is returned * @param bool $saveData is `true` if data is intended to be saved and otherwise `false` - * @return array + * @return array */ abstract protected function fetchElementData(\DOMElement $element, $saveData); @@ -693,6 +694,7 @@ public function setEntryData($identifier, IFormDocument $document) * Sets the keys of the given (empty) entry list. * * @param IDevtoolsPipEntryList $entryList + * @return void */ abstract protected function setEntryListKeys(IDevtoolsPipEntryList $entryList); diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php index e74261d3ae9..b0860e35b8b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php @@ -529,6 +529,8 @@ public function getEntryTypes() /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -571,6 +573,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -591,6 +594,7 @@ protected function getXsdFilename() /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -603,6 +607,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php index d4cea4e95b3..7b166ced865 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php @@ -162,6 +162,8 @@ static function (TextFormField $formField) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -187,6 +189,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php index feade637c6d..017b6368a2b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php @@ -130,6 +130,8 @@ public static function getSyncDependencies() /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -152,6 +154,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -226,6 +229,7 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -238,6 +242,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractFileDeletePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractFileDeletePackageInstallationPlugin.class.php index 516fd482589..7b5329263d9 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractFileDeletePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractFileDeletePackageInstallationPlugin.class.php @@ -233,6 +233,7 @@ protected function getFileFieldDescription(): ?string /** * @inheritDoc + * @return void */ protected function addFormFields(IFormDocument $form) { @@ -268,6 +269,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array */ protected function fetchElementData(\DOMElement $element, $saveData) { @@ -280,6 +283,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string */ public function getElementIdentifier(\DOMElement $element) { @@ -290,6 +294,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) { @@ -317,6 +322,7 @@ protected function insertNewXmlElement(XML $xml, \DOMElement $newElement) /** * @inheritDoc + * @return \DOMElement */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) { diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php index b2d9e096402..73121e51f17 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php @@ -129,6 +129,7 @@ public static function getSyncDependencies() /** * @inheritDoc + * @return void * @since 5.2 */ protected function addFormFields(IFormDocument $form) @@ -327,6 +328,8 @@ function (SingleSelectionFormField $formField) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -389,6 +392,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -454,6 +458,7 @@ protected function getMenuStructureData() /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -466,6 +471,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php index d37f2e29364..71ec716e0ef 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php @@ -429,6 +429,7 @@ public static function getSyncDependencies() /** * @inheritDoc + * @return void * @since 5.2 */ protected function addFormFields(IFormDocument $form) @@ -746,6 +747,8 @@ static function (IFormDocument $document, array $parameters) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -900,6 +903,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -997,6 +1001,7 @@ protected function saveObject(\DOMElement $newElement, ?\DOMElement $oldElement /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -1024,6 +1029,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php index b76888ef2a7..b78e53ca5b1 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php @@ -36,7 +36,7 @@ abstract class AbstractPackageInstallationPlugin implements IPackageInstallation /** * install/update instructions - * @var array + * @var mixed[] */ public $instruction = []; @@ -44,7 +44,7 @@ abstract class AbstractPackageInstallationPlugin implements IPackageInstallation * Creates a new AbstractPackageInstallationPlugin object. * * @param PackageInstallationDispatcher $installation - * @param array $instruction + * @param mixed[] $instruction */ public function __construct(PackageInstallationDispatcher $installation, $instruction = []) { diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php index 066a15e9f73..88349a64724 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractTemplateDeletePackageInstallationPlugin.class.php @@ -32,6 +32,7 @@ protected function getFilenameTableColumn(): string /** * @inheritDoc + * @return void */ protected function addFormFields(IFormDocument $form) { diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php index 2846343ef2d..bf5171f3743 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php @@ -317,7 +317,8 @@ protected function postImport() {} /** * Deletes the given items. * - * @param array $items + * @param mixed[] $items + * @return void */ abstract protected function handleDelete(array $items); @@ -325,8 +326,8 @@ abstract protected function handleDelete(array $items); * Prepares import, use this to map xml tags and attributes * to their corresponding database fields. * - * @param array $data - * @return array + * @param mixed[] $data + * @return mixed[] */ abstract protected function prepareImport(array $data); @@ -334,7 +335,8 @@ abstract protected function prepareImport(array $data); * Validates given item, e.g. checking for invalid values. If validation * fails you should throw an exception. * - * @param array $data + * @param mixed[] $data + * @return void */ protected function validateImport(array $data) {} @@ -342,8 +344,8 @@ protected function validateImport(array $data) {} * Returns an array with a sql query and its parameters to find an existing item for updating * or `null` if updates are not supported. * - * @param array $data - * @return array|null + * @param mixed[] $data + * @return mixed[]|null */ abstract protected function findExistingItem(array $data); @@ -353,7 +355,8 @@ abstract protected function findExistingItem(array $data); * * Attention: $data is passed by reference * - * @param array $data + * @param mixed[] $data + * @return void */ protected function prepareCreate(array &$data) { @@ -362,6 +365,8 @@ protected function prepareCreate(array &$data) /** * Triggered after executing all delete and/or import actions. + * + * @return void */ protected function cleanup() {} diff --git a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php index 2d6a5932a5c..7f62f111ddb 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php @@ -260,6 +260,8 @@ public static function getSyncDependencies() /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -335,6 +337,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -531,6 +534,7 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -544,6 +548,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php index f3a3038506b..aef470e18a5 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php @@ -654,6 +654,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -816,6 +818,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -825,6 +828,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -837,6 +841,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php index bf71f8848d6..36fa6ba3d3e 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php @@ -263,6 +263,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -299,6 +301,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -311,6 +314,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -323,6 +327,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php index 44fc8716c1b..ef288412684 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php @@ -139,6 +139,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -151,6 +153,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -160,6 +163,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) diff --git a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php index 182afa863e4..491135528a1 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php @@ -324,6 +324,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -443,6 +445,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -452,6 +455,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -464,6 +468,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php index 36994e3e483..cb1b4a4f4ec 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/EventListenerPackageInstallationPlugin.class.php @@ -346,6 +346,8 @@ public function editEntry(IFormDocument $form, $identifier) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -398,6 +400,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -407,6 +410,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -420,6 +424,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php index 97618f10ce1..faab5e7aac1 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php @@ -15,11 +15,15 @@ interface IPackageInstallationPlugin { /** * Executes the installation of this plugin. + * + * @return void */ public function install(); /** * Executes the update of this plugin. + * + * @return void */ public function update(); @@ -33,6 +37,8 @@ public function hasUninstall(); /** * Executes the uninstallation of this plugin. + * + * @return void */ public function uninstall(); diff --git a/wcfsetup/install/files/lib/system/package/plugin/IUniqueNameXMLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/IUniqueNameXMLPackageInstallationPlugin.class.php index 92f9509f8f7..049174c8363 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/IUniqueNameXMLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/IUniqueNameXMLPackageInstallationPlugin.class.php @@ -15,6 +15,8 @@ interface IUniqueNameXMLPackageInstallationPlugin { /** * Returns the name of an element by the given data. + * + * @param mixed[] $data */ public function getNameByData(array $data): string; } diff --git a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php index f6db33c1f6b..7e9df12faec 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php @@ -516,6 +516,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -560,6 +562,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -748,6 +751,7 @@ protected function saveObject(\DOMElement $newElement, ?\DOMElement $oldElement /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -766,6 +770,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php index b10cec72ed5..50d735ee24e 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php @@ -221,6 +221,8 @@ static function (IFormDocument $document, array $parameters) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -251,6 +253,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -260,6 +263,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -272,6 +276,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php index f2a193474c9..1606b725ed7 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php @@ -450,6 +450,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -538,6 +540,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -547,6 +550,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -559,6 +563,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php index fb53237dcaf..36bc494e1c3 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php @@ -443,6 +443,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -538,6 +540,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -547,6 +550,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -558,6 +562,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php index ab36011efba..78c8ed9abd6 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php @@ -167,6 +167,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -188,6 +190,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -197,6 +200,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -209,6 +213,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php index a40aecd200c..35458cd35ed 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php @@ -212,6 +212,8 @@ public function getAdditionalTemplateCode() /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -837,6 +839,7 @@ static function (UserGroupOptionFormField $formField) { /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -872,6 +875,7 @@ public function getEntryList() /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -917,6 +921,7 @@ public function getObjectTypeDefinitionDataContainer(IFormDocument $form, $defin /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php index 8d483572277..ca0e4eddc44 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php @@ -317,6 +317,8 @@ static function (IFormDocument $document, array $parameters) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -383,6 +385,7 @@ public function getCategoryOptions($categoryName = '', $inherit = true) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php index 66b582f0625..f9b2ad011cf 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php @@ -154,6 +154,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -167,6 +169,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -176,6 +179,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -188,6 +192,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php index b1e7fc32233..b41e00a032a 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -643,6 +643,8 @@ static function (SingleSelectionFormField $formField) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -794,6 +796,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -803,6 +806,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -815,6 +819,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php index 3c8253c21f9..a9d98b71b7e 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php @@ -263,6 +263,8 @@ static function (IFormDocument $document, array $parameters) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -303,6 +305,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -312,6 +315,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -324,6 +328,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php index 06d2577a486..8271d46ba0d 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php @@ -394,6 +394,8 @@ static function (IFormDocument $document, array $parameters) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -428,6 +430,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -505,6 +508,7 @@ public function editEntry(IFormDocument $form, $identifier) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -519,6 +523,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php index 17bd0ff59f7..d3329d32970 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php @@ -317,6 +317,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -399,6 +401,7 @@ public function getCategoryOptions($categoryName = '', $inherit = true) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php index 50b93224d42..959332f4d0b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php @@ -141,6 +141,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -173,6 +175,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php index 706edc8a847..8925091ea6b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php @@ -310,6 +310,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -361,6 +363,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -373,6 +376,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -385,6 +389,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php index e850698c432..73acff15588 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php @@ -397,6 +397,8 @@ static function (IFormDocument $document, array $parameters) { /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -482,6 +484,7 @@ public function getCategoryOptions($categoryName = '', $inherit = true) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php index 099d0a28d3f..07396e70e61 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php @@ -123,6 +123,7 @@ public static function getSyncDependencies() /** * @inheritDoc + * @return void * @since 5.2 */ protected function addFormFields(IFormDocument $form) @@ -198,6 +199,8 @@ protected function addFormFields(IFormDocument $form) /** * @inheritDoc + * @param bool $saveData + * @return array * @since 5.2 */ protected function fetchElementData(\DOMElement $element, $saveData) @@ -236,6 +239,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) /** * @inheritDoc + * @return string * @since 5.2 */ public function getElementIdentifier(\DOMElement $element) @@ -245,6 +249,7 @@ public function getElementIdentifier(\DOMElement $element) /** * @inheritDoc + * @return void * @since 5.2 */ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) @@ -257,6 +262,7 @@ protected function setEntryListKeys(IDevtoolsPipEntryList $entryList) /** * @inheritDoc + * @return \DOMElement * @since 5.2 */ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form) diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php index cc8b91bd9bf..b0366ba79cb 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php @@ -15,6 +15,7 @@ * @author Alexander Ebert * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License + * @implements \RecursiveIterator */ final class PackageValidationArchive implements \RecursiveIterator { @@ -22,7 +23,7 @@ final class PackageValidationArchive implements \RecursiveIterator * list of excluded packages grouped by package * @var string[][][] */ - private static $excludedPackages = []; + private static array $excludedPackages = []; /** * package archive object @@ -33,7 +34,7 @@ final class PackageValidationArchive implements \RecursiveIterator * list of direct requirements delivered by this package * @var PackageValidationArchive[] */ - private $children = []; + private array $children = []; /** * nesting depth @@ -47,9 +48,8 @@ final class PackageValidationArchive implements \RecursiveIterator /** * associated package object - * @var Package */ - private $package; + private ?Package $package = null; /** * children pointer @@ -68,10 +68,8 @@ public function __construct(string $archive, int $depth = 0) /** * Validates this package and optionally it's delivered requirements. The set validation * mode will toggle between different checks. - * - * @param int $validationMode */ - public function validate($validationMode, string $requiredVersion = ''): bool + public function validate(int $validationMode, string $requiredVersion = ''): bool { if ($validationMode !== PackageValidationManager::VALIDATION_EXCLUSION) { try { @@ -201,10 +199,9 @@ private function validateApplication(): void /** * Validates if the package has suitable install or update instructions * - * @param int $validationMode * @throws PackageValidationException */ - private function validateInstructions(string $requiredVersion, $validationMode) + private function validateInstructions(string $requiredVersion, int $validationMode): void { $package = $this->getPackage(); @@ -258,11 +255,10 @@ private function validateInstructions(string $requiredVersion, $validationMode) /** * Validates install or update instructions against the corresponding PIP, unknown PIPs will be silently ignored. * - * @param string $type * @param mixed[][] $instructions * @throws PackageValidationException */ - private function validatePackageInstallationPlugins($type, array $instructions) + private function validatePackageInstallationPlugins(string $type, array $instructions): void { for ($i = 0, $length = \count($instructions); $i < $length; $i++) { $instruction = $instructions[$i]; @@ -290,7 +286,7 @@ private function validatePackageInstallationPlugins($type, array $instructions) * * @throws PackageValidationException */ - private function validateExclusion(string $package) + private function validateExclusion(string $package): void { $packageVersion = $this->archive->getPackageInfo('version'); diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php index aca7c1165c4..19c2ef24b0e 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php @@ -302,6 +302,8 @@ protected function getLegacyMessage($code) /** * @inheritDoc + * + * @return void */ protected function logError() { diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php index ecca2e09b6a..f4d9c9ab2c6 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php @@ -135,7 +135,7 @@ public function getVirtualPackage($package) /** * Returns the iterable package archive list. * - * @return \RecursiveIteratorIterator + * @return \RecursiveIteratorIterator */ public function getPackageValidationArchiveList() { diff --git a/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php b/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php index a3b3460842c..76d180024c9 100644 --- a/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php +++ b/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php @@ -16,6 +16,7 @@ * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License * @since 3.0 + * @phpstan-type Location array{identifier: string, link: string, pageID: int, pageObjectID: int, title: string, useAsParentLocation: bool} */ class PageLocationManager extends SingletonFactory { @@ -27,13 +28,11 @@ class PageLocationManager extends SingletonFactory /** * list of locations with descending priority - * @var array + * @var list */ protected $stack = []; - /** - * @inheritDoc - */ + #[\Override] public function init() { $pageID = $pageObjectID = 0; @@ -78,6 +77,7 @@ public function init() * @param int $pageObjectID page object id * @param ITitledLinkObject $locationObject optional label for breadcrumbs usage * @param bool $useAsParentLocation + * @return void * @throws SystemException */ public function addParentLocation( @@ -124,7 +124,7 @@ public function addParentLocation( /** * Returns the list of locations with descending priority. * - * @return array + * @return list */ public function getLocations() { @@ -139,6 +139,8 @@ public function getLocations() /** * Adds all parents as defined through the page configuration. + * + * @return void */ protected function addParents() { diff --git a/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php index cfe22dc6e28..42718056c73 100644 --- a/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php @@ -18,6 +18,7 @@ class CategoryArticleListPageHandler extends AbstractLookupPageHandler implement use TDecoratedCategoryOnlineLocationLookupPageHandler; /** + * @return string * @see TDecoratedCategoryLookupPageHandler::getDecoratedCategoryClass() */ protected function getDecoratedCategoryClass() diff --git a/wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php index 35bcf88ae4f..6851cf7d4c8 100644 --- a/wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php @@ -30,6 +30,7 @@ public function getOnlineLocation(Page $page, UserOnline $user); * * @param Page $page visited page * @param UserOnline $user user online object with request data + * @return void */ public function prepareOnlineLocation(Page $page, UserOnline $user); } diff --git a/wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php index 8021fcf4603..254c5eee941 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php @@ -19,7 +19,7 @@ trait TOnlineLocationPageHandler { /** - * @inheritDoc + * @return string */ public function getOnlineLocation(Page $page, UserOnline $user) { @@ -27,7 +27,7 @@ public function getOnlineLocation(Page $page, UserOnline $user) } /** - * @inheritDoc + * @return void */ public function prepareOnlineLocation(Page $page, UserOnline $user) { diff --git a/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php index 37f61016340..b4d3b854b79 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php @@ -50,6 +50,7 @@ public function getOnlineLocation(Page $page, UserOnline $user) * * @param Page $page visited page * @param UserOnline $user user online object with request data + * @return void * @see IOnlineLocationPageHandler::prepareOnlineLocation() */ public function prepareOnlineLocation(Page $page, UserOnline $user) diff --git a/wcfsetup/install/files/lib/system/page/handler/TrophyListPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TrophyListPageHandler.class.php index b98590fc230..e2f726e61b0 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TrophyListPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TrophyListPageHandler.class.php @@ -18,6 +18,7 @@ class TrophyListPageHandler extends AbstractLookupPageHandler /** * @inheritDoc + * @return string */ protected function getDecoratedCategoryClass() { diff --git a/wcfsetup/install/files/lib/system/payment/type/IPaymentType.class.php b/wcfsetup/install/files/lib/system/payment/type/IPaymentType.class.php index 6e89d3c430e..d9885189ba6 100644 --- a/wcfsetup/install/files/lib/system/payment/type/IPaymentType.class.php +++ b/wcfsetup/install/files/lib/system/payment/type/IPaymentType.class.php @@ -20,7 +20,8 @@ interface IPaymentType * @param string $currency * @param string $transactionID * @param string $status - * @param array $transactionDetails + * @param mixed[] $transactionDetails + * @return void */ public function processTransaction( $paymentMethodObjectTypeID, diff --git a/wcfsetup/install/files/lib/system/poll/IPollHandler.class.php b/wcfsetup/install/files/lib/system/poll/IPollHandler.class.php index e5b052f0bdc..881f54aa212 100644 --- a/wcfsetup/install/files/lib/system/poll/IPollHandler.class.php +++ b/wcfsetup/install/files/lib/system/poll/IPollHandler.class.php @@ -31,6 +31,7 @@ public function canVote(); * Returns related object for given poll object. * * @param Poll $poll + * @return ?object */ public function getRelatedObject(Poll $poll); } diff --git a/wcfsetup/install/files/lib/system/poll/PollManager.class.php b/wcfsetup/install/files/lib/system/poll/PollManager.class.php index 1ceea12be30..8525fac1434 100644 --- a/wcfsetup/install/files/lib/system/poll/PollManager.class.php +++ b/wcfsetup/install/files/lib/system/poll/PollManager.class.php @@ -92,6 +92,7 @@ protected function init() * Removes a list of polls by id. * * @param int[] $pollIDs + * @return void */ public function removePolls(array $pollIDs) { @@ -162,7 +163,8 @@ public function setObject($objectType, $objectID, $pollID = 0) /** * Reads form parameters for polls. * - * @param array $postData optional post data to be used instead of $_POST + * @param array $postData optional post data to be used instead of $_POST + * @return void */ public function readFormParameters(array $postData = []) { @@ -212,6 +214,8 @@ public function readFormParameters(array $postData = []) /** * Validates poll parameters. + * + * @return void */ public function validate() { @@ -315,7 +319,7 @@ public function save($objectID = null) * This method either creates a new poll or updates or deletes an existing poll. * * @param IPollContainer $pollContainer object the poll belongs to - * @param array $pollData poll data + * @param mixed[] $pollData poll data * @return null|int id of the poll * @since 5.2 */ @@ -350,6 +354,8 @@ public function savePoll(IPollContainer $pollContainer, array $pollData) /** * Assigns variables for poll management or display. + * + * @return void */ public function assignVariables() { diff --git a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php index acd5bc0a17b..e509d78136d 100644 --- a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php +++ b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php @@ -153,6 +153,7 @@ public function getDataAttributes($objectTypeName, $objectID) * * @param string $objectTypeName * @param int[] $objectIDs + * @return void */ public function cacheLikeableObjects($objectTypeName, array $objectIDs) { @@ -256,7 +257,7 @@ public function getLikeObjects(ObjectType $objectType) * like objects * * @param ObjectType $objectType - * @param array $objectIDs + * @param int[] $objectIDs * @return int */ public function loadLikeObjects(ObjectType $objectType, array $objectIDs) @@ -309,8 +310,13 @@ public function loadLikeObjects(ObjectType $objectType, array $objectIDs) * @param User $user * @param int $reactionTypeID * @param int $time - * @return array - * @throws DatabaseQueryException + * @return array{ + * cachedReactions: array, + * reactionTypeID: ?int, + * like?: Like, + * likeObject: LikeObject|array{}, + * cumulativeLikes: int, + * } */ public function react(ILikeObject $likeable, User $user, $reactionTypeID, $time = TIME_NOW) { @@ -451,7 +457,7 @@ public function react(ILikeObject $likeable, User $user, $reactionTypeID, $time * @param LikeObject $likeObject * @param Like $like * @param ReactionType $reactionType - * @return array + * @return array{cumulativeLikes: int, cachedReactions: array, likeObject: LikeObject} */ private function updateLikeObject( ILikeObject $likeable, @@ -548,6 +554,7 @@ private function updateLikeObject( * @param LikeObject $likeObject * @param Like $like * @param ReactionType $reactionType + * @return void */ private function updateUsersLikeCounter( ILikeObject $likeable, @@ -579,7 +586,12 @@ private function updateUsersLikeCounter( * @param ILikeObject $likeable * @param LikeObject $likeObject * @param User $user - * @return array + * @return array{ + * cachedReactions: array, + * reactionTypeID: null, + * likeObject: LikeObject|array{}, + * cumulativeLikes: ?int, + * } */ public function revertReact(Like $like, ILikeObject $likeable, LikeObject $likeObject, User $user) { @@ -641,7 +653,7 @@ public function revertReact(Like $like, ILikeObject $likeable, LikeObject $likeO * * @param LikeObject $likeObject * @param Like $like - * @return array + * @return array{cumulativeLikes: int, cachedReactions: array, likeObject: LikeObject} */ private function revertLikeObject(LikeObject $likeObject, Like $like) { @@ -692,6 +704,7 @@ private function revertLikeObject(LikeObject $likeObject, Like $like) * @param string $objectType * @param int[] $objectIDs * @param string[] $notificationObjectTypes + * @return void */ public function removeReactions($objectType, array $objectIDs, array $notificationObjectTypes = []) { @@ -783,7 +796,13 @@ public function removeReactions($objectType, array $objectIDs, array $notificati * * @param LikeObject $likeObject * @param User $user - * @return array + * @return array{ + * likes: int, + * dislikes: int, + * cumulativeLikes: int, + * reactionTypeID: int, + * likeValue: int + * } */ protected function loadLikeStatus(LikeObject $likeObject, User $user) { @@ -840,8 +859,8 @@ public function getFirstReactionTypeID() /** * Removes deleted reactions from the reaction counter for the like object table. * - * @param array $cachedReactions - * @return array + * @param array $cachedReactions + * @return array */ private function cleanUpCachedReactions(array $cachedReactions) { @@ -856,7 +875,7 @@ private function cleanUpCachedReactions(array $cachedReactions) /** * @param string|null $cachedReactions - * @return array|null + * @return array{count: int, other: int, reaction: ?ReactionType}|null * @since 5.2 */ public function getTopReaction($cachedReactions) From fbe802b87c01c0e741ed9c475e05e0ad3c9c9b41 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 16 Feb 2025 13:58:01 +0100 Subject: [PATCH 06/31] Fix some remaining issues with PIPs --- phpstan-baseline.neon | 8 +++---- ...iXmlGuiPackageInstallationPlugin.class.php | 1 + ...TXmlGuiPackageInstallationPlugin.class.php | 1 + .../system/option/IOptionHandler.class.php | 4 +++- ...LOptionPackageInstallationPlugin.class.php | 3 +++ ...ACPMenuPackageInstallationPlugin.class.php | 1 + ...roviderPackageInstallationPlugin.class.php | 2 ++ ...emplatePackageInstallationPlugin.class.php | 1 + ...eDeletePackageInstallationPlugin.class.php | 5 ++++- ...actMenuPackageInstallationPlugin.class.php | 10 ++++++--- ...tOptionPackageInstallationPlugin.class.php | 22 ++++++++++++++----- ...ractXMLPackageInstallationPlugin.class.php | 13 +++++++---- .../BBCodePackageInstallationPlugin.class.php | 2 ++ .../BoxPackageInstallationPlugin.class.php | 3 ++- ...dActionPackageInstallationPlugin.class.php | 5 ++++- ...eObjectPackageInstallationPlugin.class.php | 4 ++++ ...CronjobPackageInstallationPlugin.class.php | 3 ++- ...istenerPackageInstallationPlugin.class.php | 1 + .../FilePackageInstallationPlugin.class.php | 1 + .../IPackageInstallationPlugin.class.php | 4 ++-- ...anguagePackageInstallationPlugin.class.php | 12 +++++++++- ...roviderPackageInstallationPlugin.class.php | 1 + ...enuItemPackageInstallationPlugin.class.php | 1 + .../MenuPackageInstallationPlugin.class.php | 3 ++- ...initionPackageInstallationPlugin.class.php | 3 +++ ...ectTypePackageInstallationPlugin.class.php | 7 +++++- .../OptionPackageInstallationPlugin.class.php | 2 ++ .../PIPPackageInstallationPlugin.class.php | 1 + .../PagePackageInstallationPlugin.class.php | 1 + .../ScriptPackageInstallationPlugin.class.php | 2 +- .../SmileyPackageInstallationPlugin.class.php | 1 + .../StylePackageInstallationPlugin.class.php | 1 + ...istenerPackageInstallationPlugin.class.php | 3 +++ ...emplatePackageInstallationPlugin.class.php | 1 + ...pOptionPackageInstallationPlugin.class.php | 2 ++ ...serMenuPackageInstallationPlugin.class.php | 3 ++- ...onEventPackageInstallationPlugin.class.php | 3 +++ ...rOptionPackageInstallationPlugin.class.php | 5 ++++- 38 files changed, 117 insertions(+), 29 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6040e68a17d..b5c7946a8f3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1293,13 +1293,13 @@ parameters: - message: '#^Call to function assert\(\) with true will always evaluate to true\.$#' identifier: function.alreadyNarrowedType - count: 1 + count: 2 path: wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php - message: '#^Instanceof between DOMElement and DOMElement will always evaluate to true\.$#' identifier: instanceof.alwaysTrue - count: 1 + count: 2 path: wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php - @@ -1311,13 +1311,13 @@ parameters: - message: '#^Call to function assert\(\) with true will always evaluate to true\.$#' identifier: function.alreadyNarrowedType - count: 1 + count: 2 path: wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php - message: '#^Instanceof between DOMElement and DOMElement will always evaluate to true\.$#' identifier: instanceof.alwaysTrue - count: 1 + count: 2 path: wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php - diff --git a/wcfsetup/install/files/lib/system/devtools/pip/TMultiXmlGuiPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/devtools/pip/TMultiXmlGuiPackageInstallationPlugin.class.php index 23fb348285c..cfcbc20c673 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/TMultiXmlGuiPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/TMultiXmlGuiPackageInstallationPlugin.class.php @@ -254,6 +254,7 @@ public function deleteEntry($identifier, $addDeleteInstruction) /** * @inheritDoc + * @return void */ protected function deleteObject(\DOMElement $element) { diff --git a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php index 687f5eae856..e68733f2337 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php @@ -254,6 +254,7 @@ protected function sanitizeXmlFileAfterDeleteEntry(\DOMDocument $document) * Deletes the given element from database. * * @param \DOMElement $element + * @return void */ protected function deleteObject(\DOMElement $element) { diff --git a/wcfsetup/install/files/lib/system/option/IOptionHandler.class.php b/wcfsetup/install/files/lib/system/option/IOptionHandler.class.php index c2e2c49f772..be2e8427d69 100644 --- a/wcfsetup/install/files/lib/system/option/IOptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/IOptionHandler.class.php @@ -2,6 +2,8 @@ namespace wcf\system\option; +use wcf\data\option\Option; + /** * Every option handler has to implement this interface. * @@ -48,7 +50,7 @@ public function getOptionTree($parentCategoryName = '', $level = 0); * * @param string $categoryName * @param bool $inherit - * @return array + * @return list