diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bc2c43f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.gitignore export-ignore +/.gitattributes export-ignore +/.travis.yml export-ignore +/tests export-ignore +/phpunit.xml.dist export-ignore +/apigen.neon export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bc14ee..2698915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +* 2.7.4 (2014-10-29) + * Changed loop in `generateBytes()` from `foreach` to `for`; see #33 + * Use `toString()` in README examples to avoid confusion + * Exclude build/development tools from releases using .gitattributes + * Set timezone properly for tests * 2.7.3 (2014-08-27) * Fixed upper range for `mt_rand` used in version 4 UUIDs * 2.7.2 (2014-07-28) diff --git a/README.md b/README.md index 794da6d..5df41db 100644 --- a/README.md +++ b/README.md @@ -59,21 +59,21 @@ use Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException; try { - // Generate a version 1 (time-based) UUID + // Generate a version 1 (time-based) UUID object $uuid1 = Uuid::uuid1(); - echo $uuid1 . "\n"; // e4eaaaf2-d142-11e1-b3e4-080027620cdd + echo $uuid1->toString() . "\n"; // e4eaaaf2-d142-11e1-b3e4-080027620cdd - // Generate a version 3 (name-based and hashed with MD5) UUID + // Generate a version 3 (name-based and hashed with MD5) UUID object $uuid3 = Uuid::uuid3(Uuid::NAMESPACE_DNS, 'php.net'); - echo $uuid3 . "\n"; // 11a38b9a-b3da-360f-9353-a5a725514269 + echo $uuid3->toString() . "\n"; // 11a38b9a-b3da-360f-9353-a5a725514269 - // Generate a version 4 (random) UUID + // Generate a version 4 (random) UUID object $uuid4 = Uuid::uuid4(); - echo $uuid4 . "\n"; // 25769c6c-d34d-4bfe-ba98-e0ee856f3e7a + echo $uuid4->toString() . "\n"; // 25769c6c-d34d-4bfe-ba98-e0ee856f3e7a - // Generate a version 5 (name-based and hashed with SHA1) UUID + // Generate a version 5 (name-based and hashed with SHA1) UUID object $uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'php.net'); - echo $uuid5 . "\n"; // c4a760a8-dbcf-5254-a0d9-6a4474bd1b62 + echo $uuid5->toString() . "\n"; // c4a760a8-dbcf-5254-a0d9-6a4474bd1b62 } catch (UnsatisfiedDependencyException $e) { diff --git a/src/Uuid.php b/src/Uuid.php index 107b0ba..5b3ad59 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -1225,7 +1225,7 @@ final class Uuid } $bytes = ''; - foreach (range(1, $length) as $i) { + for ($i = 1; $i <= $length; $i++) { $bytes = chr(mt_rand(0, 255)) . $bytes; } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2f16bac..786bef2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,7 @@