diff --git a/constants.php b/constants.php index 46e52bc5db8..a98315d2050 100644 --- a/constants.php +++ b/constants.php @@ -118,7 +118,7 @@ \define('REGISTER_USERNAME_MAX_LENGTH', 25); \define('REGISTER_USERNAME_FORCE_ASCII', 2); \define('REGISTER_MIN_USER_AGE', 0); -\define('REGISTER_ANTISPAM_ACTION', 0); +\define('REGISTER_ANTISPAM_ACTION', 'disable'); \define('GITHUB_PUBLIC_KEY', ''); \define('GITHUB_PRIVATE_KEY', ''); \define('TWITTER_PUBLIC_KEY', ''); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7655a096bcc..8b981ef4a58 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -12,6 +12,12 @@ parameters: count: 1 path: wcfsetup/install/files/lib/acp/form/AbstractCategoryEditForm.class.php + - + message: '#^Strict comparison using \=\=\= between array and false will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/acp/form/LanguageAddForm.class.php + - message: '#^Property wcf\\acp\\form\\LanguageImportForm\:\:\$language \(wcf\\data\\language\\Language\) does not accept wcf\\data\\language\\LanguageEditor\.$#' identifier: assign.propertyType @@ -30,12 +36,30 @@ parameters: count: 1 path: wcfsetup/install/files/lib/acp/page/DevtoolsNotificationTestPage.class.php + - + message: '#^Right side of && is always false\.$#' + identifier: booleanAnd.rightAlwaysFalse + count: 1 + path: wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php + - message: '#^Method wcf\\data\\article\\ArticleAction\:\:delete\(\) should return int but returns array\\|string\>\.$#' identifier: return.type count: 1 path: wcfsetup/install/files/lib/data/article/ArticleAction.class.php + - + message: '#^Instanceof between wcf\\data\\category\\Category and wcf\\data\\category\\AbstractDecoratedCategory will always evaluate to false\.$#' + identifier: instanceof.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/data/category/CategoryNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/data/category/CategoryNode.class.php + - message: '#^Constructor of class wcf\\data\\clipboard\\item\\ClipboardItemAction has an unused parameter \$objects\.$#' identifier: constructor.unusedParameter @@ -60,6 +84,30 @@ parameters: count: 1 path: wcfsetup/install/files/lib/data/style/StyleAction.class.php + - + message: '#^While loop condition is always true\.$#' + identifier: while.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/data/user/notification/event/UserNotificationEventAction.class.php + + - + message: '#^Negated boolean expression is always true\.$#' + identifier: booleanNot.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/page/AbstractPage.class.php + + - + message: '#^Strict comparison using \=\=\= between int and ''og\:description'' will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/page/AbstractPage.class.php + + - + message: '#^Instanceof between wcf\\data\\search\\ISearchResultObject and wcf\\data\\search\\ISearchResultObject will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/page/SearchResultPage.class.php + - message: '#^Access to an undefined property Zend\\Console\\Getopt\:\:\$exitOnFail\.$#' identifier: property.notFound @@ -192,6 +240,12 @@ parameters: count: 1 path: wcfsetup/install/files/lib/system/CLIWCF.class.php + - + message: '#^Call to function is_callable\(\) with callable\(\)\: mixed will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/Callback.class.php + - message: '#^Constant INSTALL_SCRIPT not found\.$#' identifier: constant.notFound @@ -216,6 +270,12 @@ parameters: count: 5 path: wcfsetup/install/files/lib/system/WCFSetup.class.php + - + message: '#^Instanceof between wcf\\system\\background\\job\\AbstractBackgroundJob and wcf\\system\\background\\job\\AbstractBackgroundJob will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php + - message: '#^Call to static method info\(\) on an unknown class phpline\\internal\\Log\.$#' identifier: class.notFound @@ -282,6 +342,18 @@ parameters: count: 2 path: wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php + - + message: '#^If condition is always true\.$#' + identifier: if.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php + + - + message: '#^While loop condition is always true\.$#' + identifier: while.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php + - message: '#^Method wcf\\system\\condition\\AbstractCheckboxCondition\:\:getData\(\) should return array\ but returns null\.$#' identifier: return.type @@ -306,6 +378,12 @@ parameters: count: 1 path: wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php + - + message: '#^Strict comparison using \=\=\= between array\ and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php + - message: '#^Method wcf\\system\\condition\\AbstractSelectCondition\:\:getData\(\) should return array\ but returns null\.$#' identifier: return.type @@ -402,12 +480,54 @@ parameters: count: 1 path: wcfsetup/install/files/lib/system/condition/user/UserLastActivityTimeIntervalDaysCondition.class.php + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php + + - + message: '#^Instanceof between wcf\\system\\database\\table\\column\\IDatabaseTableColumn and wcf\\system\\database\\table\\column\\IDatabaseTableColumn will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/database/table/DatabaseTable.class.php + + - + message: '#^Instanceof between wcf\\system\\database\\table\\index\\DatabaseTableForeignKey and wcf\\system\\database\\table\\index\\DatabaseTableForeignKey will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/database/table/DatabaseTable.class.php + + - + message: '#^Instanceof between wcf\\system\\database\\table\\index\\DatabaseTableIndex and wcf\\system\\database\\table\\index\\DatabaseTableIndex will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/database/table/DatabaseTable.class.php + + - + message: '#^Instanceof between wcf\\system\\database\\table\\DatabaseTable and wcf\\system\\database\\table\\DatabaseTable will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php + - message: '#^Argument of an invalid type wcf\\data\\comment\\Comment supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable count: 1 path: wcfsetup/install/files/lib/system/endpoint/controller/core/comments/RenderComment.class.php + - + message: '#^If condition is always true\.$#' + identifier: if.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/endpoint/controller/core/comments/responses/RenderResponses.class.php + - message: '#^Constructor of class wcf\\system\\exception\\ErrorException has an unused parameter \$filename\.$#' identifier: constructor.unusedParameter @@ -420,24 +540,804 @@ parameters: count: 1 path: wcfsetup/install/files/lib/system/exception/ErrorException.class.php + - + message: '#^Instanceof between wcf\\system\\file\\upload\\UploadFile and wcf\\system\\file\\upload\\UploadFile will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/CustomFormNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/CustomFormNode.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/CustomFormNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/CustomFormNode.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/CustomFormNode.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 3 + path: wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/LanguageItemFormNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/LanguageItemFormNode.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/LanguageItemFormNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/LanguageItemFormNode.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/LanguageItemFormNode.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/TemplateFormNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/TemplateFormNode.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/TemplateFormNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/TemplateFormNode.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/TemplateFormNode.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/button/FormButton.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 3 + path: wcfsetup/install/files/lib/system/form/builder/button/FormButton.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/button/FormButton.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/button/FormButton.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/button/FormButton.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 3 + path: wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/container/FormContainer.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: '#^Call to function is_int\(\) with int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php + + - + message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 3 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php + + - + message: '#^Call to function is_numeric\(\) with float\|int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/BooleanFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/ButtonFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/DateRangeFormField.class.php + + - + message: '#^Call to function is_numeric\(\) with array\ will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php + + - + message: '#^Call to function is_callable\(\) with callable\(\)\: mixed will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php + + - + message: '#^Instanceof between wcf\\data\\DatabaseObjectList and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/NumericRangeFormField.class.php + + - + message: '#^Call to function is_int\(\) with int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/PasswordFormField.class.php + + - + message: '#^Call to function is_callable\(\) with callable\(\)\: mixed will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/RadioButtonFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/RadioButtonFormField.class.php + + - + message: '#^Instanceof between wcf\\data\\DatabaseObjectList and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/RadioButtonFormField.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/RadioButtonFormField.class.php + + - + message: '#^Call to function is_numeric\(\) with float\|int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/RatingFormField.class.php + + - + message: '#^Call to function is_callable\(\) with callable\(\)\: mixed will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/SelectFormField.class.php + + - + message: '#^Instanceof between wcf\\data\\DatabaseObjectList and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/SelectFormField.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/SelectFormField.class.php + + - + message: '#^Call to function is_callable\(\) with callable\(\)\: mixed will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php + + - + message: '#^Instanceof between wcf\\data\\DatabaseObjectList and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php + + - + message: '#^Call to function is_int\(\) with int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/SourceCodeFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with ''wcf\\\\system\\\\form\\\\builder\\\\field\\\\SourceCodeFormField'' and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/SourceCodeFormField.class.php + + - + message: '#^Call to function is_int\(\) with int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php + + - + message: '#^Call to function is_numeric\(\) with array\ will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with class\-string\ and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php + + - + message: '#^Call to function is_array\(\) with array\ will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php + + - + message: '#^Call to function is_numeric\(\) with float\|int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 7 + path: wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php + + - + message: '#^Instanceof between wcf\\system\\file\\upload\\UploadFile and wcf\\system\\file\\upload\\UploadFile will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php + + - + message: '#^Method wcf\\system\\form\\builder\\field\\UploadFormField\:\:readUploadFiles\(\) has InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#' + identifier: throws.unusedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php + + - + message: '#^Instanceof between wcf\\data\\DatabaseObjectList and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/dependency/ValueFormFieldDependency.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/dependency/ValueFormFieldDependency.class.php + + - + message: '#^Call to function is_subclass_of\(\) with ''wcf\\\\system\\\\form\\\\builder\\\\field\\\\tag\\\\TagFormField'' and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/user/UserPasswordField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with ''wcf\\\\system\\\\form\\\\builder\\\\field\\\\user\\\\UserPasswordField'' and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/user/UserPasswordField.class.php + + - + message: '#^Call to function is_int\(\) with int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with ''wcf\\\\system\\\\form\\\\builder\\\\field\\\\user\\\\UsernameFormField'' and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/user/UsernameFormField.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidationError.class.php + + - + message: '#^Call to function is_int\(\) with int will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php + + - + message: '#^Call to function is_subclass_of\(\) with ''wcf\\\\system\\\\form\\\\builder\\\\field\\\\wysiwyg\\\\WysiwygFormField'' and string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 2 + path: wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: wcfsetup/install/files/lib/system/form/element/AbstractNamedFormElement.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/form/element/MultipleSelectionFormElement.class.php + - message: '#^Property wcf\\system\\form\\element\\AbstractNamedFormElement\:\:\$value \(string\) does not accept array\\.$#' identifier: assign.propertyType count: 1 path: wcfsetup/install/files/lib/system/form/element/MultipleSelectionFormElement.class.php + - + message: '#^Strict comparison using \=\=\= between "PK\\001\\002" and "PK\\001\\002" will always evaluate to true\.$#' + identifier: identical.alwaysTrue + count: 1 + path: wcfsetup/install/files/lib/system/io/Zip.class.php + + - + message: '#^Strict comparison using \=\=\= between "PK\\003\\004" and "PK\\a\\b" will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/io/Zip.class.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: wcfsetup/install/files/lib/system/io/Zip.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/option/AbstractCategoryMultiSelectOptionType.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/option/MultiSelectOptionType.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 1 + path: wcfsetup/install/files/lib/system/option/MultiSelectOptionType.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/option/PaymentMethodSelectOptionType.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 1 + path: wcfsetup/install/files/lib/system/option/PaymentMethodSelectOptionType.class.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: wcfsetup/install/files/lib/system/option/PaymentMethodSelectOptionType.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/option/UseroptionsOptionType.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 1 + path: wcfsetup/install/files/lib/system/option/UseroptionsOptionType.class.php + + - + message: '#^Unreachable statement \- code above always terminates\.$#' + identifier: deadCode.unreachable + count: 1 + path: wcfsetup/install/files/lib/system/option/UseroptionsOptionType.class.php + + - + message: '#^Loose comparison using \=\= between non\-falsy\-string and ''0'' will always evaluate to false\.$#' + identifier: equal.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/option/user/FloatUserOptionOutput.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/option/user/MessageUserOptionOutput.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/option/user/NewlineToBreakUserOptionOutput.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/option/user/group/BBCodeSelectUserGroupOptionType.class.php + + - + message: '#^Empty array passed to foreach\.$#' + identifier: foreach.emptyArray + count: 1 + path: wcfsetup/install/files/lib/system/option/user/group/BBCodeSelectUserGroupOptionType.class.php + + - + message: '#^Call to function is_array\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: wcfsetup/install/files/lib/system/option/user/group/UserGroupsUserGroupOptionType.class.php + + - + message: '#^Dead catch \- wcf\\system\\package\\exception\\IncoherentUpdatePath is never thrown in the try block\.$#' + identifier: catch.neverThrown + count: 2 + path: wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php + + - + message: '#^Dead catch \- wcf\\system\\package\\exception\\UnknownUpdatePath is never thrown in the try block\.$#' + identifier: catch.neverThrown + count: 1 + path: wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php + + - + message: '#^Call to function assert\(\) with true will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + 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 + 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 + path: wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.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 function assert\(\) with true will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + 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 + path: wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php + + - + message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php + + - + message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 3 + path: wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php + + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php + + - + message: '#^Strict comparison using \=\=\= between string and null will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: wcfsetup/install/files/lib/system/user/multifactor/totp/DeviceNode.class.php + - message: '#^Call to static method stripAnsi\(\) on an unknown class phpline\\internal\\AnsiUtil\.$#' identifier: class.notFound diff --git a/phpstan.neon b/phpstan.neon index 1ba5cd018c1..e3433d6bb0a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 3 + level: 4 paths: - wcfsetup/install/files excludePaths: @@ -11,7 +11,9 @@ parameters: scanFiles: - constants.php ignoreErrors: + - identifier: match.unhandled - identifier: new.static + - identifier: trait.unused universalObjectCratesClasses: - wcf\data\category\Category - wcf\data\condition\Condition @@ -24,3 +26,222 @@ parameters: - wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler - wcf\system\user\notification\event\IUserNotificationEvent - wcf\system\user\notification\object\type\IUserNotificationObjectType + dynamicConstantNames: + - PACKAGE_ID + - PACKAGE_NAME + - RELATIVE_WCF_DIR + - TMP_DIR + - WCF_N + - TIME_NOW + - WCF_OPTION_INC_PHP_SUCCESS + - LAST_UPDATE_TIME + - WCF_UUID + - WOLTLAB_BRANDING + - VISITOR_USE_TINY_BUILD + - ENABLE_DEBUG_MODE + - ENABLE_BENCHMARK + - LOG_IP_ADDRESS + - MODULE_SYSTEM_RECAPTCHA + - MODULE_SMILEY + - MODULE_USERS_ONLINE + - MODULE_USER_RANK + - MODULE_USER_SIGNATURE + - MODULE_MEMBERS_LIST + - MODULE_TEAM_PAGE + - MODULE_LIKE + - MODULE_USER_PROFILE_WALL + - MODULE_TAGGING + - MODULE_POLL + - MODULE_WCF_AD + - PAGE_TITLE + - PAGE_DESCRIPTION + - META_DESCRIPTION + - SHOW_VERSION_NUMBER + - EXTERNAL_LINK_TARGET_BLANK + - FOOTER_CODE + - URL_OMIT_INDEX_PHP + - URL_TITLE_COMPONENT_REPLACEMENT + - OFFLINE + - OFFLINE_MESSAGE + - OFFLINE_MESSAGE_ALLOW_HTML + - IMAGE_ADAPTER_TYPE + - SEARCH_ENGINE + - EXCEPTION_PRIVACY + - COOKIE_PREFIX + - PACKAGE_SERVER_AUTH_CODE + - PROXY_SERVER_HTTP + - IP_ADDRESS_SEARCH_ENGINE + - USER_ONLINE_TIMEOUT + - ENABLE_USER_AUTHENTICATION_FAILURE + - USER_AUTHENTICATION_FAILURE_TIMEOUT + - USER_AUTHENTICATION_FAILURE_IP_CAPTCHA + - USER_AUTHENTICATION_FAILURE_IP_BLOCK + - USER_AUTHENTICATION_FAILURE_USER_CAPTCHA + - USER_AUTHENTICATION_FAILURE_EXPIRATION + - SIGNATURE_SECRET + - CAPTCHA_TYPE + - REGISTER_USE_CAPTCHA + - LOST_PASSWORD_USE_CAPTCHA + - RECAPTCHA_PUBLICKEY + - RECAPTCHA_PRIVATEKEY + - RECAPTCHA_PRIVATEKEY_INVISIBLE + - TIMEZONE + - GOOGLE_MAPS_API_KEY + - GOOGLE_MAPS_ZOOM + - GOOGLE_MAPS_DEFAULT_LATITUDE + - GOOGLE_MAPS_DEFAULT_LONGITUDE + - MAIL_FROM_NAME + - MAIL_FROM_ADDRESS + - MAIL_ADMIN_ADDRESS + - MAIL_SIGNATURE + - MAIL_SIGNATURE_HTML + - MAIL_SEND_METHOD + - MAIL_SMTP_HOST + - MAIL_SMTP_PORT + - MAIL_SMTP_STARTTLS + - MAIL_SMTP_USER + - MAIL_SMTP_PASSWORD + - MAIL_USE_F_PARAM + - CACHE_SOURCE_TYPE + - CACHE_SOURCE_REDIS_HOST + - AVAILABLE_PAYMENT_METHODS + - PAYPAL_EMAIL_ADDRESS + - MODULE_PAID_SUBSCRIPTION + - PAID_SUBSCRIPTION_ENABLE_TOS_CONFIRMATION + - PAID_SUBSCRIPTION_TOS_URL + - ATTACHMENT_RETAIN_DIMENSIONS + - ATTACHMENT_THUMBNAIL_HEIGHT + - ATTACHMENT_THUMBNAIL_WIDTH + - MODULE_EDIT_HISTORY + - EDIT_HISTORY_EXPIRATION + - ENABLE_SHARE_BUTTONS + - SHARE_BUTTONS_PROVIDERS + - MESSAGE_FORCE_SECURE_IMAGES + - MODULE_IMAGE_PROXY + - IMAGE_PROXY_INSECURE_ONLY + - IMAGE_PROXY_EXPIRATION + - IMAGE_PROXY_HOST_WHITELIST + - CENSORED_WORDS + - PASSWORD_MIN_SCORE + - REGISTER_FORBIDDEN_USERNAMES + - REGISTER_FORBIDDEN_EMAILS + - REGISTER_ALLOWED_EMAILS + - REGISTER_DISABLED + - REGISTER_ENABLE_DISCLAIMER + - REGISTER_ACTIVATION_METHOD + - REGISTER_USERNAME_MIN_LENGTH + - REGISTER_USERNAME_MAX_LENGTH + - REGISTER_USERNAME_FORCE_ASCII + - REGISTER_MIN_USER_AGE + - REGISTER_ANTISPAM_ACTION + - GITHUB_PUBLIC_KEY + - GITHUB_PRIVATE_KEY + - TWITTER_PUBLIC_KEY + - TWITTER_PRIVATE_KEY + - FACEBOOK_PUBLIC_KEY + - FACEBOOK_PRIVATE_KEY + - GOOGLE_PUBLIC_KEY + - GOOGLE_PRIVATE_KEY + - SIGNATURE_MAX_IMAGE_HEIGHT + - USER_TITLE_MAX_LENGTH + - USER_FORBIDDEN_TITLES + - PROFILE_SHOW_OLD_USERNAME + - PROFILE_ENABLE_VISITORS + - MEMBERS_LIST_USERS_PER_PAGE + - MEMBERS_LIST_DEFAULT_SORT_FIELD + - MEMBERS_LIST_DEFAULT_SORT_ORDER + - USERS_ONLINE_SHOW_GUESTS + - USERS_ONLINE_SHOW_ROBOTS + - USERS_ONLINE_DEFAULT_SORT_FIELD + - USERS_ONLINE_DEFAULT_SORT_ORDER + - USERS_ONLINE_PAGE_REFRESH + - USERS_ONLINE_ENABLE_LEGEND + - USERS_ONLINE_RECORD + - USERS_ONLINE_RECORD_TIME + - USER_CLEANUP_NOTIFICATION_LIFETIME + - USER_CLEANUP_ACTIVITY_EVENT_LIFETIME + - USER_CLEANUP_PROFILE_VISITOR_LIFETIME + - LIKE_SHOW_SUMMARY + - MESSAGE_SIDEBAR_ENABLE_ONLINE_STATUS + - MESSAGE_SIDEBAR_ENABLE_LIKES_RECEIVED + - MESSAGE_SIDEBAR_ENABLE_ACTIVITY_POINTS + - MESSAGE_SIDEBAR_USER_OPTIONS + - TAGGING_MAX_TAG_LENGTH + - MESSAGE_MAX_QUOTE_DEPTH + - SEARCH_RESULTS_PER_PAGE + - SEARCH_DEFAULT_SORT_FIELD + - SEARCH_DEFAULT_SORT_ORDER + - POLL_MAX_OPTIONS + - POLL_FULL_WIDTH + - MEDIA_SMALL_THUMBNAIL_WIDTH + - MEDIA_SMALL_THUMBNAIL_HEIGHT + - MEDIA_SMALL_THUMBNAIL_RETAIN_DIMENSIONS + - MEDIA_MEDIUM_THUMBNAIL_WIDTH + - MEDIA_MEDIUM_THUMBNAIL_HEIGHT + - MEDIA_MEDIUM_THUMBNAIL_RETAIN_DIMENSIONS + - MEDIA_LARGE_THUMBNAIL_WIDTH + - MEDIA_LARGE_THUMBNAIL_HEIGHT + - MEDIA_LARGE_THUMBNAIL_RETAIN_DIMENSIONS + - MODULE_ARTICLE + - ARTICLE_SHOW_ABOUT_AUTHOR + - ARTICLE_ENABLE_COMMENTS_DEFAULT_VALUE + - ARTICLE_ENABLE_LIKE + - ARTICLES_PER_PAGE + - ARTICLE_RELATED_ARTICLES + - ARTICLE_RELATED_ARTICLES_MATCH_THRESHOLD + - SHOW_UPDATE_NOTICE_FRONTEND + - LANGUAGE_USE_INFORMAL_VARIANT + - SHOW_STYLE_CHANGER + - ARTICLE_SORT_ORDER + - USE_PAGE_TITLE_ON_LANDING_PAGE + - OG_IMAGE + - HEAD_CODE + - AVATAR_DEFAULT_TYPE + - ARTICLE_ENABLE_VISIT_TRACKING + - ENABLE_AD_ROTATION + - ENABLE_POLLING + - FB_SHARE_APP_ID + - MODULE_CONTACT_FORM + - SITEMAP_INDEX_TIME_FRAME + - MODULE_TROPHY + - ENABLE_DEVELOPER_TOOLS + - FORCE_LOGIN + - PAGE_LOGO_LINK_TO_APP_DEFAULT + - IMAGE_ALLOW_EXTERNAL_SOURCE + - MESSAGE_ENABLE_TOC + - MESSAGE_PUBLIC_HIGHLIGHTERS + - MESSAGE_SIDEBAR_ENABLE_ARTICLES + - IMAGE_PROXY_ENABLE_PRUNE + - SEARCH_ENABLE_PAGES + - SEARCH_ENABLE_ARTICLES + - ATTACHMENT_IMAGE_AUTOSCALE + - ATTACHMENT_IMAGE_AUTOSCALE_MAX_WIDTH + - ATTACHMENT_IMAGE_AUTOSCALE_MAX_HEIGHT + - ATTACHMENT_IMAGE_AUTOSCALE_FILE_TYPE + - ATTACHMENT_IMAGE_AUTOSCALE_QUALITY + - LOG_MISSING_LANGUAGE_ITEMS + - PRUNE_IP_ADDRESS + - BREADCRUMBS_HOME_USE_PAGE_TITLE + - CONTACT_FORM_ENABLE_ATTACHMENTS + - CONTACT_FORM_PRUNE_ATTACHMENTS + - IMAGE_EXTERNAL_SOURCE_WHITELIST + - SEARCH_MAX_COMBINED_TAGS + - ENABLE_PRODUCTION_DEBUG_MODE + - BLACKLIST_SFS_ENABLE + - BLACKLIST_SFS_USERNAME + - BLACKLIST_SFS_EMAIL_ADDRESS + - BLACKLIST_SFS_IP_ADDRESS + - ENABLE_ENTERPRISE_MODE + - MESSAGE_ENABLE_USER_CONSENT + - MODIFICATION_LOG_EXPIRATION + - INTERNAL_HOSTNAMES + - MODULE_URL_UNFURLING + - FIRST_TIME_SETUP_STATE + - FORMATTING_REMOVE_COLOR + - FORMATTING_REMOVE_FONT + - FORMATTING_REMOVE_SIZE + - URL_UNFURLING_SAVE_IMAGES + - SERVICE_WORKER_PRIVATE_KEY + - SERVICE_WORKER_PUBLIC_KEY + - RECAPTCHA_PRIVATEKEY_V3 + diff --git a/wcfsetup/install/files/lib/acp/action/DevtoolsInstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/DevtoolsInstallPackageAction.class.php index 8cd421df30f..23e3baaf1c4 100644 --- a/wcfsetup/install/files/lib/acp/action/DevtoolsInstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/DevtoolsInstallPackageAction.class.php @@ -53,7 +53,6 @@ public function readParameters() default: throw new IllegalLinkException(); - break; } } diff --git a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php index 5c2c20e712c..cbd67a89eab 100755 --- a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php @@ -51,7 +51,6 @@ public function readParameters() default: throw new IllegalLinkException(); - break; } if (isset($_POST['node'])) { diff --git a/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php index 8a805d55660..168b1582632 100644 --- a/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php @@ -54,7 +54,6 @@ public function readParameters() default: throw new IllegalLinkException(); - break; } if (isset($_POST['node'])) { diff --git a/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php b/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php index 2dcf9aee085..51adbbece62 100644 --- a/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php @@ -138,7 +138,7 @@ public function execute() $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add('banned = ?', [0]); $conditionBuilder->add('activationCode <> ?', [0]); - if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) { + if ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) { $conditionBuilder->add('emailConfirmed IS NULL'); } diff --git a/wcfsetup/install/files/lib/acp/form/AdAddForm.class.php b/wcfsetup/install/files/lib/acp/form/AdAddForm.class.php index d0a71f9713c..b611467fd0e 100644 --- a/wcfsetup/install/files/lib/acp/form/AdAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AdAddForm.class.php @@ -52,7 +52,7 @@ class AdAddForm extends AbstractForm /** * grouped ad condition object types - * @var ObjectType[][] + * @var (ObjectType|ObjectType[])[][] */ public $groupedConditionObjectTypes = []; diff --git a/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php index b4449e2387f..6024d06910a 100644 --- a/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php @@ -89,7 +89,7 @@ class ArticleAddForm extends AbstractForm /** * article date object - * @var \DateTime + * @var ?\DateTime */ public $timeObj; @@ -107,7 +107,7 @@ class ArticleAddForm extends AbstractForm /** * publication date object - * @var \DateTime + * @var ?\DateTime */ public $publicationDateObj; diff --git a/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php b/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php index aa9caf0eb1f..cf5dc35ab78 100644 --- a/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php @@ -212,7 +212,7 @@ class BoxAddForm extends AbstractForm public $presetBoxID = 0; /** - * @var Box + * @var ?Box * @since 5.2 */ public $presetBox; @@ -264,7 +264,7 @@ public function readParameters() $collator = new \Collator(WCF::getLanguage()->getLocale()); \uasort( $this->availableBoxControllers, - static fn (ObjectType $a, ObjectType $b) => $collator->compare( + static fn(ObjectType $a, ObjectType $b) => $collator->compare( WCF::getLanguage()->get('wcf.acp.box.boxController.' . $a->objectType), WCF::getLanguage()->get('wcf.acp.box.boxController.' . $b->objectType) ) @@ -445,7 +445,7 @@ public function validate() throw new UserInputException('boxController'); } - if ($this->boxController && $this->boxController->getProcessor() instanceof IConditionBoxController) { + if ($this->boxController->getProcessor() instanceof IConditionBoxController) { $this->boxController->getProcessor()->readConditions(); } } else { @@ -469,13 +469,13 @@ public function validate() // validate page object id if (isset($this->pageHandlers[$page->pageID])) { - if ($this->pageHandlers[$page->pageID] && !$this->linkPageObjectID) { + if (!$this->linkPageObjectID) { throw new UserInputException('linkPageObjectID'); } /** @var ILookupPageHandler $handler */ $handler = $page->getHandler(); - if ($this->linkPageObjectID && !$handler->isValid($this->linkPageObjectID)) { + if (!$handler->isValid($this->linkPageObjectID)) { throw new UserInputException('linkPageObjectID', 'invalid'); } } @@ -497,7 +497,7 @@ public function validate() // validate images if (WCF::getSession()->getPermission('admin.content.cms.canUseMedia')) { foreach ($this->imageID as $languageID => $imageID) { - if (!isset($this->imageID[$languageID])) { + if (!isset($this->images[$languageID])) { throw new UserInputException('imageID' . $languageID); } } diff --git a/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php b/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php index 0897810dbfd..f22011d6dbd 100644 --- a/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php @@ -138,12 +138,18 @@ public function save() // delete old conditions if ($this->box->objectTypeID) { $className = ObjectTypeCache::getInstance()->getObjectType($this->box->objectTypeID)->className; - - /** @var IConditionBoxController $oldController */ $oldController = new $className(); - /** @noinspection PhpUndefinedMethodInspection */ - if ($oldController instanceof IConditionBoxController && $oldController->getConditionDefinition() && (!$this->boxController || (!($this->boxController->getProcessor() instanceof IConditionBoxController)) || !$this->boxController->getProcessor()->getConditionDefinition())) { + if ( + $oldController instanceof IConditionBoxController + && $oldController->getConditionDefinition() + && ( + !$this->boxController + || ( + !($this->boxController->getProcessor() instanceof IConditionBoxController)) + || !$this->boxController->getProcessor()->getConditionDefinition() + ) + ) { ConditionHandler::getInstance()->deleteConditions( $oldController->getConditionDefinition(), [$this->box->boxID] @@ -180,7 +186,7 @@ public function save() if ($this->isMultilingual) { foreach (LanguageFactory::getInstance()->getLanguages() as $language) { $this->content[$language->languageID] = isset($this->htmlInputProcessors[$language->languageID]) ? - $this->htmlInputProcessors[$language->languageID]->getHtml() : ''; + $this->htmlInputProcessors[$language->languageID]->getHtml() : ''; } } else { $this->content[0] = isset($this->htmlInputProcessors[0]) ? diff --git a/wcfsetup/install/files/lib/acp/form/CategoryAddFormBuilderForm.class.php b/wcfsetup/install/files/lib/acp/form/CategoryAddFormBuilderForm.class.php index ee4eb693c04..fbb602b41e8 100644 --- a/wcfsetup/install/files/lib/acp/form/CategoryAddFormBuilderForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/CategoryAddFormBuilderForm.class.php @@ -237,7 +237,7 @@ protected function getPositionFormFields(): array ); $maximumNestingLevel = $processor->getMaximumNestingLevel(); - if (\is_numeric($maximumNestingLevel) && $maximumNestingLevel !== -1) { + if ($maximumNestingLevel !== -1) { $categoryNodeTree->setMaxDepth($maximumNestingLevel - 1); } @@ -511,7 +511,6 @@ public function checkPermissions() protected function checkCategoryPermissions(): void { $processor = $this->getObjectTypeProcessor(); - \assert($processor instanceof ICategoryType); if ($this->formObject instanceof DatabaseObject) { // @phpstan-ignore property.notFound diff --git a/wcfsetup/install/files/lib/acp/form/DevtoolsProjectAddForm.class.php b/wcfsetup/install/files/lib/acp/form/DevtoolsProjectAddForm.class.php index dc8e6a4c87a..d78540136df 100644 --- a/wcfsetup/install/files/lib/acp/form/DevtoolsProjectAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/DevtoolsProjectAddForm.class.php @@ -210,7 +210,6 @@ protected function createForm() default: throw new \LogicException("Unknown mode '{$modeField->getSaveValue()}'."); - break; } })) ->addValidator(new FormFieldValidator('uniqueness', function (TextFormField $formField) { diff --git a/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php index 78282d5105d..e823faf0cef 100644 --- a/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php @@ -256,7 +256,7 @@ public function assignVariables() /** * Saves label group to object relations. * - * @param int $groupID + * @param ?int $groupID */ protected function saveObjectTypeRelations($groupID) { diff --git a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php index 8e2e23f8808..8bdf5813cee 100755 --- a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php @@ -118,6 +118,7 @@ public function readParameters() if ($user->userID) { $failures = UserAuthenticationFailure::countUserFailures($user->userID); if ( + // @phpstan-ignore booleanAnd.leftAlwaysTrue USER_AUTHENTICATION_FAILURE_USER_CAPTCHA && $failures >= USER_AUTHENTICATION_FAILURE_USER_CAPTCHA ) { diff --git a/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php index 9f1eb123a27..42df5d84b43 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php @@ -31,7 +31,7 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @property Menu $formObject + * @property ?Menu $formObject */ class MenuAddForm extends AbstractFormBuilderForm { diff --git a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php index 6c821b56546..e4217b9f7e0 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php @@ -38,7 +38,7 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @property MenuItem $formObject + * @property ?MenuItem $formObject */ class MenuItemAddForm extends AbstractFormBuilderForm { diff --git a/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php b/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php index 3af09f4395a..241a6de6804 100644 --- a/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php @@ -44,7 +44,7 @@ class NoticeAddForm extends AbstractForm /** * grouped notice condition object types - * @var ObjectType[][] + * @var (ObjectType|ObjectType[])[][] */ public $groupedConditionObjectTypes = []; diff --git a/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php index 28ade0d877f..8935a02f878 100644 --- a/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php @@ -39,10 +39,7 @@ final class PackageEnableUpgradeOverrideForm extends AbstractFormBuilderForm */ public $neededPermissions = ['admin.configuration.package.canUpdatePackage']; - /** - * @var bool - */ - private $isEnabled; + private bool $isEnabled; /** * @inheritDoc @@ -51,6 +48,7 @@ public function readParameters() { parent::readParameters(); + // @phpstan-ignore identical.alwaysTrue if (WCF::AVAILABLE_UPGRADE_VERSION === null) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index 77b7cb601a5..c15fa3a007d 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -34,7 +34,7 @@ class PackageStartInstallForm extends AbstractForm /** * updated package object - * @var Package + * @var ?Package */ public $package; diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index 070ea570041..ee784dc3428 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -197,7 +197,7 @@ class PageAddForm extends AbstractForm public $presetPageID = 0; /** - * @var Page + * @var ?Page * @since 5.2 */ public $presetPage; diff --git a/wcfsetup/install/files/lib/acp/form/RescueModeForm.class.php b/wcfsetup/install/files/lib/acp/form/RescueModeForm.class.php index 5886b9efcc4..a52fdf8a5e3 100644 --- a/wcfsetup/install/files/lib/acp/form/RescueModeForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/RescueModeForm.class.php @@ -41,7 +41,7 @@ final class RescueModeForm extends AbstractForm public $applications; /** - * @var string[][] + * @var array */ public $applicationValues = []; @@ -108,6 +108,7 @@ public function readParameters() $floodExceeded = false; $floodControl = FloodControl::getInstance(); + // @phpstan-ignore booleanOr.leftAlwaysFalse $floodExceeded = $floodExceeded || $floodControl->countGuestContent( 'com.woltlab.wcf.rescueMode', UserUtil::getIpAddress(), diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index a601d49c376..07c4669bc32 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -591,6 +591,7 @@ protected function validateUploads() } // Check again after scaling + // @phpstan-ignore identical.alwaysFalse if (($imageData = \getimagesize($fileLocation)) === false) { throw new UserInputException($field, 'invalid'); } diff --git a/wcfsetup/install/files/lib/acp/form/TagAddForm.class.php b/wcfsetup/install/files/lib/acp/form/TagAddForm.class.php index 57c80f777a2..edeb9ea8a9c 100644 --- a/wcfsetup/install/files/lib/acp/form/TagAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/TagAddForm.class.php @@ -27,7 +27,7 @@ * @copyright 2001-2024 WoltLab GmbH * @license GNU Lesser General Public License * - * @property Tag $formObject + * @property ?Tag $formObject */ class TagAddForm extends AbstractFormBuilderForm { diff --git a/wcfsetup/install/files/lib/acp/form/TrophyAddForm.class.php b/wcfsetup/install/files/lib/acp/form/TrophyAddForm.class.php index 7019936c9cc..f4e9ac31f51 100644 --- a/wcfsetup/install/files/lib/acp/form/TrophyAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/TrophyAddForm.class.php @@ -137,7 +137,7 @@ class TrophyAddForm extends AbstractAcpForm /** * list of grouped user group assignment condition object types - * @var ObjectType[][] + * @var (ObjectType|ObjectType[])[][] */ public $conditions = []; diff --git a/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php index c3a222a321f..aaf18182208 100644 --- a/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php @@ -42,7 +42,7 @@ * @copyright 2001-2024 WoltLab GmbH * @license GNU Lesser General Public License * - * @property UserOption $formObject + * @property ?UserOption $formObject */ class UserOptionAddForm extends AbstractFormBuilderForm { diff --git a/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php b/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php index c6f4c59869d..6a63871bed7 100755 --- a/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php @@ -129,24 +129,22 @@ protected function readCacheFiles($cacheType, $cacheDir, ?Regex $ignore = null, // get additional file information $data = []; - if (\is_array($files)) { - /** @var \SplFileInfo $file */ - foreach ($files as $file) { - if ($ignore !== null && $ignore->match($file->getPath())) { - continue; - } - - $data[] = [ - 'filename' => $file->getBasename(), - 'filesize' => $file->getSize(), - 'mtime' => $file->getMTime(), - 'perm' => \substr(\sprintf('%o', $file->getPerms()), -3), - 'writable' => $file->isWritable(), - ]; - - $this->cacheData['files']++; - $this->cacheData['size'] += $file->getSize(); + /** @var \SplFileInfo $file */ + foreach ($files as $file) { + if ($ignore !== null && $ignore->match($file->getPath())) { + continue; } + + $data[] = [ + 'filename' => $file->getBasename(), + 'filesize' => $file->getSize(), + 'mtime' => $file->getMTime(), + 'perm' => \substr(\sprintf('%o', $file->getPerms()), -3), + 'writable' => $file->isWritable(), + ]; + + $this->cacheData['files']++; + $this->cacheData['size'] += $file->getSize(); } $this->caches[$cacheType][$cacheDir] = $data; diff --git a/wcfsetup/install/files/lib/acp/page/LabelListPage.class.php b/wcfsetup/install/files/lib/acp/page/LabelListPage.class.php index 57870b06085..45e1d1e6029 100644 --- a/wcfsetup/install/files/lib/acp/page/LabelListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/LabelListPage.class.php @@ -75,7 +75,7 @@ class LabelListPage extends SortablePage /** * label group to which the displayed labels belong - * @var LabelGroup + * @var ?LabelGroup */ public $labelGroup; diff --git a/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php b/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php index 820493a1761..40995ac164d 100644 --- a/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php @@ -2,6 +2,7 @@ namespace wcf\acp\page; +use wcf\data\template\group\TemplateGroup; use wcf\data\template\group\TemplateGroupList; use wcf\data\template\Template; use wcf\data\template\TemplateList; @@ -57,7 +58,7 @@ class TemplateDiffPage extends AbstractPage /** * template group hierarchy - * @var array + * @var array */ public $templateGroupHierarchy = []; @@ -107,7 +108,7 @@ public function readData() ]; $templateGroup = $templateGroupList->search($templateGroup->parentTemplateGroupID); } - $this->templateGroupHierarchy[0] = ['group' => [], 'hasTemplate' => false]; + $this->templateGroupHierarchy[0] = ['group' => null, 'hasTemplate' => false]; // find matching templates in the hierarchy $templateList = new TemplateList(); diff --git a/wcfsetup/install/files/lib/acp/page/VersionTrackerListPage.class.php b/wcfsetup/install/files/lib/acp/page/VersionTrackerListPage.class.php index 9e893431ec2..7cae4b06d60 100644 --- a/wcfsetup/install/files/lib/acp/page/VersionTrackerListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/VersionTrackerListPage.class.php @@ -56,7 +56,7 @@ class VersionTrackerListPage extends AbstractPage /** * left / old version - * @var VersionTrackerEntry + * @var ?VersionTrackerEntry */ public $old; @@ -68,7 +68,7 @@ class VersionTrackerListPage extends AbstractPage /** * right / new version - * @var VersionTrackerEntry + * @var ?VersionTrackerEntry */ public $new; diff --git a/wcfsetup/install/files/lib/action/AJAXFileDeleteAction.class.php b/wcfsetup/install/files/lib/action/AJAXFileDeleteAction.class.php index 59ea216a4b3..a2fabe34967 100644 --- a/wcfsetup/install/files/lib/action/AJAXFileDeleteAction.class.php +++ b/wcfsetup/install/files/lib/action/AJAXFileDeleteAction.class.php @@ -32,12 +32,6 @@ class AJAXFileDeleteAction extends AbstractSecureAction */ public $uniqueFileId; - /** - * The adressed file. - * @var UploadFile - */ - private $file; - /** * @var UploadFile[] */ diff --git a/wcfsetup/install/files/lib/action/GridViewFilterAction.class.php b/wcfsetup/install/files/lib/action/GridViewFilterAction.class.php index b7c032d3a6c..6140fee218f 100644 --- a/wcfsetup/install/files/lib/action/GridViewFilterAction.class.php +++ b/wcfsetup/install/files/lib/action/GridViewFilterAction.class.php @@ -42,8 +42,8 @@ public function handle(ServerRequestInterface $request): ResponseInterface throw new UserInputException('gridView', 'invalid'); } + /** @var AbstractGridView $view */ $view = new $parameters['gridView'](...$parameters['gridViewParameters']); - \assert($view instanceof AbstractGridView); if (!$view->isAccessible()) { throw new PermissionDeniedException(); diff --git a/wcfsetup/install/files/lib/action/ImageProxyAction.class.php b/wcfsetup/install/files/lib/action/ImageProxyAction.class.php index a66c7deccfc..0664460ddc9 100644 --- a/wcfsetup/install/files/lib/action/ImageProxyAction.class.php +++ b/wcfsetup/install/files/lib/action/ImageProxyAction.class.php @@ -160,12 +160,8 @@ public function execute() } catch (TransferException $e) { throw new \DomainException('Failed to request', 0, $e); } finally { - if ($response && $response->getBody()) { - $response->getBody()->close(); - } - if ($file) { - $file->close(); - } + $response?->getBody()->close(); + $file?->close(); } // check file type diff --git a/wcfsetup/install/files/lib/core.functions.php b/wcfsetup/install/files/lib/core.functions.php index fb775d5e299..b41e5d209a5 100644 --- a/wcfsetup/install/files/lib/core.functions.php +++ b/wcfsetup/install/files/lib/core.functions.php @@ -167,6 +167,7 @@ function getTemplateContextLines(\Throwable $e): array * Logs the given Throwable. * * @param string $logFile The log file to use. If set to `null` the default log file will be used and the variable contents will be replaced by the actual path. + * @param-out string $logFile * @return string The ID of the log entry. */ function logThrowable(\Throwable $e, &$logFile = null): string @@ -258,6 +259,7 @@ function printThrowable(\Throwable $e) $exceptionTitle = $exceptionSubtitle = $exceptionExplanation = ''; $logFile = sanitizePath($logFile); try { + // @phpstan-ignore notIdentical.alwaysTrue if (WCF::getLanguage() !== null) { $exceptionTitle = WCF::getLanguage()->get('wcf.global.exception.title', true); $exceptionSubtitle = str_replace('{$exceptionID}', $exceptionID, WCF::getLanguage()->get('wcf.global.exception.subtitle', true)); diff --git a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php index 999a5a15b27..ff45dafdfa4 100644 --- a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php @@ -293,7 +293,7 @@ public function getReturnValues() public function validateCreate() { // validate permissions - if (\is_array($this->permissionsCreate) && !empty($this->permissionsCreate)) { + if ($this->permissionsCreate !== []) { WCF::getSession()->checkPermissions($this->permissionsCreate); } else { throw new PermissionDeniedException(); @@ -306,7 +306,7 @@ public function validateCreate() public function validateDelete() { // validate permissions - if (\is_array($this->permissionsDelete) && !empty($this->permissionsDelete)) { + if ($this->permissionsDelete !== []) { WCF::getSession()->checkPermissions($this->permissionsDelete); } else { throw new PermissionDeniedException(); @@ -328,7 +328,7 @@ public function validateDelete() public function validateUpdate() { // validate permissions - if (\is_array($this->permissionsUpdate) && !empty($this->permissionsUpdate)) { + if ($this->permissionsUpdate !== []) { WCF::getSession()->checkPermissions($this->permissionsUpdate); } else { throw new PermissionDeniedException(); diff --git a/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php b/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php index 39c2c814227..867bf38503d 100644 --- a/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php @@ -26,14 +26,14 @@ class ProcessibleDatabaseObject extends DatabaseObject /** * processor this database object - * @var object + * @var ?object */ protected $processor; /** * Returns the processor this database object. * - * @return object + * @return ?object * @throws SystemException */ public function getProcessor() diff --git a/wcfsetup/install/files/lib/data/article/Article.class.php b/wcfsetup/install/files/lib/data/article/Article.class.php index 5df3fb1dae7..eb64d346bcd 100644 --- a/wcfsetup/install/files/lib/data/article/Article.class.php +++ b/wcfsetup/install/files/lib/data/article/Article.class.php @@ -70,7 +70,7 @@ class Article extends DatabaseObject implements ILinkableObject, IPopoverObject, /** * article's category - * @var ArticleCategory + * @var ?ArticleCategory */ protected $category; @@ -323,7 +323,7 @@ public function getLanguageLinks() /** * Returns the category of the article. * - * @return ArticleCategory + * @return ?ArticleCategory */ public function getCategory() { @@ -377,7 +377,7 @@ public function getDiscussionProvider() */ public static function getAllDiscussionProviders() { - /** @var string[] $discussionProviders */ + /** @var ?string[] $discussionProviders */ static $discussionProviders; if ($discussionProviders === null) { diff --git a/wcfsetup/install/files/lib/data/article/ViewableArticle.class.php b/wcfsetup/install/files/lib/data/article/ViewableArticle.class.php index ee6f8dde955..6ca75f8b05e 100644 --- a/wcfsetup/install/files/lib/data/article/ViewableArticle.class.php +++ b/wcfsetup/install/files/lib/data/article/ViewableArticle.class.php @@ -25,7 +25,7 @@ * @since 3.0 * * @method Article getDecoratedObject() - * @method ArticleContent|ViewableArticleContent getArticleContent() + * @method ArticleContent|ViewableArticleContent|null getArticleContent() * @mixin Article * @property-read int|null $visitTime last time the active user has visited the time or `null` if object has not been fetched via `ViewableArticleList` or if the active user is a guest */ diff --git a/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php b/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php index d8b686d7479..386136c8f94 100644 --- a/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php +++ b/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php @@ -27,7 +27,7 @@ * * @method ArticleCategory[] getChildCategories() * @method ArticleCategory[] getAllChildCategories() - * @method ArticleCategory getParentCategory() + * @method ?ArticleCategory getParentCategory() * @method ArticleCategory[] getParentCategories() * @method static ArticleCategory|null getCategory($categoryID) * @property-read string $sortField diff --git a/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php b/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php index b7dabac60fa..e09c24ccdb7 100644 --- a/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php +++ b/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php @@ -201,7 +201,7 @@ public function getMailText($mimeType = 'text/plain') * Returns a certain article content or `null` if it does not exist. * * @param int $articleID - * @param int $languageID + * @param ?int $languageID * @return ArticleContent|null */ public static function getArticleContent($articleID, $languageID) diff --git a/wcfsetup/install/files/lib/data/blacklist/entry/BlacklistEntryAction.class.php b/wcfsetup/install/files/lib/data/blacklist/entry/BlacklistEntryAction.class.php index 8d4104e8487..71b28c7c53f 100644 --- a/wcfsetup/install/files/lib/data/blacklist/entry/BlacklistEntryAction.class.php +++ b/wcfsetup/install/files/lib/data/blacklist/entry/BlacklistEntryAction.class.php @@ -60,35 +60,33 @@ public function import() } $data = JSON::decode((string)$response->getBody()); - if (\is_array($data)) { - $sql = "INSERT INTO wcf1_blacklist_entry - (type, hash, lastSeen, occurrences) - VALUES (?, ?, ?, ?) - ON DUPLICATE KEY UPDATE lastSeen = VALUES(lastSeen), - occurrences = VALUES(occurrences)"; - $statement = WCF::getDB()->prepare($sql); + $sql = "INSERT INTO wcf1_blacklist_entry + (type, hash, lastSeen, occurrences) + VALUES (?, ?, ?, ?) + ON DUPLICATE KEY UPDATE lastSeen = VALUES(lastSeen), + occurrences = VALUES(occurrences)"; + $statement = WCF::getDB()->prepare($sql); - $lastSeen = \preg_replace('~^(.+)T(.+)Z~', '$1 $2', $data['meta']['end']); + $lastSeen = \preg_replace('~^(.+)T(.+)Z~', '$1 $2', $data['meta']['end']); - WCF::getDB()->beginTransaction(); - foreach (['email', 'ipv4', 'ipv6', 'username'] as $type) { - foreach ($data[$type] as $hash => $occurrences) { - $statement->execute([ - $type, - \hex2bin($hash), - $lastSeen, - \min($occurrences, 32767), - ]); - } - } - WCF::getDB()->commitTransaction(); - - $blacklistStatus = new BlacklistStatus($data['meta']['date']); - if (!$blacklistStatus->date) { - $blacklistStatus = BlacklistStatusEditor::create(['date' => $data['meta']['date']]); + WCF::getDB()->beginTransaction(); + foreach (['email', 'ipv4', 'ipv6', 'username'] as $type) { + foreach ($data[$type] as $hash => $occurrences) { + $statement->execute([ + $type, + \hex2bin($hash), + $lastSeen, + \min($occurrences, 32767), + ]); } + } + WCF::getDB()->commitTransaction(); - (new BlacklistStatusEditor($blacklistStatus))->update([$data['meta']['type'] => 1]); + $blacklistStatus = new BlacklistStatus($data['meta']['date']); + if (!$blacklistStatus->date) { + $blacklistStatus = BlacklistStatusEditor::create(['date' => $data['meta']['date']]); } + + (new BlacklistStatusEditor($blacklistStatus))->update([$data['meta']['type'] => 1]); } } diff --git a/wcfsetup/install/files/lib/data/blacklist/status/BlacklistStatus.class.php b/wcfsetup/install/files/lib/data/blacklist/status/BlacklistStatus.class.php index c8484e3dc3c..a157ae2fb20 100644 --- a/wcfsetup/install/files/lib/data/blacklist/status/BlacklistStatus.class.php +++ b/wcfsetup/install/files/lib/data/blacklist/status/BlacklistStatus.class.php @@ -114,36 +114,34 @@ public static function getNextDelta(array $status, ?ClientInterface $client = nu } $data = JSON::decode((string)$response->getBody()); - if (\is_array($data)) { - $deltas = ['delta1', 'delta2', 'delta3', 'delta4']; - - // The array is ordered from "now" to "14 days ago". - foreach (\array_reverse($data) as $entry) { - $date = $entry['date']; - if (isset($status[$date])) { - $dateStatus = $status[$date]; - if ($dateStatus->isComplete()) { - continue; - } + $deltas = ['delta1', 'delta2', 'delta3', 'delta4']; + + // The array is ordered from "now" to "14 days ago". + foreach (\array_reverse($data) as $entry) { + $date = $entry['date']; + if (isset($status[$date])) { + $dateStatus = $status[$date]; + if ($dateStatus->isComplete()) { + continue; + } - foreach ($deltas as $delta) { - if ($entry['files'][$delta] && !$dateStatus->{$delta}) { - return "{$date}/{$delta}.json"; - } + foreach ($deltas as $delta) { + if ($entry['files'][$delta] && !$dateStatus->{$delta}) { + return "{$date}/{$delta}.json"; } - } else { - foreach ($deltas as $delta) { - if ($entry['files'][$delta]) { - return "{$date}/{$delta}.json"; - } + } + } else { + foreach ($deltas as $delta) { + if ($entry['files'][$delta]) { + return "{$date}/{$delta}.json"; } } - - // The `full.json` file is not considered for now, because it is very unlikely that none of the - // delta files are available. Also, it's significant larger than the delta updates and we cannot - // reliably predict if we're able to import it at all: slow hosts or max_execution_time almost - // exhausted by other cronjobs. } + + // The `full.json` file is not considered for now, because it is very unlikely that none of the + // delta files are available. Also, it's significant larger than the delta updates and we cannot + // reliably predict if we're able to import it at all: slow hosts or max_execution_time almost + // exhausted by other cronjobs. } return null; diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index 76d363c8fbe..f4a997eb3ad 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -367,7 +367,7 @@ public function getController() /** * Returns the menu shown in the box. * - * @return Menu + * @return ?Menu */ public function getMenu() { @@ -547,11 +547,14 @@ public function getConditions() */ public function getControllerConditions(): array { - /** @noinspection PhpUndefinedMethodInspection */ - if ($this->boxType === 'system' && $this->getController() instanceof IConditionBoxController && $this->getController()->getConditionDefinition()) { - /** @noinspection PhpUndefinedMethodInspection */ + if ($this->boxType !== 'system') { + return []; + } + + $controller = $this->getController(); + if ($controller instanceof IConditionBoxController && $controller->getConditionDefinition()) { return ConditionHandler::getInstance()->getConditions( - $this->getController()->getConditionDefinition(), + $controller->getConditionDefinition(), $this->boxID ); } @@ -634,7 +637,7 @@ public function showEditButton() * Returns the box with the given identifier. * * @param string $identifier - * @return Box + * @return ?Box */ public static function getBoxByIdentifier($identifier) { @@ -651,7 +654,7 @@ public static function getBoxByIdentifier($identifier) * Returns the box with the given name. * * @param string $name - * @return Box + * @return ?Box */ public static function getBoxByName($name) { @@ -668,7 +671,7 @@ public static function getBoxByName($name) * Returns the box with the menu id. * * @param int $menuID - * @return Box + * @return ?Box */ public static function getBoxByMenuID($menuID) { diff --git a/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php b/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php index 929081dc667..9391ca361cd 100644 --- a/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php +++ b/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php @@ -46,7 +46,7 @@ class BoxContent extends DatabaseObject * Returns a certain box content or `null` if it does not exist. * * @param int $boxID - * @param int $languageID + * @param ?int $languageID * @return BoxContent|null */ public static function getBoxContent($boxID, $languageID) diff --git a/wcfsetup/install/files/lib/data/category/AbstractDecoratedCategory.class.php b/wcfsetup/install/files/lib/data/category/AbstractDecoratedCategory.class.php index ce2b37c72e2..7ddf9fa6c07 100644 --- a/wcfsetup/install/files/lib/data/category/AbstractDecoratedCategory.class.php +++ b/wcfsetup/install/files/lib/data/category/AbstractDecoratedCategory.class.php @@ -38,7 +38,7 @@ abstract class AbstractDecoratedCategory extends DatabaseObjectDecorator /** * parent category of this category - * @var AbstractDecoratedCategory + * @var ?AbstractDecoratedCategory */ protected $parentCategory; diff --git a/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php b/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php index e176f5517e8..88509e396e1 100644 --- a/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php +++ b/wcfsetup/install/files/lib/data/category/CategoryEditor.class.php @@ -30,7 +30,7 @@ class CategoryEditor extends DatabaseObjectEditor implements IEditableCachedObje * correct new show order. * * @param int $parentCategoryID - * @param int $showOrder + * @param ?int $showOrder * @return int */ public function updateShowOrder($parentCategoryID, $showOrder) @@ -159,7 +159,7 @@ public static function deleteAll(array $objectIDs = []) * * @param int $objectTypeID * @param int $parentCategoryID - * @param int $showOrder + * @param ?int $showOrder * @return int */ protected static function getShowOrder($objectTypeID, $parentCategoryID, $showOrder) diff --git a/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php b/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php index 9e750776d3b..cf46e0114c0 100644 --- a/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php +++ b/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php @@ -67,7 +67,7 @@ public function send() /** @var ContactOptionHandler $optionHandler */ $optionHandler = $this->parameters['optionHandler']; - /** @var AttachmentHandler $attachmentHandler */ + /** @var ?AttachmentHandler $attachmentHandler */ $attachmentHandler = (!empty($this->parameters['attachmentHandler'])) ? $this->parameters['attachmentHandler'] : null; /** @var ContactAttachment[] $attachments */ diff --git a/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php b/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php index 728d5abc820..d3ed4035b34 100644 --- a/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php +++ b/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php @@ -142,9 +142,7 @@ public function getFormattedOptionValue($forcePlaintext = false) case 'date': $year = $month = $day = 0; $optionValue = \explode('-', $this->optionValue); - if (isset($optionValue[0])) { - $year = \intval($optionValue[0]); - } + $year = \intval($optionValue[0]); if (isset($optionValue[1])) { $month = \intval($optionValue[1]); } diff --git a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php index 72223b42f85..821dd98ca51 100644 --- a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php +++ b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProject.class.php @@ -41,7 +41,7 @@ class DevtoolsProject extends DatabaseObject protected $isCore; /** - * @var Package + * @var ?Package */ protected $package; @@ -51,7 +51,7 @@ class DevtoolsProject extends DatabaseObject protected $packageArchive; /** - * @var PackageValidationException + * @var ?PackageValidationException * @since 5.4 */ protected $packageValidationException; @@ -163,7 +163,7 @@ public function validatePackageXml() } /** - * @return Package + * @return ?Package */ public function getPackage() { diff --git a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProjectAction.class.php b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProjectAction.class.php index c0d93bc5d14..c9f75bf66a6 100644 --- a/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProjectAction.class.php +++ b/wcfsetup/install/files/lib/data/devtools/project/DevtoolsProjectAction.class.php @@ -257,19 +257,21 @@ public function validateDeletePipEntry() // read and validate entry type $this->readString('entryType', true); + $pip = $this->pip->getPip(); + \assert($pip instanceof IGuiPackageInstallationPlugin); if ($this->parameters['entryType'] !== '') { try { - $this->pip->getPip()->setEntryType($this->parameters['entryType']); + $pip->setEntryType($this->parameters['entryType']); } catch (\InvalidArgumentException $e) { throw new IllegalLinkException(); } - } elseif (!empty($this->pip->getPip()->getEntryTypes())) { + } elseif (!empty($pip->getEntryTypes())) { throw new IllegalLinkException(); } // read and validate identifier $this->readString('identifier'); - $entryList = $this->pip->getPip()->getEntryList(); + $entryList = $pip->getEntryList(); if (!$entryList->hasEntry($this->parameters['identifier'])) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php b/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php index 169c7e04ae6..2c457cc60b3 100644 --- a/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php +++ b/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php @@ -179,13 +179,11 @@ public function getElementTag($size) $marginTop = \floor(($size - $height) / 2); } - if ($link !== null) { - return ' + return ' ' . StringUtil::encodeHTML($this->altText)
-                    . 'title ? 'title="' . StringUtil::encodeHTML($this->title) . '" ' : '') - . 'style="margin-top: ' . $marginTop . 'px;" height="' . $height . '" width="' . $width . '" loading="lazy"> - '; - } + . '" ' . ($this->title ? 'title="' . StringUtil::encodeHTML($this->title) . '" ' : '') + . 'style="margin-top: ' . $marginTop . 'px;" height="' . $height . '" width="' . $width . '" loading="lazy"> + '; } $icon = FileUtil::getIconNameByFilename($this->filename); diff --git a/wcfsetup/install/files/lib/data/menu/item/MenuItemNode.class.php b/wcfsetup/install/files/lib/data/menu/item/MenuItemNode.class.php index 92d17cb2df2..9636da8e5c7 100644 --- a/wcfsetup/install/files/lib/data/menu/item/MenuItemNode.class.php +++ b/wcfsetup/install/files/lib/data/menu/item/MenuItemNode.class.php @@ -31,12 +31,6 @@ class MenuItemNode extends DatabaseObjectDecorator implements IObjectTreeNode */ protected bool $isActive = false; - /** - * iterator position - * @var int - */ - private int $position = 0; - /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueue.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueue.class.php index 031ec16213a..342d267cb3f 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueue.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueue.class.php @@ -118,15 +118,12 @@ public function getStatus($status = null) switch ($status) { case self::STATUS_OUTSTANDING: return WCF::getLanguage()->get('wcf.moderation.status.outstanding'); - break; case self::STATUS_PROCESSING: return WCF::getLanguage()->get('wcf.moderation.status.processing'); - break; case self::STATUS_DONE: return WCF::getLanguage()->get('wcf.moderation.status.done'); - break; case self::STATUS_REJECTED: case self::STATUS_CONFIRMED: @@ -139,7 +136,6 @@ public function getStatus($status = null) } return WCF::getLanguage()->get('wcf.moderation.status.' . $phrase . '.' . $definition->definitionName); - break; } return ''; diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php index 8c2de902789..c673cfba9df 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php @@ -42,7 +42,7 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction /** * user object - * @var User + * @var ?User */ public $user; diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueEditor.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueEditor.class.php index 566c444c98b..a0977da3f4c 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueEditor.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueEditor.class.php @@ -45,9 +45,6 @@ public function markAsRejected($markAsJustified = false) $data = ['status' => ModerationQueue::STATUS_REJECTED]; if ($markAsJustified) { $additionalData = $this->getDecoratedObject()->additionalData; - if (!\is_array($additionalData)) { - $additionalData = []; - } $additionalData['markAsJustified'] = true; $data['additionalData'] = \serialize($additionalData); diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php index 0035b1eb764..b563aa76b01 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php @@ -238,9 +238,6 @@ public function validateChangeJustifiedStatus(): void public function changeJustifiedStatus(): void { $additionalData = $this->queue->additionalData; - if (!\is_array($additionalData)) { - $additionalData = []; - } $additionalData['markAsJustified'] = $this->parameters['markAsJustified']; $this->queue->update([ diff --git a/wcfsetup/install/files/lib/data/option/Option.class.php b/wcfsetup/install/files/lib/data/option/Option.class.php index 88e5562113f..34ec6e304ca 100644 --- a/wcfsetup/install/files/lib/data/option/Option.class.php +++ b/wcfsetup/install/files/lib/data/option/Option.class.php @@ -21,7 +21,7 @@ * @property-read string $optionName name and textual identifier of the option * @property-read string $categoryName name of the option category the option belongs to * @property-read string $optionType textual identifier of the option (corresponds to a class implementing `wcf\system\option\IOptionType`) - * @property-read string $optionValue value of the option + * @property-read ?string $optionValue value of the option * @property-read string $validationPattern regular expression used to validate the option's value or empty if no such regular expression exists * @property-read string $selectOptions newline-separated list of selectable options for a selectable option type (line pattern: `{value}:{language item name}`) * @property-read string $enableOptions list of options that are enabled based on the option's value (simple comma-separated list of boolean options, otherwise newline-separated list with line pattern: `{select value}:{comma-separated list}`) diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php index 203feede0f9..94b00d56c0b 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php @@ -372,10 +372,12 @@ final public function isTrustedServer(): bool */ final public static function isUpgradeOverrideEnabled(): bool { + // @phpstan-ignore identical.alwaysTrue if (WCF::AVAILABLE_UPGRADE_VERSION === null) { return false; } + // @phpstan-ignore deadCode.unreachable $overrideKey = \sprintf( "%s\0upgradeOverride_%s", self::class, diff --git a/wcfsetup/install/files/lib/data/page/Page.class.php b/wcfsetup/install/files/lib/data/page/Page.class.php index b00f3c32288..cca3377c968 100644 --- a/wcfsetup/install/files/lib/data/page/Page.class.php +++ b/wcfsetup/install/files/lib/data/page/Page.class.php @@ -398,7 +398,7 @@ public function showShareButtons() * Returns the page with the given identifier. * * @param string $identifier unique page identifier - * @return Page + * @return ?Page */ public static function getPageByIdentifier($identifier) { @@ -415,7 +415,7 @@ public static function getPageByIdentifier($identifier) * Returns the page with the given name. * * @param string $name - * @return Page + * @return ?Page */ public static function getPageByName($name) { diff --git a/wcfsetup/install/files/lib/data/page/content/PageContent.class.php b/wcfsetup/install/files/lib/data/page/content/PageContent.class.php index d2f5e2f312a..b6c8db16272 100644 --- a/wcfsetup/install/files/lib/data/page/content/PageContent.class.php +++ b/wcfsetup/install/files/lib/data/page/content/PageContent.class.php @@ -104,7 +104,7 @@ public function getParsedTemplate($templateName) * Returns a certain page content. * * @param int $pageID - * @param int $languageID + * @param ?int $languageID * @return PageContent|null */ public static function getPageContent($pageID, $languageID) diff --git a/wcfsetup/install/files/lib/data/poll/PollAction.class.php b/wcfsetup/install/files/lib/data/poll/PollAction.class.php index 52ac340ad04..3c40651c7b6 100644 --- a/wcfsetup/install/files/lib/data/poll/PollAction.class.php +++ b/wcfsetup/install/files/lib/data/poll/PollAction.class.php @@ -38,7 +38,7 @@ class PollAction extends AbstractDatabaseObjectAction implements IGroupedUserLis /** * poll object - * @var PollEditor + * @var ?PollEditor */ protected $poll; @@ -206,8 +206,6 @@ public function vote() $this->poll = $this->getSingleObject(); } - \assert($this->poll instanceof PollEditor); - // get previous vote $sql = "SELECT optionID FROM wcf1_poll_option_vote diff --git a/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php b/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php index 8bb62098d16..2620e615a51 100644 --- a/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php +++ b/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php @@ -47,7 +47,7 @@ class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortab */ public function create() { - if (isset($this->parameters['data']['showOrder']) && $this->parameters['data']['showOrder'] !== null) { + if (isset($this->parameters['data']['showOrder'])) { $sql = "UPDATE wcf1_reaction_type SET showOrder = showOrder + 1 WHERE showOrder >= ?"; @@ -154,7 +154,7 @@ public function update() } // update show order - if (isset($this->parameters['data']['showOrder']) && $this->parameters['data']['showOrder'] !== null) { + if (isset($this->parameters['data']['showOrder'])) { $sql = "UPDATE wcf1_reaction_type SET showOrder = showOrder + 1 WHERE showOrder >= ? @@ -186,7 +186,7 @@ public function update() public function validateUpdatePosition() { // validate permissions - if (\is_array($this->permissionsUpdate) && \count($this->permissionsUpdate)) { + if ($this->permissionsUpdate !== []) { WCF::getSession()->checkPermissions($this->permissionsUpdate); } else { throw new PermissionDeniedException(); diff --git a/wcfsetup/install/files/lib/data/smiley/SmileyAction.class.php b/wcfsetup/install/files/lib/data/smiley/SmileyAction.class.php index 39b29b9142a..b071a80e3c4 100644 --- a/wcfsetup/install/files/lib/data/smiley/SmileyAction.class.php +++ b/wcfsetup/install/files/lib/data/smiley/SmileyAction.class.php @@ -121,7 +121,7 @@ public function update() public function validateUpdatePosition() { // validate permissions - if (\is_array($this->permissionsUpdate) && \count($this->permissionsUpdate)) { + if ($this->permissionsUpdate !== []) { WCF::getSession()->checkPermissions($this->permissionsUpdate); } else { throw new PermissionDeniedException(); diff --git a/wcfsetup/install/files/lib/data/style/Style.class.php b/wcfsetup/install/files/lib/data/style/Style.class.php index af31c0b97eb..a59a4344d37 100644 --- a/wcfsetup/install/files/lib/data/style/Style.class.php +++ b/wcfsetup/install/files/lib/data/style/Style.class.php @@ -34,7 +34,7 @@ * @property-read string $packageName package identifier used to export the style as a package or empty (thus style cannot be exported as package) * @property-read int $isTainted is `0` if the original declarations of an imported or installed style are not and cannot be altered, otherwise `1` * @property-read int $hasFavicon is `0` if the default favicon data should be used - * @property-read int $coverPhotoExtension extension of the style's cover photo file + * @property-read string $coverPhotoExtension extension of the style's cover photo file * @property-read int $hasDarkMode */ class Style extends DatabaseObject diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index 9dc24a2eba9..c98c7cdd58d 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -161,7 +161,7 @@ private function setStyleVariables(Style $style, bool $isDarkMode): void $style->loadVariables(); foreach (['pageLogo', 'pageLogoMobile'] as $type) { if (\array_key_exists($type, $this->parameters['uploads'])) { - /** @var \wcf\system\file\upload\UploadFile $file */ + /** @var ?\wcf\system\file\upload\UploadFile $file */ $file = $this->parameters['uploads'][$type]; if ($style->getVariable($type) && \file_exists($style->getAssetPath() . \basename($style->getVariable($type)))) { @@ -271,7 +271,7 @@ protected function updateStylePreviewImage(Style $style) { foreach (['image', 'image2x'] as $type) { if (\array_key_exists($type, $this->parameters['uploads'])) { - /** @var \wcf\system\file\upload\UploadFile $file */ + /** @var ?\wcf\system\file\upload\UploadFile $file */ $file = $this->parameters['uploads'][$type]; if ($style->{$type} && \file_exists($style->getAssetPath() . \basename($style->{$type}))) { @@ -326,7 +326,7 @@ protected function updateFavicons(Style $style) ]; if (\array_key_exists('favicon', $this->parameters['uploads'])) { - /** @var \wcf\system\file\upload\UploadFile $file */ + /** @var ?\wcf\system\file\upload\UploadFile $file */ $file = $this->parameters['uploads']['favicon']; if ($file !== null) { @@ -422,7 +422,7 @@ protected function updateFavicons(Style $style) protected function updateCoverPhoto(Style $style) { if (\array_key_exists('coverPhoto', $this->parameters['uploads'])) { - /** @var \wcf\system\file\upload\UploadFile $file */ + /** @var ?\wcf\system\file\upload\UploadFile $file */ $file = $this->parameters['uploads']['coverPhoto']; if ($style->coverPhotoExtension && \file_exists($style->getCoverPhotoLocation(false))) { diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index 36f8acd9a5f..2fefcc40c1e 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -132,7 +132,8 @@ public static function deleteAll(array $objectIDs = []) $styleList->readObjects(); foreach ($styleList as $style) { - \assert($style instanceof self); + // @phpstan-ignore function.impossibleType, instanceof.alwaysFalse + \assert($style instanceof StyleEditor); $style->delete(); } @@ -892,7 +893,7 @@ protected static function getFileLocation($location) $location = WCF_DIR . $location; $index = null; - do { + for (;;) { $directory = $location . ($index === null ? '' : $index); if (!\is_dir($directory)) { @\mkdir($directory, 0777, true); @@ -902,10 +903,7 @@ protected static function getFileLocation($location) } $index = ($index === null ? 2 : ($index + 1)); - } while (true); - - // this should never happen - throw new \LogicException(); + } } /** diff --git a/wcfsetup/install/files/lib/data/trophy/Trophy.class.php b/wcfsetup/install/files/lib/data/trophy/Trophy.class.php index 5226d7e4c05..6d9a07db6f1 100644 --- a/wcfsetup/install/files/lib/data/trophy/Trophy.class.php +++ b/wcfsetup/install/files/lib/data/trophy/Trophy.class.php @@ -102,7 +102,6 @@ public function renderTrophy($size = self::DEFAULT_SIZE, $showTooltip = false) 'trophy' => $this, 'showTooltip' => $showTooltip, ]); - break; case self::TYPE_BADGE: return WCF::getTPL()->render('wcf', 'trophyBadge', [ @@ -110,7 +109,6 @@ public function renderTrophy($size = self::DEFAULT_SIZE, $showTooltip = false) 'trophy' => $this, 'showTooltip' => $showTooltip, ]); - break; default: $parameters = [ @@ -126,7 +124,6 @@ public function renderTrophy($size = self::DEFAULT_SIZE, $showTooltip = false) } throw new \LogicException("Unable to render the trophy with the type '" . $this->type . "'."); - break; } } diff --git a/wcfsetup/install/files/lib/data/trophy/TrophyCache.class.php b/wcfsetup/install/files/lib/data/trophy/TrophyCache.class.php index 75626af662f..0e257186061 100644 --- a/wcfsetup/install/files/lib/data/trophy/TrophyCache.class.php +++ b/wcfsetup/install/files/lib/data/trophy/TrophyCache.class.php @@ -29,7 +29,7 @@ class TrophyCache extends SingletonFactory /** * Contains all trophies sorted by the category. - * @var array> + * @var ?array> */ protected $categorySortedTrophies; diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index 25c433acdce..9157ee859a2 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -184,6 +184,7 @@ public function checkPassword( // $isValid is always true at this point. However we intentionally use a variable // that defaults to false to prevent accidents during refactoring. + // @phpstan-ignore function.alreadyNarrowedType \assert($isValid); return $isValid; @@ -651,10 +652,7 @@ public function canPurchasePaidSubscriptions() public function getBlacklistMatches() { if ($this->pendingActivation() && $this->blacklistMatches) { - $matches = JSON::decode($this->blacklistMatches); - if (\is_array($matches)) { - return $matches; - } + return JSON::decode($this->blacklistMatches); } return []; @@ -698,7 +696,7 @@ public function pendingActivation() */ public function requiresEmailActivation() { - return REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER && $this->pendingActivation() && !$this->isEmailConfirmed(); + return (int)REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER && $this->pendingActivation() && !$this->isEmailConfirmed(); } /** @@ -709,7 +707,7 @@ public function requiresEmailActivation() */ public function requiresAdminActivation() { - return REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_ADMIN && $this->pendingActivation(); + return (int)REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_ADMIN && $this->pendingActivation(); } /** @@ -720,7 +718,7 @@ public function requiresAdminActivation() */ public function canEmailConfirm() { - return REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER && !$this->isEmailConfirmed(); + return (int)REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER && !$this->isEmailConfirmed(); } /** @@ -731,7 +729,7 @@ public function canEmailConfirm() */ public function mustSelfEmailConfirm() { - return !!(REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER); + return !!((int)REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER); } /** diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index ab5970604ce..dffeb595116 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -587,7 +587,7 @@ public function getSearchResultList() $collator = new \Collator(WCF::getLanguage()->getLocale()); \usort( $list, - static fn (array $item1, array $item2) => $collator->compare($item1['label'], $item2['label']) + static fn(array $item1, array $item2) => $collator->compare($item1['label'], $item2['label']) ); } @@ -704,7 +704,7 @@ public function confirmEmail() ], ]))->executeAction(); - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN)) { $this->enable(); } @@ -746,7 +746,7 @@ public function enable() 'blacklistMatches' => '', ]; - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { $data['emailConfirmed'] = null; } @@ -1135,9 +1135,7 @@ public function validatePrepareRemoveContent() /** * @since 5.3 */ - public function validateSaveUserConsent() - { - } + public function validateSaveUserConsent() {} /** * @since 5.3 @@ -1166,7 +1164,7 @@ public function validateResendActivationMail() throw new PermissionDeniedException(); } - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/data/user/UserBirthdayAction.class.php b/wcfsetup/install/files/lib/data/user/UserBirthdayAction.class.php index 2104b4aa6fd..1bc0e109904 100644 --- a/wcfsetup/install/files/lib/data/user/UserBirthdayAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserBirthdayAction.class.php @@ -56,9 +56,7 @@ public function getGroupedUserList() { $year = $month = $day = 0; $value = \explode('-', $this->parameters['date']); - if (isset($value[0])) { - $year = \intval($value[0]); - } + $year = \intval($value[0]); if (isset($value[1])) { $month = \intval($value[1]); } diff --git a/wcfsetup/install/files/lib/data/user/UserProfile.class.php b/wcfsetup/install/files/lib/data/user/UserProfile.class.php index 48e7dc911a6..6cb55f4ca19 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfile.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfile.class.php @@ -386,7 +386,7 @@ public function getAvatar() $avatar = new DefaultAvatar($this->username ?: ''); } - $this->avatar = new AvatarDecorator($this->avatar); + $this->avatar = new AvatarDecorator($avatar); } return $this->avatar; @@ -668,7 +668,7 @@ public static function getUserProfiles(array $userIDs) * Returns the user profile of the user with the given name. * * @param string $username - * @return UserProfile + * @return ?UserProfile */ public static function getUserProfileByUsername($username) { @@ -805,9 +805,7 @@ public function getAge($year = null) if ($showYear) { $birthdayYear = 0; $value = \explode('-', $this->birthday); - if (isset($value[0])) { - $birthdayYear = \intval($value[0]); - } + $birthdayYear = \intval($value[0]); if ($birthdayYear) { return $year - $birthdayYear; } @@ -838,9 +836,7 @@ public function getBirthday($year = null) // split date $birthdayYear = $month = $day = 0; $value = \explode('-', $this->birthday); - if (isset($value[0])) { - $birthdayYear = \intval($value[0]); - } + $birthdayYear = \intval($value[0]); if (isset($value[1])) { $month = \intval($value[1]); } diff --git a/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php b/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php index 688b92f76fb..ed64cef41cb 100644 --- a/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php +++ b/wcfsetup/install/files/lib/data/user/cover/photo/UserCoverPhoto.class.php @@ -65,7 +65,7 @@ public function getFilename(?bool $forceWebP = null): string } #[\Override] - public function getObjectID(): ?int + public function getObjectID(): int { return $this->file->fileID; } diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php index 49a42ef0f12..eb9ac58b6cc 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -69,7 +69,7 @@ class UserGroup extends DatabaseObject implements ITitledObject /** * group cache - * @var array{groups: array, types: array} + * @var array{groups: array, types: array} */ protected static $cache; @@ -115,7 +115,7 @@ public static function getGroupIDsByType(array $types) * * @param int[] $types * @param int[] $invalidGroupTypes - * @return UserGroup[] + * @return array */ public static function getGroupsByType(array $types = [], array $invalidGroupTypes = []) { @@ -157,7 +157,7 @@ public static function getSortedGroupsByType(array $types = [], array $invalidGr * Returns unique group by given type. Only works for the default user groups. * * @param int $type - * @return UserGroup + * @return ?UserGroup * @throws SystemException */ public static function getGroupByType($type) diff --git a/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php b/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php index c672f4bd6f7..3e67d8e96fd 100644 --- a/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php +++ b/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php @@ -163,7 +163,7 @@ public function validateGetDialog() $ignore = UserIgnore::getIgnore($this->parameters['userID']); // Check if the user is not yet ignored and cannot be ignored. - if (!$ignore && $userProfile->getPermission('user.profile.cannotBeIgnored')) { + if (!$ignore->ignoreID && $userProfile->getPermission('user.profile.cannotBeIgnored')) { throw new PermissionDeniedException(); } } diff --git a/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php b/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php index 43e02e28d7d..0dd0f0c79e7 100644 --- a/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php +++ b/wcfsetup/install/files/lib/data/user/online/UserOnline.class.php @@ -77,9 +77,8 @@ public function setLocation($location = null) if ($this->pageID) { $page = PageCache::getInstance()->getPage($this->pageID); if ($page !== null) { - if ($page->getHandler() !== null && $page->getHandler() instanceof IOnlineLocationPageHandler) { - $handler = $page->getHandler(); - \assert($handler instanceof IOnlineLocationPageHandler); + $handler = $page->getHandler(); + if ($handler instanceof IOnlineLocationPageHandler) { $this->location = $handler->getOnlineLocation($page, $this); return true; diff --git a/wcfsetup/install/files/lib/data/user/option/UserOptionEditor.class.php b/wcfsetup/install/files/lib/data/user/option/UserOptionEditor.class.php index 6eb498d3d50..b4e5c11d2ab 100644 --- a/wcfsetup/install/files/lib/data/user/option/UserOptionEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/option/UserOptionEditor.class.php @@ -41,7 +41,7 @@ public static function create(array $parameters = []) ); // add the default value to this column - if (isset($parameters['defaultValue']) && $parameters['defaultValue'] !== null) { + if (isset($parameters['defaultValue'])) { $sql = "UPDATE wcf1_user_option_value SET userOption" . $userOption->optionID . " = ?"; $statement = WCF::getDB()->prepare($sql); diff --git a/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php b/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php index c79a9b35276..5e6ecbc51f8 100644 --- a/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php +++ b/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php @@ -127,6 +127,8 @@ protected function createForm() * Finalizes the form after it has been successfully built. * * This method can be used to add form field dependencies. + * + * @return void */ protected function finalizeForm() { diff --git a/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php b/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php index 89b4ae6bd20..d7443f20174 100644 --- a/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php +++ b/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php @@ -71,7 +71,7 @@ abstract class AbstractModerationForm extends AbstractForm /** * list of comments - * @var StructuredCommentList + * @var ?StructuredCommentList */ public $commentList; diff --git a/wcfsetup/install/files/lib/form/AccountManagementForm.class.php b/wcfsetup/install/files/lib/form/AccountManagementForm.class.php index 2fb651f8cb2..c154bfe5c3e 100644 --- a/wcfsetup/install/files/lib/form/AccountManagementForm.class.php +++ b/wcfsetup/install/files/lib/form/AccountManagementForm.class.php @@ -370,11 +370,11 @@ public function save() && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail ) { - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { // update email $updateParameters['email'] = $this->email; $success[] = 'wcf.user.changeEmail.success'; - } elseif (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) { + } elseif ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) { // get reactivation code $activationCode = UserRegistrationUtil::getActivationCode(); @@ -475,7 +475,7 @@ public function save() $this->objectAction = new UserAction([WCF::getUser()], 'update', $data); $this->objectAction->executeAction(); - + // @phpstan-ignore isset.offset if (isset($updateParameters['newEmail']) && isset($updateParameters['reactivationCode'])) { // Use user list to allow overriding of the fields without duplicating logic $userList = new UserList(); diff --git a/wcfsetup/install/files/lib/form/ContactForm.class.php b/wcfsetup/install/files/lib/form/ContactForm.class.php index 3e3547bc51c..6f7e89dc845 100644 --- a/wcfsetup/install/files/lib/form/ContactForm.class.php +++ b/wcfsetup/install/files/lib/form/ContactForm.class.php @@ -185,9 +185,6 @@ private function handleSpamCheck(): void } $messages[] = $object->getOptionValue(); - if ($object->optionType === 'date' && !$object->getOptionValue()) { - continue; - } } $spamCheckEvent = new ContactFormSpamChecking( diff --git a/wcfsetup/install/files/lib/form/EmailActivationForm.class.php b/wcfsetup/install/files/lib/form/EmailActivationForm.class.php index b1ff36c7696..9c575376f48 100644 --- a/wcfsetup/install/files/lib/form/EmailActivationForm.class.php +++ b/wcfsetup/install/files/lib/form/EmailActivationForm.class.php @@ -108,7 +108,7 @@ private function validateActivationCode(IntegerFormField $formField): void */ public function show() { - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/form/EmailNewActivationCodeForm.class.php b/wcfsetup/install/files/lib/form/EmailNewActivationCodeForm.class.php index 434089ea002..c5925496a72 100644 --- a/wcfsetup/install/files/lib/form/EmailNewActivationCodeForm.class.php +++ b/wcfsetup/install/files/lib/form/EmailNewActivationCodeForm.class.php @@ -175,7 +175,7 @@ private function forwardToIndexPage(): void */ public function show() { - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/form/MessageForm.class.php b/wcfsetup/install/files/lib/form/MessageForm.class.php index 68d71dd8005..45c2050549b 100644 --- a/wcfsetup/install/files/lib/form/MessageForm.class.php +++ b/wcfsetup/install/files/lib/form/MessageForm.class.php @@ -333,7 +333,7 @@ public function assignVariables() parent::assignVariables(); $upcastProcessor = new HtmlUpcastProcessor(); - $upcastProcessor->process($this->text ?? '', $this->messageObjectType, 0); + $upcastProcessor->process($this->text, $this->messageObjectType, 0); WCF::getTPL()->assign([ 'attachmentHandler' => $this->attachmentHandler, diff --git a/wcfsetup/install/files/lib/form/MultifactorManageForm.class.php b/wcfsetup/install/files/lib/form/MultifactorManageForm.class.php index 199bf059942..70da3c7a571 100644 --- a/wcfsetup/install/files/lib/form/MultifactorManageForm.class.php +++ b/wcfsetup/install/files/lib/form/MultifactorManageForm.class.php @@ -130,7 +130,7 @@ public function save() WCF::getDB()->beginTransaction(); - /** @var Setup|null $setup */ + /** @var ?Setup $setup */ $setup = null; if ($this->setup) { $setup = $this->setup->lock(); @@ -144,10 +144,6 @@ public function save() } } - if (!$setup) { - throw new \RuntimeException("Multifactor setup disappeared"); - } - $this->returnData = $this->processor->processManagementForm($this->form, $setup); $this->setup = $setup; diff --git a/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php b/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php index d504e5d01e6..65caee53b66 100644 --- a/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php +++ b/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php @@ -110,7 +110,7 @@ private function validateActivationCode(TextFormField $formField): void */ public function show() { - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/form/RegisterForm.class.php b/wcfsetup/install/files/lib/form/RegisterForm.class.php index 74b39868d86..8f935dd1256 100644 --- a/wcfsetup/install/files/lib/form/RegisterForm.class.php +++ b/wcfsetup/install/files/lib/form/RegisterForm.class.php @@ -409,8 +409,8 @@ public function save() $addDefaultGroups = true; if ( $this->spamCheckEvent->hasMatches() - || (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && !$registerVia3rdParty) - || (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) + || ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && !$registerVia3rdParty) + || ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) ) { $activationCode = UserRegistrationUtil::getActivationCode(); $this->additionalFields['activationCode'] = $activationCode; @@ -449,10 +449,10 @@ public function save() $this->message = 'wcf.user.register.success'; UserGroupAssignmentHandler::getInstance()->checkUsers([$user->userID]); - } elseif (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && !$this->spamCheckEvent->hasMatches()) { + } elseif ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && !$this->spamCheckEvent->hasMatches()) { // registering via 3rdParty leads to instant activation if ($registerVia3rdParty) { - if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) { + if ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) { $this->message = 'wcf.user.register.success.awaitActivation'; } else { $this->message = 'wcf.user.register.success'; @@ -470,7 +470,7 @@ public function save() $email->send(); $this->message = 'wcf.user.register.success.needActivation'; } - } elseif (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN || $this->spamCheckEvent->hasMatches()) { + } elseif ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN || $this->spamCheckEvent->hasMatches()) { $this->message = 'wcf.user.register.success.awaitActivation'; } diff --git a/wcfsetup/install/files/lib/form/RegisterNewActivationCodeForm.class.php b/wcfsetup/install/files/lib/form/RegisterNewActivationCodeForm.class.php index 6571e308874..b2b887e6e56 100644 --- a/wcfsetup/install/files/lib/form/RegisterNewActivationCodeForm.class.php +++ b/wcfsetup/install/files/lib/form/RegisterNewActivationCodeForm.class.php @@ -207,7 +207,7 @@ private function forwardToIndexPage(): void */ public function show() { - if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { + if (!((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/http/Helper.class.php b/wcfsetup/install/files/lib/http/Helper.class.php index 92b2b958c4b..47eed9c3963 100644 --- a/wcfsetup/install/files/lib/http/Helper.class.php +++ b/wcfsetup/install/files/lib/http/Helper.class.php @@ -182,8 +182,8 @@ public static function fetchObjectFromRequestParameter(int|string $objectID, str throw new ParentClassException($className, DatabaseObject::class); } + /** @var DatabaseObject $dbo */ $dbo = new $className($objectID); - \assert($dbo instanceof DatabaseObject); if (!$dbo->getObjectID()) { throw new UserInputException( diff --git a/wcfsetup/install/files/lib/page/ArticleListPage.class.php b/wcfsetup/install/files/lib/page/ArticleListPage.class.php index ca6a811c9d9..ce26c7d714f 100644 --- a/wcfsetup/install/files/lib/page/ArticleListPage.class.php +++ b/wcfsetup/install/files/lib/page/ArticleListPage.class.php @@ -74,7 +74,7 @@ class ArticleListPage extends SortablePage public $controllerParameters = ['application' => 'wcf']; /** - * @var User + * @var ?User * @since 5.2 */ public $user; diff --git a/wcfsetup/install/files/lib/page/CombinedTaggedPage.class.php b/wcfsetup/install/files/lib/page/CombinedTaggedPage.class.php index 078b354dacc..16b0ae4bfa4 100644 --- a/wcfsetup/install/files/lib/page/CombinedTaggedPage.class.php +++ b/wcfsetup/install/files/lib/page/CombinedTaggedPage.class.php @@ -41,7 +41,7 @@ class CombinedTaggedPage extends MultipleLinkPage public $neededPermissions = ['user.tag.canViewTag']; /** - * @var ObjectType + * @var ?ObjectType */ public $objectType; diff --git a/wcfsetup/install/files/lib/page/TaggedPage.class.php b/wcfsetup/install/files/lib/page/TaggedPage.class.php index 1ded7bdb95a..356ccceeaa2 100644 --- a/wcfsetup/install/files/lib/page/TaggedPage.class.php +++ b/wcfsetup/install/files/lib/page/TaggedPage.class.php @@ -50,7 +50,7 @@ class TaggedPage extends MultipleLinkPage /** * object type object - * @var ObjectType + * @var ?ObjectType */ public $objectType; diff --git a/wcfsetup/install/files/lib/system/Regex.class.php b/wcfsetup/install/files/lib/system/Regex.class.php index 92ab6b78add..a745ef0726a 100644 --- a/wcfsetup/install/files/lib/system/Regex.class.php +++ b/wcfsetup/install/files/lib/system/Regex.class.php @@ -293,7 +293,6 @@ private function checkResult($result, $method = '') break; case \PREG_NO_ERROR: return $result; - break; default: $error = 'Unknown error'; break; diff --git a/wcfsetup/install/files/lib/system/SingletonFactory.class.php b/wcfsetup/install/files/lib/system/SingletonFactory.class.php index 89dda5ff1ff..74702b3d1b5 100644 --- a/wcfsetup/install/files/lib/system/SingletonFactory.class.php +++ b/wcfsetup/install/files/lib/system/SingletonFactory.class.php @@ -15,7 +15,7 @@ abstract class SingletonFactory { /** * list of singletons - * @var static[] + * @var (static|false)[] */ protected static $__singletonObjects = []; @@ -30,6 +30,8 @@ final protected function __construct() /** * Called within __construct(), override if necessary. + * + * @return void */ protected function init() { diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 2e6b7fdb0fb..4a761148af3 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -239,6 +239,7 @@ public static function destruct() { try { // database has to be initialized + // @phpstan-ignore function.alreadyNarrowedType if (!\is_object(self::$dbObj)) { return; } @@ -258,6 +259,7 @@ public static function destruct() } // update session + // @phpstan-ignore function.alreadyNarrowedType if (\is_object(self::getSession())) { self::getSession()->update(); } @@ -417,6 +419,7 @@ protected function loadOptions(): void if (!\is_writable($filename)) { FileUtil::makeWritable($filename); + // @phpstan-ignore booleanNot.alwaysTrue if (!\is_writable($filename)) { throw new SystemException("The option file '" . $filename . "' is not writable."); } @@ -644,6 +647,7 @@ protected function loadApplication(Application $application, bool $isDependentAp $packageDir = FileUtil::getRealPath(WCF_DIR . $relativePath); self::$autoloadDirectories[$abbreviation] = $packageDir . 'lib/'; + // @phpstan-ignore if.alwaysFalse if (\class_exists($className)) { // the class can now be found, update the `packageDir` value (new PackageEditor($package))->update(['packageDir' => $relativePath]); @@ -830,7 +834,7 @@ final public static function setLanguage(int $languageID): void final public static function autoload(string $className): void { $className = \strtr($className, '\\', '/'); - if (($slashPos = \strpos($className, '/')) !== null) { + if (($slashPos = \strpos($className, '/')) !== false) { $applicationPrefix = \substr($className, 0, $slashPos); if (isset(self::$autoloadDirectories[$applicationPrefix])) { $classPath = self::$autoloadDirectories[$applicationPrefix] . \substr($className, $slashPos + 1) . '.class.php'; @@ -854,7 +858,7 @@ final public static function autoloadDebug(string $className): void // logic cannot be moved into a shared function, because it // measurably reduced autoloader performance. $className = \strtr($className, '\\', '/'); - if (($slashPos = \strpos($className, '/')) !== null) { + if (($slashPos = \strpos($className, '/')) !== false) { $applicationPrefix = \substr($className, 0, $slashPos); if (isset(self::$autoloadDirectories[$applicationPrefix])) { $classPath = self::$autoloadDirectories[$applicationPrefix] . \substr($className, $slashPos + 1) . '.class.php'; diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 4af2da609f5..f75c87e8c32 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -531,7 +531,6 @@ protected function configureDB(): ResponseInterface case 1115: // work-around for older MySQL versions that don't know utf8mb4 throw new SystemException("Insufficient MySQL version. Version '8.0.30' or greater is needed."); - break; default: throw $e; diff --git a/wcfsetup/install/files/lib/system/acp/dashboard/box/UsersAwaitingApprovalAcpDashboardBox.class.php b/wcfsetup/install/files/lib/system/acp/dashboard/box/UsersAwaitingApprovalAcpDashboardBox.class.php index 1b921ea0806..c4791f2f061 100644 --- a/wcfsetup/install/files/lib/system/acp/dashboard/box/UsersAwaitingApprovalAcpDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/acp/dashboard/box/UsersAwaitingApprovalAcpDashboardBox.class.php @@ -23,7 +23,7 @@ final class UsersAwaitingApprovalAcpDashboardBox extends AbstractAcpDashboardBox public function isAccessible(): bool { return WCF::getSession()->getPermission('admin.user.canSearchUser') - && (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN); + && ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN); } #[\Override] @@ -65,7 +65,7 @@ private function getUserList(): UserProfileList $this->userList->sqlLimit = 10; $this->userList->getConditionBuilder()->add('banned = ?', [0]); $this->userList->getConditionBuilder()->add('activationCode <> ?', [0]); - if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) { + if ((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) { $this->userList->getConditionBuilder()->add('emailConfirmed IS NULL'); } $this->userList->sqlOrderBy = 'registrationDate DESC'; diff --git a/wcfsetup/install/files/lib/system/article/discussion/AbstractArticleDiscussionProvider.class.php b/wcfsetup/install/files/lib/system/article/discussion/AbstractArticleDiscussionProvider.class.php index 7a136851480..46571973793 100644 --- a/wcfsetup/install/files/lib/system/article/discussion/AbstractArticleDiscussionProvider.class.php +++ b/wcfsetup/install/files/lib/system/article/discussion/AbstractArticleDiscussionProvider.class.php @@ -17,12 +17,12 @@ abstract class AbstractArticleDiscussionProvider implements IArticleDiscussionProvider { /** - * @var Article + * @var ?Article */ protected $article; /** - * @var ArticleContent + * @var ?ArticleContent */ protected $articleContent; diff --git a/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php b/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php index da898966d8e..0d251ba2c09 100644 --- a/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php +++ b/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php @@ -347,7 +347,7 @@ public function getHtmlElement(): string { return $this->getFileProcessor()->toHtmlElement( $this->objectType->objectType, - $this->objectID ?? 0, + $this->objectID, \implode(',', $this->tmpHash), $this->parentObjectID ); diff --git a/wcfsetup/install/files/lib/system/background/job/NotificationEmailDeliveryBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/NotificationEmailDeliveryBackgroundJob.class.php index eccb0ff0da1..1c2bb8b357f 100644 --- a/wcfsetup/install/files/lib/system/background/job/NotificationEmailDeliveryBackgroundJob.class.php +++ b/wcfsetup/install/files/lib/system/background/job/NotificationEmailDeliveryBackgroundJob.class.php @@ -87,7 +87,6 @@ public function perform() $statement = WCF::getDB()->prepare($sql, 1); $statement->execute([$this->notificationID]); - /** @var UserNotification $notification */ $notification = $statement->fetchObject(UserNotification::class); $statement->closeCursor(); diff --git a/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php index cdc51a228c3..8c5abbe8a75 100644 --- a/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php +++ b/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php @@ -80,7 +80,6 @@ private function sendNotification(int $serviceWorkerID, int $notificationID): vo $statement = WCF::getDB()->prepare($sql, 1); $statement->execute([$notificationID]); - /** @var UserNotification $notification */ $notification = $statement->fetchObject(UserNotification::class); $statement->closeCursor(); if (!$notification || !$notification->notificationID) { diff --git a/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php index 29601fd28f0..efc43d7b784 100644 --- a/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php +++ b/wcfsetup/install/files/lib/system/background/job/UnfurlUrlBackgroundJob.class.php @@ -165,8 +165,6 @@ private function getImageData(UnfurlResponse $unfurlResponse): array } catch (UrlInaccessible | DownloadFailed $e) { return []; } - - throw new LogicException("Unreachable"); } private static function getImageIdByUrl(string $url): ?int diff --git a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php index 15f251171db..227528c4e25 100644 --- a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php @@ -189,6 +189,7 @@ public function getHighlighters() */ public function getCodeBlockLanguages(): array { + /** @var string[] $highlighters */ $highlighters = \explode("\n", StringUtil::unifyNewlines(\MESSAGE_PUBLIC_HIGHLIGHTERS)); if ($highlighters !== []) { return $highlighters; diff --git a/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php b/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php index 5f337cce5f8..e67a4c2a0f4 100644 --- a/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/DomBBCodeParser.class.php @@ -102,8 +102,6 @@ public function parse(\DOMDocument $document): void // converted into its BBCode representation. $strayOpeningTags = \array_filter($this->bbcodesByAppearance); foreach ($strayOpeningTags as $element) { - \assert($element !== null); - $this->insertBBCode($element); } diff --git a/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php index 8ec70ed2d67..4ba39d32806 100644 --- a/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php @@ -37,7 +37,7 @@ public function getParsedTag(array $openingTag, $content, array $closingTag, BBC } $removeLinks = false; - /** @var \DOMElement $element */ + /** @var ?\DOMElement $element */ $element = $closingTag['__parents'][0] ?? null; if ($element && $element->nodeName === 'a') { // We do permit media elements to be nested inside a link, but we must suppress @@ -46,7 +46,7 @@ public function getParsedTag(array $openingTag, $content, array $closingTag, BBC $removeLinks = true; } - /** @var ViewableMedia $media */ + /** @var ?ViewableMedia $media */ $media = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.media', $mediaID); if ($media === null) { return ContentNotVisibleView::forNotAvailable(); diff --git a/wcfsetup/install/files/lib/system/bbcode/WoltLabSuitePageBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/WoltLabSuitePageBBCode.class.php index 2e061e68258..47c512df0fc 100644 --- a/wcfsetup/install/files/lib/system/bbcode/WoltLabSuitePageBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/WoltLabSuitePageBBCode.class.php @@ -29,7 +29,7 @@ public function getParsedTag(array $openingTag, $content, array $closingTag, BBC $title = (!empty($openingTag['attributes'][1])) ? StringUtil::trim($openingTag['attributes'][1]) : ''; - /** @var Page $page */ + /** @var ?Page $page */ $page = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.page', $pageID); if ($page !== null) { return StringUtil::getAnchorTag($page->getLink(), $title ?: $page->getTitle()); diff --git a/wcfsetup/install/files/lib/system/box/PageCommentListBoxController.class.php b/wcfsetup/install/files/lib/system/box/PageCommentListBoxController.class.php index 009e96bf0d6..1ab9051b1ab 100644 --- a/wcfsetup/install/files/lib/system/box/PageCommentListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/PageCommentListBoxController.class.php @@ -50,7 +50,7 @@ protected function getTemplate() 'commentObjectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.page'), 'lastCommentTime' => $this->objectList->getMinCommentTime(), 'pageID' => RequestHandler::getInstance()->getActivePageID() ?: 0, - 'likeData' => (MODULE_LIKE && $this->objectList) ? $this->objectList->getLikeData() : [], + 'likeData' => (MODULE_LIKE) ? $this->objectList->getLikeData() : [], ]); } diff --git a/wcfsetup/install/files/lib/system/cache/builder/PageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/PageCacheBuilder.class.php index 0027a366eeb..c4489cacc31 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/PageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/PageCacheBuilder.class.php @@ -42,13 +42,13 @@ public function rebuild(array $parameters) while ($row = $statement->fetchArray()) { $pageID = $row['pageID']; - if (!isset($data['pageTitles'])) { + if (!isset($data['pageTitles'][$pageID])) { $data['pageTitles'][$pageID] = []; } $data['pageTitles'][$pageID][$row['languageID'] ?: 0] = $row['title']; - if (!isset($data['pageMetaDescriptions'])) { + if (!isset($data['pageMetaDescriptions'][$pageID])) { $data['pageMetaDescriptions'][$pageID] = []; } $data['pageMetaDescriptions'][$pageID][$row['languageID'] ?: 0] = $row['metaDescription']; diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php index 4ab4cf826b9..814b903ffad 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php @@ -145,7 +145,7 @@ public function rebuild(array $parameters) if ($includesOwnerGroup) { // Regardless of the actual permissions, the owner group has access to all groups. $accessibleGroupIDs = \array_keys(UserGroup::getAllGroups()); - } elseif (!$includesOwnerGroup && \in_array($ownerGroup->groupID, $accessibleGroupIDs)) { + } elseif (\in_array($ownerGroup->groupID, $accessibleGroupIDs)) { $accessibleGroupIDs = \array_diff($accessibleGroupIDs, [$ownerGroup->groupID]); } diff --git a/wcfsetup/install/files/lib/system/cache/runtime/CommentResponseRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/CommentResponseRuntimeCache.class.php index 64073a59c5b..4fe31d687f5 100644 --- a/wcfsetup/install/files/lib/system/cache/runtime/CommentResponseRuntimeCache.class.php +++ b/wcfsetup/install/files/lib/system/cache/runtime/CommentResponseRuntimeCache.class.php @@ -13,9 +13,9 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @method CommentResponse[] getCachedObjects() - * @method CommentResponse|null getObject($objectID) - * @method CommentResponse[] getObjects(array $objectIDs) + * @method (CommentResponse|null)[] getCachedObjects() + * @method ?CommentResponse getObject($objectID) + * @method (CommentResponse|null)[] getObjects(array $objectIDs) */ class CommentResponseRuntimeCache extends AbstractRuntimeCache { diff --git a/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php index 2e4f64dd253..7c16de370fe 100644 --- a/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php +++ b/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php @@ -13,9 +13,9 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @method Comment[] getCachedObjects() - * @method Comment|null getObject($objectID) - * @method Comment[] getObjects(array $objectIDs) + * @method (Comment|null)[] getCachedObjects() + * @method ?Comment getObject($objectID) + * @method (Comment|null)[] getObjects(array $objectIDs) */ class CommentRuntimeCache extends AbstractRuntimeCache { diff --git a/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php index 9bb7040f141..6117539a7ff 100644 --- a/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php +++ b/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php @@ -13,9 +13,9 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @method UserProfile[] getCachedObjects() + * @method (UserProfile|null)[] getCachedObjects() * @method UserProfile|null getObject($objectID) - * @method UserProfile[] getObjects(array $objectIDs) + * @method (UserProfile|null)[] getObjects(array $objectIDs) */ class UserProfileRuntimeCache extends AbstractRuntimeCache { diff --git a/wcfsetup/install/files/lib/system/cache/runtime/UserRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/UserRuntimeCache.class.php index 9be3b79f777..6e95fe4be79 100644 --- a/wcfsetup/install/files/lib/system/cache/runtime/UserRuntimeCache.class.php +++ b/wcfsetup/install/files/lib/system/cache/runtime/UserRuntimeCache.class.php @@ -13,9 +13,9 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @method User[] getCachedObjects() - * @method User|null getObject($objectID) - * @method User[] getObjects(array $objectIDs) + * @method (User|null)[] getCachedObjects() + * @method ?User getObject($objectID) + * @method (User|null)[] getObjects(array $objectIDs) */ class UserRuntimeCache extends AbstractRuntimeCache { diff --git a/wcfsetup/install/files/lib/system/cache/runtime/ViewableCommentRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/ViewableCommentRuntimeCache.class.php index 42d7ec1be38..d522973f502 100644 --- a/wcfsetup/install/files/lib/system/cache/runtime/ViewableCommentRuntimeCache.class.php +++ b/wcfsetup/install/files/lib/system/cache/runtime/ViewableCommentRuntimeCache.class.php @@ -13,9 +13,9 @@ * @license GNU Lesser General Public License * @since 5.5 * - * @method ViewableComment[] getCachedObjects() - * @method ViewableComment getObject($objectID) - * @method ViewableComment[] getObjects(array $objectIDs) + * @method (ViewableComment|null)[] getCachedObjects() + * @method ViewableComment|null getObject($objectID) + * @method (ViewableComment|null)[] getObjects(array $objectIDs) */ class ViewableCommentRuntimeCache extends AbstractRuntimeCache { diff --git a/wcfsetup/install/files/lib/system/cache/runtime/ViewableMediaRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/ViewableMediaRuntimeCache.class.php index 78fce3865dd..f53fa6f9fbc 100644 --- a/wcfsetup/install/files/lib/system/cache/runtime/ViewableMediaRuntimeCache.class.php +++ b/wcfsetup/install/files/lib/system/cache/runtime/ViewableMediaRuntimeCache.class.php @@ -13,9 +13,9 @@ * @license GNU Lesser General Public License * @since 3.0 * - * @method ViewableMedia[] getCachedObjects() - * @method ViewableMedia|null getObject($objectID) - * @method ViewableMedia[] getObjects(array $objectIDs) + * @method (ViewableMedia|null)[] getCachedObjects() + * @method ?ViewableMedia getObject($objectID) + * @method (ViewableMedia|null)[] getObjects(array $objectIDs) */ class ViewableMediaRuntimeCache extends AbstractRuntimeCache { diff --git a/wcfsetup/install/files/lib/system/category/ICategoryType.class.php b/wcfsetup/install/files/lib/system/category/ICategoryType.class.php index fba4ef713e7..442cb2470b2 100644 --- a/wcfsetup/install/files/lib/system/category/ICategoryType.class.php +++ b/wcfsetup/install/files/lib/system/category/ICategoryType.class.php @@ -25,6 +25,7 @@ public function afterDeletion(CategoryEditor $categoryEditor); * * @param CategoryEditor $categoryEditor * @since 3.1 + * @return void */ public function beforeDeletion(CategoryEditor $categoryEditor); diff --git a/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php b/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php index 630a6831f65..4d81c9c4035 100644 --- a/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php +++ b/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php @@ -302,9 +302,6 @@ protected function spawnController(IWorker $worker, $threads) $cursorOffset = -$threads; foreach ($processes as &$processData) { $status = \proc_get_status($processData['process']); - if ($status === false) { - throw new \LogicException('Unreachable'); - } $line = false; if ($processData['pipes'][3] !== false) { @@ -367,9 +364,6 @@ protected function spawnController(IWorker $worker, $threads) echo "\033[" . $threads . "A"; foreach ($processes as $processData) { $status = \proc_get_status($processData['process']); - if ($status === false) { - throw new \LogicException('Unreachable'); - } if (!$status['running']) { $processData['progressbar']->update(null, 'T' . $processData['threadId'] . ': exited'); diff --git a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php index 498462c8e62..fd6f20eda8e 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php @@ -325,7 +325,7 @@ protected function validateResendActivationMail() // check permissions if ( !WCF::getSession()->getPermission('admin.user.canEnableUser') - || !(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) + || !((int)REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) ) { return []; } diff --git a/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php b/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php index a395b128938..770da32bc4a 100644 --- a/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php +++ b/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php @@ -312,7 +312,7 @@ public function markNotificationsAsConfirmed($objectType, array $objectIDs, $tim // mark comment reaction notifications as confirmed $reactionCommentEvents = []; - if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.like.notification') !== null) { + if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.like.notification') !== 0) { foreach (UserNotificationHandler::getInstance()->getEvents($objectType . '.like.notification') as $event) { $reactionCommentEvents[$event->eventID] = [ 'eventName' => $event->eventName, @@ -415,7 +415,7 @@ public function markNotificationsAsConfirmed($objectType, array $objectIDs, $tim // mark comment response reaction notifications as confirmed $reactionResponseEvents = []; - if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.response.like.notification') !== null) { + if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.response.like.notification') !== 0) { foreach (UserNotificationHandler::getInstance()->getEvents($objectType . '.response.like.notification') as $event) { $reactionResponseEvents[$event->eventID] = [ 'eventName' => $event->eventName, @@ -523,7 +523,7 @@ public function markNotificationsAsConfirmedForComments($objectType, array $comm // mark comment reaction notifications as confirmed $reactionCommentEvents = []; - if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.like.notification') !== null) { + if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.like.notification') !== 0) { foreach (UserNotificationHandler::getInstance()->getEvents($objectType . '.like.notification') as $event) { $reactionCommentEvents[$event->eventID] = [ 'eventName' => $event->eventName, @@ -602,7 +602,7 @@ public function markNotificationsAsConfirmedForComments($objectType, array $comm // mark comment response reaction notifications as confirmed $reactionResponseEvents = []; - if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.response.like.notification') !== null) { + if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.response.like.notification') !== 0) { foreach (UserNotificationHandler::getInstance()->getEvents($objectType . '.response.like.notification') as $event) { $reactionResponseEvents[$event->eventID] = [ 'eventName' => $event->eventName, @@ -702,7 +702,7 @@ public function markNotificationsAsConfirmedForResponses($objectType, array $res // mark comment response reaction notifications as confirmed $reactionResponseEvents = []; - if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.response.like.notification') !== null) { + if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType . '.response.like.notification') !== 0) { foreach (UserNotificationHandler::getInstance()->getEvents($objectType . '.response.like.notification') as $event) { $reactionResponseEvents[$event->eventID] = [ 'eventName' => $event->eventName, diff --git a/wcfsetup/install/files/lib/system/condition/UserCoverPhotoCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserCoverPhotoCondition.class.php index d15d74dd755..469545e3884 100644 --- a/wcfsetup/install/files/lib/system/condition/UserCoverPhotoCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserCoverPhotoCondition.class.php @@ -78,11 +78,9 @@ public function checkUser(Condition $condition, User $user) switch ($condition->userCoverPhoto) { case self::NO_COVER_PHOTO: return $user->coverPhotoFileID === null; - break; case self::COVER_PHOTO: return $user->coverPhotoFileID !== null; - break; } return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserSignatureCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserSignatureCondition.class.php index abd779ce6a3..e88202a17fc 100644 --- a/wcfsetup/install/files/lib/system/condition/UserSignatureCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserSignatureCondition.class.php @@ -80,11 +80,9 @@ public function checkUser(Condition $condition, User $user) switch ($condition->userSignature) { case self::NO_SIGNATURE: return $user->signature === '' || $user->signature === null; - break; case self::SIGNATURE: return $user->signature !== '' && $user->signature !== null; - break; } return false; diff --git a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php index 6635fd248ec..8b59de90e85 100644 --- a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php @@ -81,8 +81,6 @@ public function executeCronjobs() $this->executeCronjob($cronjobEditor, $logEditor); } catch (\Throwable $e) { $this->logResult($logEditor, $e); - } catch (\Exception $e) { - $this->logResult($logEditor, $e); } } else { $this->logResult($logEditor); diff --git a/wcfsetup/install/files/lib/system/database/Database.class.php b/wcfsetup/install/files/lib/system/database/Database.class.php index 360e7506009..de3a0f09ff6 100644 --- a/wcfsetup/install/files/lib/system/database/Database.class.php +++ b/wcfsetup/install/files/lib/system/database/Database.class.php @@ -77,13 +77,13 @@ abstract class Database /** * database editor object - * @var DatabaseEditor + * @var ?DatabaseEditor */ protected $editor; /** * pdo object - * @var \PDO + * @var ?\PDO */ protected $pdo; diff --git a/wcfsetup/install/files/lib/system/database/Redis.class.php b/wcfsetup/install/files/lib/system/database/Redis.class.php index e461f8ee0cd..7e6a7fe7345 100644 --- a/wcfsetup/install/files/lib/system/database/Redis.class.php +++ b/wcfsetup/install/files/lib/system/database/Redis.class.php @@ -16,7 +16,7 @@ * @method bool expire($key, $ttl) * @method string|bool get($key) * @method int hDel($key, $hashKey1, $hashKey2 = null, $hashKeyN = null) - * @method string hGet($key, $hashKey) + * @method mixed hGet($key, $hashKey) * @method int hSet($key, $hashKey, $value) * @method int incr($key) * @method array info($option = null) diff --git a/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php b/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php index 6a94537a320..40557452c85 100644 --- a/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php +++ b/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php @@ -12,6 +12,7 @@ * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License * @since 3.0 + * @method mixed|int getCode() */ class DatabaseQueryExecutionException extends DatabaseQueryException implements IExtraInformationException { diff --git a/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php b/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php index 8b618785185..27cd8995f2b 100644 --- a/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php +++ b/wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php @@ -333,7 +333,7 @@ public function getAffectedRows() */ public function getErrorNumber() { - $errorCode = $this->pdoStatement?->errorCode(); + $errorCode = $this->pdoStatement->errorCode(); if ($errorCode === null) { return '0'; } @@ -348,14 +348,8 @@ public function getErrorNumber() */ public function getErrorDesc() { - if ($this->pdoStatement !== null) { - $errorInfoArray = $this->pdoStatement->errorInfo(); - if (isset($errorInfoArray[2])) { - return $errorInfoArray[2]; - } - } - - return ''; + $errorInfoArray = $this->pdoStatement->errorInfo(); + return $errorInfoArray[2] ?? ''; } /** diff --git a/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php index 50f31255f4a..b992f0e73c8 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php @@ -117,7 +117,7 @@ public function getName(): string #[\Override] public function getType(): string { - if ($this->type === null) { + if (!isset($this->type)) { throw new \BadMethodCallException( "Type of the database table column " . static::class . " has not been set yet" ); @@ -211,7 +211,7 @@ public static function createFromData(string $name, array $data): static } if ($column instanceof IEnumDatabaseTableColumn && !empty($data['enumValues'])) { - $values = \explode(',', $data['enumValues'] ?? ''); + $values = \explode(',', $data['enumValues']); $values = \array_map(static function ($value) { // trim one leading and one trailing `'` diff --git a/wcfsetup/install/files/lib/system/database/table/column/TDefaultValueDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/TDefaultValueDatabaseTableColumn.class.php index 10b0adc58da..9e546502e85 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/TDefaultValueDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/TDefaultValueDatabaseTableColumn.class.php @@ -22,7 +22,7 @@ trait TDefaultValueDatabaseTableColumn * Checks if the given default value is valid. * * @param mixed $defaultValue validated default value - * @throws \InvalidArgumentException if given default value is invalid + * @return void */ protected function validateDefaultValue(mixed $defaultValue) { diff --git a/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php index 5cb52b935da..6fa2013b6a0 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php @@ -70,11 +70,13 @@ public function length(?int $length): static */ protected function validateLength(int $length): void { + // @phpstan-ignore notIdentical.alwaysTrue if ($this->getMinimumLength() !== null && $length < $this->getMinimumLength()) { throw new \InvalidArgumentException( "Given length is smaller than the minimum length '{$this->getMinimumLength()}'." ); } + // @phpstan-ignore notIdentical.alwaysTrue if ($this->getMaximumLength() !== null && $length > $this->getMaximumLength()) { throw new \InvalidArgumentException( "Given length is greater than the maximum length '{$this->getMaximumLength()}'." diff --git a/wcfsetup/install/files/lib/system/database/table/index/DatabaseTableForeignKey.class.php b/wcfsetup/install/files/lib/system/database/table/index/DatabaseTableForeignKey.class.php index cab69a41c7d..efc8c1dd0d3 100644 --- a/wcfsetup/install/files/lib/system/database/table/index/DatabaseTableForeignKey.class.php +++ b/wcfsetup/install/files/lib/system/database/table/index/DatabaseTableForeignKey.class.php @@ -21,7 +21,7 @@ final class DatabaseTableForeignKey * columns affected by the foreign key * @var string[] */ - protected $columns; + protected array $columns; /** * name of the foreign key @@ -219,7 +219,7 @@ public function name($name) * Sets the action executed in referenced table if row is deleted and returns the foreign * key. * - * @param string $onDelete action executed in referenced table if row is deleted + * @param ?string $onDelete action executed in referenced table if row is deleted * @return $this this foreign key * @throws \InvalidArgumentException if given action is invalid */ @@ -238,7 +238,7 @@ public function onDelete($onDelete) * Sets the action executed in referenced table if row is updated and returns the foreign * key. * - * @param string $onUpdate action executed in referenced table if row is updated + * @param ?string $onUpdate action executed in referenced table if row is updated * @return $this this foreign key * @throws \InvalidArgumentException if given action is invalid */ diff --git a/wcfsetup/install/files/lib/system/devtools/pip/DevtoolsPip.class.php b/wcfsetup/install/files/lib/system/devtools/pip/DevtoolsPip.class.php index 8274d424c95..d0fef7b7afd 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/DevtoolsPip.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/DevtoolsPip.class.php @@ -445,10 +445,9 @@ public function getInstructions(DevtoolsProject $project, $target) if (!\is_file($path)) { $path = "{$project->path}files_wcf/{$instructions['value']}"; - if (!isset($instructions['attributes'])) { - $instructions['attributes'] = []; - } - $instructions['attributes']['application'] = 'wcf'; + $instructions['attributes'] = [ + 'application' => 'wcf', + ]; } $tar->registerFile($instructions['value'], $path); 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 1a3c96aa2bd..f8097899a1f 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php @@ -544,6 +544,7 @@ public function populateForm(IFormDocument $form) $this->addFormFields($eventParameters['form']); + // @phpstan-ignore instanceof.alwaysTrue if (!($eventParameters['form'] instanceof IFormDocument)) { throw new \UnexpectedValueException('Form document is no longer a "' . IFormDocument::class . '" object.'); } diff --git a/wcfsetup/install/files/lib/system/email/Email.class.php b/wcfsetup/install/files/lib/system/email/Email.class.php index c870456029e..b14a6371ef3 100644 --- a/wcfsetup/install/files/lib/system/email/Email.class.php +++ b/wcfsetup/install/files/lib/system/email/Email.class.php @@ -290,7 +290,7 @@ public function getReferences() /** * Sets the list-label part of the email's 'List-Id'. * - * @param string $listId + * @param ?string $listId * @param string $humanReadable * @throws \DomainException * @since 5.3 @@ -344,7 +344,7 @@ public function getListID() * If $supportsOneClick is set to true the 'List-Unsubscribe-Post' header * with the value 'List-Unsubscribe=One-Click' is added. * - * @param string $uri + * @param ?string $uri * @param bool $supportsOneClick * @since 5.3 */ @@ -645,10 +645,8 @@ public function getBodyString() return \quoted_printable_encode( \str_replace("\n", "\r\n", StringUtil::unifyNewlines($this->body->getContent())) ); - break; case 'base64': return \chunk_split(\base64_encode($this->body->getContent())); - break; case '': return $this->body->getContent(); } diff --git a/wcfsetup/install/files/lib/system/email/SimpleEmail.class.php b/wcfsetup/install/files/lib/system/email/SimpleEmail.class.php index 06567891c29..27a56668997 100644 --- a/wcfsetup/install/files/lib/system/email/SimpleEmail.class.php +++ b/wcfsetup/install/files/lib/system/email/SimpleEmail.class.php @@ -25,13 +25,13 @@ class SimpleEmail /** * the text/plain version of the message body - * @var PlainTextMimePart + * @var ?PlainTextMimePart */ private $textPlain; /** * the text/html version of the message body - * @var HtmlTextMimePart + * @var ?HtmlTextMimePart */ private $textHtml; diff --git a/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php b/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php index 2decae54f4f..c81d68a482c 100644 --- a/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php +++ b/wcfsetup/install/files/lib/system/email/mime/RecipientAwareTextMimePart.class.php @@ -37,7 +37,7 @@ class RecipientAwareTextMimePart extends TextMimePart implements IRecipientAware /** * the recipient of the email containing this mime part - * @var Mailbox + * @var ?Mailbox */ protected $mailbox; diff --git a/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php b/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php index f19ceeaed58..53b188890d4 100644 --- a/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php +++ b/wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php @@ -407,7 +407,6 @@ protected function auth() // Authentication was successful. return; - break; case 'plain': // RFC 4616 try { diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRow.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRow.class.php index e06a79b14ee..535df73d6d5 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRow.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRow.class.php @@ -33,6 +33,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res } $view = new $parameters->gridView(...$parameters->gridViewParameters); + // @phpstan-ignore function.alreadyNarrowedType, instanceof.alwaysTrue \assert($view instanceof AbstractGridView); if (!$view->isAccessible()) { diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php index a4b81859095..302c1e60049 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php @@ -33,6 +33,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res } $view = new $parameters->gridView(...$parameters->gridViewParameters); + // @phpstan-ignore function.alreadyNarrowedType, instanceof.alwaysTrue \assert($view instanceof AbstractGridView); if (!$view->isAccessible()) { diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetBulkContextMenuOptions.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetBulkContextMenuOptions.class.php index d9a3f8f5670..0a58b9fa969 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetBulkContextMenuOptions.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetBulkContextMenuOptions.class.php @@ -34,6 +34,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res } $provider = new $parameters->provider(); + // @phpstan-ignore function.alreadyNarrowedType, instanceof.alwaysTrue \assert($provider instanceof IBulkInteractionProvider); $list = new ($provider->getObjectListClassName())(); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetContextMenuOptions.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetContextMenuOptions.class.php index 0c9aaefce21..f8d2f259369 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetContextMenuOptions.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/interactions/GetContextMenuOptions.class.php @@ -34,6 +34,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res } $provider = new $parameters->provider(); + // @phpstan-ignore function.alreadyNarrowedType, instanceof.alwaysTrue \assert($provider instanceof IInteractionProvider); $object = new ($provider->getObjectClassName())($parameters->objectID); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/moderationQueues/ChangeJustifiedStatus.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/moderationQueues/ChangeJustifiedStatus.class.php index a60787897f9..b10f93f5f79 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/moderationQueues/ChangeJustifiedStatus.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/moderationQueues/ChangeJustifiedStatus.class.php @@ -33,6 +33,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $parameters = Helper::mapApiParameters($request, ChangeJustifiedStatusParameters::class); $additionalData = $queue->additionalData; + // @phpstan-ignore function.alreadyNarrowedType if (!\is_array($additionalData)) { $additionalData = []; } diff --git a/wcfsetup/install/files/lib/system/event/EventHandler.class.php b/wcfsetup/install/files/lib/system/event/EventHandler.class.php index dc1bbe8e9e0..4c5440fce29 100644 --- a/wcfsetup/install/files/lib/system/event/EventHandler.class.php +++ b/wcfsetup/install/files/lib/system/event/EventHandler.class.php @@ -160,6 +160,7 @@ private function executeListeners( } elseif ($actionObj instanceof IParameterizedEventListener) { $actionObj->execute($eventObj, $className, $eventName, $parameters); + // @phpstan-ignore function.alreadyNarrowedType if (!\is_array($parameters)) { throw new \LogicException("'{$actionClassName}' breaks the '\$parameters' array."); } diff --git a/wcfsetup/install/files/lib/system/event/listener/UsernameValidatingCheckCharactersListener.class.php b/wcfsetup/install/files/lib/system/event/listener/UsernameValidatingCheckCharactersListener.class.php index 41ae74f0c3a..7e0628cbaaf 100644 --- a/wcfsetup/install/files/lib/system/event/listener/UsernameValidatingCheckCharactersListener.class.php +++ b/wcfsetup/install/files/lib/system/event/listener/UsernameValidatingCheckCharactersListener.class.php @@ -37,6 +37,7 @@ private function isValid(string $name): bool $checks = Spoofchecker::INVISIBLE; // HIDDEN_OVERLAY (256) is available since ICU 62 + // @phpstan-ignore if.alwaysTrue if (\version_compare(\INTL_ICU_VERSION, '62.0', '>=')) { if (\defined(Spoofchecker::class . '::HIDDEN_OVERLAY')) { // The constant will exist with PHP 8.3. @@ -48,6 +49,7 @@ private function isValid(string $name): bool } // ->setRestrictionLevel() requires ICU 58. + // @phpstan-ignore function.alreadyNarrowedType if (\method_exists($spoofchecker, 'setRestrictionLevel')) { // This method needs to be called first. ->setRestrictionLevel() will // implicitly enable the check for the restriction level for which no diff --git a/wcfsetup/install/files/lib/system/file/processor/AttachmentFileProcessor.class.php b/wcfsetup/install/files/lib/system/file/processor/AttachmentFileProcessor.class.php index 882e56f4609..9ab151e2011 100644 --- a/wcfsetup/install/files/lib/system/file/processor/AttachmentFileProcessor.class.php +++ b/wcfsetup/install/files/lib/system/file/processor/AttachmentFileProcessor.class.php @@ -203,7 +203,7 @@ public function adoptThumbnail(FileThumbnail $thumbnail): void $columnName = match ($thumbnail->identifier) { '' => 'thumbnailID', 'tiny' => 'tinyThumbnailID', - 'default' => throw new UnexpectedThumbnailIdentifier($thumbnail->identifier), + default => throw new UnexpectedThumbnailIdentifier($thumbnail->identifier), }; $attachmentEditor = new AttachmentEditor($attachment); diff --git a/wcfsetup/install/files/lib/system/file/processor/FileProcessor.class.php b/wcfsetup/install/files/lib/system/file/processor/FileProcessor.class.php index 2666b118e45..99be931a194 100644 --- a/wcfsetup/install/files/lib/system/file/processor/FileProcessor.class.php +++ b/wcfsetup/install/files/lib/system/file/processor/FileProcessor.class.php @@ -238,7 +238,6 @@ public function generateThumbnails(File $file): void $existingThumbnails = []; foreach ($thumbnailList as $thumbnail) { - \assert($thumbnail instanceof FileThumbnail); $existingThumbnails[$thumbnail->identifier] = $thumbnail; } @@ -293,8 +292,6 @@ public function generateThumbnails(File $file): void } } - \assert($imageAdapter instanceof ImageAdapter); - try { $image = $imageAdapter->createThumbnail($format->width, $format->height, $format->retainDimensions); } catch (\Throwable $e) { diff --git a/wcfsetup/install/files/lib/system/file/processor/UserAvatarFileProcessor.class.php b/wcfsetup/install/files/lib/system/file/processor/UserAvatarFileProcessor.class.php index 1a1a9c88ca7..82815a1ce36 100644 --- a/wcfsetup/install/files/lib/system/file/processor/UserAvatarFileProcessor.class.php +++ b/wcfsetup/install/files/lib/system/file/processor/UserAvatarFileProcessor.class.php @@ -193,7 +193,7 @@ public function countExistingFiles(array $context): ?int } #[\Override] - public function getMaximumSize(array $context): ?int + public function getMaximumSize(array $context): int { /** * Reject the file if it is larger than 750 kB after resizing. A worst-case @@ -208,7 +208,7 @@ public function getMaximumSize(array $context): ?int } #[\Override] - public function getImageCropperConfiguration(): ?ImageCropperConfiguration + public function getImageCropperConfiguration(): ImageCropperConfiguration { return ImageCropperConfiguration::forExact( new ImageCropSize(UserAvatarFileProcessor::AVATAR_SIZE, UserAvatarFileProcessor::AVATAR_SIZE), diff --git a/wcfsetup/install/files/lib/system/file/processor/UserCoverPhotoFileProcessor.class.php b/wcfsetup/install/files/lib/system/file/processor/UserCoverPhotoFileProcessor.class.php index cfa3fd8c893..fa3831a5dcb 100644 --- a/wcfsetup/install/files/lib/system/file/processor/UserCoverPhotoFileProcessor.class.php +++ b/wcfsetup/install/files/lib/system/file/processor/UserCoverPhotoFileProcessor.class.php @@ -208,7 +208,7 @@ public function countExistingFiles(array $context): ?int } #[\Override] - public function getImageCropperConfiguration(): ?ImageCropperConfiguration + public function getImageCropperConfiguration(): ImageCropperConfiguration { return ImageCropperConfiguration::forMinMax( new ImageCropSize(UserCoverPhoto::MIN_WIDTH, UserCoverPhoto::MIN_HEIGHT), diff --git a/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php b/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php index 74ab0d763e8..d9a6da3e61b 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadField.class.php @@ -74,7 +74,7 @@ public function supportMultipleFiles() /** * Returns the max number of files. * - * @return int + * @return ?int */ public function getMaxFiles() { diff --git a/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php b/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php index fd5f3470bc6..b044bae93c6 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php @@ -73,7 +73,7 @@ class UploadFile /** * The return value of `getimagesize`. - * @var array + * @var array|false */ private $imageData; diff --git a/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php index a43922fa403..72ca992d230 100644 --- a/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php @@ -273,6 +273,8 @@ public function removeDependency($dependencyId); * * Note: A `IFormParentNode` object may only return `true` if all of its child * nodes are valid. A `IFormField` object is valid if its value is valid. + * + * @return void */ public function validate(); } diff --git a/wcfsetup/install/files/lib/system/form/builder/Psr15DialogForm.class.php b/wcfsetup/install/files/lib/system/form/builder/Psr15DialogForm.class.php index f9e24e02406..3d35c3c8e9e 100644 --- a/wcfsetup/install/files/lib/system/form/builder/Psr15DialogForm.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/Psr15DialogForm.class.php @@ -76,7 +76,7 @@ public function addButton(IFormButton $button) */ public function validate() { - return $this->traitValidate(); + $this->traitValidate(); } /** diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php index 09f227be8e8..69b5c897097 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php @@ -424,7 +424,7 @@ public function populate() ); } - /** @var IFormField $field */ + /** @var ?IFormField $field */ $field = $this->getDocument()->getNodeById($dependency->getFieldId()); if ($field === null) { throw new \UnexpectedValueException( diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php index f900a7ce336..c6839579e16 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php @@ -342,6 +342,8 @@ public function valid(): bool * * Note: A `IFormParentNode` object may only return `true` if all of its child * nodes are valid. A `IFormField` object is valid if its value is valid. + * + * @return void */ public function validate() { @@ -370,8 +372,6 @@ public function validate() /** * Checks if the given node can be added as a child to this node. - * - * @throws \InvalidArgumentException if given node cannot be added as a child */ public function validateChild(IFormChildNode $child): void { diff --git a/wcfsetup/install/files/lib/system/form/builder/container/SuffixFormFieldContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/SuffixFormFieldContainer.class.php index 08662b86d96..8ba483d18cc 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/SuffixFormFieldContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/SuffixFormFieldContainer.class.php @@ -28,7 +28,7 @@ class SuffixFormFieldContainer extends FormContainer /** * selection form field containing the suffix options - * @var ISelectionFormField + * @var ?ISelectionFormField */ protected $suffixField; @@ -118,7 +118,7 @@ public function getSelectedSuffixOption() /** * Returns the selection form field containing the suffix options. * - * @return ISelectionFormField + * @return ?ISelectionFormField */ public function getSuffixField() { diff --git a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php index 2b39ee7717a..c40b712363d 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php @@ -130,7 +130,7 @@ class WysiwygFormContainer extends FormContainer /** * actual wysiwyg form field - * @var WysiwygFormField + * @var ?WysiwygFormField */ protected $wysiwygField; diff --git a/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php index 21a48ab9713..9e91539452f 100644 --- a/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php @@ -63,7 +63,6 @@ public function __construct(string $id, ?callable $formDataProcessor = null, ?ca ); } - /** @var \ReflectionType $parameterType */ $parameterType = $parameters[0]->getType(); if ( !( @@ -105,7 +104,6 @@ public function __construct(string $id, ?callable $formDataProcessor = null, ?ca ); } - /** @var \ReflectionType $parameterType */ $parameterType = $parameters[0]->getType(); if ( !( diff --git a/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php index 9327a7e55e0..42a17d22e5b 100644 --- a/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php @@ -44,7 +44,7 @@ protected function getData(IFormNode $node, array &$data) foreach ($node as $childNode) { $this->getData($childNode, $data); } - } elseif ($node instanceof IFormField && $node->isAvailable() && $node->hasSaveValue()) { + } elseif ($node instanceof IFormField && $node->hasSaveValue()) { $data[$node->getObjectProperty()] = $node->getSaveValue(); } } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/CaptchaFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/CaptchaFormField.class.php index 7d3de864877..36731991747 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/CaptchaFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/CaptchaFormField.class.php @@ -41,7 +41,7 @@ final class CaptchaFormField extends AbstractFormField implements IObjectTypeFor protected $validationException; /** - * @var IFormFieldValidationError + * @var ?IFormFieldValidationError */ protected $validationError; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php index 2928a5e4d98..5169b48bf56 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/EmailFormField.class.php @@ -113,7 +113,7 @@ public function validate() /** * Validates the given email address in the given language. * - * @param string $email validated email address + * @param ?string $email validated email address * @param null|Language $language language of validated email address or `null` for monolingual email address */ protected function validateEmail($email, ?Language $language = null) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php index 8d71a7d2033..6e081c898b4 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/SingleSelectionFormField.class.php @@ -43,7 +43,6 @@ public function getSaveValue() if ( empty($this->getValue()) && isset($this->getOptions()[$this->getValue()]) - && $this instanceof INullableFormField && $this->isNullable() ) { return; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TAttributeFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TAttributeFormField.class.php index eecd9408565..391d5e3c99a 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TAttributeFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TAttributeFormField.class.php @@ -20,7 +20,7 @@ trait TAttributeFormField protected $fieldAttributes = []; /** - * @var string[] + * @var array */ protected static $interfaceToFieldAttributeMap = [ IAutoFocusFormField::class => 'autofocus', diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php index e701454f309..e18bffde453 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php @@ -454,7 +454,7 @@ public function updatedObject(array $data, IStorableObject $object, $loadValues $variableName = $this->getObjectProperty(); try { $value = $this->readUploadLocations($data[$variableName] ?? null); - } catch (\InvalidArgumentException | \TypeError $e) { + } catch (\InvalidArgumentException $e) { throw new \InvalidArgumentException( \sprintf( "The property %s must contain an array of strings with the valid file locations for field '%s'.", diff --git a/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php b/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php index 79576b6522e..0bf20781445 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php @@ -25,7 +25,7 @@ abstract class AbstractFormFieldDependency implements IFormFieldDependency /** * field the availability of the node dependents on - * @var IFormField + * @var ?IFormField */ protected $field; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php b/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php index 6e4d3b0db22..ce3fb87618f 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/dependency/IFormFieldDependency.class.php @@ -67,7 +67,7 @@ public function getDependentNode(); * Returns the field the availability of the element dependents on or `null` if the field has * not been set yet. * - * @return IFormField field controlling element availability + * @return ?IFormField field controlling element availability */ public function getField(); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php index 5e8df5b6879..39ea98ee8ff 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php @@ -86,10 +86,6 @@ public function updatedObject(array $data, IStorableObject $object, $loadValues ); } - if ($this->getObjectType() === null) { - throw new \UnexpectedValueException("Missing taggable object type for field '{$this->getId()}'."); - } - $languageIDs = []; /** @noinspection PhpUndefinedFieldInspection */ diff --git a/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidator.class.php b/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidator.class.php index 850104a2e25..24298597b82 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidator.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidator.class.php @@ -43,7 +43,6 @@ public function __construct($id, callable $validator) . " parameters are expected for validator '{$id}'." ); } - /** @var \ReflectionType $parameterType */ $parameterType = $parameters[0]->getType(); if ( !( diff --git a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php index 1f98ffff1b8..09da3076861 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php @@ -156,16 +156,15 @@ public function getLastEditTime() * * @param null|string $index quote data index * - * @return string[]|string + * @return string * * @throws \BadMethodCallException if quotes are not supported for this field - * @throws \InvalidArgumentException if unknown quote data is requested * * @deprecated 6.2 */ public function getQuoteData($index = null) { - if (!$this->supportQuotes()) { + if (!$this->supportQuotes) { throw new \BadMethodCallException("Quotes are not supported for field '{$this->getId()}'."); } @@ -230,8 +229,6 @@ function (IFormDocument $document, array $parameters) { * * @return static * - * @throws \InvalidArgumentException if any of the given arguments is invalid - * * @deprecated 6.2 */ public function quoteData($objectType, $actionClass, array $selectors = []) diff --git a/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php index 724b70d9072..eb422cd5f81 100644 --- a/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php @@ -75,10 +75,12 @@ public function readValue() public function smilies(array $smilies) { foreach ($smilies as $smiley) { + // @phpstan-ignore function.alreadyNarrowedType if (!\is_object($smiley)) { throw new \InvalidArgumentException( "Given value array contains invalid value of type " . \gettype($smiley) . " for field '{$this->getId()}'." ); + // @phpstan-ignore instanceof.alwaysTrue } elseif (!($smiley instanceof Smiley)) { throw new \InvalidArgumentException( "Given value array contains invalid object of class " . \get_class($smiley) . " for field '{$this->getId()}'." diff --git a/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionGridView.class.php index 23bc71d3941..188b8b9de7a 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionGridView.class.php @@ -3,9 +3,7 @@ namespace wcf\system\gridView\admin; use wcf\data\acp\session\access\log\ACPSessionAccessLogList; -use wcf\data\DatabaseObjectList; use wcf\event\gridView\admin\ACPSessionGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\gridView\AbstractGridView; use wcf\system\gridView\filter\IpAddressFilter; use wcf\system\gridView\filter\SelectFilter; @@ -86,7 +84,7 @@ public function getParameters(): array } #[\Override] - protected function createObjectList(): DatabaseObjectList + protected function createObjectList(): ACPSessionAccessLogList { $list = new ACPSessionAccessLogList(); $list->getConditionBuilder()->add('sessionLogID = ?', [$this->sessionLogID]); @@ -95,7 +93,7 @@ protected function createObjectList(): DatabaseObjectList } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): ACPSessionGridViewInitialized { return new ACPSessionGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionLogGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionLogGridView.class.php index 4238d585ef3..cade75a544d 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionLogGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/ACPSessionLogGridView.class.php @@ -5,9 +5,7 @@ use wcf\acp\form\UserEditForm; use wcf\acp\page\ACPSessionLogPage; use wcf\data\acp\session\log\ACPSessionLogList; -use wcf\data\DatabaseObjectList; use wcf\event\gridView\admin\ACPSessionLogGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\gridView\AbstractGridView; use wcf\system\gridView\filter\IpAddressFilter; use wcf\system\gridView\filter\TextFilter; @@ -85,7 +83,7 @@ public function isAccessible(): bool } #[\Override] - protected function createObjectList(): DatabaseObjectList + protected function createObjectList(): ACPSessionLogList { $list = new ACPSessionLogList(); $list->sqlSelects .= " @@ -102,7 +100,7 @@ protected function createObjectList(): DatabaseObjectList } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): ACPSessionLogGridViewInitialized { return new ACPSessionLogGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/gridView/admin/CronjobLogGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/CronjobLogGridView.class.php index acc96ae4734..4fde553a57b 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/CronjobLogGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/CronjobLogGridView.class.php @@ -7,9 +7,7 @@ use wcf\data\cronjob\log\CronjobLog; use wcf\data\cronjob\log\CronjobLogList; use wcf\data\DatabaseObject; -use wcf\data\DatabaseObjectList; use wcf\event\gridView\admin\CronjobLogGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\gridView\AbstractGridView; use wcf\system\gridView\filter\SelectFilter; use wcf\system\gridView\filter\TimeFilter; @@ -99,13 +97,13 @@ public function isAccessible(): bool } #[\Override] - protected function createObjectList(): DatabaseObjectList + protected function createObjectList(): CronjobLogList { return new CronjobLogList(); } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): CronjobLogGridViewInitialized { return new CronjobLogGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/gridView/admin/ExceptionLogGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/ExceptionLogGridView.class.php index ecd305d2730..9fda4b9f0b5 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/ExceptionLogGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/ExceptionLogGridView.class.php @@ -5,7 +5,6 @@ use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectList; use wcf\event\gridView\admin\ExceptionLogGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\gridView\AbstractGridView; use wcf\system\Regex; use wcf\system\gridView\filter\SelectFilter; @@ -200,7 +199,7 @@ private function getDefaultLogFile(): ?string } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): ExceptionLogGridViewInitialized { return new ExceptionLogGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/gridView/admin/ModificationLogGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/ModificationLogGridView.class.php index aa67607f9ba..5e4e735ca30 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/ModificationLogGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/ModificationLogGridView.class.php @@ -2,7 +2,6 @@ namespace wcf\system\gridView\admin; -use LogicException; use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectDecorator; use wcf\data\DatabaseObjectList; @@ -12,7 +11,6 @@ use wcf\data\object\type\ObjectTypeCache; use wcf\data\package\Package; use wcf\event\gridView\admin\ModificationLogGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\form\builder\field\AbstractFormField; use wcf\system\form\builder\field\SelectFormField; use wcf\system\gridView\AbstractGridView; @@ -163,7 +161,7 @@ public function isAccessible(): bool } #[\Override] - protected function createObjectList(): DatabaseObjectList + protected function createObjectList(): ModificationLogList { return new ModificationLogList(); } @@ -210,7 +208,7 @@ public function getRows(): array } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): ModificationLogGridViewInitialized { return new ModificationLogGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/gridView/admin/UserOptionGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/UserOptionGridView.class.php index a88d4e8b9f1..0333b11c31d 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/UserOptionGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/UserOptionGridView.class.php @@ -4,11 +4,9 @@ use wcf\acp\form\UserOptionEditForm; use wcf\data\DatabaseObject; -use wcf\data\DatabaseObjectList; use wcf\data\user\option\UserOption; use wcf\data\user\option\UserOptionList; use wcf\event\gridView\admin\UserOptionGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\gridView\AbstractGridView; use wcf\system\gridView\GridViewColumn; use wcf\system\gridView\GridViewRowLink; @@ -99,7 +97,7 @@ public function isAccessible(): bool } #[\Override] - protected function createObjectList(): DatabaseObjectList + protected function createObjectList(): UserOptionList { $list = new UserOptionList(); $list->getConditionBuilder()->add( @@ -115,7 +113,7 @@ protected function createObjectList(): DatabaseObjectList } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): UserOptionGridViewInitialized { return new UserOptionGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/gridView/admin/UserRankGridView.class.php b/wcfsetup/install/files/lib/system/gridView/admin/UserRankGridView.class.php index 6c1c982f44d..ac7e68b161e 100644 --- a/wcfsetup/install/files/lib/system/gridView/admin/UserRankGridView.class.php +++ b/wcfsetup/install/files/lib/system/gridView/admin/UserRankGridView.class.php @@ -4,12 +4,10 @@ use wcf\acp\form\UserRankEditForm; use wcf\data\DatabaseObject; -use wcf\data\DatabaseObjectList; use wcf\data\user\group\UserGroup; use wcf\data\user\rank\I18nUserRankList; use wcf\data\user\rank\UserRank; use wcf\event\gridView\admin\UserRankGridViewInitialized; -use wcf\event\IPsr14Event; use wcf\system\gridView\AbstractGridView; use wcf\system\gridView\filter\I18nTextFilter; use wcf\system\gridView\filter\SelectFilter; @@ -127,13 +125,13 @@ public function isAccessible(): bool } #[\Override] - protected function createObjectList(): DatabaseObjectList + protected function createObjectList(): I18nUserRankList { return new I18nUserRankList(); } #[\Override] - protected function getInitializedEvent(): ?IPsr14Event + protected function getInitializedEvent(): UserRankGridViewInitialized { return new UserRankGridViewInitialized($this); } diff --git a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php index 18b4f06e7c2..ccd863ee376 100644 --- a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php @@ -311,6 +311,7 @@ protected function convertToHtml($html) // ignore one newline because a new paragraph with bbcodes is created // using two subsequent newlines $newlines--; + // @phpstan-ignore identical.alwaysFalse if ($newlines === 0) { continue; } diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php index fc26fb1bbc8..cbde3910f34 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php @@ -260,7 +260,6 @@ protected function handleSmiley(\DOMElement $element) { $code = $element->getAttribute('alt'); - /** @var Smiley $smiley */ $smiley = SmileyCache::getInstance()->getSmileyByCode($code); if ($smiley === null || $this->smiliesFound === 50) { $element->parentNode->insertBefore($element->ownerDocument->createTextNode($code), $element); diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php index 1671f43c891..c6007a68d14 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php @@ -26,7 +26,7 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor { /** * list of allowed CSS class names per tag name - * @var array + * @var array */ public static $allowedClassNames = [ 'figure' => ['image', 'image-style-side', 'image-style-side-left'], @@ -352,7 +352,7 @@ protected function fixDom() } $appendToPreviousParagraph = static function ($node) { - /** @var \DOMElement $paragraph */ + /** @var ?\DOMElement $paragraph */ $paragraph = $node->previousSibling; if (!$paragraph || $paragraph->nodeName !== 'p') { diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php index 58fecf1b330..85eb72d3499 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php @@ -147,6 +147,7 @@ public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProc } $newElement = $converter->convert($fragment, $attributes); + // @phpstan-ignore instanceof.alwaysTrue if (!($newElement instanceof \DOMElement)) { throw new \UnexpectedValueException("Expected a valid DOMElement as return value."); } diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php index 62c205a811b..ec1efa3283b 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php @@ -436,6 +436,7 @@ protected function convertInlineElement($name, $start, $end, $attributes) DOMUtil::removeNode($end); } else { $commonAncestor = DOMUtil::getCommonAncestor($start, $end); + \assert($commonAncestor !== null); // This method doesn't behave nicely if the start and/or end node are // contained in other inline elements. HTMLPurifier guarantees well- @@ -551,10 +552,6 @@ protected function wrapContent($name, $attributes, $startNode, $endNode) while ($sibling = $element->previousSibling) { DOMUtil::prepend($sibling, $element); - - if ($sibling === $startNode) { - break; - } } } diff --git a/wcfsetup/install/files/lib/system/html/metacode/converter/TableMetacodeConverter.class.php b/wcfsetup/install/files/lib/system/html/metacode/converter/TableMetacodeConverter.class.php index b0c7146d5f5..1de0c2cb714 100644 --- a/wcfsetup/install/files/lib/system/html/metacode/converter/TableMetacodeConverter.class.php +++ b/wcfsetup/install/files/lib/system/html/metacode/converter/TableMetacodeConverter.class.php @@ -83,13 +83,7 @@ protected function handleRow(\DOMElement $row) } // move tds - /** @var \DOMElement $col */ foreach ($cols as $col) { - if (false && $col->parentNode !== $row) { - $parent = DOMUtil::getParentBefore($col, $row); - $row->insertBefore($col, $parent); - } - DOMUtil::replaceElement($col, $row->ownerDocument->createElement('td')); } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php index eb9089eefc8..f417d57e3d2 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php @@ -42,7 +42,6 @@ public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProc if (\preg_match('~\bsmiley\b~', $class)) { $code = $element->getAttribute('alt'); - /** @var Smiley $smiley */ $smiley = SmileyCache::getInstance()->getSmileyByCode($code); if ($smiley === null || $this->outputType === 'text/plain') { // output as raw code instead diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php index 5a9db4c6872..9d4a353ab55 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php @@ -223,10 +223,7 @@ private function reduceBrInEmptyParagraph(\DOMXPath $xpath): void $length = \count($foundBrs); if ($length > 1) { for ($i = 1; $i < $length; $i++) { - $br = $foundBrs[$i]; - \assert($br instanceof \DOMElement); - - $br->remove(); + $foundBrs[$i]->remove(); } } } diff --git a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php index 01b05a50092..febfe3ecf05 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php @@ -18,7 +18,7 @@ class ImagickImageAdapter implements IImageAdapter, ISingleFrameImageAdapter, IW { /** * active color - * @var \ImagickPixel + * @var ?\ImagickPixel */ protected $color; diff --git a/wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php b/wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php index 2d77d8e0e3d..06c8d337dc4 100644 --- a/wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php +++ b/wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php @@ -117,32 +117,30 @@ protected function fixEmbeddedAttachments($message, $oldID, $newID) $message = \str_ireplace('[attach=' . $oldID . ']', '[attach=' . $newID . ']', $message); return \str_ireplace('[attach=' . $oldID . ',', '[attach=' . $newID . ',', $message); - } else { - return \preg_replace_callback( - '~~', - static function (array $matches) use ($oldID, $newID): string { - $encodedAttributes = $matches['attributes']; - - $base64Decoded = \base64_decode($matches['attributes']); - if ($base64Decoded) { - try { - $attributes = JSON::decode($base64Decoded); - if ($attributes[0] == $oldID) { - $attributes[0] = $newID; - } - - $encodedAttributes = \base64_encode(JSON::encode($attributes)); - } catch (\Exception $e) { - $encodedAttributes = $matches['attributes']; + } + + return \preg_replace_callback( + '~~', + static function (array $matches) use ($oldID, $newID): string { + $encodedAttributes = $matches['attributes']; + + $base64Decoded = \base64_decode($matches['attributes']); + if ($base64Decoded) { + try { + $attributes = JSON::decode($base64Decoded); + if ($attributes[0] == $oldID) { + $attributes[0] = $newID; } - } - return ''; - }, - $message - ); - } + $encodedAttributes = \base64_encode(JSON::encode($attributes)); + } catch (\Exception $e) { + $encodedAttributes = $matches['attributes']; + } + } - return false; + return ''; + }, + $message + ); } } diff --git a/wcfsetup/install/files/lib/system/importer/UserGroupImporter.class.php b/wcfsetup/install/files/lib/system/importer/UserGroupImporter.class.php index d2dd307b8bd..91a025dc0b7 100644 --- a/wcfsetup/install/files/lib/system/importer/UserGroupImporter.class.php +++ b/wcfsetup/install/files/lib/system/importer/UserGroupImporter.class.php @@ -66,7 +66,7 @@ public function import($oldID, array $data, array $additionalData = []) foreach ($propertyValues as $languageID => $languageItemValue) { $items[] = [ 'languageID' => $languageID, - 'languageItem' => 'wcf.acp.group.' . ($property === 'description' ? 'groupDescription' : 'group') . $newGroupID, + 'languageItem' => 'wcf.acp.group.' . ($property === 'groupDescription' ? 'groupDescription' : 'group') . $newGroupID, 'languageItemValue' => $languageItemValue, ]; } diff --git a/wcfsetup/install/files/lib/system/interaction/StandaloneInteractionContextMenuView.class.php b/wcfsetup/install/files/lib/system/interaction/StandaloneInteractionContextMenuView.class.php index 90fcede4336..4467e805bb5 100644 --- a/wcfsetup/install/files/lib/system/interaction/StandaloneInteractionContextMenuView.class.php +++ b/wcfsetup/install/files/lib/system/interaction/StandaloneInteractionContextMenuView.class.php @@ -29,8 +29,6 @@ public function render(): string 'redirectUrl' => $this->redirectUrl, ], ); - - return ''; } public function getContainerID(): string diff --git a/wcfsetup/install/files/lib/system/io/File.class.php b/wcfsetup/install/files/lib/system/io/File.class.php index 0606ce0a0cf..f46401c2f11 100644 --- a/wcfsetup/install/files/lib/system/io/File.class.php +++ b/wcfsetup/install/files/lib/system/io/File.class.php @@ -26,7 +26,7 @@ * @method bool eof() * @method int filesize() * @method bool flush() - * @method string gets($length = null) + * @method string|false gets($length = null) * @method bool lock(int $operation, int &$would_block = null) * @method resource open($mode, $use_include_path = false, $context = null) * @method int puts($string, $length = null) alias of `write` diff --git a/wcfsetup/install/files/lib/system/io/Zip.class.php b/wcfsetup/install/files/lib/system/io/Zip.class.php index 71756298159..452bbd5b7df 100644 --- a/wcfsetup/install/files/lib/system/io/Zip.class.php +++ b/wcfsetup/install/files/lib/system/io/Zip.class.php @@ -267,7 +267,7 @@ protected function readCentralDirectory() * Checks whether the next record is a file. * This does not change the position of the file-pointer. * - * @param int $offset where to start reading + * @param int|false|null $offset where to start reading * @return bool * @throws SystemException */ @@ -293,7 +293,7 @@ public function isFile($offset = null) /** * Reads a file and returns it. * - * @param int $offset where to start reading + * @param int|false|null $offset where to start reading * @return array * @throws SystemException */ @@ -302,9 +302,6 @@ public function readFile($offset = null) if ($offset === null) { $offset = $this->tell(); } - if (!\is_int($offset)) { - $offset = $this->getIndexByFilename($offset); - } if ($offset === false) { throw new SystemException('Invalid offset passed to readFile'); } diff --git a/wcfsetup/install/files/lib/system/label/LabelHandler.class.php b/wcfsetup/install/files/lib/system/label/LabelHandler.class.php index 9d143e142e2..038b610449d 100644 --- a/wcfsetup/install/files/lib/system/label/LabelHandler.class.php +++ b/wcfsetup/install/files/lib/system/label/LabelHandler.class.php @@ -182,7 +182,7 @@ public function setLabels(array $labelIDs, $objectTypeID, $objectID, $validatePe $accessibleLabelIDs = $this->getAccessibleLabelIDs(); // delete previous labels - if (!$validatePermissions || ($validatePermissions && !empty($accessibleLabelIDs))) { + if (!$validatePermissions || $accessibleLabelIDs !== []) { $conditions = new PreparedStatementConditionBuilder(); if ($validatePermissions) { $conditions->add("labelID IN (?)", [$accessibleLabelIDs]); diff --git a/wcfsetup/install/files/lib/system/label/object/AbstractLabelObjectHandler.class.php b/wcfsetup/install/files/lib/system/label/object/AbstractLabelObjectHandler.class.php index 41cfbbffdc6..626d065d440 100644 --- a/wcfsetup/install/files/lib/system/label/object/AbstractLabelObjectHandler.class.php +++ b/wcfsetup/install/files/lib/system/label/object/AbstractLabelObjectHandler.class.php @@ -92,6 +92,7 @@ public function validateLabelIDs(array $labelIDs, $optionName = '', $legacyRetur $satisfiedGroups = []; foreach ($labelIDs as $groupID => $labelID) { // only one label per group is allowed + // @phpstan-ignore function.impossibleType if (\is_array($labelID)) { $validationErrors[$groupID] = 'invalid'; continue; @@ -159,6 +160,7 @@ public function setLabels(array $labelIDs, $objectID, $validatePermissions = tru */ public function removeLabels($objectID, $validatePermissions = true) { + // @phpstan-ignore function.impossibleType $objectIDs = (\is_array($objectID)) ? $objectID : [$objectID]; LabelHandler::getInstance()->removeLabels($this->objectTypeID, $objectIDs); } diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index 963fed16718..46e461b8908 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -191,18 +191,9 @@ public function getValues(string $elementID): array * the given value is set for every available language. * * @param $forceAsPlainValue if `true`, the value is added as a plain value in any case - * @throws SystemException */ public function setValue(string $elementID, string $plainValue, bool $forceAsPlainValue = false): void { - if (!\is_string($plainValue)) { - throw new SystemException( - 'Invalid argument for parameter $plainValue', - 0, - 'Expected string. ' . \ucfirst(\gettype($plainValue)) . ' given.' - ); - } - if (!$this->isPlainValue($elementID) && !$forceAsPlainValue) { $i18nValues = []; foreach ($this->availableLanguages as $language) { diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index 0a86b4dfee8..3ab54d2806b 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -96,7 +96,7 @@ public function getUserLanguage($languageID = 0) public function getLanguageByCode($languageCode) { // called within WCFSetup - if ($this->cache === false || empty($this->cache['codes'])) { + if (empty($this->cache['codes'])) { $sql = "SELECT languageID FROM wcf1_language WHERE languageCode = ?"; diff --git a/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php b/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php index 67d985ce53e..6c977cc9369 100644 --- a/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php +++ b/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php @@ -49,8 +49,7 @@ public function loadObjects(array $objectIDs) $articleIDs = []; foreach ($articles as $article) { if ( - $article !== null - && $article->getArticleContent()->languageID + $article->getArticleContent()->languageID && $article->getArticleContent()->languageID != $contentLanguageID ) { $articleIDs[] = $article->articleID; diff --git a/wcfsetup/install/files/lib/system/message/embedded/object/MediaMessageEmbeddedObjectHandler.class.php b/wcfsetup/install/files/lib/system/message/embedded/object/MediaMessageEmbeddedObjectHandler.class.php index d0150889269..f9f72ba1b4b 100644 --- a/wcfsetup/install/files/lib/system/message/embedded/object/MediaMessageEmbeddedObjectHandler.class.php +++ b/wcfsetup/install/files/lib/system/message/embedded/object/MediaMessageEmbeddedObjectHandler.class.php @@ -92,7 +92,7 @@ public function validateValues($objectType, $objectID, array $values) */ public function replaceSimple($objectType, $objectID, $value, array $attributes) { - /** @var Media $media */ + /** @var ?Media $media */ $media = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.media', $value); if ($media === null) { return null; diff --git a/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php b/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php index 039c61c19fe..ebb3cc56ca8 100644 --- a/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php +++ b/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php @@ -292,7 +292,7 @@ public function loadObjects($messageObjectType, array $messageIDs, $contentLangu /** * Returns the content language id or null. * - * @return int + * @return ?int */ public function getContentLanguageID() { diff --git a/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php b/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php index 2fa2c0b3c14..c6a7dea027b 100644 --- a/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php +++ b/wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php @@ -56,7 +56,6 @@ protected function init() * @param bool $returnFalseIfExists * * @return mixed - * @throws SystemException * @deprecated 6.2 */ public function addQuote( @@ -264,7 +263,6 @@ public function countQuotes() * @param string[] $objectTypes * * @return mixed[][] - * @throws SystemException * @deprecated 6.2 */ public function getFullQuoteObjectIDs(array $objectTypes) @@ -278,8 +276,6 @@ public function getFullQuoteObjectIDs(array $objectTypes) * @param string $objectType * @param int[] $objectIDs * - * @throws SystemException - * * @deprecated 6.2 */ public function initObjects($objectType, array $objectIDs) diff --git a/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php b/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php index c2fd9c7298e..62bf5264b8b 100644 --- a/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php +++ b/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php @@ -43,15 +43,10 @@ final class UnfurlResponse public const MAX_IMAGE_SIZE = (3 * (1 << 20)); /** - * @var ClientInterface + * @var ?ClientInterface */ private static $httpClient; - /** - * @var string - */ - private $url; - /** * @var Response */ @@ -108,7 +103,7 @@ public static function fetch(string $url): self ]); $response = self::getHttpClient()->send($request); - return new self($url, $response); + return new self($response); } catch (BadResponseException $e) { $response = $e->getResponse(); @@ -128,9 +123,8 @@ public static function fetch(string $url): self * @throws ParsingFailed If the body cannot be parsed (e.g. the url is an image). * @throws DownloadFailed If the url can not be downloaded. This can be a temporary error. */ - private function __construct(string $url, Response $response) + private function __construct(Response $response) { - $this->url = $url; $this->response = $response; $this->readBody(); @@ -337,7 +331,6 @@ private static function isUrlInaccessible(Response $response): bool case 404: // Not Found case 406: // Not Acceptable return true; - break; } return false; diff --git a/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php b/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php index 2a1f66c7ed3..a8e615d16b7 100644 --- a/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php +++ b/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php @@ -100,7 +100,7 @@ public function isValid($definitionName, $objectType) * Returns the object type processor. * * @param string $definitionName - * @param string $objectType + * @param ?string $objectType * @param int $objectTypeID * @return object|null */ diff --git a/wcfsetup/install/files/lib/system/option/FileOptionType.class.php b/wcfsetup/install/files/lib/system/option/FileOptionType.class.php index c6c76a56e16..4b8d77224b8 100644 --- a/wcfsetup/install/files/lib/system/option/FileOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/FileOptionType.class.php @@ -21,7 +21,7 @@ class FileOptionType extends AbstractOptionType { /** * upload handler for option files - * @var UploadHandler[] + * @var array */ protected $uploadHandlers = []; diff --git a/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php b/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php index 384b22c5090..0f94a039a81 100644 --- a/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php +++ b/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php @@ -46,9 +46,7 @@ protected static function splitDate($value) { $year = $month = $day = 0; $optionValue = \explode('-', $value); - if (isset($optionValue[0])) { - $year = \intval($optionValue[0]); - } + $year = \intval($optionValue[0]); if (isset($optionValue[1])) { $month = \intval($optionValue[1]); } diff --git a/wcfsetup/install/files/lib/system/option/user/SelectOptionsUserOptionOutput.class.php b/wcfsetup/install/files/lib/system/option/user/SelectOptionsUserOptionOutput.class.php index b3aa32bc201..0cbcf112267 100644 --- a/wcfsetup/install/files/lib/system/option/user/SelectOptionsUserOptionOutput.class.php +++ b/wcfsetup/install/files/lib/system/option/user/SelectOptionsUserOptionOutput.class.php @@ -46,7 +46,7 @@ public function getOutput(User $user, UserOption $option, $value) * Returns the selected option value(s) for output. * * @param UserOption $option - * @param string $value + * @param ?string $value * @return mixed */ protected static function getResult(UserOption $option, $value) diff --git a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php index 8406d67cb6a..ab9be617ccf 100644 --- a/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php @@ -62,7 +62,7 @@ class UserOptionHandler extends OptionHandler /** * current user - * @var User + * @var ?User */ public $user; diff --git a/wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php b/wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php index 486e3b6e868..16aa9663a89 100644 --- a/wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php +++ b/wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php @@ -27,7 +27,7 @@ class UserGroupOptionHandler extends OptionHandler /** * user group object - * @var UserGroup + * @var ?UserGroup */ protected $group; diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 9c5c45ead6f..034ef28062f 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -31,7 +31,7 @@ class PackageArchive /** * tar archive object - * @var Tar + * @var ?Tar */ protected $tar; @@ -542,9 +542,7 @@ protected function readPackageInfo() */ public function deleteArchive() { - if ($this->tar instanceof Tar) { - $this->tar->close(); - } + $this->tar?->close(); @\unlink($this->archive); } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 7fa69a84a82..72041e8f53b 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -633,7 +633,7 @@ protected function installPackage(array $nodeData): PackageInstallationStep && empty($this->getPackage()->packageDir) ) { $document = $this->promptPackageDir($applicationDirectory); - if ($document !== null && $document instanceof FormDocument) { + if ($document !== null) { $installationStep->setDocument($document); } @@ -995,63 +995,61 @@ protected function promptPackageDir($applicationDirectory) } } - if ($packageDir !== null) { - // validate package dir - if ($document !== null && \file_exists($packageDir . 'global.php')) { - $document->setError( - 'packageDir', - WCF::getLanguage()->get('wcf.acp.package.packageDir.notAvailable') - ); + // validate package dir + if ($document !== null && \file_exists($packageDir . 'global.php')) { + $document->setError( + 'packageDir', + WCF::getLanguage()->get('wcf.acp.package.packageDir.notAvailable') + ); - return $document; - } + return $document; + } - // set package dir - $packageEditor = new PackageEditor($this->getPackage()); - $packageEditor->update([ - 'packageDir' => FileUtil::getRelativePath(WCF_DIR, $packageDir), - ]); + // set package dir + $packageEditor = new PackageEditor($this->getPackage()); + $packageEditor->update([ + 'packageDir' => FileUtil::getRelativePath(WCF_DIR, $packageDir), + ]); - // determine domain path, in some environments (e.g. ISPConfig) the $_SERVER paths are - // faked and differ from the real filesystem path - if (PACKAGE_ID) { - $wcfDomainPath = ApplicationHandler::getInstance()->getWCF()->domainPath; - } else { - $sql = "SELECT domainPath + // determine domain path, in some environments (e.g. ISPConfig) the $_SERVER paths are + // faked and differ from the real filesystem path + if (PACKAGE_ID) { + $wcfDomainPath = ApplicationHandler::getInstance()->getWCF()->domainPath; + } else { + $sql = "SELECT domainPath FROM wcf1_application WHERE packageID = ?"; - $statement = WCF::getDB()->prepare($sql); - $statement->execute([1]); - $row = $statement->fetchArray(); + $statement = WCF::getDB()->prepare($sql); + $statement->execute([1]); + $row = $statement->fetchArray(); - $wcfDomainPath = $row['domainPath']; - } + $wcfDomainPath = $row['domainPath']; + } - $documentRoot = \substr( - FileUtil::unifyDirSeparator(WCF_DIR), - 0, - -\strlen(FileUtil::unifyDirSeparator($wcfDomainPath)) - ); - $domainPath = FileUtil::getRelativePath($documentRoot, $packageDir); - if ($domainPath === './') { - // `FileUtil::getRelativePath()` returns `./` if both paths lead to the same directory - $domainPath = '/'; - } + $documentRoot = \substr( + FileUtil::unifyDirSeparator(WCF_DIR), + 0, + -\strlen(FileUtil::unifyDirSeparator($wcfDomainPath)) + ); + $domainPath = FileUtil::getRelativePath($documentRoot, $packageDir); + if ($domainPath === './') { + // `FileUtil::getRelativePath()` returns `./` if both paths lead to the same directory + $domainPath = '/'; + } - $domainPath = FileUtil::addLeadingSlash($domainPath); + $domainPath = FileUtil::addLeadingSlash($domainPath); - // update application path and untaint application - $application = new Application($this->getPackage()->packageID); - $applicationEditor = new ApplicationEditor($application); - $applicationEditor->update([ - 'domainPath' => $domainPath, - 'isTainted' => 0, - ]); + // update application path and untaint application + $application = new Application($this->getPackage()->packageID); + $applicationEditor = new ApplicationEditor($application); + $applicationEditor->update([ + 'domainPath' => $domainPath, + 'isTainted' => 0, + ]); - // create directory and set permissions - @\mkdir($packageDir, 0777, true); - FileUtil::makeWritable($packageDir); - } + // create directory and set permissions + @\mkdir($packageDir, 0777, true); + FileUtil::makeWritable($packageDir); return null; } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index deac7a21705..e8407193d48 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -133,7 +133,7 @@ public function buildNodes() break; default: - new \LogicException('Unreachable'); + throw new \LogicException('Unreachable'); } // required packages @@ -706,6 +706,7 @@ protected function buildPluginNodes(array $instructions): void } } + // @phpstan-ignore function.alreadyNarrowedType, notIdentical.alwaysTrue \assert($pluginNodes !== []); $sql = "INSERT INTO wcf1_package_installation_node diff --git a/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php index 102e7bd6824..f5e57ea3488 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php @@ -88,7 +88,7 @@ public function uninstall(string $node): PackageInstallationStep break; default: - new \LogicException('Unreachable'); + throw new \LogicException('Unreachable'); } } diff --git a/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php b/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php index 767a1a882e4..8bc0ca8a519 100644 --- a/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php +++ b/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php @@ -28,7 +28,7 @@ final class LicenseApi public function updateLicenseFile(?LicenseData $data): void { - $creationDate = $data?->creationDate ?? new \DateTimeImmutable(); + $creationDate = $data->creationDate ?? new \DateTimeImmutable(); $writer = new AtomicWriter(self::LICENSE_FILE); $writer->write("format('c')} */\n\n"); 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 da08bad2609..39d54802c68 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractFileDeletePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractFileDeletePackageInstallationPlugin.class.php @@ -272,7 +272,7 @@ protected function addFormFields(IFormDocument $form) protected function fetchElementData(\DOMElement $element, $saveData) { return [ - 'application' => $element->getAttribute('application') ?? 'wcf', + 'application' => $element->getAttribute('application') ?: 'wcf', $this->tagName => $element->nodeValue, 'packageID' => $this->installation->getPackage()->packageID, ]; @@ -283,7 +283,7 @@ protected function fetchElementData(\DOMElement $element, $saveData) */ public function getElementIdentifier(\DOMElement $element) { - $app = $element->getAttribute('application') ?? 'wcf'; + $app = $element->getAttribute('application') ?: 'wcf'; return \sha1($app . '_' . $element->nodeValue); } @@ -355,6 +355,8 @@ protected function saveObject(\DOMElement $newElement, ?\DOMElement $oldElement /** * @inheritDoc + * + * @return void */ final protected function deleteObject(\DOMElement $element) { 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 6e36128a6d7..dc829a86476 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php @@ -195,15 +195,9 @@ protected function importItems(\DOMXPath $xpath) } if ($this instanceof IUniqueNameXMLPackageInstallationPlugin) { - $names = \array_map(function ($data) { - \assert($this instanceof IUniqueNameXMLPackageInstallationPlugin); + $names = \array_map(fn($data) => $this->getNameByData($data), $pipData); - return $this->getNameByData($data); - }, $pipData); - - $validNames = \array_filter($names, static function ($name) { - return !empty($name); - }); + $validNames = \array_filter($names); if ($validNames !== \array_unique($validNames)) { throw new LogicException( @@ -292,7 +286,7 @@ protected function getI18nValues(array $values, $singleValueOnly = false) * * @param array $row * @param array $data - * @return \wcf\data\IStorableObject|null + * @return \wcf\data\IStorableObject|\wcf\data\DatabaseObjectEditor|null */ protected function import(array $row, array $data) { 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 a2208687cf3..f3a3038506b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php @@ -245,7 +245,6 @@ protected function prepareImport(array $data) default: throw new SystemException("Unknown type '{$boxType}' for box '{$identifier}"); - break; } if (!empty($data['elements']['visibilityExceptions'])) { @@ -348,7 +347,7 @@ protected function import(array $row, array $data) unset($data['additionalData']); } - /** @var Box $box */ + /** @var Box|BoxEditor $box */ $box = parent::import($row, $data); } 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 a9525bb0d98..182afa863e4 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php @@ -56,7 +56,7 @@ protected function getElement(\DOMXPath $xpath, array &$elements, \DOMElement $e break; case 'expression': $elements['expression'] = [ - 'type' => $element->getAttribute('type') ?? '', + 'type' => $element->getAttribute('type'), 'value' => $element->nodeValue, ]; break; @@ -120,7 +120,7 @@ private function getRandomExpression(string $name, string $expression): CronExpr $name ), true) )); - $engine = static fn (int $min, int $max) => $randomizer->getInt($min, $max); + $engine = static fn(int $min, int $max) => $randomizer->getInt($min, $max); } else { // A seedable engine is not available, use completely random values. $engine = \random_int(...); @@ -506,14 +506,14 @@ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form $expression = $document->createElement( 'expression', $formData['expression'] ?? - \sprintf( - '%s %s %s %s %s', - $formData['startminute'], - $formData['starthour'], - $formData['startdom'], - $formData['startmonth'], - $formData['startdow'] - ) + \sprintf( + '%s %s %s %s %s', + $formData['startminute'], + $formData['starthour'], + $formData['startdom'], + $formData['startmonth'], + $formData['startdow'] + ) ); if ($formData['expressionType'] !== '') { $expression->setAttribute('type', $formData['expressionType']); 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 1a9eeaa450c..9aa6e787859 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php @@ -158,19 +158,18 @@ public function install() // save language if ($languageFile !== null) { - if ($xml = $this->readLanguage($languageFile)) { - // get language object - $languageEditor = new LanguageEditor(new Language(null, $installedLanguage)); - - // import xml - // don't update language files if package is an application - $languageEditor->updateFromXML( - $xml, - $this->installation->getPackageID(), - !$this->installation->getPackage()->isApplication, - $updateExistingItems - ); - } + $xml = $this->readLanguage($languageFile); + // get language object + $languageEditor = new LanguageEditor(new Language(null, $installedLanguage)); + + // import xml + // don't update language files if package is an application + $languageEditor->updateFromXML( + $xml, + $this->installation->getPackageID(), + !$this->installation->getPackage()->isApplication, + $updateExistingItems + ); } } } @@ -822,14 +821,13 @@ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form throw new \LogicException("Unknown language category mode '{$data['languageCategoryIDMode']}'."); } - /** @var \DOMElement $import */ + /** @var ?\DOMElement $import */ $import = $document->getElementsByTagName('import')->item(0); if ($import === null) { $import = $document->createElement('import'); DOMUtil::prepend($import, $document->documentElement); } - /** @var \DOMElement $languageCategory */ foreach ($import->getElementsByTagName('category') as $languageCategory) { if ($languageCategory instanceof \DOMElement && $languageCategory->getAttribute('name') === $languageCategoryName) { $languageCategory->appendChild($languageItem); 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 ba011c369ef..9df0691a501 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -204,7 +204,7 @@ protected function prepareImport(array $data) // @deprecated if (!empty($data['elements']['controllerCustomURL'])) { $controllerCustomURL = $data['elements']['controllerCustomURL']; - if ($controllerCustomURL && !RouteHandler::isValidCustomUrl($controllerCustomURL)) { + if (!RouteHandler::isValidCustomUrl($controllerCustomURL)) { throw new SystemException("Invalid custom url for page identifier '" . $data['attributes']['identifier'] . "'"); } } @@ -233,7 +233,6 @@ protected function prepareImport(array $data) default: throw new SystemException("Unknown type '{$pageType}' for page '{$identifier}"); - break; } // get application package id 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 60413be52a3..52f61239141 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php @@ -285,23 +285,18 @@ protected function getLegacyMessage($code) } return "unable to find package file '" . $this->details['archive'] . "'"; - break; case self::MISSING_PACKAGE_XML: return "package information file '" . PackageArchive::INFO_FILE . "' not found in '" . $this->details['archive'] . "'"; - break; case self::INVALID_PACKAGE_NAME: return "'" . $this->details['packageName'] . "' is not a valid package name."; - break; case self::INVALID_PACKAGE_VERSION: return "package version '" . $this->details['packageVersion'] . "' is invalid"; - break; default: return $this->getErrorMessage($code); - break; } } diff --git a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php index 3ca396016ab..aeff5234824 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryMenuPageHandler.class.php @@ -34,7 +34,7 @@ public function isVisible($objectID = null) { $className = $this->getDecoratedCategoryClass(); - /** @var AbstractDecoratedCategory $category */ + /** @var ?AbstractDecoratedCategory $category */ /** @noinspection PhpUndefinedMethodInspection */ $category = $className::getCategory($objectID); diff --git a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php index eb0ebe93d84..67536b9a0e8 100644 --- a/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/TDecoratedCategoryOnlineLocationPageHandler.class.php @@ -47,7 +47,7 @@ public function getOnlineLocation(Page $page, UserOnline $user) throw new ParentClassException($className, AbstractDecoratedCategory::class); } - /** @var AbstractDecoratedCategory $category */ + /** @var ?AbstractDecoratedCategory $category */ /** @noinspection PhpUndefinedMethodInspection */ $category = $className::getCategory($user->pageObjectID); if ($category === null) { diff --git a/wcfsetup/install/files/lib/system/poll/PollManager.class.php b/wcfsetup/install/files/lib/system/poll/PollManager.class.php index 293ca4cca9a..1ceea12be30 100644 --- a/wcfsetup/install/files/lib/system/poll/PollManager.class.php +++ b/wcfsetup/install/files/lib/system/poll/PollManager.class.php @@ -462,7 +462,7 @@ public function getRelatedObject(Poll $poll) * Returns the handler object for given object type. Returns false if object type (id) * is not found, or null if no handler is assigned. * - * @param int $objectTypeID + * @param ?int $objectTypeID * @param string $objectType * @return mixed * @throws SystemException diff --git a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php index de28adc8f43..96dd3f18c16 100644 --- a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php +++ b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php @@ -196,6 +196,7 @@ public function getLikeableObject($objectTypeName, $objectID) ); } + // @phpstan-ignore instanceof.alwaysTrue if (!($this->likeableObjectsCache[$objectTypeName][$objectID] instanceof ILikeObject)) { throw new ImplementationException( \get_class($this->likeableObjectsCache[$objectTypeName][$objectID]), @@ -430,7 +431,7 @@ public function react(ILikeObject $likeable, User $user, $reactionTypeID, $time throw $e; } - /** @noinspection PhpUnreachableStatementInspection */ + // @phpstan-ignore deadCode.unreachable throw new \LogicException('Unreachable'); } diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 8f7d4a7c838..49fe71265f0 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -164,6 +164,7 @@ public function handle(string $application = 'wcf', bool $isACPRequest = false): return; } } else { + // @phpstan-ignore function.alreadyNarrowedType, instanceof.alwaysTrue \assert($builtRequest instanceof RequestHandlerInterface); $pipeline = new Pipeline([ 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 ee3c19fef01..afc253bc5c6 100644 --- a/wcfsetup/install/files/lib/system/request/route/LookupRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/LookupRequestRoute.class.php @@ -50,7 +50,7 @@ public function matches($requestURL): bool if (\preg_match($regex, $requestURL, $matches)) { $application = ApplicationHandler::getInstance()->getActiveApplication()->getAbbreviation(); - if (!empty($matches['id'])) { + if (!empty($matches['controller'])) { // check for static controller URLs $this->routeData = ControllerMap::getInstance()->resolveCustomController( $application, diff --git a/wcfsetup/install/files/lib/system/rssFeed/XmlElement.class.php b/wcfsetup/install/files/lib/system/rssFeed/XmlElement.class.php index 72fc0ff5b7e..d6c3121bc3a 100644 --- a/wcfsetup/install/files/lib/system/rssFeed/XmlElement.class.php +++ b/wcfsetup/install/files/lib/system/rssFeed/XmlElement.class.php @@ -12,16 +12,16 @@ */ final class XmlElement extends \SimpleXMLElement { - public function addChild(string $name, ?string $value = null, ?string $namespace = null): ?static + public function addChild(string $name, ?string $value = null, ?string $namespace = null): ?self { - if ($value !== null && \is_string($value)) { + if ($value !== null) { $value = \str_replace('&', '&', $value); } return parent::addChild($name, $value, $namespace); } - public function addChildCData(string $name, string $value): static + public function addChildCData(string $name, string $value): self { $child = $this->addChild($name); $child->addCData($value); diff --git a/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php b/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php index bbd3b601ed6..579d739c5f4 100644 --- a/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php +++ b/wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php @@ -107,6 +107,7 @@ private function readMessages(): void $objectType = SearchEngine::getInstance()->getObjectType($type); $message = $objectType->getObject($objectID); if ($message !== null) { + // @phpstan-ignore instanceof.alwaysTrue if (!($message instanceof ISearchResultObject)) { throw new ImplementationException(\get_class($message), ISearchResultObject::class); } 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 6f90de03cd7..adf9b31ce9d 100644 --- a/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php +++ b/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php @@ -27,10 +27,7 @@ class MysqlSearchEngine extends AbstractSearchEngine */ protected $ftMinWordLen; - /** - * @var int - */ - private $minTokenSize; + private int $minTokenSize; /** * @inheritDoc diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 4ee15d07b94..2f54a478aee 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -194,29 +194,27 @@ private function parseCookie(string $value): array } $version = \unpack('Cversion', $value)['version']; - if (!\in_array($version, [1], true)) { - throw new \InvalidArgumentException(\sprintf( - 'Unknown version %d', - $version - )); - } + switch ($version) { + case 1: + if ($length !== 22) { + throw new \InvalidArgumentException(\sprintf( + 'Expected exactly 22 Bytes, %d given.', + $length + )); + } + $data = \unpack('Cversion/a20sessionId/Ctimestep', $value); + \assert($data['version'] === 1); + \assert(\strlen($data['sessionId']) === 20); + $data['sessionId'] = Hex::encode($data['sessionId']); + + return $data; - if ($version === 1) { - if ($length !== 22) { + default: throw new \InvalidArgumentException(\sprintf( - 'Expected exactly 22 Bytes, %d given.', - $length + 'Unknown version %d', + $version )); - } - $data = \unpack('Cversion/a20sessionId/Ctimestep', $value); - \assert($data['version'] === 1); - \assert(\strlen($data['sessionId']) === 20); - $data['sessionId'] = Hex::encode($data['sessionId']); - - return $data; } - - throw new \LogicException('Unreachable'); } /** @@ -273,6 +271,7 @@ private function getCookieTimestep(): int { $window = (24 * 3600); + // @phpstan-ignore function.alreadyNarrowedType, smaller.alwaysTrue \assert((self::USER_SESSION_LIFETIME / $window) < 0xFF); return \intdiv(TIME_NOW, $window) & 0xFF; diff --git a/wcfsetup/install/files/lib/system/setup/Installer.class.php b/wcfsetup/install/files/lib/system/setup/Installer.class.php index bc3550c9c33..4a26148ebb9 100644 --- a/wcfsetup/install/files/lib/system/setup/Installer.class.php +++ b/wcfsetup/install/files/lib/system/setup/Installer.class.php @@ -36,7 +36,7 @@ class Installer /** * file handler of the installed files - * @var \wcf\system\setup\IFileHandler + * @var ?\wcf\system\setup\IFileHandler */ protected $fileHandler; @@ -196,9 +196,7 @@ protected function getTar($source) */ protected function checkFiles(&$files) { - if ($this->fileHandler != null && $this->fileHandler instanceof IFileHandler) { - $this->fileHandler->checkFiles($files); - } + $this->fileHandler?->checkFiles($files); } /** @@ -208,9 +206,7 @@ protected function checkFiles(&$files) */ protected function logFiles(&$files) { - if ($this->fileHandler != null && $this->fileHandler instanceof IFileHandler) { - $this->fileHandler->logFiles($files); - } + $this->fileHandler?->logFiles($files); } /** diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index d7627a2bcef..fec130f974e 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -655,7 +655,7 @@ private function prepareVariables(array $variables): array if (PACKAGE_ID) { foreach (Option::getOptions() as $constantName => $option) { if (\in_array($option->optionType, static::$supportedOptionType)) { - $variables['wcf_option_' . \mb_strtolower($constantName)] = \is_int($option->optionValue) ? $option->optionValue : '"' . $option->optionValue . '"'; + $variables['wcf_option_' . \mb_strtolower($constantName)] = \is_numeric($option->optionValue) ? $option->optionValue : '"' . $option->optionValue . '"'; } } } else { diff --git a/wcfsetup/install/files/lib/system/style/StyleHandler.class.php b/wcfsetup/install/files/lib/system/style/StyleHandler.class.php index b087706e320..8657ae7fd33 100644 --- a/wcfsetup/install/files/lib/system/style/StyleHandler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleHandler.class.php @@ -119,6 +119,7 @@ public function changeStyle($styleID = 0, $ignorePermissions = false) $this->style = new ActiveStyle($this->cache['styles'][$styleID]); // set template group id + // @phpstan-ignore if.alwaysTrue if (WCF::getTPL()) { WCF::getTPL()->setTemplateGroupID($this->style->templateGroupID); } diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index c3746cf759f..bfc318f6215 100755 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -11,6 +11,7 @@ use wcf\system\exception\SystemException; use wcf\system\Regex; use wcf\system\SingletonFactory; +use wcf\system\template\plugin\IPrefilterTemplatePlugin; use wcf\system\WCF; use wcf\util\DirectoryUtil; use wcf\util\HeaderUtil; @@ -198,7 +199,7 @@ class TemplateEngine extends SingletonFactory /** * all available template variables and those assigned during runtime - * @var mixed[][] + * @var array> */ protected $v = []; @@ -844,7 +845,7 @@ public static function deleteCompiledTemplates($compileDir = '') /** * Returns an array with all prefilters. * - * @return string[] + * @return (string|IPrefilterTemplatePlugin)[] */ public function getPrefilters() { diff --git a/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php b/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php index 4b271d94f79..070fea954d1 100644 --- a/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php @@ -188,13 +188,13 @@ class TemplateScriptingCompiler /** * list of automatically loaded tenplate plugins - * @var string[] + * @var array */ protected $autoloadPlugins = []; /** * stack with template tags data - * @var array + * @var list */ protected $tagStack = []; @@ -334,18 +334,15 @@ public function compileString($identifier, $sourceContent, array $metaData = [], } // throw error messages for unclosed tags - if (\count($this->tagStack) > 0) { - foreach ($this->tagStack as $tagStack) { - throw new SystemException( - static::formatSyntaxError( - 'unclosed tag {' . $tagStack[0] . '}', - $this->currentIdentifier, - $tagStack[1] - ) - ); - } - - return false; + $unclosedTag = \array_shift($this->tagStack); + if ($unclosedTag !== null) { + throw new SystemException( + static::formatSyntaxError( + 'unclosed tag {' . $unclosedTag[0] . '}', + $this->currentIdentifier, + $unclosedTag[1] + ) + ); } $compiledContent = ''; @@ -365,7 +362,7 @@ public function compileString($identifier, $sourceContent, array $metaData = [], // include Plugins $compiledAutoloadPlugins = ''; - if (\count($this->autoloadPlugins) > 0) { + if ($this->autoloadPlugins !== []) { $compiledAutoloadPlugins = "autoloadPlugins as $className) { $compiledAutoloadPlugins .= "if (!isset(\$this->pluginObjects['{$className}'])) {\n"; @@ -399,6 +396,7 @@ public function compileString($identifier, $sourceContent, array $metaData = [], * @param array $metaData * @return string * @throws SystemException + * @phpstan-impure */ protected function compileTag($tag, $identifier, array &$metaData) { @@ -423,6 +421,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return $this->compileIfTag($tagArgs); case 'elseif': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'if' && $openTag != 'elseif') { throw new SystemException( @@ -439,6 +438,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return $this->compileIfTag($tagArgs, true); case 'else': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'if' && $openTag != 'elseif') { throw new SystemException( @@ -454,6 +454,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return ''; case '/if': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'if' && $openTag != 'elseif' && $openTag != 'else') { throw new SystemException( @@ -477,6 +478,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return $this->compileForeachTag($tagArgs); case 'foreachelse': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'foreach') { throw new SystemException( @@ -492,6 +494,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return ''; case '/foreach': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'foreach' && $openTag != 'foreachelse') { throw new SystemException( @@ -512,6 +515,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return $this->compileSectionTag($tagArgs); case 'sectionelse': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'section') { throw new SystemException( @@ -527,6 +531,7 @@ protected function compileTag($tag, $identifier, array &$metaData) return ''; case '/section': + \assert($this->tagStack !== []); [$openTag] = \end($this->tagStack); if ($openTag != 'section' && $openTag != 'sectionelse') { throw new SystemException( @@ -1192,8 +1197,8 @@ public static function makeArgString($args) * Returns a formatted syntax error message. * * @param string $errorMsg - * @param string $file - * @param int $line + * @param ?string $file + * @param ?int $line * @return string */ public static function formatSyntaxError($errorMsg, $file = null, $line = null) @@ -1201,7 +1206,7 @@ public static function formatSyntaxError($errorMsg, $file = null, $line = null) $errorMsg = 'Template compilation failed: ' . $errorMsg; if ($file && $line) { $errorMsg .= " in template '{$file}' on line {$line}"; - } elseif ($file && !$line) { + } elseif ($file) { $errorMsg .= " in template '{$file}'"; } @@ -1310,6 +1315,7 @@ protected function compileIfTag($tagArgs, $elseif = false) * Adds a tag to the tag stack. * * @param string $tag + * @return void */ public function pushTag($tag) { @@ -1607,7 +1613,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; } } @@ -1631,7 +1636,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case '->': // object access case '?->': @@ -1648,7 +1652,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case '(': // left parenthesis if ($status == 'object') { @@ -1678,7 +1681,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case ')': // right parenthesis while ($oldStatus = \array_pop($statusStack)) { @@ -1708,7 +1710,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case '[': // bracket open if ($status == 'variable' || $status == 'object') { @@ -1727,7 +1728,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case ']': // bracket close while ($oldStatus = \array_pop($statusStack)) { @@ -1753,7 +1753,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case '|': // modifier // handle previous modifier @@ -1816,7 +1815,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case ',': while ($oldStatus = \array_pop($statusStack)) { @@ -1844,7 +1842,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; case '+': // math operators case '-': @@ -1871,7 +1868,6 @@ public function compileVariableTag($tag, $replaceQuotes = true) $this->currentLineNo ) ); - break; } } } @@ -1988,7 +1984,7 @@ public function applyPrefilters($templateName, $string) } else { throw new SystemException( static::formatSyntaxError( - "Prefilter '" . (\is_object($prefilter) ? \get_class($prefilter) : $prefilter) . "' does not implement the interface 'IPrefilterTemplatePlugin'", + "Prefilter '" . \get_class($prefilter) . "' does not implement the interface 'IPrefilterTemplatePlugin'", $this->currentIdentifier ) ); diff --git a/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php index 3b891022b13..58e9ae963f2 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php @@ -28,15 +28,15 @@ class DateModifierTemplatePlugin implements IModifierTemplatePlugin */ public function execute($tagArgs, TemplateEngine $tplObj) { - if ($tagArgs[0] instanceof \DateTimeInterface) { - $dateTime = clone $tagArgs[0]; + $value = $tagArgs[0]; + if ($value instanceof \DateTime || $value instanceof \DateTimeImmutable) { + $dateTime = clone $value; } else { - $timestamp = \intval($tagArgs[0]); + $timestamp = \intval($value); $dateTime = new \DateTimeImmutable('@' . $timestamp); } if (!empty($tagArgs[1])) { - \assert($dateTime instanceof \DateTime || $dateTime instanceof \DateTimeImmutable); return $dateTime ->setTimezone(WCF::getUser()->getTimeZone()) ->format($tagArgs[1]); 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 153e3b86985..2e952dade4b 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php @@ -105,8 +105,8 @@ public function execute($tagArgs, TemplateEngine $tplObj) /** * Makes the HTML for an option group. * - * @param string $key - * @param array $values + * @param ?string $key + * @param array|DatabaseObjectList $values * @return string */ protected function makeOptionGroup($key, $values) diff --git a/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php index d035518ad3a..7aa2b4dd18a 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/ObjectActionFunctionTemplatePlugin.class.php @@ -114,8 +114,6 @@ public function execute($tagArgs, TemplateEngine $tplObj) HTML; - break; - case 'toggle': if (!isset($tagArgs['isDisabled'])) { throw new \InvalidArgumentException("Missing 'isDisabled' argument for 'toggle' action."); diff --git a/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php b/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php index 854d9cef61e..48d141b6eef 100644 --- a/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php +++ b/wcfsetup/install/files/lib/system/user/GroupedUserList.class.php @@ -111,7 +111,7 @@ public static function loadUsers(): void if ($userIDs !== []) { $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); foreach ($userProfiles as $userID => $userProfile) { - if ($userProfile) { + if ($userProfile !== null) { self::$users[$userID] = $userProfile; } } diff --git a/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php index c3a78b62a6d..a4cc7bd24c1 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php @@ -32,10 +32,6 @@ public function prepare(array $events) // fetch users $userIDs = $users = []; foreach ($this->comments as $comment) { - if ($comment === null) { - continue; - } - $userIDs[] = $comment->objectID; } if (!empty($userIDs)) { diff --git a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Wcf1e.class.php b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Wcf1e.class.php index 65d5dcc0e14..0c2a326d348 100644 --- a/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Wcf1e.class.php +++ b/wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Wcf1e.class.php @@ -119,15 +119,12 @@ private function encrypt( switch ($this->encryptionMethod) { case 'c': return (string)\crc32($string); - break; case 'm': return \md5($string); - break; case 's': return \sha1($string); - break; default: throw new \BadMethodCallException("Unknown encryption used"); 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 46b13fe4bc5..679e38792df 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/EmailMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/EmailMultifactorMethod.class.php @@ -166,6 +166,7 @@ public function createAuthenticationForm(IFormDocument $form, Setup $setup): voi } if ($lastCode < (\TIME_NOW - self::REFRESH_AFTER)) { + // @phpstan-ignore function.alreadyNarrowedType, smallerOrEqual.alwaysTrue \assert(self::LENGTH <= 9, "Code does not fit into a 32-bit integer."); $code = \random_int( diff --git a/wcfsetup/install/files/lib/system/user/multifactor/Helper.class.php b/wcfsetup/install/files/lib/system/user/multifactor/Helper.class.php index 0a1f1bc581a..07e3f5719f8 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/Helper.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/Helper.class.php @@ -18,7 +18,7 @@ final class Helper public static function digitStream(): \Iterator { $i = 1; - while (true) { + for (;;) { yield $i++; if ($i > 9) { $i = 0; 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 37dc21a70a7..8859669ae22 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/Setup.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/Setup.class.php @@ -176,7 +176,7 @@ public static function allocateSetUpId(ObjectType $objectType, User $user): self ]); $setup = self::find($objectType, $user); - \assert($setup); + \assert($setup !== null); return $setup; } 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 24da76556be..bb62d203488 100644 --- a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php @@ -31,7 +31,7 @@ final class UserStorageHandler extends SingletonFactory /** * redis instance - * @var Redis + * @var ?Redis */ private $redis; @@ -251,6 +251,8 @@ public function resetAll(string $field) /** * Removes and inserts data records on shutdown. + * + * @return void */ public function shutdown() { diff --git a/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php b/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php index 58e5568ba93..28e84ce090e 100644 --- a/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php +++ b/wcfsetup/install/files/lib/system/version/VersionTrackerEntry.class.php @@ -33,7 +33,7 @@ class VersionTrackerEntry /** * VersionTrackerEntry constructor. * - * @param int $id id + * @param ?int $id id * @param array $data version data */ public function __construct($id, array $data) diff --git a/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php b/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php index 52971abacc3..1af07a7366c 100644 --- a/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php +++ b/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php @@ -243,6 +243,7 @@ public function trackTypeVisit($objectType, $time = TIME_NOW) public function prune(): void { $visitLifetime = 120 * 86400; + // @phpstan-ignore function.alreadyNarrowedType, greater.alwaysTrue \assert($visitLifetime > self::LIFETIME); $sql = "DELETE FROM wcf1_tracked_visit diff --git a/wcfsetup/install/files/lib/system/worker/IWorker.class.php b/wcfsetup/install/files/lib/system/worker/IWorker.class.php index 2c2df5cec65..67b8d150ec4 100644 --- a/wcfsetup/install/files/lib/system/worker/IWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/IWorker.class.php @@ -59,6 +59,8 @@ public function getProceedURL(); /** * Executes actions after worker has been executed. + * + * @return void */ public function finalize(); } diff --git a/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php b/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php index e358434245f..63ad9c45f67 100644 --- a/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/ImportWorker.class.php @@ -25,7 +25,7 @@ class ImportWorker extends AbstractWorker /** * exporter object - * @var \wcf\system\exporter\IExporter + * @var ?\wcf\system\exporter\IExporter */ protected $exporter; diff --git a/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php b/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php index d99faefa9f7..3b98af9d380 100755 --- a/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php @@ -58,7 +58,7 @@ class SitemapRebuildWorker extends AbstractRebuildDataWorker /** * The current temporary file as File object. - * @var File + * @var ?File */ public $file; diff --git a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php index 68a94a1b2f2..53c062a0476 100644 --- a/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserContentRemoveWorker.class.php @@ -45,7 +45,7 @@ class UserContentRemoveWorker extends AbstractWorker protected $data; /** - * @var string[] + * @var ?string[] */ public $contentProviders; diff --git a/wcfsetup/install/files/lib/util/ClassUtil.class.php b/wcfsetup/install/files/lib/util/ClassUtil.class.php index f22aec7db1a..1b8fe787f74 100644 --- a/wcfsetup/install/files/lib/util/ClassUtil.class.php +++ b/wcfsetup/install/files/lib/util/ClassUtil.class.php @@ -24,6 +24,7 @@ final class ClassUtil */ public static function equals($a, $b) { + // @phpstan-ignore function.alreadyNarrowedType if (!\is_object($a)) { return false; } @@ -45,6 +46,7 @@ public static function equals($a, $b) public static function isInstanceOf($className, $targetClass) { // validate parameters + // @phpstan-ignore function.alreadyNarrowedType if (!\is_string($className)) { return false; } elseif (!\class_exists($className)) { @@ -57,6 +59,7 @@ public static function isInstanceOf($className, $targetClass) ); } + // @phpstan-ignore function.alreadyNarrowedType return \is_subclass_of($className, $targetClass); } diff --git a/wcfsetup/install/files/lib/util/DateUtil.class.php b/wcfsetup/install/files/lib/util/DateUtil.class.php index 5dae24831aa..23146db385a 100644 --- a/wcfsetup/install/files/lib/util/DateUtil.class.php +++ b/wcfsetup/install/files/lib/util/DateUtil.class.php @@ -444,9 +444,7 @@ public static function getAge($date) // split date $year = $month = $day = 0; $value = \explode('-', $date); - if (isset($value[0])) { - $year = \intval($value[0]); - } + $year = \intval($value[0]); if (isset($value[1])) { $month = \intval($value[1]); } diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index 37ea62933be..2541a3b5986 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -298,6 +298,7 @@ public static function getRealPath(string $path): string } $lastValue = \end($pathA); + // @phpstan-ignore identical.alwaysFalse if ($lastValue === '' || $lastValue === false) { $result[] = ''; } diff --git a/wcfsetup/install/files/lib/util/HTTPRequest.class.php b/wcfsetup/install/files/lib/util/HTTPRequest.class.php index 3f0b86fd1dc..c9a422c0e11 100644 --- a/wcfsetup/install/files/lib/util/HTTPRequest.class.php +++ b/wcfsetup/install/files/lib/util/HTTPRequest.class.php @@ -98,13 +98,11 @@ public function __construct($url, array $options = [], $postParameters = [], arr $language = WCF::getLanguage(); $this->addHeader( 'user-agent', - "HTTP.PHP (HTTPRequest.class.php; WoltLab Suite/" . WCF_VERSION . "; " . ($language ? $language->languageCode : 'en') . ")" + "HTTP.PHP (HTTPRequest.class.php; WoltLab Suite/" . WCF_VERSION . "; " . $language->languageCode . ")" ); $this->addHeader('accept', '*/*'); $this->addHeader('accept-encoding', 'identity'); - if ($language) { - $this->addHeader('accept-language', $language->getFixedLanguageCode()); - } + $this->addHeader('accept-language', $language->getFixedLanguageCode()); if (isset($this->options['maxLength'])) { $this->addHeader('Range', 'bytes=0-' . ($this->options['maxLength'] - 1)); diff --git a/wcfsetup/install/files/lib/util/HeaderUtil.class.php b/wcfsetup/install/files/lib/util/HeaderUtil.class.php index 753d1b2e740..402e7c49543 100644 --- a/wcfsetup/install/files/lib/util/HeaderUtil.class.php +++ b/wcfsetup/install/files/lib/util/HeaderUtil.class.php @@ -71,7 +71,7 @@ public static function getCookieDomain(): ?string } $cookieDomain = $application->cookieDomain; - if ($addDomain && \strpos($cookieDomain, ':') !== false) { + if (\strpos($cookieDomain, ':') !== false) { $cookieDomain = \explode(':', $cookieDomain, 2)[0]; } diff --git a/wcfsetup/install/files/lib/util/MessageUtil.class.php b/wcfsetup/install/files/lib/util/MessageUtil.class.php index dd64ad0fd17..f658aba4689 100644 --- a/wcfsetup/install/files/lib/util/MessageUtil.class.php +++ b/wcfsetup/install/files/lib/util/MessageUtil.class.php @@ -77,7 +77,7 @@ public static function getMentionedUserIDs(HtmlInputProcessor $htmlInputProcesso if (!empty($attributes[0])) { $userIDs[] = $attributes[0]; } - } elseif ($type === 'group' && WCF::getSession()->getPermission('user.message.canMentionGroups')) { + } elseif (WCF::getSession()->getPermission('user.message.canMentionGroups')) { if (!empty($attributes[0])) { $group = UserGroup::getGroupByID($attributes[0]); if ($group !== null && $group->canBeMentioned() && !isset($groups[$group->groupID])) { @@ -138,7 +138,7 @@ public static function getMentionedUsers(HtmlInputProcessor $htmlInputProcessor) if ($type === 'user') { $usernames[] = $element->textContent; - } elseif ($type === 'group' && WCF::getSession()->getPermission('user.message.canMentionGroups')) { + } elseif (WCF::getSession()->getPermission('user.message.canMentionGroups')) { $attributes = $htmlInputProcessor->getHtmlInputNodeProcessor()->parseAttributes( $element->getAttribute('data-attributes') ); diff --git a/wcfsetup/install/files/lib/util/StringUtil.class.php b/wcfsetup/install/files/lib/util/StringUtil.class.php index d902ae22b0d..e69896add5d 100644 --- a/wcfsetup/install/files/lib/util/StringUtil.class.php +++ b/wcfsetup/install/files/lib/util/StringUtil.class.php @@ -415,7 +415,7 @@ public static function getCharacter($dec): string public static function getCharValue($c) { $ud = 0; - if (\ord($c[0]) >= 0 && \ord($c[0]) <= 127) { + if (\ord($c[0]) <= 127) { $ud = \ord($c[0]); } if (\ord($c[0]) >= 192 && \ord($c[0]) <= 223) { @@ -433,7 +433,7 @@ public static function getCharValue($c) if (\ord($c[0]) >= 252 && \ord($c[0]) <= 253) { $ud = (\ord($c[0]) - 252) * 1073741824 + (\ord($c[1]) - 128) * 16777216 + (\ord($c[2]) - 128) * 262144 + (\ord($c[3]) - 128) * 4096 + (\ord($c[4]) - 128) * 64 + (\ord($c[5]) - 128); } - if (\ord($c[0]) >= 254 && \ord($c[0]) <= 255) { + if (\ord($c[0]) >= 254) { $ud = false; // error } diff --git a/wcfsetup/install/files/lib/util/Url.class.php b/wcfsetup/install/files/lib/util/Url.class.php index 0834b0035bb..443267e6150 100644 --- a/wcfsetup/install/files/lib/util/Url.class.php +++ b/wcfsetup/install/files/lib/util/Url.class.php @@ -146,7 +146,7 @@ public function offsetSet(mixed $offset, mixed $value): void * making it easier to spot typos. * * @param mixed $property - * @return int|string + * @return string * @throws \RuntimeException */ private function getIndex($property) diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index 64d8e75a9a7..02377a17aeb 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -283,7 +283,7 @@ public static function verifyGuestToken(string $token): ?string return null; } - if (!\is_array($data) || !isset($data['username']) || !isset($data['time'])) { + if (!isset($data['username']) || !isset($data['time'])) { return null; }