Fix Psalm errors resulting from changes introduced in 3.9.4

This commit is contained in:
Ben Ramsey
2020-03-07 15:22:00 -06:00
parent 4a53d4d33d
commit 57e3ce9dd7
19 changed files with 35 additions and 48 deletions
-5
View File
@@ -1,5 +0,0 @@
.. _nonstandard.codec.ordered-time:
============
Ordered Time
============
+2 -8
View File
@@ -18,6 +18,8 @@ use Ramsey\Uuid\UuidInterface;
/**
* A codec encodes and decodes a UUID according to defined rules
*
* @psalm-immutable
*/
interface CodecInterface
{
@@ -30,8 +32,6 @@ interface CodecInterface
* @return string Hexadecimal string representation of a UUID
*
* @psalm-return non-empty-string
*
* @psalm-pure
*/
public function encode(UuidInterface $uuid): string;
@@ -44,8 +44,6 @@ interface CodecInterface
* @return string Binary string representation of a UUID
*
* @psalm-return non-empty-string
*
* @psalm-pure
*/
public function encodeBinary(UuidInterface $uuid): string;
@@ -57,8 +55,6 @@ interface CodecInterface
*
* @return UuidInterface An instance of a UUID decoded from a hexadecimal
* string representation
*
* @psalm-pure
*/
public function decode(string $encodedUuid): UuidInterface;
@@ -70,8 +66,6 @@ interface CodecInterface
*
* @return UuidInterface An instance of a UUID decoded from a binary string
* representation
*
* @psalm-pure
*/
public function decodeBytes(string $bytes): UuidInterface;
}
+2 -10
View File
@@ -24,13 +24,11 @@ use function substr;
* GuidStringCodec encodes and decodes globally unique identifiers (GUID)
*
* @see Guid
*
* @psalm-immutable
*/
class GuidStringCodec extends StringCodec
{
/**
* @inheritDoc
* @psalm-pure
*/
public function decode(string $encodedUuid): UuidInterface
{
$bytes = $this->getBytes($encodedUuid);
@@ -38,10 +36,6 @@ class GuidStringCodec extends StringCodec
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
}
/**
* @inheritDoc
* @psalm-pure
*/
public function decodeBytes(string $bytes): UuidInterface
{
// Specifically call parent::decode to preserve correct byte order
@@ -50,8 +44,6 @@ class GuidStringCodec extends StringCodec
/**
* Swaps bytes according to the GUID rules
*
* @psalm-pure
*/
private function swapBytes(string $bytes): string
{
+2 -3
View File
@@ -40,6 +40,8 @@ use function substr;
* malformed UUIDs.
*
* @link https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/ Storing UUID Values in MySQL
*
* @psalm-immutable
*/
class OrderedTimeCodec extends StringCodec
{
@@ -48,7 +50,6 @@ class OrderedTimeCodec extends StringCodec
* fields rearranged for optimized storage
*
* @inheritDoc
* @psalm-pure
* @psalm-return non-empty-string
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
@@ -79,8 +80,6 @@ class OrderedTimeCodec extends StringCodec
* @throws InvalidArgumentException if $bytes is an invalid length
*
* @inheritDoc
*
* @psalm-pure
*/
public function decodeBytes(string $bytes): UuidInterface
{
+2 -12
View File
@@ -31,6 +31,8 @@ use function substr;
* StringCodec encodes and decodes RFC 4122 UUIDs
*
* @link http://tools.ietf.org/html/rfc4122
*
* @psalm-immutable
*/
class StringCodec implements CodecInterface
{
@@ -49,9 +51,6 @@ class StringCodec implements CodecInterface
$this->builder = $builder;
}
/**
* @psalm-pure
*/
public function encode(UuidInterface $uuid): string
{
/** @var FieldsInterface $fields */
@@ -70,7 +69,6 @@ class StringCodec implements CodecInterface
}
/**
* @psalm-pure
* @psalm-return non-empty-string
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
@@ -84,18 +82,12 @@ class StringCodec implements CodecInterface
* @throws InvalidUuidStringException
*
* @inheritDoc
*
* @psalm-pure
*/
public function decode(string $encodedUuid): UuidInterface
{
return $this->builder->build($this, $this->getBytes($encodedUuid));
}
/**
* @inheritDoc
* @psalm-pure
*/
public function decodeBytes(string $bytes): UuidInterface
{
if (strlen($bytes) !== 16) {
@@ -117,8 +109,6 @@ class StringCodec implements CodecInterface
/**
* Returns a byte string of the UUID
*
* @psalm-pure
*/
protected function getBytes(string $encodedUuid): string
{
+2 -10
View File
@@ -45,11 +45,12 @@ use function substr_replace;
* ```
*
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
*
* @psalm-immutable
*/
class TimestampFirstCombCodec extends StringCodec
{
/**
* @psalm-pure
* @psalm-return non-empty-string
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
@@ -69,7 +70,6 @@ class TimestampFirstCombCodec extends StringCodec
}
/**
* @psalm-pure
* @psalm-return non-empty-string
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
@@ -83,8 +83,6 @@ class TimestampFirstCombCodec extends StringCodec
* @throws InvalidUuidStringException
*
* @inheritDoc
*
* @psalm-pure
*/
public function decode(string $encodedUuid): UuidInterface
{
@@ -93,10 +91,6 @@ class TimestampFirstCombCodec extends StringCodec
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
}
/**
* @inheritDoc
* @psalm-pure
*/
public function decodeBytes(string $bytes): UuidInterface
{
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
@@ -104,8 +98,6 @@ class TimestampFirstCombCodec extends StringCodec
/**
* Swaps bytes according to the timestamp-first COMB rules
*
* @psalm-pure
*/
private function swapBytes(string $bytes): string
{
+2
View File
@@ -43,6 +43,8 @@ namespace Ramsey\Uuid\Codec;
* ```
*
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
*
* @psalm-immutable
*/
class TimestampLastCombCodec extends StringCodec
{
@@ -22,6 +22,8 @@ use Ramsey\Uuid\Math\BrickMathCalculator;
* BigNumberConverter is deprecated in favor of GenericNumberConverter
*
* @deprecated Transition to {@see GenericNumberConverter}.
*
* @psalm-immutable
*/
class BigNumberConverter implements NumberConverterInterface
{
@@ -17,6 +17,8 @@ namespace Ramsey\Uuid\Converter\Number;
/**
* @deprecated DegradedNumberConverter is no longer necessary for converting
* numbers on 32-bit systems. Transition to {@see GenericNumberConverter}.
*
* @psalm-immutable
*/
class DegradedNumberConverter extends BigNumberConverter
{
@@ -21,6 +21,8 @@ use Ramsey\Uuid\Type\Integer as IntegerObject;
/**
* GenericNumberConverter uses the provided calculate to convert decimal
* numbers to and from hexadecimal values
*
* @psalm-immutable
*/
class GenericNumberConverter implements NumberConverterInterface
{
@@ -17,6 +17,8 @@ namespace Ramsey\Uuid\Converter;
/**
* A number converter converts UUIDs from hexadecimal characters into
* representations of integers and vice versa
*
* @psalm-immutable
*/
interface NumberConverterInterface
{
@@ -24,6 +24,8 @@ use Ramsey\Uuid\Type\Time;
* BigNumberTimeConverter is deprecated in favor of GenericTimeConverter
*
* @deprecated Transition to {@see GenericTimeConverter}.
*
* @psalm-immutable
*/
class BigNumberTimeConverter implements TimeConverterInterface
{
@@ -17,6 +17,8 @@ namespace Ramsey\Uuid\Converter\Time;
/**
* @deprecated DegradedTimeConverter is no longer necessary for converting
* time on 32-bit systems. Transition to {@see GenericTimeConverter}.
*
* @psalm-immutable
*/
class DegradedTimeConverter extends BigNumberTimeConverter
{
@@ -29,6 +29,8 @@ use const STR_PAD_LEFT;
/**
* GenericTimeConverter uses the provided calculator to calculate and convert
* time values
*
* @psalm-immutable
*/
class GenericTimeConverter implements TimeConverterInterface
{
+2
View File
@@ -37,6 +37,8 @@ use const STR_PAD_RIGHT;
* PhpTimeConverter uses built-in PHP functions and standard math operations
* available to the PHP programming language to provide facilities for
* converting parts of time into representations that may be used in UUIDs
*
* @psalm-immutable
*/
class PhpTimeConverter implements TimeConverterInterface
{
+2
View File
@@ -20,6 +20,8 @@ use Ramsey\Uuid\Type\Time;
/**
* A time converter converts timestamps into representations that may be used
* in UUIDs
*
* @psalm-immutable
*/
interface TimeConverterInterface
{
+1
View File
@@ -427,6 +427,7 @@ class FeatureSet
return new GuidBuilder($this->numberConverter, $this->timeConverter);
}
/** @psalm-suppress ImpureArgument */
return new FallbackBuilder(new BuilderCollection([
new Rfc4122UuidBuilder($this->numberConverter, $this->timeConverter),
new NonstandardUuidBuilder($this->numberConverter, $this->timeConverter),
+2
View File
@@ -19,6 +19,8 @@ use function base64_encode;
/**
* Provides common serialization functionality to fields
*
* @psalm-immutable
*/
trait SerializableFieldsTrait
{
+2
View File
@@ -16,6 +16,8 @@ namespace Ramsey\Uuid\Rfc4122;
/**
* Provides common functionality for handling the version, as defined by RFC 4122
*
* @psalm-immutable
*/
trait VersionTrait
{