From b2aefd9b624f769eba4baf5d3b4043eaf1eba0d5 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 4 Jun 2026 12:43:44 +0200 Subject: [PATCH 1/2] Introduce Uid stub --- composer.json | 2 +- .../Symfony/StubFilesExtensionLoader.php | 4 ++ stubs/Symfony/Component/Uid/AbstractUid.stub | 41 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 stubs/Symfony/Component/Uid/AbstractUid.stub diff --git a/composer.json b/composer.json index 7dcc1e6b..bb449c6c 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "require": { "php": "^7.4 || ^8.0", "ext-simplexml": "*", - "phpstan/phpstan": "^2.1.13" + "phpstan/phpstan": "^2.2.0" }, "conflict": { "symfony/framework-bundle": "<3.0" diff --git a/src/Stubs/Symfony/StubFilesExtensionLoader.php b/src/Stubs/Symfony/StubFilesExtensionLoader.php index 9b4ea3be..685f058a 100644 --- a/src/Stubs/Symfony/StubFilesExtensionLoader.php +++ b/src/Stubs/Symfony/StubFilesExtensionLoader.php @@ -142,6 +142,10 @@ public function getFiles(): array $files[] = $stubsDir . '/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub'; } + if ($this->isInstalledVersionBelow('symfony/uuid', '8.2.0.0')) { + $files[] = $stubsDir . '/Symfony/Component/Uid/AbstractUuid.stub'; + } + if ($this->isInstalledVersionBelow('symfony/validator', '5.4.0.0')) { $files[] = $stubsDir . '/Symfony/Component/Validator/ConstraintViolationInterface.stub'; $files[] = $stubsDir . '/Symfony/Component/Validator/ConstraintViolationListInterface.stub'; diff --git a/stubs/Symfony/Component/Uid/AbstractUid.stub b/stubs/Symfony/Component/Uid/AbstractUid.stub new file mode 100644 index 00000000..17581887 --- /dev/null +++ b/stubs/Symfony/Component/Uid/AbstractUid.stub @@ -0,0 +1,41 @@ + Date: Thu, 25 Jun 2026 17:41:56 +0200 Subject: [PATCH 2/2] Add tests --- composer.json | 3 ++- tests/Type/Symfony/ExtensionTest.php | 2 ++ tests/Type/Symfony/data/uid.php | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/Type/Symfony/data/uid.php diff --git a/composer.json b/composer.json index bb449c6c..36c6d8a4 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "symfony/messenger": "^5.4", "symfony/polyfill-php80": "^1.24", "symfony/serializer": "^5.4", - "symfony/service-contracts": "^2.2.0" + "symfony/service-contracts": "^2.2.0", + "symfony/uid": "^5.4.0" }, "config": { "sort-packages": true diff --git a/tests/Type/Symfony/ExtensionTest.php b/tests/Type/Symfony/ExtensionTest.php index 7e965cf5..3fbbad33 100644 --- a/tests/Type/Symfony/ExtensionTest.php +++ b/tests/Type/Symfony/ExtensionTest.php @@ -76,6 +76,8 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/extension/with-configuration-with-constructor/WithConfigurationWithConstructorExtension.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/extension/with-configuration-with-constructor-optional-params/WithConfigurationWithConstructorOptionalParamsExtension.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/extension/with-configuration-with-constructor-required-params/WithConfigurationWithConstructorRequiredParamsExtension.php'); + + yield from $this->gatherAssertTypes(__DIR__ . '/data/uid.php'); } /** diff --git a/tests/Type/Symfony/data/uid.php b/tests/Type/Symfony/data/uid.php new file mode 100644 index 00000000..65b8eff9 --- /dev/null +++ b/tests/Type/Symfony/data/uid.php @@ -0,0 +1,14 @@ +toRfc4122()); +assertType('non-empty-string&non-decimal-int-string', $uuid->toHex()); +assertType('non-empty-string&non-decimal-int-string', $uuid->hash()); +assertType('non-empty-string&non-decimal-int-string', $uuid->toString()); +assertType('non-empty-string&non-decimal-int-string', $uuid->jsonSerialize());