chore: update package files

This commit is contained in:
Ben Ramsey
2021-08-06 14:05:57 -05:00
parent 90a87a7543
commit c005f69d6e
67 changed files with 890 additions and 615 deletions
+16
View File
@@ -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
+24 -12
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
* @ramsey
-101
View File
@@ -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: <https://github.com/ramsey/uuid/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/
+35
View File
@@ -0,0 +1,35 @@
---
name: Bug Report
about: Create a bug report to help us improve
labels: bug
assignees:
---
<!--- Provide a general summary of the issue you're having in the title above. -->
## 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.
-->
1. Step one...
2. Step two...
3. Step three...
## 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. -->
- 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
<!-- Provide any additional context that may help us debug the problem. -->
+31
View File
@@ -0,0 +1,31 @@
---
name: Feature Request
about: Suggest a feature for this project
labels: enhancement
assignees:
---
<!--- Provide a general summary of your feature request in the title above. -->
<!-- Give your feature a short title here. -->
## My feature title
<!-- Provide a short and clear description of the feature. -->
## Background/problem
<!--
Provide background details to show why this feature is necessary. Is your
feature request related to a problem? If so, please describe the problem.
Provide as much detail as possible.
-->
## Proposal/solution
<!--
Provide a short and clear description of the solution you'd like. Include code
examples, if possible. Feel free to use pseudo-code to show how you think the
feature should work.
-->
## Alternatives
<!-- Describe any alternative solutions or features you've considered. -->
## Additional context
<!-- Please provide any other context or code examples that may help. -->
+19
View File
@@ -0,0 +1,19 @@
---
name: Question
about: Ask a question about how to use this library
labels: question
assignees:
---
<!--- Provide a general summary of your question in the title above. -->
<!-- Write your question here. -->
## How do I... ?
<!-- Provide any additional context that may help us answer your question. -->
## Example code
<!--
If your question is about code that you've written, provide a short and clear
example of what you're trying to accomplish. Try to keep this as short as
possible. If able, please provide an example outside of any framework you are
using. This will help us to quickly respond to your question.
-->
-55
View File
@@ -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
<?php
require_once 'vendor/autoload.php';
$foo = new Foo\Bar();
// Code that, when run, shows the behavior...
```
2. Execute the script from a terminal:
``` bash
$ php foo.php
```
3. See output similar to the following:
```
Error message or wrong output...
```
## Expected behavior
A clear and concise description of what you expected to happen.
## Screenshots or output
If applicable, add screenshots or program output to help explain your problem.
## Environment details
- OS: [e.g. Windows 10, Linux (Ubuntu 18.04.1), macOS Mojave (10.14.2)]
- PHP version: [e.g. 7.1.25, 7.2.13]
- ramsey/uuid version: [e.g. 1.0.0, 1.0.1, 1.1.0]
## Additional context
Add any other context about the problem here.
+1
View File
@@ -0,0 +1 @@
blank_issues_enabled: false
-22
View File
@@ -1,22 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
labels: enhancement
assignees:
---
## Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
## Describe the solution you'd like
A clear and concise description of what you want to happen. Include code examples, if applicable.
## Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
## Additional context
Add any other context or code examples about the feature request here.
+7
View File
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "monthly"
versioning-strategy: "increase-if-necessary"
@@ -18,13 +18,10 @@
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Checklist:
## PR checklist
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] 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.
+90 -39
View File
@@ -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"
+1 -1
View File
@@ -1,4 +1,4 @@
/build/
/captainhook.config.json
/composer.lock
/phpcs.xml
/phpunit.xml
+171
View File
@@ -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: <https://github.com/ramsey/uuid/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/
+1 -3
View File
@@ -1,6 +1,4 @@
MIT License
Copyright (c) 2012-2020 Ben Ramsey <ben@benramsey.com>
Copyright (c) 2012-2021 Ben Ramsey <ben@benramsey.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+6 -15
View File
@@ -8,25 +8,22 @@
<a href="https://github.com/ramsey/uuid"><img src="http://img.shields.io/badge/source-ramsey/uuid-blue.svg?style=flat-square" alt="Source Code"></a>
<a href="https://packagist.org/packages/ramsey/uuid"><img src="https://img.shields.io/packagist/v/ramsey/uuid.svg?style=flat-square&label=release" alt="Download Package"></a>
<a href="https://php.net"><img src="https://img.shields.io/packagist/php-v/ramsey/uuid.svg?style=flat-square&colorB=%238892BF" alt="PHP Programming Language"></a>
<a href="https://github.com/ramsey/uuid/blob/master/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
<a href="https://github.com/ramsey/uuid/actions?query=workflow%3ACI"><img src="https://img.shields.io/github/workflow/status/ramsey/uuid/CI?label=CI&logo=github&style=flat-square" alt="Build Status"></a>
<a href="https://codecov.io/gh/ramsey/uuid"><img src="https://img.shields.io/codecov/c/gh/ramsey/uuid?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a>
<a href="https://shepherd.dev/github/ramsey/uuid"><img src="https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Framsey%2Fuuid%2Fcoverage" alt="Psalm Type Coverage"></a>
<a href="https://github.com/ramsey/uuid/blob/master/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
<a href="https://packagist.org/packages/ramsey/uuid/stats"><img src="https://img.shields.io/packagist/dt/ramsey/uuid.svg?style=flat-square&colorB=darkmagenta" alt="Package downloads on Packagist"></a>
<a href="https://phpc.chat/channel/ramsey"><img src="https://img.shields.io/badge/phpc.chat-%23ramsey-darkslateblue?style=flat-square" alt="Chat with the maintainers"></a>
</p>
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 <https://uuid.ramsey.dev> 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
+64 -9
View File
@@ -1,29 +1,59 @@
<!--
This policy was created using the HackerOne Policy Builder:
https://hackerone.com/policy-builder/
This policy template was created using the HackerOne Policy Builder [1],
with guidance from the National Telecommunications and Information
Administration Coordinated Vulnerability Disclosure Template [2].
-->
# Vulnerability Disclosure Policy
# Vulnerability Disclosure Policy (VDP)
## Brand Promise
<!--
This is your brand promise. Its objective is to "demonstrate a clear, good
faith commitment to customers and other stakeholders potentially impacted by
security vulnerabilities" [2].
-->
Keeping user information safe and secure is a top priority, and we welcome the
contribution of external security researchers.
## Scope
<!--
This is your initial scope. It tells vulnerability finders and reporters
"which systems and capabilities are 'fair game' versus 'off limits'" [2].
For software packages, this is often a list of currently maintained versions
of the package.
-->
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 <security@ramsey.dev>.
<!--
This is your communication process. It tells security researchers how to
contact you to report a vulnerability. It may be a link to a web form that
uses HTTPS for secure communication, or it may be an email address.
Optionally, you may choose to include a PGP public key, so that researchers
may send you encrypted messages.
-->
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
<!--
This section assures vulnerability finders and reporters that they will
receive good faith responses to their good faith acts. In other words,
"we will not take legal action if..." [2].
-->
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
<!--
The preferences section sets expectations based on priority and submission
volume, rather than legal objection or restriction [2].
According to the NTIA [2]:
This section is a living document that sets expectations for preferences
and priorities, typically maintained by the support and engineering
team. This can outline classes of vulnerabilities, reporting style
(crash dumps, CVSS scoring, proof-of-concept, etc.), tools, etc. Too
many preferences can set the wrong tone or make reporting findings
difficult to navigate. This section also sets expectations to the
researcher community for what types of issues are considered important
or not.
-->
* 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.
<!--
References
[1] HackerOne. Policy builder. Retrieved from https://hackerone.com/policy-builder/
[2] NTIA Safety Working Group. 2016. "Early stage" coordinated vulnerability
disclosure template: Version 1.1. (15 December 2016). Retrieved from
https://www.ntia.doc.gov/files/ntia/publications/ntia_vuln_disclosure_early_stage_template.pdf
-->
## 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-----
+6
View File
@@ -0,0 +1,6 @@
*
!.gitignore
!cache
!cache/.gitkeep
!logs
!logs/.gitkeep
View File
View File
+123
View File
@@ -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": []
}
}
+22 -18
View File
@@ -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"
}
}
+76 -39
View File
@@ -1,22 +1,14 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/3.5.0/phpcs.xsd"
name="ramsey/uuid">
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd" name="Ramsey">
<description>ramsey/uuid coding standard</description>
<arg name="extensions" value="php"/>
<arg name="colors"/>
<arg value="sp"/>
<!--
Much of this coding standard is borrowed from chiron/coding-standard:
https://github.com/ncou/coding-standard
-->
<!-- Source and tests must follow the coding standard. -->
<file>./src</file>
<file>./tests</file>
<!-- Arguments for the command line runner. -->
<arg name="colors"/>
<arg value="sp"/>
<description>A common coding standard for Ramsey's PHP libraries.</description>
<!-- Rules -->
<rule ref="PSR12">
@@ -72,6 +64,13 @@
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Allow comments to run longer than 120 characters -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="ignoreComments" value="true"/>
</properties>
</rule>
<!-- Forbid a bunch of functions -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
@@ -103,6 +102,9 @@
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Rules for single-line arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require presence of constant visibility -->
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
@@ -143,15 +145,8 @@
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@internal,@deprecated,"/>
<element value="@link,@see,@uses,"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
@@ -179,7 +174,11 @@
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
<properties>
<property name="allowDocCommentAboveReturn" value="true"/>
</properties>
</rule>
<!-- Report use of the useless @inheritDoc annotation -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
@@ -187,11 +186,11 @@
<!-- Require consistent spacing for control structures (add a line break) -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_BREAK" />
<element value="T_CONTINUE" />
<property name="jumpStatements" type="array">
<element value="break"/>
<element value="continue"/>
<element value="return"/>
<element value="throw"/>
</property>
</properties>
</rule>
@@ -237,19 +236,19 @@
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Forbid using absolute class name references -->
<!-- Forbid using absolute class name references (except global ones) -->
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowFallbackGlobalFunctions" value="true"/>
<property name="allowFullyQualifiedGlobalClasses" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" value="false"/>
<property name="allowFullyQualifiedGlobalFunctions" value="false"/>
<property name="allowFullyQualifiedExceptions" value="true"/>
<property name="allowPartialUses" value="false"/>
<property name="fullyQualifiedKeywords" type="array">
<element value="T_EXTENDS"/>
<element value="T_IMPLEMENTS"/>
<element value="T_USE"/>
</property>
<property name="allowFullyQualifiedNameForCollidingClasses" value="true"/>
<property name="allowFullyQualifiedNameForCollidingConstants" value="true"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true"/>
<property name="allowPartialUses" value="true"/>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
@@ -278,6 +277,9 @@
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Require NOWDOC if string interpolation not used -->
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc"/>
<!-- Forbid 'list(...)' syntax -->
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
@@ -305,7 +307,19 @@
</rule>
<!-- Require presence of declare(strict_types=1) -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing"/>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<!-- Ignore whitespace requirements for lines occurring before declare(strict_types=1).
In general, we have two lines before this statement, one before the
file header comment and one after. The sniff does not count any
newlines from the comment block. However, in tests, we don't use
file header comments, so we have only one line before this
statement. This causes problems, so we just ignore this error. -->
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBeforeDeclare"/>
<properties>
<property name="linesCountAfterDeclare" value="1"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>
</rule>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
@@ -326,6 +340,9 @@
<properties>
<property name="enableObjectTypeHint" value="true"/>
</properties>
<!-- We don't want to check for this just yet. -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
@@ -347,9 +364,19 @@
<!-- Require the return type hint to have one space (i.e. function foo(): ?int) -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<!-- For arrow functions, require 1 space after the keyword and before/after the arrow -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Disallow use of super-global variables -->
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<!-- Clean up unnecessary variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
@@ -394,7 +421,7 @@
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacing" value="1"/>
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
@@ -406,6 +433,13 @@
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
<properties>
<property name="withSpaces" value="yes"/>
<property name="nullPosition" value="last"/>
</properties>
</rule>
<!-- Forbid spaces around '->' operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
@@ -433,7 +467,10 @@
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
</rule>
<!-- Checks duplicate spaces anywhere because there aren't sniffs for every part of code to check formatting. -->
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>
</ruleset>
@@ -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\.$#'
+8 -8
View File
@@ -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
+9 -6
View File
@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
cacheResultFile="./build/cache/phpunit.result.cache"
colors="true"
verbose="true">
<testsuites>
<testsuite name="ramsey/uuid test suite">
<testsuite name="unit-tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<psalm xmlns="https://getpsalm.org/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
totallyTyped="true"
cacheDirectory="./build/cache/psalm"
errorBaseline="./psalm-baseline.xml">
<projectFiles>
<directory name="./src" />
<directory name="./tests/static-analysis" />
</projectFiles>
<stubs>
<file name="./tests/phpstan-bootstrap.php"/>
</stubs>
</psalm>
-28
View File
@@ -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
-22
View File
@@ -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
-17
View File
@@ -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
-31
View File
@@ -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 "$@"
-13
View File
@@ -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
-19
View File
@@ -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
@@ -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
+3 -1
View File
@@ -26,6 +26,8 @@ use Traversable;
/**
* A collection of UuidBuilderInterface objects
*
* @extends AbstractCollection<UuidBuilderInterface>
*/
class BuilderCollection extends AbstractCollection
{
@@ -54,7 +56,7 @@ class BuilderCollection extends AbstractCollection
*/
public function unserialize($serialized): void
{
/** @var mixed[] $data */
/** @var array<array-key, UuidBuilderInterface> $data */
$data = unserialize($serialized, [
'allowed_classes' => [
BrickMathCalculator::class,
+1
View File
@@ -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]
+1
View File
@@ -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();
}
+1
View File
@@ -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());
}
@@ -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);
}
}
+2 -1
View File
@@ -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
}
+2 -1
View File
@@ -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(),
+3 -2
View File
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @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');
+3 -1
View File
@@ -20,6 +20,8 @@ use Ramsey\Uuid\Type\Hexadecimal;
/**
* A collection of NodeProviderInterface objects
*
* @extends AbstractCollection<NodeProviderInterface>
*/
class NodeProviderCollection extends AbstractCollection
{
@@ -38,7 +40,7 @@ class NodeProviderCollection extends AbstractCollection
*/
public function unserialize($serialized): void
{
/** @var mixed[] $data */
/** @var array<array-key, NodeProviderInterface> $data */
$data = unserialize($serialized, [
'allowed_classes' => [
Hexadecimal::class,
+2 -1
View File
@@ -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(),
+4 -4
View File
@@ -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
+6 -6
View File
@@ -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
{
-2
View File
@@ -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);
+3 -2
View File
@@ -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);
}
@@ -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
@@ -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
-1
View File
@@ -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
+2 -1
View File
@@ -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();
-1
View File
@@ -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
{
+2 -1
View File
@@ -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();
+8
View File
@@ -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
+56 -56
View File
@@ -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<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
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<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
@@ -810,42 +810,42 @@ TXT
EHC26: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
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<PERFORMNUD,DAD>
media: autoselect (1000baseT <full-duplex>)
status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> 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<PERFORMNUD,DAD>
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 0e:35:86:38:c8:c2
ether 0e:35:86:38:c8:c2
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> 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<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:60
ether 32:00:18:9b:dc:60
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:18:9b:dc:61
ether 32:00:18:9b:dc:61
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
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<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
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<PERFORMNUD,DAD>
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'],
];
}
}
-1
View File
@@ -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
{
+2
View File
@@ -61,6 +61,8 @@ class UuidV1Test extends TestCase
}
/**
* @param non-empty-string $uuid
*
* @dataProvider provideUuidV1WithOddMicroseconds
*/
public function testGetDateTimeProperlyHandlesLongMicroseconds(string $uuid, string $expected): void
+19 -7
View File
@@ -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
+1 -1
View File
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @license http://opensource.org/licenses/MIT MIT
* @license http://opensource.org/licenses/MIT MIT
*/
declare(strict_types=1);
+3 -2
View File
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @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()
+10 -10
View File
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @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)
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @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);
-17
View File
@@ -1,17 +0,0 @@
<?xml version="1.0"?>
<psalm xmlns="https://getpsalm.org/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config ../vendor/vimeo/psalm/config.xsd"
totallyTyped="true"
cacheDirectory="build/cache/psalm"
errorBaseline="tests/psalm-baseline.xml">
<projectFiles>
<directory name="src" />
<directory name="tests/static-analysis" />
</projectFiles>
<stubs>
<file name="tests/phpstan-bootstrap.php"/>
</stubs>
</psalm>