Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Stubs/Symfony/StubFilesExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
41 changes: 41 additions & 0 deletions stubs/Symfony/Component/Uid/AbstractUid.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Symfony\Component\Uid\Exception\InvalidArgumentException;

abstract class AbstractUid
{
/**
* @var non-empty-string&non-decimal-int-string
*/
protected string $uid;

/**
* @return non-empty-string&non-decimal-int-string
*/
public function toRfc4122(): string;

/**
* @return non-empty-string&non-decimal-int-string
*/
public function toHex(): string;

/**
* @return non-empty-string&non-decimal-int-string
*/
public function hash(): string;

/**
* @return non-empty-string&non-decimal-int-string
*/
final public function toString(): string;

/**
* @return non-empty-string&non-decimal-int-string
*/
public function __toString(): string;

/**
* @return non-empty-string&non-decimal-int-string
*/
public function jsonSerialize(): string;
}
2 changes: 2 additions & 0 deletions tests/Type/Symfony/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/Type/Symfony/data/uid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace UuidStub;

use Symfony\Component\Uid\Uuid;
use function PHPStan\Testing\assertType;

$uuid = new Uuid::v4();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Suggested change
$uuid = new Uuid::v4();
$uuid = Uuid::v4();


assertType('non-empty-string&non-decimal-int-string', $uuid->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());
Loading