Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Uuid final again (aka Revert 'Remove "final" keyword to allow extending') #255

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
d718aa1
Migrate isValid() to Validator and ValidatorInterface
bradynpoulsen Feb 6, 2016
ffacb03
Update Travis builds to use Travis-installed PHP instead of Docker
ramsey Jun 23, 2016
1ebda49
Set minimum version to PHP 5.6 and use PHP 5.5 style ::class constants
jildertmiedema Jun 23, 2016
042f1d7
Add GmpConverter and GmpTimeConverter
jecknig Jul 3, 2016
5d16dbe
Update dev requirements and test suite for PHP 7+ only
ramsey Nov 8, 2017
f6403c6
Bump phpunit/phpunit development dependency to version 6.4
Potherca Nov 9, 2017
dd4609c
Drop paragonie/random_compat from dependencies
mhujer Nov 10, 2017
e52f125
Add XSD schema to phpunit.xml.dist config
mhujer Nov 10, 2017
d834515
Require phpstan and correct issues found up to level 2
mhujer Nov 10, 2017
361d376
Use ::class constants where possible
mhujer Dec 11, 2017
1380db6
Ensure that RandomNodeProviderTest runs only on 64bit systems
mhujer Dec 23, 2017
cdc1e20
Change library ircmaxell/random-lib to paragonie/random-lib
karsasmus Jan 17, 2018
0709ec5
fix 4.x branch rebase
mhujer Jan 20, 2018
ba3d525
Drop remnants of HHVM from tests
mhujer Nov 10, 2017
ad89bda
Do not use the latest goaop/framework 2.2
mhujer Feb 21, 2018
e4bf54e
Revert "Do not use the latest goaop/framework 2.2"
mhujer Feb 21, 2018
78bb737
Tests: configure cacheDir for AspectMock
mhujer Feb 15, 2018
7f21db7
Do not use the latest goaop/framework 2.2
mhujer Feb 21, 2018
b9b7369
bumping phpstan level
SignpostMarv Jan 27, 2018
4be1dca
adjusting docs to match existing tests & return types
SignpostMarv Jan 27, 2018
d8a1a93
bumping phpstan level
SignpostMarv Jan 27, 2018
904a30a
adjusting docs to match existing tests & return types
SignpostMarv Jan 27, 2018
f379939
bumping phpstan level
SignpostMarv Jan 27, 2018
5fafb5f
typecasting to resolve phpstan issue triggered by return type defined…
SignpostMarv Jan 27, 2018
e803ec4
bumping phpstan level
SignpostMarv Jan 27, 2018
569f58f
calling unset rather than setting null to resolve issues identified b…
SignpostMarv Jan 27, 2018
34f4904
bumping phpstan level, no issues identified
SignpostMarv Jan 27, 2018
deb3a89
tests pass so we can probably safely supress this error
SignpostMarv Feb 13, 2018
b4fb954
bumping phpstan level, supressing error caused by docblocks on moonto…
SignpostMarv Feb 13, 2018
17f954d
bumping phpstan level, swapping order of property assignment caused b…
SignpostMarv Feb 13, 2018
4643624
setting level to max
SignpostMarv Feb 13, 2018
88882de
Fix typo for PHP version requirement
teohhanhui Mar 28, 2018
cdaec86
Merge pull request #219 from teohhanhui/php-version-typo
ramsey Mar 28, 2018
8ab47b1
Merge branch '4.x' into 4.x
ramsey Jul 1, 2018
6e01164
Enhancement: Normalize composer.json
localheinz Jul 19, 2018
ae67e4c
Merge pull request #210 from SignpostMarv/4.x--phpstan
ramsey Jul 19, 2018
6b5d7c2
Update text of the ignored error message for phpstan
ramsey Jul 19, 2018
0fcaa91
Merge branch 'master' into 4.x
ramsey Jul 19, 2018
f15ae36
Fix PHPStan issues and avoid risky tests in PHPUnit
ramsey Jul 19, 2018
4ecdb1a
Remove unused test data files
ramsey Jul 19, 2018
2204e4c
Merge pull request #204 from karsasmus/4.x
ramsey Jul 19, 2018
780f29a
Merge branch '4.x' of github.com:ramsey/uuid into 4.x
ramsey Jul 19, 2018
5981d27
Update suggested package for random-lib to paragonie/random-lib
ramsey Jul 19, 2018
d0b16bd
Remove SodiumRandomGenerator generator class; it is no longer necessary
ramsey Jul 19, 2018
2fd06e7
Merge branch 'master' into 4.x
ramsey Jul 19, 2018
73f82d4
Set minimum PHP version to 7.2
ramsey Jul 19, 2018
e083181
Remove earlier PHP versions from testing on Travis CI
ramsey Jul 19, 2018
f012f3c
Merge pull request #213 from mhujer/fix-aspect-mock-cache-dir
ramsey Jul 19, 2018
e6462b4
Merge branch 'master' into 4.x
ramsey Jul 19, 2018
72c0f74
Merge branch '4.x' into feature/normalize
ramsey Jul 19, 2018
4a91e5c
Merge pull request #234 from localheinz/feature/normalize
ramsey Jul 19, 2018
11467bb
Merge branch 'master' into 4.x
ramsey Jul 19, 2018
be7ce46
Preparing the README for cutting master over to the 4.x series
ramsey Jul 19, 2018
8990d47
Merge branch 'master' into 4.x
ramsey Jul 19, 2018
4d374c3
Add configuration for Sami documentation generator
ramsey Jul 19, 2018
a395c51
Merge branch 'master' into 4.x
ramsey Jul 19, 2018
430f140
Merge branch '4.x' into master
ramsey Jul 19, 2018
bf06dca
Remove unused use statement
ramsey Jul 20, 2018
357616b
Update the changelog to follow the keepachangelog.com suggested format
ramsey Jul 21, 2018
962b14c
Merge branch '3.x'
ramsey Aug 5, 2018
753fc26
Remove the OpenSslGenerator
ramsey Aug 12, 2018
2979b6e
Remove the MtRandGenerator
ramsey Aug 12, 2018
8dfa3d9
Use a high-strength generator by default, when using RandomLibAdapter
ramsey Aug 12, 2018
5cadea8
Remove toString() method and add __toString() to UuidInterface
ramsey Aug 12, 2018
e373667
Remove unused tools scripts
ramsey Aug 12, 2018
6e0a79b
Add donation badge through LiberaPay to README
ramsey Aug 23, 2018
15c3029
change array declarations
AlessandroMinoccheri Sep 7, 2018
cc1b86c
Merge pull request #237 from AlessandroMinoccheri/feature/fix_array_d…
ramsey Sep 7, 2018
489b135
Change getDateTime to DateTimeInterface
Sep 25, 2018
bbc5eeb
Merge pull request #239 from Zeyckler/changeGetgetDateTimeToDateTimeI…
ramsey Oct 1, 2018
2d321b2
Update .travis.yml
andreybolonin Oct 27, 2018
fb2e207
Merge pull request #249 from andreybolonin/patch-1
ramsey Oct 27, 2018
748cf67
Add CodeTriage statement
ramsey Jan 7, 2019
39a6d5e
Revert "Remove "final" keyword to allow extending"
Majkl578 Jan 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

matrix:
Expand All @@ -28,6 +24,7 @@ before_script:

script:
- ./vendor/bin/parallel-lint src tests
- composer run phpstan
- travis_wait ./vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml
- ./vendor/bin/phpcs src tests --standard=psr2 -sp

Expand Down
607 changes: 381 additions & 226 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Contributions are welcome. We accept pull requests on [GitHub](https://github.com/ramsey/uuid).

You can triage issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to ramsey/uuid on CodeTriage](https://codetriage.com/ramsey/uuid).

This project adheres to a [Contributor Code of Conduct](https://github.com/ramsey/uuid/blob/master/CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code.

## Team members
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# ramsey/uuid

_NOTICE: Formerly known as `rhumsaa/uuid`, The package and namespace names have changed to `ramsey/uuid` and `Ramsey\Uuid`, respectively._

[![Source Code][badge-source]][source]
[![Latest Version][badge-release]][release]
[![Software License][badge-license]][license]
[![Build Status][badge-build]][build]
[![Coverage Status][badge-coverage]][coverage]
[![Total Downloads][badge-downloads]][downloads]
[![Donate][badge-liberapay]][donate]

ramsey/uuid is a PHP 5.4+ library for generating and working with [RFC 4122][rfc4122] version 1, 3, 4, and 5 universally unique identifiers (UUID).
ramsey/uuid is a PHP 7.2+ library for generating and working with [RFC 4122][rfc4122] version 1, 3, 4, and 5 universally unique identifiers (UUID).

This project adheres to a [Contributor Code of Conduct][conduct]. By participating in this project and its community, you are expected to uphold this code.

Expand All @@ -32,6 +31,11 @@ composer require ramsey/uuid
```


## Upgrading from 3.x to 4.x

TODO


## Upgrading from 2.x to 3.x

While we have made significant internal changes to the library, we have made every effort to ensure a seamless upgrade path from the 2.x series of this library to 3.x.
Expand Down Expand Up @@ -65,7 +69,7 @@ After doing so, you will have the latest ramsey/uuid package in the 2.x series,

## Requirements

Some methods in this library have requirements due to integer size restrictions on 32-bit and 64-bit builds of PHP. A 64-bit build of PHP and the [Moontoast\Math][] library are recommended. However, this library is designed to work on 32-bit builds of PHP without Moontoast\Math, with some degraded functionality. Please check the API documentation for more information.
Some methods in this library have requirements due to integer size restrictions on 32-bit and 64-bit builds of PHP. A 64-bit build of PHP and either the [GMP PHP-extension][ext-gmp] or the [Moontoast\Math][] library are recommended. However, this library is designed to work on 32-bit builds of PHP without GMP or Moontoast\Math, with some degraded functionality. Please check the API documentation for more information.

If a particular requirement is not present, then an `UnsatisfiedDependencyException` is thrown, allowing one to catch a bad call in an environment where the call is not supported and gracefully degrade.

Expand All @@ -74,14 +78,6 @@ If a particular requirement is not present, then an `UnsatisfiedDependencyExcept

The [latest class API documentation][apidocs] is available online.

This project uses [ApiGen](http://apigen.org/) to generate this documentation. To generate the documentation on your own, install dev dependencies and run the following command from the root of the project:

```
composer build-docs
```

This will generate documentation in the `build/apidocs/` folder.


## Examples

Expand Down Expand Up @@ -140,6 +136,7 @@ The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and
[packagist]: https://packagist.org/packages/ramsey/uuid
[composer]: http://getcomposer.org/
[moontoast\math]: https://packagist.org/packages/moontoast/math
[ext-gmp]: http://php.net/manual/en/book.gmp.php
[apidocs]: http://docs.benramsey.com/ramsey-uuid/latest/
[wiki-cookbook]: https://github.com/ramsey/uuid/wiki/Ramsey%5CUuid-Cookbook
[contributing]: https://github.com/ramsey/uuid/blob/master/CONTRIBUTING.md
Expand All @@ -150,10 +147,12 @@ The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and
[badge-build]: https://img.shields.io/travis/ramsey/uuid/master.svg?style=flat-square
[badge-coverage]: https://img.shields.io/coveralls/ramsey/uuid/master.svg?style=flat-square
[badge-downloads]: https://img.shields.io/packagist/dt/ramsey/uuid.svg?style=flat-square
[badge-liberapay]: http://img.shields.io/liberapay/patrons/ramsey.svg?logo=liberapay&style=flat-square

[source]: https://github.com/ramsey/uuid
[release]: https://packagist.org/packages/ramsey/uuid
[license]: https://github.com/ramsey/uuid/blob/master/LICENSE
[build]: https://travis-ci.org/ramsey/uuid
[coverage]: https://coveralls.io/r/ramsey/uuid?branch=master
[downloads]: https://packagist.org/packages/ramsey/uuid
[donate]: https://liberapay.com/ramsey/donate
90 changes: 44 additions & 46 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,79 @@
{
"name": "ramsey/uuid",
"description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).",
"type": "library",
"keywords": ["uuid", "identifier", "guid"],
"description": "A PHP 7.2+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).",
"keywords": [
"uuid",
"identifier",
"guid"
],
"homepage": "https://github.com/ramsey/uuid",
"license": "MIT",
"authors": [
{
"name": "Ben Ramsey",
"email": "ben@benramsey.com",
"homepage": "https://benramsey.com"
},
{
"name": "Marijn Huizendveld",
"email": "marijn.huizendveld@gmail.com"
},
{
"name": "Thibaud Fabre",
"email": "thibaud@aztech.io"
}
],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid"
},
"require": {
"php": "^5.4 || ^7.0",
"php": "^7.2",
"ext-json": "*",
"paragonie/random_compat": "^1.0|^2.0|9.99.99",
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"codeception/aspect-mock": "^1.0 | ~2.0.0",
"doctrine/annotations": "~1.2.0",
"goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0",
"ircmaxell/random-lib": "^1.1",
"ext-gmp": "*",
"codeception/aspect-mock": "~2.0.0",
"doctrine/annotations": "^1.2",
"goaop/framework": "^2.1 <2.2",
"jakub-onderka/php-parallel-lint": "^0.9.0",
"mockery/mockery": "^0.9.9",
"mockery/mockery": "^1.0",
"moontoast/math": "^1.1",
"php-mock/php-mock-phpunit": "^0.3|^1.1",
"phpunit/phpunit": "^4.7|^5.0|^6.5",
"squizlabs/php_codesniffer": "^2.3"
"paragonie/random-lib": "^2.0",
"php-mock/php-mock-phpunit": "^2.0",
"phpstan/phpstan-phpunit": "0.9.2",
"phpstan/phpstan-shim": "0.9.1",
"phpunit/phpunit": "^6.4",
"squizlabs/php_codesniffer": "^3.0"
},
"suggest": {
"ext-ctype": "Provides support for PHP Ctype functions",
"ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
"ext-gmp": "Provides support for converting UUID to 128-bit integer (in string form).",
"ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator",
"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-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type.",
"ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid"
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
"ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid",
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
},
"autoload": {
"psr-4": {"Ramsey\\Uuid\\": "src/"}
},
"autoload-dev": {
"psr-4": {"Ramsey\\Uuid\\Test\\": "tests/"}
},
"replace": {
"rhumsaa/uuid": "self.version"
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Ramsey\\Uuid\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Ramsey\\Uuid\\Test\\": "tests/"
}
},
"scripts": {
"lint": "parallel-lint src tests",
"phpunit": "phpunit --verbose --colors=always",
"phpcs": "phpcs src tests --standard=psr2 -sp --colors",
"phpstan": [
"phpstan analyse -c phpstan.neon src --level max --no-progress",
"phpstan analyse -c phpstan-tests.neon tests --level 4 --no-progress"
],
"phpunit": "phpunit --verbose --colors=always",
"test": [
"@lint",
"@phpstan",
"@phpunit",
"@phpcs"
]
},
"config": {
"sort-packages": true
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"rss": "https://packagist.org/feeds/package.ramsey/uuid.rss"
}
}
7 changes: 7 additions & 0 deletions phpstan-tests.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
- '#Function uuid_create not found#'
- '#Function uuid_parse not found#'
- '#Constant UUID_TYPE_TIME not found#'
- '#Constant UUID_TYPE_RANDOM not found#'
- '#does not accept PHPUnit\\Framework\\MockObject\\MockObject#'
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
- '#Function uuid_create not found#'
- '#Function uuid_parse not found#'
- '#Constant UUID_TYPE_TIME not found#'
- '#Constant UUID_TYPE_RANDOM not found#'
- '#Moontoast\\Math\\BigNumber::convertFromBase10\(\) expects int\|string, Moontoast\\Math\\BigNumber given.#'
13 changes: 9 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true"
backupGlobals="false">

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.4/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
>
<testsuites>
<testsuite>
<testsuite name="ramsey/uuid test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
Expand Down
2 changes: 1 addition & 1 deletion src/BinaryUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BinaryUtils
/**
* Applies the RFC 4122 variant field to the `clock_seq_hi_and_reserved` field
*
* @param $clockSeqHi
* @param int $clockSeqHi
* @return int The high field of the clock sequence multiplexed with the variant
* @link http://tools.ietf.org/html/rfc4122#section-4.1.1
*/
Expand Down
20 changes: 15 additions & 5 deletions src/Builder/DefaultUuidBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\Uuid;

/**
Expand All @@ -27,16 +28,25 @@ class DefaultUuidBuilder implements UuidBuilderInterface
/**
* @var NumberConverterInterface
*/
private $converter;
private $numberConverter;

/**
* The time converter to use for converting timestamps extracted from UUIDs to unix timestamps
* @var TimeConverterInterface
*/
protected $timeConverter;

/**
* Constructs the DefaultUuidBuilder
*
* @param NumberConverterInterface $converter The number converter to use when constructing the Uuid
* @param NumberConverterInterface $numberConverter The number converter to use when constructing the Uuid
* @param TimeConverterInterface $timeConverter The time converter to use
* for converting timestamps extracted from a UUID to unix timestamps
*/
public function __construct(NumberConverterInterface $converter)
public function __construct(NumberConverterInterface $numberConverter, TimeConverterInterface $timeConverter)
{
$this->converter = $converter;
$this->numberConverter = $numberConverter;
$this->timeConverter = $timeConverter;
}

/**
Expand All @@ -49,6 +59,6 @@ public function __construct(NumberConverterInterface $converter)
*/
public function build(CodecInterface $codec, array $fields)
{
return new Uuid($fields, $this->converter, $codec);
return new Uuid($fields, $this->numberConverter, $codec, $this->timeConverter);
}
}
20 changes: 15 additions & 5 deletions src/Builder/DegradedUuidBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\DegradedUuid;

/**
Expand All @@ -26,16 +27,25 @@ class DegradedUuidBuilder implements UuidBuilderInterface
/**
* @var NumberConverterInterface
*/
private $converter;
private $numberConverter;

/**
* The time converter to use for converting timestamps extracted from UUIDs to unix timestamps
* @var TimeConverterInterface
*/
protected $timeConverter;

/**
* Constructs the DegradedUuidBuilder
*
* @param NumberConverterInterface $converter The number converter to use when constructing the DegradedUuid
* @param NumberConverterInterface $numberConverter The number converter to use when constructing the DegradedUuid
* @param TimeConverterInterface $timeConverter The time converter to use
* for converting timestamps extracted from a UUID to unix timestamps
*/
public function __construct(NumberConverterInterface $converter)
public function __construct(NumberConverterInterface $numberConverter, TimeConverterInterface $timeConverter)
{
$this->converter = $converter;
$this->numberConverter = $numberConverter;
$this->timeConverter = $timeConverter;
}

/**
Expand All @@ -48,6 +58,6 @@ public function __construct(NumberConverterInterface $converter)
*/
public function build(CodecInterface $codec, array $fields)
{
return new DegradedUuid($fields, $this->converter, $codec);
return new DegradedUuid($fields, $this->numberConverter, $codec, $this->timeConverter);
}
}
Loading