diff --git a/typo3/sysext/core/Classes/Package/MetaData.php b/typo3/sysext/core/Classes/Package/MetaData.php
index 9cbe90a1cd078cac52ead08149ab8320ad77d833..f34a79f68a4858dc99b36b4e17512f21cd6ce524 100644
--- a/typo3/sysext/core/Classes/Package/MetaData.php
+++ b/typo3/sysext/core/Classes/Package/MetaData.php
@@ -40,7 +40,7 @@ class MetaData
     /**
      * Package type
      *
-     * @var string
+     * @var string|null
      */
     protected $packageType;
 
@@ -52,13 +52,13 @@ class MetaData
 
     /**
      * Package title
-     * @var ?string
+     * @var string|null
      */
     protected $title;
 
     /**
      * Package description
-     * @var string
+     * @var string|null
      */
     protected $description;
 
@@ -98,7 +98,7 @@ class MetaData
 
     public function isExtensionType(): bool
     {
-        return str_starts_with($this->packageType, 'typo3-cms-');
+        return is_string($this->packageType) && str_starts_with($this->packageType, 'typo3-cms-');
     }
 
     public function isFrameworkType(): bool
@@ -119,7 +119,7 @@ class MetaData
     /**
      * Set package type
      *
-     * @param string $packageType
+     * @param string|null $packageType
      */
     public function setPackageType($packageType)
     {
@@ -153,7 +153,7 @@ class MetaData
     }
 
     /**
-     * @return string The package description
+     * @return string|null The package description
      */
     public function getDescription()
     {
@@ -161,7 +161,7 @@ class MetaData
     }
 
     /**
-     * @param string $description The package description to set
+     * @param string|null $description The package description to set
      */
     public function setDescription($description)
     {
diff --git a/typo3/sysext/core/Tests/Unit/Package/MetaDataTest.php b/typo3/sysext/core/Tests/Unit/Package/MetaDataTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..67a3f119b36714b6f594fefe29eef6b11b09db2b
--- /dev/null
+++ b/typo3/sysext/core/Tests/Unit/Package/MetaDataTest.php
@@ -0,0 +1,66 @@
+<?php
+
+declare(strict_types=1);
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+namespace TYPO3\CMS\Core\Tests\Unit\Package;
+
+use TYPO3\CMS\Core\Package\MetaData;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+class MetaDataTest extends UnitTestCase
+{
+    public function typeIsCorrectlyResolvedDataProvider(): \Generator
+    {
+        yield 'framework type is set' => [
+            'typo3-cms-framework',
+            true,
+            true,
+        ];
+
+        yield 'extension type is set' => [
+            'typo3-cms-extension',
+            true,
+            false,
+        ];
+
+        yield 'no type is set' => [
+            null,
+            false,
+            false,
+        ];
+
+        yield 'other type is set' => [
+            'other',
+            false,
+            false,
+        ];
+    }
+
+    /**
+     * @param ?string $type
+     * @param bool $isExtension
+     * @param bool $isFramework
+     * @test
+     * @dataProvider typeIsCorrectlyResolvedDataProvider
+     */
+    public function typeIsCorrectlyResolved(?string $type, bool $isExtension, bool $isFramework): void
+    {
+        $metaData = new MetaData('foo');
+        $metaData->setPackageType($type);
+        self::assertSame($isExtension, $metaData->isExtensionType());
+        self::assertSame($isFramework, $metaData->isFrameworkType());
+    }
+}