diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..c48539a
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+# EditorConfig http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# This applies to all files
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+charset = utf-8
+indent_style = space
+indent_size = 4
+
+[*.{yml,yaml}]
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index 9654800..f49e103 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,12 +1,24 @@
-/.gitattributes export-ignore
-/.github/ export-ignore
-/.gitignore export-ignore
-/.readthedocs.yml export-ignore
-/codecov.yml export-ignore
-/docs/ export-ignore
-/phpbench.json export-ignore
-/phpcs.xml.dist export-ignore
-/phpunit.xml.dist export-ignore
-/resources/ export-ignore
-/SECURITY.md export-ignore
-/tests/ export-ignore
+/.allowed-licenses export-ignore
+/.editorconfig export-ignore
+/.gitattributes export-ignore
+/.github/ export-ignore
+/.gitignore export-ignore
+/.readthedocs.yml export-ignore
+/bin/ export-ignore
+/build/ export-ignore
+/captainhook.json export-ignore
+/CHANGELOG.md export-ignore
+/codecov.yml export-ignore
+/CODE_OF_CONDUCT.md export-ignore
+/CONTRIBUTING.md export-ignore
+/conventional-commits.json export-ignore
+/docs/ export-ignore
+/phpbench.json export-ignore
+/phpcs.xml.dist export-ignore
+/phpstan.neon.dist export-ignore
+/phpunit.xml.dist export-ignore
+/psalm-baseline.xml export-ignore
+/psalm.xml export-ignore
+/resources/ export-ignore
+/SECURITY.md export-ignore
+/tests/ export-ignore
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 0000000..4004d82
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1 @@
+* @ramsey
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
deleted file mode 100644
index cd34a42..0000000
--- a/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# Contributing
-
-Contributions are welcome. I accept pull requests on [GitHub][].
-
-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][]. By participating in
-this project and its community, you are expected to uphold this code.
-
-
-## Communication Channels
-
-You can find help and discussion in the following places:
-
-* GitHub Issues:
-
-
-## Reporting Bugs
-
-Bugs are tracked in the project's [issue tracker][issues].
-
-When submitting a bug report, please include enough information to reproduce the
-bug. A good bug report includes the following sections:
-
-* Expected outcome
-* Actual outcome
-* Steps to reproduce, including sample code
-* Any other information that will help debug and reproduce the issue, including
- stack traces, system/environment information, and screenshots
-
-**Please do not include passwords or any personally identifiable information in
-your bug report and sample code.**
-
-
-## Fixing Bugs
-
-I welcome pull requests to fix bugs!
-
-If you see a bug report that you'd like to fix, please feel free to do so.
-Following the directions and guidelines described in the "Adding New Features"
-section below, you may create bugfix branches and send pull requests.
-
-
-## Adding New Features
-
-If you have an idea for a new feature, it's a good idea to check out the
-[issues][] or active [pull requests][] first to see if the feature is already
-being worked on. If not, feel free to submit an issue first, asking whether the
-feature is beneficial to the project. This will save you from doing a lot of
-development work only to have your feature rejected. I don't enjoy rejecting
-your hard work, but some features just don't fit with the goals of the project.
-
-When you do begin working on your feature, here are some guidelines to consider:
-
-* Your pull request description should clearly detail the changes you have made.
- I will use this description to update the CHANGELOG. If there is no
- description or it does not adequately describe your feature, I will ask you
- to update the description.
-* ramsey/uuid follows the **[PSR-2 coding standard][psr-2]**. Please
- ensure your code does, too.
-* Please **write tests** for any new features you add.
-* Please **ensure that tests pass** before submitting your pull request.
- ramsey/uuid has Travis CI automatically running tests for pull requests.
- However, running the tests locally will help save time.
-* **Use topic/feature branches.** Please do not ask to pull from your master
- branch.
- * For more information, see "[Understanding the GitHub flow][gh-flow]."
-* **Submit one feature per pull request.** If you have multiple features you
- wish to submit, please break them up into separate pull requests.
-* **Write good commit messages.** Make sure each individual commit in your pull
- request is meaningful. If you had to make multiple intermediate commits while
- developing, please squash them before submitting.
- * For more information, see "[How to Write a Git Commit Message][git-commit]."
-
-
-## Running Tests
-
-The following must pass before I will accept a pull request. If this does not
-pass, it will result in a complete build failure. Before you can run this, be
-sure to `composer install` ([download Composer][]).
-
-To run all the tests and coding standards checks, execute the following from the
-command line, while in the project root directory (the same place as the
-`composer.json` file):
-
-```
-composer run-script test
-```
-
-
-[github]: https://github.com/ramsey/uuid
-[contributor code of conduct]: https://github.com/ramsey/uuid/blob/master/.github/CODE_OF_CONDUCT.md
-[issues]: https://github.com/ramsey/uuid/issues
-[pull requests]: https://github.com/ramsey/uuid/pulls
-[psr-2]: https://www.php-fig.org/psr/psr-2/
-[gh-flow]: https://guides.github.com/introduction/flow/
-[git-commit]: https://chris.beams.io/posts/git-commit/
-[download composer]: https://getcomposer.org/
diff --git a/.github/ISSUE_TEMPLATE/Bug_Report.md b/.github/ISSUE_TEMPLATE/Bug_Report.md
new file mode 100644
index 0000000..1d003a7
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Bug_Report.md
@@ -0,0 +1,35 @@
+---
+name: Bug Report
+about: Create a bug report to help us improve
+labels: bug
+assignees:
+---
+
+
+## Description
+
+
+## Steps to reproduce
+
+1. Step one...
+2. Step two...
+3. Step three...
+
+## Expected behavior
+
+
+## Screenshots or output
+
+
+## Environment details
+
+- version of this package: *e.g. 1.0.0, 1.0.1, 1.1.0*
+- PHP version: *e.g. 7.3.16, 7.4.4*
+- OS: *e.g. Windows 10, Linux (Ubuntu 18.04.1), macOS Catalina (10.15.3)*
+
+## Additional context
+
diff --git a/.github/ISSUE_TEMPLATE/Feature_Request.md b/.github/ISSUE_TEMPLATE/Feature_Request.md
new file mode 100644
index 0000000..fdde4b2
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Feature_Request.md
@@ -0,0 +1,31 @@
+---
+name: Feature Request
+about: Suggest a feature for this project
+labels: enhancement
+assignees:
+---
+
+
+
+## My feature title
+
+
+## Background/problem
+
+
+## Proposal/solution
+
+
+## Alternatives
+
+
+## Additional context
+
diff --git a/.github/ISSUE_TEMPLATE/Question.md b/.github/ISSUE_TEMPLATE/Question.md
new file mode 100644
index 0000000..5c76b2a
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Question.md
@@ -0,0 +1,19 @@
+---
+name: Question
+about: Ask a question about how to use this library
+labels: question
+assignees:
+---
+
+
+
+## How do I... ?
+
+
+## Example code
+
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 50ac557..0000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,55 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-labels: bug
-assignees:
----
-
-## Describe the bug
-
-A clear and concise description of what the bug is.
-
-## To Reproduce...
-
-Steps to reproduce the behavior (include code examples, if applicable):
-
-1. Create script `foo.php` and add the following:
-
- ``` php
-
-- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
-- [ ] I have read the **[CONTRIBUTING.md](https://github.com/ramsey/uuid/blob/master/.github/CONTRIBUTING.md)** document.
+- [ ] I have read the **CONTRIBUTING.md** document.
- [ ] I have added tests to cover my changes.
-- [ ] All new and existing tests passed.
-- [ ] I have run `composer run-script test` locally, and there were no failures or errors.
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index 8c14d39..6fbdd07 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -1,54 +1,64 @@
-# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
+# GitHub Actions Documentation: https://docs.github.com/en/actions
-name: "CI"
+name: "build"
-on:
- pull_request:
- push:
- branches:
- - "master"
+on: ["pull_request", "push"]
env:
COMPOSER_ROOT_VERSION: "1.99.99"
jobs:
-
coding-standards:
- name: "Coding Standards"
+ name: "Coding standards"
runs-on: "ubuntu-latest"
steps:
- - uses: "actions/checkout@v2"
- - uses: "shivammathur/setup-php@v2"
+ - name: "Checkout repository"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
with:
- php-version: "7.4"
+ php-version: "latest"
+ extensions: bcmath, ctype, gmp
coverage: "none"
- ini-values: "memory_limit=-1"
- - uses: "ramsey/composer-install@v1"
- - name: "Run the linter"
+
+ - name: "Install dependencies (Composer)"
+ uses: "ramsey/composer-install@v1"
+
+ - name: "Check syntax (php-parallel-lint)"
run: "composer lint -- --colors"
- - name: "Check coding standards"
+
+ - name: "Check coding standards (PHP_CodeSniffer)"
run: "./vendor/bin/phpcs --colors"
static-analysis:
- name: "Static Analysis"
+ name: "Static analysis"
runs-on: "ubuntu-latest"
steps:
- - uses: "actions/checkout@v2"
- - uses: "shivammathur/setup-php@v2"
+ - name: "Checkout repository"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
with:
- php-version: "7.4"
+ php-version: "latest"
+ extensions: bcmath, ctype, gmp
coverage: "none"
- ini-values: "memory_limit=-1"
- - uses: "ramsey/composer-install@v1"
- - name: "Run PHPStan"
+
+ - name: "Install dependencies (Composer)"
+ uses: "ramsey/composer-install@v1"
+
+ - name: "Statically analyze code (PHPStan)"
run: "composer phpstan -- --ansi"
- - name: "Run Psalm"
+
+ - name: "Statically analyze code (Psalm)"
run: "composer psalm -- --shepherd"
benchmark:
name: "Benchmark"
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
+
strategy:
fail-fast: false
matrix:
@@ -56,30 +66,65 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
+ - "8.0"
experimental:
- false
include:
- - php-version: "8.0"
+ - php-version: "8.1"
experimental: true
- composer-options: "--ignore-platform-reqs"
+ composer-options: "--ignore-platform-req=php"
+
steps:
- - uses: "actions/checkout@v2"
- - uses: "shivammathur/setup-php@v2"
+ - name: "Checkout repository"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: bcmath, ctype, gmp
coverage: "none"
ini-values: "memory_limit=-1"
- - uses: "ramsey/composer-install@v1"
+
+ - name: "Install dependencies (Composer)"
+ uses: "ramsey/composer-install@v1"
with:
composer-options: "${{ matrix.composer-options }}"
+
- name: "Run PHPBench"
run: "composer phpbench -- --ansi"
+ code-coverage:
+ name: "Code coverage"
+ runs-on: "ubuntu-latest"
+ steps:
+ - name: "Checkout repository"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "latest"
+ extensions: bcmath, ctype, gmp
+ coverage: "pcov"
+ ini-values: "memory_limit=-1"
+
+ - name: "Install dependencies (Composer)"
+ uses: "ramsey/composer-install@v1"
+ with:
+ dependency-versions: "${{ matrix.dependencies }}"
+
+ - name: "Run unit tests (PHPUnit)"
+ 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@v1"
+
unit-tests:
name: "Unit Tests"
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
+
strategy:
fail-fast: false
matrix:
@@ -87,24 +132,30 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
+ - "8.0"
experimental:
- false
include:
- - php-version: "8.0"
+ - php-version: "8.1"
experimental: true
- composer-options: "--ignore-platform-reqs"
+ composer-options: "--ignore-platform-req=php"
+
steps:
- - uses: "actions/checkout@v2"
- - uses: "shivammathur/setup-php@v2"
+ - name: "Checkout repository"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: bcmath, ctype, gmp
- coverage: "pcov"
+ coverage: "none"
ini-values: "memory_limit=-1"
- - uses: "ramsey/composer-install@v1"
+
+ - name: "Install dependencies (Composer)"
+ uses: "ramsey/composer-install@v1"
with:
composer-options: "${{ matrix.composer-options }}"
- - name: "Run unit tests"
- run: "./vendor/bin/phpunit --verbose --colors=always --coverage-clover build/logs/clover.xml --coverage-text"
- - name: "Publish coverage report to Codecov"
- uses: "codecov/codecov-action@v1"
+
+ - name: "Run unit tests (PHPUnit)"
+ run: "./vendor/bin/phpunit --verbose --colors=always --no-coverage"
diff --git a/.gitignore b/.gitignore
index c61d5b8..3e79da8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-/build/
+/captainhook.config.json
/composer.lock
/phpcs.xml
/phpunit.xml
diff --git a/.github/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
similarity index 100%
rename from .github/CODE_OF_CONDUCT.md
rename to CODE_OF_CONDUCT.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..75d91f5
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,171 @@
+# Contributing
+
+Contributions are welcome. This project accepts pull requests on [GitHub][].
+
+This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By
+participating in this project and its community, you are expected to uphold this
+code.
+
+## Communication Channels
+
+You can find help and discussion in the following places:
+
+* GitHub Issues:
+
+## Reporting Bugs
+
+Report bugs using the project's [issue tracker][issues].
+
+⚠️ _**ATTENTION!!!** DO NOT include passwords or other sensitive information in
+your bug report._
+
+When submitting a bug report, please include enough information to reproduce the
+bug. A good bug report includes the following sections:
+
+* **Description**
+
+ Provide a short and clear description of the bug.
+
+* **Steps to reproduce**
+
+ Provide steps to reproduce the behavior you are experiencing. Please try to
+ keep this as short as possible. If able, create a reproducible script outside
+ of any framework you are using. This will help us to quickly debug the issue.
+
+* **Expected behavior**
+
+ Provide a short and clear description of what you expect to happen.
+
+* **Screenshots or output**
+
+ If applicable, add screenshots or program output to help explain your problem.
+
+* **Environment details**
+
+ Provide details about the system where you're using this package, such as PHP
+ version and operating system.
+
+* **Additional context**
+
+ Provide any additional context that may help us debug the problem.
+
+## Fixing Bugs
+
+This project welcomes pull requests to fix bugs!
+
+If you see a bug report that you'd like to fix, please feel free to do so.
+Following the directions and guidelines described in the "Adding New Features"
+section below, you may create bugfix branches and send pull requests.
+
+## Adding New Features
+
+If you have an idea for a new feature, it's a good idea to check out the
+[issues][] or active [pull requests][] first to see if anyone is already working
+on the feature. If not, feel free to submit an issue first, asking whether the
+feature is beneficial to the project. This will save you from doing a lot of
+development work only to have your feature rejected. We don't enjoy rejecting
+your hard work, but some features don't fit with the goals of the project.
+
+When you do begin working on your feature, here are some guidelines to consider:
+
+* Your pull request description should clearly detail the changes you have made.
+ We will use this description to update the CHANGELOG. If there is no
+ description, or it does not adequately describe your feature, we may ask you
+ to update the description.
+* ramsey/uuid follows a superset of **[PSR-12 coding standard][psr-12]**.
+ Please ensure your code does, too. _Hint: run `composer phpcs` to check._
+* Please **write tests** for any new features you add.
+* Please **ensure that tests pass** before submitting your pull request.
+ ramsey/uuid automatically runs tests for pull requests. However,
+ running the tests locally will help save time. _Hint: run `composer test`._
+* **Use topic/feature branches.** Please do not ask to pull from your main branch.
+ * For more information, see "[Understanding the GitHub flow][gh-flow]."
+* **Submit one feature per pull request.** If you have multiple features you
+ wish to submit, please break them into separate pull requests.
+
+## Developing
+
+To develop this project, you will need [PHP](https://www.php.net) 7.4 or greater
+and [Composer](https://getcomposer.org).
+
+After cloning this repository locally, execute the following commands:
+
+``` bash
+cd /path/to/repository
+composer install
+```
+
+Now, you are ready to develop!
+
+### Tooling
+
+This project uses [CaptainHook](https://github.com/CaptainHookPhp/captainhook)
+to validate all staged changes prior to commit.
+
+### Commands
+
+To see all the commands available for contributing to this project:
+
+``` bash
+composer list
+```
+
+### Coding Standards
+
+This project follows a superset of [PSR-12](https://www.php-fig.org/psr/psr-12/)
+coding standards, enforced by [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
+
+CaptainHook will run coding standards checks before committing.
+
+You may lint the codebase manually using the following commands:
+
+``` bash
+# Lint
+composer phpcs
+
+# Attempt to auto-fix coding standards issues
+composer phpcbf
+```
+
+### Static Analysis
+
+This project uses a combination of [PHPStan](https://github.com/phpstan/phpstan)
+and [Psalm](https://github.com/vimeo/psalm) to provide static analysis of PHP
+code.
+
+CaptainHook will run static analysis checks before committing.
+
+You may run static analysis manually across the whole codebase with the
+following command:
+
+``` bash
+# Static analysis
+composer analyze
+```
+
+### Project Structure
+
+This project uses [pds/skeleton](https://github.com/php-pds/skeleton) as its
+base folder structure and layout.
+
+### Running Tests
+
+The following must pass before we will accept a pull request. If this does not
+pass, it will result in a complete build failure. Before you can run this, be
+sure to `composer install`.
+
+To run all the tests and coding standards checks, execute the following from the
+command line, while in the project root directory:
+
+```
+composer test
+```
+
+CaptainHook will automatically run all tests before pushing to the remote
+repository.
+
+[github]: https://github.com/ramsey/uuid
+[issues]: https://github.com/ramsey/uuid/issues
+[pull requests]: https://github.com/ramsey/uuid/pulls
+[psr-12]: https://www.php-fig.org/psr/psr-12/
+[gh-flow]: https://guides.github.com/introduction/flow/
diff --git a/LICENSE b/LICENSE
index b2aa4b5..5e06cf4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,4 @@
-MIT License
-
-Copyright (c) 2012-2020 Ben Ramsey
+Copyright (c) 2012-2021 Ben Ramsey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 2ecd3ca..e234fed 100644
--- a/README.md
+++ b/README.md
@@ -8,25 +8,22 @@
+
-
-
-
ramsey/uuid is a PHP library for generating and working with universally unique
identifiers (UUIDs).
-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.
+This project adheres to a [code of conduct](CODE_OF_CONDUCT.md).
+By participating in this project and its community, you are expected to
+uphold this code.
Much inspiration for this library came from the [Java][javauuid] and
[Python][pyuuid] UUID libraries.
-
## Installation
The preferred method of installation is via [Composer][]. Run the following
@@ -37,24 +34,21 @@ command to install the package and add it as a requirement to your project's
composer require ramsey/uuid
```
-
## Upgrading to Version 4
See the documentation for a thorough upgrade guide:
* [Upgrading ramsey/uuid Version 3 to 4](https://uuid.ramsey.dev/en/latest/upgrading/3-to-4.html)
-
## Documentation
Please see for documentation, tips, examples, and
frequently asked questions.
-
## Contributing
-Contributions are welcome! Please read [CONTRIBUTING.md][] for details.
-
+Contributions are welcome! To contribute, please familiarize yourself with
+[CONTRIBUTING.md](CONTRIBUTING.md).
## Coordinated Disclosure
@@ -63,7 +57,6 @@ contribution of external security researchers. If you believe you've found a
security issue in software that is maintained in this repository, please read
[SECURITY.md][] for instructions on submitting a vulnerability report.
-
## ramsey/uuid for Enterprise
Available as part of the Tidelift Subscription.
@@ -74,14 +67,12 @@ packages you use to build your applications. Save time, reduce risk, and improve
code health, while paying the maintainers of the exact packages you use.
[Learn more.](https://tidelift.com/subscription/pkg/packagist-ramsey-uuid?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
-
## Copyright and License
The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and
licensed for use under the MIT License (MIT). Please see [LICENSE][] for more
information.
-
[rfc4122]: http://tools.ietf.org/html/rfc4122
[conduct]: https://github.com/ramsey/uuid/blob/master/.github/CODE_OF_CONDUCT.md
[javauuid]: http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html
diff --git a/SECURITY.md b/SECURITY.md
index 7e1936c..5f0bc98 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -1,29 +1,59 @@
-# Vulnerability Disclosure Policy
+# Vulnerability Disclosure Policy (VDP)
+
+## Brand Promise
+
+
Keeping user information safe and secure is a top priority, and we welcome the
contribution of external security researchers.
## Scope
+
+
If you believe you've found a security issue in software that is maintained in
this repository, we encourage you to notify us.
| Version | In scope | Source code |
-| :-----: | :------: | :---------- |
-| latest | ✅ | https://github.com/ramsey/uuid |
+| ------- | -------- | ----------- |
+| latest | ✅ | https://github.com/ramsey/uuid |
## How to Submit a Report
-To submit a vulnerability report, please contact us at .
+
+
+To submit a vulnerability report, please contact us at security@ramsey.dev.
Your submission will be reviewed and validated by a member of our team.
## Safe Harbor
+
+
We support safe harbor for security researchers who:
* Make a good faith effort to avoid privacy violations, destruction of data, and
@@ -33,7 +63,7 @@ We support safe harbor for security researchers who:
us immediately, do not proceed with access, and immediately purge any local
information.
* Provide us with a reasonable amount of time to resolve vulnerabilities prior
- to any disclosure to the public or a third-party.
+ to any disclosure to the public or a third party.
We will consider activities conducted consistent with this policy to constitute
"authorized" conduct and will not pursue civil action or initiate a complaint to
@@ -45,15 +75,40 @@ with or unaddressed by this policy.
## Preferences
+
+
* Please provide detailed reports with reproducible steps and a clearly defined
impact.
* Include the version number of the vulnerable package in your report
* Social engineering (e.g. phishing, vishing, smishing) is prohibited.
+
+
## Encryption Key for security@ramsey.dev
-For increased privacy when reporting sensitive issues, you may encrypt your
-messages using the following key:
+For increased privacy when reporting sensitive issues, you may encrypt your message using the following public key:
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..1375c16
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1,6 @@
+*
+!.gitignore
+!cache
+!cache/.gitkeep
+!logs
+!logs/.gitkeep
diff --git a/build/cache/.gitkeep b/build/cache/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/build/logs/.gitkeep b/build/logs/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/captainhook.json b/captainhook.json
new file mode 100644
index 0000000..195812e
--- /dev/null
+++ b/captainhook.json
@@ -0,0 +1,123 @@
+{
+ "config": {
+ "ansi-colors": true,
+ "fail-on-first-error": false,
+ "plugins": [],
+ "verbosity": "normal"
+ },
+ "commit-msg": {
+ "enabled": false,
+ "actions": []
+ },
+ "pre-push": {
+ "enabled": true,
+ "actions": [
+ {
+ "action": "composer test"
+ }
+ ]
+ },
+ "pre-commit": {
+ "enabled": true,
+ "actions": [
+ {
+ "action": "composer validate",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\Any",
+ "args": [["composer.json"]]
+ }
+ ]
+ },
+ {
+ "action": "composer normalize --dry-run",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\Any",
+ "args": [["composer.json"]]
+ }
+ ]
+ },
+ {
+ "action": "composer lint:paths -- {$STAGED_FILES|of-type:php}",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
+ "args": ["php"]
+ }
+ ]
+ },
+ {
+ "action": "composer phpcs -- {$STAGED_FILES|of-type:php}",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
+ "args": ["php"]
+ }
+ ]
+ },
+ {
+ "action": "composer phpstan -- {$STAGED_FILES|of-type:php}",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
+ "args": ["php"]
+ }
+ ]
+ },
+ {
+ "action": "composer psalm -- {$STAGED_FILES|of-type:php}",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
+ "args": ["php"]
+ }
+ ]
+ }
+ ]
+ },
+ "prepare-commit-msg": {
+ "enabled": false,
+ "actions": []
+ },
+ "post-commit": {
+ "enabled": false,
+ "actions": []
+ },
+ "post-merge": {
+ "enabled": true,
+ "actions": [
+ {
+ "action": "composer install --ansi",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any",
+ "args": [["composer.json", "composer.lock"]]
+ }
+ ]
+ }
+ ]
+ },
+ "post-checkout": {
+ "enabled": true,
+ "actions": [
+ {
+ "action": "composer install --ansi",
+ "conditions": [
+ {
+ "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any",
+ "args": [["composer.json", "composer.lock"]]
+ }
+ ]
+ }
+ ]
+ },
+ "post-rewrite": {
+ "enabled": false,
+ "actions": []
+ },
+ "post-change": {
+ "enabled": false,
+ "actions": []
+ }
+}
diff --git a/composer.json b/composer.json
index b308471..016eb51 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,6 @@
"identifier",
"guid"
],
- "homepage": "https://github.com/ramsey/uuid",
"license": "MIT",
"require": {
"php": "^7.2 || ^8",
@@ -16,9 +15,15 @@
"ramsey/collection": "^1.0",
"symfony/polyfill-ctype": "^1.8"
},
+ "replace": {
+ "rhumsaa/uuid": "self.version"
+ },
"require-dev": {
+ "captainhook/captainhook": "^5.10",
+ "captainhook/plugin-composer": "^5.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"doctrine/annotations": "^1.8",
+ "ergebnis/composer-normalize": "^2.15",
"mockery/mockery": "^1.3",
"moontoast/math": "^1.1",
"paragonie/random-lib": "^2",
@@ -31,20 +36,17 @@
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5 || ^9",
- "psy/psysh": "^0.10.0",
- "slevomat/coding-standard": "^6.0",
+ "slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^3.18"
},
- "minimum-stability": "dev",
- "prefer-stable": true,
"suggest": {
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
"ext-ctype": "Enables faster processing of character classification using ctype functions.",
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
"ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
- "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type.",
- "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter"
+ "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
+ "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
},
"config": {
"sort-packages": true
@@ -52,11 +54,11 @@
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
+ },
+ "captainhook": {
+ "force-install": true
}
},
- "replace": {
- "rhumsaa/uuid": "self.version"
- },
"autoload": {
"psr-4": {
"Ramsey\\Uuid\\": "src/"
@@ -72,18 +74,25 @@
"Ramsey\\Uuid\\Test\\": "tests/"
}
},
+ "minimum-stability": "dev",
+ "prefer-stable": true,
"scripts": {
+ "analyze": [
+ "@phpstan",
+ "@psalm"
+ ],
"lint": "parallel-lint src tests",
+ "lint:paths": "parallel-lint",
"phpbench": "phpbench run",
"phpcbf": "phpcbf -vpw --cache=build/cache/phpcs.cache",
"phpcs": "phpcs --cache=build/cache/phpcs.cache",
"phpstan": [
- "phpstan analyse -c tests/phpstan.neon --no-progress",
- "phpstan analyse -c tests/phpstan-tests.neon --no-progress"
+ "phpstan analyse --no-progress",
+ "phpstan analyse -c phpstan-tests.neon --no-progress"
],
- "psalm": "psalm --show-info=false --config=tests/psalm.xml",
"phpunit": "phpunit --verbose --colors=always",
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
+ "psalm": "psalm --show-info=false --config=psalm.xml",
"test": [
"@lint",
"@phpbench",
@@ -92,10 +101,5 @@
"@psalm",
"@phpunit"
]
- },
- "support": {
- "issues": "https://github.com/ramsey/uuid/issues",
- "rss": "https://github.com/ramsey/uuid/releases.atom",
- "source": "https://github.com/ramsey/uuid"
}
}
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index abf6f4b..aac5769 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -1,22 +1,14 @@
-
+
- ramsey/uuid coding standard
+
+
+
-
-
-
./src
./tests
-
-
-
+ A common coding standard for Ramsey's PHP libraries.
@@ -72,6 +64,13 @@
+
+
+
+
+
+
+
@@ -103,6 +102,9 @@
+
+
+
@@ -143,15 +145,8 @@
-
-
+
+
@@ -179,7 +174,11 @@
-
+
+
+
+
+
@@ -187,11 +186,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -237,19 +236,19 @@
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
@@ -278,6 +277,9 @@
+
+
+
@@ -305,7 +307,19 @@
-
+
+
+
+
+
+
+
+
@@ -326,6 +340,9 @@
+
+
+
@@ -347,9 +364,19 @@
+
+
+
+
+
+
+
+
+
+
@@ -394,7 +421,7 @@
-
+
@@ -406,6 +433,13 @@
+
+
+
+
+
+
+
@@ -433,7 +467,10 @@
-
+
+
+
+
diff --git a/tests/phpstan-tests.neon b/phpstan-tests.neon
similarity index 54%
rename from tests/phpstan-tests.neon
rename to phpstan-tests.neon
index 1973ce3..94ee0fa 100644
--- a/tests/phpstan-tests.neon
+++ b/phpstan-tests.neon
@@ -1,29 +1,31 @@
parameters:
- tmpDir: ../build/cache/phpstan
+ tmpDir: ./build/cache/phpstan
level: max
paths:
- - .
+ - ./tests
bootstrapFiles:
- - ./phpstan-bootstrap.php
+ - ./tests/phpstan-bootstrap.php
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
excludes_analyse:
- - ./ExpectedBehaviorTest.php
- - ./phpstan-bootstrap.php
+ - ./tests/ExpectedBehaviorTest.php
+ - ./tests/phpstan-bootstrap.php
ignoreErrors:
-
message: "#^Function uuid_create\\(\\) has no return typehint specified\\.$#"
count: 1
- path: phpstan-bootstrap.php
+ path: ./tests/phpstan-bootstrap.php
-
message: "#^Function uuid_create\\(\\) has parameter \\$uuid_type with no typehint specified\\.$#"
count: 1
- path: phpstan-bootstrap.php
+ path: ./tests/phpstan-bootstrap.php
-
message: "#^Function uuid_parse\\(\\) has no return typehint specified\\.$#"
count: 1
- path: phpstan-bootstrap.php
+ path: ./tests/phpstan-bootstrap.php
-
message: "#^Function uuid_parse\\(\\) has parameter \\$uuid with no typehint specified\\.$#"
count: 1
- path: phpstan-bootstrap.php
+ path: ./tests/phpstan-bootstrap.php
+ - '#^Call to static method [a-zA-Z0-9\\_]+::[a-zA-Z0-9]+\(\) on a separate line has no effect\.$#'
+ - '#^Call to method [a-zA-Z0-9\\_]+::[a-zA-Z0-9]+\(\) on a separate line has no effect\.$#'
diff --git a/tests/phpstan.neon b/phpstan.neon.dist
similarity index 70%
rename from tests/phpstan.neon
rename to phpstan.neon.dist
index 9a01671..131212f 100644
--- a/tests/phpstan.neon
+++ b/phpstan.neon.dist
@@ -1,31 +1,31 @@
parameters:
- tmpDir: ../build/cache/phpstan
+ tmpDir: ./build/cache/phpstan
level: max
paths:
- - ../src
+ - ./src
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
bootstrapFiles:
- - ./phpstan-bootstrap.php
+ - ./tests/phpstan-bootstrap.php
ignoreErrors:
-
message: '#^Call to function is_int\(\) with float will always evaluate to false\.$#'
count: 1
- path: ../src/Converter/Time/PhpTimeConverter.php
+ path: ./src/Converter/Time/PhpTimeConverter.php
-
message: '#^Unreachable statement - code above always terminates\.$#'
count: 1
- path: ../src/Converter/Time/PhpTimeConverter.php
+ path: ./src/Converter/Time/PhpTimeConverter.php
-
message: '#^Comparison operation "<" between int<6, max> and 0 is always false\.$#'
count: 1
- path: ../src/Generator/CombGenerator.php
+ path: ./src/Generator/CombGenerator.php
-
message: '#^Comparison operation ">" between 6 and 0 is always true\.$#'
count: 1
- path: ../src/Generator/CombGenerator.php
+ path: ./src/Generator/CombGenerator.php
-
# Legacy methods of `Ramsey\Uuid` use interface methods that are NOT defined on `FieldsInterface`
message: '#^Call to an undefined method Ramsey\\Uuid\\Fields\\FieldsInterface::get.*$#'
count: 9
- path: ../src/Lazy/LazyUuidFromString.php
+ path: ./src/Lazy/LazyUuidFromString.php
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 9cd876f..97c1f24 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,18 +1,21 @@
+
-
+
./tests
-
-
+
+
+
./src
-
-
+
+
+
diff --git a/tests/psalm-baseline.xml b/psalm-baseline.xml
similarity index 100%
rename from tests/psalm-baseline.xml
rename to psalm-baseline.xml
diff --git a/psalm.xml b/psalm.xml
new file mode 100644
index 0000000..7d4f6f5
--- /dev/null
+++ b/psalm.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/docker/Dockerfile b/resources/docker/Dockerfile
deleted file mode 100644
index 21e098a..0000000
--- a/resources/docker/Dockerfile
+++ /dev/null
@@ -1,28 +0,0 @@
-ARG PHP_VERSION
-ARG ARCH
-
-FROM ${ARCH}/php:${PHP_VERSION}-cli-alpine
-
-ARG XDEBUG
-
-RUN apk update \
- && apk add --virtual=builddeps autoconf g++ gcc libc6-compat make re2c \
- && apk add \
- git \
- gmp-dev \
- libsodium-dev \
- libzip-dev \
- unzip \
- util-linux-dev \
- && docker-php-ext-install -j$(nproc) bcmath gmp zip \
- && yes '' | pecl install libsodium-1.0.7 \
- && yes '' | pecl install uuid \
- && docker-php-ext-enable libsodium uuid \
- && if [ "${XDEBUG}" == "yes" ]; then yes '' | pecl install xdebug; fi \
- && if [ "${XDEBUG}" == "yes" ]; then docker-php-ext-enable xdebug; fi \
- && apk del builddeps
-
-COPY composer-install.sh /usr/local/bin/composer-install.sh
-RUN composer-install.sh \
- && mv composer.phar /usr/local/bin/composer \
- && rm /usr/local/bin/composer-install.sh
diff --git a/resources/docker/build.sh b/resources/docker/build.sh
deleted file mode 100755
index 976b991..0000000
--- a/resources/docker/build.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-PHP_VERSION=$1
-ARCH=$2
-XDEBUG=${3:-no}
-
-xdebug_tag="-without-xdebug"
-if [ "${XDEBUG}" == "yes" ]; then
- xdebug_tag=""
-fi
-
-build_tag="benramsey/ramsey-uuid:php-${PHP_VERSION}-${ARCH}${xdebug_tag}"
-
-docker build \
- --tag ${build_tag} \
- --build-arg PHP_VERSION=${PHP_VERSION} \
- --build-arg ARCH=${ARCH} \
- --build-arg XDEBUG=${XDEBUG} \
- .
-
-docker run --rm ${build_tag} php -v
-docker run --rm ${build_tag} composer --version --ansi
diff --git a/resources/docker/composer-install.sh b/resources/docker/composer-install.sh
deleted file mode 100755
index 89abc1a..0000000
--- a/resources/docker/composer-install.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-EXPECTED_SIGNATURE="$(curl --silent https://composer.github.io/installer.sig)"
-php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
-
-if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
-then
- >&2 echo 'ERROR: Invalid installer signature'
- rm composer-setup.php
- exit 1
-fi
-
-php composer-setup.php --quiet
-RESULT=$?
-rm composer-setup.php
-exit $RESULT
diff --git a/resources/scripts/cmd-proxy.sh b/resources/scripts/cmd-proxy.sh
deleted file mode 100755
index 6934649..0000000
--- a/resources/scripts/cmd-proxy.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-#
-# This script uses the ARCH environment variable to determine whether to run
-# the commands through a 32-bit Docker container, for 32-bit testing. If the
-# ARCH is anything other than "arm32," then it simply executes the commands
-# on the local system, rather than in a container.
-
-php_version="${TRAVIS_PHP_VERSION:-$(php -r "echo phpversion();")}"
-
-dots_count=$(echo $php_version | awk -F"." '{print NF-1}')
-if [ $dots_count -ge 2 ]; then
- php_version="${php_version%.*}"
-fi
-
-architecture="${ARCH:-${TRAVIS_CPU_ARCH:-$(uname -m)}}"
-
-# Only use Xdebug if running as a cron job on Travis CI
-xdebug=""
-if [ "${TRAVIS_EVENT_TYPE}" != "cron" ]; then
- xdebug="-without-xdebug"
-fi
-
-cmd_proxy=""
-
-if [ "${architecture}" = "arm32" ]; then
- image="benramsey/ramsey-uuid:php-${php_version}-arm32v7${xdebug}"
- volumes="-v ${PWD}:${PWD} -v ${HOME}/.composer/cache:/root/.composer/cache"
- cmd_proxy="docker run --rm ${volumes} -w ${PWD} ${image}"
-fi
-
-$cmd_proxy "$@"
diff --git a/resources/scripts/php-coveralls.sh b/resources/scripts/php-coveralls.sh
deleted file mode 100755
index 5031938..0000000
--- a/resources/scripts/php-coveralls.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-set -e
-
-if [ "${TRAVIS_EVENT_TYPE}" != "cron" ]; then
- exit 0
-fi
-
-if [ -f vendor/bin/php-coveralls ]; then
- php vendor/bin/php-coveralls -v
-else
- php vendor/bin/coveralls -v
-fi
diff --git a/resources/scripts/system-info.sh b/resources/scripts/system-info.sh
deleted file mode 100755
index af35a54..0000000
--- a/resources/scripts/system-info.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-endianness=$(printf I | hexdump -o | awk '{ print substr($2,6,1); exit}')
-
-endian="Big"
-if [ "${endianness}" = "1" ]; then
- endian="Little"
-fi
-
-echo
-echo "SYSTEM INFORMATION:"
-echo
-echo "$(uname -a)"
-echo
-echo "CPU mode: $(getconf LONG_BIT)-bit"
-echo "Endianness: ${endian}"
-echo
-php --version
-echo
diff --git a/resources/scripts/travis-before-install.sh b/resources/scripts/travis-before-install.sh
deleted file mode 100755
index 1612def..0000000
--- a/resources/scripts/travis-before-install.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-#
-# This script runs as part of the Travis CI before_install phase. If the ARCH
-# environment variable is set and has the value "arm32," then we exit early,
-# since we will use a pre-built Docker image to run commands instead.
-
-architecture=${ARCH:-${TRAVIS_CPU_ARCH:-$(uname -m)}}
-
-if [ "${architecture}" = "arm32" ]; then
- exit
-fi
-
-yes '' | pecl install -f libsodium-1.0.7
-yes '' | pecl install -f uuid-1.0.4
-composer self-update
diff --git a/src/Builder/BuilderCollection.php b/src/Builder/BuilderCollection.php
index 0997971..bb52e26 100644
--- a/src/Builder/BuilderCollection.php
+++ b/src/Builder/BuilderCollection.php
@@ -26,6 +26,8 @@ use Traversable;
/**
* A collection of UuidBuilderInterface objects
+ *
+ * @extends AbstractCollection
*/
class BuilderCollection extends AbstractCollection
{
@@ -54,7 +56,7 @@ class BuilderCollection extends AbstractCollection
*/
public function unserialize($serialized): void
{
- /** @var mixed[] $data */
+ /** @var array $data */
$data = unserialize($serialized, [
'allowed_classes' => [
BrickMathCalculator::class,
diff --git a/src/Codec/OrderedTimeCodec.php b/src/Codec/OrderedTimeCodec.php
index fe9f57c..0798ebc 100644
--- a/src/Codec/OrderedTimeCodec.php
+++ b/src/Codec/OrderedTimeCodec.php
@@ -67,6 +67,7 @@ class OrderedTimeCodec extends StringCodec
$bytes = $uuid->getFields()->getBytes();
+ /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
return $bytes[6] . $bytes[7]
. $bytes[4] . $bytes[5]
. $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3]
diff --git a/src/Codec/StringCodec.php b/src/Codec/StringCodec.php
index fff13bd..58c9f58 100644
--- a/src/Codec/StringCodec.php
+++ b/src/Codec/StringCodec.php
@@ -75,6 +75,7 @@ class StringCodec implements CodecInterface
*/
public function encodeBinary(UuidInterface $uuid): string
{
+ /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
return $uuid->getFields()->getBytes();
}
diff --git a/src/Codec/TimestampFirstCombCodec.php b/src/Codec/TimestampFirstCombCodec.php
index 06ce38f..0e0042d 100644
--- a/src/Codec/TimestampFirstCombCodec.php
+++ b/src/Codec/TimestampFirstCombCodec.php
@@ -76,6 +76,7 @@ class TimestampFirstCombCodec extends StringCodec
*/
public function encodeBinary(UuidInterface $uuid): string
{
+ /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
return $this->swapBytes($uuid->getFields()->getBytes());
}
diff --git a/src/Converter/Number/GenericNumberConverter.php b/src/Converter/Number/GenericNumberConverter.php
index b95d5e0..501eac0 100644
--- a/src/Converter/Number/GenericNumberConverter.php
+++ b/src/Converter/Number/GenericNumberConverter.php
@@ -57,6 +57,7 @@ class GenericNumberConverter implements NumberConverterInterface
*/
public function toHex(string $number): string
{
+ /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
return $this->calculator->toBase(new IntegerObject($number), 16);
}
}
diff --git a/src/Generator/DefaultNameGenerator.php b/src/Generator/DefaultNameGenerator.php
index 1c0b004..7303e9f 100644
--- a/src/Generator/DefaultNameGenerator.php
+++ b/src/Generator/DefaultNameGenerator.php
@@ -16,6 +16,7 @@ namespace Ramsey\Uuid\Generator;
use Ramsey\Uuid\Exception\NameException;
use Ramsey\Uuid\UuidInterface;
+use ValueError;
use function hash;
@@ -31,7 +32,7 @@ class DefaultNameGenerator implements NameGeneratorInterface
try {
/** @var string|bool $bytes */
$bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
- } catch (\ValueError $e) {
+ } catch (ValueError $e) {
$bytes = false; // keep same behavior than PHP 7
}
diff --git a/src/Generator/RandomBytesGenerator.php b/src/Generator/RandomBytesGenerator.php
index e6e9a19..12edb96 100644
--- a/src/Generator/RandomBytesGenerator.php
+++ b/src/Generator/RandomBytesGenerator.php
@@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Generator;
use Ramsey\Uuid\Exception\RandomSourceException;
+use Throwable;
/**
* RandomBytesGenerator generates strings of random binary data using the
@@ -33,7 +34,7 @@ class RandomBytesGenerator implements RandomGeneratorInterface
{
try {
return random_bytes($length);
- } catch (\Throwable $exception) {
+ } catch (Throwable $exception) {
throw new RandomSourceException(
$exception->getMessage(),
(int) $exception->getCode(),
diff --git a/src/Lazy/LazyUuidFromString.php b/src/Lazy/LazyUuidFromString.php
index 3d4ddcb..82c156c 100644
--- a/src/Lazy/LazyUuidFromString.php
+++ b/src/Lazy/LazyUuidFromString.php
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey
- * @license http://opensource.org/licenses/MIT MIT
+ * @license http://opensource.org/licenses/MIT MIT
*/
declare(strict_types=1);
@@ -242,6 +242,7 @@ final class LazyUuidFromString implements UuidInterface
*/
public function getBytes(): string
{
+ /** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
return (string) hex2bin(str_replace('-', '', $this->uuid));
}
@@ -497,7 +498,7 @@ final class LazyUuidFromString implements UuidInterface
public function getTimestamp(): string
{
$instance = ($this->unwrapped ?? $this->unwrap());
- $fields = $instance->getFields();
+ $fields = $instance->getFields();
if ($fields->getVersion() !== 1) {
throw new UnsupportedOperationException('Not a time-based UUID');
diff --git a/src/Provider/Node/NodeProviderCollection.php b/src/Provider/Node/NodeProviderCollection.php
index c49398e..5575b5b 100644
--- a/src/Provider/Node/NodeProviderCollection.php
+++ b/src/Provider/Node/NodeProviderCollection.php
@@ -20,6 +20,8 @@ use Ramsey\Uuid\Type\Hexadecimal;
/**
* A collection of NodeProviderInterface objects
+ *
+ * @extends AbstractCollection
*/
class NodeProviderCollection extends AbstractCollection
{
@@ -38,7 +40,7 @@ class NodeProviderCollection extends AbstractCollection
*/
public function unserialize($serialized): void
{
- /** @var mixed[] $data */
+ /** @var array $data */
$data = unserialize($serialized, [
'allowed_classes' => [
Hexadecimal::class,
diff --git a/src/Provider/Node/RandomNodeProvider.php b/src/Provider/Node/RandomNodeProvider.php
index 266c0b7..7614136 100644
--- a/src/Provider/Node/RandomNodeProvider.php
+++ b/src/Provider/Node/RandomNodeProvider.php
@@ -17,6 +17,7 @@ namespace Ramsey\Uuid\Provider\Node;
use Ramsey\Uuid\Exception\RandomSourceException;
use Ramsey\Uuid\Provider\NodeProviderInterface;
use Ramsey\Uuid\Type\Hexadecimal;
+use Throwable;
use function bin2hex;
use function dechex;
@@ -38,7 +39,7 @@ class RandomNodeProvider implements NodeProviderInterface
{
try {
$nodeBytes = random_bytes(6);
- } catch (\Throwable $exception) {
+ } catch (Throwable $exception) {
throw new RandomSourceException(
$exception->getMessage(),
(int) $exception->getCode(),
diff --git a/src/Uuid.php b/src/Uuid.php
index 762dfdb..08c9223 100644
--- a/src/Uuid.php
+++ b/src/Uuid.php
@@ -238,9 +238,9 @@ class Uuid implements UuidInterface
* ```
* use Ramsey\Uuid\Uuid;
*
- * $timeBasedUuid = Uuid::uuid1();
- * $namespaceMd5Uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, 'http://php.net/');
- * $randomUuid = Uuid::uuid4();
+ * $timeBasedUuid = Uuid::uuid1();
+ * $namespaceMd5Uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, 'http://php.net/');
+ * $randomUuid = Uuid::uuid4();
* $namespaceSha1Uuid = Uuid::uuid5(Uuid::NAMESPACE_URL, 'http://php.net/');
* ```
*
@@ -436,7 +436,7 @@ class Uuid implements UuidInterface
/**
* Creates a UUID from the string standard representation
*
- * @param string $uuid A hexadecimal string
+ * @param non-empty-string $uuid A hexadecimal string
*
* @return UuidInterface A UuidInterface instance created from a hexadecimal
* string representation
diff --git a/src/functions.php b/src/functions.php
index 7b29ec4..ed30b58 100644
--- a/src/functions.php
+++ b/src/functions.php
@@ -29,7 +29,7 @@ use Ramsey\Uuid\Type\Integer as IntegerObject;
* could arise when the clock is set backwards in time or if the node ID
* changes
*
- * @return string Version 1 UUID as a string
+ * @return non-empty-string Version 1 UUID as a string
*/
function v1($node = null, ?int $clockSeq = null): string
{
@@ -52,7 +52,7 @@ function v1($node = null, ?int $clockSeq = null): string
* that could arise when the clock is set backwards in time or if the
* node ID changes
*
- * @return string Version 2 UUID as a string
+ * @return non-empty-string Version 2 UUID as a string
*/
function v2(
int $localDomain,
@@ -69,7 +69,7 @@ function v2(
*
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
*
- * @return string Version 3 UUID as a string
+ * @return non-empty-string Version 3 UUID as a string
*/
function v3($ns, string $name): string
{
@@ -79,7 +79,7 @@ function v3($ns, string $name): string
/**
* Returns a version 4 (random) UUID
*
- * @return string Version 4 UUID as a string
+ * @return non-empty-string Version 4 UUID as a string
*/
function v4(): string
{
@@ -92,7 +92,7 @@ function v4(): string
*
* @param string|UuidInterface $ns The namespace (must be a valid UUID)
*
- * @return string Version 5 UUID as a string
+ * @return non-empty-string Version 5 UUID as a string
*/
function v5($ns, string $name): string
{
@@ -109,7 +109,7 @@ function v5($ns, string $name): string
* could arise when the clock is set backwards in time or if the node ID
* changes
*
- * @return string Version 6 UUID as a string
+ * @return non-empty-string Version 6 UUID as a string
*/
function v6(?Hexadecimal $node = null, ?int $clockSeq = null): string
{
diff --git a/tests/Builder/FallbackBuilderTest.php b/tests/Builder/FallbackBuilderTest.php
index 7b63b6c..d9dc8de 100644
--- a/tests/Builder/FallbackBuilderTest.php
+++ b/tests/Builder/FallbackBuilderTest.php
@@ -24,7 +24,6 @@ use Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder;
use Ramsey\Uuid\Rfc4122\UuidV1;
use Ramsey\Uuid\Rfc4122\UuidV2;
use Ramsey\Uuid\Test\TestCase;
-use Ramsey\Uuid\Validator\GenericValidator;
class FallbackBuilderTest extends TestCase
{
@@ -69,7 +68,6 @@ class FallbackBuilderTest extends TestCase
*/
public function testSerializationOfBuilderCollection(string $bytes): void
{
- $validator = new GenericValidator();
$calculator = new BrickMathCalculator();
$genericNumberConverter = new GenericNumberConverter($calculator);
$genericTimeConverter = new GenericTimeConverter($calculator);
diff --git a/tests/Codec/StringCodecTest.php b/tests/Codec/StringCodecTest.php
index 7aa71f9..2412dcd 100644
--- a/tests/Codec/StringCodecTest.php
+++ b/tests/Codec/StringCodecTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Test\Codec;
+use InvalidArgumentException;
use Mockery;
use PHPUnit\Framework\MockObject\MockObject;
use Ramsey\Uuid\Builder\UuidBuilderInterface;
@@ -112,7 +113,7 @@ class StringCodecTest extends TestCase
$string = 'invalid-uuid';
$codec = new StringCodec($this->builder);
- $this->expectException(\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$codec->decode($string);
}
@@ -132,7 +133,7 @@ class StringCodecTest extends TestCase
$bytes = pack('H*', $string);
$codec = new StringCodec($this->builder);
- $this->expectException(\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$bytes string should contain 16 characters.');
$codec->decodeBytes($bytes);
}
diff --git a/tests/Generator/DefaultNameGeneratorTest.php b/tests/Generator/DefaultNameGeneratorTest.php
index 8c3ee19..5c15421 100644
--- a/tests/Generator/DefaultNameGeneratorTest.php
+++ b/tests/Generator/DefaultNameGeneratorTest.php
@@ -14,6 +14,8 @@ use function hash;
class DefaultNameGeneratorTest extends TestCase
{
/**
+ * @param non-empty-string $ns
+ *
* @dataProvider provideNamesForHashingTest
*/
public function testDefaultNameGeneratorHashesName(string $ns, string $name, string $algorithm): void
diff --git a/tests/Generator/PeclUuidNameGeneratorTest.php b/tests/Generator/PeclUuidNameGeneratorTest.php
index 1c946bb..6d2aad3 100644
--- a/tests/Generator/PeclUuidNameGeneratorTest.php
+++ b/tests/Generator/PeclUuidNameGeneratorTest.php
@@ -19,6 +19,8 @@ use function unpack;
class PeclUuidNameGeneratorTest extends TestCase
{
/**
+ * @param non-empty-string $ns
+ *
* @dataProvider provideNamesForHashingTest
*/
public function testPeclUuidNameGeneratorHashesName(string $ns, string $name, string $algorithm): void
diff --git a/tests/Guid/FieldsTest.php b/tests/Guid/FieldsTest.php
index d55f4b1..4924e55 100644
--- a/tests/Guid/FieldsTest.php
+++ b/tests/Guid/FieldsTest.php
@@ -98,7 +98,6 @@ class FieldsTest extends TestCase
/**
* @param string|int $expectedValue
*
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint
* @dataProvider fieldGetterMethodProvider
*/
public function testFieldGetterMethods(string $bytes, string $methodName, $expectedValue): void
diff --git a/tests/Guid/GuidBuilderTest.php b/tests/Guid/GuidBuilderTest.php
index 7938ade..df0405a 100644
--- a/tests/Guid/GuidBuilderTest.php
+++ b/tests/Guid/GuidBuilderTest.php
@@ -9,6 +9,7 @@ use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Exception\UnableToBuildUuidException;
use Ramsey\Uuid\Guid\GuidBuilder;
use Ramsey\Uuid\Test\TestCase;
+use RuntimeException;
class GuidBuilderTest extends TestCase
{
@@ -19,7 +20,7 @@ class GuidBuilderTest extends TestCase
$builder = Mockery::mock(GuidBuilder::class);
$builder->shouldAllowMockingProtectedMethods();
$builder->shouldReceive('buildFields')->andThrow(
- \RuntimeException::class,
+ RuntimeException::class,
'exception thrown'
);
$builder->shouldReceive('build')->passthru();
diff --git a/tests/Nonstandard/FieldsTest.php b/tests/Nonstandard/FieldsTest.php
index 119196a..319896a 100644
--- a/tests/Nonstandard/FieldsTest.php
+++ b/tests/Nonstandard/FieldsTest.php
@@ -31,7 +31,6 @@ class FieldsTest extends TestCase
* @param string|int $expectedValue
*
* @dataProvider fieldGetterMethodProvider
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint
*/
public function testFieldGetterMethods(string $uuid, string $methodName, $expectedValue): void
{
diff --git a/tests/Nonstandard/UuidBuilderTest.php b/tests/Nonstandard/UuidBuilderTest.php
index fb80d55..7bf36a9 100644
--- a/tests/Nonstandard/UuidBuilderTest.php
+++ b/tests/Nonstandard/UuidBuilderTest.php
@@ -9,6 +9,7 @@ use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Exception\UnableToBuildUuidException;
use Ramsey\Uuid\Nonstandard\UuidBuilder;
use Ramsey\Uuid\Test\TestCase;
+use RuntimeException;
class UuidBuilderTest extends TestCase
{
@@ -19,7 +20,7 @@ class UuidBuilderTest extends TestCase
$builder = Mockery::mock(UuidBuilder::class);
$builder->shouldAllowMockingProtectedMethods();
$builder->shouldReceive('buildFields')->andThrow(
- \RuntimeException::class,
+ RuntimeException::class,
'exception thrown'
);
$builder->shouldReceive('build')->passthru();
diff --git a/tests/Nonstandard/UuidV6Test.php b/tests/Nonstandard/UuidV6Test.php
index 899f032..0df8103 100644
--- a/tests/Nonstandard/UuidV6Test.php
+++ b/tests/Nonstandard/UuidV6Test.php
@@ -62,6 +62,8 @@ class UuidV6Test extends TestCase
}
/**
+ * @param non-empty-string $uuid
+ *
* @dataProvider provideUuidV6WithOddMicroseconds
*/
public function testGetDateTimeProperlyHandlesLongMicroseconds(string $uuid, string $expected): void
@@ -101,6 +103,9 @@ class UuidV6Test extends TestCase
}
/**
+ * @param non-empty-string $uuidv6
+ * @param non-empty-string $uuidv1
+ *
* @dataProvider provideUuidV1UuidV6Equivalents
*/
public function testToUuidV1(string $uuidv6, string $uuidv1): void
@@ -119,6 +124,9 @@ class UuidV6Test extends TestCase
}
/**
+ * @param non-empty-string $uuidv6
+ * @param non-empty-string $uuidv1
+ *
* @dataProvider provideUuidV1UuidV6Equivalents
*/
public function testFromUuidV1(string $uuidv6, string $uuidv1): void
diff --git a/tests/Provider/Node/SystemNodeProviderTest.php b/tests/Provider/Node/SystemNodeProviderTest.php
index 8bf85c2..322ce77 100644
--- a/tests/Provider/Node/SystemNodeProviderTest.php
+++ b/tests/Provider/Node/SystemNodeProviderTest.php
@@ -117,7 +117,7 @@ class SystemNodeProviderTest extends TestCase
$provider = new SystemNodeProvider();
try {
- $node = $provider->getNode();
+ $provider->getNode();
} catch (NodeException $exception) {
// do nothing
}
@@ -178,7 +178,7 @@ class SystemNodeProviderTest extends TestCase
$provider = new SystemNodeProvider();
try {
- $node = $provider->getNode();
+ $provider->getNode();
} catch (NodeException $exception) {
// do nothing
}
@@ -237,7 +237,7 @@ class SystemNodeProviderTest extends TestCase
$provider = new SystemNodeProvider();
try {
- $node = $provider->getNode();
+ $provider->getNode();
} catch (NodeException $exception) {
// do nothing
}
@@ -309,7 +309,7 @@ class SystemNodeProviderTest extends TestCase
$provider = new SystemNodeProvider();
try {
- $node = $provider->getNode();
+ $provider->getNode();
} catch (NodeException $exception) {
// do nothing
}
@@ -567,7 +567,7 @@ class SystemNodeProviderTest extends TestCase
$provider = new SystemNodeProvider();
try {
- $node = $provider->getNode();
+ $provider->getNode();
} catch (NodeException $exception) {
// do nothing
}
@@ -708,20 +708,20 @@ class SystemNodeProviderTest extends TestCase
public function provideInvalidNetStatOutput(): array
{
return [
- 'Not an octal value' => [
+ 'Not an octal value' => [
"The program 'netstat' is currently not installed. " .
"You can install it by typing:\nsudo apt install net-tools\n",
],
- 'One character too short' => ["\nA-BB-CC-DD-EE-FF\n"],
- 'One tuple too short' => ["\nBB-CC-DD-EE-FF\n"],
- 'With colon, with linebreak, without space' => ["\n:AA-BB-CC-DD-EE-FF\n"],
- 'With colon, without linebreak, with space' => [' : AA-BB-CC-DD-EE-FF'],
- 'With colon, without linebreak, without space' => [':AA-BB-CC-DD-EE-FF'],
+ 'One character too short' => ["\nA-BB-CC-DD-EE-FF\n"],
+ 'One tuple too short' => ["\nBB-CC-DD-EE-FF\n"],
+ 'With colon, with linebreak, without space' => ["\n:AA-BB-CC-DD-EE-FF\n"],
+ 'With colon, without linebreak, with space' => [' : AA-BB-CC-DD-EE-FF'],
+ 'With colon, without linebreak, without space' => [':AA-BB-CC-DD-EE-FF'],
'Without colon, without linebreak, without space' => ['AA-BB-CC-DD-EE-FF'],
- 'Without leading linebreak' => ["AA-BB-CC-DD-EE-FF\n"],
- 'Without leading whitespace' => ['AA-BB-CC-DD-EE-FF '],
- 'Without trailing linebreak' => ["\nAA-BB-CC-DD-EE-FF"],
- 'Without trailing whitespace' => [' AA-BB-CC-DD-EE-FF'],
+ 'Without leading linebreak' => ["AA-BB-CC-DD-EE-FF\n"],
+ 'Without leading whitespace' => ['AA-BB-CC-DD-EE-FF '],
+ 'Without trailing linebreak' => ["\nAA-BB-CC-DD-EE-FF"],
+ 'Without trailing whitespace' => [' AA-BB-CC-DD-EE-FF'],
];
}
@@ -768,30 +768,30 @@ class SystemNodeProviderTest extends TestCase
/* Full output of related command */
'Full output - Linux' => [<<<'TXT'
Kernel Interface table
- docker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
+ docker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
+ collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
-
- enp3s0 Link encap:Ethernet HWaddr fe:dc:ba:98:76:54
+
+ enp3s0 Link encap:Ethernet HWaddr fe:dc:ba:98:76:54
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: ffee::ddcc:bbaa:9988:7766/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:943077 errors:0 dropped:0 overruns:0 frame:0
TX packets:2168039 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
+ collisions:0 txqueuelen:1000
RX bytes:748596414 (748.5 MB) TX bytes:2930448282 (2.9 GB)
-
- lo Link encap:Local Loopback
+
+ lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8302 errors:0 dropped:0 overruns:0 frame:0
TX packets:8302 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
+ collisions:0 txqueuelen:1000
RX bytes:1094983 (1.0 MB) TX bytes:1094983 (1.0 MB)
TXT
, '0123456789ab',
@@ -799,9 +799,9 @@ TXT
'Full output - MacOS' => [<<<'TXT'
lo0: flags=8049 mtu 16384
options=1203
- inet 127.0.0.1 netmask 0xff000000
- inet6 ::1 prefixlen 128
- inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
+ inet 127.0.0.1 netmask 0xff000000
+ inet6 ::1 prefixlen 128
+ inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201
gif0: flags=8010 mtu 1280
stf0: flags=0<> mtu 1280
@@ -810,42 +810,42 @@ TXT
EHC26: flags=0<> mtu 0
en0: flags=8863 mtu 1500
options=10b
- ether 10:dd:b1:b4:e4:8e
- inet6 fe80::c70:76f5:aa1:5db1%en0 prefixlen 64 secured scopeid 0x7
+ ether 10:dd:b1:b4:e4:8e
+ inet6 fe80::c70:76f5:aa1:5db1%en0 prefixlen 64 secured scopeid 0x7
inet 10.53.8.112 netmask 0xfffffc00 broadcast 10.53.11.255
nd6 options=201
media: autoselect (1000baseT )
status: active
en1: flags=8863 mtu 1500
- ether ec:35:86:38:c8:c2
- inet6 fe80::aa:d44f:5f5f:7fd4%en1 prefixlen 64 secured scopeid 0x8
+ ether ec:35:86:38:c8:c2
+ inet6 fe80::aa:d44f:5f5f:7fd4%en1 prefixlen 64 secured scopeid 0x8
inet 10.53.17.196 netmask 0xfffffc00 broadcast 10.53.19.255
nd6 options=201
media: autoselect
status: active
p2p0: flags=8843 mtu 2304
- ether 0e:35:86:38:c8:c2
+ ether 0e:35:86:38:c8:c2
media: autoselect
status: inactive
awdl0: flags=8943 mtu 1484
- ether ea:ab:ae:25:f5:d0
- inet6 fe80::e8ab:aeff:fe25:f5d0%awdl0 prefixlen 64 scopeid 0xa
+ ether ea:ab:ae:25:f5:d0
+ inet6 fe80::e8ab:aeff:fe25:f5d0%awdl0 prefixlen 64 scopeid 0xa
nd6 options=201
media: autoselect
status: active
en2: flags=8963 mtu 1500
options=60
- ether 32:00:18:9b:dc:60
+ ether 32:00:18:9b:dc:60
media: autoselect
status: inactive
en3: flags=8963 mtu 1500
options=60
- ether 32:00:18:9b:dc:61
+ ether 32:00:18:9b:dc:61
media: autoselect
status: inactive
bridge0: flags=8822 mtu 1500
options=63
- ether 32:00:18:9b:dc:60
+ ether 32:00:18:9b:dc:60
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
@@ -859,30 +859,30 @@ TXT
status: inactive
utun0: flags=8051 mtu 2000
options=6403
- inet6 fe80::57c6:d692:9d41:d28f%utun0 prefixlen 64 scopeid 0xe
+ inet6 fe80::57c6:d692:9d41:d28f%utun0 prefixlen 64 scopeid 0xe
nd6 options=201
TXT
, '10ddb1b4e48e',
],
'Full output - Window' => [<<<'TXT'
Windows IP Configuration
-
+
Host Name . . . . . . . . . . . . : MSEDGEWIN10
- Primary Dns Suffix . . . . . . . :
+ Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : network.lan
-
+
Ethernet adapter Ethernet:
-
+
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
Physical Address. . . . . . . . . : 08-00-27-B8-42-C6
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
- Link-local IPv6 Address . . . . . : fe80::606a:ae33:7ce1:b5e9%3(Preferred)
- IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
+ Link-local IPv6 Address . . . . . : fe80::606a:ae33:7ce1:b5e9%3(Preferred)
+ IPv4 Address. . . . . . . . . . . : 10.0.2.15(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, January 30, 2018 11:25:31 PM
Lease Expires . . . . . . . . . . : Wednesday, January 31, 2018 11:25:27 PM
@@ -892,9 +892,9 @@ TXT
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-40-72-3F-08-00-27-B8-42-C6
DNS Servers . . . . . . . . . . . : 10.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled
-
+
Tunnel adapter isatap.network.lan:
-
+
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : network.lan
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
@@ -914,25 +914,25 @@ TXT
],
/* The single line that is relevant */
- 'Linux - single line' => ["\ndocker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab\n", '0123456789ab'],
+ 'Linux - single line' => ["\ndocker0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab\n", '0123456789ab'],
'MacOS - Single line ' => ["\nether 10:dd:b1:b4:e4:8e\n", '10ddb1b4e48e'],
'Window - single line' => ["\nPhysical Address. . . . . . . . . : 08-00-27-B8-42-C6\n", '080027b842c6'],
/* Minimal subsets of the single line to show the differences */
- 'with colon, with linebreak, with space' => ["\n : AA-BB-CC-DD-EE-FF\n", 'aabbccddeeff'],
- 'without colon, with linebreak, with space' => ["\n AA-BB-CC-DD-EE-FF \n", 'aabbccddeeff'],
- 'without colon, with linebreak, without space' => ["\nAA-BB-CC-DD-EE-FF\n", 'aabbccddeeff'],
- 'without colon, without linebreak, with space' => [' AA-BB-CC-DD-EE-FF ', 'aabbccddeeff'],
+ 'with colon, with linebreak, with space' => ["\n : AA-BB-CC-DD-EE-FF\n", 'aabbccddeeff'],
+ 'without colon, with linebreak, with space' => ["\n AA-BB-CC-DD-EE-FF \n", 'aabbccddeeff'],
+ 'without colon, with linebreak, without space' => ["\nAA-BB-CC-DD-EE-FF\n", 'aabbccddeeff'],
+ 'without colon, without linebreak, with space' => [' AA-BB-CC-DD-EE-FF ', 'aabbccddeeff'],
/* Other accepted variations */
- 'Actual mac - 1' => ["\n52:54:00:14:91:69\n", '525400149169'],
- 'Actual mac - 2' => ["\n00:16:3e:a9:73:f0\n", '00163ea973f0'],
- 'FF:FF:FF:FF:FF:FF' => ["\nFF:FF:FF:FF:FF:FF\n", 'ffffffffffff'],
+ 'Actual mac - 1' => ["\n52:54:00:14:91:69\n", '525400149169'],
+ 'Actual mac - 2' => ["\n00:16:3e:a9:73:f0\n", '00163ea973f0'],
+ 'FF:FF:FF:FF:FF:FF' => ["\nFF:FF:FF:FF:FF:FF\n", 'ffffffffffff'],
/* Incorrect variations that are also accepted */
- 'Local host' => ["\n00:00:00:00:00:00\n", '000000000000'],
- 'Too long -- extra character' => ["\nABC-01-23-45-67-89\n", 'bc0123456789'],
- 'Too long -- extra tuple' => ["\n01-AA-BB-CC-DD-EE-FF\n", '01aabbccddee'],
+ 'Local host' => ["\n00:00:00:00:00:00\n", '000000000000'],
+ 'Too long -- extra character' => ["\nABC-01-23-45-67-89\n", 'bc0123456789'],
+ 'Too long -- extra tuple' => ["\n01-AA-BB-CC-DD-EE-FF\n", '01aabbccddee'],
];
}
}
diff --git a/tests/Rfc4122/FieldsTest.php b/tests/Rfc4122/FieldsTest.php
index 39b36eb..eb84dee 100644
--- a/tests/Rfc4122/FieldsTest.php
+++ b/tests/Rfc4122/FieldsTest.php
@@ -94,7 +94,6 @@ class FieldsTest extends TestCase
* @param string|int $expectedValue
*
* @dataProvider fieldGetterMethodProvider
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint
*/
public function testFieldGetterMethods(string $uuid, string $methodName, $expectedValue): void
{
diff --git a/tests/Rfc4122/UuidV1Test.php b/tests/Rfc4122/UuidV1Test.php
index 6889067..41f5bb0 100644
--- a/tests/Rfc4122/UuidV1Test.php
+++ b/tests/Rfc4122/UuidV1Test.php
@@ -61,6 +61,8 @@ class UuidV1Test extends TestCase
}
/**
+ * @param non-empty-string $uuid
+ *
* @dataProvider provideUuidV1WithOddMicroseconds
*/
public function testGetDateTimeProperlyHandlesLongMicroseconds(string $uuid, string $expected): void
diff --git a/tests/UuidTest.php b/tests/UuidTest.php
index fccde37..6b2427d 100644
--- a/tests/UuidTest.php
+++ b/tests/UuidTest.php
@@ -404,7 +404,7 @@ class UuidTest extends TestCase
$this->expectException(UnsupportedOperationException::class);
$this->expectExceptionMessage('Not a time-based UUID');
- $ts = $uuid->getTimestamp();
+ $uuid->getTimestamp();
}
public function testGetTimestampHexFromNonVersion1Uuid(): void
@@ -415,7 +415,7 @@ class UuidTest extends TestCase
$this->expectException(UnsupportedOperationException::class);
$this->expectExceptionMessage('Not a time-based UUID');
- $ts = $uuid->getTimestampHex();
+ $uuid->getTimestampHex();
}
public function testGetUrn(): void
@@ -425,6 +425,8 @@ class UuidTest extends TestCase
}
/**
+ * @param non-empty-string $uuid
+ *
* @dataProvider provideVariousVariantUuids
*/
public function testGetVariantForVariousVariantUuids(string $uuid, int $variant): void
@@ -574,7 +576,7 @@ class UuidTest extends TestCase
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid node value');
- $uuid = Uuid::uuid1('9223372036854775808');
+ Uuid::uuid1('9223372036854775808');
}
public function testUuid1WithNonHexadecimalNode(): void
@@ -582,7 +584,7 @@ class UuidTest extends TestCase
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid node value');
- $uuid = Uuid::uuid1('db77e160355g');
+ Uuid::uuid1('db77e160355g');
}
public function testUuid1WithNon48bitNumber(): void
@@ -590,7 +592,7 @@ class UuidTest extends TestCase
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid node value');
- $uuid = Uuid::uuid1('db77e160355ef');
+ Uuid::uuid1('db77e160355ef');
}
public function testUuid1WithRandomNode(): void
@@ -690,6 +692,9 @@ class UuidTest extends TestCase
* Taken from the Python UUID tests in
* http://hg.python.org/cpython/file/2f4c4db9aee5/Lib/test/test_uuid.py
*
+ * @param non-empty-string $uuid
+ * @param non-empty-string $ns
+ *
* @dataProvider provideUuid3WithKnownUuids
*/
public function testUuid3WithKnownUuids(string $uuid, string $ns, string $name): void
@@ -823,6 +828,9 @@ class UuidTest extends TestCase
* Taken from the Python UUID tests in
* http://hg.python.org/cpython/file/2f4c4db9aee5/Lib/test/test_uuid.py
*
+ * @param non-empty-string $uuid
+ * @param non-empty-string $ns
+ *
* @dataProvider provideUuid5WithKnownUuids
*/
public function testUuid5WithKnownUuids(string $uuid, string $ns, string $name): void
@@ -1152,7 +1160,11 @@ class UuidTest extends TestCase
* This test ensures that Ramsey\Uuid passes the same test cases
* as the Python UUID library.
*
+ * @param non-empty-string $string
+ * @param non-empty-string $curly
+ * @param non-empty-string $hex
* @param string[] $fields
+ * @param non-empty-string $urn
*
* @dataProvider providePythonTests
*/
@@ -1527,7 +1539,7 @@ class UuidTest extends TestCase
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid UUID string:');
- $uuid = Uuid::uuid3('', '');
+ Uuid::uuid3('', '');
}
public function testUuid3WithEmptyName(): void
@@ -1549,7 +1561,7 @@ class UuidTest extends TestCase
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid UUID string:');
- $uuid = Uuid::uuid5('', '');
+ Uuid::uuid5('', '');
}
public function testUuid5WithEmptyName(): void
diff --git a/tests/benchmark/UuidFieldExtractionBench.php b/tests/benchmark/UuidFieldExtractionBench.php
index 10bdb8a..a2e8336 100644
--- a/tests/benchmark/UuidFieldExtractionBench.php
+++ b/tests/benchmark/UuidFieldExtractionBench.php
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey
- * @license http://opensource.org/licenses/MIT MIT
+ * @license http://opensource.org/licenses/MIT MIT
*/
declare(strict_types=1);
diff --git a/tests/benchmark/UuidGenerationBench.php b/tests/benchmark/UuidGenerationBench.php
index 6c6b5ca..c547a9f 100644
--- a/tests/benchmark/UuidGenerationBench.php
+++ b/tests/benchmark/UuidGenerationBench.php
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey
- * @license http://opensource.org/licenses/MIT MIT
+ * @license http://opensource.org/licenses/MIT MIT
*/
declare(strict_types=1);
@@ -18,6 +18,7 @@ use Ramsey\Uuid\Provider\Node\StaticNodeProvider;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Type\Integer as IntegerIdentifier;
use Ramsey\Uuid\Uuid;
+use Ramsey\Uuid\UuidInterface;
final class UuidGenerationBench
{
@@ -27,7 +28,7 @@ final class UuidGenerationBench
private $clockSequence;
/** @var IntegerIdentifier */
private $localIdentifier;
- /** @var \Ramsey\Uuid\UuidInterface */
+ /** @var UuidInterface */
private $namespace;
public function __construct()
diff --git a/tests/benchmark/UuidSerializationBench.php b/tests/benchmark/UuidSerializationBench.php
index 719f32a..ea02bbd 100644
--- a/tests/benchmark/UuidSerializationBench.php
+++ b/tests/benchmark/UuidSerializationBench.php
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey
- * @license http://opensource.org/licenses/MIT MIT
+ * @license http://opensource.org/licenses/MIT MIT
*/
declare(strict_types=1);
@@ -22,8 +22,8 @@ use function serialize;
final class UuidSerializationBench
{
- private const TINY_UUID = '00000000-0000-0000-0000-000000000001';
- private const HUGE_UUID = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
+ private const TINY_UUID = '00000000-0000-0000-0000-000000000001';
+ private const HUGE_UUID = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
private const UUIDS_TO_BE_SHORTENED = [
'0ae0cac5-2a40-465c-99ed-3d331b7cf72a',
'5759b9ce-07b5-4e89-b33a-f864317a2951',
@@ -151,13 +151,13 @@ final class UuidSerializationBench
public function __construct()
{
- $this->tinyUuid = Uuid::fromString(self::TINY_UUID);
- $this->hugeUuid = Uuid::fromString(self::HUGE_UUID);
- $this->uuid = Uuid::fromString(self::UUIDS_TO_BE_SHORTENED[0]);
- $this->promiscuousUuids = array_map([Uuid::class, 'fromString'], self::UUIDS_TO_BE_SHORTENED);
- $this->serializedTinyUuid = serialize(Uuid::fromString(self::TINY_UUID));
- $this->serializedHugeUuid = serialize(Uuid::fromString(self::HUGE_UUID));
- $this->serializedUuid = serialize(Uuid::fromString(self::UUIDS_TO_BE_SHORTENED[0]));
+ $this->tinyUuid = Uuid::fromString(self::TINY_UUID);
+ $this->hugeUuid = Uuid::fromString(self::HUGE_UUID);
+ $this->uuid = Uuid::fromString(self::UUIDS_TO_BE_SHORTENED[0]);
+ $this->promiscuousUuids = array_map([Uuid::class, 'fromString'], self::UUIDS_TO_BE_SHORTENED);
+ $this->serializedTinyUuid = serialize(Uuid::fromString(self::TINY_UUID));
+ $this->serializedHugeUuid = serialize(Uuid::fromString(self::HUGE_UUID));
+ $this->serializedUuid = serialize(Uuid::fromString(self::UUIDS_TO_BE_SHORTENED[0]));
$this->serializedPromiscuousUuids = array_map(
'serialize',
array_map([Uuid::class, 'fromString'], self::UUIDS_TO_BE_SHORTENED)
diff --git a/tests/benchmark/UuidStringConversionBench.php b/tests/benchmark/UuidStringConversionBench.php
index a15b804..303b5ae 100644
--- a/tests/benchmark/UuidStringConversionBench.php
+++ b/tests/benchmark/UuidStringConversionBench.php
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey
- * @license http://opensource.org/licenses/MIT MIT
+ * @license http://opensource.org/licenses/MIT MIT
*/
declare(strict_types=1);
@@ -21,8 +21,8 @@ use function array_map;
final class UuidStringConversionBench
{
- private const TINY_UUID = '00000000-0000-0000-0000-000000000001';
- private const HUGE_UUID = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
+ private const TINY_UUID = '00000000-0000-0000-0000-000000000001';
+ private const HUGE_UUID = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
private const UUIDS_TO_BE_SHORTENED = [
'0ae0cac5-2a40-465c-99ed-3d331b7cf72a',
'5759b9ce-07b5-4e89-b33a-f864317a2951',
@@ -159,13 +159,13 @@ final class UuidStringConversionBench
public function __construct()
{
- $this->tinyUuid = Uuid::fromString(self::TINY_UUID);
- $this->hugeUuid = Uuid::fromString(self::HUGE_UUID);
- $this->uuid = Uuid::fromString(self::UUIDS_TO_BE_SHORTENED[0]);
+ $this->tinyUuid = Uuid::fromString(self::TINY_UUID);
+ $this->hugeUuid = Uuid::fromString(self::HUGE_UUID);
+ $this->uuid = Uuid::fromString(self::UUIDS_TO_BE_SHORTENED[0]);
$this->promiscuousUuids = array_map([Uuid::class, 'fromString'], self::UUIDS_TO_BE_SHORTENED);
- $this->tinyUuidBytes = $this->tinyUuid->getBytes();
- $this->hugeUuidBytes = $this->hugeUuid->getBytes();
- $this->uuidBytes = $this->uuid->getBytes();
+ $this->tinyUuidBytes = $this->tinyUuid->getBytes();
+ $this->hugeUuidBytes = $this->hugeUuid->getBytes();
+ $this->uuidBytes = $this->uuid->getBytes();
$this->promiscuousUuidsBytes = array_map(static function (UuidInterface $uuid): string {
return $uuid->getBytes();
}, $this->promiscuousUuids);
diff --git a/tests/psalm.xml b/tests/psalm.xml
deleted file mode 100644
index eb4be33..0000000
--- a/tests/psalm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-