From 083a041c6a2cfa7708346fc9cf81179d6b44dffb Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 2 Jul 2016 13:12:35 +0200 Subject: [PATCH] Fix some warnings about undefined contexts --- wcfsetup/install.php | 1 + .../condition/UserIntegerPropertyCondition.class.php | 1 + .../files/lib/system/image/ImageHandler.class.php | 1 + .../install/files/lib/system/io/GZipFile.class.php | 1 + .../system/option/CaptchaSelectOptionType.class.php | 5 ++--- .../lib/system/option/SelectOptionType.class.php | 1 + ...ommentResponseOwnerUserNotificationEvent.class.php | 11 +++++++---- .../UserProfileCommentUserNotificationEvent.class.php | 9 ++++++--- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/wcfsetup/install.php b/wcfsetup/install.php index 47867e6854..d635109148 100644 --- a/wcfsetup/install.php +++ b/wcfsetup/install.php @@ -782,6 +782,7 @@ class ZipFile extends File { if (!self::$gzopen64 && !function_exists('gzopen')) { throw new SystemException('Can not find functions of the zlib extension'); } + /** @noinspection PhpUndefinedFunctionInspection */ $this->resource = (self::$gzopen64 ? @gzopen64($filename, $mode) : @gzopen($filename, $mode)); if ($this->resource === false) { throw new SystemException('Can not open file ' . $filename); diff --git a/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php index 9c156d0984..86251d1fd2 100644 --- a/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php @@ -26,6 +26,7 @@ class UserIntegerPropertyCondition extends AbstractIntegerCondition implements I } if (isset($conditionData['greaterThan'])) { + /** @noinspection PhpUndefinedFieldInspection */ $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' > ?', [$conditionData['greaterThan']]); } if (isset($conditionData['lessThan'])) { diff --git a/wcfsetup/install/files/lib/system/image/ImageHandler.class.php b/wcfsetup/install/files/lib/system/image/ImageHandler.class.php index 1bef80ffa0..26835b8927 100644 --- a/wcfsetup/install/files/lib/system/image/ImageHandler.class.php +++ b/wcfsetup/install/files/lib/system/image/ImageHandler.class.php @@ -39,6 +39,7 @@ class ImageHandler extends SingletonFactory { } $imageAdapter = $this->imageAdapters[IMAGE_ADAPTER_TYPE]; + /** @noinspection PhpUndefinedCallbackInspection */ $isSupported = call_user_func([$imageAdapter, 'isSupported']); // fallback to GD if image adapter is not available diff --git a/wcfsetup/install/files/lib/system/io/GZipFile.class.php b/wcfsetup/install/files/lib/system/io/GZipFile.class.php index ba89054a81..22d8745dec 100644 --- a/wcfsetup/install/files/lib/system/io/GZipFile.class.php +++ b/wcfsetup/install/files/lib/system/io/GZipFile.class.php @@ -35,6 +35,7 @@ class GZipFile extends File { } $this->filename = $filename; + /** @noinspection PhpUndefinedFunctionInspection */ $this->resource = (self::$gzopen64 ? gzopen64($filename, $mode) : gzopen($filename, $mode)); if ($this->resource === false) { throw new SystemException('Can not open file ' . $filename); diff --git a/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php b/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php index 3fa7c890d6..6b9b1973f3 100644 --- a/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/CaptchaSelectOptionType.class.php @@ -19,11 +19,10 @@ class CaptchaSelectOptionType extends AbstractOptionType { */ public function getFormElement(Option $option, $value) { $selectOptions = CaptchaHandler::getInstance()->getCaptchaSelection(); + /** @noinspection PhpUndefinedFieldInspection */ if ($option->allowemptyvalue) { $selectOptions = array_merge( - [ - '' => WCF::getLanguage()->get('wcf.captcha.useNoCaptcha') - ], + ['' => WCF::getLanguage()->get('wcf.captcha.useNoCaptcha')], $selectOptions ); } diff --git a/wcfsetup/install/files/lib/system/option/SelectOptionType.class.php b/wcfsetup/install/files/lib/system/option/SelectOptionType.class.php index de2ec66c6b..8cbdacc9a9 100644 --- a/wcfsetup/install/files/lib/system/option/SelectOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/SelectOptionType.class.php @@ -20,6 +20,7 @@ class SelectOptionType extends RadioButtonOptionType { public function getFormElement(Option $option, $value) { $options = $this->parseEnableOptions($option); + /** @noinspection PhpUndefinedFieldInspection */ WCF::getTPL()->assign([ 'disableOptions' => $options['disableOptions'], 'enableOptions' => $options['enableOptions'], diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php index fb5309fccb..4ed3efb429 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php @@ -6,6 +6,7 @@ use wcf\data\user\UserProfile; use wcf\system\cache\runtime\CommentRuntimeCache; use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\request\LinkHandler; +use wcf\system\user\notification\object\CommentResponseUserNotificationObject; use wcf\system\WCF; /** @@ -15,6 +16,8 @@ use wcf\system\WCF; * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\User\Notification\Event + * + * @method CommentResponseUserNotificationObject getUserNotificationObject() */ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent { /** @@ -26,7 +29,7 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare * @inheritDoc */ protected function prepare() { - CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID); + CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID); UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']); } @@ -49,7 +52,7 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare * @inheritDoc */ public function getMessage() { - $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID); if ($comment->userID) { $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID); } @@ -83,7 +86,7 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare * @inheritDoc */ public function getEmailMessage($notificationType = 'instant') { - $comment = new Comment($this->userNotificationObject->commentID); + $comment = new Comment($this->getUserNotificationObject()->commentID); $owner = new User($comment->objectID); if ($comment->userID) { $commentAuthor = new User($comment->userID); @@ -134,6 +137,6 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare * @inheritDoc */ public function getEventHash() { - return sha1($this->eventID . '-' . $this->userNotificationObject->commentID); + return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID); } } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php index 2f631d54c4..52cfecfe0e 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php @@ -2,6 +2,7 @@ namespace wcf\system\user\notification\event; use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\request\LinkHandler; +use wcf\system\user\notification\object\CommentUserNotificationObject; /** * User notification event for profile comments. @@ -10,6 +11,8 @@ use wcf\system\request\LinkHandler; * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\User\Notification\Event + * + * @method CommentUserNotificationObject getUserNotificationObject() */ class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent { /** @@ -21,7 +24,7 @@ class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotifica * @inheritDoc */ protected function prepare() { - UserProfileRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->objectID); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID); } /** @@ -68,7 +71,7 @@ class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotifica * @inheritDoc */ public function getEmailMessage($notificationType = 'instant') { - $user = UserProfileRuntimeCache::getInstance()->getObject($this->userNotificationObject->objectID); + $user = UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID); $authors = $this->getAuthors(); if (count($authors) > 1) { @@ -100,7 +103,7 @@ class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotifica * @inheritDoc */ public function getLink() { - return LinkHandler::getInstance()->getLink('User', ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->userNotificationObject->objectID)], '#wall'); + return LinkHandler::getInstance()->getLink('User', ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)], '#wall'); } /** -- 2.20.1