diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d375d20..df9c3b1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -27,7 +27,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install PHP" uses: "shivammathur/setup-php@v2" @@ -36,7 +36,7 @@ jobs: coverage: "none" - name: "Install dependencies (Composer)" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" - name: "Check syntax (php-parallel-lint)" run: "composer lint -- --colors" @@ -49,7 +49,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install PHP" uses: "shivammathur/setup-php@v2" @@ -58,7 +58,7 @@ jobs: coverage: "none" - name: "Install dependencies (Composer)" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" - name: "Statically analyze code (PHPStan)" run: "composer phpstan -- --ansi" @@ -77,10 +77,18 @@ jobs: php-version: - "8.1" - "8.2" + - "8.3" + - "8.4" + include: + # Keep the locked version by default + - dependency-versions: "locked" + # For PHP 8.0, installing with --prefer-highest to use brick/math v0.11 + - php-version: "8.0" + dependency-versions: "highest" steps: - name: "Checkout repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install dependencies (apt)" run: | @@ -96,7 +104,9 @@ jobs: ini-values: "memory_limit=-1" - name: "Install dependencies (Composer)" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" + with: + dependency-versions: "${{ matrix.dependency-versions }}" - name: "Run PHPBench" run: "composer phpbench -- --ansi" @@ -107,7 +117,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install dependencies (apt)" run: | @@ -123,7 +133,7 @@ jobs: ini-values: "memory_limit=-1" - name: "Install dependencies (Composer)" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.dependencies }}" @@ -131,7 +141,7 @@ jobs: run: "./vendor/bin/phpunit --verbose --colors=always --coverage-text --coverage-clover build/logs/clover.xml" - name: "Publish coverage report to Codecov" - uses: "codecov/codecov-action@v3.1.1" + uses: "codecov/codecov-action@v5.0.2" unit-tests: name: "Unit Tests" @@ -144,9 +154,17 @@ jobs: php-version: - "8.1" - "8.2" + - "8.3" + - "8.4" operating-system: - "ubuntu-latest" - "windows-latest" + include: + # Keep the locked version by default + - dependency-versions: "locked" + # For PHP 8.0, installing with --prefer-highest to use brick/math v0.11 + - php-version: "8.0" + dependency-versions: "highest" steps: - name: "Configure Git (for Windows)" @@ -156,7 +174,7 @@ jobs: git config --system core.eol lf - name: "Checkout repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install dependencies (apt)" if: ${{ matrix.operating-system == 'ubuntu-latest' }} @@ -173,9 +191,9 @@ jobs: ini-values: "memory_limit=-1" - name: "Install dependencies (Composer)" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" with: - composer-options: "${{ matrix.composer-options }}" + dependency-versions: "${{ matrix.dependency-versions }}" - name: "Run unit tests (PHPUnit)" run: "./vendor/bin/phpunit --verbose --colors=always --no-coverage" diff --git a/.github/workflows/merge-dependabot-upgrades.yml b/.github/workflows/merge-dependabot-upgrades.yml index cddb937..60665f8 100644 --- a/.github/workflows/merge-dependabot-upgrades.yml +++ b/.github/workflows/merge-dependabot-upgrades.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Auto-Merge if: ${{ github.event.workflow_run.conclusion == 'success' }} - uses: ridedott/merge-me-action@v2.10.44 + uses: ridedott/merge-me-action@v2.10.111 with: # This must be used as GitHub Actions token does not support pushing # to protected branches. diff --git a/.readthedocs.yml b/.readthedocs.yml index bc50e91..a0d7665 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,11 +1,15 @@ version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.12" + sphinx: configuration: docs/conf.py formats: all python: - version: 3.7 install: - requirements: docs/requirements.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b3abc5..6f0f380 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * Remove dependency on ramsey/collection package. +## 4.7.6 - 2024-04-27 + +### Fixed + +* Allow brick/math version `^0.12`. + + +## 4.7.5 - 2023-11-08 + +### Fixed + +* Protect against UUIDv7 collisions within the same millisecond, as reported + in [#518](https://github.com/ramsey/uuid/issues/518) and fixed in + [#522](https://github.com/ramsey/uuid/pull/522). +* Improve the return type hint for `UuidInterface::compareTo()`. + + ## 4.7.4 - 2023-04-15 ### Fixed @@ -530,7 +547,7 @@ The following functionality is deprecated and will be removed in ramsey/uuid for these fields. You may use the new `Math\CalculatorInterface::toIntegerValue()` method to convert the `Type\Hexadecimal` instances to instances of `Type\Integer`. This library provides `Math\BrickMathCalculator`, which may be - used for this purpose, or you may use the arbitrary-precision arithemetic + used for this purpose, or you may use the arbitrary-precision arithmetic library of your choice. * `getClockSeqHiAndReserved()` * `getClockSeqLow()` diff --git a/composer.json b/composer.json index 3ffc6f8..084c537 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^8.1", "ext-json": "*", - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11" + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12" }, "require-dev": { "captainhook/captainhook": "^5.10", @@ -22,7 +22,7 @@ "mockery/mockery": "^1.3", "php-mock/php-mock": "^2.2", "php-mock/php-mock-mockery": "^1.3", - "php-parallel-lint/php-parallel-lint": "^1.1", + "php-parallel-lint/php-parallel-lint": "^1.4.0", "phpbench/phpbench": "^1.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", diff --git a/composer.lock b/composer.lock index f9bccf0..d54646d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a37c400c7a3410be8aab78fc569c2a59", + "content-hash": "e17d280f45e686b94dad8bca568a2a98", "packages": [ { "name": "brick/math", - "version": "0.11.0", + "version": "0.12.1", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" + "reference": "f510c0a40911935b77b86859eb5223d58d660df1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", + "reference": "f510c0a40911935b77b86859eb5223d58d660df1", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "5.0.0" + "phpunit/phpunit": "^10.1", + "vimeo/psalm": "5.16.0" }, "type": "library", "autoload": { @@ -46,12 +46,17 @@ "arithmetic", "bigdecimal", "bignum", + "bignumber", "brick", - "math" + "decimal", + "integer", + "math", + "mathematics", + "rational" ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.11.0" + "source": "https://github.com/brick/math/tree/0.12.1" }, "funding": [ { @@ -234,12 +239,12 @@ "version": "5.12.0", "source": { "type": "git", - "url": "https://github.com/captainhookphp/captainhook.git", + "url": "https://github.com/captainhook-git/captainhook.git", "reference": "cc27956ef2aa831e10053a891bda99df595b674b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/cc27956ef2aa831e10053a891bda99df595b674b", + "url": "https://api.github.com/repos/captainhook-git/captainhook/zipball/cc27956ef2aa831e10053a891bda99df595b674b", "reference": "cc27956ef2aa831e10053a891bda99df595b674b", "shasum": "" }, @@ -1867,12 +1872,12 @@ "version": "5.2.12", "source": { "type": "git", - "url": "https://github.com/justinrainbow/json-schema.git", + "url": "https://github.com/jsonrainbow/json-schema.git", "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", "shasum": "" }, @@ -2586,16 +2591,16 @@ }, { "name": "php-parallel-lint/php-parallel-lint", - "version": "v1.3.2", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "6483c9832e71973ed29cf71bd6b3f4fde438a9de" + "reference": "6db563514f27e19595a19f45a4bf757b6401194e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6483c9832e71973ed29cf71bd6b3f4fde438a9de", - "reference": "6483c9832e71973ed29cf71bd6b3f4fde438a9de", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e", "shasum": "" }, "require": { @@ -2633,13 +2638,17 @@ "email": "ahoj@jakubonderka.cz" } ], - "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "keywords": [ + "lint", + "static analysis" + ], "support": { "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", - "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.3.2" + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" }, - "time": "2022-02-21T12:50:22+00:00" + "time": "2024-03-27T12:14:49+00:00" }, { "name": "phpbench/container", @@ -5578,12 +5587,12 @@ "version": "3.7.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, @@ -7196,13 +7205,13 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.1", "ext-json": "*" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/docs/requirements.txt b/docs/requirements.txt index 132abd8..022d5b4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,3 @@ -Sphinx==4.5.0 -sphinx-rtd-theme==1.0.0 -sphinxcontrib-phpdomain==0.9.0 +Sphinx==7.3.7 +sphinx-rtd-theme==2.0.0 +sphinxcontrib-phpdomain==0.11.1 diff --git a/psalm.xml b/psalm.xml index 930f633..65815e5 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,7 +4,8 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorLevel="1" cacheDirectory="./build/cache/psalm" - errorBaseline="psalm-baseline.xml"> + errorBaseline="psalm-baseline.xml" + phpVersion="8.1"> diff --git a/src/Generator/UnixTimeGenerator.php b/src/Generator/UnixTimeGenerator.php index b64965d..2af98be 100644 --- a/src/Generator/UnixTimeGenerator.php +++ b/src/Generator/UnixTimeGenerator.php @@ -143,7 +143,7 @@ class UnixTimeGenerator implements TimeGeneratorInterface self::$seedIndex = 21; } - self::$rand[5] = 0xffff & $carry = self::$rand[5] + (self::$seedParts[self::$seedIndex--] & 0xffffff); + self::$rand[5] = 0xffff & $carry = self::$rand[5] + 1 + (self::$seedParts[self::$seedIndex--] & 0xffffff); self::$rand[4] = 0xffff & $carry = self::$rand[4] + ($carry >> 16); self::$rand[3] = 0xffff & $carry = self::$rand[3] + ($carry >> 16); self::$rand[2] = 0xffff & $carry = self::$rand[2] + ($carry >> 16); diff --git a/src/Math/BrickMathCalculator.php b/src/Math/BrickMathCalculator.php index 33e725f..31642e2 100644 --- a/src/Math/BrickMathCalculator.php +++ b/src/Math/BrickMathCalculator.php @@ -137,9 +137,11 @@ final class BrickMathCalculator implements CalculatorInterface /** * Maps ramsey/uuid rounding modes to those used by brick/math + * + * @return BrickMathRounding::* */ - private function getBrickRoundingMode(int $roundingMode): int + private function getBrickRoundingMode(int $roundingMode) { - return self::ROUNDING_MODE_MAP[$roundingMode] ?? 0; + return self::ROUNDING_MODE_MAP[$roundingMode] ?? BrickMathRounding::UNNECESSARY; } } diff --git a/src/Uuid.php b/src/Uuid.php index ef5140a..61293d8 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -19,6 +19,7 @@ use DateTimeInterface; use Ramsey\Uuid\Codec\CodecInterface; use Ramsey\Uuid\Converter\NumberConverterInterface; use Ramsey\Uuid\Converter\TimeConverterInterface; +use Ramsey\Uuid\Exception\InvalidArgumentException; use Ramsey\Uuid\Exception\UnsupportedOperationException; use Ramsey\Uuid\Lazy\LazyUuidFromString; use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; @@ -322,9 +323,10 @@ class Uuid implements Rfc4122UuidInterface * @return UuidInterface A UuidInterface instance created from a binary * string representation * + * @throws InvalidArgumentException + * * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants, * but under constant factory setups, this method operates in functionally pure manners - * * @psalm-suppress ImpureStaticProperty we know that the factory being replaced can lead to massive * havoc across all consumers: that should never happen, and * is generally to be discouraged. Until the factory is kept @@ -360,9 +362,10 @@ class Uuid implements Rfc4122UuidInterface * @return UuidInterface A UuidInterface instance created from a hexadecimal * string representation * + * @throws InvalidArgumentException + * * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants, * but under constant factory setups, this method operates in functionally pure manners - * * @psalm-suppress ImpureStaticProperty we know that the factory being replaced can lead to massive * havoc across all consumers: that should never happen, and * is generally to be discouraged. Until the factory is kept @@ -410,6 +413,8 @@ class Uuid implements Rfc4122UuidInterface * @return UuidInterface A UuidInterface instance created from the Hexadecimal * object representing a hexadecimal number * + * @throws InvalidArgumentException + * * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants, * but under constant factory setups, this method operates in functionally pure manners * @psalm-suppress MixedInferredReturnType,MixedReturnStatement @@ -437,6 +442,8 @@ class Uuid implements Rfc4122UuidInterface * @return UuidInterface A UuidInterface instance created from the string * representation of a 128-bit integer * + * @throws InvalidArgumentException + * * @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants, * but under constant factory setups, this method operates in functionally pure manners */ diff --git a/src/UuidInterface.php b/src/UuidInterface.php index 9f3035b..474957e 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -58,7 +58,7 @@ interface UuidInterface extends JsonSerializable, Stringable * * @param UuidInterface $other The UUID to compare * - * @return int -1, 0, or 1 if the UUID is less than, equal to, or greater than $other + * @return int<-1,1> -1, 0, or 1 if the UUID is less than, equal to, or greater than $other */ public function compareTo(UuidInterface $other): int; diff --git a/tests/Provider/Dce/SystemDceSecurityProviderTest.php b/tests/Provider/Dce/SystemDceSecurityProviderTest.php index 8350d9d..f65f398 100644 --- a/tests/Provider/Dce/SystemDceSecurityProviderTest.php +++ b/tests/Provider/Dce/SystemDceSecurityProviderTest.php @@ -449,7 +449,7 @@ class SystemDceSecurityProviderTest extends TestCase 'expectedId' => '546', ], [ - 'netUserReponse' => 'Local Group Memberships Some Group Another Group', + 'netUserResponse' => 'Local Group Memberships Some Group Another Group', 'wmicGroupResponse' => 'Some Group S-1-5-80-19088743-1985229328-4294967295-1324', 'expectedGroup' => 'Some Group', 'expectedId' => '1324',