Fix warnings about local variables that might not have been defined
authorMatthias Schmidt <gravatronics@live.com>
Fri, 27 May 2016 07:26:25 +0000 (09:26 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 27 May 2016 09:48:12 +0000 (11:48 +0200)
16 files changed:
wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php
wcfsetup/install/files/lib/acp/form/UserEditForm.class.php
wcfsetup/install/files/lib/action/ImageProxyAction.class.php
wcfsetup/install/files/lib/form/AvatarEditForm.class.php
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/acl/ACLHandler.class.php
wcfsetup/install/files/lib/system/box/UserListBoxController.class.php
wcfsetup/install/files/lib/system/cli/command/PackageCLICommand.class.php
wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php
wcfsetup/install/files/lib/system/importer/UserImporter.class.php
wcfsetup/install/files/lib/system/label/LabelHandler.class.php
wcfsetup/install/files/lib/system/like/LikeHandler.class.php
wcfsetup/install/files/lib/system/moderation/queue/report/CommentResponseModerationQueueReportHandler.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php
wcfsetup/install/files/lib/util/DateUtil.class.php

index fbb317ab0c8093523d7146bb2d6fe107a90e9590..c26dce79bafb30054aa12cf4ce2b9f8a47f9dc01 100755 (executable)
@@ -156,6 +156,7 @@ class PackageStartInstallForm extends AbstractForm {
                // obey foreign key
                $packageID = ($this->package) ? $this->package->packageID : null;
                
+               $archive = null;
                if ($this->stylePackageImportLocation) {
                        $archive = $this->stylePackageImportLocation;
                }
index 9d55db62d51335beeaa605ad2bfb03098eac6c7a..ad011ba9e7eaec85d80414c4d448b6b6c0d2f06c 100755 (executable)
@@ -246,6 +246,8 @@ class UserEditForm extends UserAddForm {
                                $action->executeAction();
                        }
                }
+               
+               $avatarData = [];
                switch ($this->avatarType) {
                        case 'none':
                                $avatarData = [
index 84a18b82e90ab68fab89ebcb1d742508a512821a..477a3050884b2459f18fa4b36f343c908e5e2462 100644 (file)
@@ -50,6 +50,7 @@ class ImageProxyAction extends AbstractAction {
                        // prepare path
                        $fileExtension = pathinfo($url, PATHINFO_EXTENSION);
                        $fileLocation = WCF_DIR.'images/proxy/'.substr($fileName, 0, 2).'/'.$fileName.($fileExtension ? '.'.$fileExtension : '');
+                       $imageData = getimagesize($fileLocation);
                        $dir = dirname($fileLocation);
                        if (!@file_exists($dir)) {
                                FileUtil::makePath($dir);
index 8fb7532c9a9d0847e672714d588707e6ee22aee8..cc93bd58dc11d3ef5f8fb803bad0966471c52844 100644 (file)
@@ -92,6 +92,7 @@ class AvatarEditForm extends AbstractForm {
                }
                
                // update user
+               $data = [];
                switch ($this->avatarType) {
                        case 'none':
                                $data = [
@@ -99,13 +100,13 @@ class AvatarEditForm extends AbstractForm {
                                        'enableGravatar' => 0
                                ];
                        break;
-                               
+                       
                        case 'custom':
                                $data = [
                                        'enableGravatar' => 0
                                ];
                        break;
-                               
+                       
                        case 'gravatar':
                                $data = [
                                        'avatarID' => null,
index b08da629c5db6aa902b503aae7e750281b92edc5..9b64510fc2e10ce3eaa76d7e613edd27bf6ca611 100644 (file)
@@ -1184,6 +1184,7 @@ class WCFSetup extends WCF {
                                }
                                
                                $queueIDs = [];
+                               /** @noinspection PhpUndefinedVariableInspection */
                                $queueID = $queue->queueID;
                                while ($queueID) {
                                        $queueIDs[] = $queueID;
@@ -1213,6 +1214,7 @@ class WCFSetup extends WCF {
                                throw new SystemException('', 0, '', $e);
                        }
                        
+                       /** @noinspection PhpUndefinedVariableInspection */
                        $queue = PackageInstallationQueueEditor::create([
                                'parentQueueID' => $queue->queueID,
                                'processNo' => $processNo,
index 73d23c06667c26020c4f44a2f00a9dc675390b77..634ec0a90a35f2a56869da5d7f9c38baa5cd7a27 100644 (file)
@@ -58,6 +58,7 @@ class ACLHandler extends SingletonFactory {
                        
                        $data = $this->getPermissions($objectTypeID, [], null, true);
                        
+                       $users = [];
                        foreach ($values as $type => $optionData) {
                                if ($type === 'user') {
                                        $users = User::getUsers(array_keys($optionData));
index 9b5fa4a69c567317adb8aa24a8761116508a5376..43ac9fcdf9d378bb8ba879a52bae8dd2637842c7 100644 (file)
@@ -102,6 +102,7 @@ class UserListBoxController extends AbstractDatabaseObjectListBoxController {
         * @inheritDoc
         */
        protected function getTemplate() {
+               $userProfiles = [];
                if ($this->userIDs !== null) {
                        $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($this->userIDs);
                        
index 5697256b4621d511b61a164fc327cb092f86c947..b4fb52ae47aa85eefc380674d04b9081aa70e793 100644 (file)
@@ -286,6 +286,8 @@ class PackageCLICommand implements IArgumentedCLICommand {
                        }
                        $installation = new PackageInstallationDispatcher($queue);
                        
+                       $progress = 0;
+                       $currentAction = '';
                        switch ($step) {
                                case 'prepare':
                                        // InstallPackageAction::stepPrepare()
index 42ca44c8d7d093ad24b732a54edf3d6dd98f169e..88319d707e83682a116f57b05c49892d9b57910a 100644 (file)
@@ -162,6 +162,7 @@ class WorkerCLICommand implements IArgumentedCLICommand {
                        }
                        
                        $docComment = explode("\n", StringUtil::unifyNewlines($reflection->getDocComment()));
+                       $comment = '';
                        foreach ($docComment as $commentLine) {
                                if (Regex::compile('[a-z]', Regex::CASE_INSENSITIVE)->match($commentLine)) {
                                        $comment = Regex::compile('^[^a-z]+', Regex::CASE_INSENSITIVE)->replace($commentLine, '');
index ec3ddcdb351212e80128fa9cc9efc634f8454f43..07a859670dadcadf1306c81dd212bf013ff9a0bf 100644 (file)
@@ -60,6 +60,8 @@ class UserImporter extends AbstractImporter {
         * @inheritDoc
         */
        public function import($oldID, array $data, array $additionalData = []) {
+               $targetUser = null;
+               
                // whether to perform a merge
                $performMerge = false;
                
index 3dad7efac3c766e0d34662f5d231fa8ebd497589..98abbc333be57bca04eecbc317619356f425156c 100644 (file)
@@ -282,6 +282,7 @@ class LabelHandler extends SingletonFactory {
        public function getLabelGroups(array $groupIDs = [], $validatePermissions = true, $permission = 'canSetLabel') {
                $data = [];
                
+               $optionID = null;
                if ($validatePermissions) {
                        $optionID = $this->getOptionID($permission);
                        if ($optionID === null) {
index 8b800bbf52bba266e474efaec647c90524db9802..bae82be8b4892e98f8b9e2e4c8147d0530fee2aa 100644 (file)
@@ -170,16 +170,16 @@ class LikeHandler extends SingletonFactory {
                        return $this->revertLike($like, $likeable, $likeObject, $user);
                }
                
+               // like data
+               /** @noinspection PhpUnusedLocalVariableInspection */
+               $cumulativeLikes = 0;
+               /** @noinspection PhpUnusedLocalVariableInspection */
+               $newValue = $oldValue = null;
+               $users = [];
+               
                try {
                        WCF::getDB()->beginTransaction();
                        
-                       // like data
-                       /** @noinspection PhpUnusedLocalVariableInspection */
-                       $cumulativeLikes = 0;
-                       /** @noinspection PhpUnusedLocalVariableInspection */
-                       $newValue = $oldValue = null;
-                       $users = [];
-                       
                        // update existing object
                        if ($likeObject->likeObjectID) {
                                $likes = $likeObject->likes;
@@ -340,6 +340,8 @@ class LikeHandler extends SingletonFactory {
         * @return      array
         */
        public function revertLike(Like $like, ILikeObject $likeable, LikeObject $likeObject, User $user) {
+               $usersArray = [];
+               
                try {
                        WCF::getDB()->beginTransaction();
                        
@@ -369,7 +371,6 @@ class LikeHandler extends SingletonFactory {
                        ];
                        
                        $users = $likeObject->getUsers();
-                       $usersArray = [];
                        foreach ($users as $user2) {
                                $usersArray[$user2->userID] = ['userID' => $user2->userID, 'username' => $user2->username];
                        }
index ed4211543a96d3b6b9d6ad415399e2e2edd3263d..a5c286e98e76faef1cd8ebcbb340c46c951de077 100644 (file)
@@ -163,6 +163,7 @@ class CommentResponseModerationQueueReportHandler extends CommentCommentModerati
                        }
                }
                
+               $comments = [];
                if (!empty($commentIDs)) {
                        $comments = CommentRuntimeCache::getInstance()->getObjects($commentIDs);
                }
index 91212ae5f711f0643c17660075f91959e325b901..9e3eb9c78b2b49fb21be66cdf77c30d4da46a640 100644 (file)
@@ -186,6 +186,7 @@ class PackageInstallationScheduler {
                                        // sort multiple instances by version number
                                        uasort($installedPackages[$row['package']], [Package::class, 'compareVersion']);
                                        
+                                       $packageID = 0;
                                        foreach ($installedPackages[$row['package']] as $packageID => $packageVersion) {
                                                if (empty($row['minversion']) || Package::compareVersion($row['minversion'], $packageVersion, '<=')) {
                                                        continue 2;
index a59ff5b1aca7d398d08d7b0e9046cc83e509f973..d62863893e776c5c31e873b76c9810d167f7f15a 100644 (file)
@@ -199,6 +199,7 @@ class TemplateScriptingCompiler {
         * @throws      SystemException
         */
        public function compileString($identifier, $sourceContent, array $metaData = [], $isolated = false) {
+               $previousData = [];
                if ($isolated) {
                        $previousData = [
                                'autoloadPlugins' => $this->autoloadPlugins,
index 816359db4f3b9a7dc7a34bcd893468bd49c03ad8..e85322782bf15160d999ff69ba6d0abcecc0a2d1 100644 (file)
@@ -193,6 +193,8 @@ final class DateUtil {
                $weeks = floor($days / 7);
                $hours = $interval->format('%h');
                $minutes = $interval->format('%i');
+               
+               $direction = '';
                switch ($interval->format('%R')) {
                        case '+':
                                $direction = 'past';