diff --git a/composer.json b/composer.json index 45a0908..ee0162e 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "suggest": { "ext-ctype": "Provides support for PHP Ctype functions", "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-openssl": "Provides the OpenSSL extension for use with the OpenSslGenerator", "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", diff --git a/src/Codec/CodecInterface.php b/src/Codec/CodecInterface.php index 6ea2054..c6c54c7 100644 --- a/src/Codec/CodecInterface.php +++ b/src/Codec/CodecInterface.php @@ -14,6 +14,8 @@ namespace Ramsey\Uuid\Codec; +use InvalidArgumentException; +use Ramsey\Uuid\Exception\InvalidUuidStringException; use Ramsey\Uuid\UuidInterface; /** @@ -42,7 +44,7 @@ interface CodecInterface * * @param string $encodedUuid * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function decode($encodedUuid); @@ -51,8 +53,8 @@ interface CodecInterface * * @param string $bytes * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException - * @throws \InvalidArgumentException if string has not 16 characters + * @throws InvalidUuidStringException + * @throws InvalidArgumentException if string has not 16 characters */ public function decodeBytes($bytes); } diff --git a/src/Codec/GuidStringCodec.php b/src/Codec/GuidStringCodec.php index 864980b..3675480 100644 --- a/src/Codec/GuidStringCodec.php +++ b/src/Codec/GuidStringCodec.php @@ -14,6 +14,7 @@ namespace Ramsey\Uuid\Codec; +use Ramsey\Uuid\Exception\InvalidUuidStringException; use Ramsey\Uuid\UuidInterface; /** @@ -60,7 +61,7 @@ class GuidStringCodec extends StringCodec * * @param string $encodedUuid * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function decode($encodedUuid) { @@ -76,7 +77,7 @@ class GuidStringCodec extends StringCodec * * @param string $bytes * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function decodeBytes($bytes) { diff --git a/src/Codec/OrderedTimeCodec.php b/src/Codec/OrderedTimeCodec.php index 3257759..de91aab 100644 --- a/src/Codec/OrderedTimeCodec.php +++ b/src/Codec/OrderedTimeCodec.php @@ -50,7 +50,7 @@ class OrderedTimeCodec extends StringCodec * * @param string $bytes * @return UuidInterface - * @throws \InvalidArgumentException if string has not 16 characters + * @throws InvalidArgumentException if string has not 16 characters */ public function decodeBytes($bytes) { diff --git a/src/Codec/StringCodec.php b/src/Codec/StringCodec.php index e74e0e9..f1bc024 100644 --- a/src/Codec/StringCodec.php +++ b/src/Codec/StringCodec.php @@ -74,7 +74,7 @@ class StringCodec implements CodecInterface * * @param string $encodedUuid * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function decode($encodedUuid) { @@ -89,7 +89,7 @@ class StringCodec implements CodecInterface * * @param string $bytes * @return UuidInterface - * @throws \InvalidArgumentException if string has not 16 characters + * @throws InvalidArgumentException if string has not 16 characters */ public function decodeBytes($bytes) { @@ -117,7 +117,7 @@ class StringCodec implements CodecInterface * * @param string $encodedUuid * @return array - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ protected function extractComponents($encodedUuid) { diff --git a/src/Codec/TimestampFirstCombCodec.php b/src/Codec/TimestampFirstCombCodec.php index 2c4ded8..270a1e7 100644 --- a/src/Codec/TimestampFirstCombCodec.php +++ b/src/Codec/TimestampFirstCombCodec.php @@ -13,6 +13,7 @@ */ namespace Ramsey\Uuid\Codec; +use Ramsey\Uuid\Exception\InvalidUuidStringException; use Ramsey\Uuid\UuidInterface; /** @@ -60,7 +61,7 @@ class TimestampFirstCombCodec extends StringCodec * @param string $encodedUuid * * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function decode($encodedUuid) { @@ -77,7 +78,7 @@ class TimestampFirstCombCodec extends StringCodec * @param string $bytes * * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function decodeBytes($bytes) { diff --git a/src/Converter/NumberConverterInterface.php b/src/Converter/NumberConverterInterface.php index 9505e8c..b978e2e 100644 --- a/src/Converter/NumberConverterInterface.php +++ b/src/Converter/NumberConverterInterface.php @@ -14,6 +14,8 @@ namespace Ramsey\Uuid\Converter; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; + /** * NumberConverterInterface converts UUIDs from hexadecimal characters into * representations of integers and vice versa @@ -28,7 +30,7 @@ interface NumberConverterInterface * * @param string $hex The hexadecimal string representation to convert * @return mixed - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present */ public function fromHex($hex); @@ -40,7 +42,7 @@ interface NumberConverterInterface * a true integer, a string integer, or a object representation that * this converter can understand * @return string Hexadecimal string - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present */ public function toHex($integer); } diff --git a/src/Converter/TimeConverterInterface.php b/src/Converter/TimeConverterInterface.php index 382008a..c851792 100644 --- a/src/Converter/TimeConverterInterface.php +++ b/src/Converter/TimeConverterInterface.php @@ -14,6 +14,8 @@ namespace Ramsey\Uuid\Converter; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; + /** * TimeConverterInterface provides facilities for converting parts of time into * representations that may be used in UUIDs @@ -27,7 +29,7 @@ interface TimeConverterInterface * @param string $seconds * @param string $microSeconds * @return string[] An array guaranteed to contain `low`, `mid`, and `high` keys - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * @throws UnsatisfiedDependencyException if called on a 32-bit system and * `Moontoast\Math\BigNumber` is not present * @link http://tools.ietf.org/html/rfc4122#section-4.2.2 */ diff --git a/src/DegradedUuid.php b/src/DegradedUuid.php index bcf0be8..2669761 100644 --- a/src/DegradedUuid.php +++ b/src/DegradedUuid.php @@ -14,6 +14,8 @@ namespace Ramsey\Uuid; +use DateTime; +use Moontoast\Math\BigNumber; use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; use Ramsey\Uuid\Exception\UnsupportedOperationException; @@ -35,13 +37,13 @@ class DegradedUuid extends Uuid $time = $this->converter->fromHex($this->getTimestampHex()); - $ts = new \Moontoast\Math\BigNumber($time, 20); + $ts = new BigNumber($time, 20); $ts->subtract('122192928000000000'); $ts->divide('10000000.0'); $ts->round(); $unixTime = $ts->getValue(); - return new \DateTime("@{$unixTime}"); + return new DateTime("@{$unixTime}"); } /** diff --git a/src/Exception/InvalidUuidStringException.php b/src/Exception/InvalidUuidStringException.php index 0e48064..7df0e8c 100644 --- a/src/Exception/InvalidUuidStringException.php +++ b/src/Exception/InvalidUuidStringException.php @@ -14,9 +14,11 @@ namespace Ramsey\Uuid\Exception; +use InvalidArgumentException; + /** * Thrown to indicate that the parsed UUID string is invalid. */ -class InvalidUuidStringException extends \InvalidArgumentException +class InvalidUuidStringException extends InvalidArgumentException { } diff --git a/src/Exception/UnsatisfiedDependencyException.php b/src/Exception/UnsatisfiedDependencyException.php index 8b5d5d0..89c7396 100644 --- a/src/Exception/UnsatisfiedDependencyException.php +++ b/src/Exception/UnsatisfiedDependencyException.php @@ -14,10 +14,12 @@ namespace Ramsey\Uuid\Exception; +use RuntimeException; + /** * Thrown to indicate that the requested operation has dependencies that have not * been satisfied. */ -class UnsatisfiedDependencyException extends \RuntimeException +class UnsatisfiedDependencyException extends RuntimeException { } diff --git a/src/Exception/UnsupportedOperationException.php b/src/Exception/UnsupportedOperationException.php index b371b68..4340947 100644 --- a/src/Exception/UnsupportedOperationException.php +++ b/src/Exception/UnsupportedOperationException.php @@ -14,9 +14,11 @@ namespace Ramsey\Uuid\Exception; +use RuntimeException; + /** * Thrown to indicate that the requested operation is not supported. */ -class UnsupportedOperationException extends \RuntimeException +class UnsupportedOperationException extends RuntimeException { } diff --git a/src/Generator/CombGenerator.php b/src/Generator/CombGenerator.php index 7a94823..1d4a5f6 100644 --- a/src/Generator/CombGenerator.php +++ b/src/Generator/CombGenerator.php @@ -14,7 +14,10 @@ namespace Ramsey\Uuid\Generator; +use Exception; +use InvalidArgumentException; use Ramsey\Uuid\Converter\NumberConverterInterface; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; /** * CombGenerator provides functionality to generate COMB (combined GUID/timestamp) @@ -53,14 +56,14 @@ class CombGenerator implements RandomGeneratorInterface * * @param integer $length The number of bytes of random binary data to generate * @return string A binary string - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException if length is not a positive integer - * @throws \Exception + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws InvalidArgumentException if length is not a positive integer + * @throws Exception */ public function generate($length) { if ($length < self::TIMESTAMP_BYTES || $length < 0) { - throw new \InvalidArgumentException('Length must be a positive integer.'); + throw new InvalidArgumentException('Length must be a positive integer.'); } $hash = ''; diff --git a/src/Generator/DefaultTimeGenerator.php b/src/Generator/DefaultTimeGenerator.php index 5abb631..5c5ccb2 100644 --- a/src/Generator/DefaultTimeGenerator.php +++ b/src/Generator/DefaultTimeGenerator.php @@ -14,8 +14,11 @@ namespace Ramsey\Uuid\Generator; +use Exception; +use InvalidArgumentException; use Ramsey\Uuid\BinaryUtils; use Ramsey\Uuid\Converter\TimeConverterInterface; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; use Ramsey\Uuid\Provider\NodeProviderInterface; use Ramsey\Uuid\Provider\TimeProviderInterface; @@ -72,10 +75,10 @@ class DefaultTimeGenerator implements TimeGeneratorInterface * could arise when the clock is set backwards in time or if the node ID * changes. * @return string A binary string - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * @throws UnsatisfiedDependencyException if called on a 32-bit system and * `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws InvalidArgumentException + * @throws Exception if it was not possible to gather sufficient entropy */ public function generate($node = null, $clockSeq = null) { @@ -115,8 +118,8 @@ class DefaultTimeGenerator implements TimeGeneratorInterface * * @param string|int $node A node value that may be used to override the node provider * @return string Hexadecimal representation of the node ID - * @throws \InvalidArgumentException - * @throws \Exception + * @throws InvalidArgumentException + * @throws Exception */ protected function getValidNode($node) { @@ -130,7 +133,7 @@ class DefaultTimeGenerator implements TimeGeneratorInterface } if (!ctype_xdigit($node) || strlen($node) > 12) { - throw new \InvalidArgumentException('Invalid node value'); + throw new InvalidArgumentException('Invalid node value'); } return strtolower(sprintf('%012s', $node)); diff --git a/src/Generator/RandomBytesGenerator.php b/src/Generator/RandomBytesGenerator.php index aaa285d..cc3d379 100644 --- a/src/Generator/RandomBytesGenerator.php +++ b/src/Generator/RandomBytesGenerator.php @@ -14,6 +14,8 @@ namespace Ramsey\Uuid\Generator; +use Exception; + /** * RandomBytesGenerator provides functionality to generate strings of random * binary data using `random_bytes()` function in PHP 7+ or paragonie/random_compat @@ -28,7 +30,7 @@ class RandomBytesGenerator implements RandomGeneratorInterface * * @param integer $length The number of bytes of random binary data to generate * @return string A binary string - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws Exception if it was not possible to gather sufficient entropy */ public function generate($length) { diff --git a/src/Generator/RandomGeneratorInterface.php b/src/Generator/RandomGeneratorInterface.php index 3a1bcae..b791d60 100644 --- a/src/Generator/RandomGeneratorInterface.php +++ b/src/Generator/RandomGeneratorInterface.php @@ -14,6 +14,10 @@ namespace Ramsey\Uuid\Generator; +use Exception; +use InvalidArgumentException; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; + /** * RandomGeneratorInterface provides functionality to generate strings of random * binary data @@ -25,9 +29,9 @@ interface RandomGeneratorInterface * * @param integer $length The number of bytes of random binary data to generate * @return string A binary string - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws InvalidArgumentException + * @throws Exception if it was not possible to gather sufficient entropy */ public function generate($length); } diff --git a/src/Generator/TimeGeneratorInterface.php b/src/Generator/TimeGeneratorInterface.php index cb182ea..27c7459 100644 --- a/src/Generator/TimeGeneratorInterface.php +++ b/src/Generator/TimeGeneratorInterface.php @@ -14,6 +14,10 @@ namespace Ramsey\Uuid\Generator; +use Exception; +use InvalidArgumentException; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; + /** * TimeGeneratorInterface provides functionality to generate strings of binary * data for version 1 UUIDs based on a host ID, sequence number, and the current @@ -30,10 +34,10 @@ interface TimeGeneratorInterface * could arise when the clock is set backwards in time or if the node ID * changes. * @return string A binary string - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * @throws UnsatisfiedDependencyException if called on a 32-bit system and * `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws InvalidArgumentException + * @throws Exception if it was not possible to gather sufficient entropy */ public function generate($node = null, $clockSeq = null); } diff --git a/src/Provider/Node/FallbackNodeProvider.php b/src/Provider/Node/FallbackNodeProvider.php index 289fdde..83488ab 100644 --- a/src/Provider/Node/FallbackNodeProvider.php +++ b/src/Provider/Node/FallbackNodeProvider.php @@ -14,6 +14,7 @@ namespace Ramsey\Uuid\Provider\Node; +use Exception; use Ramsey\Uuid\Provider\NodeProviderInterface; /** @@ -43,7 +44,7 @@ class FallbackNodeProvider implements NodeProviderInterface * and returning the first non-empty value found * * @return string System node ID as a hexadecimal string - * @throws \Exception + * @throws Exception */ public function getNode() { diff --git a/src/Provider/Node/RandomNodeProvider.php b/src/Provider/Node/RandomNodeProvider.php index 76c570d..75d0e64 100644 --- a/src/Provider/Node/RandomNodeProvider.php +++ b/src/Provider/Node/RandomNodeProvider.php @@ -14,6 +14,7 @@ namespace Ramsey\Uuid\Provider\Node; +use Exception; use Ramsey\Uuid\Provider\NodeProviderInterface; /** @@ -28,7 +29,7 @@ class RandomNodeProvider implements NodeProviderInterface * Returns the system node ID * * @return string System node ID as a hexadecimal string - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws Exception if it was not possible to gather sufficient entropy */ public function getNode() { diff --git a/src/Provider/NodeProviderInterface.php b/src/Provider/NodeProviderInterface.php index 14f747b..b6f721f 100644 --- a/src/Provider/NodeProviderInterface.php +++ b/src/Provider/NodeProviderInterface.php @@ -14,6 +14,8 @@ namespace Ramsey\Uuid\Provider; +use Exception; + /** * NodeProviderInterface provides functionality to get the node ID (or host ID * in the form of the system's MAC address) from a specific type of node provider @@ -24,7 +26,7 @@ interface NodeProviderInterface * Returns the system node ID * * @return string System node ID as a hexadecimal string - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws Exception if it was not possible to gather sufficient entropy */ public function getNode(); } diff --git a/src/Provider/Time/FixedTimeProvider.php b/src/Provider/Time/FixedTimeProvider.php index a62d39c..79a9d04 100644 --- a/src/Provider/Time/FixedTimeProvider.php +++ b/src/Provider/Time/FixedTimeProvider.php @@ -14,6 +14,7 @@ namespace Ramsey\Uuid\Provider\Time; +use InvalidArgumentException; use Ramsey\Uuid\Provider\TimeProviderInterface; /** @@ -33,12 +34,12 @@ class FixedTimeProvider implements TimeProviderInterface * Constructs a `FixedTimeProvider` using the provided `$timestamp` * * @param int[] Array containing `sec` and `usec` components of a timestamp - * @throws \InvalidArgumentException if the `$timestamp` does not contain `sec` or `usec` components + * @throws InvalidArgumentException if the `$timestamp` does not contain `sec` or `usec` components */ public function __construct(array $timestamp) { if (!array_key_exists('sec', $timestamp) || !array_key_exists('usec', $timestamp)) { - throw new \InvalidArgumentException('Array must contain sec and usec keys.'); + throw new InvalidArgumentException('Array must contain sec and usec keys.'); } $this->fixedTime = $timestamp; diff --git a/src/Uuid.php b/src/Uuid.php index a0cdae1..b5d546a 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -14,8 +14,13 @@ namespace Ramsey\Uuid; +use DateTime; +use Exception; +use InvalidArgumentException; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Codec\CodecInterface; +use Ramsey\Uuid\Exception\InvalidUuidStringException; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; use Ramsey\Uuid\Exception\UnsupportedOperationException; /** @@ -229,7 +234,7 @@ class Uuid implements UuidInterface * * @param string $serialized * @link http://php.net/manual/en/class.serializable.php - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function unserialize($serialized) { @@ -345,7 +350,7 @@ class Uuid implements UuidInterface $unixTime = ($this->getTimestamp() - 0x01b21dd213814000) / 1e7; $unixTime = number_format($unixTime, 0, '', ''); - return new \DateTime("@{$unixTime}"); + return new DateTime("@{$unixTime}"); } /** @@ -400,7 +405,7 @@ class Uuid implements UuidInterface * Returns the least significant 64 bits of this UUID's 128 bit value. * * @return mixed Converted representation of the unsigned 64-bit integer value - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present */ public function getLeastSignificantBits() { @@ -421,7 +426,7 @@ class Uuid implements UuidInterface * Returns the most significant 64 bits of this UUID's 128 bit value. * * @return mixed Converted representation of the unsigned 64-bit integer value - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present */ public function getMostSignificantBits() { @@ -624,8 +629,8 @@ class Uuid implements UuidInterface * * @param string $bytes * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException - * @throws \InvalidArgumentException + * @throws InvalidUuidStringException + * @throws InvalidArgumentException */ public static function fromBytes($bytes) { @@ -637,7 +642,7 @@ class Uuid implements UuidInterface * * @param string $name A string that specifies a UUID * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public static function fromString($name) { @@ -649,8 +654,8 @@ class Uuid implements UuidInterface * * @param string $integer String representation of 128-bit integer * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws InvalidUuidStringException */ public static function fromInteger($integer) { @@ -665,7 +670,7 @@ class Uuid implements UuidInterface */ public static function isValid($uuid) { - $uuid = str_replace(array('urn:', 'uuid:', '{', '}'), '', $uuid); + $uuid = str_replace(['urn:', 'uuid:', '{', '}'], '', $uuid); if ($uuid == self::NIL) { return true; @@ -687,10 +692,10 @@ class Uuid implements UuidInterface * could arise when the clock is set backwards in time or if the node ID * changes. * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * @throws UnsatisfiedDependencyException if called on a 32-bit system and * `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws InvalidArgumentException + * @throws Exception if it was not possible to gather sufficient entropy */ public static function uuid1($node = null, $clockSeq = null) { @@ -704,7 +709,7 @@ class Uuid implements UuidInterface * @param string $ns The UUID namespace in which to create the named UUID * @param string $name The name to create a UUID for * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public static function uuid3($ns, $name) { @@ -715,9 +720,9 @@ class Uuid implements UuidInterface * Generate a version 4 (random) UUID. * * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws InvalidArgumentException + * @throws Exception */ public static function uuid4() { @@ -731,7 +736,7 @@ class Uuid implements UuidInterface * @param string $ns The UUID namespace in which to create the named UUID * @param string $name The name to create a UUID for * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public static function uuid5($ns, $name) { diff --git a/src/UuidFactory.php b/src/UuidFactory.php index df5d8bf..5a57b09 100644 --- a/src/UuidFactory.php +++ b/src/UuidFactory.php @@ -15,6 +15,7 @@ namespace Ramsey\Uuid; use Ramsey\Uuid\Converter\NumberConverterInterface; +use Ramsey\Uuid\Exception\InvalidUuidStringException; use Ramsey\Uuid\Provider\NodeProviderInterface; use Ramsey\Uuid\Generator\RandomGeneratorInterface; use Ramsey\Uuid\Generator\TimeGeneratorInterface; @@ -274,7 +275,7 @@ class UuidFactory implements UuidFactoryInterface * @param string $hashFunction The hash function to use when hashing together * the namespace and name * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ protected function uuidFromNsAndName($ns, $name, $version, $hashFunction) { diff --git a/src/UuidFactoryInterface.php b/src/UuidFactoryInterface.php index a228f5b..f78dda2 100644 --- a/src/UuidFactoryInterface.php +++ b/src/UuidFactoryInterface.php @@ -14,6 +14,11 @@ namespace Ramsey\Uuid; +use Exception; +use InvalidArgumentException; +use Ramsey\Uuid\Exception\InvalidUuidStringException; +use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; + /** * UuidFactoryInterface defines common functionality all `UuidFactory` instances * must implement @@ -29,10 +34,10 @@ interface UuidFactoryInterface * could arise when the clock is set backwards in time or if the node ID * changes. * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if called on a 32-bit system and + * @throws UnsatisfiedDependencyException if called on a 32-bit system and * `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception if it was not possible to gather sufficient entropy + * @throws InvalidArgumentException + * @throws Exception if it was not possible to gather sufficient entropy */ public function uuid1($node = null, $clockSeq = null); @@ -43,7 +48,7 @@ interface UuidFactoryInterface * @param string $ns The UUID namespace in which to create the named UUID * @param string $name The name to create a UUID for * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function uuid3($ns, $name); @@ -51,9 +56,9 @@ interface UuidFactoryInterface * Generate a version 4 (random) UUID. * * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present - * @throws \InvalidArgumentException - * @throws \Exception + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws InvalidArgumentException + * @throws Exception */ public function uuid4(); @@ -64,7 +69,7 @@ interface UuidFactoryInterface * @param string $ns The UUID namespace in which to create the named UUID * @param string $name The name to create a UUID for * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function uuid5($ns, $name); @@ -73,8 +78,8 @@ interface UuidFactoryInterface * * @param string $bytes A 16-byte string representation of a UUID * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException - * @throws \InvalidArgumentException if string has not 16 characters + * @throws InvalidUuidStringException + * @throws InvalidArgumentException if string has not 16 characters */ public function fromBytes($bytes); @@ -83,7 +88,7 @@ interface UuidFactoryInterface * * @param string $uuid A string representation of a UUID * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws InvalidUuidStringException */ public function fromString($uuid); @@ -96,8 +101,8 @@ interface UuidFactoryInterface * @param mixed $integer The integer to use when creating a `Uuid` from an * integer; may be of any type understood by the configured number converter * @return UuidInterface - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present - * @throws \Ramsey\Uuid\Exception\InvalidUuidStringException + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws InvalidUuidStringException */ public function fromInteger($integer); } diff --git a/src/UuidInterface.php b/src/UuidInterface.php index e1cea67..42a3ad7 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -137,7 +137,7 @@ interface UuidInterface extends JsonSerializable, Serializable * representation. * * @return mixed Converted representation of the unsigned 128-bit integer value - * @throws \Ramsey\Uuid\Exception\UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present + * @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present */ public function getInteger(); diff --git a/tests/Builder/DefaultUuidBuilderTest.php b/tests/Builder/DefaultUuidBuilderTest.php index b6dc731..125b497 100644 --- a/tests/Builder/DefaultUuidBuilderTest.php +++ b/tests/Builder/DefaultUuidBuilderTest.php @@ -2,6 +2,7 @@ namespace Ramsey\Uuid\Test\Builder; +use PHPUnit_Framework_TestCase; use Ramsey\Uuid\Builder\DefaultUuidBuilder; /** @@ -9,7 +10,7 @@ use Ramsey\Uuid\Builder\DefaultUuidBuilder; * @package Ramsey\Uuid\Test\Builder * @covers Ramsey\Uuid\Builder\DefaultUuidBuilder */ -class DefaultUuidBuilderTest extends \PHPUnit_Framework_TestCase +class DefaultUuidBuilderTest extends PHPUnit_Framework_TestCase { public function testBuildCreatesUuid() diff --git a/tests/Builder/DegradedUuidBuilderTest.php b/tests/Builder/DegradedUuidBuilderTest.php index fbc222e..ce017e2 100644 --- a/tests/Builder/DegradedUuidBuilderTest.php +++ b/tests/Builder/DegradedUuidBuilderTest.php @@ -2,6 +2,7 @@ namespace Ramsey\Uuid\Test\Builder; +use PHPUnit_Framework_TestCase; use Ramsey\Uuid\Builder\DegradedUuidBuilder; /** @@ -9,7 +10,7 @@ use Ramsey\Uuid\Builder\DegradedUuidBuilder; * @package Ramsey\Uuid\Test\Builder * @covers Ramsey\Uuid\Builder\DegradedUuidBuilder */ -class DegradedUuidBuilderTest extends \PHPUnit_Framework_TestCase +class DegradedUuidBuilderTest extends PHPUnit_Framework_TestCase { public function testBuildCreatesUuid() diff --git a/tests/Converter/Time/PhpTimeConverterTest.php b/tests/Converter/Time/PhpTimeConverterTest.php index 5492956..47a3a17 100644 --- a/tests/Converter/Time/PhpTimeConverterTest.php +++ b/tests/Converter/Time/PhpTimeConverterTest.php @@ -2,6 +2,7 @@ namespace Ramsey\Uuid\Test\Converter; +use PHPUnit_Framework_TestCase; use Ramsey\Uuid\Converter\Time\PhpTimeConverter; /** @@ -9,7 +10,7 @@ use Ramsey\Uuid\Converter\Time\PhpTimeConverter; * @package Ramsey\Uuid\Test\Converter * @covers Ramsey\Uuid\Converter\Time\PhpTimeConverter */ -class PhpTimeConverterTest extends \PHPUnit_Framework_TestCase +class PhpTimeConverterTest extends PHPUnit_Framework_TestCase { public function testCalculateTimeReturnsArrayOfTimeSegments() diff --git a/tests/Encoder/TimestampFirstCombCodecTest.php b/tests/Encoder/TimestampFirstCombCodecTest.php index f16bd8d..248f6cb 100644 --- a/tests/Encoder/TimestampFirstCombCodecTest.php +++ b/tests/Encoder/TimestampFirstCombCodecTest.php @@ -29,7 +29,7 @@ class TimestampFirstCombCodecTest extends TestCase $uuidMock = $this->getMockBuilder('Ramsey\Uuid\UuidInterface')->getMock(); $uuidMock->expects($this->any()) ->method('getFieldsHex') - ->willReturn(array('ff6f8cb0', 'c57d', '11e1', '9b', '21', '0800200c9a66')); + ->willReturn(['ff6f8cb0', 'c57d', '11e1', '9b', '21', '0800200c9a66']); $encodedUuid = $this->codec->encode($uuidMock); $this->assertSame('0800200c-9a66-11e1-9b21-ff6f8cb0c57d', $encodedUuid); @@ -40,7 +40,7 @@ class TimestampFirstCombCodecTest extends TestCase $uuidMock = $this->getMockBuilder('Ramsey\Uuid\UuidInterface')->getMock(); $uuidMock->expects($this->any()) ->method('getFieldsHex') - ->willReturn(array('ff6f8cb0', 'c57d', '11e1', '9b', '21', '0800200c9a66')); + ->willReturn(['ff6f8cb0', 'c57d', '11e1', '9b', '21', '0800200c9a66']); $encodedUuid = $this->codec->encodeBinary($uuidMock); $this->assertSame(hex2bin('0800200c9a6611e19b21ff6f8cb0c57d'), $encodedUuid); @@ -52,14 +52,14 @@ class TimestampFirstCombCodecTest extends TestCase ->method('build') ->with( $this->codec, - array( + [ 'time_low' => 'ff6f8cb0', 'time_mid' => 'c57d', 'time_hi_and_version' => '11e1', 'clock_seq_hi_and_reserved' => '9b', 'clock_seq_low' => '21', 'node' => '0800200c9a66' - ) + ] ); $this->codec->decode('0800200c-9a66-11e1-9b21-ff6f8cb0c57d'); } @@ -70,14 +70,14 @@ class TimestampFirstCombCodecTest extends TestCase ->method('build') ->with( $this->codec, - array( + [ 'time_low' => 'ff6f8cb0', 'time_mid' => 'c57d', 'time_hi_and_version' => '11e1', 'clock_seq_hi_and_reserved' => '9b', 'clock_seq_low' => '21', 'node' => '0800200c9a66' - ) + ] ); $this->codec->decodeBytes(hex2bin('0800200c9a6611e19b21ff6f8cb0c57d')); } diff --git a/tests/Encoder/TimestampLastCombCodecTest.php b/tests/Encoder/TimestampLastCombCodecTest.php index edfd9c2..266449b 100644 --- a/tests/Encoder/TimestampLastCombCodecTest.php +++ b/tests/Encoder/TimestampLastCombCodecTest.php @@ -29,7 +29,7 @@ class TimestampLastCombCodecTest extends TestCase $uuidMock = $this->getMockBuilder('Ramsey\Uuid\UuidInterface')->getMock(); $uuidMock->expects($this->any()) ->method('getFieldsHex') - ->willReturn(array('0800200c', '9a66', '11e1', '9b', '21', 'ff6f8cb0c57d')); + ->willReturn(['0800200c', '9a66', '11e1', '9b', '21', 'ff6f8cb0c57d']); $encodedUuid = $this->codec->encode($uuidMock); $this->assertSame('0800200c-9a66-11e1-9b21-ff6f8cb0c57d', $encodedUuid); @@ -52,14 +52,14 @@ class TimestampLastCombCodecTest extends TestCase ->method('build') ->with( $this->codec, - array( + [ 'time_low' => '0800200c', 'time_mid' => '9a66', 'time_hi_and_version' => '11e1', 'clock_seq_hi_and_reserved' => '9b', 'clock_seq_low' => '21', 'node' => 'ff6f8cb0c57d' - ) + ] ); $this->codec->decode('0800200c-9a66-11e1-9b21-ff6f8cb0c57d'); } @@ -70,14 +70,14 @@ class TimestampLastCombCodecTest extends TestCase ->method('build') ->with( $this->codec, - array( + [ 'time_low' => '0800200c', 'time_mid' => '9a66', 'time_hi_and_version' => '11e1', 'clock_seq_hi_and_reserved' => '9b', 'clock_seq_low' => '21', 'node' => 'ff6f8cb0c57d' - ) + ] ); $this->codec->decodeBytes(hex2bin('0800200c9a6611e19b21ff6f8cb0c57d')); } diff --git a/tests/Generator/CombGeneratorTest.php b/tests/Generator/CombGeneratorTest.php index 1ecc47b..28bbd55 100644 --- a/tests/Generator/CombGeneratorTest.php +++ b/tests/Generator/CombGeneratorTest.php @@ -70,6 +70,8 @@ class CombGeneratorTest extends TestCase /** * @dataProvider lengthLessThanSix + * @param $length + * @throws \Exception */ public function testGenerateWithLessThanTimestampBytesThrowsException($length) { diff --git a/tests/Generator/MtRandGeneratorTest.php b/tests/Generator/MtRandGeneratorTest.php index b670ccd..9936020 100644 --- a/tests/Generator/MtRandGeneratorTest.php +++ b/tests/Generator/MtRandGeneratorTest.php @@ -25,6 +25,7 @@ class MtRandGeneratorTest extends TestCase /** * @dataProvider lengthDataProvider + * @param $length */ public function testGenerateReturnsStringOfGivenLength($length) { diff --git a/tests/Generator/OpenSslGeneratorTest.php b/tests/Generator/OpenSslGeneratorTest.php index d83c4d1..33f28ae 100644 --- a/tests/Generator/OpenSslGeneratorTest.php +++ b/tests/Generator/OpenSslGeneratorTest.php @@ -26,6 +26,8 @@ class OpenSslGeneratorTest extends TestCase * @dataProvider lengthAndHexDataProvider * @runInSeparateProcess * @preserveGlobalState disabled + * @param $length + * @param $hex */ public function testGenerateUsesOpenSsl($length, $hex) { @@ -41,6 +43,8 @@ class OpenSslGeneratorTest extends TestCase * @dataProvider lengthAndHexDataProvider * @runInSeparateProcess * @preserveGlobalState disabled + * @param $length + * @param $hex */ public function testGenerateReturnsRandomBytes($length, $hex) { diff --git a/tests/Generator/RandomBytesGeneratorTest.php b/tests/Generator/RandomBytesGeneratorTest.php index b7bf593..cd1092c 100644 --- a/tests/Generator/RandomBytesGeneratorTest.php +++ b/tests/Generator/RandomBytesGeneratorTest.php @@ -28,6 +28,7 @@ class RandomBytesGeneratorTest extends TestCase * @preserveGlobalState disabled * @param int $length * @param string $hex + * @throws \Exception */ public function testGenerateUsesOpenSsl($length, $hex) { @@ -45,6 +46,7 @@ class RandomBytesGeneratorTest extends TestCase * @preserveGlobalState disabled * @param int $length * @param string $hex + * @throws \Exception */ public function testGenerateReturnsRandomBytes($length, $hex) { diff --git a/tests/Generator/SodiumRandomGeneratorTest.php b/tests/Generator/SodiumRandomGeneratorTest.php index 1981bce..7716d6d 100644 --- a/tests/Generator/SodiumRandomGeneratorTest.php +++ b/tests/Generator/SodiumRandomGeneratorTest.php @@ -5,6 +5,8 @@ namespace Ramsey\Uuid\Test\Generator; use phpmock\phpunit\PHPMock; use Ramsey\Uuid\Test\TestCase; use Ramsey\Uuid\Generator\SodiumRandomGenerator; +use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\UuidFactory; class SodiumRandomGeneratorTest extends TestCase { @@ -33,11 +35,11 @@ class SodiumRandomGeneratorTest extends TestCase public function testFactoryUsesSodiumRandomGenerator() { $this->skipIfLibsodiumExtensionNotLoaded(); - $uuidFactory = new \Ramsey\Uuid\UuidFactory(); + $uuidFactory = new UuidFactory(); $uuidFactory->setRandomGenerator(new SodiumRandomGenerator()); - \Ramsey\Uuid\Uuid::setFactory($uuidFactory); + Uuid::setFactory($uuidFactory); - $uuid = \Ramsey\Uuid\Uuid::uuid4(); + $uuid = Uuid::uuid4(); $this->assertInstanceOf( 'Ramsey\Uuid\Generator\SodiumRandomGenerator', diff --git a/tests/Provider/Node/SystemNodeProviderTest.php b/tests/Provider/Node/SystemNodeProviderTest.php index 783a9f5..a51b37c 100644 --- a/tests/Provider/Node/SystemNodeProviderTest.php +++ b/tests/Provider/Node/SystemNodeProviderTest.php @@ -3,6 +3,7 @@ namespace Ramsey\Uuid\Test\Provider\Node; use AspectMock\Proxy\FuncProxy; +use InvalidArgumentException; use Ramsey\Uuid\Provider\Node\SystemNodeProvider; use Ramsey\Uuid\Test\TestCase; use AspectMock\Test as AspectMock; @@ -574,7 +575,7 @@ class SystemNodeProviderTest extends TestCase 'Given parameter for %s must be an array or NULL, "%s" given.', [$key, gettype($asserts)] ); - throw new \InvalidArgumentException($error); + throw new InvalidArgumentException($error); } }); } diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 9cf2a17..f4f73b3 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -10,6 +10,7 @@ use Ramsey\Uuid\Generator\CombGenerator; use Ramsey\Uuid\Generator\RandomGeneratorFactory; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidFactory; +use stdClass; class UuidTest extends TestCase { @@ -80,7 +81,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\InvalidUuidStringException + * @expectedException Ramsey\Uuid\Exception\InvalidUuidStringException * @expectedExceptionMessage Invalid UUID string: */ public function testFromStringWithInvalidUuidString() @@ -89,7 +90,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\InvalidUuidStringException + * @expectedException Ramsey\Uuid\Exception\InvalidUuidStringException * @expectedExceptionMessage Invalid UUID string: */ public function testFromStringWithTrailingNewLine() @@ -217,7 +218,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetDateTimeThrownException() { @@ -232,7 +233,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsupportedOperationException + * @expectedException Ramsey\Uuid\Exception\UnsupportedOperationException * @expectedExceptionMessage Not a time-based UUID */ public function testGetDateTimeFromNonVersion1Uuid() @@ -248,14 +249,14 @@ class UuidTest extends TestCase { $this->skip64BitTest(); - $fields = array( + $fields = [ 'time_low' => 4285500592, 'time_mid' => 50557, 'time_hi_and_version' => 4577, 'clock_seq_hi_and_reserved' => 155, 'clock_seq_low' => 33, 'node' => 8796630719078, - ); + ]; $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); @@ -263,7 +264,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetFields32Bit() { @@ -277,14 +278,14 @@ class UuidTest extends TestCase */ public function testGetFieldsHex() { - $fields = array( + $fields = [ 'time_low' => 'ff6f8cb0', 'time_mid' => 'c57d', 'time_hi_and_version' => '11e1', 'clock_seq_hi_and_reserved' => '9b', 'clock_seq_low' => '21', 'node' => '0800200c9a66', - ); + ]; $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'); @@ -303,7 +304,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetLeastSignificantBitsException() { @@ -333,7 +334,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetMostSignificantBitsException() { @@ -362,7 +363,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetNode32Bit() { @@ -407,7 +408,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetTimeLow32Bit() { @@ -470,7 +471,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsupportedOperationException + * @expectedException Ramsey\Uuid\Exception\UnsupportedOperationException * @expectedExceptionMessage Not a time-based UUID */ public function testGetTimestampFromNonVersion1Uuid() @@ -481,7 +482,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsupportedOperationException + * @expectedException Ramsey\Uuid\Exception\UnsupportedOperationException * @expectedExceptionMessage Not a time-based UUID */ public function testGetTimestampHexFromNonVersion1Uuid() @@ -492,7 +493,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetTimestamp32Bit() { @@ -788,12 +789,12 @@ class UuidTest extends TestCase */ public function testUuid3WithKnownUuids() { - $uuids = array( + $uuids = [ '6fa459ea-ee8a-3ca4-894e-db77e160355e' => Uuid::uuid3(Uuid::NAMESPACE_DNS, 'python.org'), '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d' => Uuid::uuid3(Uuid::NAMESPACE_URL, 'http://python.org/'), 'dd1a1cef-13d5-368a-ad82-eca71acd4cd1' => Uuid::uuid3(Uuid::NAMESPACE_OID, '1.3.6.1'), '658d3002-db6b-3040-a1d1-8ddd7d189a4d' => Uuid::uuid3(Uuid::NAMESPACE_X500, 'c=ca'), - ); + ]; foreach ($uuids as $ustr => $uobj) { $this->assertEquals(Uuid::RFC_4122, $uobj->getVariant()); @@ -815,7 +816,7 @@ class UuidTest extends TestCase /** * Tests that generated UUID's using timestamp last COMB are sequential - * @return string + * @throws \Exception */ public function testUuid4TimestampLastComb() { @@ -847,7 +848,7 @@ class UuidTest extends TestCase /** * Tests that generated UUID's using timestamp first COMB are sequential - * @return string + * @throws \Exception */ public function testUuid4TimestampFirstComb() { @@ -933,12 +934,12 @@ class UuidTest extends TestCase */ public function testUuid5WithKnownUuids() { - $uuids = array( + $uuids = [ '886313e1-3b8a-5372-9b90-0c9aee199e5d' => Uuid::uuid5(Uuid::NAMESPACE_DNS, 'python.org'), '4c565f0d-3f5a-5890-b41b-20cf47701c5e' => Uuid::uuid5(Uuid::NAMESPACE_URL, 'http://python.org/'), '1447fa61-5277-5fef-a9b3-fbc6e44f4af3' => Uuid::uuid5(Uuid::NAMESPACE_OID, '1.3.6.1'), 'cc957dd1-a972-5349-98cd-874190002798' => Uuid::uuid5(Uuid::NAMESPACE_X500, 'c=ca'), - ); + ]; foreach ($uuids as $ustr => $uobj) { $this->assertEquals(Uuid::RFC_4122, $uobj->getVariant()); @@ -1009,19 +1010,19 @@ class UuidTest extends TestCase $this->assertTrue($uuid1->equals($uuid2)); $this->assertFalse($uuid1->equals($uuid3)); $this->assertFalse($uuid1->equals(null)); - $this->assertFalse($uuid1->equals(new \stdClass())); + $this->assertFalse($uuid1->equals(new stdClass())); } /** */ public function testCalculateUuidTime() { - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => 1348845514, 'usec' => 277885, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet = new FeatureSet(); $featureSet->setTimeProvider($timeOfDay); @@ -1060,12 +1061,12 @@ class UuidTest extends TestCase { $this->skipIfNoMoontoastMath(); - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => 1348845514, 'usec' => 277885, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet = new FeatureSet(false, true); $featureSet->setTimeProvider($timeOfDay); @@ -1106,12 +1107,12 @@ class UuidTest extends TestCase $this->skip64BitTest(); // 5235-03-31T21:20:59+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => 103072857659, 'usec' => 999999, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet = new FeatureSet(); $featureSet->setTimeProvider($timeOfDay); @@ -1125,12 +1126,12 @@ class UuidTest extends TestCase $this->assertEquals('1fff', $uuidA->getTimeHiAndVersionHex()); // 1582-10-15T00:00:00+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => -12219292800, 'usec' => 0, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet->setTimeProvider($timeOfDay); @@ -1156,12 +1157,12 @@ class UuidTest extends TestCase $featureSet = new FeatureSet(false, true); // 5235-03-31T21:20:59+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => 103072857659, 'usec' => 999999, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet->setTimeProvider($timeOfDay); @@ -1175,12 +1176,12 @@ class UuidTest extends TestCase $this->assertEquals('1fff', $uuidA->getTimeHiAndVersionHex()); // 1582-10-15T00:00:00+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => -12219292800, 'usec' => 0, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet->setTimeProvider($timeOfDay); @@ -1201,12 +1202,12 @@ class UuidTest extends TestCase $this->skipIfNoMoontoastMath(); // 2038-01-19T03:14:07+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => 2147483647, 'usec' => 999999, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet = new FeatureSet(false, true); $featureSet->setTimeProvider($timeOfDay); @@ -1221,12 +1222,12 @@ class UuidTest extends TestCase $this->assertEquals('11fe', $uuidA->getTimeHiAndVersionHex()); // 1901-12-13T20:45:53+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => -2147483647, 'usec' => 0, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet->setTimeProvider($timeOfDay); @@ -1250,12 +1251,12 @@ class UuidTest extends TestCase $this->skip64BitTest(); // 2038-01-19T03:14:07+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => 2147483647, 'usec' => 999999, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet = new FeatureSet(); $featureSet->setTimeProvider($timeOfDay); @@ -1270,12 +1271,12 @@ class UuidTest extends TestCase $this->assertEquals('11fe', $uuidA->getTimeHiAndVersionHex()); // 1901-12-13T20:45:53+00:00 - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => -2147483647, 'usec' => 0, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $featureSet->setTimeProvider($timeOfDay); @@ -1300,12 +1301,12 @@ class UuidTest extends TestCase $currentTime = strtotime('2012-12-11T00:00:00+00:00'); $endTime = $currentTime + 3600; - $timeOfDay = new FixedTimeProvider(array( + $timeOfDay = new FixedTimeProvider([ 'sec' => $currentTime, 'usec' => 0, 'minuteswest' => 0, 'dsttime' => 0, - )); + ]); $smallIntFeatureSet = new FeatureSet(false, true); $smallIntFeatureSet->setTimeProvider($timeOfDay); @@ -1318,7 +1319,7 @@ class UuidTest extends TestCase $factory = new UuidFactory($featureSet); while ($currentTime <= $endTime) { - foreach (array(0, 50000, 250000, 500000, 750000, 999999) as $usec) { + foreach ([0, 50000, 250000, 500000, 750000, 999999] as $usec) { $timeOfDay->setSec($currentTime); $timeOfDay->setUsec($usec); @@ -1342,7 +1343,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testCalculateUuidTimeThrownException() { @@ -1558,298 +1559,298 @@ class UuidTest extends TestCase public function testUuidPassesPythonTests() { // This array is taken directly from the Python tests, more or less - $tests = array( - array( + $tests = [ + [ 'string' => '00000000-0000-0000-0000-000000000000', 'curly' => '{00000000-0000-0000-0000-000000000000}', 'hex' => '00000000000000000000000000000000', 'bytes' => 'AAAAAAAAAAAAAAAAAAAAAA==', 'int' => '0', - 'fields' => array( + 'fields' => [ 'time_low' => '0', 'time_mid' => '0', 'time_hi_and_version' => '0', 'clock_seq_hi_and_reserved' => '0', 'clock_seq_low' => '0', 'node' => '0', - ), + ], 'urn' => 'urn:uuid:00000000-0000-0000-0000-000000000000', 'time' => '0', 'clock_seq' => '0000', 'variant' => Uuid::RESERVED_NCS, 'version' => null, - ), - array( + ], + [ 'string' => '00010203-0405-0607-0809-0a0b0c0d0e0f', 'curly' => '{00010203-0405-0607-0809-0a0b0c0d0e0f}', 'hex' => '000102030405060708090a0b0c0d0e0f', 'bytes' => 'AAECAwQFBgcICQoLDA0ODw==', 'int' => '5233100606242806050955395731361295', - 'fields' => array( + 'fields' => [ 'time_low' => '10203', 'time_mid' => '405', 'time_hi_and_version' => '607', 'clock_seq_hi_and_reserved' => '8', 'clock_seq_low' => '9', 'node' => '0a0b0c0d0e0f', - ), + ], 'urn' => 'urn:uuid:00010203-0405-0607-0809-0a0b0c0d0e0f', 'time' => '607040500010203', 'clock_seq' => '0809', 'variant' => Uuid::RESERVED_NCS, 'version' => null, - ), - array( + ], + [ 'string' => '02d9e6d5-9467-382e-8f9b-9300a64ac3cd', 'curly' => '{02d9e6d5-9467-382e-8f9b-9300a64ac3cd}', 'hex' => '02d9e6d59467382e8f9b9300a64ac3cd', 'bytes' => 'Atnm1ZRnOC6Pm5MApkrDzQ==', 'int' => '3789866285607910888100818383505376205', - 'fields' => array( + 'fields' => [ 'time_low' => '02d9e6d5', 'time_mid' => '9467', 'time_hi_and_version' => '382e', 'clock_seq_hi_and_reserved' => '8f', 'clock_seq_low' => '9b', 'node' => '9300a64ac3cd', - ), + ], 'urn' => 'urn:uuid:02d9e6d5-9467-382e-8f9b-9300a64ac3cd', 'time' => '82e946702d9e6d5', 'clock_seq' => '0f9b', 'variant' => Uuid::RFC_4122, 'version' => 3, - ), - array( + ], + [ 'string' => '12345678-1234-5678-1234-567812345678', 'curly' => '{12345678-1234-5678-1234-567812345678}', 'hex' => '12345678123456781234567812345678', 'bytes' => 'EjRWeBI0VngSNFZ4EjRWeA==', 'int' => '24197857161011715162171839636988778104', - 'fields' => array( + 'fields' => [ 'time_low' => '12345678', 'time_mid' => '1234', 'time_hi_and_version' => '5678', 'clock_seq_hi_and_reserved' => '12', 'clock_seq_low' => '34', 'node' => '567812345678', - ), + ], 'urn' => 'urn:uuid:12345678-1234-5678-1234-567812345678', 'time' => '678123412345678', 'clock_seq' => '1234', 'variant' => Uuid::RESERVED_NCS, 'version' => null, - ), - array( + ], + [ 'string' => '6ba7b810-9dad-11d1-80b4-00c04fd430c8', 'curly' => '{6ba7b810-9dad-11d1-80b4-00c04fd430c8}', 'hex' => '6ba7b8109dad11d180b400c04fd430c8', 'bytes' => 'a6e4EJ2tEdGAtADAT9QwyA==', 'int' => '143098242404177361603877621312831893704', - 'fields' => array( + 'fields' => [ 'time_low' => '6ba7b810', 'time_mid' => '9dad', 'time_hi_and_version' => '11d1', 'clock_seq_hi_and_reserved' => '80', 'clock_seq_low' => 'b4', 'node' => '00c04fd430c8', - ), + ], 'urn' => 'urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8', 'time' => '1d19dad6ba7b810', 'clock_seq' => '00b4', 'variant' => Uuid::RFC_4122, 'version' => 1, - ), - array( + ], + [ 'string' => '6ba7b811-9dad-11d1-80b4-00c04fd430c8', 'curly' => '{6ba7b811-9dad-11d1-80b4-00c04fd430c8}', 'hex' => '6ba7b8119dad11d180b400c04fd430c8', 'bytes' => 'a6e4EZ2tEdGAtADAT9QwyA==', 'int' => '143098242483405524118141958906375844040', - 'fields' => array( + 'fields' => [ 'time_low' => '6ba7b811', 'time_mid' => '9dad', 'time_hi_and_version' => '11d1', 'clock_seq_hi_and_reserved' => '80', 'clock_seq_low' => 'b4', 'node' => '00c04fd430c8', - ), + ], 'urn' => 'urn:uuid:6ba7b811-9dad-11d1-80b4-00c04fd430c8', 'time' => '1d19dad6ba7b811', 'clock_seq' => '00b4', 'variant' => Uuid::RFC_4122, 'version' => 1, - ), - array( + ], + [ 'string' => '6ba7b812-9dad-11d1-80b4-00c04fd430c8', 'curly' => '{6ba7b812-9dad-11d1-80b4-00c04fd430c8}', 'hex' => '6ba7b8129dad11d180b400c04fd430c8', 'bytes' => 'a6e4Ep2tEdGAtADAT9QwyA==', 'int' => '143098242562633686632406296499919794376', - 'fields' => array( + 'fields' => [ 'time_low' => '6ba7b812', 'time_mid' => '9dad', 'time_hi_and_version' => '11d1', 'clock_seq_hi_and_reserved' => '80', 'clock_seq_low' => 'b4', 'node' => '00c04fd430c8', - ), + ], 'urn' => 'urn:uuid:6ba7b812-9dad-11d1-80b4-00c04fd430c8', 'time' => '1d19dad6ba7b812', 'clock_seq' => '00b4', 'variant' => Uuid::RFC_4122, 'version' => 1, - ), - array( + ], + [ 'string' => '6ba7b814-9dad-11d1-80b4-00c04fd430c8', 'curly' => '{6ba7b814-9dad-11d1-80b4-00c04fd430c8}', 'hex' => '6ba7b8149dad11d180b400c04fd430c8', 'bytes' => 'a6e4FJ2tEdGAtADAT9QwyA==', 'int' => '143098242721090011660934971687007695048', - 'fields' => array( + 'fields' => [ 'time_low' => '6ba7b814', 'time_mid' => '9dad', 'time_hi_and_version' => '11d1', 'clock_seq_hi_and_reserved' => '80', 'clock_seq_low' => 'b4', 'node' => '00c04fd430c8', - ), + ], 'urn' => 'urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8', 'time' => '1d19dad6ba7b814', 'clock_seq' => '00b4', 'variant' => Uuid::RFC_4122, 'version' => 1, - ), - array( + ], + [ 'string' => '7d444840-9dc0-11d1-b245-5ffdce74fad2', 'curly' => '{7d444840-9dc0-11d1-b245-5ffdce74fad2}', 'hex' => '7d4448409dc011d1b2455ffdce74fad2', 'bytes' => 'fURIQJ3AEdGyRV/9znT60g==', 'int' => '166508041112410060672666770310773930706', - 'fields' => array( + 'fields' => [ 'time_low' => '7d444840', 'time_mid' => '9dc0', 'time_hi_and_version' => '11d1', 'clock_seq_hi_and_reserved' => 'b2', 'clock_seq_low' => '45', 'node' => '5ffdce74fad2', - ), + ], 'urn' => 'urn:uuid:7d444840-9dc0-11d1-b245-5ffdce74fad2', 'time' => '1d19dc07d444840', 'clock_seq' => '3245', 'variant' => Uuid::RFC_4122, 'version' => 1, - ), - array( + ], + [ 'string' => 'e902893a-9d22-3c7e-a7b8-d6e313b71d9f', 'curly' => '{e902893a-9d22-3c7e-a7b8-d6e313b71d9f}', 'hex' => 'e902893a9d223c7ea7b8d6e313b71d9f', 'bytes' => '6QKJOp0iPH6nuNbjE7cdnw==', 'int' => '309723290945582129846206211755626405279', - 'fields' => array( + 'fields' => [ 'time_low' => 'e902893a', 'time_mid' => '9d22', 'time_hi_and_version' => '3c7e', 'clock_seq_hi_and_reserved' => 'a7', 'clock_seq_low' => 'b8', 'node' => 'd6e313b71d9f', - ), + ], 'urn' => 'urn:uuid:e902893a-9d22-3c7e-a7b8-d6e313b71d9f', 'time' => 'c7e9d22e902893a', 'clock_seq' => '27b8', 'variant' => Uuid::RFC_4122, 'version' => 3, - ), - array( + ], + [ 'string' => 'eb424026-6f54-4ef8-a4d0-bb658a1fc6cf', 'curly' => '{eb424026-6f54-4ef8-a4d0-bb658a1fc6cf}', 'hex' => 'eb4240266f544ef8a4d0bb658a1fc6cf', 'bytes' => '60JAJm9UTvik0Ltlih/Gzw==', 'int' => '312712571721458096795100956955942831823', - 'fields' => array( + 'fields' => [ 'time_low' => 'eb424026', 'time_mid' => '6f54', 'time_hi_and_version' => '4ef8', 'clock_seq_hi_and_reserved' => 'a4', 'clock_seq_low' => 'd0', 'node' => 'bb658a1fc6cf', - ), + ], 'urn' => 'urn:uuid:eb424026-6f54-4ef8-a4d0-bb658a1fc6cf', 'time' => 'ef86f54eb424026', 'clock_seq' => '24d0', 'variant' => Uuid::RFC_4122, 'version' => 4, - ), - array( + ], + [ 'string' => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6', 'curly' => '{f81d4fae-7dec-11d0-a765-00a0c91e6bf6}', 'hex' => 'f81d4fae7dec11d0a76500a0c91e6bf6', 'bytes' => '+B1Prn3sEdCnZQCgyR5r9g==', 'int' => '329800735698586629295641978511506172918', - 'fields' => array( + 'fields' => [ 'time_low' => 'f81d4fae', 'time_mid' => '7dec', 'time_hi_and_version' => '11d0', 'clock_seq_hi_and_reserved' => 'a7', 'clock_seq_low' => '65', 'node' => '00a0c91e6bf6', - ), + ], 'urn' => 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6', 'time' => '1d07decf81d4fae', 'clock_seq' => '2765', 'variant' => Uuid::RFC_4122, 'version' => 1, - ), - array( + ], + [ 'string' => 'fffefdfc-fffe-fffe-fffe-fffefdfcfbfa', 'curly' => '{fffefdfc-fffe-fffe-fffe-fffefdfcfbfa}', 'hex' => 'fffefdfcfffefffefffefffefdfcfbfa', 'bytes' => '//79/P/+//7//v/+/fz7+g==', 'int' => '340277133821575024845345576078114880506', - 'fields' => array( + 'fields' => [ 'time_low' => 'fffefdfc', 'time_mid' => 'fffe', 'time_hi_and_version' => 'fffe', 'clock_seq_hi_and_reserved' => 'ff', 'clock_seq_low' => 'fe', 'node' => 'fffefdfcfbfa', - ), + ], 'urn' => 'urn:uuid:fffefdfc-fffe-fffe-fffe-fffefdfcfbfa', 'time' => 'ffefffefffefdfc', 'clock_seq' => '3ffe', 'variant' => Uuid::RESERVED_FUTURE, 'version' => null, - ), - array( + ], + [ 'string' => 'ffffffff-ffff-ffff-ffff-ffffffffffff', 'curly' => '{ffffffff-ffff-ffff-ffff-ffffffffffff}', 'hex' => 'ffffffffffffffffffffffffffffffff', 'bytes' => '/////////////////////w==', 'int' => '340282366920938463463374607431768211455', - 'fields' => array( + 'fields' => [ 'time_low' => 'ffffffff', 'time_mid' => 'ffff', 'time_hi_and_version' => 'ffff', 'clock_seq_hi_and_reserved' => 'ff', 'clock_seq_low' => 'ff', 'node' => 'ffffffffffff', - ), + ], 'urn' => 'urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff', 'time' => 'fffffffffffffff', 'clock_seq' => '3fff', 'variant' => Uuid::RESERVED_FUTURE, 'version' => null, - ), - ); + ], + ]; foreach ($tests as $test) { - $uuids = array( + $uuids = [ Uuid::fromString($test['string']), Uuid::fromString($test['curly']), Uuid::fromString($test['hex']), Uuid::fromBytes(base64_decode($test['bytes'])), Uuid::fromString($test['urn']), Uuid::fromInteger($test['int']), - ); + ]; foreach ($uuids as $uuid) { $this->assertEquals($test['string'], (string)$uuid); $this->assertEquals($test['hex'], $uuid->getHex()); @@ -1876,7 +1877,7 @@ class UuidTest extends TestCase } /** - * @expectedException \Ramsey\Uuid\Exception\UnsatisfiedDependencyException + * @expectedException Ramsey\Uuid\Exception\UnsatisfiedDependencyException */ public function testGetInteger() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index feccbed..400a67a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,18 +1,20 @@ init([ 'debug' => true, 'cacheDir' => sys_get_temp_dir(),