diff --git a/composer.json b/composer.json index 30f8772..c4276f4 100644 --- a/composer.json +++ b/composer.json @@ -27,10 +27,10 @@ "php-mock/php-mock-mockery": "^1.3", "php-parallel-lint/php-parallel-lint": "^1.1", "phpbench/phpbench": "^1.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-mockery": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.1", "phpunit/phpunit": "^8.5 || ^9", "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.5", diff --git a/composer.lock b/composer.lock index 4ae3dec..5ad7e31 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "17a6c6ec5c0033f9ffc148f102749aac", + "content-hash": "1bfc27346ea3fff9a474cf22336aea47", "packages": [ { "name": "brick/math", @@ -3125,20 +3125,20 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.99", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c", + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": "^7.2|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -3148,11 +3148,6 @@ "phpstan.phar" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - } - }, "autoload": { "files": [ "bootstrap.php" @@ -3165,7 +3160,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + "source": "https://github.com/phpstan/phpstan/tree/1.8.2" }, "funding": [ { @@ -3185,38 +3180,36 @@ "type": "tidelift" } ], - "time": "2021-09-12T20:09:55+00:00" + "time": "2022-07-20T09:57:31+00:00" }, { "name": "phpstan/phpstan-mockery", - "version": "0.12.14", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-mockery.git", - "reference": "7cc74bf434b3c2190f7f4cfc08c74f7c0b65667f" + "reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/7cc74bf434b3c2190f7f4cfc08c74f7c0b65667f", - "reference": "7cc74bf434b3c2190f7f4cfc08c74f7c0b65667f", + "url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/245b17ccd00f04be3c6b9fc6645f63793b37b2ea", + "reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.60" + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.5.0" }, "require-dev": { "mockery/mockery": "^1.2.4", + "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^0.12.16", - "phpstan/phpstan-strict-rules": "^0.12.5", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5" }, "type": "phpstan-extension", "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, "phpstan": { "includes": [ "extension.neon" @@ -3235,41 +3228,39 @@ "description": "PHPStan Mockery extension", "support": { "issues": "https://github.com/phpstan/phpstan-mockery/issues", - "source": "https://github.com/phpstan/phpstan-mockery/tree/0.12.14" + "source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.0" }, - "time": "2021-06-10T12:12:36+00:00" + "time": "2022-05-09T13:12:35+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "0.12.22", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc" + "reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc", - "reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4a3c437c09075736285d1cabb5c75bf27ed0bc84", + "reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.92" + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.5.0" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { + "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^0.12.6", + "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5" }, "type": "phpstan-extension", "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, "phpstan": { "includes": [ "extension.neon", @@ -3289,9 +3280,9 @@ "description": "PHPUnit extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.22" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.1.1" }, - "time": "2021-08-12T10:53:43+00:00" + "time": "2022-04-20T15:24:25+00:00" }, { "name": "phpunit/php-code-coverage", @@ -6543,5 +6534,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8b57bf0..d31b470 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,6 +17,8 @@ parameters: count: 9 path: ./src/Lazy/LazyUuidFromString.php - - message: '#^Result of \|\| is always false\.$#' + message: '#^Property Ramsey\\Uuid\\FeatureSet::\$disableBigNumber is never read, only written#' count: 1 - path: ./src/Type/Time.php + path: ./src/FeatureSet.php + + - '#^Method Ramsey\\Uuid\\Generator\\Pecl[A-Za-z]+Generator::generate\(\) should return string but returns string\|false\.$#' diff --git a/src/FeatureSet.php b/src/FeatureSet.php index 6683666..819f99a 100644 --- a/src/FeatureSet.php +++ b/src/FeatureSet.php @@ -127,7 +127,7 @@ class FeatureSet private $timeGenerator; /** - * @var TimeProviderInterface + * @var TimeProviderInterface|null */ private $timeProvider; @@ -292,7 +292,10 @@ class FeatureSet public function setNodeProvider(NodeProviderInterface $nodeProvider): void { $this->nodeProvider = $nodeProvider; - $this->timeGenerator = $this->buildTimeGenerator($this->timeProvider); + + if (isset($this->timeProvider)) { + $this->timeGenerator = $this->buildTimeGenerator($this->timeProvider); + } } /** diff --git a/src/Fields/SerializableFieldsTrait.php b/src/Fields/SerializableFieldsTrait.php index 16e6525..a2a89c6 100644 --- a/src/Fields/SerializableFieldsTrait.php +++ b/src/Fields/SerializableFieldsTrait.php @@ -71,7 +71,7 @@ trait SerializableFieldsTrait } /** - * @param array{bytes: string} $data + * @param array{bytes?: string} $data */ public function __unserialize(array $data): void { diff --git a/src/Generator/RandomGeneratorInterface.php b/src/Generator/RandomGeneratorInterface.php index 5c83cb4..1180b97 100644 --- a/src/Generator/RandomGeneratorInterface.php +++ b/src/Generator/RandomGeneratorInterface.php @@ -22,7 +22,7 @@ interface RandomGeneratorInterface /** * Generates a string of randomized binary data * - * @param int $length The number of bytes of random binary data to generate + * @param int<1, max> $length The number of bytes of random binary data to generate * * @return string A binary string */ diff --git a/src/Lazy/LazyUuidFromString.php b/src/Lazy/LazyUuidFromString.php index 8ba7579..1ff1662 100644 --- a/src/Lazy/LazyUuidFromString.php +++ b/src/Lazy/LazyUuidFromString.php @@ -115,9 +115,9 @@ final class LazyUuidFromString implements UuidInterface } /** - * @param array{string: string} $data + * @param array{string?: string} $data * - * @psalm-param array{string: non-empty-string} $data + * @psalm-param array{string?: non-empty-string} $data */ public function __unserialize(array $data): void { diff --git a/src/Provider/Dce/SystemDceSecurityProvider.php b/src/Provider/Dce/SystemDceSecurityProvider.php index 7ff4076..c53b839 100644 --- a/src/Provider/Dce/SystemDceSecurityProvider.php +++ b/src/Provider/Dce/SystemDceSecurityProvider.php @@ -42,6 +42,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface */ public function getUid(): IntegerObject { + /** @var int|float|string|IntegerObject|null $uid */ static $uid = null; if ($uid instanceof IntegerObject) { @@ -72,6 +73,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface */ public function getGid(): IntegerObject { + /** @var int|float|string|IntegerObject|null $gid */ static $gid = null; if ($gid instanceof IntegerObject) { @@ -150,7 +152,13 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface */ private function getOs(): string { - return strtoupper(substr(constant('PHP_OS'), 0, 3)); + /** + * @psalm-suppress UnnecessaryVarAnnotation + * @var string $phpOs + */ + $phpOs = constant('PHP_OS'); + + return strtoupper(substr($phpOs, 0, 3)); } /** diff --git a/src/Provider/Node/SystemNodeProvider.php b/src/Provider/Node/SystemNodeProvider.php index d512f22..d0a1e69 100644 --- a/src/Provider/Node/SystemNodeProvider.php +++ b/src/Provider/Node/SystemNodeProvider.php @@ -27,8 +27,8 @@ use function ob_start; use function preg_match; use function preg_match_all; use function reset; +use function str_contains; use function str_replace; -use function strpos; use function strtolower; use function strtoupper; use function substr; @@ -100,12 +100,18 @@ class SystemNodeProvider implements NodeProviderInterface { $disabledFunctions = strtolower((string) ini_get('disable_functions')); - if (strpos($disabledFunctions, 'passthru') !== false) { + if (str_contains($disabledFunctions, 'passthru')) { return ''; } + /** + * @psalm-suppress UnnecessaryVarAnnotation + * @var string $phpOs + */ + $phpOs = constant('PHP_OS'); + ob_start(); - switch (strtoupper(substr(constant('PHP_OS'), 0, 3))) { + switch (strtoupper(substr($phpOs, 0, 3))) { case 'WIN': passthru('ipconfig /all 2>&1'); @@ -142,13 +148,20 @@ class SystemNodeProvider implements NodeProviderInterface { $mac = ''; - if (strtoupper(constant('PHP_OS')) === 'LINUX') { + /** + * @psalm-suppress UnnecessaryVarAnnotation + * @var string $phpOs + */ + $phpOs = constant('PHP_OS'); + + if (strtoupper($phpOs) === 'LINUX') { $addressPaths = glob('/sys/class/net/*/address', GLOB_NOSORT); if ($addressPaths === false || count($addressPaths) === 0) { return ''; } + /** @var array $macs */ $macs = []; array_walk($addressPaths, function (string $addressPath) use (&$macs): void { @@ -157,7 +170,10 @@ class SystemNodeProvider implements NodeProviderInterface } }); - $macs = array_map('trim', $macs); + /** @var callable $trim */ + $trim = 'trim'; + + $macs = array_map($trim, $macs); // Remove invalid entries. $macs = array_filter($macs, function (string $address) { @@ -165,6 +181,7 @@ class SystemNodeProvider implements NodeProviderInterface && preg_match(self::SYSFS_PATTERN, $address); }); + /** @var string|bool $mac */ $mac = reset($macs); } diff --git a/src/Type/Decimal.php b/src/Type/Decimal.php index 10f9384..0c42e63 100644 --- a/src/Type/Decimal.php +++ b/src/Type/Decimal.php @@ -19,6 +19,7 @@ use ValueError; use function is_numeric; use function sprintf; +use function str_starts_with; /** * A value object representing a decimal @@ -45,7 +46,7 @@ final class Decimal implements NumberInterface private $isNegative = false; /** - * @param mixed $value The decimal value to store + * @param int|float|string|self $value The decimal value to store */ public function __construct($value) { @@ -59,7 +60,7 @@ final class Decimal implements NumberInterface } // Remove the leading +-symbol. - if (strpos($value, '+') === 0) { + if (str_starts_with($value, '+')) { $value = substr($value, 1); } @@ -68,7 +69,7 @@ final class Decimal implements NumberInterface $value = '0'; } - if (strpos($value, '-') === 0) { + if (str_starts_with($value, '-')) { $this->isNegative = true; } @@ -122,7 +123,7 @@ final class Decimal implements NumberInterface } /** - * @param array{string: string} $data + * @param array{string?: string} $data */ public function __unserialize(array $data): void { diff --git a/src/Type/Hexadecimal.php b/src/Type/Hexadecimal.php index 88adc2e..fee0f85 100644 --- a/src/Type/Hexadecimal.php +++ b/src/Type/Hexadecimal.php @@ -101,7 +101,7 @@ final class Hexadecimal implements TypeInterface } /** - * @param array{string: string} $data + * @param array{string?: string} $data */ public function __unserialize(array $data): void { diff --git a/src/Type/Integer.php b/src/Type/Integer.php index 7690f6c..e786efe 100644 --- a/src/Type/Integer.php +++ b/src/Type/Integer.php @@ -20,7 +20,7 @@ use ValueError; use function ctype_digit; use function ltrim; use function sprintf; -use function strpos; +use function str_starts_with; use function substr; /** @@ -48,7 +48,7 @@ final class Integer implements NumberInterface private $isNegative = false; /** - * @param mixed $value The integer value to store + * @param int|float|string|self $value The integer value to store */ public function __construct($value) { @@ -56,7 +56,7 @@ final class Integer implements NumberInterface $sign = '+'; // If the value contains a sign, remove it for ctype_digit() check. - if (strpos($value, '-') === 0 || strpos($value, '+') === 0) { + if (str_starts_with($value, '-') || str_starts_with($value, '+')) { $sign = substr($value, 0, 1); $value = substr($value, 1); } @@ -138,7 +138,7 @@ final class Integer implements NumberInterface } /** - * @param array{string: string} $data + * @param array{string?: string} $data */ public function __unserialize(array $data): void { diff --git a/src/Type/Time.php b/src/Type/Time.php index dd1b8bc..f9c72b5 100644 --- a/src/Type/Time.php +++ b/src/Type/Time.php @@ -17,7 +17,6 @@ namespace Ramsey\Uuid\Type; use Ramsey\Uuid\Exception\UnsupportedOperationException; use Ramsey\Uuid\Type\Integer as IntegerObject; use ValueError; -use stdClass; use function json_decode; use function json_encode; @@ -45,8 +44,8 @@ final class Time implements TypeInterface private $microseconds; /** - * @param mixed $seconds - * @param mixed $microseconds + * @param int|float|string|IntegerObject $seconds + * @param int|float|string|IntegerObject $microseconds */ public function __construct($seconds, $microseconds = 0) { @@ -111,20 +110,20 @@ final class Time implements TypeInterface */ public function unserialize($serialized): void { - /** @var stdClass $time */ - $time = json_decode($serialized); + /** @var array{seconds?: int|float|string, microseconds?: int|float|string} $time */ + $time = json_decode($serialized, true); - if (!isset($time->seconds) || !isset($time->microseconds)) { + if (!isset($time['seconds']) || !isset($time['microseconds'])) { throw new UnsupportedOperationException( 'Attempted to unserialize an invalid value' ); } - $this->__construct($time->seconds, $time->microseconds); + $this->__construct($time['seconds'], $time['microseconds']); } /** - * @param array{seconds: string, microseconds: string} $data + * @param array{seconds?: string, microseconds?: string} $data */ public function __unserialize(array $data): void { diff --git a/src/Uuid.php b/src/Uuid.php index 1a439b7..12afc9f 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -324,7 +324,7 @@ class Uuid implements UuidInterface } /** - * @param array{bytes: string} $data + * @param array{bytes?: string} $data */ public function __unserialize(array $data): void { diff --git a/tests/Codec/OrderedTimeCodecTest.php b/tests/Codec/OrderedTimeCodecTest.php index 7a690eb..1cc2f8b 100644 --- a/tests/Codec/OrderedTimeCodecTest.php +++ b/tests/Codec/OrderedTimeCodecTest.php @@ -242,6 +242,8 @@ class OrderedTimeCodecTest extends TestCase ); $decoded = $codec->decode($expected); $serialized = serialize($decoded); + + /** @var UuidInterface $unserializedUuid */ $unserializedUuid = unserialize($serialized); $expectedUuid = Uuid::fromString($expected); diff --git a/tests/Generator/CombGeneratorTest.php b/tests/Generator/CombGeneratorTest.php index dd43d4a..3be4ba5 100644 --- a/tests/Generator/CombGeneratorTest.php +++ b/tests/Generator/CombGeneratorTest.php @@ -87,7 +87,7 @@ class CombGeneratorTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function lengthLessThanSix(): array { @@ -95,6 +95,8 @@ class CombGeneratorTest extends TestCase } /** + * @param int<1, max> $length + * * @throws Exception * * @dataProvider lengthLessThanSix diff --git a/tests/Generator/DceSecurityGeneratorTest.php b/tests/Generator/DceSecurityGeneratorTest.php index 378a04c..71e0c29 100644 --- a/tests/Generator/DceSecurityGeneratorTest.php +++ b/tests/Generator/DceSecurityGeneratorTest.php @@ -28,10 +28,10 @@ use function substr; class DceSecurityGeneratorTest extends TestCase { /** - * @param mixed $uid - * @param mixed $gid - * @param mixed $seconds - * @param mixed $microseconds + * @param int|string $uid + * @param int|string $gid + * @param int|string $seconds + * @param int|string $microseconds * * @dataProvider provideValuesForDceSecurityGenerator */ @@ -49,11 +49,13 @@ class DceSecurityGeneratorTest extends TestCase string $expectedNode, string $expectedTimeMidHi ): void { + /** @var DceSecurityProviderInterface $dceSecurityProvider */ $dceSecurityProvider = Mockery::mock(DceSecurityProviderInterface::class, [ 'getUid' => new IntegerObject($uid), 'getGid' => new IntegerObject($gid), ]); + /** @var NodeProviderInterface $nodeProvider */ $nodeProvider = Mockery::mock(NodeProviderInterface::class, [ 'getNode' => new Hexadecimal($node), ]); @@ -76,7 +78,7 @@ class DceSecurityGeneratorTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideValuesForDceSecurityGenerator(): array { diff --git a/tests/Generator/RandomBytesGeneratorTest.php b/tests/Generator/RandomBytesGeneratorTest.php index 1b09b07..d3e5c0c 100644 --- a/tests/Generator/RandomBytesGeneratorTest.php +++ b/tests/Generator/RandomBytesGeneratorTest.php @@ -27,6 +27,8 @@ class RandomBytesGeneratorTest extends TestCase } /** + * @param int<1, max> $length + * * @throws Exception * * @dataProvider lengthAndHexDataProvider diff --git a/tests/Guid/FieldsTest.php b/tests/Guid/FieldsTest.php index 4924e55..5c363db 100644 --- a/tests/Guid/FieldsTest.php +++ b/tests/Guid/FieldsTest.php @@ -196,6 +196,8 @@ class FieldsTest extends TestCase $fields = new Fields($bytes); $serializedFields = serialize($fields); + + /** @var Fields $unserializedFields */ $unserializedFields = unserialize($serializedFields); $this->assertSame($fields->getBytes(), $unserializedFields->getBytes()); diff --git a/tests/Nonstandard/FieldsTest.php b/tests/Nonstandard/FieldsTest.php index 319896a..bb51fcc 100644 --- a/tests/Nonstandard/FieldsTest.php +++ b/tests/Nonstandard/FieldsTest.php @@ -72,6 +72,8 @@ class FieldsTest extends TestCase $fields = new Fields($bytes); $serializedFields = serialize($fields); + + /** @var Fields $unserializedFields */ $unserializedFields = unserialize($serializedFields); $this->assertSame($fields->getBytes(), $unserializedFields->getBytes()); diff --git a/tests/Rfc4122/FieldsTest.php b/tests/Rfc4122/FieldsTest.php index eb84dee..b34a3d3 100644 --- a/tests/Rfc4122/FieldsTest.php +++ b/tests/Rfc4122/FieldsTest.php @@ -207,6 +207,8 @@ class FieldsTest extends TestCase $fields = new Fields($bytes); $serializedFields = serialize($fields); + + /** @var Fields $unserializedFields */ $unserializedFields = unserialize($serializedFields); $this->assertSame($fields->getBytes(), $unserializedFields->getBytes()); @@ -217,6 +219,8 @@ class FieldsTest extends TestCase $fields = new Fields("\xb3\xcd\x58\x6a\xe3\xca\x44\xf3\x98\x8c\xf4\xd6\x66\xc1\xbf\x4d"); $serializedFields = 'C:26:"Ramsey\Uuid\Rfc4122\Fields":24:{s81YauPKRPOYjPTWZsG/TQ==}'; + + /** @var Fields $unserializedFields */ $unserializedFields = unserialize($serializedFields); $this->assertSame($fields->getBytes(), $unserializedFields->getBytes()); diff --git a/tests/Type/DecimalTest.php b/tests/Type/DecimalTest.php index 6870069..30c5e9a 100644 --- a/tests/Type/DecimalTest.php +++ b/tests/Type/DecimalTest.php @@ -16,7 +16,7 @@ use function unserialize; class DecimalTest extends TestCase { /** - * @param int|float|string $value + * @param int|float|string|Decimal $value * * @dataProvider provideDecimal */ @@ -30,7 +30,7 @@ class DecimalTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideDecimal(): array { @@ -260,7 +260,7 @@ class DecimalTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideDecimalBadValues(): array { @@ -275,7 +275,7 @@ class DecimalTest extends TestCase } /** - * @param mixed $value + * @param float|int|string|Decimal $value * * @dataProvider provideDecimal */ @@ -283,13 +283,15 @@ class DecimalTest extends TestCase { $decimal = new Decimal($value); $serializedDecimal = serialize($decimal); + + /** @var Decimal $unserializedDecimal */ $unserializedDecimal = unserialize($serializedDecimal); $this->assertSame($expected, $unserializedDecimal->toString()); } /** - * @param mixed $value + * @param float|int|string|Decimal $value * * @dataProvider provideDecimal */ diff --git a/tests/Type/HexadecimalTest.php b/tests/Type/HexadecimalTest.php index 2a3112c..11cfffb 100644 --- a/tests/Type/HexadecimalTest.php +++ b/tests/Type/HexadecimalTest.php @@ -27,7 +27,7 @@ class HexadecimalTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideHex(): array { @@ -61,7 +61,7 @@ class HexadecimalTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideHexBadValues(): array { @@ -74,25 +74,23 @@ class HexadecimalTest extends TestCase } /** - * @param mixed $value - * * @dataProvider provideHex */ - public function testSerializeUnserializeHexadecimal($value, string $expected): void + public function testSerializeUnserializeHexadecimal(string $value, string $expected): void { $hexadecimal = new Hexadecimal($value); $serializedHexadecimal = serialize($hexadecimal); + + /** @var Hexadecimal $unserializedHexadecimal */ $unserializedHexadecimal = unserialize($serializedHexadecimal); $this->assertSame($expected, $unserializedHexadecimal->toString()); } /** - * @param mixed $value - * * @dataProvider provideHex */ - public function testJsonSerialize($value, string $expected): void + public function testJsonSerialize(string $value, string $expected): void { $hexadecimal = new Hexadecimal($value); $expectedJson = sprintf('"%s"', $expected); diff --git a/tests/Type/IntegerTest.php b/tests/Type/IntegerTest.php index c57e656..02a3e96 100644 --- a/tests/Type/IntegerTest.php +++ b/tests/Type/IntegerTest.php @@ -16,7 +16,7 @@ use function unserialize; class IntegerTest extends TestCase { /** - * @param int|float|string $value + * @param int|float|string|IntegerObject $value * * @dataProvider provideInteger */ @@ -30,7 +30,7 @@ class IntegerTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideInteger(): array { @@ -175,7 +175,7 @@ class IntegerTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideIntegerBadValues(): array { @@ -195,7 +195,7 @@ class IntegerTest extends TestCase } /** - * @param mixed $value + * @param int|float|string|IntegerObject $value * * @dataProvider provideInteger */ @@ -203,13 +203,15 @@ class IntegerTest extends TestCase { $integer = new IntegerObject($value); $serializedInteger = serialize($integer); + + /** @var IntegerObject $unserializedInteger */ $unserializedInteger = unserialize($serializedInteger); $this->assertSame($expected, $unserializedInteger->toString()); } /** - * @param mixed $value + * @param int|float|string|IntegerObject $value * * @dataProvider provideInteger */ diff --git a/tests/Type/TimeTest.php b/tests/Type/TimeTest.php index a81b43f..98287e6 100644 --- a/tests/Type/TimeTest.php +++ b/tests/Type/TimeTest.php @@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Type; use Ramsey\Uuid\Exception\UnsupportedOperationException; use Ramsey\Uuid\Test\TestCase; +use Ramsey\Uuid\Type\Integer as IntegerObject; use Ramsey\Uuid\Type\Time; use function json_encode; @@ -15,8 +16,8 @@ use function unserialize; class TimeTest extends TestCase { /** - * @param int|float|string $seconds - * @param int|float|string|null $microseconds + * @param int|float|string|IntegerObject $seconds + * @param int|float|string|IntegerObject|null $microseconds * * @dataProvider provideTimeValues */ @@ -45,7 +46,7 @@ class TimeTest extends TestCase } /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + * @return array */ public function provideTimeValues(): array { @@ -62,8 +63,8 @@ class TimeTest extends TestCase } /** - * @param int|float|string $seconds - * @param int|float|string|null $microseconds + * @param int|float|string|IntegerObject $seconds + * @param int|float|string|IntegerObject|null $microseconds * * @dataProvider provideTimeValues */ @@ -76,6 +77,8 @@ class TimeTest extends TestCase $time = new Time(...$params); $serializedTime = serialize($time); + + /** @var Time $unserializedTime */ $unserializedTime = unserialize($serializedTime); $this->assertSame((string) $seconds, $unserializedTime->getSeconds()->toString()); @@ -97,8 +100,8 @@ class TimeTest extends TestCase } /** - * @param int|float|string $seconds - * @param int|float|string|null $microseconds + * @param int|float|string|IntegerObject $seconds + * @param int|float|string|IntegerObject|null $microseconds * * @dataProvider provideTimeValues */ diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 2ebac1d..c2313b7 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -1539,7 +1539,10 @@ class UuidTest extends TestCase { $uuid = Uuid::uuid4(); $serialized = serialize($uuid); + + /** @var UuidInterface $unserializedUuid */ $unserializedUuid = unserialize($serialized); + $this->assertTrue($uuid->equals($unserializedUuid)); }