Propagating @psalm-pure to factories and builders used internally to purely assemble a UuidInterface

Ref: https://github.com/ramsey/uuid/pull/300#issuecomment-601329450
This commit is contained in:
Marco Pivetta
2020-03-23 10:16:15 +01:00
parent c8e8b7b693
commit 15a5d4f5e1
12 changed files with 40 additions and 12 deletions
+2
View File
@@ -61,6 +61,8 @@ class DegradedUuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+2
View File
@@ -48,6 +48,8 @@ class FallbackBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return UuidInterface an instance of a UUID object
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+2
View File
@@ -32,6 +32,8 @@ interface UuidBuilderInterface
*
* @return UuidInterface Implementations may choose to return more specific
* instances of UUIDs that implement UuidInterface
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface;
}
+1
View File
@@ -25,6 +25,7 @@ use function hash;
*/
class DefaultNameGenerator implements NameGeneratorInterface
{
/** @psalm-pure */
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
/** @var string|bool $bytes */
+2
View File
@@ -31,6 +31,8 @@ interface NameGeneratorInterface
* @param string $hashAlgorithm The hashing algorithm to use
*
* @return string A binary string
*
* @psalm-pure
*/
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string;
}
+1
View File
@@ -30,6 +30,7 @@ use function uuid_parse;
*/
class PeclUuidNameGenerator implements NameGeneratorInterface
{
/** @psalm-pure */
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
{
switch ($hashAlgorithm) {
+2
View File
@@ -62,6 +62,8 @@ class GuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid\Guid
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+2
View File
@@ -61,6 +61,8 @@ class UuidBuilder implements UuidBuilderInterface
*
* @return Uuid The Nonstandard\UuidBuilder returns an instance of
* Nonstandard\Uuid
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+2
View File
@@ -65,6 +65,8 @@ class UuidBuilder implements UuidBuilderInterface
* @param string $bytes The byte string from which to construct a UUID
*
* @return Rfc4122UuidInterface UuidBuilder returns instances of Rfc4122UuidInterface
*
* @psalm-pure
*/
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
+8
View File
@@ -351,6 +351,7 @@ class UuidFactory implements UuidFactoryInterface
/**
* @inheritDoc
* @psalm-pure
*/
public function uuid3($ns, string $name): UuidInterface
{
@@ -366,6 +367,7 @@ class UuidFactory implements UuidFactoryInterface
/**
* @inheritDoc
* @psalm-pure
*/
public function uuid5($ns, string $name): UuidInterface
{
@@ -401,6 +403,8 @@ class UuidFactory implements UuidFactoryInterface
*
* @return UuidInterface An instance of UuidInterface, created from the
* provided bytes
*
* @psalm-pure
*/
public function uuid(string $bytes): UuidInterface
{
@@ -418,6 +422,8 @@ class UuidFactory implements UuidFactoryInterface
*
* @return UuidInterface An instance of UuidInterface, created by hashing
* together the provided namespace and name
*
* @psalm-pure
*/
private function uuidFromNsAndName($ns, string $name, int $version, string $hashAlgorithm): UuidInterface
{
@@ -438,6 +444,8 @@ class UuidFactory implements UuidFactoryInterface
*
* @return UuidInterface An instance of UuidInterface, created from the
* byte string and version
*
* @psalm-pure
*/
private function uuidFromBytesAndVersion(string $bytes, int $version): UuidInterface
{
+4
View File
@@ -83,6 +83,8 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* version 3 UUID
*
* @psalm-pure
*/
public function uuid3($ns, string $name): UuidInterface;
@@ -103,6 +105,8 @@ interface UuidFactoryInterface
*
* @return UuidInterface A UuidInterface instance that represents a
* version 5 UUID
*
* @psalm-pure
*/
public function uuid5($ns, string $name): UuidInterface;
+12 -12
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.8.3@389af1bfc739bfdff3f9e3dc7bd6499aee51a831">
<files psalm-version="3.9.4@352bd3f5c5789db04e4010856c2f4e01ed354f4e">
<file src="src/Builder/DegradedUuidBuilder.php">
<DeprecatedClass occurrences="3">
<code>new DegradedTimeConverter()</code>
@@ -44,6 +44,13 @@
<code>uuid_parse($uuid)</code>
</MixedReturnStatement>
</file>
<file src="src/Generator/PeclUuidNameGenerator.php">
<ImpureFunctionCall occurrences="3">
<code>uuid_generate_md5</code>
<code>uuid_generate_sha1</code>
<code>uuid_parse</code>
</ImpureFunctionCall>
</file>
<file src="src/Provider/Dce/SystemDceSecurityProvider.php">
<ForbiddenCode occurrences="5">
<code>shell_exec('id -u')</code>
@@ -54,23 +61,16 @@
</ForbiddenCode>
</file>
<file src="src/Provider/Node/SystemNodeProvider.php">
<MixedArgument occurrences="2">
<code>$node</code>
<MixedArgument occurrences="1">
<code>$macs</code>
</MixedArgument>
<MixedAssignment occurrences="2">
<code>$node</code>
<MixedAssignment occurrences="1">
<code>$node</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="1">
<code>getNode</code>
</MixedInferredReturnType>
<TypeDoesNotContainType occurrences="1">
<code>is_array($node)</code>
</TypeDoesNotContainType>
</file>
<file src="src/Uuid.php">
<ImpureMethodCall occurrences="5">
<ImpureMethodCall occurrences="6">
<code>getFactory</code>
<code>getFactory</code>
<code>getFactory</code>
<code>getFactory</code>