Improve readability of `$instructions` fetch in PackageInstallationNodeBuilder::build...
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 18 Nov 2022 11:19:46 +0000 (12:19 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 18 Nov 2022 11:19:46 +0000 (12:19 +0100)
wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php

index 7f1649b4c35bb704210a5ec465300a65f7636968..66a271ade1dbe1dd08eda20256887bf63fabac76 100644 (file)
@@ -616,13 +616,22 @@ class PackageInstallationNodeBuilder
         $pluginNodes = [];
 
         $this->emptyNode = true;
-        $instructions = match ($this->installation->getAction()) {
-            'install' => $this->installation->getArchive()->getInstallInstructions(),
-            'update' => $this->installation->getArchive()->getUpdateInstructionsFor(
-                self::$pendingPackages[$this->installation->getPackage()->package]
-                ?? $this->installation->getPackage()->packageVersion
-            ) ?? [],
-        };
+
+        switch ($this->installation->getAction()) {
+            case 'install':
+                $instructions = $this->installation->getArchive()->getInstallInstructions();
+
+                break;
+            case 'update':
+                $package = $this->installation->getPackage();
+                $currentPackageVersion = self::$pendingPackages[$package->package] ?? $package->packageVersion;
+                $instructions = $this->installation->getArchive()->getUpdateInstructionsFor($currentPackageVersion) ?? [];
+
+                break;
+            default:
+                throw new \LogicException('Unreachable');
+        }
+
         $count = \count($instructions);
 
         if ($count === 0) {