updated composer
This commit is contained in:
+120
@@ -0,0 +1,120 @@
|
||||
# https://docs.github.com/en/actions
|
||||
|
||||
name: "CI"
|
||||
|
||||
on:
|
||||
pull_request: ~
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
env:
|
||||
COMPOSER_ROOT_VERSION: 1.99
|
||||
|
||||
jobs:
|
||||
coding-standards:
|
||||
name: "Coding Standards"
|
||||
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v2.3.4"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@2.9.0"
|
||||
with:
|
||||
coverage: "none"
|
||||
extensions: "mbstring"
|
||||
php-version: "7.4"
|
||||
tools: "composer-normalize"
|
||||
|
||||
- name: "Validate composer.json"
|
||||
run: "composer validate --strict"
|
||||
|
||||
- name: "Normalize composer.json"
|
||||
run: "composer-normalize --dry-run"
|
||||
|
||||
- name: "PHP-CS-Fixer"
|
||||
uses: "docker://oskarstark/php-cs-fixer-ga:2.18.0"
|
||||
with:
|
||||
args: "--dry-run --diff-format udiff"
|
||||
|
||||
static-code-analysis:
|
||||
name: "Static Code Analysis"
|
||||
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v2.3.4"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@2.9.0"
|
||||
with:
|
||||
coverage: "none"
|
||||
extensions: "mbstring"
|
||||
php-version: "7.4"
|
||||
|
||||
- name: "Install dependencies with composer"
|
||||
run: "composer update --no-interaction --no-progress && composer i --working-dir=ci"
|
||||
|
||||
- name: "Run vimeo/psalm"
|
||||
run: "ci/vendor/bin/psalm --threads=4"
|
||||
|
||||
tests:
|
||||
name: "Tests"
|
||||
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "7.2"
|
||||
- "7.3"
|
||||
- "7.4"
|
||||
- "8.0"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v2.3.4"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@2.9.0"
|
||||
with:
|
||||
coverage: "none"
|
||||
extensions: "mbstring"
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: "Install dependencies with composer"
|
||||
run: "composer update --no-interaction --no-progress"
|
||||
|
||||
- name: "Run unit tests"
|
||||
run: "vendor/bin/phpunit"
|
||||
|
||||
windows-tests:
|
||||
name: "Windows tests"
|
||||
|
||||
runs-on: "windows-latest"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "7.4"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v2.3.4"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@2.9.0"
|
||||
with:
|
||||
coverage: "none"
|
||||
extensions: "mbstring"
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: "Install dependencies with composer"
|
||||
run: "composer update --no-interaction --no-progress"
|
||||
|
||||
- name: "Run unit tests"
|
||||
run: "vendor/bin/phpunit tests/AssertTest.php"
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/src')
|
||||
->in(__DIR__.'/tests')
|
||||
;
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'@Symfony' => true,
|
||||
'ordered_imports' => true,
|
||||
'array_syntax' => ['syntax' => 'long'],
|
||||
'no_superfluous_phpdoc_tags' => false,
|
||||
'phpdoc_annotation_without_dot' => false,
|
||||
'phpdoc_types_order' => false,
|
||||
'phpdoc_summary' => false,
|
||||
'phpdoc_to_comment' => false,
|
||||
'phpdoc_align' => false,
|
||||
'yoda_style' => false,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
Vendored
+16
-1
@@ -3,6 +3,21 @@ Changelog
|
||||
|
||||
## UNRELEASED
|
||||
|
||||
## 1.10.0
|
||||
|
||||
### Added
|
||||
|
||||
* On invalid assertion, we throw a `Webmozart\Assert\InvalidArgumentException`
|
||||
* Added `Assert::positiveInteger()`
|
||||
|
||||
### Changed
|
||||
|
||||
* Using a trait with real implementations of `all*()` and `nullOr*()` methods to improve psalm compatibility.
|
||||
|
||||
### Removed
|
||||
|
||||
* Support for PHP <7.2
|
||||
|
||||
## 1.9.1
|
||||
|
||||
## Fixed
|
||||
@@ -12,7 +27,7 @@ Changelog
|
||||
## 1.9.0
|
||||
|
||||
* added better Psalm support for `all*` & `nullOr*` methods
|
||||
* These methods are now understood by Psalm through a mixin. You may need a newer version of Psalm in order to use this
|
||||
* These methods are now understood by Psalm through a mixin. You may need a newer version of Psalm in order to use this
|
||||
* added `@psalm-pure` annotation to `Assert::notFalse()`
|
||||
* added more `@psalm-assert` annotations where appropriate
|
||||
|
||||
|
||||
Vendored
+10
-6
@@ -1,9 +1,6 @@
|
||||
Webmozart Assert
|
||||
================
|
||||
|
||||
[](https://travis-ci.org/webmozart/assert)
|
||||
[](https://ci.appveyor.com/project/webmozart/assert/branch/master)
|
||||
[](https://scrutinizer-ci.com/g/webmozart/assert/?branch=master)
|
||||
[](https://packagist.org/packages/webmozart/assert)
|
||||
[](https://packagist.org/packages/webmozart/assert)
|
||||
|
||||
@@ -11,7 +8,7 @@ This library contains efficient assertions to test the input and output of
|
||||
your methods. With these assertions, you can greatly reduce the amount of coding
|
||||
needed to write a safe implementation.
|
||||
|
||||
All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if
|
||||
All assertions in the [`Assert`] class throw an `Webmozart\Assert\InvalidArgumentException` if
|
||||
they fail.
|
||||
|
||||
FAQ
|
||||
@@ -70,11 +67,11 @@ If you create an employee with an invalid ID, an exception is thrown:
|
||||
|
||||
```php
|
||||
new Employee('foobar');
|
||||
// => InvalidArgumentException:
|
||||
// => Webmozart\Assert\InvalidArgumentException:
|
||||
// The employee ID must be an integer. Got: string
|
||||
|
||||
new Employee(-10);
|
||||
// => InvalidArgumentException:
|
||||
// => Webmozart\Assert\InvalidArgumentException:
|
||||
// The employee ID must be a positive integer. Got: -10
|
||||
```
|
||||
|
||||
@@ -91,6 +88,7 @@ Method | Description
|
||||
`stringNotEmpty($value, $message = '')` | Check that a value is a non-empty string
|
||||
`integer($value, $message = '')` | Check that a value is an integer
|
||||
`integerish($value, $message = '')` | Check that a value casts to an integer
|
||||
`positiveInteger($value, $message = '')` | Check that a value is a positive (non-zero) integer
|
||||
`float($value, $message = '')` | Check that a value is a float
|
||||
`numeric($value, $message = '')` | Check that a value is numeric
|
||||
`natural($value, $message= ''')` | Check that a value is a non-negative integer
|
||||
@@ -251,6 +249,12 @@ Overriding the following methods in your assertion class allows you to change th
|
||||
* `protected static function reportInvalidArgument($message)`
|
||||
* This method is called when an assertion fails, with the specified error message. Here you can throw your own exception, or log something.
|
||||
|
||||
## Static analysis support
|
||||
|
||||
Where applicable, assertion functions are annotated to support Psalm's
|
||||
[Assertion syntax](https://psalm.dev/docs/annotating_code/assertion_syntax/).
|
||||
A dedicated [PHPStan Plugin](https://github.com/phpstan/phpstan-webmozart-assert) is
|
||||
required for proper type support.
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
+11
-6
@@ -14,15 +14,20 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.3.3 || ^7.0 || ^8.0",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
|
||||
},
|
||||
"conflict": {
|
||||
"vimeo/psalm": "<3.9.1",
|
||||
"phpstan/phpstan": "<0.12.20"
|
||||
"phpstan/phpstan": "<0.12.20",
|
||||
"vimeo/psalm": "<4.6.1 || 4.6.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5.13"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.10-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
+22
-4
@@ -18,7 +18,6 @@ use Countable;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use ResourceBundle;
|
||||
use SimpleXMLElement;
|
||||
use Throwable;
|
||||
@@ -27,14 +26,14 @@ use Traversable;
|
||||
/**
|
||||
* Efficient assertions to validate the input/output of your methods.
|
||||
*
|
||||
* @mixin Mixin
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class Assert
|
||||
{
|
||||
use Mixin;
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert string $value
|
||||
@@ -107,6 +106,25 @@ class Assert
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert positive-int $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function positiveInteger($value, $message = '')
|
||||
{
|
||||
if (!(\is_int($value) && $value > 0)) {
|
||||
static::reportInvalidArgument(\sprintf(
|
||||
$message ?: 'Expected a positive integer. Got: %s',
|
||||
static::valueToString($value)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert float $value
|
||||
@@ -147,7 +165,7 @@ class Assert
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert int $value
|
||||
* @psalm-assert positive-int|0 $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the webmozart/assert package.
|
||||
*
|
||||
* (c) Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Webmozart\Assert;
|
||||
|
||||
class InvalidArgumentException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
||||
+1201
-256
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user