Bump 'spomky-labs/otphp' to 11.3.x.

This is mainly for PHP 8.4 compatibility.
This commit is contained in:
wn_ 2024-12-09 17:58:28 +00:00
parent cd2c10f9f7
commit f6a8facfd4
232 changed files with 1263 additions and 54377 deletions

View File

@ -21,7 +21,7 @@
]
},
"require": {
"spomky-labs/otphp": "^10.0",
"spomky-labs/otphp": "^11.3",
"chillerlan/php-qrcode": "^5.0.3",
"mervick/material-design-icons": "^2.2",
"j4mie/idiorm": "dev-master",

340
composer.lock generated
View File

@ -4,75 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9ab892ba18b7df4be49cc46f17aa6267",
"content-hash": "1aa8437b32b5398144a47490f6bcdfa0",
"packages": [
{
"name": "beberlei/assert",
"version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/beberlei/assert.git",
"reference": "cb70015c04be1baee6f5f5c953703347c0ac1655"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/beberlei/assert/zipball/cb70015c04be1baee6f5f5c953703347c0ac1655",
"reference": "cb70015c04be1baee6f5f5c953703347c0ac1655",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"php": "^7.0 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan": "*",
"phpunit/phpunit": ">=6.0.0",
"yoast/phpunit-polyfills": "^0.1.0"
},
"suggest": {
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles"
},
"type": "library",
"autoload": {
"files": [
"lib/Assert/functions.php"
],
"psr-4": {
"Assert\\": "lib/Assert"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de",
"role": "Lead Developer"
},
{
"name": "Richard Quadling",
"email": "rquadling@gmail.com",
"role": "Collaborator"
}
],
"description": "Thin assertion library for input validation in business models.",
"keywords": [
"assert",
"assertion",
"validation"
],
"support": {
"issues": "https://github.com/beberlei/assert/issues",
"source": "https://github.com/beberlei/assert/tree/v3.3.2"
},
"time": "2021-12-16T21:41:27+00:00"
},
{
"name": "chillerlan/php-qrcode",
"version": "5.0.3",
@ -667,24 +600,24 @@
},
{
"name": "paragonie/constant_time_encoding",
"version": "v2.6.3",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "58c3f47f650c94ec05a151692652a868995d2938"
"reference": "df1e7fde177501eee2037dd159cf04f5f301a512"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938",
"reference": "58c3f47f650c94ec05a151692652a868995d2938",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512",
"reference": "df1e7fde177501eee2037dd159cf04f5f301a512",
"shasum": ""
},
"require": {
"php": "^7|^8"
"php": "^8"
},
"require-dev": {
"phpunit/phpunit": "^6|^7|^8|^9",
"vimeo/psalm": "^1|^2|^3|^4"
"phpunit/phpunit": "^9",
"vimeo/psalm": "^4|^5"
},
"type": "library",
"autoload": {
@ -730,7 +663,55 @@
"issues": "https://github.com/paragonie/constant_time_encoding/issues",
"source": "https://github.com/paragonie/constant_time_encoding"
},
"time": "2022-06-14T06:56:20+00:00"
"time": "2024-05-08T12:36:18+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"time": "2022-11-25T14:36:26+00:00"
},
{
"name": "psr/http-client",
@ -993,43 +974,40 @@
},
{
"name": "spomky-labs/otphp",
"version": "v10.0.3",
"version": "11.3.0",
"source": {
"type": "git",
"url": "https://github.com/Spomky-Labs/otphp.git",
"reference": "9784d9f7c790eed26e102d6c78f12c754036c366"
"reference": "2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Spomky-Labs/otphp/zipball/9784d9f7c790eed26e102d6c78f12c754036c366",
"reference": "9784d9f7c790eed26e102d6c78f12c754036c366",
"url": "https://api.github.com/repos/Spomky-Labs/otphp/zipball/2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33",
"reference": "2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33",
"shasum": ""
},
"require": {
"beberlei/assert": "^3.0",
"ext-mbstring": "*",
"paragonie/constant_time_encoding": "^2.0",
"php": "^7.2|^8.0",
"thecodingmachine/safe": "^0.1.14|^1.0|^2.0"
"paragonie/constant_time_encoding": "^2.0 || ^3.0",
"php": ">=8.1",
"psr/clock": "^1.0",
"symfony/deprecation-contracts": "^3.2"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-beberlei-assert": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^8.0",
"thecodingmachine/phpstan-safe-rule": "^1.0 || ^2.0"
"ekino/phpstan-banned-code": "^1.0",
"infection/infection": "^0.26|^0.27|^0.28|^0.29",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5.26|^10.0|^11.0",
"qossmic/deptrac-shim": "^1.0",
"rector/rector": "^1.0",
"symfony/phpunit-bridge": "^6.1|^7.0",
"symplify/easy-coding-standard": "^12.0"
},
"type": "library",
"extra": {
"branch-alias": {
"v10.0": "10.0.x-dev",
"v9.0": "9.0.x-dev",
"v8.3": "8.3.x-dev"
}
},
"autoload": {
"psr-4": {
"OTPHP\\": "src/"
@ -1062,22 +1040,32 @@
],
"support": {
"issues": "https://github.com/Spomky-Labs/otphp/issues",
"source": "https://github.com/Spomky-Labs/otphp/tree/v10.0.3"
"source": "https://github.com/Spomky-Labs/otphp/tree/11.3.0"
},
"time": "2022-03-17T08:00:35+00:00"
"funding": [
{
"url": "https://github.com/Spomky",
"type": "github"
},
{
"url": "https://www.patreon.com/FlorentMorselli",
"type": "patreon"
}
],
"time": "2024-06-12T11:22:32+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.5.0",
"version": "v3.5.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1"
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"shasum": ""
},
"require": {
@ -1115,7 +1103,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
},
"funding": [
{
@ -1131,145 +1119,7 @@
"type": "tidelift"
}
],
"time": "2024-04-18T09:32:20+00:00"
},
{
"name": "thecodingmachine/safe",
"version": "v2.2.2",
"source": {
"type": "git",
"url": "https://github.com/thecodingmachine/safe.git",
"reference": "440284f9592c9df402832452a6871a8b3c48d97e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/440284f9592c9df402832452a6871a8b3c48d97e",
"reference": "440284f9592c9df402832452a6871a8b3c48d97e",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.2",
"thecodingmachine/phpstan-strict-rules": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
}
},
"autoload": {
"files": [
"deprecated/apc.php",
"deprecated/array.php",
"deprecated/datetime.php",
"deprecated/libevent.php",
"deprecated/password.php",
"deprecated/mssql.php",
"deprecated/stats.php",
"deprecated/strings.php",
"lib/special_cases.php",
"deprecated/mysqli.php",
"generated/apache.php",
"generated/apcu.php",
"generated/array.php",
"generated/bzip2.php",
"generated/calendar.php",
"generated/classobj.php",
"generated/com.php",
"generated/cubrid.php",
"generated/curl.php",
"generated/datetime.php",
"generated/dir.php",
"generated/eio.php",
"generated/errorfunc.php",
"generated/exec.php",
"generated/fileinfo.php",
"generated/filesystem.php",
"generated/filter.php",
"generated/fpm.php",
"generated/ftp.php",
"generated/funchand.php",
"generated/gettext.php",
"generated/gmp.php",
"generated/gnupg.php",
"generated/hash.php",
"generated/ibase.php",
"generated/ibmDb2.php",
"generated/iconv.php",
"generated/image.php",
"generated/imap.php",
"generated/info.php",
"generated/inotify.php",
"generated/json.php",
"generated/ldap.php",
"generated/libxml.php",
"generated/lzf.php",
"generated/mailparse.php",
"generated/mbstring.php",
"generated/misc.php",
"generated/mysql.php",
"generated/network.php",
"generated/oci8.php",
"generated/opcache.php",
"generated/openssl.php",
"generated/outcontrol.php",
"generated/pcntl.php",
"generated/pcre.php",
"generated/pgsql.php",
"generated/posix.php",
"generated/ps.php",
"generated/pspell.php",
"generated/readline.php",
"generated/rpminfo.php",
"generated/rrd.php",
"generated/sem.php",
"generated/session.php",
"generated/shmop.php",
"generated/sockets.php",
"generated/sodium.php",
"generated/solr.php",
"generated/spl.php",
"generated/sqlsrv.php",
"generated/ssdeep.php",
"generated/ssh2.php",
"generated/stream.php",
"generated/strings.php",
"generated/swoole.php",
"generated/uodbc.php",
"generated/uopz.php",
"generated/url.php",
"generated/var.php",
"generated/xdiff.php",
"generated/xml.php",
"generated/xmlrpc.php",
"generated/yaml.php",
"generated/yaz.php",
"generated/zip.php",
"generated/zlib.php"
],
"classmap": [
"lib/DateTime.php",
"lib/DateTimeImmutable.php",
"lib/Exceptions/",
"deprecated/Exceptions/",
"generated/Exceptions/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
"support": {
"issues": "https://github.com/thecodingmachine/safe/issues",
"source": "https://github.com/thecodingmachine/safe/tree/v2.2.2"
},
"time": "2022-07-20T17:46:34+00:00"
"time": "2024-09-25T14:20:29+00:00"
}
],
"packages-dev": [

View File

@ -1,64 +0,0 @@
on: [push, pull_request]
name: CI
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: "cs2pr"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
- name: "Composer"
run: "composer update --prefer-stable"
- name: "PHPUnit"
run: "php vendor/bin/phpunit"
# lint:
# name: Lint
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v1
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: 7.4
# - name: "Cache dependencies installed with composer"
# uses: "actions/cache@v1"
# with:
# path: "~/.composer/cache"
# key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
# restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
# - name: "Composer"
# run: "composer update --prefer-stable"
# - name: "assert:cs-lint"
# run: "composer assert:cs-lint"
# - name: "assert:sa-code"
# run: "composer assert:sa-code"
# - name: "assert:sa-tests"
# run: "composer assert:sa-tests"

View File

@ -1,11 +0,0 @@
Copyright (c) 2011-2013, Benjamin Eberlei
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- 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.

View File

@ -1,64 +0,0 @@
{
"name": "beberlei/assert",
"description": "Thin assertion library for input validation in business models.",
"authors": [
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de",
"role": "Lead Developer"
},
{
"name": "Richard Quadling",
"email": "rquadling@gmail.com",
"role": "Collaborator"
}
],
"license": "BSD-2-Clause",
"keywords": [
"assert",
"assertion",
"validation"
],
"config": {
"sort-packages": true
},
"require": {
"php": "^7.0 || ^8.0",
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-ctype": "*",
"ext-json": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan": "*",
"phpunit/phpunit": ">=6.0.0",
"yoast/phpunit-polyfills": "^0.1.0"
},
"autoload": {
"psr-4": {
"Assert\\": "lib/Assert"
},
"files": [
"lib/Assert/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Assert\\Tests\\": "tests/Assert/Tests"
},
"files": [
"tests/Assert/Tests/Fixtures/functions.php"
]
},
"scripts": {
"assert:generate-docs": "php bin/generate_method_docs.php",
"assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run",
"assert:cs-fix": "php-cs-fixer fix . -vvv || true",
"assert:sa-code": "vendor/bin/phpstan analyse --configuration=phpstan-code.neon --no-progress --ansi -l 7 bin lib",
"assert:sa-tests": "vendor/bin/phpstan analyse --configuration=phpstan-tests.neon --no-progress --ansi -l 7 tests"
},
"suggest": {
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles"
}
}

View File

@ -1,85 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
/**
* AssertionChain factory.
*/
abstract class Assert
{
/** @var string */
protected static $lazyAssertionExceptionClass = LazyAssertionException::class;
/** @var string */
protected static $assertionClass = Assertion::class;
/**
* Start validation on a value, returns {@link AssertionChain}.
*
* The invocation of this method starts an assertion chain
* that is happening on the passed value.
*
* @param mixed $value
* @param string|callable|null $defaultMessage
*
* @example
*
* Assert::that($value)->notEmpty()->integer();
* Assert::that($value)->nullOr()->string()->startsWith("Foo");
*
* The assertion chain can be stateful, that means be careful when you reuse
* it. You should never pass around the chain.
*/
public static function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
$assertionChain = new AssertionChain($value, $defaultMessage, $defaultPropertyPath);
return $assertionChain->setAssertionClassName(static::$assertionClass);
}
/**
* Start validation on a set of values, returns {@link AssertionChain}.
*
* @param mixed $values
* @param string|callable|null $defaultMessage
*/
public static function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
return static::that($values, $defaultMessage, $defaultPropertyPath)->all();
}
/**
* Start validation and allow NULL, returns {@link AssertionChain}.
*
* @param mixed $value
* @param string|callable|null $defaultMessage
*/
public static function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
return static::that($value, $defaultMessage, $defaultPropertyPath)->nullOr();
}
/**
* Create a lazy assertion object.
*/
public static function lazy(): LazyAssertion
{
$lazyAssertion = new LazyAssertion();
return $lazyAssertion
->setAssertClass(\get_called_class())
->setExceptionClass(static::$lazyAssertionExceptionClass);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,247 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
use LogicException;
/**
* Chaining builder for assertions.
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
*
* @method AssertionChain alnum(string|callable $message = null, string $propertyPath = null) Assert that value is alphanumeric.
* @method AssertionChain base64(string|callable $message = null, string $propertyPath = null) Assert that a constant is defined.
* @method AssertionChain between(mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit.
* @method AssertionChain betweenExclusive(mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater than a lower limit, and less than an upper limit.
* @method AssertionChain betweenLength(int $minLength, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string length is between min and max lengths.
* @method AssertionChain boolean(string|callable $message = null, string $propertyPath = null) Assert that value is php boolean.
* @method AssertionChain choice(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices.
* @method AssertionChain choicesNotEmpty(array $choices, string|callable $message = null, string $propertyPath = null) Determines if the values array has every choice as key and that this choice has content.
* @method AssertionChain classExists(string|callable $message = null, string $propertyPath = null) Assert that the class exists.
* @method AssertionChain contains(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string contains a sequence of chars.
* @method AssertionChain count(int $count, string|callable $message = null, string $propertyPath = null) Assert that the count of countable is equal to count.
* @method AssertionChain date(string $format, string|callable $message = null, string $propertyPath = null) Assert that date is valid and corresponds to the given format.
* @method AssertionChain defined(string|callable $message = null, string $propertyPath = null) Assert that a constant is defined.
* @method AssertionChain digit(string|callable $message = null, string $propertyPath = null) Validates if an integer or integerish is a digit.
* @method AssertionChain directory(string|callable $message = null, string $propertyPath = null) Assert that a directory exists.
* @method AssertionChain e164(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid E164 Phone Number.
* @method AssertionChain email(string|callable $message = null, string $propertyPath = null) Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL).
* @method AssertionChain endsWith(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string ends with a sequence of chars.
* @method AssertionChain eq(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are equal (using ==).
* @method AssertionChain eqArraySubset(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that the array contains the subset.
* @method AssertionChain extensionLoaded(string|callable $message = null, string $propertyPath = null) Assert that extension is loaded.
* @method AssertionChain extensionVersion(string $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded and a specific version is installed.
* @method AssertionChain false(string|callable $message = null, string $propertyPath = null) Assert that the value is boolean False.
* @method AssertionChain file(string|callable $message = null, string $propertyPath = null) Assert that a file exists.
* @method AssertionChain float(string|callable $message = null, string $propertyPath = null) Assert that value is a php float.
* @method AssertionChain greaterOrEqualThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater or equal than given limit.
* @method AssertionChain greaterThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater than given limit.
* @method AssertionChain implementsInterface(string $interfaceName, string|callable $message = null, string $propertyPath = null) Assert that the class implements the interface.
* @method AssertionChain inArray(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices. This is an alias of Assertion::choice().
* @method AssertionChain integer(string|callable $message = null, string $propertyPath = null) Assert that value is a php integer.
* @method AssertionChain integerish(string|callable $message = null, string $propertyPath = null) Assert that value is a php integer'ish.
* @method AssertionChain interfaceExists(string|callable $message = null, string $propertyPath = null) Assert that the interface exists.
* @method AssertionChain ip(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 or IPv6 address.
* @method AssertionChain ipv4(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 address.
* @method AssertionChain ipv6(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv6 address.
* @method AssertionChain isArray(string|callable $message = null, string $propertyPath = null) Assert that value is an array.
* @method AssertionChain isArrayAccessible(string|callable $message = null, string $propertyPath = null) Assert that value is an array or an array-accessible object.
* @method AssertionChain isCallable(string|callable $message = null, string $propertyPath = null) Determines that the provided value is callable.
* @method AssertionChain isCountable(string|callable $message = null, string $propertyPath = null) Assert that value is countable.
* @method AssertionChain isInstanceOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is instance of given class-name.
* @method AssertionChain isJsonString(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid json string.
* @method AssertionChain isObject(string|callable $message = null, string $propertyPath = null) Determines that the provided value is an object.
* @method AssertionChain isResource(string|callable $message = null, string $propertyPath = null) Assert that value is a resource.
* @method AssertionChain isTraversable(string|callable $message = null, string $propertyPath = null) Assert that value is an array or a traversable object.
* @method AssertionChain keyExists(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array.
* @method AssertionChain keyIsset(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object using isset().
* @method AssertionChain keyNotExists(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key does not exist in an array.
* @method AssertionChain length(int $length, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string has a given length.
* @method AssertionChain lessOrEqualThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less or equal than given limit.
* @method AssertionChain lessThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less than given limit.
* @method AssertionChain max(mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that a number is smaller as a given limit.
* @method AssertionChain maxCount(int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at most $count elements.
* @method AssertionChain maxLength(int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string value is not longer than $maxLength chars.
* @method AssertionChain methodExists(mixed $object, string|callable $message = null, string $propertyPath = null) Determines that the named method is defined in the provided object.
* @method AssertionChain min(mixed $minValue, string|callable $message = null, string $propertyPath = null) Assert that a value is at least as big as a given limit.
* @method AssertionChain minCount(int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at least $count elements.
* @method AssertionChain minLength(int $minLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that a string is at least $minLength chars long.
* @method AssertionChain noContent(string|callable $message = null, string $propertyPath = null) Assert that value is empty.
* @method AssertionChain notBlank(string|callable $message = null, string $propertyPath = null) Assert that value is not blank.
* @method AssertionChain notContains(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string does not contains a sequence of chars.
* @method AssertionChain notEmpty(string|callable $message = null, string $propertyPath = null) Assert that value is not empty.
* @method AssertionChain notEmptyKey(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object and its value is not empty.
* @method AssertionChain notEq(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not equal (using ==).
* @method AssertionChain notInArray(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is not in array of choices.
* @method AssertionChain notIsInstanceOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is not instance of given class-name.
* @method AssertionChain notNull(string|callable $message = null, string $propertyPath = null) Assert that value is not null.
* @method AssertionChain notRegex(string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value does not match a regex.
* @method AssertionChain notSame(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not the same (using ===).
* @method AssertionChain null(string|callable $message = null, string $propertyPath = null) Assert that value is null.
* @method AssertionChain numeric(string|callable $message = null, string $propertyPath = null) Assert that value is numeric.
* @method AssertionChain objectOrClass(string|callable $message = null, string $propertyPath = null) Assert that the value is an object, or a class that exists.
* @method AssertionChain phpVersion(mixed $version, string|callable $message = null, string $propertyPath = null) Assert on PHP version.
* @method AssertionChain propertiesExist(array $properties, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the properties all exist.
* @method AssertionChain propertyExists(string $property, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the property exists.
* @method AssertionChain range(mixed $minValue, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that value is in range of numbers.
* @method AssertionChain readable(string|callable $message = null, string $propertyPath = null) Assert that the value is something readable.
* @method AssertionChain regex(string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value matches a regex.
* @method AssertionChain same(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are the same (using ===).
* @method AssertionChain satisfy(callable $callback, string|callable $message = null, string $propertyPath = null) Assert that the provided value is valid according to a callback.
* @method AssertionChain scalar(string|callable $message = null, string $propertyPath = null) Assert that value is a PHP scalar.
* @method AssertionChain startsWith(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string starts with a sequence of chars.
* @method AssertionChain string(string|callable $message = null, string $propertyPath = null) Assert that value is a string.
* @method AssertionChain subclassOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is subclass of given class-name.
* @method AssertionChain true(string|callable $message = null, string $propertyPath = null) Assert that the value is boolean True.
* @method AssertionChain uniqueValues(string|callable $message = null, string $propertyPath = null) Assert that values in array are unique (using strict equality).
* @method AssertionChain url(string|callable $message = null, string $propertyPath = null) Assert that value is an URL.
* @method AssertionChain uuid(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid UUID.
* @method AssertionChain version(string $operator, string $version2, string|callable $message = null, string $propertyPath = null) Assert comparison of two versions.
* @method AssertionChain writeable(string|callable $message = null, string $propertyPath = null) Assert that the value is something writeable.
*/
class AssertionChain
{
/**
* @var mixed
*/
private $value;
/**
* @var string|callable|null
*/
private $defaultMessage;
/**
* @var string|null
*/
private $defaultPropertyPath;
/**
* Return each assertion as always valid.
*
* @var bool
*/
private $alwaysValid = false;
/**
* Perform assertion on every element of array or traversable.
*
* @var bool
*/
private $all = false;
/** @var string|Assertion Class to use for assertion calls */
private $assertionClassName = 'Assert\Assertion';
/**
* AssertionChain constructor.
*
* @param mixed $value
* @param string|callable|null $defaultMessage
*/
public function __construct($value, $defaultMessage = null, string $defaultPropertyPath = null)
{
$this->value = $value;
$this->defaultMessage = $defaultMessage;
$this->defaultPropertyPath = $defaultPropertyPath;
}
/**
* Call assertion on the current value in the chain.
*
* @param string $methodName
* @param array $args
*/
public function __call($methodName, $args): AssertionChain
{
if (true === $this->alwaysValid) {
return $this;
}
try {
$method = new \ReflectionMethod($this->assertionClassName, $methodName);
} catch (\ReflectionException $exception) {
throw new \RuntimeException("Assertion '".$methodName."' does not exist.");
}
\array_unshift($args, $this->value);
$params = $method->getParameters();
foreach ($params as $idx => $param) {
if (isset($args[$idx])) {
continue;
}
switch ($param->getName()) {
case 'message':
$args[$idx] = $this->defaultMessage;
break;
case 'propertyPath':
$args[$idx] = $this->defaultPropertyPath;
break;
}
}
if ($this->all) {
$methodName = 'all'.$methodName;
}
\call_user_func_array([$this->assertionClassName, $methodName], $args);
return $this;
}
/**
* Switch chain into validation mode for an array of values.
*/
public function all(): AssertionChain
{
$this->all = true;
return $this;
}
/**
* Switch chain into mode allowing nulls, ignoring further assertions.
*/
public function nullOr(): AssertionChain
{
if (null === $this->value) {
$this->alwaysValid = true;
}
return $this;
}
/**
* @param string $className
*
* @return $this
*/
public function setAssertionClassName($className): AssertionChain
{
if (!\is_string($className)) {
throw new LogicException('Exception class name must be passed as a string');
}
if (Assertion::class !== $className && !\is_subclass_of($className, Assertion::class)) {
throw new LogicException($className.' is not (a subclass of) '.Assertion::class);
}
$this->assertionClassName = $className;
return $this;
}
}

View File

@ -1,32 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
use Throwable;
interface AssertionFailedException extends Throwable
{
/**
* @return string|null
*/
public function getPropertyPath();
/**
* @return mixed
*/
public function getValue();
public function getConstraints(): array;
}

View File

@ -1,74 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
class InvalidArgumentException extends \InvalidArgumentException implements AssertionFailedException
{
/**
* @var string|null
*/
private $propertyPath;
/**
* @var mixed
*/
private $value;
/**
* @var array
*/
private $constraints;
public function __construct($message, $code, string $propertyPath = null, $value = null, array $constraints = [])
{
parent::__construct($message, $code);
$this->propertyPath = $propertyPath;
$this->value = $value;
$this->constraints = $constraints;
}
/**
* User controlled way to define a sub-property causing
* the failure of a currently asserted objects.
*
* Useful to transport information about the nature of the error
* back to higher layers.
*
* @return string|null
*/
public function getPropertyPath()
{
return $this->propertyPath;
}
/**
* Get the value that caused the assertion to fail.
*
* @return mixed
*/
public function getValue()
{
return $this->value;
}
/**
* Get the constraints that applied to the failed assertion.
*/
public function getConstraints(): array
{
return $this->constraints;
}
}

View File

@ -1,228 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
use LogicException;
/**
* Chaining builder for lazy assertions.
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
*
* @method LazyAssertion alnum(string|callable $message = null, string $propertyPath = null) Assert that value is alphanumeric.
* @method LazyAssertion base64(string|callable $message = null, string $propertyPath = null) Assert that a constant is defined.
* @method LazyAssertion between(mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit.
* @method LazyAssertion betweenExclusive(mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater than a lower limit, and less than an upper limit.
* @method LazyAssertion betweenLength(int $minLength, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string length is between min and max lengths.
* @method LazyAssertion boolean(string|callable $message = null, string $propertyPath = null) Assert that value is php boolean.
* @method LazyAssertion choice(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices.
* @method LazyAssertion choicesNotEmpty(array $choices, string|callable $message = null, string $propertyPath = null) Determines if the values array has every choice as key and that this choice has content.
* @method LazyAssertion classExists(string|callable $message = null, string $propertyPath = null) Assert that the class exists.
* @method LazyAssertion contains(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string contains a sequence of chars.
* @method LazyAssertion count(int $count, string|callable $message = null, string $propertyPath = null) Assert that the count of countable is equal to count.
* @method LazyAssertion date(string $format, string|callable $message = null, string $propertyPath = null) Assert that date is valid and corresponds to the given format.
* @method LazyAssertion defined(string|callable $message = null, string $propertyPath = null) Assert that a constant is defined.
* @method LazyAssertion digit(string|callable $message = null, string $propertyPath = null) Validates if an integer or integerish is a digit.
* @method LazyAssertion directory(string|callable $message = null, string $propertyPath = null) Assert that a directory exists.
* @method LazyAssertion e164(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid E164 Phone Number.
* @method LazyAssertion email(string|callable $message = null, string $propertyPath = null) Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL).
* @method LazyAssertion endsWith(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string ends with a sequence of chars.
* @method LazyAssertion eq(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are equal (using ==).
* @method LazyAssertion eqArraySubset(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that the array contains the subset.
* @method LazyAssertion extensionLoaded(string|callable $message = null, string $propertyPath = null) Assert that extension is loaded.
* @method LazyAssertion extensionVersion(string $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded and a specific version is installed.
* @method LazyAssertion false(string|callable $message = null, string $propertyPath = null) Assert that the value is boolean False.
* @method LazyAssertion file(string|callable $message = null, string $propertyPath = null) Assert that a file exists.
* @method LazyAssertion float(string|callable $message = null, string $propertyPath = null) Assert that value is a php float.
* @method LazyAssertion greaterOrEqualThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater or equal than given limit.
* @method LazyAssertion greaterThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater than given limit.
* @method LazyAssertion implementsInterface(string $interfaceName, string|callable $message = null, string $propertyPath = null) Assert that the class implements the interface.
* @method LazyAssertion inArray(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices. This is an alias of Assertion::choice().
* @method LazyAssertion integer(string|callable $message = null, string $propertyPath = null) Assert that value is a php integer.
* @method LazyAssertion integerish(string|callable $message = null, string $propertyPath = null) Assert that value is a php integer'ish.
* @method LazyAssertion interfaceExists(string|callable $message = null, string $propertyPath = null) Assert that the interface exists.
* @method LazyAssertion ip(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 or IPv6 address.
* @method LazyAssertion ipv4(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 address.
* @method LazyAssertion ipv6(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv6 address.
* @method LazyAssertion isArray(string|callable $message = null, string $propertyPath = null) Assert that value is an array.
* @method LazyAssertion isArrayAccessible(string|callable $message = null, string $propertyPath = null) Assert that value is an array or an array-accessible object.
* @method LazyAssertion isCallable(string|callable $message = null, string $propertyPath = null) Determines that the provided value is callable.
* @method LazyAssertion isCountable(string|callable $message = null, string $propertyPath = null) Assert that value is countable.
* @method LazyAssertion isInstanceOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is instance of given class-name.
* @method LazyAssertion isJsonString(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid json string.
* @method LazyAssertion isObject(string|callable $message = null, string $propertyPath = null) Determines that the provided value is an object.
* @method LazyAssertion isResource(string|callable $message = null, string $propertyPath = null) Assert that value is a resource.
* @method LazyAssertion isTraversable(string|callable $message = null, string $propertyPath = null) Assert that value is an array or a traversable object.
* @method LazyAssertion keyExists(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array.
* @method LazyAssertion keyIsset(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object using isset().
* @method LazyAssertion keyNotExists(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key does not exist in an array.
* @method LazyAssertion length(int $length, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string has a given length.
* @method LazyAssertion lessOrEqualThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less or equal than given limit.
* @method LazyAssertion lessThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less than given limit.
* @method LazyAssertion max(mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that a number is smaller as a given limit.
* @method LazyAssertion maxCount(int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at most $count elements.
* @method LazyAssertion maxLength(int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string value is not longer than $maxLength chars.
* @method LazyAssertion methodExists(mixed $object, string|callable $message = null, string $propertyPath = null) Determines that the named method is defined in the provided object.
* @method LazyAssertion min(mixed $minValue, string|callable $message = null, string $propertyPath = null) Assert that a value is at least as big as a given limit.
* @method LazyAssertion minCount(int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at least $count elements.
* @method LazyAssertion minLength(int $minLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that a string is at least $minLength chars long.
* @method LazyAssertion noContent(string|callable $message = null, string $propertyPath = null) Assert that value is empty.
* @method LazyAssertion notBlank(string|callable $message = null, string $propertyPath = null) Assert that value is not blank.
* @method LazyAssertion notContains(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string does not contains a sequence of chars.
* @method LazyAssertion notEmpty(string|callable $message = null, string $propertyPath = null) Assert that value is not empty.
* @method LazyAssertion notEmptyKey(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object and its value is not empty.
* @method LazyAssertion notEq(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not equal (using ==).
* @method LazyAssertion notInArray(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is not in array of choices.
* @method LazyAssertion notIsInstanceOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is not instance of given class-name.
* @method LazyAssertion notNull(string|callable $message = null, string $propertyPath = null) Assert that value is not null.
* @method LazyAssertion notRegex(string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value does not match a regex.
* @method LazyAssertion notSame(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not the same (using ===).
* @method LazyAssertion null(string|callable $message = null, string $propertyPath = null) Assert that value is null.
* @method LazyAssertion numeric(string|callable $message = null, string $propertyPath = null) Assert that value is numeric.
* @method LazyAssertion objectOrClass(string|callable $message = null, string $propertyPath = null) Assert that the value is an object, or a class that exists.
* @method LazyAssertion phpVersion(mixed $version, string|callable $message = null, string $propertyPath = null) Assert on PHP version.
* @method LazyAssertion propertiesExist(array $properties, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the properties all exist.
* @method LazyAssertion propertyExists(string $property, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the property exists.
* @method LazyAssertion range(mixed $minValue, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that value is in range of numbers.
* @method LazyAssertion readable(string|callable $message = null, string $propertyPath = null) Assert that the value is something readable.
* @method LazyAssertion regex(string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value matches a regex.
* @method LazyAssertion same(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are the same (using ===).
* @method LazyAssertion satisfy(callable $callback, string|callable $message = null, string $propertyPath = null) Assert that the provided value is valid according to a callback.
* @method LazyAssertion scalar(string|callable $message = null, string $propertyPath = null) Assert that value is a PHP scalar.
* @method LazyAssertion startsWith(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string starts with a sequence of chars.
* @method LazyAssertion string(string|callable $message = null, string $propertyPath = null) Assert that value is a string.
* @method LazyAssertion subclassOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is subclass of given class-name.
* @method LazyAssertion true(string|callable $message = null, string $propertyPath = null) Assert that the value is boolean True.
* @method LazyAssertion uniqueValues(string|callable $message = null, string $propertyPath = null) Assert that values in array are unique (using strict equality).
* @method LazyAssertion url(string|callable $message = null, string $propertyPath = null) Assert that value is an URL.
* @method LazyAssertion uuid(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid UUID.
* @method LazyAssertion version(string $operator, string $version2, string|callable $message = null, string $propertyPath = null) Assert comparison of two versions.
* @method LazyAssertion writeable(string|callable $message = null, string $propertyPath = null) Assert that the value is something writeable.
* @method LazyAssertion all() Switch chain into validation mode for an array of values.
* @method LazyAssertion nullOr() Switch chain into mode allowing nulls, ignoring further assertions.
*/
class LazyAssertion
{
private $currentChainFailed = false;
private $alwaysTryAll = false;
private $thisChainTryAll = false;
private $currentChain;
private $errors = [];
/** @var string The class to use as AssertionChain factory */
private $assertClass = Assert::class;
/** @var string|LazyAssertionException The class to use for exceptions */
private $exceptionClass = LazyAssertionException::class;
/**
* @param mixed $value
* @param string|callable|null $defaultMessage
*
* @return static
*/
public function that($value, string $propertyPath = null, $defaultMessage = null)
{
$this->currentChainFailed = false;
$this->thisChainTryAll = false;
$assertClass = $this->assertClass;
$this->currentChain = $assertClass::that($value, $defaultMessage, $propertyPath);
return $this;
}
/**
* @return static
*/
public function tryAll()
{
if (!$this->currentChain) {
$this->alwaysTryAll = true;
}
$this->thisChainTryAll = true;
return $this;
}
/**
* @param string $method
* @param array $args
*
* @return static
*/
public function __call($method, $args)
{
if (false === $this->alwaysTryAll
&& false === $this->thisChainTryAll
&& true === $this->currentChainFailed
) {
return $this;
}
try {
\call_user_func_array([$this->currentChain, $method], $args);
} catch (AssertionFailedException $e) {
$this->errors[] = $e;
$this->currentChainFailed = true;
}
return $this;
}
/**
* @throws LazyAssertionException
*/
public function verifyNow(): bool
{
if ($this->errors) {
throw \call_user_func([$this->exceptionClass, 'fromErrors'], $this->errors);
}
return true;
}
/**
* @param string $className
*
* @return static
*/
public function setAssertClass(string $className): LazyAssertion
{
if (Assert::class !== $className && !\is_subclass_of($className, Assert::class)) {
throw new LogicException($className.' is not (a subclass of) '.Assert::class);
}
$this->assertClass = $className;
return $this;
}
/**
* @param string $className
*
* @return static
*/
public function setExceptionClass(string $className): LazyAssertion
{
if (LazyAssertionException::class !== $className && !\is_subclass_of($className, LazyAssertionException::class)) {
throw new LogicException($className.' is not (a subclass of) '.LazyAssertionException::class);
}
$this->exceptionClass = $className;
return $this;
}
}

View File

@ -1,53 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
class LazyAssertionException extends InvalidArgumentException
{
/**
* @var InvalidArgumentException[]
*/
private $errors = [];
/**
* @param InvalidArgumentException[] $errors
*/
public static function fromErrors(array $errors): self
{
$message = \sprintf('The following %d assertions failed:', \count($errors))."\n";
$i = 1;
foreach ($errors as $error) {
$message .= \sprintf("%d) %s: %s\n", $i++, $error->getPropertyPath(), $error->getMessage());
}
return new static($message, $errors);
}
public function __construct($message, array $errors)
{
parent::__construct($message, 0, null, null);
$this->errors = $errors;
}
/**
* @return InvalidArgumentException[]
*/
public function getErrorExceptions(): array
{
return $this->errors;
}
}

View File

@ -1,72 +0,0 @@
<?php
/**
* Assert
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/
namespace Assert;
/**
* Start validation on a value, returns {@link AssertionChain}.
*
* The invocation of this method starts an assertion chain
* that is happening on the passed value.
*
* @param mixed $value
* @param string|callable|null $defaultMessage
* @param string $defaultPropertyPath
*
* @example
*
* \Assert\that($value)->notEmpty()->integer();
* \Assert\that($value)->nullOr()->string()->startsWith("Foo");
*
* The assertion chain can be stateful, that means be careful when you reuse
* it. You should never pass around the chain.
*/
function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
return Assert::that($value, $defaultMessage, $defaultPropertyPath);
}
/**
* Start validation on a set of values, returns {@link AssertionChain}.
*
* @param mixed $values
* @param string|callable|null $defaultMessage
* @param string $defaultPropertyPath
*/
function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
return Assert::thatAll($values, $defaultMessage, $defaultPropertyPath);
}
/**
* Start validation and allow NULL, returns {@link AssertionChain}.
*
* @param mixed $value
* @param string|callable|null $defaultMessage
* @param string $defaultPropertyPath
*
* @deprecated In favour of Assert::thatNullOr($value, $defaultMessage = null, $defaultPropertyPath = null)
*/
function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
return Assert::thatNullOr($value, $defaultMessage, $defaultPropertyPath);
}
/**
* Create a lazy assertion object.
*/
function lazy(): LazyAssertion
{
return Assert::lazy();
}

View File

@ -8,13 +8,6 @@ $baseDir = dirname($vendorDir);
return array(
'API' => $baseDir . '/classes/API.php',
'Article' => $baseDir . '/classes/Article.php',
'Assert\\Assert' => $vendorDir . '/beberlei/assert/lib/Assert/Assert.php',
'Assert\\Assertion' => $vendorDir . '/beberlei/assert/lib/Assert/Assertion.php',
'Assert\\AssertionChain' => $vendorDir . '/beberlei/assert/lib/Assert/AssertionChain.php',
'Assert\\AssertionFailedException' => $vendorDir . '/beberlei/assert/lib/Assert/AssertionFailedException.php',
'Assert\\InvalidArgumentException' => $vendorDir . '/beberlei/assert/lib/Assert/InvalidArgumentException.php',
'Assert\\LazyAssertion' => $vendorDir . '/beberlei/assert/lib/Assert/LazyAssertion.php',
'Assert\\LazyAssertionException' => $vendorDir . '/beberlei/assert/lib/Assert/LazyAssertionException.php',
'Auth_Base' => $baseDir . '/classes/Auth_Base.php',
'Cache_Adapter' => $baseDir . '/classes/Cache_Adapter.php',
'Cache_Local' => $baseDir . '/classes/Cache_Local.php',
@ -176,11 +169,13 @@ return array(
'OTPHP\\FactoryInterface' => $vendorDir . '/spomky-labs/otphp/src/FactoryInterface.php',
'OTPHP\\HOTP' => $vendorDir . '/spomky-labs/otphp/src/HOTP.php',
'OTPHP\\HOTPInterface' => $vendorDir . '/spomky-labs/otphp/src/HOTPInterface.php',
'OTPHP\\InternalClock' => $vendorDir . '/spomky-labs/otphp/src/InternalClock.php',
'OTPHP\\OTP' => $vendorDir . '/spomky-labs/otphp/src/OTP.php',
'OTPHP\\OTPInterface' => $vendorDir . '/spomky-labs/otphp/src/OTPInterface.php',
'OTPHP\\ParameterTrait' => $vendorDir . '/spomky-labs/otphp/src/ParameterTrait.php',
'OTPHP\\TOTP' => $vendorDir . '/spomky-labs/otphp/src/TOTP.php',
'OTPHP\\TOTPInterface' => $vendorDir . '/spomky-labs/otphp/src/TOTPInterface.php',
'OTPHP\\Url' => $vendorDir . '/spomky-labs/otphp/src/Url.php',
'PHPUnit\\Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php',
'PHPUnit\\Framework\\ActualValueIsNotAnObjectException' => $vendorDir . '/phpunit/phpunit/src/Framework/Exception/ActualValueIsNotAnObjectException.php',
'PHPUnit\\Framework\\Assert' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert.php',
@ -963,6 +958,7 @@ return array(
'Prophecy\\Prophet' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Prophet.php',
'Prophecy\\Util\\ExportUtil' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php',
'Prophecy\\Util\\StringUtil' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Util/StringUtil.php',
'Psr\\Clock\\ClockInterface' => $vendorDir . '/psr/clock/src/ClockInterface.php',
'Psr\\Http\\Client\\ClientExceptionInterface' => $vendorDir . '/psr/http-client/src/ClientExceptionInterface.php',
'Psr\\Http\\Client\\ClientInterface' => $vendorDir . '/psr/http-client/src/ClientInterface.php',
'Psr\\Http\\Client\\NetworkExceptionInterface' => $vendorDir . '/psr/http-client/src/NetworkExceptionInterface.php',
@ -982,93 +978,6 @@ return array(
'Psr\\Http\\Message\\UriInterface' => $vendorDir . '/psr/http-message/src/UriInterface.php',
'RPC' => $baseDir . '/classes/RPC.php',
'RSSUtils' => $baseDir . '/classes/RSSUtils.php',
'Safe\\DateTime' => $vendorDir . '/thecodingmachine/safe/lib/DateTime.php',
'Safe\\DateTimeImmutable' => $vendorDir . '/thecodingmachine/safe/lib/DateTimeImmutable.php',
'Safe\\Exceptions\\ApacheException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ApacheException.php',
'Safe\\Exceptions\\ApcException' => $vendorDir . '/thecodingmachine/safe/deprecated/Exceptions/ApcException.php',
'Safe\\Exceptions\\ApcuException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ApcuException.php',
'Safe\\Exceptions\\ArrayException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ArrayException.php',
'Safe\\Exceptions\\Bzip2Exception' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/Bzip2Exception.php',
'Safe\\Exceptions\\CalendarException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/CalendarException.php',
'Safe\\Exceptions\\ClassobjException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ClassobjException.php',
'Safe\\Exceptions\\ComException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ComException.php',
'Safe\\Exceptions\\CubridException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/CubridException.php',
'Safe\\Exceptions\\CurlException' => $vendorDir . '/thecodingmachine/safe/lib/Exceptions/CurlException.php',
'Safe\\Exceptions\\DatetimeException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/DatetimeException.php',
'Safe\\Exceptions\\DirException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/DirException.php',
'Safe\\Exceptions\\EioException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/EioException.php',
'Safe\\Exceptions\\ErrorfuncException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ErrorfuncException.php',
'Safe\\Exceptions\\ExecException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ExecException.php',
'Safe\\Exceptions\\FileinfoException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/FileinfoException.php',
'Safe\\Exceptions\\FilesystemException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/FilesystemException.php',
'Safe\\Exceptions\\FilterException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/FilterException.php',
'Safe\\Exceptions\\FpmException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/FpmException.php',
'Safe\\Exceptions\\FtpException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/FtpException.php',
'Safe\\Exceptions\\FunchandException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/FunchandException.php',
'Safe\\Exceptions\\GettextException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/GettextException.php',
'Safe\\Exceptions\\GmpException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/GmpException.php',
'Safe\\Exceptions\\GnupgException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/GnupgException.php',
'Safe\\Exceptions\\HashException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/HashException.php',
'Safe\\Exceptions\\IbaseException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/IbaseException.php',
'Safe\\Exceptions\\IbmDb2Exception' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/IbmDb2Exception.php',
'Safe\\Exceptions\\IconvException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/IconvException.php',
'Safe\\Exceptions\\ImageException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ImageException.php',
'Safe\\Exceptions\\ImapException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ImapException.php',
'Safe\\Exceptions\\InfoException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/InfoException.php',
'Safe\\Exceptions\\InotifyException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/InotifyException.php',
'Safe\\Exceptions\\JsonException' => $vendorDir . '/thecodingmachine/safe/lib/Exceptions/JsonException.php',
'Safe\\Exceptions\\LdapException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/LdapException.php',
'Safe\\Exceptions\\LibeventException' => $vendorDir . '/thecodingmachine/safe/deprecated/Exceptions/LibeventException.php',
'Safe\\Exceptions\\LibxmlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/LibxmlException.php',
'Safe\\Exceptions\\LzfException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/LzfException.php',
'Safe\\Exceptions\\MailparseException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/MailparseException.php',
'Safe\\Exceptions\\MbstringException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/MbstringException.php',
'Safe\\Exceptions\\MiscException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/MiscException.php',
'Safe\\Exceptions\\MssqlException' => $vendorDir . '/thecodingmachine/safe/deprecated/Exceptions/MssqlException.php',
'Safe\\Exceptions\\MysqlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/MysqlException.php',
'Safe\\Exceptions\\MysqliException' => $vendorDir . '/thecodingmachine/safe/deprecated/Exceptions/MysqliException.php',
'Safe\\Exceptions\\NetworkException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/NetworkException.php',
'Safe\\Exceptions\\Oci8Exception' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/Oci8Exception.php',
'Safe\\Exceptions\\OpcacheException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/OpcacheException.php',
'Safe\\Exceptions\\OpensslException' => $vendorDir . '/thecodingmachine/safe/lib/Exceptions/OpensslException.php',
'Safe\\Exceptions\\OutcontrolException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/OutcontrolException.php',
'Safe\\Exceptions\\PasswordException' => $vendorDir . '/thecodingmachine/safe/deprecated/Exceptions/PasswordException.php',
'Safe\\Exceptions\\PcntlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/PcntlException.php',
'Safe\\Exceptions\\PcreException' => $vendorDir . '/thecodingmachine/safe/lib/Exceptions/PcreException.php',
'Safe\\Exceptions\\PgsqlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/PgsqlException.php',
'Safe\\Exceptions\\PosixException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/PosixException.php',
'Safe\\Exceptions\\PsException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/PsException.php',
'Safe\\Exceptions\\PspellException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/PspellException.php',
'Safe\\Exceptions\\ReadlineException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ReadlineException.php',
'Safe\\Exceptions\\RpminfoException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/RpminfoException.php',
'Safe\\Exceptions\\RrdException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/RrdException.php',
'Safe\\Exceptions\\SafeExceptionInterface' => $vendorDir . '/thecodingmachine/safe/lib/Exceptions/SafeExceptionInterface.php',
'Safe\\Exceptions\\SemException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SemException.php',
'Safe\\Exceptions\\SessionException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SessionException.php',
'Safe\\Exceptions\\ShmopException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ShmopException.php',
'Safe\\Exceptions\\SimplexmlException' => $vendorDir . '/thecodingmachine/safe/lib/Exceptions/SimplexmlException.php',
'Safe\\Exceptions\\SocketsException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SocketsException.php',
'Safe\\Exceptions\\SodiumException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SodiumException.php',
'Safe\\Exceptions\\SolrException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SolrException.php',
'Safe\\Exceptions\\SplException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SplException.php',
'Safe\\Exceptions\\SqlsrvException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SqlsrvException.php',
'Safe\\Exceptions\\SsdeepException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SsdeepException.php',
'Safe\\Exceptions\\Ssh2Exception' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/Ssh2Exception.php',
'Safe\\Exceptions\\StatsException' => $vendorDir . '/thecodingmachine/safe/deprecated/Exceptions/StatsException.php',
'Safe\\Exceptions\\StreamException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/StreamException.php',
'Safe\\Exceptions\\StringsException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/StringsException.php',
'Safe\\Exceptions\\SwooleException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/SwooleException.php',
'Safe\\Exceptions\\UodbcException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/UodbcException.php',
'Safe\\Exceptions\\UopzException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/UopzException.php',
'Safe\\Exceptions\\UrlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/UrlException.php',
'Safe\\Exceptions\\VarException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/VarException.php',
'Safe\\Exceptions\\XdiffException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/XdiffException.php',
'Safe\\Exceptions\\XmlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/XmlException.php',
'Safe\\Exceptions\\XmlrpcException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/XmlrpcException.php',
'Safe\\Exceptions\\YamlException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/YamlException.php',
'Safe\\Exceptions\\YazException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/YazException.php',
'Safe\\Exceptions\\ZipException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ZipException.php',
'Safe\\Exceptions\\ZlibException' => $vendorDir . '/thecodingmachine/safe/generated/Exceptions/ZlibException.php',
'Sanitizer' => $baseDir . '/classes/Sanitizer.php',
'SebastianBergmann\\CliParser\\AmbiguousOptionException' => $vendorDir . '/sebastian/cli-parser/src/exceptions/AmbiguousOptionException.php',
'SebastianBergmann\\CliParser\\Exception' => $vendorDir . '/sebastian/cli-parser/src/exceptions/Exception.php',

View File

@ -7,96 +7,8 @@ $baseDir = dirname($vendorDir);
return array(
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'a4ecaeafb8cfb009ad0e052c90355e98' => $vendorDir . '/beberlei/assert/lib/Assert/functions.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'51fcf4e06c07cc00c920b44bcd900e7a' => $vendorDir . '/thecodingmachine/safe/deprecated/apc.php',
'288267919fedd3829a7732b5fb202197' => $vendorDir . '/thecodingmachine/safe/deprecated/array.php',
'a88cd08cfbf1600f7d5de6e587eee1fa' => $vendorDir . '/thecodingmachine/safe/deprecated/datetime.php',
'47f619d9197b36cf5ab70738d7743fe2' => $vendorDir . '/thecodingmachine/safe/deprecated/libevent.php',
'213c1c2258e2e5aa409a0af3e993b3a9' => $vendorDir . '/thecodingmachine/safe/deprecated/password.php',
'ea6bb8a12ef9b68f6ada99058e530760' => $vendorDir . '/thecodingmachine/safe/deprecated/mssql.php',
'9a29089eb3ce41a446744c68a00f118c' => $vendorDir . '/thecodingmachine/safe/deprecated/stats.php',
'd5947c9df62650029c674c79176af68d' => $vendorDir . '/thecodingmachine/safe/deprecated/strings.php',
'72243e5536b63e298acb6476f01f1aff' => $vendorDir . '/thecodingmachine/safe/lib/special_cases.php',
'09f92ed6301edc510574c196c2b7d1af' => $vendorDir . '/thecodingmachine/safe/deprecated/mysqli.php',
'3f648889e687f31c52f949ba8a9d0873' => $vendorDir . '/thecodingmachine/safe/generated/apache.php',
'eeb4581d958421a4244aaa4167c6a575' => $vendorDir . '/thecodingmachine/safe/generated/apcu.php',
'04cb0b3c1dac5b5ddb23c14e3d66dbe9' => $vendorDir . '/thecodingmachine/safe/generated/array.php',
'450b332a74a9a21e043c5e953485a791' => $vendorDir . '/thecodingmachine/safe/generated/bzip2.php',
'6e9b7954ecfd7cbb9ca239319d1acdb6' => $vendorDir . '/thecodingmachine/safe/generated/calendar.php',
'2c6d7e8bd2de9a272a9d4d43b0a4304a' => $vendorDir . '/thecodingmachine/safe/generated/classobj.php',
'0b8231c1ad0865447c988a4c16b4001f' => $vendorDir . '/thecodingmachine/safe/generated/com.php',
'7643a71fe1c3256058c8fee234cb86e5' => $vendorDir . '/thecodingmachine/safe/generated/cubrid.php',
'68e1365710575942efc1d55000032cee' => $vendorDir . '/thecodingmachine/safe/generated/curl.php',
'02fd26bca803106c5b942a7197c3ad8b' => $vendorDir . '/thecodingmachine/safe/generated/datetime.php',
'f4817dcbd956cd221b1c31f6fbd5749c' => $vendorDir . '/thecodingmachine/safe/generated/dir.php',
'51c3f2d10ca61a70dbcea0e38d8e902d' => $vendorDir . '/thecodingmachine/safe/generated/eio.php',
'1d34f34327ca3e81535963016e3be2c3' => $vendorDir . '/thecodingmachine/safe/generated/errorfunc.php',
'4fd0ba2d3717b0424d474bebfdafa2b4' => $vendorDir . '/thecodingmachine/safe/generated/exec.php',
'98f4dae054bc7fb19c13be14935cbdd3' => $vendorDir . '/thecodingmachine/safe/generated/fileinfo.php',
'5530ae063ba88323eaf0a07904efdf85' => $vendorDir . '/thecodingmachine/safe/generated/filesystem.php',
'633f4f134975d70e97bddad83348e91a' => $vendorDir . '/thecodingmachine/safe/generated/filter.php',
'fbd163fc68c5faf73d5ed4002ffd836d' => $vendorDir . '/thecodingmachine/safe/generated/fpm.php',
'21b511999d61411fab0692ff8795bbed' => $vendorDir . '/thecodingmachine/safe/generated/ftp.php',
'85fbd73fc92365cd90526b0ea03cae3a' => $vendorDir . '/thecodingmachine/safe/generated/funchand.php',
'a2e4c6dfdbf36f56f1945ddcbd54e289' => $vendorDir . '/thecodingmachine/safe/generated/gettext.php',
'51df9c146e0b7dcbdf358d8abd24dbdc' => $vendorDir . '/thecodingmachine/safe/generated/gmp.php',
'93bb7fe678d7dcfb1322f8e3475a48b0' => $vendorDir . '/thecodingmachine/safe/generated/gnupg.php',
'c171ba99cf316379ff66468392bf4950' => $vendorDir . '/thecodingmachine/safe/generated/hash.php',
'5ab4aad4c28e468209fbfcceb2e5e6a5' => $vendorDir . '/thecodingmachine/safe/generated/ibase.php',
'4d57409c5e8e576b0c64c08d9d731cfb' => $vendorDir . '/thecodingmachine/safe/generated/ibmDb2.php',
'eeb246d5403972a9d62106e4a4883496' => $vendorDir . '/thecodingmachine/safe/generated/iconv.php',
'c28a05f498c01b810a714f7214b7a8da' => $vendorDir . '/thecodingmachine/safe/generated/image.php',
'8063cd92acdf00fd978b5599eb7cc142' => $vendorDir . '/thecodingmachine/safe/generated/imap.php',
'8bd26dbe768e9c9599edad7b198e5446' => $vendorDir . '/thecodingmachine/safe/generated/info.php',
'd4362910bde43c0f956b52527effd7d4' => $vendorDir . '/thecodingmachine/safe/generated/inotify.php',
'696ba49197d9b55f0428a12bb5a818e1' => $vendorDir . '/thecodingmachine/safe/generated/json.php',
'9818aaa99c8647c63f8ef62b7a368160' => $vendorDir . '/thecodingmachine/safe/generated/ldap.php',
'bcf523ff2a195eb08e0fbb668ed784d0' => $vendorDir . '/thecodingmachine/safe/generated/libxml.php',
'68be68a9a8b95bb56cab6109ff03bc88' => $vendorDir . '/thecodingmachine/safe/generated/lzf.php',
'bdca804bb0904ea9f53f328dfc0bb8a5' => $vendorDir . '/thecodingmachine/safe/generated/mailparse.php',
'b0a3fcac3eaf55445796d6af26b89366' => $vendorDir . '/thecodingmachine/safe/generated/mbstring.php',
'98de16b8db03eb0cb4d318b4402215a6' => $vendorDir . '/thecodingmachine/safe/generated/misc.php',
'7cefd81607cd21b8b3a15656eb6465f5' => $vendorDir . '/thecodingmachine/safe/generated/mysql.php',
'cbac956836b72483dcff1ac39d5c0a0f' => $vendorDir . '/thecodingmachine/safe/generated/network.php',
'6c8f89dfbdc117d7871f572269363f25' => $vendorDir . '/thecodingmachine/safe/generated/oci8.php',
'169a669966a45c06bf55ed029122729b' => $vendorDir . '/thecodingmachine/safe/generated/opcache.php',
'def61bf4fecd4d4bca7354919cd69302' => $vendorDir . '/thecodingmachine/safe/generated/openssl.php',
'26bb010649a6d32d4120181458aa6ef2' => $vendorDir . '/thecodingmachine/safe/generated/outcontrol.php',
'002ebcb842e2c0d5b7f67fe64cc93158' => $vendorDir . '/thecodingmachine/safe/generated/pcntl.php',
'86df38612982dade72c7085ce7eca81f' => $vendorDir . '/thecodingmachine/safe/generated/pcre.php',
'1fc22f445c69ea8706e82fce301c0831' => $vendorDir . '/thecodingmachine/safe/generated/pgsql.php',
'c70b42561584f7144bff38cd63c4eef3' => $vendorDir . '/thecodingmachine/safe/generated/posix.php',
'9923214639c32ca5173db03a177d3b63' => $vendorDir . '/thecodingmachine/safe/generated/ps.php',
'7e9c3f8eae2b5bf42205c4f1295cb7a7' => $vendorDir . '/thecodingmachine/safe/generated/pspell.php',
'91aa91f6245c349c2e2e88bd0025f199' => $vendorDir . '/thecodingmachine/safe/generated/readline.php',
'd43773cacb9e5e8e897aa255e32007d1' => $vendorDir . '/thecodingmachine/safe/generated/rpminfo.php',
'f053a3849e9e8383762b34b91db0320b' => $vendorDir . '/thecodingmachine/safe/generated/rrd.php',
'775b964f72f827a1bf87c65ab5b10800' => $vendorDir . '/thecodingmachine/safe/generated/sem.php',
'816428bd69c29ab5e1ed622af5dca0cd' => $vendorDir . '/thecodingmachine/safe/generated/session.php',
'5093e233bedbefaef0df262bfbab0a5c' => $vendorDir . '/thecodingmachine/safe/generated/shmop.php',
'b080617b1d949683c2e37f8f01dc0e15' => $vendorDir . '/thecodingmachine/safe/generated/sockets.php',
'2708aa182ddcfe6ce27c96acaaa40f69' => $vendorDir . '/thecodingmachine/safe/generated/sodium.php',
'f1b96cb260a5baeea9a7285cda82a1ec' => $vendorDir . '/thecodingmachine/safe/generated/solr.php',
'3fd8853757d0fe3557c179efb807afeb' => $vendorDir . '/thecodingmachine/safe/generated/spl.php',
'9312ce96a51c846913fcda5f186d58dd' => $vendorDir . '/thecodingmachine/safe/generated/sqlsrv.php',
'd3eb383ad0b8b962b29dc4afd29d6715' => $vendorDir . '/thecodingmachine/safe/generated/ssdeep.php',
'42a09bc448f441a0b9f9367ea975c0bf' => $vendorDir . '/thecodingmachine/safe/generated/ssh2.php',
'ef711077d356d1b33ca0b10b67b0be8f' => $vendorDir . '/thecodingmachine/safe/generated/stream.php',
'764b09f6df081cbb2807b97c6ace3866' => $vendorDir . '/thecodingmachine/safe/generated/strings.php',
'ef241678769fee4a44aaa288f3b78aa1' => $vendorDir . '/thecodingmachine/safe/generated/swoole.php',
'0efc8f6778cba932b9e2a89e28de2452' => $vendorDir . '/thecodingmachine/safe/generated/uodbc.php',
'd383d32907b98af53ee9208c62204fd0' => $vendorDir . '/thecodingmachine/safe/generated/uopz.php',
'2fd2e4060f7fe772660f002ce38f0b71' => $vendorDir . '/thecodingmachine/safe/generated/url.php',
'782249e03deebeaf57b9991ff5493aa0' => $vendorDir . '/thecodingmachine/safe/generated/var.php',
'344440cd1cd7200fdb4f12af0d3c587f' => $vendorDir . '/thecodingmachine/safe/generated/xdiff.php',
'3599f369219c658a5fb6c4fe66832f62' => $vendorDir . '/thecodingmachine/safe/generated/xml.php',
'7fcd313da9fae337051b091b3492c21b' => $vendorDir . '/thecodingmachine/safe/generated/xmlrpc.php',
'd668c74cfa92d893b582356733d9a80e' => $vendorDir . '/thecodingmachine/safe/generated/yaml.php',
'4af1dca6db8c527c6eed27bff85ff0e5' => $vendorDir . '/thecodingmachine/safe/generated/yaz.php',
'fe43ca06499ac37bc2dedd823af71eb5' => $vendorDir . '/thecodingmachine/safe/generated/zip.php',
'356736db98a6834f0a886b8d509b0ecd' => $vendorDir . '/thecodingmachine/safe/generated/zlib.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',

View File

@ -13,6 +13,7 @@ return array(
'Soundasleep\\' => array($vendorDir . '/soundasleep/html2text/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'),
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
'ParagonIE\\ConstantTime\\' => array($vendorDir . '/paragonie/constant_time_encoding/src'),
@ -22,6 +23,5 @@ return array(
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'Assert\\' => array($vendorDir . '/beberlei/assert/lib/Assert'),
'' => array($baseDir . '/classes'),
);

View File

@ -8,96 +8,8 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
{
public static $files = array (
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'a4ecaeafb8cfb009ad0e052c90355e98' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php',
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'51fcf4e06c07cc00c920b44bcd900e7a' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/apc.php',
'288267919fedd3829a7732b5fb202197' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/array.php',
'a88cd08cfbf1600f7d5de6e587eee1fa' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/datetime.php',
'47f619d9197b36cf5ab70738d7743fe2' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/libevent.php',
'213c1c2258e2e5aa409a0af3e993b3a9' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/password.php',
'ea6bb8a12ef9b68f6ada99058e530760' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/mssql.php',
'9a29089eb3ce41a446744c68a00f118c' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/stats.php',
'd5947c9df62650029c674c79176af68d' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/strings.php',
'72243e5536b63e298acb6476f01f1aff' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/special_cases.php',
'09f92ed6301edc510574c196c2b7d1af' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/mysqli.php',
'3f648889e687f31c52f949ba8a9d0873' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/apache.php',
'eeb4581d958421a4244aaa4167c6a575' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/apcu.php',
'04cb0b3c1dac5b5ddb23c14e3d66dbe9' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/array.php',
'450b332a74a9a21e043c5e953485a791' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/bzip2.php',
'6e9b7954ecfd7cbb9ca239319d1acdb6' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/calendar.php',
'2c6d7e8bd2de9a272a9d4d43b0a4304a' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/classobj.php',
'0b8231c1ad0865447c988a4c16b4001f' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/com.php',
'7643a71fe1c3256058c8fee234cb86e5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/cubrid.php',
'68e1365710575942efc1d55000032cee' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/curl.php',
'02fd26bca803106c5b942a7197c3ad8b' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/datetime.php',
'f4817dcbd956cd221b1c31f6fbd5749c' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/dir.php',
'51c3f2d10ca61a70dbcea0e38d8e902d' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/eio.php',
'1d34f34327ca3e81535963016e3be2c3' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/errorfunc.php',
'4fd0ba2d3717b0424d474bebfdafa2b4' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/exec.php',
'98f4dae054bc7fb19c13be14935cbdd3' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/fileinfo.php',
'5530ae063ba88323eaf0a07904efdf85' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/filesystem.php',
'633f4f134975d70e97bddad83348e91a' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/filter.php',
'fbd163fc68c5faf73d5ed4002ffd836d' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/fpm.php',
'21b511999d61411fab0692ff8795bbed' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ftp.php',
'85fbd73fc92365cd90526b0ea03cae3a' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/funchand.php',
'a2e4c6dfdbf36f56f1945ddcbd54e289' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/gettext.php',
'51df9c146e0b7dcbdf358d8abd24dbdc' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/gmp.php',
'93bb7fe678d7dcfb1322f8e3475a48b0' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/gnupg.php',
'c171ba99cf316379ff66468392bf4950' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/hash.php',
'5ab4aad4c28e468209fbfcceb2e5e6a5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ibase.php',
'4d57409c5e8e576b0c64c08d9d731cfb' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ibmDb2.php',
'eeb246d5403972a9d62106e4a4883496' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/iconv.php',
'c28a05f498c01b810a714f7214b7a8da' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/image.php',
'8063cd92acdf00fd978b5599eb7cc142' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/imap.php',
'8bd26dbe768e9c9599edad7b198e5446' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/info.php',
'd4362910bde43c0f956b52527effd7d4' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/inotify.php',
'696ba49197d9b55f0428a12bb5a818e1' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/json.php',
'9818aaa99c8647c63f8ef62b7a368160' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ldap.php',
'bcf523ff2a195eb08e0fbb668ed784d0' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/libxml.php',
'68be68a9a8b95bb56cab6109ff03bc88' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/lzf.php',
'bdca804bb0904ea9f53f328dfc0bb8a5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/mailparse.php',
'b0a3fcac3eaf55445796d6af26b89366' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/mbstring.php',
'98de16b8db03eb0cb4d318b4402215a6' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/misc.php',
'7cefd81607cd21b8b3a15656eb6465f5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/mysql.php',
'cbac956836b72483dcff1ac39d5c0a0f' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/network.php',
'6c8f89dfbdc117d7871f572269363f25' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/oci8.php',
'169a669966a45c06bf55ed029122729b' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/opcache.php',
'def61bf4fecd4d4bca7354919cd69302' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/openssl.php',
'26bb010649a6d32d4120181458aa6ef2' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/outcontrol.php',
'002ebcb842e2c0d5b7f67fe64cc93158' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/pcntl.php',
'86df38612982dade72c7085ce7eca81f' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/pcre.php',
'1fc22f445c69ea8706e82fce301c0831' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/pgsql.php',
'c70b42561584f7144bff38cd63c4eef3' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/posix.php',
'9923214639c32ca5173db03a177d3b63' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ps.php',
'7e9c3f8eae2b5bf42205c4f1295cb7a7' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/pspell.php',
'91aa91f6245c349c2e2e88bd0025f199' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/readline.php',
'd43773cacb9e5e8e897aa255e32007d1' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/rpminfo.php',
'f053a3849e9e8383762b34b91db0320b' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/rrd.php',
'775b964f72f827a1bf87c65ab5b10800' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/sem.php',
'816428bd69c29ab5e1ed622af5dca0cd' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/session.php',
'5093e233bedbefaef0df262bfbab0a5c' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/shmop.php',
'b080617b1d949683c2e37f8f01dc0e15' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/sockets.php',
'2708aa182ddcfe6ce27c96acaaa40f69' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/sodium.php',
'f1b96cb260a5baeea9a7285cda82a1ec' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/solr.php',
'3fd8853757d0fe3557c179efb807afeb' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/spl.php',
'9312ce96a51c846913fcda5f186d58dd' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/sqlsrv.php',
'd3eb383ad0b8b962b29dc4afd29d6715' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ssdeep.php',
'42a09bc448f441a0b9f9367ea975c0bf' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/ssh2.php',
'ef711077d356d1b33ca0b10b67b0be8f' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/stream.php',
'764b09f6df081cbb2807b97c6ace3866' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/strings.php',
'ef241678769fee4a44aaa288f3b78aa1' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/swoole.php',
'0efc8f6778cba932b9e2a89e28de2452' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/uodbc.php',
'd383d32907b98af53ee9208c62204fd0' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/uopz.php',
'2fd2e4060f7fe772660f002ce38f0b71' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/url.php',
'782249e03deebeaf57b9991ff5493aa0' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/var.php',
'344440cd1cd7200fdb4f12af0d3c587f' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/xdiff.php',
'3599f369219c658a5fb6c4fe66832f62' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/xml.php',
'7fcd313da9fae337051b091b3492c21b' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/xmlrpc.php',
'd668c74cfa92d893b582356733d9a80e' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/yaml.php',
'4af1dca6db8c527c6eed27bff85ff0e5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/yaz.php',
'fe43ca06499ac37bc2dedd823af71eb5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/zip.php',
'356736db98a6834f0a886b8d509b0ecd' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/zlib.php',
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
@ -126,6 +38,7 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
array (
'Psr\\Http\\Message\\' => 17,
'Psr\\Http\\Client\\' => 16,
'Psr\\Clock\\' => 10,
'Prophecy\\' => 9,
'PhpParser\\' => 10,
'ParagonIE\\ConstantTime\\' => 23,
@ -145,10 +58,6 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
'Doctrine\\Instantiator\\' => 22,
'DeepCopy\\' => 9,
),
'A' =>
array (
'Assert\\' => 7,
),
);
public static $prefixDirsPsr4 = array (
@ -183,6 +92,10 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
array (
0 => __DIR__ . '/..' . '/psr/http-client/src',
),
'Psr\\Clock\\' =>
array (
0 => __DIR__ . '/..' . '/psr/clock/src',
),
'Prophecy\\' =>
array (
0 => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy',
@ -219,10 +132,6 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
array (
0 => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy',
),
'Assert\\' =>
array (
0 => __DIR__ . '/..' . '/beberlei/assert/lib/Assert',
),
);
public static $fallbackDirsPsr4 = array (
@ -232,13 +141,6 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
public static $classMap = array (
'API' => __DIR__ . '/../..' . '/classes/API.php',
'Article' => __DIR__ . '/../..' . '/classes/Article.php',
'Assert\\Assert' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/Assert.php',
'Assert\\Assertion' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/Assertion.php',
'Assert\\AssertionChain' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/AssertionChain.php',
'Assert\\AssertionFailedException' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/AssertionFailedException.php',
'Assert\\InvalidArgumentException' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/InvalidArgumentException.php',
'Assert\\LazyAssertion' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/LazyAssertion.php',
'Assert\\LazyAssertionException' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/LazyAssertionException.php',
'Auth_Base' => __DIR__ . '/../..' . '/classes/Auth_Base.php',
'Cache_Adapter' => __DIR__ . '/../..' . '/classes/Cache_Adapter.php',
'Cache_Local' => __DIR__ . '/../..' . '/classes/Cache_Local.php',
@ -400,11 +302,13 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
'OTPHP\\FactoryInterface' => __DIR__ . '/..' . '/spomky-labs/otphp/src/FactoryInterface.php',
'OTPHP\\HOTP' => __DIR__ . '/..' . '/spomky-labs/otphp/src/HOTP.php',
'OTPHP\\HOTPInterface' => __DIR__ . '/..' . '/spomky-labs/otphp/src/HOTPInterface.php',
'OTPHP\\InternalClock' => __DIR__ . '/..' . '/spomky-labs/otphp/src/InternalClock.php',
'OTPHP\\OTP' => __DIR__ . '/..' . '/spomky-labs/otphp/src/OTP.php',
'OTPHP\\OTPInterface' => __DIR__ . '/..' . '/spomky-labs/otphp/src/OTPInterface.php',
'OTPHP\\ParameterTrait' => __DIR__ . '/..' . '/spomky-labs/otphp/src/ParameterTrait.php',
'OTPHP\\TOTP' => __DIR__ . '/..' . '/spomky-labs/otphp/src/TOTP.php',
'OTPHP\\TOTPInterface' => __DIR__ . '/..' . '/spomky-labs/otphp/src/TOTPInterface.php',
'OTPHP\\Url' => __DIR__ . '/..' . '/spomky-labs/otphp/src/Url.php',
'PHPUnit\\Exception' => __DIR__ . '/..' . '/phpunit/phpunit/src/Exception.php',
'PHPUnit\\Framework\\ActualValueIsNotAnObjectException' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Exception/ActualValueIsNotAnObjectException.php',
'PHPUnit\\Framework\\Assert' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert.php',
@ -1187,6 +1091,7 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
'Prophecy\\Prophet' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Prophet.php',
'Prophecy\\Util\\ExportUtil' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php',
'Prophecy\\Util\\StringUtil' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Util/StringUtil.php',
'Psr\\Clock\\ClockInterface' => __DIR__ . '/..' . '/psr/clock/src/ClockInterface.php',
'Psr\\Http\\Client\\ClientExceptionInterface' => __DIR__ . '/..' . '/psr/http-client/src/ClientExceptionInterface.php',
'Psr\\Http\\Client\\ClientInterface' => __DIR__ . '/..' . '/psr/http-client/src/ClientInterface.php',
'Psr\\Http\\Client\\NetworkExceptionInterface' => __DIR__ . '/..' . '/psr/http-client/src/NetworkExceptionInterface.php',
@ -1206,93 +1111,6 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
'Psr\\Http\\Message\\UriInterface' => __DIR__ . '/..' . '/psr/http-message/src/UriInterface.php',
'RPC' => __DIR__ . '/../..' . '/classes/RPC.php',
'RSSUtils' => __DIR__ . '/../..' . '/classes/RSSUtils.php',
'Safe\\DateTime' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/DateTime.php',
'Safe\\DateTimeImmutable' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/DateTimeImmutable.php',
'Safe\\Exceptions\\ApacheException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ApacheException.php',
'Safe\\Exceptions\\ApcException' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/Exceptions/ApcException.php',
'Safe\\Exceptions\\ApcuException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ApcuException.php',
'Safe\\Exceptions\\ArrayException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ArrayException.php',
'Safe\\Exceptions\\Bzip2Exception' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/Bzip2Exception.php',
'Safe\\Exceptions\\CalendarException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/CalendarException.php',
'Safe\\Exceptions\\ClassobjException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ClassobjException.php',
'Safe\\Exceptions\\ComException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ComException.php',
'Safe\\Exceptions\\CubridException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/CubridException.php',
'Safe\\Exceptions\\CurlException' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/Exceptions/CurlException.php',
'Safe\\Exceptions\\DatetimeException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/DatetimeException.php',
'Safe\\Exceptions\\DirException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/DirException.php',
'Safe\\Exceptions\\EioException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/EioException.php',
'Safe\\Exceptions\\ErrorfuncException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ErrorfuncException.php',
'Safe\\Exceptions\\ExecException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ExecException.php',
'Safe\\Exceptions\\FileinfoException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/FileinfoException.php',
'Safe\\Exceptions\\FilesystemException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/FilesystemException.php',
'Safe\\Exceptions\\FilterException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/FilterException.php',
'Safe\\Exceptions\\FpmException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/FpmException.php',
'Safe\\Exceptions\\FtpException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/FtpException.php',
'Safe\\Exceptions\\FunchandException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/FunchandException.php',
'Safe\\Exceptions\\GettextException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/GettextException.php',
'Safe\\Exceptions\\GmpException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/GmpException.php',
'Safe\\Exceptions\\GnupgException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/GnupgException.php',
'Safe\\Exceptions\\HashException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/HashException.php',
'Safe\\Exceptions\\IbaseException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/IbaseException.php',
'Safe\\Exceptions\\IbmDb2Exception' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/IbmDb2Exception.php',
'Safe\\Exceptions\\IconvException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/IconvException.php',
'Safe\\Exceptions\\ImageException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ImageException.php',
'Safe\\Exceptions\\ImapException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ImapException.php',
'Safe\\Exceptions\\InfoException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/InfoException.php',
'Safe\\Exceptions\\InotifyException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/InotifyException.php',
'Safe\\Exceptions\\JsonException' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/Exceptions/JsonException.php',
'Safe\\Exceptions\\LdapException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/LdapException.php',
'Safe\\Exceptions\\LibeventException' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/Exceptions/LibeventException.php',
'Safe\\Exceptions\\LibxmlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/LibxmlException.php',
'Safe\\Exceptions\\LzfException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/LzfException.php',
'Safe\\Exceptions\\MailparseException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/MailparseException.php',
'Safe\\Exceptions\\MbstringException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/MbstringException.php',
'Safe\\Exceptions\\MiscException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/MiscException.php',
'Safe\\Exceptions\\MssqlException' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/Exceptions/MssqlException.php',
'Safe\\Exceptions\\MysqlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/MysqlException.php',
'Safe\\Exceptions\\MysqliException' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/Exceptions/MysqliException.php',
'Safe\\Exceptions\\NetworkException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/NetworkException.php',
'Safe\\Exceptions\\Oci8Exception' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/Oci8Exception.php',
'Safe\\Exceptions\\OpcacheException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/OpcacheException.php',
'Safe\\Exceptions\\OpensslException' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/Exceptions/OpensslException.php',
'Safe\\Exceptions\\OutcontrolException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/OutcontrolException.php',
'Safe\\Exceptions\\PasswordException' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/Exceptions/PasswordException.php',
'Safe\\Exceptions\\PcntlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/PcntlException.php',
'Safe\\Exceptions\\PcreException' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/Exceptions/PcreException.php',
'Safe\\Exceptions\\PgsqlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/PgsqlException.php',
'Safe\\Exceptions\\PosixException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/PosixException.php',
'Safe\\Exceptions\\PsException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/PsException.php',
'Safe\\Exceptions\\PspellException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/PspellException.php',
'Safe\\Exceptions\\ReadlineException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ReadlineException.php',
'Safe\\Exceptions\\RpminfoException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/RpminfoException.php',
'Safe\\Exceptions\\RrdException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/RrdException.php',
'Safe\\Exceptions\\SafeExceptionInterface' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/Exceptions/SafeExceptionInterface.php',
'Safe\\Exceptions\\SemException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SemException.php',
'Safe\\Exceptions\\SessionException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SessionException.php',
'Safe\\Exceptions\\ShmopException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ShmopException.php',
'Safe\\Exceptions\\SimplexmlException' => __DIR__ . '/..' . '/thecodingmachine/safe/lib/Exceptions/SimplexmlException.php',
'Safe\\Exceptions\\SocketsException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SocketsException.php',
'Safe\\Exceptions\\SodiumException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SodiumException.php',
'Safe\\Exceptions\\SolrException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SolrException.php',
'Safe\\Exceptions\\SplException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SplException.php',
'Safe\\Exceptions\\SqlsrvException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SqlsrvException.php',
'Safe\\Exceptions\\SsdeepException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SsdeepException.php',
'Safe\\Exceptions\\Ssh2Exception' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/Ssh2Exception.php',
'Safe\\Exceptions\\StatsException' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/Exceptions/StatsException.php',
'Safe\\Exceptions\\StreamException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/StreamException.php',
'Safe\\Exceptions\\StringsException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/StringsException.php',
'Safe\\Exceptions\\SwooleException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/SwooleException.php',
'Safe\\Exceptions\\UodbcException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/UodbcException.php',
'Safe\\Exceptions\\UopzException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/UopzException.php',
'Safe\\Exceptions\\UrlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/UrlException.php',
'Safe\\Exceptions\\VarException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/VarException.php',
'Safe\\Exceptions\\XdiffException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/XdiffException.php',
'Safe\\Exceptions\\XmlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/XmlException.php',
'Safe\\Exceptions\\XmlrpcException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/XmlrpcException.php',
'Safe\\Exceptions\\YamlException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/YamlException.php',
'Safe\\Exceptions\\YazException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/YazException.php',
'Safe\\Exceptions\\ZipException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ZipException.php',
'Safe\\Exceptions\\ZlibException' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/Exceptions/ZlibException.php',
'Sanitizer' => __DIR__ . '/../..' . '/classes/Sanitizer.php',
'SebastianBergmann\\CliParser\\AmbiguousOptionException' => __DIR__ . '/..' . '/sebastian/cli-parser/src/exceptions/AmbiguousOptionException.php',
'SebastianBergmann\\CliParser\\Exception' => __DIR__ . '/..' . '/sebastian/cli-parser/src/exceptions/Exception.php',

View File

@ -1,75 +1,5 @@
{
"packages": [
{
"name": "beberlei/assert",
"version": "v3.3.2",
"version_normalized": "3.3.2.0",
"source": {
"type": "git",
"url": "https://github.com/beberlei/assert.git",
"reference": "cb70015c04be1baee6f5f5c953703347c0ac1655"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/beberlei/assert/zipball/cb70015c04be1baee6f5f5c953703347c0ac1655",
"reference": "cb70015c04be1baee6f5f5c953703347c0ac1655",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"php": "^7.0 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan": "*",
"phpunit/phpunit": ">=6.0.0",
"yoast/phpunit-polyfills": "^0.1.0"
},
"suggest": {
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles"
},
"time": "2021-12-16T21:41:27+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"lib/Assert/functions.php"
],
"psr-4": {
"Assert\\": "lib/Assert"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de",
"role": "Lead Developer"
},
{
"name": "Richard Quadling",
"email": "rquadling@gmail.com",
"role": "Collaborator"
}
],
"description": "Thin assertion library for input validation in business models.",
"keywords": [
"assert",
"assertion",
"validation"
],
"support": {
"issues": "https://github.com/beberlei/assert/issues",
"source": "https://github.com/beberlei/assert/tree/v3.3.2"
},
"install-path": "../beberlei/assert"
},
{
"name": "chillerlan/php-qrcode",
"version": "5.0.3",
@ -879,27 +809,27 @@
},
{
"name": "paragonie/constant_time_encoding",
"version": "v2.6.3",
"version_normalized": "2.6.3.0",
"version": "v3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "58c3f47f650c94ec05a151692652a868995d2938"
"reference": "df1e7fde177501eee2037dd159cf04f5f301a512"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938",
"reference": "58c3f47f650c94ec05a151692652a868995d2938",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512",
"reference": "df1e7fde177501eee2037dd159cf04f5f301a512",
"shasum": ""
},
"require": {
"php": "^7|^8"
"php": "^8"
},
"require-dev": {
"phpunit/phpunit": "^6|^7|^8|^9",
"vimeo/psalm": "^1|^2|^3|^4"
"phpunit/phpunit": "^9",
"vimeo/psalm": "^4|^5"
},
"time": "2022-06-14T06:56:20+00:00",
"time": "2024-05-08T12:36:18+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1803,6 +1733,57 @@
],
"install-path": "../phpunit/phpunit"
},
{
"name": "psr/clock",
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"time": "2022-11-25T14:36:26+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"install-path": "../psr/clock"
},
{
"name": "psr/http-client",
"version": "1.0.3",
@ -3091,45 +3072,42 @@
},
{
"name": "spomky-labs/otphp",
"version": "v10.0.3",
"version_normalized": "10.0.3.0",
"version": "11.3.0",
"version_normalized": "11.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/Spomky-Labs/otphp.git",
"reference": "9784d9f7c790eed26e102d6c78f12c754036c366"
"reference": "2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Spomky-Labs/otphp/zipball/9784d9f7c790eed26e102d6c78f12c754036c366",
"reference": "9784d9f7c790eed26e102d6c78f12c754036c366",
"url": "https://api.github.com/repos/Spomky-Labs/otphp/zipball/2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33",
"reference": "2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33",
"shasum": ""
},
"require": {
"beberlei/assert": "^3.0",
"ext-mbstring": "*",
"paragonie/constant_time_encoding": "^2.0",
"php": "^7.2|^8.0",
"thecodingmachine/safe": "^0.1.14|^1.0|^2.0"
"paragonie/constant_time_encoding": "^2.0 || ^3.0",
"php": ">=8.1",
"psr/clock": "^1.0",
"symfony/deprecation-contracts": "^3.2"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-beberlei-assert": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^8.0",
"thecodingmachine/phpstan-safe-rule": "^1.0 || ^2.0"
"ekino/phpstan-banned-code": "^1.0",
"infection/infection": "^0.26|^0.27|^0.28|^0.29",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5.26|^10.0|^11.0",
"qossmic/deptrac-shim": "^1.0",
"rector/rector": "^1.0",
"symfony/phpunit-bridge": "^6.1|^7.0",
"symplify/easy-coding-standard": "^12.0"
},
"time": "2022-03-17T08:00:35+00:00",
"time": "2024-06-12T11:22:32+00:00",
"type": "library",
"extra": {
"branch-alias": {
"v10.0": "10.0.x-dev",
"v9.0": "9.0.x-dev",
"v8.3": "8.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
@ -3163,29 +3141,39 @@
],
"support": {
"issues": "https://github.com/Spomky-Labs/otphp/issues",
"source": "https://github.com/Spomky-Labs/otphp/tree/v10.0.3"
"source": "https://github.com/Spomky-Labs/otphp/tree/11.3.0"
},
"funding": [
{
"url": "https://github.com/Spomky",
"type": "github"
},
{
"url": "https://www.patreon.com/FlorentMorselli",
"type": "patreon"
}
],
"install-path": "../spomky-labs/otphp"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.5.0",
"version_normalized": "3.5.0.0",
"version": "v3.5.1",
"version_normalized": "3.5.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1"
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"time": "2024-04-18T09:32:20+00:00",
"time": "2024-09-25T14:20:29+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -3219,7 +3207,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
},
"funding": [
{
@ -3237,147 +3225,6 @@
],
"install-path": "../symfony/deprecation-contracts"
},
{
"name": "thecodingmachine/safe",
"version": "v2.2.2",
"version_normalized": "2.2.2.0",
"source": {
"type": "git",
"url": "https://github.com/thecodingmachine/safe.git",
"reference": "440284f9592c9df402832452a6871a8b3c48d97e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/440284f9592c9df402832452a6871a8b3c48d97e",
"reference": "440284f9592c9df402832452a6871a8b3c48d97e",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.2",
"thecodingmachine/phpstan-strict-rules": "^1.0"
},
"time": "2022-07-20T17:46:34+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"files": [
"deprecated/apc.php",
"deprecated/array.php",
"deprecated/datetime.php",
"deprecated/libevent.php",
"deprecated/password.php",
"deprecated/mssql.php",
"deprecated/stats.php",
"deprecated/strings.php",
"lib/special_cases.php",
"deprecated/mysqli.php",
"generated/apache.php",
"generated/apcu.php",
"generated/array.php",
"generated/bzip2.php",
"generated/calendar.php",
"generated/classobj.php",
"generated/com.php",
"generated/cubrid.php",
"generated/curl.php",
"generated/datetime.php",
"generated/dir.php",
"generated/eio.php",
"generated/errorfunc.php",
"generated/exec.php",
"generated/fileinfo.php",
"generated/filesystem.php",
"generated/filter.php",
"generated/fpm.php",
"generated/ftp.php",
"generated/funchand.php",
"generated/gettext.php",
"generated/gmp.php",
"generated/gnupg.php",
"generated/hash.php",
"generated/ibase.php",
"generated/ibmDb2.php",
"generated/iconv.php",
"generated/image.php",
"generated/imap.php",
"generated/info.php",
"generated/inotify.php",
"generated/json.php",
"generated/ldap.php",
"generated/libxml.php",
"generated/lzf.php",
"generated/mailparse.php",
"generated/mbstring.php",
"generated/misc.php",
"generated/mysql.php",
"generated/network.php",
"generated/oci8.php",
"generated/opcache.php",
"generated/openssl.php",
"generated/outcontrol.php",
"generated/pcntl.php",
"generated/pcre.php",
"generated/pgsql.php",
"generated/posix.php",
"generated/ps.php",
"generated/pspell.php",
"generated/readline.php",
"generated/rpminfo.php",
"generated/rrd.php",
"generated/sem.php",
"generated/session.php",
"generated/shmop.php",
"generated/sockets.php",
"generated/sodium.php",
"generated/solr.php",
"generated/spl.php",
"generated/sqlsrv.php",
"generated/ssdeep.php",
"generated/ssh2.php",
"generated/stream.php",
"generated/strings.php",
"generated/swoole.php",
"generated/uodbc.php",
"generated/uopz.php",
"generated/url.php",
"generated/var.php",
"generated/xdiff.php",
"generated/xml.php",
"generated/xmlrpc.php",
"generated/yaml.php",
"generated/yaz.php",
"generated/zip.php",
"generated/zlib.php"
],
"classmap": [
"lib/DateTime.php",
"lib/DateTimeImmutable.php",
"lib/Exceptions/",
"deprecated/Exceptions/",
"generated/Exceptions/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
"support": {
"issues": "https://github.com/thecodingmachine/safe/issues",
"source": "https://github.com/thecodingmachine/safe/tree/v2.2.2"
},
"install-path": "../thecodingmachine/safe"
},
{
"name": "theseer/tokenizer",
"version": "1.2.1",

View File

@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '1e14fc0fd957cea2ab176d5132c3fe5329991c17',
'reference' => 'cd2c10f9f71409df24fc74c1bbd7d5ddbf48d991',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -13,21 +13,12 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '1e14fc0fd957cea2ab176d5132c3fe5329991c17',
'reference' => 'cd2c10f9f71409df24fc74c1bbd7d5ddbf48d991',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'beberlei/assert' => array(
'pretty_version' => 'v3.3.2',
'version' => '3.3.2.0',
'reference' => 'cb70015c04be1baee6f5f5c953703347c0ac1655',
'type' => 'library',
'install_path' => __DIR__ . '/../beberlei/assert',
'aliases' => array(),
'dev_requirement' => false,
),
'chillerlan/php-qrcode' => array(
'pretty_version' => '5.0.3',
'version' => '5.0.3.0',
@ -121,9 +112,9 @@
'dev_requirement' => true,
),
'paragonie/constant_time_encoding' => array(
'pretty_version' => 'v2.6.3',
'version' => '2.6.3.0',
'reference' => '58c3f47f650c94ec05a151692652a868995d2938',
'pretty_version' => 'v3.0.0',
'version' => '3.0.0.0',
'reference' => 'df1e7fde177501eee2037dd159cf04f5f301a512',
'type' => 'library',
'install_path' => __DIR__ . '/../paragonie/constant_time_encoding',
'aliases' => array(),
@ -246,6 +237,15 @@
'aliases' => array(),
'dev_requirement' => true,
),
'psr/clock' => array(
'pretty_version' => '1.0.0',
'version' => '1.0.0.0',
'reference' => 'e41a24703d4560fd0acb709162f73b8adfc3aa0d',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/clock',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-client' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
@ -454,32 +454,23 @@
'dev_requirement' => false,
),
'spomky-labs/otphp' => array(
'pretty_version' => 'v10.0.3',
'version' => '10.0.3.0',
'reference' => '9784d9f7c790eed26e102d6c78f12c754036c366',
'pretty_version' => '11.3.0',
'version' => '11.3.0.0',
'reference' => '2d8ccb5fc992b9cc65ef321fa4f00fefdb3f4b33',
'type' => 'library',
'install_path' => __DIR__ . '/../spomky-labs/otphp',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v3.5.0',
'version' => '3.5.0.0',
'reference' => '0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1',
'pretty_version' => 'v3.5.1',
'version' => '3.5.1.0',
'reference' => '74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'thecodingmachine/safe' => array(
'pretty_version' => 'v2.2.2',
'version' => '2.2.2.0',
'reference' => '440284f9592c9df402832452a6871a8b3c48d97e',
'type' => 'library',
'install_path' => __DIR__ . '/../thecodingmachine/safe',
'aliases' => array(),
'dev_requirement' => false,
),
'theseer/tokenizer' => array(
'pretty_version' => '1.2.1',
'version' => '1.2.1.0',

View File

@ -1,6 +1,7 @@
# Constant-Time Encoding
[![Build Status](https://github.com/paragonie/constant_time_encoding/actions/workflows/ci.yml/badge.svg)](https://github.com/paragonie/constant_time_encoding/actions)
[![Static Analysis](https://github.com/paragonie/constant_time_encoding/actions/workflows/psalm.yml/badge.svg)](https://github.com/paragonie/constant_time_encoding/actions)
[![Latest Stable Version](https://poser.pugx.org/paragonie/constant_time_encoding/v/stable)](https://packagist.org/packages/paragonie/constant_time_encoding)
[![Latest Unstable Version](https://poser.pugx.org/paragonie/constant_time_encoding/v/unstable)](https://packagist.org/packages/paragonie/constant_time_encoding)
[![License](https://poser.pugx.org/paragonie/constant_time_encoding/license)](https://packagist.org/packages/paragonie/constant_time_encoding)
@ -11,7 +12,7 @@ this library aims to offer character encoding functions that do not leak
information about what you are encoding/decoding via processor cache
misses. Further reading on [cache-timing attacks](http://blog.ircmaxell.com/2014/11/its-all-about-time.html).
Our fork offers the following enchancements:
Our fork offers the following enhancements:
* `mbstring.func_overload` resistance
* Unit tests
@ -22,10 +23,13 @@ Our fork offers the following enchancements:
## PHP Version Requirements
Version 2 of this library should work on **PHP 7** or newer. For PHP 5
support, see [the v1.x branch](https://github.com/paragonie/constant_time_encoding/tree/v1.x).
Version 3 of this library should work on **PHP 8** or newer.
If you are adding this as a dependency to a project intended to work on both PHP 5 and PHP 7, please set the required version to `^1|^2` instead of just `^1` or `^2`.
Version 2 of this library should work on **PHP 7** or newer. See [the v2.x branch](https://github.com/paragonie/constant_time_encoding/tree/v2.x).
For PHP 5 support, see [the v1.x branch](https://github.com/paragonie/constant_time_encoding/tree/v1.x).
If you are adding this as a dependency to a project intended to work on PHP 5 through 8.4, please set the required version to `^1|^2|^3`.
## How to Install

View File

@ -37,11 +37,11 @@
"source": "https://github.com/paragonie/constant_time_encoding"
},
"require": {
"php": "^7|^8"
"php": "^8"
},
"require-dev": {
"phpunit/phpunit": "^6|^7|^8|^9",
"vimeo/psalm": "^1|^2|^3|^4"
"phpunit/phpunit": "^9",
"vimeo/psalm": "^4|^5"
},
"autoload": {
"psr-4": {

View File

@ -44,8 +44,11 @@ abstract class Base32 implements EncoderInterface
* @param bool $strictPadding
* @return string
*/
public static function decode(string $encodedString, bool $strictPadding = false): string
{
public static function decode(
#[\SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
return static::doDecode($encodedString, false, $strictPadding);
}
@ -56,8 +59,11 @@ abstract class Base32 implements EncoderInterface
* @param bool $strictPadding
* @return string
*/
public static function decodeUpper(string $src, bool $strictPadding = false): string
{
public static function decodeUpper(
#[\SensitiveParameter]
string $src,
bool $strictPadding = false
): string {
return static::doDecode($src, true, $strictPadding);
}
@ -68,10 +74,13 @@ abstract class Base32 implements EncoderInterface
* @return string
* @throws TypeError
*/
public static function encode(string $binString): string
{
public static function encode(
#[\SensitiveParameter]
string $binString
): string {
return static::doEncode($binString, false, true);
}
/**
* Encode into Base32 (RFC 4648)
*
@ -79,8 +88,10 @@ abstract class Base32 implements EncoderInterface
* @return string
* @throws TypeError
*/
public static function encodeUnpadded(string $src): string
{
public static function encodeUnpadded(
#[\SensitiveParameter]
string $src
): string {
return static::doEncode($src, false, false);
}
@ -91,8 +102,10 @@ abstract class Base32 implements EncoderInterface
* @return string
* @throws TypeError
*/
public static function encodeUpper(string $src): string
{
public static function encodeUpper(
#[\SensitiveParameter]
string $src
): string {
return static::doEncode($src, true, true);
}
@ -103,8 +116,10 @@ abstract class Base32 implements EncoderInterface
* @return string
* @throws TypeError
*/
public static function encodeUpperUnpadded(string $src): string
{
public static function encodeUpperUnpadded(
#[\SensitiveParameter]
string $src
): string {
return static::doEncode($src, true, false);
}
@ -191,8 +206,11 @@ abstract class Base32 implements EncoderInterface
* @param bool $upper
* @return string
*/
public static function decodeNoPadding(string $encodedString, bool $upper = false): string
{
public static function decodeNoPadding(
#[\SensitiveParameter]
string $encodedString,
bool $upper = false
): string {
$srcLen = Binary::safeStrlen($encodedString);
if ($srcLen === 0) {
return '';
@ -222,9 +240,9 @@ abstract class Base32 implements EncoderInterface
* @return string
*
* @throws TypeError
* @psalm-suppress RedundantCondition
*/
protected static function doDecode(
#[\SensitiveParameter]
string $src,
bool $upper = false,
bool $strictPadding = false
@ -434,8 +452,12 @@ abstract class Base32 implements EncoderInterface
* @return string
* @throws TypeError
*/
protected static function doEncode(string $src, bool $upper = false, $pad = true): string
{
protected static function doEncode(
#[\SensitiveParameter]
string $src,
bool $upper = false,
$pad = true
): string {
// We do this to reduce code duplication:
$method = $upper
? 'encode5BitsUpper'

View File

@ -47,8 +47,10 @@ abstract class Base64 implements EncoderInterface
*
* @throws TypeError
*/
public static function encode(string $binString): string
{
public static function encode(
#[\SensitiveParameter]
string $binString
): string {
return static::doEncode($binString, true);
}
@ -62,8 +64,10 @@ abstract class Base64 implements EncoderInterface
*
* @throws TypeError
*/
public static function encodeUnpadded(string $src): string
{
public static function encodeUnpadded(
#[\SensitiveParameter]
string $src
): string {
return static::doEncode($src, false);
}
@ -74,8 +78,11 @@ abstract class Base64 implements EncoderInterface
*
* @throws TypeError
*/
protected static function doEncode(string $src, bool $pad = true): string
{
protected static function doEncode(
#[\SensitiveParameter]
string $src,
bool $pad = true
): string {
$dest = '';
$srcLen = Binary::safeStrlen($src);
// Main loop (no padding):
@ -129,10 +136,12 @@ abstract class Base64 implements EncoderInterface
*
* @throws RangeException
* @throws TypeError
* @psalm-suppress RedundantCondition
*/
public static function decode(string $encodedString, bool $strictPadding = false): string
{
public static function decode(
#[\SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
// Remove padding
$srcLen = Binary::safeStrlen($encodedString);
if ($srcLen === 0) {
@ -227,25 +236,21 @@ abstract class Base64 implements EncoderInterface
* @param string $encodedString
* @return string
*/
public static function decodeNoPadding(string $encodedString): string
{
public static function decodeNoPadding(
#[\SensitiveParameter]
string $encodedString
): string {
$srcLen = Binary::safeStrlen($encodedString);
if ($srcLen === 0) {
return '';
}
if (($srcLen & 3) === 0) {
if ($encodedString[$srcLen - 1] === '=') {
// If $strLen is not zero, and it is divisible by 4, then it's at least 4.
if ($encodedString[$srcLen - 1] === '=' || $encodedString[$srcLen - 2] === '=') {
throw new InvalidArgumentException(
"decodeNoPadding() doesn't tolerate padding"
);
}
if (($srcLen & 3) > 1) {
if ($encodedString[$srcLen - 2] === '=') {
throw new InvalidArgumentException(
"decodeNoPadding() doesn't tolerate padding"
);
}
}
}
return static::decode(
$encodedString,

View File

@ -45,8 +45,10 @@ abstract class Binary
* @param string $str
* @return int
*/
public static function safeStrlen(string $str): int
{
public static function safeStrlen(
#[\SensitiveParameter]
string $str
): int {
if (\function_exists('mb_strlen')) {
// mb_strlen in PHP 7.x can return false.
/** @psalm-suppress RedundantCast */
@ -70,9 +72,10 @@ abstract class Binary
* @throws TypeError
*/
public static function safeSubstr(
#[\SensitiveParameter]
string $str,
int $start = 0,
$length = null
?int $length = null
): string {
if ($length === 0) {
return '';

View File

@ -40,8 +40,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32Encode(string $str): string
{
public static function base32Encode(
#[\SensitiveParameter]
string $str
): string {
return Base32::encode($str);
}
@ -52,8 +54,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32EncodeUpper(string $str): string
{
public static function base32EncodeUpper(
#[\SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
}
@ -64,8 +68,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32Decode(string $str): string
{
public static function base32Decode(
#[\SensitiveParameter]
string $str
): string {
return Base32::decode($str);
}
@ -76,8 +82,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32DecodeUpper(string $str): string
{
public static function base32DecodeUpper(
#[\SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str);
}
@ -88,8 +96,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32HexEncode(string $str): string
{
public static function base32HexEncode(
#[\SensitiveParameter]
string $str
): string {
return Base32Hex::encode($str);
}
@ -100,8 +110,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32HexEncodeUpper(string $str): string
{
public static function base32HexEncodeUpper(
#[\SensitiveParameter]
string $str
): string {
return Base32Hex::encodeUpper($str);
}
@ -112,8 +124,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32HexDecode(string $str): string
{
public static function base32HexDecode(
#[\SensitiveParameter]
string $str
): string {
return Base32Hex::decode($str);
}
@ -124,8 +138,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base32HexDecodeUpper(string $str): string
{
public static function base32HexDecodeUpper(
#[\SensitiveParameter]
string $str
): string {
return Base32Hex::decodeUpper($str);
}
@ -136,8 +152,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base64Encode(string $str): string
{
public static function base64Encode(
#[\SensitiveParameter]
string $str
): string {
return Base64::encode($str);
}
@ -148,8 +166,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base64Decode(string $str): string
{
public static function base64Decode(
#[\SensitiveParameter]
string $str
): string {
return Base64::decode($str);
}
@ -161,8 +181,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base64EncodeDotSlash(string $str): string
{
public static function base64EncodeDotSlash(
#[\SensitiveParameter]
string $str
): string {
return Base64DotSlash::encode($str);
}
@ -176,8 +198,10 @@ abstract class Encoding
* @throws \RangeException
* @throws TypeError
*/
public static function base64DecodeDotSlash(string $str): string
{
public static function base64DecodeDotSlash(
#[\SensitiveParameter]
string $str
): string {
return Base64DotSlash::decode($str);
}
@ -189,8 +213,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function base64EncodeDotSlashOrdered(string $str): string
{
public static function base64EncodeDotSlashOrdered(
#[\SensitiveParameter]
string $str
): string {
return Base64DotSlashOrdered::encode($str);
}
@ -204,8 +230,10 @@ abstract class Encoding
* @throws \RangeException
* @throws TypeError
*/
public static function base64DecodeDotSlashOrdered(string $str): string
{
public static function base64DecodeDotSlashOrdered(
#[\SensitiveParameter]
string $str
): string {
return Base64DotSlashOrdered::decode($str);
}
@ -217,8 +245,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function hexEncode(string $bin_string): string
{
public static function hexEncode(
#[\SensitiveParameter]
string $bin_string
): string {
return Hex::encode($bin_string);
}
@ -230,8 +260,10 @@ abstract class Encoding
* @return string (raw binary)
* @throws \RangeException
*/
public static function hexDecode(string $hex_string): string
{
public static function hexDecode(
#[\SensitiveParameter]
string $hex_string
): string {
return Hex::decode($hex_string);
}
@ -243,8 +275,10 @@ abstract class Encoding
* @return string
* @throws TypeError
*/
public static function hexEncodeUpper(string $bin_string): string
{
public static function hexEncodeUpper(
#[\SensitiveParameter]
string $bin_string
): string {
return Hex::encodeUpper($bin_string);
}
@ -255,8 +289,10 @@ abstract class Encoding
* @param string $bin_string (raw binary)
* @return string
*/
public static function hexDecodeUpper(string $bin_string): string
{
public static function hexDecodeUpper(
#[\SensitiveParameter]
string $bin_string
): string {
return Hex::decode($bin_string);
}
}

View File

@ -42,8 +42,10 @@ abstract class Hex implements EncoderInterface
* @return string
* @throws TypeError
*/
public static function encode(string $binString): string
{
public static function encode(
#[\SensitiveParameter]
string $binString
): string {
$hex = '';
$len = Binary::safeStrlen($binString);
for ($i = 0; $i < $len; ++$i) {
@ -69,8 +71,10 @@ abstract class Hex implements EncoderInterface
* @return string
* @throws TypeError
*/
public static function encodeUpper(string $binString): string
{
public static function encodeUpper(
#[\SensitiveParameter]
string $binString
): string {
$hex = '';
$len = Binary::safeStrlen($binString);
@ -99,6 +103,7 @@ abstract class Hex implements EncoderInterface
* @throws RangeException
*/
public static function decode(
#[\SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {

View File

@ -46,8 +46,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base64Encode(string $str): string
{
public static function base64Encode(
#[\SensitiveParameter]
string $str
): string {
return Base64::encode($str);
}
@ -61,8 +63,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base64Decode(string $str): string
{
public static function base64Decode(
#[\SensitiveParameter]
string $str
): string {
return Base64::decode($str, true);
}
@ -76,8 +80,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base64UrlSafeEncode(string $str): string
{
public static function base64UrlSafeEncode(
#[\SensitiveParameter]
string $str
): string {
return Base64UrlSafe::encode($str);
}
@ -91,8 +97,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base64UrlSafeDecode(string $str): string
{
public static function base64UrlSafeDecode(
#[\SensitiveParameter]
string $str
): string {
return Base64UrlSafe::decode($str, true);
}
@ -106,8 +114,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base32Encode(string $str): string
{
public static function base32Encode(
#[\SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
}
@ -121,8 +131,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base32Decode(string $str): string
{
public static function base32Decode(
#[\SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str, true);
}
@ -136,8 +148,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base32HexEncode(string $str): string
{
public static function base32HexEncode(
#[\SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
}
@ -151,8 +165,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base32HexDecode(string $str): string
{
public static function base32HexDecode(
#[\SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str, true);
}
@ -166,8 +182,10 @@ abstract class RFC4648
*
* @throws TypeError
*/
public static function base16Encode(string $str): string
{
public static function base16Encode(
#[\SensitiveParameter]
string $str
): string {
return Hex::encodeUpper($str);
}
@ -179,8 +197,10 @@ abstract class RFC4648
* @param string $str
* @return string
*/
public static function base16Decode(string $str): string
{
public static function base16Decode(
#[\SensitiveParameter]
string $str
): string {
return Hex::decode($str, true);
}
}
}

11
vendor/psr/clock/CHANGELOG.md vendored Normal file
View File

@ -0,0 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 1.0.0
First stable release after PSR-20 acceptance
## 0.1.0
First release

View File

@ -1,6 +1,4 @@
MIT License
Copyright (c) 2018 TheCodingMachine
Copyright (c) 2017 PHP Framework Interoperability Group
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -9,13 +7,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

61
vendor/psr/clock/README.md vendored Normal file
View File

@ -0,0 +1,61 @@
# PSR Clock
This repository holds the interface for [PSR-20][psr-url].
Note that this is not a clock of its own. It is merely an interface that
describes a clock. See the specification for more details.
## Installation
```bash
composer require psr/clock
```
## Usage
If you need a clock, you can use the interface like this:
```php
<?php
use Psr\Clock\ClockInterface;
class Foo
{
private ClockInterface $clock;
public function __construct(ClockInterface $clock)
{
$this->clock = $clock;
}
public function doSomething()
{
/** @var DateTimeImmutable $currentDateAndTime */
$currentDateAndTime = $this->clock->now();
// do something useful with that information
}
}
```
You can then pick one of the [implementations][implementation-url] of the interface to get a clock.
If you want to implement the interface, you can require this package and
implement `Psr\Clock\ClockInterface` in your code.
Don't forget to add `psr/clock-implementation` to your `composer.json`s `provides`-section like this:
```json
{
"provides": {
"psr/clock-implementation": "1.0"
}
}
```
And please read the [specification text][specification-url] for details on the interface.
[psr-url]: https://www.php-fig.org/psr/psr-20
[package-url]: https://packagist.org/packages/psr/clock
[implementation-url]: https://packagist.org/providers/psr/clock-implementation
[specification-url]: https://github.com/php-fig/fig-standards/blob/master/proposed/clock.md

21
vendor/psr/clock/composer.json vendored Normal file
View File

@ -0,0 +1,21 @@
{
"name": "psr/clock",
"description": "Common interface for reading the clock.",
"keywords": ["psr", "psr-20", "time", "clock", "now"],
"homepage": "https://github.com/php-fig/clock",
"license": "MIT",
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"require": {
"php": "^7.0 || ^8.0"
},
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
}
}

13
vendor/psr/clock/src/ClockInterface.php vendored Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace Psr\Clock;
use DateTimeImmutable;
interface ClockInterface
{
/**
* Returns the current time as a DateTimeImmutable Object
*/
public function now(): DateTimeImmutable;
}

View File

@ -1,61 +0,0 @@
<?php
$header = 'The MIT License (MIT)
Copyright (c) 2014-2019 Spomky-Labs
This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.';
$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'@DoctrineAnnotation' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'strict_param' => true,
'strict_comparison' => true,
'array_syntax' => ['syntax' => 'short'],
'array_indentation' => true,
'ordered_imports' => true,
'protected_to_private' => true,
'declare_strict_types' => true,
'native_function_invocation' => [
'include' => ['@compiler_optimized'],
'scope' => 'namespaced',
],
'mb_str_functions' => true,
'method_chaining_indentation' => true,
'linebreak_after_opening_tag' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_elseif' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_order' => true,
'pow_to_exponentiation' => true,
'simplified_null_return' => true,
'header_comment' => [
'header' => $header,
],
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
'php_unit_test_annotation' => [
'case' => 'snake',
'style' => 'annotation',
],
'php_unit_test_case_static_method_calls' => true,
])
->setRiskyAllowed(true)
->setUsingCache(true)
->setFinder($finder)
;

View File

@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@spomky-labs.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

43
vendor/spomky-labs/otphp/README.md vendored Normal file
View File

@ -0,0 +1,43 @@
TOTP / HOTP library in PHP
==========================
![Build Status](https://github.com/spomky-labs/otphp/workflows/Integrate/badge.svg)
![Build Status](https://github.com/spomky-labs/otphp/workflows/Infection/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/spomky-labs/otphp/v/stable.png)](https://packagist.org/packages/spomky-labs/otphp)
[![Total Downloads](https://poser.pugx.org/spomky-labs/otphp/downloads.png)](https://packagist.org/packages/spomky-labs/otphp)
[![Latest Unstable Version](https://poser.pugx.org/spomky-labs/otphp/v/unstable.png)](https://packagist.org/packages/spomky-labs/otphp)
[![License](https://poser.pugx.org/spomky-labs/otphp/license.png)](https://packagist.org/packages/spomky-labs/otphp)
A php library for generating one-time passwords according to [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226) (HOTP Algorithm) and [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238) (TOTP Algorithm)
This library is compatible with Google Authenticator apps available for Android and iPhone.
It is also compatible with other applications such as [FreeOTP](https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp) for example.
# Documentation
The documentation of this project is available in the [*doc* folder](doc/index.md).
# Support
I bring solutions to your problems and answer your questions.
If you really love that project, and the work I have done or if you want I prioritize your issues, then you can help me out for a couple of :beers: or more!
[Become a sponsor](https://github.com/sponsors/Spomky)
Or
[![Become a Patreon](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/FlorentMorselli)
## Contributing
Requests for new features, bug fixed and all other ideas to make this project useful are welcome.
Please report all issues in [the repository bug tracker](hhttps://github.com/Spomky-Labs/otphp/issues).
Also make sure to [follow these best practices](.github/CONTRIBUTING.md).
## Licence
This software is release under the [MIT licence](LICENSE).

View File

@ -2,16 +2,15 @@
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 11.0.x | :white_check_mark: |
| 10.0.x | :white_check_mark: |
| < 10.0 | :x: |
| Version | Supported |
| ------- |----------------------------------------|
| 11.0.x | :white_check_mark: |
| 10.0.x | :white_check_mark: (security fix only) |
| < 10.0 | :x: |
## Reporting a Vulnerability
Please send an email to `security@spomky-labs.com`.
Please email `security@spomky-labs.com`.
If deemed necessary, you can encrypt your message using one of the following GPG key
```

View File

@ -16,23 +16,25 @@
}
],
"require": {
"php": "^7.2|^8.0",
"php": ">=8.1",
"ext-mbstring": "*",
"paragonie/constant_time_encoding": "^2.0",
"beberlei/assert": "^3.0",
"thecodingmachine/safe": "^0.1.14|^1.0|^2.0"
"paragonie/constant_time_encoding": "^2.0 || ^3.0",
"psr/clock": "^1.0",
"symfony/deprecation-contracts": "^3.2"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"php-coveralls/php-coveralls": "^2.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-beberlei-assert": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"thecodingmachine/phpstan-safe-rule": "^1.0 || ^2.0"
},
"suggest": {
"ekino/phpstan-banned-code": "^1.0",
"infection/infection": "^0.26|^0.27|^0.28|^0.29",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5.26|^10.0|^11.0",
"qossmic/deptrac-shim": "^1.0",
"rector/rector": "^1.0",
"symfony/phpunit-bridge": "^6.1|^7.0",
"symplify/easy-coding-standard": "^12.0"
},
"autoload": {
"psr-4": { "OTPHP\\": "src/" }
@ -40,11 +42,18 @@
"autoload-dev": {
"psr-4": { "OTPHP\\Test\\": "tests/" }
},
"extra": {
"branch-alias": {
"v10.0": "10.0.x-dev",
"v9.0": "9.0.x-dev",
"v8.3": "8.3.x-dev"
}
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"infection/extension-installer": true,
"composer/package-versions-deprecated": true,
"symfony/flex": true,
"symfony/runtime": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
}
}

View File

@ -1,13 +0,0 @@
parameters:
level: 7
paths:
- src
- tests
ignoreErrors:
- '#Variable property access on \$this\(OTPHP\\OTP\)\.#'
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
- vendor/phpstan/phpstan-beberlei-assert/extension.neon

View File

@ -2,114 +2,103 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use InvalidArgumentException;
use function Safe\parse_url;
use function Safe\sprintf;
use Psr\Clock\ClockInterface;
use Throwable;
use function assert;
use function count;
/**
* This class is used to load OTP object from a provisioning Uri.
*
* @see \OTPHP\Test\FactoryTest
*/
final class Factory implements FactoryInterface
{
public static function loadFromProvisioningUri(string $uri): OTPInterface
public static function loadFromProvisioningUri(string $uri, ?ClockInterface $clock = null): OTPInterface
{
try {
$parsed_url = parse_url($uri);
$parsed_url = Url::fromString($uri);
$parsed_url->getScheme() === 'otpauth' || throw new InvalidArgumentException('Invalid scheme.');
} catch (Throwable $throwable) {
throw new InvalidArgumentException('Not a valid OTP provisioning URI', $throwable->getCode(), $throwable);
}
Assertion::isArray($parsed_url, 'Not a valid OTP provisioning URI');
self::checkData($parsed_url);
if ($clock === null) {
trigger_deprecation(
'spomky-labs/otphp',
'11.3.0',
'The parameter "$clock" will become mandatory in 12.0.0. Please set a valid PSR Clock implementation instead of "null".'
);
$clock = new InternalClock();
}
$otp = self::createOTP($parsed_url);
$otp = self::createOTP($parsed_url, $clock);
self::populateOTP($otp, $parsed_url);
return $otp;
}
/**
* @param array<string, mixed> $data
*/
private static function populateParameters(OTPInterface &$otp, array $data): void
private static function populateParameters(OTPInterface $otp, Url $data): void
{
foreach ($data['query'] as $key => $value) {
foreach ($data->getQuery() as $key => $value) {
$otp->setParameter($key, $value);
}
}
/**
* @param array<string, mixed> $data
*/
private static function populateOTP(OTPInterface &$otp, array $data): void
private static function populateOTP(OTPInterface $otp, Url $data): void
{
self::populateParameters($otp, $data);
$result = explode(':', rawurldecode(mb_substr($data['path'], 1)));
$result = explode(':', rawurldecode(mb_substr($data->getPath(), 1)));
if (2 > \count($result)) {
if (count($result) < 2) {
$otp->setIssuerIncludedAsParameter(false);
return;
}
if (null !== $otp->getIssuer()) {
Assertion::eq($result[0], $otp->getIssuer(), 'Invalid OTP: invalid issuer in parameter');
if ($otp->getIssuer() !== null) {
$result[0] === $otp->getIssuer() || throw new InvalidArgumentException(
'Invalid OTP: invalid issuer in parameter'
);
$otp->setIssuerIncludedAsParameter(true);
}
assert($result[0] !== '');
$otp->setIssuer($result[0]);
}
/**
* @param array<string, mixed> $data
*/
private static function checkData(array &$data): void
private static function createOTP(Url $parsed_url, ClockInterface $clock): OTPInterface
{
foreach (['scheme', 'host', 'path', 'query'] as $key) {
Assertion::keyExists($data, $key, 'Not a valid OTP provisioning URI');
}
Assertion::eq('otpauth', $data['scheme'], 'Not a valid OTP provisioning URI');
parse_str($data['query'], $data['query']);
Assertion::keyExists($data['query'], 'secret', 'Not a valid OTP provisioning URI');
}
/**
* @param array<string, mixed> $parsed_url
*/
private static function createOTP(array $parsed_url): OTPInterface
{
switch ($parsed_url['host']) {
switch ($parsed_url->getHost()) {
case 'totp':
$totp = TOTP::create($parsed_url['query']['secret']);
$totp->setLabel(self::getLabel($parsed_url['path']));
$totp = TOTP::createFromSecret($parsed_url->getSecret(), $clock);
$totp->setLabel(self::getLabel($parsed_url->getPath()));
return $totp;
case 'hotp':
$hotp = HOTP::create($parsed_url['query']['secret']);
$hotp->setLabel(self::getLabel($parsed_url['path']));
$hotp = HOTP::createFromSecret($parsed_url->getSecret());
$hotp->setLabel(self::getLabel($parsed_url->getPath()));
return $hotp;
default:
throw new InvalidArgumentException(sprintf('Unsupported "%s" OTP type', $parsed_url['host']));
throw new InvalidArgumentException(sprintf('Unsupported "%s" OTP type', $parsed_url->getHost()));
}
}
/**
* @param non-empty-string $data
* @return non-empty-string
*/
private static function getLabel(string $data): string
{
$result = explode(':', rawurldecode(mb_substr($data, 1)));
$label = count($result) === 2 ? $result[1] : $result[0];
assert($label !== '');
return 2 === \count($result) ? $result[1] : $result[0];
return $label;
}
}

View File

@ -2,22 +2,15 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface FactoryInterface
{
/**
* This method is the unique public method of the class.
* It can load a provisioning Uri and convert it into an OTP object.
* This method is the unique public method of the class. It can load a provisioning Uri and convert it into an OTP
* object.
*
* @param non-empty-string $uri
*/
public static function loadFromProvisioningUri(string $uri): OTPInterface;
}

View File

@ -2,60 +2,78 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use InvalidArgumentException;
use function is_int;
/**
* @see \OTPHP\Test\HOTPTest
*/
final class HOTP extends OTP implements HOTPInterface
{
protected function __construct(?string $secret, int $counter, string $digest, int $digits)
{
parent::__construct($secret, $digest, $digits);
$this->setCounter($counter);
private const DEFAULT_WINDOW = 0;
public static function create(
null|string $secret = null,
int $counter = self::DEFAULT_COUNTER,
string $digest = self::DEFAULT_DIGEST,
int $digits = self::DEFAULT_DIGITS
): self {
$htop = $secret !== null
? self::createFromSecret($secret)
: self::generate()
;
$htop->setCounter($counter);
$htop->setDigest($digest);
$htop->setDigits($digits);
return $htop;
}
public static function create(?string $secret = null, int $counter = 0, string $digest = 'sha1', int $digits = 6): HOTPInterface
public static function createFromSecret(string $secret): self
{
return new self($secret, $counter, $digest, $digits);
$htop = new self($secret);
$htop->setCounter(self::DEFAULT_COUNTER);
$htop->setDigest(self::DEFAULT_DIGEST);
$htop->setDigits(self::DEFAULT_DIGITS);
return $htop;
}
protected function setCounter(int $counter): void
public static function generate(): self
{
$this->setParameter('counter', $counter);
return self::createFromSecret(self::generateSecret());
}
/**
* @return 0|positive-int
*/
public function getCounter(): int
{
return $this->getParameter('counter');
}
$value = $this->getParameter('counter');
(is_int($value) && $value >= 0) || throw new InvalidArgumentException('Invalid "counter" parameter.');
private function updateCounter(int $counter): void
{
$this->setCounter($counter);
return $value;
}
public function getProvisioningUri(): string
{
return $this->generateURI('hotp', ['counter' => $this->getCounter()]);
return $this->generateURI('hotp', [
'counter' => $this->getCounter(),
]);
}
/**
* If the counter is not provided, the OTP is verified at the actual counter.
*
* @param null|0|positive-int $counter
*/
public function verify(string $otp, ?int $counter = null, ?int $window = null): bool
public function verify(string $otp, null|int $counter = null, null|int $window = null): bool
{
Assertion::greaterOrEqualThan($counter, 0, 'The counter must be at least 0.');
$counter >= 0 || throw new InvalidArgumentException('The counter must be at least 0.');
if (null === $counter) {
if ($counter === null) {
$counter = $this->getCounter();
} elseif ($counter < $this->getCounter()) {
return false;
@ -64,12 +82,45 @@ final class HOTP extends OTP implements HOTPInterface
return $this->verifyOtpWithWindow($otp, $counter, $window);
}
private function getWindow(?int $window): int
public function setCounter(int $counter): void
{
return abs($window ?? 0);
$this->setParameter('counter', $counter);
}
private function verifyOtpWithWindow(string $otp, int $counter, ?int $window): bool
/**
* @return array<non-empty-string, callable>
*/
protected function getParameterMap(): array
{
return [...parent::getParameterMap(), ...[
'counter' => static function (mixed $value): int {
$value = (int) $value;
$value >= 0 || throw new InvalidArgumentException('Counter must be at least 0.');
return $value;
},
]];
}
private function updateCounter(int $counter): void
{
$this->setCounter($counter);
}
/**
* @param null|0|positive-int $window
*/
private function getWindow(null|int $window): int
{
return abs($window ?? self::DEFAULT_WINDOW);
}
/**
* @param non-empty-string $otp
* @param 0|positive-int $counter
* @param null|0|positive-int $window
*/
private function verifyOtpWithWindow(string $otp, int $counter, null|int $window): bool
{
$window = $this->getWindow($window);
@ -83,21 +134,4 @@ final class HOTP extends OTP implements HOTPInterface
return false;
}
/**
* @return array<string, mixed>
*/
protected function getParameterMap(): array
{
$v = array_merge(
parent::getParameterMap(),
['counter' => function ($value): int {
Assertion::greaterOrEqualThan((int) $value, 0, 'Counter must be at least 0.');
return (int) $value;
}]
);
return $v;
}
}

View File

@ -2,28 +2,35 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface HOTPInterface extends OTPInterface
{
public const DEFAULT_COUNTER = 0;
/**
* The initial counter (a positive integer).
*/
public function getCounter(): int;
/**
* Create a new TOTP object.
* Create a new HOTP object.
*
* If the secret is null, a random 64 bytes secret will be generated.
*
* @param null|non-empty-string $secret
* @param 0|positive-int $counter
* @param non-empty-string $digest
* @param positive-int $digits
*
* @deprecated Deprecated since v11.1, use ::createFromSecret or ::generate instead
*/
public static function create(?string $secret = null, int $counter = 0, string $digest = 'sha1', int $digits = 6): self;
public static function create(
null|string $secret = null,
int $counter = 0,
string $digest = 'sha1',
int $digits = 6
): self;
public function setCounter(int $counter): void;
}

View File

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace OTPHP;
use DateTimeImmutable;
use Psr\Clock\ClockInterface;
/**
* @internal
*/
final class InternalClock implements ClockInterface
{
public function now(): DateTimeImmutable
{
return new DateTimeImmutable();
}
}

View File

@ -2,32 +2,30 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use Exception;
use InvalidArgumentException;
use ParagonIE\ConstantTime\Base32;
use RuntimeException;
use function Safe\ksort;
use function Safe\sprintf;
use function assert;
use function chr;
use function count;
use function is_string;
use const STR_PAD_LEFT;
abstract class OTP implements OTPInterface
{
use ParameterTrait;
protected function __construct(?string $secret, string $digest, int $digits)
private const DEFAULT_SECRET_SIZE = 64;
/**
* @param non-empty-string $secret
*/
protected function __construct(string $secret)
{
$this->setSecret($secret);
$this->setDigest($digest);
$this->setDigits($digits);
}
public function getQrCodeUri(string $uri, string $placeholder): string
@ -37,33 +35,53 @@ abstract class OTP implements OTPInterface
return str_replace($placeholder, $provisioning_uri, $uri);
}
/**
* @param 0|positive-int $input
*/
public function at(int $input): string
{
return $this->generateOTP($input);
}
/**
* @return non-empty-string
*/
final protected static function generateSecret(): string
{
return Base32::encodeUpper(random_bytes(self::DEFAULT_SECRET_SIZE));
}
/**
* The OTP at the specified input.
*
* @param 0|positive-int $input
*
* @return non-empty-string
*/
protected function generateOTP(int $input): string
{
$hash = hash_hmac($this->getDigest(), $this->intToByteString($input), $this->getDecodedSecret(), true);
$unpacked = unpack('C*', $hash);
$unpacked !== false || throw new InvalidArgumentException('Invalid data.');
$hmac = array_values($unpacked);
$hmac = array_values(unpack('C*', $hash));
$offset = ($hmac[\count($hmac) - 1] & 0xF);
$code = ($hmac[$offset + 0] & 0x7F) << 24 | ($hmac[$offset + 1] & 0xFF) << 16 | ($hmac[$offset + 2] & 0xFF) << 8 | ($hmac[$offset + 3] & 0xFF);
$offset = ($hmac[count($hmac) - 1] & 0xF);
$code = ($hmac[$offset] & 0x7F) << 24 | ($hmac[$offset + 1] & 0xFF) << 16 | ($hmac[$offset + 2] & 0xFF) << 8 | ($hmac[$offset + 3] & 0xFF);
$otp = $code % (10 ** $this->getDigits());
return str_pad((string) $otp, $this->getDigits(), '0', STR_PAD_LEFT);
}
public function at(int $timestamp): string
{
return $this->generateOTP($timestamp);
}
/**
* @param array<string, mixed> $options
* @param array<non-empty-string, mixed> $options
*/
protected function filterOptions(array &$options): void
{
foreach (['algorithm' => 'sha1', 'period' => 30, 'digits' => 6] as $key => $default) {
foreach ([
'algorithm' => 'sha1',
'period' => 30,
'digits' => 6,
] as $key => $default) {
if (isset($options[$key]) && $default === $options[$key]) {
unset($options[$key]);
}
@ -73,42 +91,60 @@ abstract class OTP implements OTPInterface
}
/**
* @param array<string, mixed> $options
* @param non-empty-string $type
* @param array<non-empty-string, mixed> $options
*
* @return non-empty-string
*/
protected function generateURI(string $type, array $options): string
{
$label = $this->getLabel();
Assertion::string($label, 'The label is not set.');
Assertion::false($this->hasColon($label), 'Label must not contain a colon.');
$options = array_merge($options, $this->getParameters());
is_string($label) || throw new InvalidArgumentException('The label is not set.');
$this->hasColon($label) === false || throw new InvalidArgumentException('Label must not contain a colon.');
$options = [...$options, ...$this->getParameters()];
$this->filterOptions($options);
$params = str_replace(['+', '%7E'], ['%20', '~'], http_build_query($options));
$params = str_replace(['+', '%7E'], ['%20', '~'], http_build_query($options, '', '&'));
return sprintf('otpauth://%s/%s?%s', $type, rawurlencode((null !== $this->getIssuer() ? $this->getIssuer().':' : '').$label), $params);
return sprintf(
'otpauth://%s/%s?%s',
$type,
rawurlencode(($this->getIssuer() !== null ? $this->getIssuer() . ':' : '') . $label),
$params
);
}
/**
* @param non-empty-string $safe
* @param non-empty-string $user
*/
protected function compareOTP(string $safe, string $user): bool
{
return hash_equals($safe, $user);
}
/**
* @return non-empty-string
*/
private function getDecodedSecret(): string
{
try {
return Base32::decodeUpper($this->getSecret());
} catch (\Exception $e) {
$decoded = Base32::decodeUpper($this->getSecret());
} catch (Exception) {
throw new RuntimeException('Unable to decode the secret. Is it correctly base32 encoded?');
}
assert($decoded !== '');
return $decoded;
}
private function intToByteString(int $int): string
{
$result = [];
while (0 !== $int) {
$result[] = \chr($int & 0xFF);
while ($int !== 0) {
$result[] = chr($int & 0xFF);
$int >>= 8;
}
return str_pad(implode(array_reverse($result)), 8, "\000", STR_PAD_LEFT);
}
protected function compareOTP(string $safe, string $user): bool
{
return hash_equals($safe, $user);
return str_pad(implode('', array_reverse($result)), 8, "\000", STR_PAD_LEFT);
}
}

View File

@ -2,50 +2,80 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface OTPInterface
{
/**
* @return string Return the OTP at the specified timestamp
*/
public function at(int $timestamp): string;
public const DEFAULT_DIGITS = 6;
public const DEFAULT_DIGEST = 'sha1';
/**
* Verify that the OTP is valid with the specified input.
* If no input is provided, the input is set to a default value or false is returned.
* Create a OTP object from an existing secret.
*
* @param non-empty-string $secret
*/
public function verify(string $otp, ?int $input = null, ?int $window = null): bool;
public static function createFromSecret(string $secret): self;
/**
* @return string The secret of the OTP
* Create a new OTP object. A random 64 bytes secret will be generated.
*/
public static function generate(): self;
/**
* @param non-empty-string $secret
*/
public function setSecret(string $secret): void;
public function setDigits(int $digits): void;
/**
* @param non-empty-string $digest
*/
public function setDigest(string $digest): void;
/**
* Generate the OTP at the specified input.
*
* @param 0|positive-int $input
*
* @return non-empty-string Return the OTP at the specified timestamp
*/
public function at(int $input): string;
/**
* Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default
* value or false is returned.
*
* @param non-empty-string $otp
* @param null|0|positive-int $input
* @param null|0|positive-int $window
*/
public function verify(string $otp, null|int $input = null, null|int $window = null): bool;
/**
* @return non-empty-string The secret of the OTP
*/
public function getSecret(): string;
/**
* @param string $label The label of the OTP
* @param non-empty-string $label The label of the OTP
*/
public function setLabel(string $label): void;
/**
* @return string|null The label of the OTP
* @return non-empty-string|null The label of the OTP
*/
public function getLabel(): ?string;
public function getLabel(): null|string;
/**
* @return string|null The issuer
* @return non-empty-string|null The issuer
*/
public function getIssuer(): ?string;
/**
* @param non-empty-string $issuer
*/
public function setIssuer(string $issuer): void;
/**
@ -56,42 +86,47 @@ interface OTPInterface
public function setIssuerIncludedAsParameter(bool $issuer_included_as_parameter): void;
/**
* @return int Number of digits in the OTP
* @return positive-int Number of digits in the OTP
*/
public function getDigits(): int;
/**
* @return string Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'
* @return non-empty-string Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'
*/
public function getDigest(): string;
/**
* @return mixed|null
* @param non-empty-string $parameter
*/
public function getParameter(string $parameter);
public function getParameter(string $parameter): mixed;
/**
* @param non-empty-string $parameter
*/
public function hasParameter(string $parameter): bool;
/**
* @return array<string, mixed>
* @return array<non-empty-string, mixed>
*/
public function getParameters(): array;
/**
* @param mixed|null $value
* @param non-empty-string $parameter
*/
public function setParameter(string $parameter, $value): void;
public function setParameter(string $parameter, mixed $value): void;
/**
* Get the provisioning URI.
*
* @return non-empty-string
*/
public function getProvisioningUri(): string;
/**
* Get the provisioning URI.
*
* @param string $uri The Uri of the QRCode generator with all parameters. This Uri MUST contain a placeholder that will be replaced by the method.
* @param string $placeholder the placeholder to be replaced in the QR Code generator URI
* @param non-empty-string $uri The Uri of the QRCode generator with all parameters. This Uri MUST contain a placeholder that will be replaced by the method.
* @param non-empty-string $placeholder the placeholder to be replaced in the QR Code generator URI
*/
public function getQrCodeUri(string $uri, string $placeholder): string;
}

View File

@ -2,52 +2,42 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use InvalidArgumentException;
use ParagonIE\ConstantTime\Base32;
use function Safe\sprintf;
use function array_key_exists;
use function assert;
use function in_array;
use function is_int;
use function is_string;
trait ParameterTrait
{
/**
* @var array<string, mixed>
* @var array<non-empty-string, mixed>
*/
private $parameters = [];
private array $parameters = [];
/**
* @var string|null
* @var non-empty-string|null
*/
private $issuer;
private null|string $issuer = null;
/**
* @var string|null
* @var non-empty-string|null
*/
private $label;
private null|string $label = null;
private bool $issuer_included_as_parameter = true;
/**
* @var bool
*/
private $issuer_included_as_parameter = true;
/**
* @return array<string, mixed>
* @return array<non-empty-string, mixed>
*/
public function getParameters(): array
{
$parameters = $this->parameters;
if (null !== $this->getIssuer() && true === $this->isIssuerIncludedAsParameter()) {
if ($this->getIssuer() !== null && $this->isIssuerIncludedAsParameter() === true) {
$parameters['issuer'] = $this->getIssuer();
}
@ -56,15 +46,13 @@ trait ParameterTrait
public function getSecret(): string
{
return $this->getParameter('secret');
$value = $this->getParameter('secret');
(is_string($value) && $value !== '') || throw new InvalidArgumentException('Invalid "secret" parameter.');
return $value;
}
public function setSecret(?string $secret): void
{
$this->setParameter('secret', $secret);
}
public function getLabel(): ?string
public function getLabel(): null|string
{
return $this->label;
}
@ -74,7 +62,7 @@ trait ParameterTrait
$this->setParameter('label', $label);
}
public function getIssuer(): ?string
public function getIssuer(): null|string
{
return $this->issuer;
}
@ -96,30 +84,26 @@ trait ParameterTrait
public function getDigits(): int
{
return $this->getParameter('digits');
}
$value = $this->getParameter('digits');
(is_int($value) && $value > 0) || throw new InvalidArgumentException('Invalid "digits" parameter.');
private function setDigits(int $digits): void
{
$this->setParameter('digits', $digits);
return $value;
}
public function getDigest(): string
{
return $this->getParameter('algorithm');
}
$value = $this->getParameter('algorithm');
(is_string($value) && $value !== '') || throw new InvalidArgumentException('Invalid "algorithm" parameter.');
private function setDigest(string $digest): void
{
$this->setParameter('algorithm', $digest);
return $value;
}
public function hasParameter(string $parameter): bool
{
return \array_key_exists($parameter, $this->parameters);
return array_key_exists($parameter, $this->parameters);
}
public function getParameter(string $parameter)
public function getParameter(string $parameter): mixed
{
if ($this->hasParameter($parameter)) {
return $this->getParameters()[$parameter];
@ -128,65 +112,85 @@ trait ParameterTrait
throw new InvalidArgumentException(sprintf('Parameter "%s" does not exist', $parameter));
}
public function setParameter(string $parameter, $value): void
public function setParameter(string $parameter, mixed $value): void
{
$map = $this->getParameterMap();
if (true === \array_key_exists($parameter, $map)) {
if (array_key_exists($parameter, $map) === true) {
$callback = $map[$parameter];
$value = $callback($value);
}
if (property_exists($this, $parameter)) {
$this->$parameter = $value;
$this->{$parameter} = $value;
} else {
$this->parameters[$parameter] = $value;
}
}
public function setSecret(string $secret): void
{
$this->setParameter('secret', $secret);
}
public function setDigits(int $digits): void
{
$this->setParameter('digits', $digits);
}
public function setDigest(string $digest): void
{
$this->setParameter('algorithm', $digest);
}
/**
* @return array<string, mixed>
* @return array<non-empty-string, callable>
*/
protected function getParameterMap(): array
{
return [
'label' => function ($value) {
Assertion::false($this->hasColon($value), 'Label must not contain a colon.');
'label' => function (string $value): string {
assert($value !== '');
$this->hasColon($value) === false || throw new InvalidArgumentException(
'Label must not contain a colon.'
);
return $value;
},
'secret' => function ($value): string {
if (null === $value) {
$value = Base32::encodeUpper(random_bytes(64));
}
$value = trim(mb_strtoupper($value), '=');
return $value;
},
'algorithm' => function ($value): string {
'secret' => static fn (string $value): string => mb_strtoupper(trim($value, '=')),
'algorithm' => static function (string $value): string {
$value = mb_strtolower($value);
Assertion::inArray($value, hash_algos(), sprintf('The "%s" digest is not supported.', $value));
in_array($value, hash_algos(), true) || throw new InvalidArgumentException(sprintf(
'The "%s" digest is not supported.',
$value
));
return $value;
},
'digits' => function ($value): int {
Assertion::greaterThan($value, 0, 'Digits must be at least 1.');
'digits' => static function ($value): int {
$value > 0 || throw new InvalidArgumentException('Digits must be at least 1.');
return (int) $value;
},
'issuer' => function ($value) {
Assertion::false($this->hasColon($value), 'Issuer must not contain a colon.');
'issuer' => function (string $value): string {
assert($value !== '');
$this->hasColon($value) === false || throw new InvalidArgumentException(
'Issuer must not contain a colon.'
);
return $value;
},
];
}
/**
* @param non-empty-string $value
*/
private function hasColon(string $value): bool
{
$colons = [':', '%3A', '%3a'];
foreach ($colons as $colon) {
if (false !== mb_strpos($value, $colon)) {
if (str_contains($value, $colon)) {
return true;
}
}

View File

@ -2,158 +2,214 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
use Assert\Assertion;
use function Safe\ksort;
use InvalidArgumentException;
use Psr\Clock\ClockInterface;
use function assert;
use function is_int;
/**
* @see \OTPHP\Test\TOTPTest
*/
final class TOTP extends OTP implements TOTPInterface
{
protected function __construct(?string $secret, int $period, string $digest, int $digits, int $epoch = 0)
private readonly ClockInterface $clock;
public function __construct(string $secret, ?ClockInterface $clock = null)
{
parent::__construct($secret, $digest, $digits);
$this->setPeriod($period);
$this->setEpoch($epoch);
parent::__construct($secret);
if ($clock === null) {
trigger_deprecation(
'spomky-labs/otphp',
'11.3.0',
'The parameter "$clock" will become mandatory in 12.0.0. Please set a valid PSR Clock implementation instead of "null".'
);
$clock = new InternalClock();
}
$this->clock = $clock;
}
public static function create(?string $secret = null, int $period = 30, string $digest = 'sha1', int $digits = 6, int $epoch = 0): TOTPInterface
{
return new self($secret, $period, $digest, $digits, $epoch);
public static function create(
null|string $secret = null,
int $period = self::DEFAULT_PERIOD,
string $digest = self::DEFAULT_DIGEST,
int $digits = self::DEFAULT_DIGITS,
int $epoch = self::DEFAULT_EPOCH,
?ClockInterface $clock = null
): self {
$totp = $secret !== null
? self::createFromSecret($secret, $clock)
: self::generate($clock)
;
$totp->setPeriod($period);
$totp->setDigest($digest);
$totp->setDigits($digits);
$totp->setEpoch($epoch);
return $totp;
}
protected function setPeriod(int $period): void
public static function createFromSecret(string $secret, ?ClockInterface $clock = null): self
{
$this->setParameter('period', $period);
$totp = new self($secret, $clock);
$totp->setPeriod(self::DEFAULT_PERIOD);
$totp->setDigest(self::DEFAULT_DIGEST);
$totp->setDigits(self::DEFAULT_DIGITS);
$totp->setEpoch(self::DEFAULT_EPOCH);
return $totp;
}
public static function generate(?ClockInterface $clock = null): self
{
return self::createFromSecret(self::generateSecret(), $clock);
}
public function getPeriod(): int
{
return $this->getParameter('period');
}
$value = $this->getParameter('period');
(is_int($value) && $value > 0) || throw new InvalidArgumentException('Invalid "period" parameter.');
private function setEpoch(int $epoch): void
{
$this->setParameter('epoch', $epoch);
return $value;
}
public function getEpoch(): int
{
return $this->getParameter('epoch');
$value = $this->getParameter('epoch');
(is_int($value) && $value >= 0) || throw new InvalidArgumentException('Invalid "epoch" parameter.');
return $value;
}
public function at(int $timestamp): string
public function expiresIn(): int
{
return $this->generateOTP($this->timecode($timestamp));
$period = $this->getPeriod();
return $period - ($this->clock->now()->getTimestamp() % $this->getPeriod());
}
/**
* The OTP at the specified input.
*
* @param 0|positive-int $input
*/
public function at(int $input): string
{
return $this->generateOTP($this->timecode($input));
}
public function now(): string
{
return $this->at(time());
$timestamp = $this->clock->now()
->getTimestamp();
assert($timestamp >= 0, 'The timestamp must return a positive integer.');
return $this->at($timestamp);
}
/**
* If no timestamp is provided, the OTP is verified at the actual timestamp.
* If no timestamp is provided, the OTP is verified at the actual timestamp. When used, the leeway parameter will
* allow time drift. The passed value is in seconds.
*
* @param 0|positive-int $timestamp
* @param null|0|positive-int $leeway
*/
public function verify(string $otp, ?int $timestamp = null, ?int $window = null): bool
public function verify(string $otp, null|int $timestamp = null, null|int $leeway = null): bool
{
$timestamp = $this->getTimestamp($timestamp);
$timestamp ??= $this->clock->now()
->getTimestamp();
$timestamp >= 0 || throw new InvalidArgumentException('Timestamp must be at least 0.');
if (null === $window) {
if ($leeway === null) {
return $this->compareOTP($this->at($timestamp), $otp);
}
return $this->verifyOtpWithWindow($otp, $timestamp, $window);
}
$leeway = abs($leeway);
$leeway < $this->getPeriod() || throw new InvalidArgumentException(
'The leeway must be lower than the TOTP period'
);
$timestampMinusLeeway = $timestamp - $leeway;
$timestampMinusLeeway >= 0 || throw new InvalidArgumentException(
'The timestamp must be greater than or equal to the leeway.'
);
private function verifyOtpWithWindow(string $otp, int $timestamp, int $window): bool
{
$window = abs($window);
for ($i = 0; $i <= $window; ++$i) {
$next = $i * $this->getPeriod() + $timestamp;
$previous = -$i * $this->getPeriod() + $timestamp;
$valid = $this->compareOTP($this->at($next), $otp) ||
$this->compareOTP($this->at($previous), $otp);
if ($valid) {
return true;
}
}
return false;
}
private function getTimestamp(?int $timestamp): int
{
$timestamp = $timestamp ?? time();
Assertion::greaterOrEqualThan($timestamp, 0, 'Timestamp must be at least 0.');
return $timestamp;
return $this->compareOTP($this->at($timestampMinusLeeway), $otp)
|| $this->compareOTP($this->at($timestamp), $otp)
|| $this->compareOTP($this->at($timestamp + $leeway), $otp);
}
public function getProvisioningUri(): string
{
$params = [];
if (30 !== $this->getPeriod()) {
if ($this->getPeriod() !== 30) {
$params['period'] = $this->getPeriod();
}
if (0 !== $this->getEpoch()) {
if ($this->getEpoch() !== 0) {
$params['epoch'] = $this->getEpoch();
}
return $this->generateURI('totp', $params);
}
private function timecode(int $timestamp): int
public function setPeriod(int $period): void
{
return (int) floor(($timestamp - $this->getEpoch()) / $this->getPeriod());
$this->setParameter('period', $period);
}
public function setEpoch(int $epoch): void
{
$this->setParameter('epoch', $epoch);
}
/**
* @return array<string, mixed>
* @return array<non-empty-string, callable>
*/
protected function getParameterMap(): array
{
$v = array_merge(
parent::getParameterMap(),
[
'period' => function ($value): int {
Assertion::greaterThan((int) $value, 0, 'Period must be at least 1.');
return [
...parent::getParameterMap(),
'period' => static function ($value): int {
(int) $value > 0 || throw new InvalidArgumentException('Period must be at least 1.');
return (int) $value;
},
'epoch' => function ($value): int {
Assertion::greaterOrEqualThan((int) $value, 0, 'Epoch must be greater than or equal to 0.');
return (int) $value;
},
'epoch' => static function ($value): int {
(int) $value >= 0 || throw new InvalidArgumentException(
'Epoch must be greater than or equal to 0.'
);
return (int) $value;
},
]
);
return $v;
return (int) $value;
},
];
}
/**
* @param array<string, mixed> $options
* @param array<non-empty-string, mixed> $options
*/
protected function filterOptions(array &$options): void
{
parent::filterOptions($options);
if (isset($options['epoch']) && 0 === $options['epoch']) {
if (isset($options['epoch']) && $options['epoch'] === 0) {
unset($options['epoch']);
}
ksort($options);
}
/**
* @param 0|positive-int $timestamp
*
* @return 0|positive-int
*/
private function timecode(int $timestamp): int
{
$timecode = (int) floor(($timestamp - $this->getEpoch()) / $this->getPeriod());
assert($timecode >= 0);
return $timecode;
}
}

View File

@ -2,28 +2,41 @@
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OTPHP;
interface TOTPInterface extends OTPInterface
{
public const DEFAULT_PERIOD = 30;
public const DEFAULT_EPOCH = 0;
/**
* Create a new TOTP object.
*
* If the secret is null, a random 64 bytes secret will be generated.
*
* @param null|non-empty-string $secret
* @param positive-int $period
* @param non-empty-string $digest
* @param positive-int $digits
*
* @deprecated Deprecated since v11.1, use ::createFromSecret or ::generate instead
*/
public static function create(?string $secret = null, int $period = 30, string $digest = 'sha1', int $digits = 6): self;
public static function create(
null|string $secret = null,
int $period = self::DEFAULT_PERIOD,
string $digest = self::DEFAULT_DIGEST,
int $digits = self::DEFAULT_DIGITS
): self;
public function setPeriod(int $period): void;
public function setEpoch(int $epoch): void;
/**
* Return the TOTP at the current time.
*
* @return non-empty-string
*/
public function now(): string;
@ -32,5 +45,7 @@ interface TOTPInterface extends OTPInterface
*/
public function getPeriod(): int;
public function expiresIn(): int;
public function getEpoch(): int;
}

102
vendor/spomky-labs/otphp/src/Url.php vendored Normal file
View File

@ -0,0 +1,102 @@
<?php
declare(strict_types=1);
namespace OTPHP;
use InvalidArgumentException;
use function array_key_exists;
use function is_string;
/**
* @internal
*/
final class Url
{
/**
* @param non-empty-string $scheme
* @param non-empty-string $host
* @param non-empty-string $path
* @param non-empty-string $secret
* @param array<non-empty-string, mixed> $query
*/
public function __construct(
private readonly string $scheme,
private readonly string $host,
private readonly string $path,
private readonly string $secret,
private readonly array $query
) {
}
/**
* @return non-empty-string
*/
public function getScheme(): string
{
return $this->scheme;
}
/**
* @return non-empty-string
*/
public function getHost(): string
{
return $this->host;
}
/**
* @return non-empty-string
*/
public function getPath(): string
{
return $this->path;
}
/**
* @return non-empty-string
*/
public function getSecret(): string
{
return $this->secret;
}
/**
* @return array<non-empty-string, mixed>
*/
public function getQuery(): array
{
return $this->query;
}
/**
* @param non-empty-string $uri
*/
public static function fromString(string $uri): self
{
$parsed_url = parse_url($uri);
$parsed_url !== false || throw new InvalidArgumentException('Invalid URI.');
foreach (['scheme', 'host', 'path', 'query'] as $key) {
array_key_exists($key, $parsed_url) || throw new InvalidArgumentException(
'Not a valid OTP provisioning URI'
);
}
$scheme = $parsed_url['scheme'] ?? null;
$host = $parsed_url['host'] ?? null;
$path = $parsed_url['path'] ?? null;
$query = $parsed_url['query'] ?? null;
$scheme === 'otpauth' || throw new InvalidArgumentException('Not a valid OTP provisioning URI');
is_string($host) || throw new InvalidArgumentException('Invalid URI.');
is_string($path) || throw new InvalidArgumentException('Invalid URI.');
is_string($query) || throw new InvalidArgumentException('Invalid URI.');
$parsedQuery = [];
parse_str($query, $parsedQuery);
array_key_exists('secret', $parsedQuery) || throw new InvalidArgumentException(
'Not a valid OTP provisioning URI'
);
$secret = $parsedQuery['secret'];
unset($parsedQuery['secret']);
return new self($scheme, $host, $path, $secret, $parsedQuery);
}
}

View File

@ -1,176 +0,0 @@
[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/safe/v/stable.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![Total Downloads](https://poser.pugx.org/thecodingmachine/safe/downloads.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/safe/v/unstable.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![License](https://poser.pugx.org/thecodingmachine/safe/license.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![Build Status](https://travis-ci.org/thecodingmachine/safe.svg?branch=master)](https://travis-ci.org/thecodingmachine/safe)
[![Continuous Integration](https://github.com/thecodingmachine/safe/workflows/Continuous%20Integration/badge.svg)](https://github.com/thecodingmachine/safe/actions)
[![codecov](https://codecov.io/gh/thecodingmachine/safe/branch/master/graph/badge.svg)](https://codecov.io/gh/thecodingmachine/safe)
Safe PHP
========
A set of core PHP functions rewritten to throw exceptions instead of returning `false` when an error is encountered.
## The problem
Most PHP core functions were written before exception handling was added to the language. Therefore, most PHP functions
do not throw exceptions. Instead, they return `false` in case of error.
But most of us are too lazy to check explicitly for every single return of every core PHP function.
```php
// This code is incorrect. Twice.
// "file_get_contents" can return false if the file does not exists
// "json_decode" can return false if the file content is not valid JSON
$content = file_get_contents('foobar.json');
$foobar = json_decode($content);
```
The correct version of this code would be:
```php
$content = file_get_contents('foobar.json');
if ($content === false) {
throw new FileLoadingException('Could not load file foobar.json');
}
$foobar = json_decode($content);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new FileLoadingException('foobar.json does not contain valid JSON: '.json_last_error_msg());
}
```
Obviously, while this snippet is correct, it is less easy to read.
## The solution
Enter *thecodingmachine/safe* aka Safe-PHP.
Safe-PHP redeclares all core PHP functions. The new PHP functions act exactly as the old ones, except they
throw exceptions properly when an error is encountered. The "safe" functions have the same name as the core PHP
functions, except they are in the `Safe` namespace.
```php
use function Safe\file_get_contents;
use function Safe\json_decode;
// This code is both safe and simple!
$content = file_get_contents('foobar.json');
$foobar = json_decode($content);
```
All PHP functions that can return `false` on error are part of Safe.
In addition, Safe also provide 2 'Safe' classes: `Safe\DateTime` and `Safe\DateTimeImmutable` whose methods will throw exceptions instead of returning false.
## PHPStan integration
> Yeah... but I must explicitly think about importing the "safe" variant of the function, for each and every file of my application.
> I'm sure I will forget some "use function" statements!
Fear not! thecodingmachine/safe comes with a PHPStan rule.
Never heard of [PHPStan](https://github.com/phpstan/phpstan) before?
Check it out, it's an amazing code analyzer for PHP.
Simply install the Safe rule in your PHPStan setup (explained in the "Installation" section) and PHPStan will let you know each time you are using an "unsafe" function.
The code below will trigger this warning:
```php
$content = file_get_contents('foobar.json');
```
> Function file_get_contents is unsafe to use. It can return FALSE instead of throwing an exception. Please add 'use function Safe\\file_get_contents;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.
## Installation
Use composer to install Safe-PHP:
```bash
$ composer require thecodingmachine/safe
```
*Highly recommended*: install PHPStan and PHPStan extension:
```bash
$ composer require --dev thecodingmachine/phpstan-safe-rule
```
Now, edit your `phpstan.neon` file and add these rules:
```yml
includes:
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
```
## Automated refactoring
You have a large legacy codebase and want to use "Safe-PHP" functions throughout your project? PHPStan will help you
find these functions but changing the namespace of the functions one function at a time might be a tedious task.
Fortunately, Safe comes bundled with a "Rector" configuration file. [Rector](https://github.com/rectorphp/rector) is a command-line
tool that performs instant refactoring of your application.
Run
```bash
$ composer require --dev rector/rector
```
to install `rector/rector`.
Run
```bash
vendor/bin/rector process src/ --config vendor/thecodingmachine/safe/rector-migrate.php
```
to run `rector/rector`.
*Note:* do not forget to replace "src/" with the path to your source directory.
**Important:** the refactoring only performs a "dumb" replacement of functions. It will not modify the way
"false" return values are handled. So if your code was already performing error handling, you will have to deal
with it manually.
Especially, you should look for error handling that was already performed, like:
```php
if (!mkdir($dirPath)) {
// Do something on error
}
```
This code will be refactored by Rector to:
```php
if (!\Safe\mkdir($dirPath)) {
// Do something on error
}
```
You should then (manually) refactor it to:
```php
try {
\Safe\mkdir($dirPath));
} catch (\Safe\FilesystemException $e) {
// Do something on error
}
```
## Performance impact
Safe is loading 1000+ functions from ~85 files on each request. Yet, the performance impact of this loading is quite low.
In case you worry, using Safe will "cost" you ~700µs on each request. The [performance section](performance/README.md)
contains more information regarding the way we tested the performance impact of Safe.
## Learn more
Read [the release article on TheCodingMachine's blog](https://thecodingmachine.io/introducing-safe-php) if you want to
learn more about what triggered the development of Safe-PHP.
## Contributing
The files that contain all the functions are auto-generated from the PHP doc.
Read the [CONTRIBUTING.md](CONTRIBUTING.md) file to learn how to regenerate these files and to contribute to this library.

View File

@ -1,122 +0,0 @@
{
"name": "thecodingmachine/safe",
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
"license": "MIT",
"autoload": {
"classmap": [
"lib/DateTime.php",
"lib/DateTimeImmutable.php",
"lib/Exceptions/",
"deprecated/Exceptions/",
"generated/Exceptions/"
],
"files": [
"deprecated/apc.php",
"deprecated/array.php",
"deprecated/datetime.php",
"deprecated/libevent.php",
"deprecated/password.php",
"deprecated/mssql.php",
"deprecated/stats.php",
"deprecated/strings.php",
"lib/special_cases.php",
"deprecated/mysqli.php",
"generated/apache.php",
"generated/apcu.php",
"generated/array.php",
"generated/bzip2.php",
"generated/calendar.php",
"generated/classobj.php",
"generated/com.php",
"generated/cubrid.php",
"generated/curl.php",
"generated/datetime.php",
"generated/dir.php",
"generated/eio.php",
"generated/errorfunc.php",
"generated/exec.php",
"generated/fileinfo.php",
"generated/filesystem.php",
"generated/filter.php",
"generated/fpm.php",
"generated/ftp.php",
"generated/funchand.php",
"generated/gettext.php",
"generated/gmp.php",
"generated/gnupg.php",
"generated/hash.php",
"generated/ibase.php",
"generated/ibmDb2.php",
"generated/iconv.php",
"generated/image.php",
"generated/imap.php",
"generated/info.php",
"generated/inotify.php",
"generated/json.php",
"generated/ldap.php",
"generated/libxml.php",
"generated/lzf.php",
"generated/mailparse.php",
"generated/mbstring.php",
"generated/misc.php",
"generated/mysql.php",
"generated/network.php",
"generated/oci8.php",
"generated/opcache.php",
"generated/openssl.php",
"generated/outcontrol.php",
"generated/pcntl.php",
"generated/pcre.php",
"generated/pgsql.php",
"generated/posix.php",
"generated/ps.php",
"generated/pspell.php",
"generated/readline.php",
"generated/rpminfo.php",
"generated/rrd.php",
"generated/sem.php",
"generated/session.php",
"generated/shmop.php",
"generated/sockets.php",
"generated/sodium.php",
"generated/solr.php",
"generated/spl.php",
"generated/sqlsrv.php",
"generated/ssdeep.php",
"generated/ssh2.php",
"generated/stream.php",
"generated/strings.php",
"generated/swoole.php",
"generated/uodbc.php",
"generated/uopz.php",
"generated/url.php",
"generated/var.php",
"generated/xdiff.php",
"generated/xml.php",
"generated/xmlrpc.php",
"generated/yaml.php",
"generated/yaz.php",
"generated/zip.php",
"generated/zlib.php"
]
},
"require": {
"php": "^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.5",
"thecodingmachine/phpstan-strict-rules": "^1.0",
"squizlabs/php_codesniffer": "^3.2",
"phpunit/phpunit": "^9.5"
},
"scripts": {
"phpstan": "phpstan analyse lib -c phpstan.neon --level=max --no-progress -vvv",
"cs-fix": "phpcbf",
"cs-check": "phpcs"
},
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
}
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ApcException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class LibeventException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class MssqlException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class MysqliException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace Safe\Exceptions;
/**
* @deprecated This exception is deprecated
*/
class PasswordException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class StatsException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,238 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\ApcException;
/**
* Retrieves cached information and meta-data from APC's data store.
*
* @param string $cache_type If cache_type is "user",
* information about the user cache will be returned.
*
* If cache_type is "filehits",
* information about which files have been served from the bytecode cache
* for the current request will be returned. This feature must be enabled at
* compile time using --enable-filehits.
*
* If an invalid or no cache_type is specified, information about
* the system cache (cached files) will be returned.
* @param bool $limited If limited is TRUE, the
* return value will exclude the individual list of cache entries. This
* is useful when trying to optimize calls for statistics gathering.
* @return array Array of cached data (and meta-data)
* @throws ApcException
*
*/
function apc_cache_info(string $cache_type = '', bool $limited = false): array
{
error_clear_last();
$result = \apc_cache_info($cache_type, $limited);
if ($result === false) {
throw ApcException::createFromPhpError();
}
return $result;
}
/**
* apc_cas updates an already existing integer value if the
* old parameter matches the currently stored value
* with the value of the new parameter.
*
* @param string $key The key of the value being updated.
* @param int $old The old value (the value currently stored).
* @param int $new The new value to update to.
* @throws ApcException
*
*/
function apc_cas(string $key, int $old, int $new): void
{
error_clear_last();
$result = \apc_cas($key, $old, $new);
if ($result === false) {
throw ApcException::createFromPhpError();
}
}
/**
* Stores a file in the bytecode cache, bypassing all filters.
*
* @param string $filename Full or relative path to a PHP file that will be compiled and stored in
* the bytecode cache.
* @param bool $atomic
* @return mixed Returns TRUE on success.
* @throws ApcException
*
*/
function apc_compile_file(string $filename, bool $atomic = true)
{
error_clear_last();
$result = \apc_compile_file($filename, $atomic);
if ($result === false) {
throw ApcException::createFromPhpError();
}
return $result;
}
/**
* Decreases a stored integer value.
*
* @param string $key The key of the value being decreased.
* @param int $step The step, or value to decrease.
* @param bool|null $success Optionally pass the success or fail boolean value to
* this referenced variable.
* @return int Returns the current value of key's value on success
* @throws ApcException
*
*/
function apc_dec(string $key, int $step = 1, ?bool &$success = null): int
{
error_clear_last();
$result = \apc_dec($key, $step, $success);
if ($result === false) {
throw ApcException::createFromPhpError();
}
return $result;
}
/**
* define is notoriously slow. Since the main benefit of
* APC is to increase the performance of scripts/applications, this mechanism
* is provided to streamline the process of mass constant definition. However,
* this function does not perform as well as anticipated.
*
* For a better-performing solution, try the
* hidef extension from PECL.
*
* @param string $key The key serves as the name of the constant set
* being stored. This key is used to retrieve the
* stored constants in apc_load_constants.
* @param array $constants An associative array of constant_name =&gt; value
* pairs. The constant_name must follow the normal
* constant naming rules.
* value must evaluate to a scalar value.
* @param bool $case_sensitive The default behaviour for constants is to be declared case-sensitive;
* i.e. CONSTANT and Constant
* represent different values. If this parameter evaluates to FALSE the
* constants will be declared as case-insensitive symbols.
* @throws ApcException
*
*/
function apc_define_constants(string $key, array $constants, bool $case_sensitive = true): void
{
error_clear_last();
$result = \apc_define_constants($key, $constants, $case_sensitive);
if ($result === false) {
throw ApcException::createFromPhpError();
}
}
/**
* Deletes the given files from the opcode cache.
*
* @param mixed $keys The files to be deleted. Accepts a string,
* array of strings, or an APCIterator
* object.
* @return mixed Returns TRUE on success.
* Or if keys is an array, then
* an empty array is returned on success, or an array of failed files
* is returned.
* @throws ApcException
*
*/
function apc_delete_file($keys)
{
error_clear_last();
$result = \apc_delete_file($keys);
if ($result === false) {
throw ApcException::createFromPhpError();
}
return $result;
}
/**
* Removes a stored variable from the cache.
*
* @param string|string[]|\APCIterator $key The key used to store the value (with
* apc_store).
* @throws ApcException
*
*/
function apc_delete($key): void
{
error_clear_last();
$result = \apc_delete($key);
if ($result === false) {
throw ApcException::createFromPhpError();
}
}
/**
* Increases a stored number.
*
* @param string $key The key of the value being increased.
* @param int $step The step, or value to increase.
* @param bool|null $success Optionally pass the success or fail boolean value to
* this referenced variable.
* @return int Returns the current value of key's value on success
* @throws ApcException
*
*/
function apc_inc(string $key, int $step = 1, ?bool &$success = null): int
{
error_clear_last();
$result = \apc_inc($key, $step, $success);
if ($result === false) {
throw ApcException::createFromPhpError();
}
return $result;
}
/**
* Loads a set of constants from the cache.
*
* @param string $key The name of the constant set (that was stored with
* apc_define_constants) to be retrieved.
* @param bool $case_sensitive The default behaviour for constants is to be declared case-sensitive;
* i.e. CONSTANT and Constant
* represent different values. If this parameter evaluates to FALSE the
* constants will be declared as case-insensitive symbols.
* @throws ApcException
*
*/
function apc_load_constants(string $key, bool $case_sensitive = true): void
{
error_clear_last();
$result = \apc_load_constants($key, $case_sensitive);
if ($result === false) {
throw ApcException::createFromPhpError();
}
}
/**
* Retrieves APC's Shared Memory Allocation information.
*
* @param bool $limited When set to FALSE (default) apc_sma_info will
* return a detailed information about each segment.
* @return array Array of Shared Memory Allocation data; FALSE on failure.
* @throws ApcException
*
*/
function apc_sma_info(bool $limited = false): array
{
error_clear_last();
$result = \apc_sma_info($limited);
if ($result === false) {
throw ApcException::createFromPhpError();
}
return $result;
}

View File

@ -1,301 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\ArrayException;
/**
* array_replace_recursive replaces the values of
* array with the same values from all the following
* arrays. If a key from the first array exists in the second array, its value
* will be replaced by the value from the second array. If the key exists in the
* second array, and not the first, it will be created in the first array.
* If a key only exists in the first array, it will be left as is.
* If several arrays are passed for replacement, they will be processed
* in order, the later array overwriting the previous values.
*
* array_replace_recursive is recursive : it will recurse into
* arrays and apply the same process to the inner value.
*
* When the value in the first array is scalar, it will be replaced
* by the value in the second array, may it be scalar or array.
* When the value in the first array and the second array
* are both arrays, array_replace_recursive will replace
* their respective value recursively.
*
* @param array $array The array in which elements are replaced.
* @param array $replacements Arrays from which elements will be extracted.
* @return array Returns an array.
* @throws ArrayException
*
*/
function array_replace_recursive(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$result = \array_replace_recursive($array, ...$replacements);
} else {
$result = \array_replace_recursive($array);
}
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* array_replace replaces the values of
* array with values having the same keys in each of the following
* arrays. If a key from the first array exists in the second array, its value
* will be replaced by the value from the second array. If the key exists in the
* second array, and not the first, it will be created in the first array.
* If a key only exists in the first array, it will be left as is.
* If several arrays are passed for replacement, they will be processed
* in order, the later arrays overwriting the previous values.
*
* array_replace is not recursive : it will replace
* values in the first array by whatever type is in the second array.
*
* @param array $array The array in which elements are replaced.
* @param array $replacements Arrays from which elements will be extracted.
* Values from later arrays overwrite the previous values.
* @return array Returns an array.
* @throws ArrayException
*
*/
function array_replace(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$result = \array_replace($array, ...$replacements);
} else {
$result = \array_replace($array);
}
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* array_flip returns an array in flip
* order, i.e. keys from array become values and values
* from array become keys.
*
* Note that the values of array need to be valid
* keys, i.e. they need to be either integer or
* string. A warning will be emitted if a value has the wrong
* type, and the key/value pair in question will not be included
* in the result.
*
* If a value has several occurrences, the latest key will be
* used as its value, and all others will be lost.
*
* @param array $array An array of key/value pairs to be flipped.
* @return array Returns the flipped array on success.
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function array_flip(array $array): array
{
error_clear_last();
$result = \array_flip($array);
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* This function sorts an array such that array indices maintain their
* correlation with the array elements they are associated with.
*
* This is used mainly when sorting associative arrays where the actual
* element order is significant.
*
* @param array $array The input array.
* @param int $sort_flags You may modify the behavior of the sort using the optional parameter
* sort_flags, for details see
* sort.
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function arsort(array &$array, int $sort_flags = SORT_REGULAR): void
{
error_clear_last();
$result = \arsort($array, $sort_flags);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* This function sorts an array such that array indices maintain
* their correlation with the array elements they are associated
* with. This is used mainly when sorting associative arrays where
* the actual element order is significant.
*
* @param array $array The input array.
* @param int $sort_flags You may modify the behavior of the sort using the optional
* parameter sort_flags, for details
* see sort.
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*/
function asort(array &$array, int $sort_flags = SORT_REGULAR): void
{
error_clear_last();
$result = \asort($array, $sort_flags);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* Sorts an array by key in reverse order, maintaining key to data
* correlations. This is useful mainly for associative arrays.
*
* @param array $array The input array.
* @param int $sort_flags You may modify the behavior of the sort using the optional parameter
* sort_flags, for details see
* sort.
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function krsort(array &$array, int $sort_flags = SORT_REGULAR): void
{
error_clear_last();
$result = \krsort($array, $sort_flags);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* Sorts an array by key, maintaining key to data correlations. This is
* useful mainly for associative arrays.
*
* @param array $array The input array.
* @param int $sort_flags You may modify the behavior of the sort using the optional
* parameter sort_flags, for details
* see sort.
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function ksort(array &$array, int $sort_flags = SORT_REGULAR): void
{
error_clear_last();
$result = \ksort($array, $sort_flags);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* This function sorts an array. Elements will be arranged from
* lowest to highest when this function has completed.
*
* @param array $array The input array.
* @param int $sort_flags The optional second parameter sort_flags
* may be used to modify the sorting behavior using these values:
*
* Sorting type flags:
*
*
* SORT_REGULAR - compare items normally;
* the details are described in the comparison operators section
*
*
* SORT_NUMERIC - compare items numerically
*
*
* SORT_STRING - compare items as strings
*
*
*
* SORT_LOCALE_STRING - compare items as
* strings, based on the current locale. It uses the locale,
* which can be changed using setlocale
*
*
*
*
* SORT_NATURAL - compare items as strings
* using "natural ordering" like natsort
*
*
*
*
* SORT_FLAG_CASE - can be combined
* (bitwise OR) with
* SORT_STRING or
* SORT_NATURAL to sort strings case-insensitively
*
*
*
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*/
function sort(array &$array, int $sort_flags = SORT_REGULAR): void
{
error_clear_last();
$result = \sort($array, $sort_flags);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* This function will sort an array by its values using a user-supplied
* comparison function. If the array you wish to sort needs to be sorted by
* some non-trivial criteria, you should use this function.
*
* @param array $array The input array.
* @param callable $value_compare_func The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
* Note that before PHP 7.0.0 this integer had to be in the range from -2147483648 to 2147483647.
*
* Returning non-integer values from the comparison
* function, such as float, will result in an internal cast to
* integer of the callback's return value. So values such as
* 0.99 and 0.1 will both be cast to an integer value of 0, which will
* compare such values as equal.
* @throws ArrayException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function usort(array &$array, callable $value_compare_func): void
{
error_clear_last();
$result = \usort($array, $value_compare_func);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
}
/**
* Creates an array by using the values from the
* keys array as keys and the values from the
* values array as the corresponding values.
*
* @param array $keys Array of keys to be used. Illegal values for key will be
* converted to string.
* @param array $values Array of values to be used
* @return array Returns the combined array, FALSE if the number of elements
* for each array isn't equal.
* @throws ArrayException
* @deprecated
*
*/
function array_combine(array $keys, array $values): array
{
error_clear_last();
$result = \array_combine($keys, $values);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
return $result;
}

View File

@ -1,36 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\DatetimeException;
/**
* Identical to the date function except that
* the time returned is Greenwich Mean Time (GMT).
*
* @param string $format The format of the outputted date string. See the formatting
* options for the date function.
* @param int $timestamp The optional timestamp parameter is an
* integer Unix timestamp that defaults to the current
* local time if a timestamp is not given. In other
* words, it defaults to the value of time.
* @return string Returns a formatted date string. If a non-numeric value is used for
* timestamp, FALSE is returned and an
* E_WARNING level error is emitted.
* @throws DatetimeException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function gmdate(string $format, int $timestamp = null): string
{
error_clear_last();
if ($timestamp !== null) {
$result = \gmdate($format, $timestamp);
} else {
$result = \gmdate($format);
}
if ($result === false) {
throw DatetimeException::createFromPhpError();
}
return $result;
}

View File

@ -1,71 +0,0 @@
<?php
return [
'apc_cache_info',
'apc_cas',
'apc_compile_file',
'apc_dec',
'apc_define_constants',
'apc_delete',
'apc_delete_file',
'apc_inc',
'apc_load_constants',
'apc_sma_info',
'arsort',
'array_replace',
'array_replace_recursive',
'array_combine',
'array_flip',
'asort',
'event_add',
'event_base_loopbreak',
'event_base_loopexit',
'event_base_new',
'event_base_priority_init',
'event_base_reinit',
'event_base_set',
'event_buffer_base_set',
'event_buffer_disable',
'event_buffer_enable',
'event_buffer_new',
'event_buffer_priority_set',
'event_buffer_set_callback',
'event_buffer_write',
'event_del',
'event_new',
'event_priority_set',
'event_set',
'event_timer_set',
'gmdate',
'imagepsencodefont',
'imagepsextendfont',
'imagepsfreefont',
'imagepsslantfont',
'krsort',
'ksort',
'mssql_bind',
'mssql_close',
'mssql_connect',
'mssql_data_seek',
'mssql_field_length',
'mssql_field_name',
'mssql_field_seek',
'mssql_field_type',
'mssql_free_result',
'mssql_free_statement',
'mssql_init',
'mssql_pconnect',
'mssql_query',
'mssql_select_db',
'mysqli_get_client_stats',
'password_hash',
'sort',
'stats_covariance',
'stats_standard_deviation',
'stats_stat_correlation',
'stats_stat_innerproduct',
'stats_variance',
'substr',
'usort',
'vsprintf',
];

View File

@ -1,496 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\LibeventException;
/**
* event_add schedules the execution of the event
* when the event specified in event_set occurs or in at least the time
* specified by the timeout argument. If
* timeout was not specified, not timeout is set. The
* event must be already initalized by event_set
* and event_base_set functions. If the
* event already has a timeout set, it is replaced by
* the new one.
*
* @param resource $event Valid event resource.
* @param int $timeout Optional timeout (in microseconds).
* @throws LibeventException
*
*/
function event_add($event, int $timeout = -1): void
{
error_clear_last();
$result = \event_add($event, $timeout);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Abort the active event loop immediately. The behaviour is similar to
* break statement.
*
* @param resource $event_base Valid event base resource.
* @throws LibeventException
*
*/
function event_base_loopbreak($event_base): void
{
error_clear_last();
$result = \event_base_loopbreak($event_base);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* The next event loop iteration after the given timer expires will complete
* normally, then exit without blocking for events again.
*
* @param resource $event_base Valid event base resource.
* @param int $timeout Optional timeout parameter (in microseconds).
* @throws LibeventException
*
*/
function event_base_loopexit($event_base, int $timeout = -1): void
{
error_clear_last();
$result = \event_base_loopexit($event_base, $timeout);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Returns new event base, which can be used later in event_base_set,
* event_base_loop and other functions.
*
* @return resource event_base_new returns valid event base resource on
* success.
* @throws LibeventException
*
*/
function event_base_new()
{
error_clear_last();
$result = \event_base_new();
if ($result === false) {
throw LibeventException::createFromPhpError();
}
return $result;
}
/**
* Sets the number of different event priority levels.
*
* By default all events are scheduled with the same priority
* (npriorities/2).
* Using event_base_priority_init you can change the number
* of event priority levels and then set a desired priority for each event.
*
* @param resource $event_base Valid event base resource.
* @param int $npriorities The number of event priority levels.
* @throws LibeventException
*
*/
function event_base_priority_init($event_base, int $npriorities): void
{
error_clear_last();
$result = \event_base_priority_init($event_base, $npriorities);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Some event mechanisms do not survive across fork. The
* event_base needs to be reinitialized with this
* function.
*
* @param resource $event_base Valid event base resource that needs to be re-initialized.
* @throws LibeventException
*
*/
function event_base_reinit($event_base): void
{
error_clear_last();
$result = \event_base_reinit($event_base);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Associates the event_base with the
* event.
*
* @param resource $event Valid event resource.
* @param resource $event_base Valid event base resource.
* @throws LibeventException
*
*/
function event_base_set($event, $event_base): void
{
error_clear_last();
$result = \event_base_set($event, $event_base);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Assign the specified bevent to the
* event_base.
*
* @param resource $bevent Valid buffered event resource.
* @param resource $event_base Valid event base resource.
* @throws LibeventException
*
*/
function event_buffer_base_set($bevent, $event_base): void
{
error_clear_last();
$result = \event_buffer_base_set($bevent, $event_base);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Disables the specified buffered event.
*
* @param resource $bevent Valid buffered event resource.
* @param int $events Any combination of EV_READ and
* EV_WRITE.
* @throws LibeventException
*
*/
function event_buffer_disable($bevent, int $events): void
{
error_clear_last();
$result = \event_buffer_disable($bevent, $events);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Enables the specified buffered event.
*
* @param resource $bevent Valid buffered event resource.
* @param int $events Any combination of EV_READ and
* EV_WRITE.
* @throws LibeventException
*
*/
function event_buffer_enable($bevent, int $events): void
{
error_clear_last();
$result = \event_buffer_enable($bevent, $events);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Libevent provides an abstraction layer on top of the regular event API.
* Using buffered event you don't need to deal with the I/O manually, instead
* it provides input and output buffers that get filled and drained
* automatically.
*
* @param resource $stream Valid PHP stream resource. Must be castable to file descriptor.
* @param mixed $readcb Callback to invoke where there is data to read, or NULL if
* no callback is desired.
* @param mixed $writecb Callback to invoke where the descriptor is ready for writing,
* or NULL if no callback is desired.
* @param mixed $errorcb Callback to invoke where there is an error on the descriptor, cannot be
* NULL.
* @param mixed $arg An argument that will be passed to each of the callbacks (optional).
* @return resource event_buffer_new returns new buffered event resource
* on success.
* @throws LibeventException
*
*/
function event_buffer_new($stream, $readcb, $writecb, $errorcb, $arg = null)
{
error_clear_last();
if ($arg !== null) {
$result = \event_buffer_new($stream, $readcb, $writecb, $errorcb, $arg);
} else {
$result = \event_buffer_new($stream, $readcb, $writecb, $errorcb);
}
if ($result === false) {
throw LibeventException::createFromPhpError();
}
return $result;
}
/**
* Assign a priority to the bevent.
*
* @param resource $bevent Valid buffered event resource.
* @param int $priority Priority level. Cannot be less than zero and cannot exceed maximum
* priority level of the event base (see event_base_priority_init).
* @throws LibeventException
*
*/
function event_buffer_priority_set($bevent, int $priority): void
{
error_clear_last();
$result = \event_buffer_priority_set($bevent, $priority);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Sets or changes existing callbacks for the buffered event.
*
* @param resource $event Valid buffered event resource.
* @param mixed $readcb Callback to invoke where there is data to read, or NULL if
* no callback is desired.
* @param mixed $writecb Callback to invoke where the descriptor is ready for writing,
* or NULL if no callback is desired.
* @param mixed $errorcb Callback to invoke where there is an error on the descriptor, cannot be
* NULL.
* @param mixed $arg An argument that will be passed to each of the callbacks (optional).
* @throws LibeventException
*
*/
function event_buffer_set_callback($event, $readcb, $writecb, $errorcb, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$result = \event_buffer_set_callback($event, $readcb, $writecb, $errorcb, $arg);
} else {
$result = \event_buffer_set_callback($event, $readcb, $writecb, $errorcb);
}
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Writes data to the specified buffered event. The data is appended to the
* output buffer and written to the descriptor when it becomes available for
* writing.
*
* @param resource $bevent Valid buffered event resource.
* @param string $data The data to be written.
* @param int $data_size Optional size parameter. event_buffer_write writes
* all the data by default.
* @throws LibeventException
*
*/
function event_buffer_write($bevent, string $data, int $data_size = -1): void
{
error_clear_last();
$result = \event_buffer_write($bevent, $data, $data_size);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Cancels the event.
*
* @param resource $event Valid event resource.
* @throws LibeventException
*
*/
function event_del($event): void
{
error_clear_last();
$result = \event_del($event);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Creates and returns a new event resource.
*
* @return resource event_new returns a new event resource on success.
* @throws LibeventException
*
*/
function event_new()
{
error_clear_last();
$result = \event_new();
if ($result === false) {
throw LibeventException::createFromPhpError();
}
return $result;
}
/**
* Assign a priority to the event.
*
* @param resource $event Valid event resource.
* @param int $priority Priority level. Cannot be less than zero and cannot exceed maximum
* priority level of the event base (see
* event_base_priority_init).
* @throws LibeventException
*
*/
function event_priority_set($event, int $priority): void
{
error_clear_last();
$result = \event_priority_set($event, $priority);
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Prepares the event to be used in event_add. The event
* is prepared to call the function specified by the callback
* on the events specified in parameter events, which
* is a set of the following flags: EV_TIMEOUT,
* EV_SIGNAL, EV_READ,
* EV_WRITE and EV_PERSIST.
*
* If EV_SIGNAL bit is set in parameter events,
* the fd is interpreted as signal number.
*
* After initializing the event, use event_base_set to
* associate the event with its event base.
*
* In case of matching event, these three arguments are passed to the
* callback function:
*
*
* fd
*
*
* Signal number or resource indicating the stream.
*
*
*
*
* events
*
*
* A flag indicating the event. Consists of the following flags:
* EV_TIMEOUT, EV_SIGNAL,
* EV_READ, EV_WRITE
* and EV_PERSIST.
*
*
*
*
* arg
*
*
* Optional parameter, previously passed to event_set
* as arg.
*
*
*
*
*
* @param resource $event Valid event resource.
* @param mixed $fd Valid PHP stream resource. The stream must be castable to file
* descriptor, so you most likely won't be able to use any of filtered
* streams.
* @param int $events A set of flags indicating the desired event, can be
* EV_READ and/or EV_WRITE.
* The additional flag EV_PERSIST makes the event
* to persist until event_del is called, otherwise
* the callback is invoked only once.
* @param mixed $callback Callback function to be called when the matching event occurs.
* @param mixed $arg Optional callback parameter.
* @throws LibeventException
*
*/
function event_set($event, $fd, int $events, $callback, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$result = \event_set($event, $fd, $events, $callback, $arg);
} else {
$result = \event_set($event, $fd, $events, $callback);
}
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}
/**
* Prepares the timer event to be used in event_add. The
* event is prepared to call the function specified by the
* callback when the event timeout elapses.
*
* After initializing the event, use event_base_set to
* associate the event with its event base.
*
* In case of matching event, these three arguments are passed to the
* callback function:
*
*
* fd
*
*
* Signal number or resource indicating the stream.
*
*
*
*
* events
*
*
* A flag indicating the event. This will always be
* EV_TIMEOUT for timer events.
*
*
*
*
* arg
*
*
* Optional parameter, previously passed to
* event_timer_set as arg.
*
*
*
*
*
* @param resource $event Valid event resource.
* @param callable $callback Callback function to be called when the matching event occurs.
* @param mixed $arg Optional callback parameter.
* @throws LibeventException
*
*/
function event_timer_set($event, callable $callback, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$result = \event_timer_set($event, $callback, $arg);
} else {
$result = \event_timer_set($event, $callback);
}
if ($result === false) {
throw LibeventException::createFromPhpError();
}
}

View File

@ -1,426 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\MssqlException;
/**
* Binds a parameter to a stored procedure or a remote stored procedure.
*
* @param resource $stmt Statement resource, obtained with mssql_init.
* @param string $param_name The parameter name, as a string.
*
* You have to include the @ character, like in the
* T-SQL syntax. See the explanation included in
* mssql_execute.
* @param mixed $var The PHP variable you'll bind the MSSQL parameter to. It is passed by
* reference, to retrieve OUTPUT and RETVAL values after
* the procedure execution.
* @param int $type One of: SQLTEXT,
* SQLVARCHAR, SQLCHAR,
* SQLINT1, SQLINT2,
* SQLINT4, SQLBIT,
* SQLFLT4, SQLFLT8,
* SQLFLTN.
* @param bool $is_output Whether the value is an OUTPUT parameter or not. If it's an OUTPUT
* parameter and you don't mention it, it will be treated as a normal
* input parameter and no error will be thrown.
* @param bool $is_null Whether the parameter is NULL or not. Passing the NULL value as
* var will not do the job.
* @param int $maxlen Used with char/varchar values. You have to indicate the length of the
* data so if the parameter is a varchar(50), the type must be
* SQLVARCHAR and this value 50.
* @throws MssqlException
*
*/
function mssql_bind($stmt, string $param_name, &$var, int $type, bool $is_output = false, bool $is_null = false, int $maxlen = -1): void
{
error_clear_last();
$result = \mssql_bind($stmt, $param_name, $var, $type, $is_output, $is_null, $maxlen);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}
/**
* Closes the link to a MS SQL Server database that's associated with the
* specified link identifier. If the link identifier isn't specified, the
* last opened link is assumed.
*
* Note that this isn't usually necessary, as non-persistent open
* links are automatically closed at the end of the script's
* execution.
*
* @param resource $link_identifier A MS SQL link identifier, returned by
* mssql_connect.
*
* This function will not close persistent links generated by
* mssql_pconnect.
* @throws MssqlException
*
*/
function mssql_close($link_identifier = null): void
{
error_clear_last();
if ($link_identifier !== null) {
$result = \mssql_close($link_identifier);
} else {
$result = \mssql_close();
}
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}
/**
* mssql_connect establishes a connection to a
* MS SQL server.
*
* The link to the server will be closed as soon as the execution of
* the script ends, unless it's closed earlier by explicitly calling
* mssql_close.
*
* @param string $servername The MS SQL server. It can also include a port number, e.g.
* hostname:port (Linux), or
* hostname,port (Windows).
* @param string $username The username.
* @param string $password The password.
* @param bool $new_link If a second call is made to mssql_connect with the
* same arguments, no new link will be established, but instead, the link
* identifier of the already opened link will be returned. This parameter
* modifies this behavior and makes mssql_connect
* always open a new link, even if mssql_connect was
* called before with the same parameters.
* @return resource Returns a MS SQL link identifier on success.
* @throws MssqlException
*
*/
function mssql_connect(string $servername = null, string $username = null, string $password = null, bool $new_link = false)
{
error_clear_last();
if ($new_link !== false) {
$result = \mssql_connect($servername, $username, $password, $new_link);
} elseif ($password !== null) {
$result = \mssql_connect($servername, $username, $password);
} elseif ($username !== null) {
$result = \mssql_connect($servername, $username);
} elseif ($servername !== null) {
$result = \mssql_connect($servername);
} else {
$result = \mssql_connect();
}
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* mssql_data_seek moves the internal row
* pointer of the MS SQL result associated with the specified result
* identifier to point to the specified row number, first row being
* number 0. The next call to mssql_fetch_row
* would return that row.
*
* @param resource $result_identifier The result resource that is being evaluated.
* @param int $row_number The desired row number of the new result pointer.
* @throws MssqlException
*
*/
function mssql_data_seek($result_identifier, int $row_number): void
{
error_clear_last();
$result = \mssql_data_seek($result_identifier, $row_number);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}
/**
* Returns the length of field no. offset in
* result.
*
* @param resource $result The result resource that is being evaluated. This result comes from a
* call to mssql_query.
* @param int $offset The field offset, starts at 0. If omitted, the current field is used.
* @return int The length of the specified field index on success.
* @throws MssqlException
*
*/
function mssql_field_length($result, int $offset = -1): int
{
error_clear_last();
$result = \mssql_field_length($result, $offset);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* Returns the name of field no. offset in
* result.
*
* @param resource $result The result resource that is being evaluated. This result comes from a
* call to mssql_query.
* @param int $offset The field offset, starts at 0. If omitted, the current field is used.
* @return string The name of the specified field index on success.
* @throws MssqlException
*
*/
function mssql_field_name($result, int $offset = -1): string
{
error_clear_last();
$result = \mssql_field_name($result, $offset);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* Seeks to the specified field offset. If the next call to
* mssql_fetch_field won't include a field
* offset, this field would be returned.
*
* @param resource $result The result resource that is being evaluated. This result comes from a
* call to mssql_query.
* @param int $field_offset The field offset, starts at 0.
* @throws MssqlException
*
*/
function mssql_field_seek($result, int $field_offset): void
{
error_clear_last();
$result = \mssql_field_seek($result, $field_offset);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}
/**
* Returns the type of field no. offset in
* result.
*
* @param resource $result The result resource that is being evaluated. This result comes from a
* call to mssql_query.
* @param int $offset The field offset, starts at 0. If omitted, the current field is used.
* @return string The type of the specified field index on success.
* @throws MssqlException
*
*/
function mssql_field_type($result, int $offset = -1): string
{
error_clear_last();
$result = \mssql_field_type($result, $offset);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* mssql_free_result only needs to be called
* if you are worried about using too much memory while your script
* is running. All result memory will automatically be freed when
* the script ends. You may call mssql_free_result
* with the result identifier as an argument and the associated
* result memory will be freed.
*
* @param resource $result The result resource that is being freed. This result comes from a
* call to mssql_query.
* @throws MssqlException
*
*/
function mssql_free_result($result): void
{
error_clear_last();
$result = \mssql_free_result($result);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}
/**
* mssql_free_statement only needs to be called
* if you are worried about using too much memory while your script
* is running. All statement memory will automatically be freed when
* the script ends. You may call mssql_free_statement
* with the statement identifier as an argument and the associated
* statement memory will be freed.
*
* @param resource $stmt Statement resource, obtained with mssql_init.
* @throws MssqlException
*
*/
function mssql_free_statement($stmt): void
{
error_clear_last();
$result = \mssql_free_statement($stmt);
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}
/**
* Initializes a stored procedure or a remote stored procedure.
*
* @param string $sp_name Stored procedure name, like ownew.sp_name or
* otherdb.owner.sp_name.
* @param resource $link_identifier A MS SQL link identifier, returned by
* mssql_connect.
* @return resource Returns a resource identifier "statement", used in subsequent calls to
* mssql_bind and mssql_executes.
* @throws MssqlException
*
*/
function mssql_init(string $sp_name, $link_identifier = null)
{
error_clear_last();
if ($link_identifier !== null) {
$result = \mssql_init($sp_name, $link_identifier);
} else {
$result = \mssql_init($sp_name);
}
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* mssql_pconnect acts very much like
* mssql_connect with two major differences.
*
* First, when connecting, the function would first try to find a
* (persistent) link that's already open with the same host,
* username and password. If one is found, an identifier for it
* will be returned instead of opening a new connection.
*
* Second, the connection to the SQL server will not be closed when
* the execution of the script ends. Instead, the link will remain
* open for future use (mssql_close will not
* close links established by mssql_pconnect).
*
* This type of links is therefore called 'persistent'.
*
* @param string $servername The MS SQL server. It can also include a port number. e.g.
* hostname:port.
* @param string $username The username.
* @param string $password The password.
* @param bool $new_link If a second call is made to mssql_pconnect with
* the same arguments, no new link will be established, but instead, the
* link identifier of the already opened link will be returned. This
* parameter modifies this behavior and makes
* mssql_pconnect always open a new link, even if
* mssql_pconnect was called before with the same
* parameters.
* @return resource Returns a positive MS SQL persistent link identifier on success.
* @throws MssqlException
*
*/
function mssql_pconnect(string $servername = null, string $username = null, string $password = null, bool $new_link = false)
{
error_clear_last();
if ($new_link !== false) {
$result = \mssql_pconnect($servername, $username, $password, $new_link);
} elseif ($password !== null) {
$result = \mssql_pconnect($servername, $username, $password);
} elseif ($username !== null) {
$result = \mssql_pconnect($servername, $username);
} elseif ($servername !== null) {
$result = \mssql_pconnect($servername);
} else {
$result = \mssql_pconnect();
}
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* mssql_query sends a query to the currently active
* database on the server that's associated with the specified link
* identifier.
*
* @param string $query An SQL query.
* @param resource $link_identifier A MS SQL link identifier, returned by
* mssql_connect or
* mssql_pconnect.
*
* If the link identifier isn't specified, the last opened link is
* assumed. If no link is open, the function tries to establish a link
* as if mssql_connect was called, and use it.
* @param int $batch_size The number of records to batch in the buffer.
* @return mixed Returns a MS SQL result resource on success, TRUE if no rows were
* returned.
* @throws MssqlException
*
*/
function mssql_query(string $query, $link_identifier = null, int $batch_size = 0)
{
error_clear_last();
if ($batch_size !== 0) {
$result = \mssql_query($query, $link_identifier, $batch_size);
} elseif ($link_identifier !== null) {
$result = \mssql_query($query, $link_identifier);
} else {
$result = \mssql_query($query);
}
if ($result === false) {
throw MssqlException::createFromPhpError();
}
return $result;
}
/**
* mssql_select_db sets the current active
* database on the server that's associated with the specified link
* identifier.
*
* Every subsequent call to mssql_query will be
* made on the active database.
*
* @param string $database_name The database name.
*
* To escape the name of a database that contains spaces, hyphens ("-"),
* or any other exceptional characters, the database name must be
* enclosed in brackets, as is shown in the example, below. This
* technique must also be applied when selecting a database name that is
* also a reserved word (such as primary).
* @param resource $link_identifier A MS SQL link identifier, returned by
* mssql_connect or
* mssql_pconnect.
*
* If no link identifier is specified, the last opened link is assumed.
* If no link is open, the function will try to establish a link as if
* mssql_connect was called, and use it.
* @throws MssqlException
*
*/
function mssql_select_db(string $database_name, $link_identifier = null): void
{
error_clear_last();
if ($link_identifier !== null) {
$result = \mssql_select_db($database_name, $link_identifier);
} else {
$result = \mssql_select_db($database_name);
}
if ($result === false) {
throw MssqlException::createFromPhpError();
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\MysqliException;
/**
* Returns client per-process statistics.
*
* @return array Returns an array with client stats if success, FALSE otherwise.
* @throws MysqliException
*
*/
function mysqli_get_client_stats(): array
{
error_clear_last();
$result = \mysqli_get_client_stats();
if ($result === false) {
throw MysqliException::createFromPhpError();
}
return $result;
}

View File

@ -1,127 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\PasswordException;
/**
* password_hash creates a new password hash using a strong one-way hashing
* algorithm. password_hash is compatible with crypt.
* Therefore, password hashes created by crypt can be used with
* password_hash.
*
*
*
*
* PASSWORD_DEFAULT - Use the bcrypt algorithm (default as of PHP 5.5.0).
* Note that this constant is designed to change over time as new and stronger algorithms are added
* to PHP. For that reason, the length of the result from using this identifier can change over
* time. Therefore, it is recommended to store the result in a database column that can expand
* beyond 60 characters (255 characters would be a good choice).
*
*
*
*
* PASSWORD_BCRYPT - Use the CRYPT_BLOWFISH algorithm to
* create the hash. This will produce a standard crypt compatible hash using
* the "$2y$" identifier. The result will always be a 60 character string.
*
*
*
*
* PASSWORD_ARGON2I - Use the Argon2i hashing algorithm to create the hash.
* This algorithm is only available if PHP has been compiled with Argon2 support.
*
*
*
*
* PASSWORD_ARGON2ID - Use the Argon2id hashing algorithm to create the hash.
* This algorithm is only available if PHP has been compiled with Argon2 support.
*
*
*
*
*
*
*
* salt (string) - to manually provide a salt to use when hashing the password.
* Note that this will override and prevent a salt from being automatically generated.
*
*
* If omitted, a random salt will be generated by password_hash for
* each password hashed. This is the intended mode of operation.
*
*
*
* The salt option has been deprecated as of PHP 7.0.0. It is now
* preferred to simply use the salt that is generated by default.
*
*
*
*
*
* cost (integer) - which denotes the algorithmic cost that should be used.
* Examples of these values can be found on the crypt page.
*
*
* If omitted, a default value of 10 will be used. This is a good
* baseline cost, but you may want to consider increasing it depending on your hardware.
*
*
*
*
*
*
*
* memory_cost (integer) - Maximum memory (in kibibytes) that may
* be used to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_MEMORY_COST.
*
*
*
*
* time_cost (integer) - Maximum amount of time it may
* take to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_TIME_COST.
*
*
*
*
* threads (integer) - Number of threads to use for computing
* the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_THREADS.
*
*
*
*
* @param string $password The user's password.
*
* Using the PASSWORD_BCRYPT as the
* algorithm, will result
* in the password parameter being truncated to a
* maximum length of 72 characters.
* @param int|string|null $algo A password algorithm constant denoting the algorithm to use when hashing the password.
* @param array $options An associative array containing options. See the password algorithm constants for documentation on the supported options for each algorithm.
*
* If omitted, a random salt will be created and the default cost will be
* used.
* @return string Returns the hashed password.
*
* The used algorithm, cost and salt are returned as part of the hash. Therefore,
* all information that's needed to verify the hash is included in it. This allows
* the password_verify function to verify the hash without
* needing separate storage for the salt or algorithm information.
* @throws PasswordException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function password_hash(string $password, $algo, array $options = null): string
{
error_clear_last();
if ($options !== null) {
$result = \password_hash($password, $algo, $options);
} else {
$result = \password_hash($password, $algo);
}
if ($result === false) {
throw PasswordException::createFromPhpError();
}
return $result;
}

View File

@ -1,108 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\StatsException;
/**
* Returns the covariance of a and b.
*
* @param array $a The first array
* @param array $b The second array
* @return float Returns the covariance of a and b.
* @throws StatsException
*
*/
function stats_covariance(array $a, array $b): float
{
error_clear_last();
$result = \stats_covariance($a, $b);
if ($result === false) {
throw StatsException::createFromPhpError();
}
return $result;
}
/**
* Returns the standard deviation of the values in a.
*
* @param array $a The array of data to find the standard deviation for. Note that all
* values of the array will be cast to float.
* @param bool $sample Indicates if a represents a sample of the
* population; defaults to FALSE.
* @return float Returns the standard deviation on success; FALSE on failure.
* @throws StatsException
*
*/
function stats_standard_deviation(array $a, bool $sample = false): float
{
error_clear_last();
$result = \stats_standard_deviation($a, $sample);
if ($result === false) {
throw StatsException::createFromPhpError();
}
return $result;
}
/**
* Returns the Pearson correlation coefficient between arr1 and arr2.
*
* @param array $arr1 The first array
* @param array $arr2 The second array
* @return float Returns the Pearson correlation coefficient between arr1 and arr2.
* @throws StatsException
*
*/
function stats_stat_correlation(array $arr1, array $arr2): float
{
error_clear_last();
$result = \stats_stat_correlation($arr1, $arr2);
if ($result === false) {
throw StatsException::createFromPhpError();
}
return $result;
}
/**
* Returns the inner product of arr1 and arr2.
*
* @param array $arr1 The first array
* @param array $arr2 The second array
* @return float Returns the inner product of arr1 and arr2.
* @throws StatsException
*
*/
function stats_stat_innerproduct(array $arr1, array $arr2): float
{
error_clear_last();
$result = \stats_stat_innerproduct($arr1, $arr2);
if ($result === false) {
throw StatsException::createFromPhpError();
}
return $result;
}
/**
* Returns the variance of the values in a.
*
* @param array $a The array of data to find the standard deviation for. Note that all
* values of the array will be cast to float.
* @param bool $sample Indicates if a represents a sample of the
* population; defaults to FALSE.
* @return float Returns the variance on success; FALSE on failure.
* @throws StatsException
*
*/
function stats_variance(array $a, bool $sample = false): float
{
error_clear_last();
$result = \stats_variance($a, $sample);
if ($result === false) {
throw StatsException::createFromPhpError();
}
return $result;
}

View File

@ -1,677 +0,0 @@
<?php
namespace Safe;
use Safe\Exceptions\StringsException;
/**
* Returns a string produced according to the formatting string
* format.
*
* @param string $format The format string is composed of zero or more directives:
* ordinary characters (excluding %) that are
* copied directly to the result and conversion
* specifications, each of which results in fetching its
* own parameter.
*
* A conversion specification follows this prototype:
* %[argnum$][flags][width][.precision]specifier.
*
* An integer followed by a dollar sign $,
* to specify which number argument to treat in the conversion.
*
*
* Flags
*
*
*
* Flag
* Description
*
*
*
*
* -
*
* Left-justify within the given field width;
* Right justification is the default
*
*
*
* +
*
* Prefix positive numbers with a plus sign
* +; Default only negative
* are prefixed with a negative sign.
*
*
*
* (space)
*
* Pads the result with spaces.
* This is the default.
*
*
*
* 0
*
* Only left-pads numbers with zeros.
* With s specifiers this can
* also right-pad with zeros.
*
*
*
* '(char)
*
* Pads the result with the character (char).
*
*
*
*
*
*
* An integer that says how many characters (minimum)
* this conversion should result in.
*
* A period . followed by an integer
* who's meaning depends on the specifier:
*
*
*
* For e, E,
* f and F
* specifiers: this is the number of digits to be printed
* after the decimal point (by default, this is 6).
*
*
*
*
* For g and G
* specifiers: this is the maximum number of significant
* digits to be printed.
*
*
*
*
* For s specifier: it acts as a cutoff point,
* setting a maximum character limit to the string.
*
*
*
*
*
* If the period is specified without an explicit value for precision,
* 0 is assumed.
*
*
*
*
* Specifiers
*
*
*
* Specifier
* Description
*
*
*
*
* %
*
* A literal percent character. No argument is required.
*
*
*
* b
*
* The argument is treated as an integer and presented
* as a binary number.
*
*
*
* c
*
* The argument is treated as an integer and presented
* as the character with that ASCII.
*
*
*
* d
*
* The argument is treated as an integer and presented
* as a (signed) decimal number.
*
*
*
* e
*
* The argument is treated as scientific notation (e.g. 1.2e+2).
* The precision specifier stands for the number of digits after the
* decimal point since PHP 5.2.1. In earlier versions, it was taken as
* number of significant digits (one less).
*
*
*
* E
*
* Like the e specifier but uses
* uppercase letter (e.g. 1.2E+2).
*
*
*
* f
*
* The argument is treated as a float and presented
* as a floating-point number (locale aware).
*
*
*
* F
*
* The argument is treated as a float and presented
* as a floating-point number (non-locale aware).
* Available as of PHP 5.0.3.
*
*
*
* g
*
*
* General format.
*
*
* Let P equal the precision if nonzero, 6 if the precision is omitted,
* or 1 if the precision is zero.
* Then, if a conversion with style E would have an exponent of X:
*
*
* If P &gt; X 4, the conversion is with style f and precision P (X + 1).
* Otherwise, the conversion is with style e and precision P 1.
*
*
*
*
* G
*
* Like the g specifier but uses
* E and f.
*
*
*
* o
*
* The argument is treated as an integer and presented
* as an octal number.
*
*
*
* s
*
* The argument is treated and presented as a string.
*
*
*
* u
*
* The argument is treated as an integer and presented
* as an unsigned decimal number.
*
*
*
* x
*
* The argument is treated as an integer and presented
* as a hexadecimal number (with lowercase letters).
*
*
*
* X
*
* The argument is treated as an integer and presented
* as a hexadecimal number (with uppercase letters).
*
*
*
*
*
*
* General format.
*
* Let P equal the precision if nonzero, 6 if the precision is omitted,
* or 1 if the precision is zero.
* Then, if a conversion with style E would have an exponent of X:
*
* If P &gt; X 4, the conversion is with style f and precision P (X + 1).
* Otherwise, the conversion is with style e and precision P 1.
*
* The c type specifier ignores padding and width
*
* Attempting to use a combination of the string and width specifiers with character sets that require more than one byte per character may result in unexpected results
*
* Variables will be co-erced to a suitable type for the specifier:
*
* Type Handling
*
*
*
* Type
* Specifiers
*
*
*
*
* string
* s
*
*
* integer
*
* d,
* u,
* c,
* o,
* x,
* X,
* b
*
*
*
* double
*
* g,
* G,
* e,
* E,
* f,
* F
*
*
*
*
*
* @param mixed $params
* @return string Returns a string produced according to the formatting string
* format.
* @throws StringsException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function sprintf(string $format, ...$params): string
{
error_clear_last();
if ($params !== []) {
$result = \sprintf($format, ...$params);
} else {
$result = \sprintf($format);
}
if ($result === false) {
throw StringsException::createFromPhpError();
}
return $result;
}
/**
* Returns the portion of string specified by the
* start and length parameters.
*
* @param string $string The input string.
* @param int $start If start is non-negative, the returned string
* will start at the start'th position in
* string, counting from zero. For instance,
* in the string 'abcdef', the character at
* position 0 is 'a', the
* character at position 2 is
* 'c', and so forth.
*
* If start is negative, the returned string
* will start at the start'th character
* from the end of string.
*
* If string is less than
* start characters long, FALSE will be returned.
*
*
* Using a negative start
*
*
* ]]>
*
*
* @param int $length If length is given and is positive, the string
* returned will contain at most length characters
* beginning from start (depending on the length of
* string).
*
* If length is given and is negative, then that many
* characters will be omitted from the end of string
* (after the start position has been calculated when a
* start is negative). If
* start denotes the position of this truncation or
* beyond, FALSE will be returned.
*
* If length is given and is 0,
* FALSE or NULL, an empty string will be returned.
*
* If length is omitted, the substring starting from
* start until the end of the string will be
* returned.
* @return string Returns the extracted part of string;, or
* an empty string.
* @throws StringsException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*
*/
function substr(string $string, int $start, int $length = null): string
{
error_clear_last();
if ($length !== null) {
$result = \substr($string, $start, $length);
} else {
$result = \substr($string, $start);
}
if ($result === false) {
throw StringsException::createFromPhpError();
}
return $result;
}
/**
* Operates as sprintf but accepts an array of
* arguments, rather than a variable number of arguments.
*
* @param string $format The format string is composed of zero or more directives:
* ordinary characters (excluding %) that are
* copied directly to the result and conversion
* specifications, each of which results in fetching its
* own parameter.
*
* A conversion specification follows this prototype:
* %[argnum$][flags][width][.precision]specifier.
*
* An integer followed by a dollar sign $,
* to specify which number argument to treat in the conversion.
*
*
* Flags
*
*
*
* Flag
* Description
*
*
*
*
* -
*
* Left-justify within the given field width;
* Right justification is the default
*
*
*
* +
*
* Prefix positive numbers with a plus sign
* +; Default only negative
* are prefixed with a negative sign.
*
*
*
* (space)
*
* Pads the result with spaces.
* This is the default.
*
*
*
* 0
*
* Only left-pads numbers with zeros.
* With s specifiers this can
* also right-pad with zeros.
*
*
*
* '(char)
*
* Pads the result with the character (char).
*
*
*
*
*
*
* An integer that says how many characters (minimum)
* this conversion should result in.
*
* A period . followed by an integer
* who's meaning depends on the specifier:
*
*
*
* For e, E,
* f and F
* specifiers: this is the number of digits to be printed
* after the decimal point (by default, this is 6).
*
*
*
*
* For g and G
* specifiers: this is the maximum number of significant
* digits to be printed.
*
*
*
*
* For s specifier: it acts as a cutoff point,
* setting a maximum character limit to the string.
*
*
*
*
*
* If the period is specified without an explicit value for precision,
* 0 is assumed.
*
*
*
*
* Specifiers
*
*
*
* Specifier
* Description
*
*
*
*
* %
*
* A literal percent character. No argument is required.
*
*
*
* b
*
* The argument is treated as an integer and presented
* as a binary number.
*
*
*
* c
*
* The argument is treated as an integer and presented
* as the character with that ASCII.
*
*
*
* d
*
* The argument is treated as an integer and presented
* as a (signed) decimal number.
*
*
*
* e
*
* The argument is treated as scientific notation (e.g. 1.2e+2).
* The precision specifier stands for the number of digits after the
* decimal point since PHP 5.2.1. In earlier versions, it was taken as
* number of significant digits (one less).
*
*
*
* E
*
* Like the e specifier but uses
* uppercase letter (e.g. 1.2E+2).
*
*
*
* f
*
* The argument is treated as a float and presented
* as a floating-point number (locale aware).
*
*
*
* F
*
* The argument is treated as a float and presented
* as a floating-point number (non-locale aware).
* Available as of PHP 5.0.3.
*
*
*
* g
*
*
* General format.
*
*
* Let P equal the precision if nonzero, 6 if the precision is omitted,
* or 1 if the precision is zero.
* Then, if a conversion with style E would have an exponent of X:
*
*
* If P &gt; X 4, the conversion is with style f and precision P (X + 1).
* Otherwise, the conversion is with style e and precision P 1.
*
*
*
*
* G
*
* Like the g specifier but uses
* E and f.
*
*
*
* o
*
* The argument is treated as an integer and presented
* as an octal number.
*
*
*
* s
*
* The argument is treated and presented as a string.
*
*
*
* u
*
* The argument is treated as an integer and presented
* as an unsigned decimal number.
*
*
*
* x
*
* The argument is treated as an integer and presented
* as a hexadecimal number (with lowercase letters).
*
*
*
* X
*
* The argument is treated as an integer and presented
* as a hexadecimal number (with uppercase letters).
*
*
*
*
*
*
* General format.
*
* Let P equal the precision if nonzero, 6 if the precision is omitted,
* or 1 if the precision is zero.
* Then, if a conversion with style E would have an exponent of X:
*
* If P &gt; X 4, the conversion is with style f and precision P (X + 1).
* Otherwise, the conversion is with style e and precision P 1.
*
* The c type specifier ignores padding and width
*
* Attempting to use a combination of the string and width specifiers with character sets that require more than one byte per character may result in unexpected results
*
* Variables will be co-erced to a suitable type for the specifier:
*
* Type Handling
*
*
*
* Type
* Specifiers
*
*
*
*
* string
* s
*
*
* integer
*
* d,
* u,
* c,
* o,
* x,
* X,
* b
*
*
*
* double
*
* g,
* G,
* e,
* E,
* f,
* F
*
*
*
*
*
* @param array $args
* @return string Return array values as a formatted string according to
* format.
* @throws StringsException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*/
function vsprintf(string $format, array $args): string
{
error_clear_last();
$result = \vsprintf($format, $args);
if ($result === false) {
throw StringsException::createFromPhpError();
}
return $result;
}

View File

@ -1,7 +0,0 @@
version: '3.7'
services:
app:
image: thecodingmachine/php:8.1-v4-apache
volumes:
- ./:/var/www/html

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ApacheException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ApcuException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ArrayException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class Bzip2Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class CalendarException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ClassobjException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ComException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class CubridException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class DatetimeException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class DirException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class EioException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ErrorfuncException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ExecException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class FileinfoException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class FilesystemException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class FilterException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class FpmException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class FtpException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class FunchandException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class GettextException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class GmpException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class GnupgException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class HashException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class IbaseException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class IbmDb2Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class IconvException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ImageException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class ImapException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class InfoException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class InotifyException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Safe\Exceptions;
class LdapException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}

Some files were not shown because too many files have changed in this diff Show More