Skip to content

Commit

Permalink
Fix level 1 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntimeX committed Feb 5, 2025
1 parent 92145b7 commit 0632172
Show file tree
Hide file tree
Showing 76 changed files with 352 additions and 143 deletions.
4 changes: 4 additions & 0 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,7 @@
\define('FORMATTING_REMOVE_COLOR', 1);
\define('FORMATTING_REMOVE_FONT', 1);
\define('FORMATTING_REMOVE_SIZE', 1);
\define('URL_UNFURLING_SAVE_IMAGES', 1);
\define('SERVICE_WORKER_PRIVATE_KEY', '');
\define('SERVICE_WORKER_PUBLIC_KEY', '');
\define('RECAPTCHA_PRIVATEKEY_V3', '');
121 changes: 121 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
parameters:
ignoreErrors:
-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 1
path: wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_spider_step1.php

-
message: '#^Constructor of class wcf\\data\\clipboard\\item\\ClipboardItemAction has an unused parameter \$objects\.$#'
identifier: constructor.unusedParameter
count: 1
path: wcfsetup/install/files/lib/data/clipboard/item/ClipboardItemAction.class.php

-
message: '#^Call to static method error\(\) on an unknown class phpline\\internal\\Log\.$#'
identifier: class.notFound
count: 3
path: wcfsetup/install/files/lib/system/CLIWCF.class.php

-
message: '#^Call to static method get\(\) on an unknown class phpline\\TerminalFactory\.$#'
identifier: class.notFound
count: 1
path: wcfsetup/install/files/lib/system/CLIWCF.class.php

-
message: '#^Call to static method warn\(\) on an unknown class phpline\\internal\\Log\.$#'
identifier: class.notFound
count: 1
path: wcfsetup/install/files/lib/system/CLIWCF.class.php

-
message: '#^Constant VERBOSITY not found\.$#'
identifier: constant.notFound
count: 1
path: wcfsetup/install/files/lib/system/CLIWCF.class.php

-
message: '#^Instantiated class phpline\\console\\ConsoleReader not found\.$#'
identifier: class.notFound
count: 1
path: wcfsetup/install/files/lib/system/CLIWCF.class.php

-
message: '#^Instantiated class phpline\\console\\history\\MemoryHistory not found\.$#'
identifier: class.notFound
count: 1
path: wcfsetup/install/files/lib/system/CLIWCF.class.php

-
message: '#^Constant INSTALL_SCRIPT not found\.$#'
identifier: constant.notFound
count: 1
path: wcfsetup/install/files/lib/system/WCFSetup.class.php

-
message: '#^Constant INSTALL_SCRIPT_DIR not found\.$#'
identifier: constant.notFound
count: 5
path: wcfsetup/install/files/lib/system/WCFSetup.class.php

-
message: '#^Constant SETUP_FILE not found\.$#'
identifier: constant.notFound
count: 3
path: wcfsetup/install/files/lib/system/WCFSetup.class.php

-
message: '#^Constant TMP_FILE_PREFIX not found\.$#'
identifier: constant.notFound
count: 5
path: wcfsetup/install/files/lib/system/WCFSetup.class.php

-
message: '#^Call to static method info\(\) on an unknown class phpline\\internal\\Log\.$#'
identifier: class.notFound
count: 2
path: wcfsetup/install/files/lib/system/cli/command/CLICommandHandler.class.php

-
message: '#^Call to static method debug\(\) on an unknown class phpline\\internal\\Log\.$#'
identifier: class.notFound
count: 1
path: wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php

-
message: '#^Call to static method info\(\) on an unknown class phpline\\internal\\Log\.$#'
identifier: class.notFound
count: 2
path: wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php

-
message: '#^Constructor of class wcf\\system\\exception\\ErrorException has an unused parameter \$filename\.$#'
identifier: constructor.unusedParameter
count: 1
path: wcfsetup/install/files/lib/system/exception/ErrorException.class.php

-
message: '#^Constructor of class wcf\\system\\exception\\ErrorException has an unused parameter \$lineno\.$#'
identifier: constructor.unusedParameter
count: 1
path: wcfsetup/install/files/lib/system/exception/ErrorException.class.php

-
message: '#^Call to an undefined method wcf\\system\\form\\builder\\container\\wysiwyg\\WysiwygFormContainer\:\:addValidationError\(\)\.$#'
identifier: method.notFound
count: 2
path: wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php

-
message: '#^Method wcf\\system\\package\\plugin\\LanguagePackageInstallationPlugin\:\:getEmptyXml\(\) invoked with 0 parameters, 1 required\.$#'
identifier: arguments.count
count: 1
path: wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php

-
message: '#^Call to static method stripAnsi\(\) on an unknown class phpline\\internal\\AnsiUtil\.$#'
identifier: class.notFound
count: 3
path: wcfsetup/install/files/lib/util/CLIUtil.class.php
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- phpstan-baseline.neon

parameters:
level: 1
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use wcf\acp\form\FirstTimeSetupLicenseForm;
use wcf\acp\form\FirstTimeSetupOptionsEmailForm;
use wcf\acp\form\FirstTimeSetupOptionsForm;
use wcf\acp\page\FirstTimeSetupCompletedPage;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GuzzleHttp\Exception\ConnectException;
use Psr\Http\Client\ClientExceptionInterface;
use wcf\acp\action\FirstTimeSetupAction;
use wcf\data\option\Option;
use wcf\data\option\OptionAction;
use wcf\data\package\update\server\PackageUpdateServerAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace wcf\acp\form;

use wcf\acp\action\FirstTimeSetupAction;
use wcf\data\option\Option;
use wcf\data\option\OptionAction;
use wcf\system\exception\PermissionDeniedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace wcf\acp\form;

use wcf\acp\action\FirstTimeSetupAction;
use wcf\data\option\Option;
use wcf\data\option\OptionAction;
use wcf\system\exception\PermissionDeniedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class UserTrophyAddForm extends AbstractAcpForm

/**
* usernames (comma separated)
* @var string[]
* @var string
*/
public $user = '';

Expand Down Expand Up @@ -146,7 +146,7 @@ protected function validateUser()
}
}

if (!empty($error)) {
if ($error !== []) {
throw new UserInputException('user', $error);
}
}
Expand Down
41 changes: 36 additions & 5 deletions wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
*/
abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements IEditableObject
{
use TFastCreate {
TFastCreate::fastCreate as private dboEditorCreateBase;
}

/**
* @inheritDoc
*/
public static function create(array $parameters = [])
{
return new static::$baseClass(static::dboEditorCreateBase($parameters));
return new static::$baseClass(static::fastCreate($parameters));
}

/**
Expand Down Expand Up @@ -137,4 +133,39 @@ public static function createOrIgnore(array $parameters = [])
throw $e;
}
}

/**
* Creates the object and returns the ID.
*/
public static function fastCreate(array $parameters): int|string
{
$keys = $values = '';
$statementParameters = [];
foreach ($parameters as $key => $value) {
if (!empty($keys)) {
$keys .= ',';
$values .= ',';
}

$keys .= $key;
$values .= '?';
$statementParameters[] = $value;
}

// save object
$sql = "INSERT INTO " . static::getDatabaseTableName() . "
(" . $keys . ")
VALUES (" . $values . ")";
$statement = WCF::getDB()->prepare($sql);
$statement->execute($statementParameters);

// return new object
if (static::getDatabaseTableIndexIsIdentity()) {
$id = WCF::getDB()->getInsertID(static::getDatabaseTableName(), static::getDatabaseTableIndexName());
} else {
$id = $parameters[static::getDatabaseTableIndexName()];
}

return $id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.0
* @property-read string $options
*/
trait TDatabaseObjectOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.0
* @property-read string $permissions
*/
trait TDatabaseObjectPermissions
{
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/files/lib/data/TFastCreate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 5.4
* @deprecated 6.2 Moved into `DatabaseObjectEditor`.
*/
trait TFastCreate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getLink(): string
// links of top option category menu items need the id of the option
// category
if ($this->parentMenuItem == 'wcf.acp.menu.link.option.category') {
/** @noinspection PhpUndefinedFieldInspection */
/** @phpstan-ignore property.notFound */
$linkParameters['id'] = $this->optionCategoryID;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public function delete()
// delete entry from search index
SearchIndexManager::getInstance()->delete('com.woltlab.wcf.article', $articleContentIDs);

parent::delete();
return parent::delete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ public function readObjects()
}
}

if (isset($articleList)) {
if ($articleList->search($articleContent->articleID) !== null) {
$articleContent->setArticle($articleList->search($articleContent->articleID));
} else {
throw new \LogicException('Unable to find article with id "' . $articleContent->articleID . '".');
}
if ($articleList->search($articleContent->articleID) !== null) {
$articleContent->setArticle($articleList->search($articleContent->articleID));
} else {
throw new \LogicException('Unable to find article with id "' . $articleContent->articleID . '".');
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public function copy()
'uploadTime' => $attachment->uploadTime,
'showOrder' => $attachment->showOrder,
'fileID' => $file?->fileID,
'thumbnailID' => $thumbnailID,
'tinyThumbnailID' => $tinyThumbnailID,
'thumbnailID' => $thumbnailID ?? null,
'tinyThumbnailID' => $tinyThumbnailID ?? null,
]);

$newAttachmentIDs[$attachment->attachmentID] = $newAttachment->attachmentID;
Expand Down
2 changes: 1 addition & 1 deletion wcfsetup/install/files/lib/data/box/BoxAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function delete()
MessageEmbeddedObjectManager::getInstance()->removeObjects('com.woltlab.wcf.box.content', $boxContentIDs);
}

parent::delete();
return parent::delete();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion wcfsetup/install/files/lib/data/label/LabelAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ public function update()
*/
public function delete()
{
parent::delete();
$count = parent::delete();

$this->deleteI18nValues();

return $count;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @property-read int $cumulativeLikes number of likes of the liked object
* @property-read string $cachedUsers serialized array with the ids and names of the three users who liked (+1) the object last
* @property-read string $cachedReactions serialized array with the reactionTypeIDs and the count of the reactions
* @property-read int $reactionTypeID
*/
class LikeObject extends DatabaseObject
{
Expand Down Expand Up @@ -176,7 +177,8 @@ public function getReactionsJson(): string
$data = [];
foreach ($this->reactions as $reactionTypeID => $value) {
$data[] = [
$reactionTypeID, $value['reactionCount'],
$reactionTypeID,
$value['reactionCount'],
];
}

Expand Down
4 changes: 3 additions & 1 deletion wcfsetup/install/files/lib/data/media/MediaAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,11 @@ public function delete()
$mediaEditor->deleteFiles();
}

parent::delete();
$count = parent::delete();

$this->unmarkItems();

return $count;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @property-read int $lastChangeTime timestamp at which the moderation queue entry has been changed the last time
* @property-read array $additionalData array with additional data of the moderation queue entry
* @property-read bool $markAsJustified true if the report was closed, but it was actually justified and other actions may have been taken
* @property-read string $message
*/
class ModerationQueue extends DatabaseObject
{
Expand Down Expand Up @@ -140,6 +141,8 @@ public function getStatus($status = null)
return WCF::getLanguage()->get('wcf.moderation.status.' . $phrase . '.' . $definition->definitionName);
break;
}

return '';
}

/**
Expand Down
Loading

0 comments on commit 0632172

Please sign in to comment.