chore(deps-dev): upgrade PHPStan

This commit is contained in:
Ben Ramsey
2025-05-25 16:52:53 -05:00
parent 691c2c816e
commit 76cbc566e2
57 changed files with 447 additions and 422 deletions
+5 -8
View File
@@ -26,10 +26,10 @@
"php-mock/php-mock-mockery": "^1.3",
"php-parallel-lint/php-parallel-lint": "^1.4.0",
"phpbench/phpbench": "^1.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-mockery": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^8.5 || ^9",
"slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.5"
@@ -83,10 +83,7 @@
"phpbench": "phpbench run",
"phpcbf": "phpcbf -vpw --cache=build/cache/phpcs.cache",
"phpcs": "phpcs --cache=build/cache/phpcs.cache",
"phpstan": [
"phpstan analyse --no-progress --memory-limit=1G",
"phpstan analyse -c phpstan-tests.neon --no-progress --memory-limit=1G"
],
"phpstan": "phpstan analyse --memory-limit=1G",
"phpunit": "phpunit --verbose --colors=always",
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
"test": [
Generated
+50 -48
View File
@@ -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": "8a871cc8547137334b735ea98dd9cc28",
"content-hash": "cbda15fd74ceae31bed05f16b0493a76",
"packages": [
{
"name": "brick/math",
@@ -2103,28 +2103,27 @@
},
{
"name": "phpstan/extension-installer",
"version": "1.1.0",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/extension-installer.git",
"reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051"
"reference": "85e90b3942d06b2326fba0403ec24fe912372936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051",
"reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1 || ^2.0",
"php": "^7.1 || ^8.0",
"phpstan/phpstan": ">=0.11.6"
"composer-plugin-api": "^2.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.9.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.8",
"phing/phing": "^2.16.3",
"composer/composer": "^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12"
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
},
"type": "composer-plugin",
"extra": {
@@ -2140,11 +2139,15 @@
"MIT"
],
"description": "Composer plugin for automatic installation of PHPStan extensions",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.1.0"
"source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
},
"time": "2020-12-13T13:06:13+00:00"
"time": "2024-09-04T20:21:43+00:00"
},
{
"name": "phpstan/phpdoc-parser",
@@ -2193,20 +2196,20 @@
},
{
"name": "phpstan/phpstan",
"version": "1.8.5",
"version": "2.1.17",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "f6598a5ff12ca4499a836815e08b4d77a2ddeb20"
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f6598a5ff12ca4499a836815e08b4d77a2ddeb20",
"reference": "f6598a5ff12ca4499a836815e08b4d77a2ddeb20",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/89b5ef665716fa2a52ecd2633f21007a6a349053",
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@@ -2231,8 +2234,11 @@
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.8.5"
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
@@ -2242,39 +2248,34 @@
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2022-09-07T16:05:32+00:00"
"time": "2025-05-21T20:55:28+00:00"
},
{
"name": "phpstan/phpstan-mockery",
"version": "1.1.0",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-mockery.git",
"reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea"
"reference": "89a949d0ac64298e88b7c7fa00caee565c198394"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/245b17ccd00f04be3c6b9fc6645f63793b37b2ea",
"reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea",
"url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/89a949d0ac64298e88b7c7fa00caee565c198394",
"reference": "89a949d0ac64298e88b7c7fa00caee565c198394",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.5.0"
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0"
},
"require-dev": {
"mockery/mockery": "^1.2.4",
"nikic/php-parser": "^4.13.0",
"mockery/mockery": "^1.6.11",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6"
},
"type": "phpstan-extension",
"extra": {
@@ -2296,36 +2297,37 @@
"description": "PHPStan Mockery extension",
"support": {
"issues": "https://github.com/phpstan/phpstan-mockery/issues",
"source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.0"
"source": "https://github.com/phpstan/phpstan-mockery/tree/2.0.0"
},
"time": "2022-05-09T13:12:35+00:00"
"time": "2024-10-14T03:18:12+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "1.1.1",
"version": "2.0.6",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84"
"reference": "6b92469f8a7995e626da3aa487099617b8dfa260"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4a3c437c09075736285d1cabb5c75bf27ed0bc84",
"reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6b92469f8a7995e626da3aa487099617b8dfa260",
"reference": "6b92469f8a7995e626da3aa487099617b8dfa260",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.5.0"
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0.4"
},
"conflict": {
"phpunit/phpunit": "<7.0"
},
"require-dev": {
"nikic/php-parser": "^4.13.0",
"nikic/php-parser": "^5",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6"
},
"type": "phpstan-extension",
"extra": {
@@ -2348,9 +2350,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/1.1.1"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.6"
},
"time": "2022-04-20T15:24:25+00:00"
"time": "2025-03-26T12:47:06+00:00"
},
{
"name": "phpunit/php-code-coverage",
-32
View File
@@ -1,32 +0,0 @@
parameters:
tmpDir: ./build/cache/phpstan
level: max
paths:
- ./tests
bootstrapFiles:
- ./tests/static-analysis/stubs.php
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
excludePaths:
analyse:
- ./tests/ExpectedBehaviorTest.php
- ./tests/static-analysis/stubs.php
ignoreErrors:
-
message: "#^Call to static method Ramsey\\\\Uuid\\\\.+ on a separate line has no effect\\.$#"
paths:
- ./tests/*Test.php
- ./tests/benchmark/*Bench.php
-
message: "#^Call to method Ramsey\\\\Uuid\\\\.+ on a separate line has no effect\\.$#"
paths:
- ./tests/Builder/*Test.php
- ./tests/Converter/*Test.php
- ./tests/Generator/*Test.php
- ./tests/Guid/*Test.php
- ./tests/Nonstandard/*Test.php
- ./tests/Rfc4122/*Test.php
-
message: "#^Method Ramsey\\\\Uuid\\\\.+ should return non-empty-string but returns string\\.$#"
paths:
- ./tests/static-analysis/ValidUuidIsNonEmpty.php
+6 -17
View File
@@ -1,24 +1,13 @@
parameters:
tmpDir: ./build/cache/phpstan
level: max
treatPhpDocTypesAsCertain: false
paths:
- ./src
checkMissingIterableValueType: false
- ./tests
bootstrapFiles:
- ./tests/static-analysis/stubs.php
ignoreErrors:
-
message: '#^Comparison operation ">" between 6 and 0 is always true\.$#'
count: 1
path: ./src/Generator/CombGenerator.php
-
# Legacy methods of `Ramsey\Uuid` use interface methods that are NOT defined on `FieldsInterface`
message: '#^Call to an undefined method Ramsey\\Uuid\\Fields\\FieldsInterface::get.*$#'
count: 9
path: ./src/Lazy/LazyUuidFromString.php
-
message: '#^Constructor of class Ramsey\\Uuid\\FeatureSet has an unused parameter \$forceNoBigNumber\.#'
count: 1
path: ./src/FeatureSet.php
- '#^Method Ramsey\\Uuid\\Generator\\Pecl[A-Za-z]+Generator::generate\(\) should return string but returns string\|false\.$#'
excludePaths:
analyse:
- ./tests/ExpectedBehaviorTest.php
- ./tests/static-analysis/stubs.php
+1
View File
@@ -70,6 +70,7 @@ class BuilderCollection extends AbstractCollection
$this->data = array_filter(
$data,
function ($unserialized): bool {
/** @phpstan-ignore instanceof.alwaysTrue */
return $unserialized instanceof UuidBuilderInterface;
}
);
-1
View File
@@ -64,7 +64,6 @@ class OrderedTimeCodec extends StringCodec
$bytes = $uuid->getFields()->getBytes();
/** @var non-empty-string */
return $bytes[6] . $bytes[7]
. $bytes[4] . $bytes[5]
. $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3]
+1
View File
@@ -92,6 +92,7 @@ class PhpTimeConverter implements TimeConverterInterface
// Check to see whether we've overflowed the max/min integer size.
// If so, we will default to a different time converter.
// @phpstan-ignore function.alreadyNarrowedType (the integer value might have overflowed)
if (!is_int($uuidTime)) {
return $this->fallbackConverter->calculateTime(
$seconds->toString(),
+2
View File
@@ -85,6 +85,8 @@ class FeatureSet
* system node ID (primarily for testing purposes)
* @param bool $enablePecl True to enable the use of the PeclUuidTimeGenerator
* to generate version 1 UUIDs
*
* @phpstan-ignore constructor.unusedParameter ($forceNoBigNumber is deprecated)
*/
public function __construct(
bool $useGuids = false,
+2
View File
@@ -82,6 +82,8 @@ class CombGenerator implements RandomGeneratorInterface
}
$hash = '';
/** @phpstan-ignore greater.alwaysTrue (TIMESTAMP_BYTES constant could change in child classes) */
if (self::TIMESTAMP_BYTES > 0 && $length > self::TIMESTAMP_BYTES) {
$hash = $this->generator->generate($length - self::TIMESTAMP_BYTES);
}
+5 -12
View File
@@ -29,19 +29,12 @@ class DefaultNameGenerator implements NameGeneratorInterface
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
try {
/** @var string|bool $bytes */
$bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
return hash($hashAlgorithm, $ns->getBytes() . $name, true);
} catch (ValueError $e) {
$bytes = false; // keep same behavior than PHP 7
throw new NameException(
message: sprintf('Unable to hash namespace and name with algorithm \'%s\'', $hashAlgorithm),
previous: $e,
);
}
if ($bytes === false) {
throw new NameException(sprintf(
'Unable to hash namespace and name with algorithm \'%s\'',
$hashAlgorithm
));
}
return (string) $bytes;
}
}
+1 -1
View File
@@ -43,6 +43,6 @@ class PeclUuidNameGenerator implements NameGeneratorInterface
),
};
return uuid_parse($uuid);
return (string) uuid_parse($uuid);
}
}
+1 -1
View File
@@ -30,6 +30,6 @@ class PeclUuidRandomGenerator implements RandomGeneratorInterface
{
$uuid = uuid_create(UUID_TYPE_RANDOM);
return uuid_parse($uuid);
return (string) uuid_parse($uuid);
}
}
+1 -1
View File
@@ -34,6 +34,6 @@ class PeclUuidTimeGenerator implements TimeGeneratorInterface
{
$uuid = uuid_create(UUID_TYPE_TIME);
return uuid_parse($uuid);
return (string) uuid_parse($uuid);
}
}
+9 -9
View File
@@ -37,7 +37,7 @@ use function unpack;
use const STR_PAD_LEFT;
/**
* GUIDs are comprised of a set of named fields, according to RFC 4122
* GUIDs consist of a set of named fields, according to RFC 4122
*
* @see Guid
*
@@ -89,7 +89,7 @@ final class Fields implements FieldsInterface
public function getTimeLow(): Hexadecimal
{
// Swap the bytes from little endian to network byte order.
/** @var array $hex */
/** @var string[] $hex */
$hex = unpack(
'H*',
pack(
@@ -99,13 +99,13 @@ final class Fields implements FieldsInterface
)
);
return new Hexadecimal((string) ($hex[1] ?? ''));
return new Hexadecimal($hex[1] ?? '');
}
public function getTimeMid(): Hexadecimal
{
// Swap the bytes from little endian to network byte order.
/** @var array $hex */
/** @var string[] $hex */
$hex = unpack(
'H*',
pack(
@@ -114,13 +114,13 @@ final class Fields implements FieldsInterface
)
);
return new Hexadecimal((string) ($hex[1] ?? ''));
return new Hexadecimal($hex[1] ?? '');
}
public function getTimeHiAndVersion(): Hexadecimal
{
// Swap the bytes from little endian to network byte order.
/** @var array $hex */
/** @var string[] $hex */
$hex = unpack(
'H*',
pack(
@@ -129,7 +129,7 @@ final class Fields implements FieldsInterface
)
);
return new Hexadecimal((string) ($hex[1] ?? ''));
return new Hexadecimal($hex[1] ?? '');
}
public function getTimestamp(): Hexadecimal
@@ -176,10 +176,10 @@ final class Fields implements FieldsInterface
return null;
}
/** @var array $parts */
/** @var int[] $parts */
$parts = unpack('n*', $this->bytes);
return ((int) $parts[4] >> 4) & 0x00f;
return ($parts[4] >> 4) & 0x00f;
}
private function isCorrectVariant(): bool
+1 -3
View File
@@ -38,11 +38,9 @@ use function substr;
* conversion. This object optimizes instantiation, serialization and string conversion time, at the cost of
* increased overhead for more advanced UUID operations.
*
* @internal this type is used internally for performance reasons, and is not supposed to be directly referenced
* @internal this type is used internally for performance reasons and is not supposed to be directly referenced
* in consumer libraries.
*
* @immutable
*
* Note: the {@see FieldsInterface} does not declare methods that deprecated API
* relies upon: the API has been ported from the {@see \Ramsey\Uuid\Uuid} definition,
* and is deprecated anyway.
@@ -199,9 +199,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
return '';
}
/** @var string[] $userGroups */
$userGroups = preg_split('/\s{2,}/', (string) $response, -1, PREG_SPLIT_NO_EMPTY);
$firstGroup = trim($userGroups[1] ?? '', "* \t\n\r\0\x0B");
if ($firstGroup === '') {
@@ -214,9 +212,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
return '';
}
/** @var string[] $userGroup */
$userGroup = preg_split('/\s{2,}/', (string) $response, -1, PREG_SPLIT_NO_EMPTY);
$sid = $userGroup[1] ?? '';
if (($lastHyphen = strrpos($sid, '-')) === false) {
@@ -56,6 +56,7 @@ class NodeProviderCollection extends AbstractCollection
$this->data = array_filter(
$data,
function ($unserialized): bool {
/** @phpstan-ignore-next-line */
return $unserialized instanceof NodeProviderInterface;
}
);
+6 -4
View File
@@ -72,10 +72,11 @@ class SystemNodeProvider implements NodeProviderInterface
*/
protected function getNodeFromSystem(): string
{
/** @var string | null $node */
static $node = null;
if ($node !== null) {
return (string) $node;
return $node;
}
// First, try a Linux-specific approach.
@@ -173,9 +174,10 @@ class SystemNodeProvider implements NodeProviderInterface
$macs = array_map($trim, $macs);
// Remove invalid entries.
$macs = array_filter($macs, function (string $address) {
return $address !== '00:00:00:00:00:00'
&& preg_match(self::SYSFS_PATTERN, $address);
$macs = array_filter($macs, function (mixed $address): bool {
assert(is_string($address));
return $address !== '00:00:00:00:00:00' && preg_match(self::SYSFS_PATTERN, $address);
});
/** @var string|bool $mac */
+3 -1
View File
@@ -36,7 +36,7 @@ use function str_starts_with;
final class Decimal implements NumberInterface
{
private string $value;
private bool $isNegative = false;
private bool $isNegative;
public function __construct(float | int | string | self $value)
{
@@ -61,6 +61,8 @@ final class Decimal implements NumberInterface
if (str_starts_with($value, '-')) {
$this->isNegative = true;
} else {
$this->isNegative = false;
}
$this->value = $value;
+4
View File
@@ -42,6 +42,9 @@ final class Integer implements NumberInterface
*/
private string $value;
/**
* @phpstan-ignore property.readOnlyByPhpDocDefaultValue
*/
private bool $isNegative = false;
public function __construct(float | int | string | self $value)
@@ -145,6 +148,7 @@ final class Integer implements NumberInterface
if ($sign === '-' && $value !== '0') {
$value = $sign . $value;
/** @phpstan-ignore property.readOnlyByPhpDocAssignNotInConstructor */
$this->isNegative = true;
}
+17 -1
View File
@@ -223,12 +223,16 @@ class Uuid implements UuidInterface
self::DCE_DOMAIN_ORG => 'org',
];
/**
* @phpstan-ignore property.readOnlyByPhpDocDefaultValue
*/
private static ?UuidFactoryInterface $factory = null;
/**
* @var bool flag to detect if the UUID factory was replaced internally,
* which disables all optimizations for the default/happy path internal
* scenarios
* @phpstan-ignore property.readOnlyByPhpDocDefaultValue
*/
private static bool $factoryReplaced = false;
@@ -321,9 +325,16 @@ class Uuid implements UuidInterface
$uuid = self::getFactory()->fromString($data);
}
/** @phpstan-ignore property.readOnlyByPhpDocAssignNotInConstructor */
$this->codec = $uuid->codec;
/** @phpstan-ignore property.readOnlyByPhpDocAssignNotInConstructor */
$this->numberConverter = $uuid->numberConverter;
/** @phpstan-ignore property.readOnlyByPhpDocAssignNotInConstructor */
$this->fields = $uuid->fields;
/** @phpstan-ignore property.readOnlyByPhpDocAssignNotInConstructor */
$this->timeConverter = $uuid->timeConverter;
}
@@ -519,7 +530,10 @@ class Uuid implements UuidInterface
$factory = self::getFactory();
if (method_exists($factory, 'fromHexadecimal')) {
return $factory->fromHexadecimal($hex);
$uuid = $factory->fromHexadecimal($hex);
assert($uuid instanceof UuidInterface);
return $uuid;
}
throw new BadMethodCallException('The method fromHexadecimal() does not exist on the provided factory');
@@ -546,6 +560,8 @@ class Uuid implements UuidInterface
* @param string $uuid A string to validate as a UUID
*
* @return bool True if the string is a valid UUID, false otherwise
*
* @phpstan-assert-if-true =non-empty-string $uuid
*/
public static function isValid(string $uuid): bool
{
+4 -4
View File
@@ -466,14 +466,14 @@ class UuidFactory implements UuidFactoryInterface
*/
private function uuidFromBytesAndVersion(string $bytes, int $version): UuidInterface
{
/** @var array $unpackedTime */
/** @var int[] $unpackedTime */
$unpackedTime = unpack('n*', substr($bytes, 6, 2));
$timeHi = (int) $unpackedTime[1];
$timeHi = $unpackedTime[1];
$timeHiAndVersion = pack('n*', BinaryUtils::applyVersion($timeHi, $version));
/** @var array $unpackedClockSeq */
/** @var int[] $unpackedClockSeq */
$unpackedClockSeq = unpack('n*', substr($bytes, 8, 2));
$clockSeqHi = (int) $unpackedClockSeq[1];
$clockSeqHi = $unpackedClockSeq[1];
$clockSeqHiAndReserved = pack('n*', BinaryUtils::applyVariant($clockSeqHi));
$bytes = substr_replace($bytes, $timeHiAndVersion, 6, 2);
+2 -2
View File
@@ -29,7 +29,7 @@ class BinaryUtilsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{timeHi: int, version: int, expectedInt: int, expectedHex: non-empty-string}>
*/
public function provideVersionTestValues(): array
{
@@ -128,7 +128,7 @@ class BinaryUtilsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{clockSeq: int, expectedInt: int, expectedHex: non-empty-string}>
*/
public function provideVariantTestValues(): array
{
+19 -20
View File
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Test\Builder;
use DateTimeInterface;
use Mockery;
use Ramsey\Uuid\Builder\FallbackBuilder;
use Ramsey\Uuid\Builder\UuidBuilderInterface;
@@ -101,7 +100,7 @@ class FallbackBuilderTest extends TestCase
$uuid = $builder->build($codec, $bytes);
if (($uuid instanceof UuidV1) || ($uuid instanceof UuidV2) || ($uuid instanceof UuidV6)) {
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertNotEmpty($uuid->getDateTime()->format('r'));
}
} catch (UnableToBuildUuidException $exception) {
switch ($exception->getMessage()) {
@@ -118,78 +117,78 @@ class FallbackBuilderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{bytes: string}>
*/
public function provideBytes(): array
{
return [
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1110b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1110b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1111b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1111b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1112b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1112b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1113b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1113b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1114b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1114b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1115b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1115b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1116b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1116b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e1117b210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e1117b210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e111eb210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e111eb210800200c9a66'),
],
[
// GUID bytes
'bytes' => hex2bin('b08c6fff7dc5e111fb210800200c9a66'),
'bytes' => (string) hex2bin('b08c6fff7dc5e111fb210800200c9a66'),
],
[
// Version 1 bytes
'bytes' => hex2bin('ff6f8cb0c57d11e19b210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d11e19b210800200c9a66'),
],
[
// Version 2 bytes
'bytes' => hex2bin('000001f55cde21ea84000242ac130003'),
'bytes' => (string) hex2bin('000001f55cde21ea84000242ac130003'),
],
[
// Version 3 bytes
'bytes' => hex2bin('ff6f8cb0c57d31e1bb210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d31e1bb210800200c9a66'),
],
[
// Version 4 bytes
'bytes' => hex2bin('ff6f8cb0c57d41e1ab210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d41e1ab210800200c9a66'),
],
[
// Version 5 bytes
'bytes' => hex2bin('ff6f8cb0c57d51e18b210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d51e18b210800200c9a66'),
],
[
// Version 6 bytes
'bytes' => hex2bin('ff6f8cb0c57d61e18b210800200c9a66'),
'bytes' => (string) hex2bin('ff6f8cb0c57d61e18b210800200c9a66'),
],
[
// NIL bytes
'bytes' => hex2bin('00000000000000000000000000000000'),
'bytes' => (string) hex2bin('00000000000000000000000000000000'),
],
];
}
@@ -35,7 +35,6 @@ class BigNumberTimeConverterTest extends TestCase
$converter = new BigNumberTimeConverter();
$returned = $converter->calculateTime((string) $seconds, (string) $microseconds);
$this->assertInstanceOf(Hexadecimal::class, $returned);
$this->assertSame($expected, $returned->toString());
}
@@ -12,6 +12,10 @@ use Ramsey\Uuid\Type\Hexadecimal;
class GenericTimeConverterTest extends TestCase
{
/**
* @param numeric-string $seconds
* @param numeric-string $microseconds
* @param non-empty-string $expected
*
* @dataProvider provideCalculateTime
*/
public function testCalculateTime(string $seconds, string $microseconds, string $expected): void
@@ -25,7 +29,7 @@ class GenericTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{seconds: numeric-string, microseconds: numeric-string, expected: non-empty-string}>
*/
public function provideCalculateTime(): array
{
@@ -80,6 +84,9 @@ class GenericTimeConverterTest extends TestCase
}
/**
* @param numeric-string $unixTimestamp
* @param numeric-string $microseconds
*
* @dataProvider provideConvertTime
*/
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
@@ -94,7 +101,7 @@ class GenericTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: numeric-string, microseconds: numeric-string}>
*/
public function provideConvertTime(): array
{
@@ -70,6 +70,9 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @param numeric-string $unixTimestamp
* @param numeric-string $microseconds
*
* @dataProvider provideConvertTime
*/
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
@@ -85,7 +88,7 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: numeric-string, microseconds: numeric-string}>
*/
public function provideConvertTime(): array
{
@@ -134,6 +137,10 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @param non-empty-string $seconds
* @param non-empty-string $microseconds
* @param non-empty-string $expected
*
* @dataProvider provideCalculateTime
*/
public function testCalculateTime(string $seconds, string $microseconds, string $expected): void
@@ -148,7 +155,7 @@ class PhpTimeConverterTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{seconds: non-empty-string, microseconds: non-empty-string, expected: non-empty-string}>
*/
public function provideCalculateTime(): array
{
-2
View File
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Test;
use DateTimeInterface;
use Mockery;
use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
@@ -31,7 +30,6 @@ class DeprecatedUuidMethodsTraitTest extends TestCase
$uuid = new Uuid($fields, $numberConverter, $codec, $timeConverter);
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('2012-07-04T02:14:34+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('1341368074.491000', $uuid->getDateTime()->format('U.u'));
}
+1
View File
@@ -46,6 +46,7 @@ class FeatureSetTest extends TestCase
{
$featureSet = new FeatureSet();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(TimeConverterInterface::class, $featureSet->getTimeConverter());
}
+3 -1
View File
@@ -15,6 +15,8 @@ class DefaultNameGeneratorTest extends TestCase
{
/**
* @param non-empty-string $ns
* @param non-empty-string $name
* @param non-empty-string $algorithm
*
* @dataProvider provideNamesForHashingTest
*/
@@ -29,7 +31,7 @@ class DefaultNameGeneratorTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{ns: non-empty-string, name: non-empty-string, algorithm: non-empty-string}>
*/
public function provideNamesForHashingTest(): array
{
@@ -32,14 +32,14 @@ class PeclUuidNameGeneratorTest extends TestCase
// Need to add the version and variant, since ext-uuid already includes
// these in the values returned.
/** @var array $unpackedTime */
/** @var int[] $unpackedTime */
$unpackedTime = unpack('n*', substr($expectedBytes, 6, 2));
$timeHi = (int) $unpackedTime[1];
$timeHi = $unpackedTime[1];
$timeHiAndVersion = pack('n*', BinaryUtils::applyVersion($timeHi, $version));
/** @var array $unpackedClockSeq */
/** @var int[] $unpackedClockSeq */
$unpackedClockSeq = unpack('n*', substr($expectedBytes, 8, 2));
$clockSeqHi = (int) $unpackedClockSeq[1];
$clockSeqHi = $unpackedClockSeq[1];
$clockSeqHiAndReserved = pack('n*', BinaryUtils::applyVariant($clockSeqHi));
$expectedBytes = substr_replace($expectedBytes, $timeHiAndVersion, 6, 2);
@@ -99,7 +99,6 @@ class PeclUuidNameGeneratorTest extends TestCase
'Unable to hash namespace and name with algorithm \'aBadAlgorithm\''
);
/** @phpstan-ignore-next-line */
$generator->generate($namespace, 'a test name', 'aBadAlgorithm');
}
}
+4 -3
View File
@@ -15,7 +15,7 @@ use function hex2bin;
class RandomBytesGeneratorTest extends TestCase
{
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: positive-int, 1: non-empty-string}>
*/
public function lengthAndHexDataProvider(): array
{
@@ -27,7 +27,8 @@ class RandomBytesGeneratorTest extends TestCase
}
/**
* @param int<1, max> $length
* @param positive-int $length
* @param non-empty-string $hex
*
* @throws Exception
*
@@ -53,7 +54,7 @@ class RandomBytesGeneratorTest extends TestCase
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGenerateThrowsExceptionWhenExceptionThrownByRandombytes(): void
public function testGenerateThrowsExceptionWhenExceptionThrownByRandomBytes(): void
{
PHPMockery::mock('Ramsey\Uuid\Generator', 'random_bytes')
->once()
+3 -1
View File
@@ -26,6 +26,7 @@ class RandomLibAdapterTest extends TestCase
->disableOriginalConstructor()
->getMock();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(RandomLibAdapter::class, new RandomLibAdapter($generator));
}
@@ -33,7 +34,7 @@ class RandomLibAdapterTest extends TestCase
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testAdapterWithoutGeneratorGreatesGenerator(): void
public function testAdapterWithoutGeneratorCreatesGenerator(): void
{
$generator = Mockery::mock(Generator::class);
@@ -41,6 +42,7 @@ class RandomLibAdapterTest extends TestCase
$factory = Mockery::mock('overload:' . RandomLibFactory::class);
$factory->expects()->getHighStrengthGenerator()->andReturns($generator);
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(RandomLibAdapter::class, new RandomLibAdapter());
}
@@ -28,6 +28,7 @@ class TimeGeneratorFactoryTest extends TestCase
$factory = new TimeGeneratorFactory($nodeProvider, $timeConverter, $timeProvider);
$generator = $factory->getGenerator();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(TimeGeneratorInterface::class, $generator);
}
}
+15 -6
View File
@@ -26,6 +26,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $guid
*
* @dataProvider nonRfc4122GuidVariantProvider
*/
public function testConstructorThrowsExceptionIfNotRfc4122Variant(string $guid): void
@@ -44,7 +46,7 @@ class FieldsTest extends TestCase
/**
* These values are already in GUID byte order, for easy testing.
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function nonRfc4122GuidVariantProvider(): array
{
@@ -65,6 +67,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $guid
*
* @dataProvider invalidVersionProvider
*/
public function testConstructorThrowsExceptionIfInvalidVersion(string $guid): void
@@ -80,7 +84,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function invalidVersionProvider(): array
{
@@ -100,12 +104,17 @@ class FieldsTest extends TestCase
}
/**
* @param string|int $expectedValue
* @param non-empty-string $bytes
* @param non-empty-string $methodName
* @param non-empty-string | bool | int | null $expectedValue
*
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(string $bytes, string $methodName, $expectedValue): void
{
public function testFieldGetterMethods(
string $bytes,
string $methodName,
bool | int | string | null $expectedValue,
): void {
$bytes = (string) hex2bin($bytes);
$fields = new Fields($bytes);
@@ -119,7 +128,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: non-empty-string, 2: non-empty-string | int | bool | null}>
*/
public function fieldGetterMethodProvider(): array
{
-3
View File
@@ -8,7 +8,6 @@ use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Math\BrickMathCalculator;
use Ramsey\Uuid\Math\RoundingMode;
use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Integer as IntegerObject;
class BrickMathCalculatorTest extends TestCase
@@ -71,7 +70,6 @@ class BrickMathCalculatorTest extends TestCase
$result = $calculator->fromBase('ffffffffffffffffffff', 16);
$this->assertInstanceOf(IntegerObject::class, $result);
$this->assertSame('1208925819614629174706175', $result->toString());
}
@@ -90,7 +88,6 @@ class BrickMathCalculatorTest extends TestCase
$result = $calculator->toHexadecimal($intValue);
$this->assertInstanceOf(Hexadecimal::class, $result);
$this->assertSame('ffffffffffffffffffff', $result->toString());
}
+9 -4
View File
@@ -28,12 +28,17 @@ class FieldsTest extends TestCase
}
/**
* @param string|int $expectedValue
* @param non-empty-string $uuid
* @param non-empty-string $methodName
* @param non-empty-string | int | bool | null $expectedValue
*
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(string $uuid, string $methodName, $expectedValue): void
{
public function testFieldGetterMethods(
string $uuid,
string $methodName,
bool | int | string | null $expectedValue,
): void {
$bytes = (string) hex2bin(str_replace('-', '', $uuid));
$fields = new Fields($bytes);
@@ -47,7 +52,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: non-empty-string, 2: non-empty-string | int | bool | null}>
*/
public function fieldGetterMethodProvider(): array
{
+3 -3
View File
@@ -44,7 +44,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
@@ -78,7 +78,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, expected: non-empty-string}>
*/
public function provideUuidV6WithOddMicroseconds(): array
{
@@ -146,7 +146,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidv6: non-empty-string, uuidv1: non-empty-string}>
*/
public function provideUuidV1UuidV6Equivalents(): array
{
@@ -8,7 +8,6 @@ use Mockery;
use Ramsey\Uuid\Exception\DceSecurityException;
use Ramsey\Uuid\Provider\Dce\SystemDceSecurityProvider;
use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Type\Integer as IntegerObject;
use phpmock\mockery\PHPMockery;
use function array_merge;
@@ -147,13 +146,12 @@ class SystemDceSecurityProviderTest extends TestCase
$uid = $provider->getUid();
$this->assertInstanceOf(IntegerObject::class, $uid);
$this->assertSame($expectedId, $uid->toString());
$this->assertSame($uid, $provider->getUid());
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: non-empty-string, expectedId: non-empty-string}>
*/
public function provideWindowsGoodWhoAmIValues(): array
{
@@ -199,7 +197,6 @@ class SystemDceSecurityProviderTest extends TestCase
$uid = $provider->getUid();
$this->assertInstanceOf(IntegerObject::class, $uid);
$this->assertSame($id, $uid->toString());
$this->assertSame($uid, $provider->getUid());
}
@@ -298,7 +295,6 @@ class SystemDceSecurityProviderTest extends TestCase
$gid = $provider->getGid();
$this->assertInstanceOf(IntegerObject::class, $gid);
$this->assertSame($id, $gid->toString());
$this->assertSame($gid, $provider->getGid());
}
@@ -419,13 +415,17 @@ class SystemDceSecurityProviderTest extends TestCase
$gid = $provider->getGid();
$this->assertInstanceOf(IntegerObject::class, $gid);
$this->assertSame($expectedId, $gid->toString());
$this->assertSame($gid, $provider->getGid());
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{
* netUserResponse: non-empty-string,
* wmicGroupResponse: non-empty-string,
* expectedGroup: non-empty-string,
* expectedId: non-empty-string,
* }>
*/
public function provideWindowsGoodNetUserAndWmicGroupValues(): array
{
@@ -458,7 +458,7 @@ class SystemDceSecurityProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{os: non-empty-string, id: non-empty-string}>
*/
public function providePosixTestValues(): array
{
@@ -474,7 +474,7 @@ class SystemDceSecurityProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: string | null}>
*/
public function provideWindowsBadValues(): array
{
@@ -490,7 +490,7 @@ class SystemDceSecurityProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: string | null}>
*/
public function provideWindowsBadGroupValues(): array
{
@@ -81,7 +81,6 @@ class FallbackNodeProviderTest extends TestCase
foreach ($unserializedNodeProviderCollection as $nodeProvider) {
$this->assertInstanceOf(NodeProviderInterface::class, $nodeProvider);
$this->assertInstanceOf(Hexadecimal::class, $nodeProvider->getNode());
}
}
}
@@ -12,6 +12,8 @@ use Ramsey\Uuid\Type\Hexadecimal;
class StaticNodeProviderTest extends TestCase
{
/**
* @param non-empty-string $expectedNode
*
* @dataProvider provideNodeForTest
*/
public function testStaticNode(Hexadecimal $node, string $expectedNode): void
@@ -22,7 +24,7 @@ class StaticNodeProviderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{node: Hexadecimal, expectedNode: non-empty-string}>
*/
public function provideNodeForTest(): array
{
+156 -151
View File
@@ -401,6 +401,7 @@ class SystemNodeProviderTest extends TestCase
/* Arrange */
$this->arrangeMockFunctions(
function () {
/** @var non-empty-list<string> $macs */
static $macs = ["00:00:00:00:00:00\n", "01:02:03:04:05:06\n"];
return array_shift($macs);
@@ -654,11 +655,11 @@ class SystemNodeProviderTest extends TestCase
self::MOCK_IS_READABLE => $isReadableAssert,
];
array_walk($mockFunctionAsserts, function ($asserts, $key): void {
array_walk($mockFunctionAsserts, function (mixed $asserts, string $key): void {
if ($asserts === null) {
// Assert the function was never invoked.
$this->assertEmpty($this->functionProxies[$key]->getInvocations());
} elseif (is_array($asserts)) {
} elseif (is_array($asserts)) { /** @phpstan-ignore function.alreadyNarrowedType */
// Assert there was at least one invocation for this function.
$this->assertNotEmpty($this->functionProxies[$key]->getInvocations());
@@ -686,7 +687,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Provides the command that should be executed per supported OS
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<string, array{0: non-empty-string, 1: non-empty-string}>
*/
public function provideCommandPerOs(): array
{
@@ -703,7 +704,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Values that are NOT parsed to a mac address by the class under test
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<string, array{0: non-empty-string}>
*/
public function provideInvalidNetStatOutput(): array
{
@@ -729,7 +730,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Provides notations that the class under test should NOT attempt to strip
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function provideInvalidNotationalFormats(): array
{
@@ -749,7 +750,7 @@ class SystemNodeProviderTest extends TestCase
/**
* Provides mac addresses that the class under test should strip notational format from
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: non-empty-string}>
*/
public function provideNotationalFormats(): array
{
@@ -762,168 +763,172 @@ class SystemNodeProviderTest extends TestCase
/**
* Values that are parsed to a mac address by the class under test
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<string, array{0: non-empty-string, 1: non-empty-string}>
*/
public function provideValidNetStatOutput(): array
{
return [
/* Full output of related command */
'Full output - Linux' => [<<<'TXT'
Kernel Interface table
docker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
'Full output - Linux' => [
<<<'TXT'
Kernel Interface table
docker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp3s0 Link encap:Ethernet HWaddr fe:dc:ba:98:76:54
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: ffee::ddcc:bbaa:9988:7766/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:943077 errors:0 dropped:0 overruns:0 frame:0
TX packets:2168039 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:748596414 (748.5 MB) TX bytes:2930448282 (2.9 GB)
enp3s0 Link encap:Ethernet HWaddr fe:dc:ba:98:76:54
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: ffee::ddcc:bbaa:9988:7766/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:943077 errors:0 dropped:0 overruns:0 frame:0
TX packets:2168039 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:748596414 (748.5 MB) TX bytes:2930448282 (2.9 GB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8302 errors:0 dropped:0 overruns:0 frame:0
TX packets:8302 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1094983 (1.0 MB) TX bytes:1094983 (1.0 MB)
TXT
, '0123456789ab',
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8302 errors:0 dropped:0 overruns:0 frame:0
TX packets:8302 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1094983 (1.0 MB) TX bytes:1094983 (1.0 MB)
TXT,
'0123456789ab',
],
'Full output - MacOS' => [<<<'TXT'
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
EHC29: flags=0<> mtu 0
XHC20: flags=0<> mtu 0
EHC26: flags=0<> mtu 0
aa0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 00:00:00:00:00:00
status: active
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 10:dd:b1:b4:e4:8e
inet6 fe80::c70:76f5:aa1:5db1%en0 prefixlen 64 secured scopeid 0x7
inet 10.53.8.112 netmask 0xfffffc00 broadcast 10.53.11.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex>)
status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether ec:35:86:38:c8:c2
inet6 fe80::aa:d44f:5f5f:7fd4%en1 prefixlen 64 secured scopeid 0x8
inet 10.53.17.196 netmask 0xfffffc00 broadcast 10.53.19.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 0e:35:86:38:c8:c2
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether ea:ab:ae:25:f5:d0
inet6 fe80::e8ab:aeff:fe25:f5d0%awdl0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:60
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:61
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 32:00:18:9b:dc:60
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 11 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 12 priority 0 path cost 0
media: <unknown type>
status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
inet6 fe80::57c6:d692:9d41:d28f%utun0 prefixlen 64 scopeid 0xe
nd6 options=201<PERFORMNUD,DAD>
TXT
, '10ddb1b4e48e',
'Full output - MacOS' => [
<<<'TXT'
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
EHC29: flags=0<> mtu 0
XHC20: flags=0<> mtu 0
EHC26: flags=0<> mtu 0
aa0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 00:00:00:00:00:00
status: active
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 10:dd:b1:b4:e4:8e
inet6 fe80::c70:76f5:aa1:5db1%en0 prefixlen 64 secured scopeid 0x7
inet 10.53.8.112 netmask 0xfffffc00 broadcast 10.53.11.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex>)
status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether ec:35:86:38:c8:c2
inet6 fe80::aa:d44f:5f5f:7fd4%en1 prefixlen 64 secured scopeid 0x8
inet 10.53.17.196 netmask 0xfffffc00 broadcast 10.53.19.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 0e:35:86:38:c8:c2
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether ea:ab:ae:25:f5:d0
inet6 fe80::e8ab:aeff:fe25:f5d0%awdl0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:60
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:61
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 32:00:18:9b:dc:60
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 11 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 12 priority 0 path cost 0
media: <unknown type>
status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
inet6 fe80::57c6:d692:9d41:d28f%utun0 prefixlen 64 scopeid 0xe
nd6 options=201<PERFORMNUD,DAD>
TXT,
'10ddb1b4e48e',
],
'Full output - Window' => [<<<'TXT'
Windows IP Configuration
'Full output - Window' => [
<<<'TXT'
Windows IP Configuration
Host Name . . . . . . . . . . . . : MSEDGEWIN10
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : network.lan
Host Name . . . . . . . . . . . . : MSEDGEWIN10
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : network.lan
Some kind of adapter:
Some kind of adapter:
Connection-specific DNS Suffix . : network.foo
Description . . . . . . . . . . . : Some Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00
Connection-specific DNS Suffix . : network.foo
Description . . . . . . . . . . . : Some Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00
Ethernet adapter Ethernet:
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
Physical Address. . . . . . . . . : 08-00-27-B8-42-C6
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::606a:ae33:7ce1:b5e9%3(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, January 30, 2018 11:25:31 PM
Lease Expires . . . . . . . . . . : Wednesday, January 31, 2018 11:25:27 PM
Default Gateway . . . . . . . . . : 10.0.2.2
DHCP Server . . . . . . . . . . . : 10.0.2.2
DHCPv6 IAID . . . . . . . . . . . : 34078759
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-40-72-3F-08-00-27-B8-42-C6
DNS Servers . . . . . . . . . . . : 10.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
Physical Address. . . . . . . . . : 08-00-27-B8-42-C6
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::606a:ae33:7ce1:b5e9%3(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, January 30, 2018 11:25:31 PM
Lease Expires . . . . . . . . . . : Wednesday, January 31, 2018 11:25:27 PM
Default Gateway . . . . . . . . . : 10.0.2.2
DHCP Server . . . . . . . . . . . : 10.0.2.2
DHCPv6 IAID . . . . . . . . . . . : 34078759
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-40-72-3F-08-00-27-B8-42-C6
DNS Servers . . . . . . . . . . . : 10.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapter isatap.network.lan:
Tunnel adapter isatap.network.lan:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
TXT
, '080027b842c6',
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
TXT,
'080027b842c6',
],
'Full output - FreeBSD' => [<<<'TXT'
Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll
aa0 0 <Link#0> 00:00:00:00:00:00 0 0 0 0 0 0
em0 1500 <Link#1> 08:00:27:71:a1:00 65514 0 0 42918 0 0
em1 1500 <Link#2> 08:00:27:d0:60:a0 1199 0 0 535 0 0
lo0 16384 <Link#3> lo0 4 0 0 4 0 0
TXT
, '08002771a100',
'Full output - FreeBSD' => [
<<<'TXT'
Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll
aa0 0 <Link#0> 00:00:00:00:00:00 0 0 0 0 0 0
em0 1500 <Link#1> 08:00:27:71:a1:00 65514 0 0 42918 0 0
em1 1500 <Link#2> 08:00:27:d0:60:a0 1199 0 0 535 0 0
lo0 16384 <Link#3> lo0 4 0 0 4 0 0
TXT,
'08002771a100',
],
/* The single line that is relevant */
@@ -15,6 +15,7 @@ class SystemTimeProviderTest extends TestCase
$provider = new SystemTimeProvider();
$time = $provider->getTime();
/** @phpstan-ignore method.alreadyNarrowedType */
$this->assertInstanceOf(Time::class, $time);
}
}
+15 -6
View File
@@ -27,6 +27,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $uuid
*
* @dataProvider nonRfc4122VariantProvider
*/
public function testConstructorThrowsExceptionIfNotRfc4122Variant(string $uuid): void
@@ -42,7 +44,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function nonRfc4122VariantProvider(): array
{
@@ -63,6 +65,8 @@ class FieldsTest extends TestCase
}
/**
* @param non-empty-string $uuid
*
* @dataProvider invalidVersionProvider
*/
public function testConstructorThrowsExceptionIfInvalidVersion(string $uuid): void
@@ -78,7 +82,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function invalidVersionProvider(): array
{
@@ -95,12 +99,17 @@ class FieldsTest extends TestCase
}
/**
* @param string|int $expectedValue
* @param non-empty-string $uuid
* @param non-empty-string $methodName
* @param non-empty-string | int | bool | null $expectedValue
*
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(string $uuid, string $methodName, $expectedValue): void
{
public function testFieldGetterMethods(
string $uuid,
string $methodName,
bool | int | string | null $expectedValue,
): void {
$bytes = (string) hex2bin(str_replace('-', '', $uuid));
$fields = new Fields($bytes);
@@ -114,7 +123,7 @@ class FieldsTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: non-empty-string, 2: non-empty-string | int | bool | null}>
*/
public function fieldGetterMethodProvider(): array
{
+2 -1
View File
@@ -32,6 +32,7 @@ use function str_replace;
class UuidBuilderTest extends TestCase
{
/**
* @param non-empty-string $uuid
* @param class-string $expectedClass
*
* @dataProvider provideBuildTestValues
@@ -56,7 +57,7 @@ class UuidBuilderTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, expectedClass: class-string, expectedVersion: int | null}>
*/
public function provideBuildTestValues(): array
{
+3 -2
View File
@@ -43,7 +43,7 @@ class UuidV1Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
@@ -62,6 +62,7 @@ class UuidV1Test extends TestCase
/**
* @param non-empty-string $uuid
* @param numeric-string $expected
*
* @dataProvider provideUuidV1WithOddMicroseconds
*/
@@ -77,7 +78,7 @@ class UuidV1Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, expected: numeric-string}>
*/
public function provideUuidV1WithOddMicroseconds(): array
{
+12 -2
View File
@@ -54,7 +54,7 @@ class UuidV2Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
@@ -114,7 +114,17 @@ class UuidV2Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* phpcs:ignore SlevomatCodingStandard.TypeHints.LongTypeHints.UsedLongTypeHint
* @return array<array{
* domain: int,
* identifier: Integer,
* time: Time,
* expectedDomain: int,
* expectedDomainName: non-empty-string,
* expectedIdentifier: non-empty-string,
* expectedTimestamp: non-empty-string,
* expectedTime: non-empty-string,
* }>
*/
public function provideLocalDomainAndIdentifierForTests(): array
{
+1 -1
View File
@@ -38,7 +38,7 @@ class UuidV3Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
+1 -1
View File
@@ -38,7 +38,7 @@ class UuidV4Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
+1 -1
View File
@@ -38,7 +38,7 @@ class UuidV5Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
+4 -3
View File
@@ -44,7 +44,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{version: int}>
*/
public function provideTestVersions(): array
{
@@ -63,6 +63,7 @@ class UuidV6Test extends TestCase
/**
* @param non-empty-string $uuid
* @param non-empty-string $expected
*
* @dataProvider provideUuidV6WithOddMicroseconds
*/
@@ -78,7 +79,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, expected: non-empty-string}>
*/
public function provideUuidV6WithOddMicroseconds(): array
{
@@ -146,7 +147,7 @@ class UuidV6Test extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuidv6: non-empty-string, uuidv1: non-empty-string}>
*/
public function provideUuidV1UuidV6Equivalents(): array
{
+1 -1
View File
@@ -43,7 +43,7 @@ class ValidatorTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: string, expected: bool}>
*/
public function provideValuesForValidation(): array
{
+2 -2
View File
@@ -34,7 +34,7 @@ class VariantTraitTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string}>
*/
public function invalidBytesProvider(): array
{
@@ -62,7 +62,7 @@ class VariantTraitTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: int}>
*/
public function uuidVariantProvider(): array
{
+1 -1
View File
@@ -21,7 +21,7 @@ class TestCase extends PhpUnitTestCase
public static function isLittleEndianSystem(): bool
{
/** @var array $unpacked */
/** @var int[] $unpacked */
$unpacked = unpack('v', pack('S', 0x00FF));
return current($unpacked) === 0x00FF;
+1 -1
View File
@@ -158,7 +158,7 @@ class UuidFactoryTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: DateTimeInterface, 1: Hexadecimal | null, 2: int | null, 3: string, 4: string}>
*/
public function provideDateTime(): array
{
+30 -34
View File
@@ -257,19 +257,16 @@ class UuidTest extends TestCase
{
// Check a recent date
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('2012-07-04T02:14:34+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('1341368074.491000', $uuid->getDateTime()->format('U.u'));
// Check an old date
$uuid = Uuid::fromString('0901e600-0154-1000-9b21-0800200c9a66');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('1582-10-16T16:34:04+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('-12219146756.000000', $uuid->getDateTime()->format('U.u'));
// Check a future date
$uuid = Uuid::fromString('ff9785f6-ffff-1fff-9669-00007ffffffe');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('5236-03-31T21:20:59+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('103072857659.999999', $uuid->getDateTime()->format('U.u'));
@@ -277,19 +274,16 @@ class UuidTest extends TestCase
// See inline comments in
// {@see \Ramsey\Uuid\Test\Converter\Time\GenericTimeConverterTest::provideCalculateTime()}
$uuid = Uuid::fromString('fffffffa-ffff-1fff-8b1e-acde48001122');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('5236-03-31T21:21:00+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('103072857660.684697', $uuid->getDateTime()->format('U.u'));
// Check the oldest date
$uuid = Uuid::fromString('00000000-0000-1000-9669-00007ffffffe');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('1582-10-15T00:00:00+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('-12219292800.000000', $uuid->getDateTime()->format('U.u'));
// The Unix epoch
$uuid = Uuid::fromString('13814000-1dd2-11b2-9669-00007ffffffe');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('1970-01-01T00:00:00+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('0.000000', $uuid->getDateTime()->format('U.u'));
}
@@ -298,19 +292,16 @@ class UuidTest extends TestCase
{
// Check a recent date
$uuid = Uuid::fromString('1e1c57df-f6f8-6cb0-9b21-0800200c9a66');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('2012-07-04T02:14:34+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('1341368074.491000', $uuid->getDateTime()->format('U.u'));
// Check an old date
$uuid = Uuid::fromString('00001540-901e-6600-9b21-0800200c9a66');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('1582-10-16T16:34:04+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('-12219146756.000000', $uuid->getDateTime()->format('U.u'));
// Check a future date
$uuid = Uuid::fromString('ffffffff-f978-65f6-9669-00007ffffffe');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('5236-03-31T21:20:59+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('103072857659.999999', $uuid->getDateTime()->format('U.u'));
@@ -318,19 +309,16 @@ class UuidTest extends TestCase
// See inline comments in
// {@see \Ramsey\Uuid\Test\Converter\Time\GenericTimeConverterTest::provideCalculateTime()}
$uuid = Uuid::fromString('ffffffff-ffff-6ffa-8b1e-acde48001122');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('5236-03-31T21:21:00+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('103072857660.684697', $uuid->getDateTime()->format('U.u'));
// Check the oldest date
$uuid = Uuid::fromString('00000000-0000-6000-9669-00007ffffffe');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('1582-10-15T00:00:00+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('-12219292800.000000', $uuid->getDateTime()->format('U.u'));
// The Unix epoch
$uuid = Uuid::fromString('1b21dd21-3814-6000-9669-00007ffffffe');
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame('1970-01-01T00:00:00+00:00', $uuid->getDateTime()->format('c'));
$this->assertSame('0.000000', $uuid->getDateTime()->format('U.u'));
}
@@ -516,7 +504,7 @@ class UuidTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: non-empty-string, 1: int}>
*/
public function provideVariousVariantUuids(): array
{
@@ -594,7 +582,6 @@ class UuidTest extends TestCase
public function testUuid1(): void
{
$uuid = Uuid::uuid1();
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
}
@@ -688,7 +675,6 @@ class UuidTest extends TestCase
Uuid::setFactory(new UuidFactory(new FeatureSet(false, false, false, true)));
$uuid = Uuid::uuid1();
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
}
@@ -696,7 +682,6 @@ class UuidTest extends TestCase
public function testUuid1WithUserGeneratedRandomNode(): void
{
$uuid = Uuid::uuid1(new Hexadecimal((string) (new RandomNodeProvider())->getNode()));
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(1, $uuid->getVersion());
}
@@ -704,7 +689,6 @@ class UuidTest extends TestCase
public function testUuid6(): void
{
$uuid = Uuid::uuid6();
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
}
@@ -712,7 +696,6 @@ class UuidTest extends TestCase
public function testUuid6WithNodeAndClockSequence(): void
{
$uuid = Uuid::uuid6(new Hexadecimal('0800200c9a66'), 0x1669);
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
$this->assertSame('1669', $uuid->getClockSequenceHex());
@@ -724,7 +707,6 @@ class UuidTest extends TestCase
{
$uuid = Uuid::uuid6(new Hexadecimal('7160355e'));
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
$this->assertSame('00007160355e', $uuid->getNodeHex());
@@ -734,7 +716,6 @@ class UuidTest extends TestCase
{
$uuid = Uuid::uuid6(new Hexadecimal('71B0aD5e'));
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
$this->assertSame('000071b0ad5e', $uuid->getNodeHex());
@@ -761,7 +742,6 @@ class UuidTest extends TestCase
Uuid::setFactory(new UuidFactory(new FeatureSet(false, false, false, true)));
$uuid = Uuid::uuid6();
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
}
@@ -769,7 +749,6 @@ class UuidTest extends TestCase
public function testUuid6WithUserGeneratedRandomNode(): void
{
$uuid = Uuid::uuid6(new Hexadecimal((string) (new RandomNodeProvider())->getNode()));
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(6, $uuid->getVersion());
}
@@ -777,7 +756,6 @@ class UuidTest extends TestCase
public function testUuid7(): void
{
$uuid = Uuid::uuid7();
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(7, $uuid->getVersion());
}
@@ -800,7 +778,6 @@ class UuidTest extends TestCase
$dateTime = new DateTimeImmutable('@281474976710.655');
$uuid = Uuid::uuid7($dateTime);
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(7, $uuid->getVersion());
$this->assertSame(
@@ -833,7 +810,6 @@ class UuidTest extends TestCase
$dateTime = new DateTimeImmutable('1979-01-01 00:00:00.000000');
$uuid = Uuid::uuid7($dateTime);
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
$this->assertSame(2, $uuid->getVariant());
$this->assertSame(7, $uuid->getVersion());
$this->assertSame(
@@ -896,6 +872,7 @@ class UuidTest extends TestCase
*
* @param non-empty-string $uuid
* @param non-empty-string $ns
* @param non-empty-string $name
*
* @dataProvider provideUuid3WithKnownUuids
*/
@@ -911,7 +888,7 @@ class UuidTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, ns: non-empty-string, name: non-empty-string}>
*/
public function provideUuid3WithKnownUuids(): array
{
@@ -954,7 +931,7 @@ class UuidTest extends TestCase
$mock = $this->getMockBuilder(RandomGeneratorInterface::class)->getMock();
$mock->expects($this->any())
->method('generate')
->willReturnCallback(function ($length) {
->willReturnCallback(function (int $length) {
// Makes first fields of UUIDs equal
return hex2bin(str_pad('', $length * 2, '0'));
});
@@ -984,7 +961,7 @@ class UuidTest extends TestCase
$mock = $this->getMockBuilder(RandomGeneratorInterface::class)->getMock();
$mock->expects($this->any())
->method('generate')
->willReturnCallback(function ($length) {
->willReturnCallback(function (int $length) {
// Makes first fields of UUIDs equal
return hex2bin(str_pad('', $length * 2, '0'));
});
@@ -1032,6 +1009,7 @@ class UuidTest extends TestCase
*
* @param non-empty-string $uuid
* @param non-empty-string $ns
* @param non-empty-string $name
*
* @dataProvider provideUuid5WithKnownUuids
*/
@@ -1047,7 +1025,7 @@ class UuidTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{uuid: non-empty-string, ns: non-empty-string, name: non-empty-string}>
*/
public function provideUuid5WithKnownUuids(): array
{
@@ -1365,8 +1343,12 @@ class UuidTest extends TestCase
* @param non-empty-string $string
* @param non-empty-string $curly
* @param non-empty-string $hex
* @param non-empty-string $bytes
* @param non-empty-string $int
* @param string[] $fields
* @param non-empty-string $urn
* @param non-empty-string $time
* @param non-empty-string $clockSeq
*
* @dataProvider providePythonTests
*/
@@ -1419,7 +1401,19 @@ class UuidTest extends TestCase
* Taken from the Python UUID tests in
* http://hg.python.org/cpython/file/2f4c4db9aee5/Lib/test/test_uuid.py
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{
* string: non-empty-string,
* curly: non-empty-string,
* hex: non-empty-string,
* bytes: non-empty-string,
* int: non-empty-string,
* fields: array<string, string>,
* urn: non-empty-string,
* time: non-empty-string,
* clock_seq: non-empty-string,
* variant: int,
* version: int | null,
* }>
*/
public function providePythonTests(): array
{
@@ -1886,7 +1880,7 @@ class UuidTest extends TestCase
}
/**
* @param mixed[] $args
* @param array<int | string> $args
*
* @dataProvider provideStaticMethods
*/
@@ -1898,7 +1892,7 @@ class UuidTest extends TestCase
}
/**
* @param mixed[] $args
* @param array<int | string> $args
*
* @dataProvider provideStaticMethods
*/
@@ -1906,6 +1900,7 @@ class UuidTest extends TestCase
string $staticMethod,
array $args = []
): void {
/** @var UuidInterface $generated */
$generated = Uuid::$staticMethod(...$args);
self::assertSame(
@@ -1915,7 +1910,7 @@ class UuidTest extends TestCase
}
/**
* @param mixed[] $args
* @param array<int | string> $args
*
* @dataProvider provideStaticMethods
*/
@@ -1923,6 +1918,7 @@ class UuidTest extends TestCase
string $staticMethod,
array $args = []
): void {
/** @var UuidInterface $generated */
$generated = Uuid::$staticMethod(...$args);
self::assertSame(
@@ -1932,7 +1928,7 @@ class UuidTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{0: string, 1?: array<int | string>}>
*/
public function provideStaticMethods(): array
{
+1 -1
View File
@@ -34,7 +34,7 @@ class GenericValidatorTest extends TestCase
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
* @return array<array{value: string, expected: bool}>
*/
public function provideValuesForValidation(): array
{