Skip to content

Commit

Permalink
Dust off
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 21, 2023
1 parent 587a710 commit 2591c89
Show file tree
Hide file tree
Showing 22 changed files with 252 additions and 97,320 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: sebastianbergmann
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
- "pull_request"
- "push"

name: "CI"

env:
COMPOSER_ROOT_VERSION: "1.0-dev"

permissions:
contents: read

jobs:
coding-guidelines:
name: Coding Guidelines

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- name: Run PHP-CS-Fixer
run: ./tools/php-cs-fixer fix --dry-run --show-progress=dots --using-cache=no --verbose

type-checker:
name: Type Checker

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- name: Install dependencies with Composer
run: ./tools/composer update --no-interaction --no-ansi --no-progress

- name: Run Psalm
run: ./tools/psalm --config=.psalm/config.xml --no-progress --shepherd --show-info=false --stats

tests:
name: Tests

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"

- name: "Install dependencies with Composer"
run: "./tools/composer update --no-ansi --no-interaction --no-progress"

- name: "Run tests with PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Send code coverage report to Codecov.io"
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
run: "bash <(curl -s https://codecov.io/bash) || true"
7 changes: 3 additions & 4 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^9.5.9" installed="9.5.13" location="./tools/phpunit" copy="true"/>
<phar name="php-cs-fixer" version="^3.1.0" installed="3.6.0" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^4.10.0" installed="4.20.0" location="./tools/psalm" copy="true"/>
<phar name="composer" version="^2.1.8" installed="2.2.6" location="./tools/composer" copy="true"/>
<phar name="php-cs-fixer" version="^3.15" installed="3.15.1" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^5.8" installed="5.8.0" location="./tools/psalm" copy="true"/>
<phar name="composer" version="^2.5" installed="2.5.4" location="./tools/composer" copy="true"/>
</phive>
23 changes: 17 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'blank_line_before_statement' => [
'statements' => [
'break',
'case',
'continue',
'declare',
'default',
Expand All @@ -43,6 +44,7 @@
'if',
'include',
'include_once',
'phpdoc',
'require',
'require_once',
'return',
Expand All @@ -51,6 +53,7 @@
'try',
'while',
'yield',
'yield_from',
],
],
'braces' => [
Expand All @@ -59,9 +62,9 @@
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'const' => 'none',
'method' => 'one',
'property' => 'one'
'property' => 'only_if_meta'
]
],
'class_definition' => true,
Expand All @@ -87,6 +90,7 @@
'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'get_class_to_class_keyword' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
Expand Down Expand Up @@ -118,9 +122,16 @@
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => false,
'native_function_casing' => false,
'native_function_invocation' => false,
'native_function_invocation' => [
'include' => [
'@internal',
],
],
'native_function_type_declaration_casing' => true,
'new_with_braces' => false,
'new_with_braces' => [
'named_class' => false,
'anonymous_class' => false,
],
'no_alias_functions' => true,
'no_alias_language_construct_call' => true,
'no_alternative_syntax' => true,
Expand Down Expand Up @@ -150,14 +161,14 @@
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unneeded_import_alias' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => true,
Expand Down
3 changes: 1 addition & 2 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
</files>
<files psalm-version="5.8.0@9cf4f60a333f779ad3bc704a555920e81d4fdcda"/>
12 changes: 4 additions & 8 deletions .psalm/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
resolveFromConfigFile="false"
cacheDirectory=".psalm/cache"
errorBaseline=".psalm/baseline.xml"
errorLevel="1"
phpVersion="8.0"
strictBinaryOperands="true"
checkForThrowsDocblock="true"
findUnusedVariablesAndParams="true"
findUnusedPsalmSuppress="true"
ensureArrayStringOffsetsExist="true"
ensureArrayIntOffsetsExist="true"
findUnusedVariablesAndParams="false"
findUnusedCode="false"
errorBaseline=".psalm/baseline.xml"
findUnusedBaselineEntry="true"
>
<projectFiles>
<directory name="src" />
Expand Down
9 changes: 9 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ChangeLog

All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [1.0.0] - YYYY-MM-DD

* Initial release

[1.0.0]: https://github.com/sebastianbergmann/uuid/compare/f4a58bc49316b4dae46aa69cbe311d08932be2f6...main
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, Sebastian Bergmann
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[![Latest Stable Version](https://poser.pugx.org/sebastian/uuid/v/stable.png)](https://packagist.org/packages/sebastian/uuid)
[![CI Status](https://github.com/sebastianbergmann/uuid/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/uuid/actions)
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/uuid/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/uuid)
[![codecov](https://codecov.io/gh/sebastianbergmann/uuid/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/uuid)

# sebastian/uuid

This package provides a single function: `uuid()`. This function uses PHP's `random_bytes()` function to generate a string that contains a 16-byte number written in hexadecimal and divided into five groups of characters (8-4-4-4-12).

Strings generated using the `uuid()` function can be used as Universally Unique Identifiers (UUIDs) in certain contexts.

## Installation

You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):

```
composer require sebastian/uuid
```

If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:

```
composer require --dev sebastian/uuid
```

## Usage

```php
<?php declare(strict_types=1);
use function SebastianBergmann\Uuid\uuid;

var_dump(uuid());
```
```
string(36) "67b14e2a-17a4-43f7-aba5-859f7fc07b69"
```
30 changes: 30 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Security Policy

If you believe you have found a security vulnerability in the library that is developed in this repository, please report it to us through coordinated disclosure.

**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**

Instead, please send an email to `sebastian@phpunit.de`.

Please include as much of the information listed below as you can to help us better understand and resolve the issue:

* The type of issue
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

## Web Context

The library that is developed in this repository was either extracted from [PHPUnit](https://github.com/sebastianbergmann/phpunit) or developed specifically as a dependency for PHPUnit.

The library is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using the library in a HTTP or web context or with untrusted input data is performed. The library might also contain functionality that intentionally exposes internal application data for debugging purposes.

If the library is used in a web application, the application developer is responsible for filtering inputs or escaping outputs as necessary and for verifying that the used functionality is safe for use within the intended context.

Vulnerabilities specific to the use outside of a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes.

19 changes: 17 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="uuid">
<project name="uuid" default="setup">
<target name="setup" depends="clean,composer"/>

<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.lock"/>
</target>

<target name="composer" depends="clean" description="Install dependencies with Composer">
<exec executable="${basedir}/tools/composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
</exec>
</target>

<target name="update-tools">
<exec executable="phive" taskname="phive">
<arg value="--no-progress"/>
Expand All @@ -8,4 +24,3 @@
</exec>
</target>
</project>

9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"support": {
"issues": "https://github.com/sebastianbergmann/uuid/issues"
},
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": ">=8.0"
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "^10.0"
},
"config": {
"platform": {
"php": "8.0.0"
"php": "8.1.0"
},
"optimize-autoloader": true,
"sort-packages": true
Expand Down
17 changes: 6 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,26 +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/9.5/phpunit.xsd"
bootstrap="src/uuid.php"
cacheResultFile=".phpunit.cache/test-results"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
colors="true"
verbose="true">
colors="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down

0 comments on commit 2591c89

Please sign in to comment.