diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72995ed9..14fa5905 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,7 @@ jobs: - 7.1 - 7.2 - 7.3 + - 7.4 unit-tests: name: "Unit tests" runs-on: ubuntu-20.04 @@ -88,6 +89,7 @@ jobs: php-version: - 7.2 - 7.3 + - 7.4 typo3-version: - ^8.7 - ^9.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index 06cd9fc0..b8ec7dde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## 6.5.16 +### Added +- Add support for PHP 7.4 (#200) + ### Changed - Switch the CI from Travis CI to GitHub actions (#199) diff --git a/Resources/Private/Php/composer.json b/Resources/Private/Php/composer.json index aa059b20..07733fb7 100644 --- a/Resources/Private/Php/composer.json +++ b/Resources/Private/Php/composer.json @@ -4,7 +4,7 @@ "license": "GPL-2.0-or-later", "require": { "phpunit/phpunit": "^6.5.14", - "mikey179/vfsstream": "^1.6.7" + "mikey179/vfsstream": "^1.6.8" }, "prefer-stable": true, "config": { diff --git a/Resources/Private/Php/composer.lock b/Resources/Private/Php/composer.lock index 8928aa22..10ea5689 100644 --- a/Resources/Private/Php/composer.lock +++ b/Resources/Private/Php/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dfb3222ffbdec14b94a08939baa02eb6", + "content-hash": "6390214dea0d54f1a85554b142ffc271", "packages": [ { "name": "doctrine/instantiator", @@ -62,16 +62,16 @@ }, { "name": "mikey179/vfsstream", - "version": "v1.6.7", + "version": "v1.6.8", "source": { "type": "git", "url": "https://github.com/bovigo/vfsStream.git", - "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb" + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", - "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe", + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe", "shasum": "" }, "require": { @@ -98,13 +98,13 @@ "authors": [ { "name": "Frank Kleine", - "role": "Developer", - "homepage": "http://frankkleine.de/" + "homepage": "http://frankkleine.de/", + "role": "Developer" } ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2019-08-01T01:38:37+00:00" + "time": "2019-10-30T15:31:00+00:00" }, { "name": "myclabs/deep-copy", @@ -309,27 +309,28 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", + "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4" }, "type": "library", @@ -356,29 +357,29 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-04-30T17:48:53+00:00" + "time": "2019-12-28T18:55:12+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "0.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "cf842904952e64e703800d094cdf34e715a8a3ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/cf842904952e64e703800d094cdf34e715a8a3ae", + "reference": "cf842904952e64e703800d094cdf34e715a8a3ae", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", + "php": "^7.0", "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { @@ -388,9 +389,7 @@ }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -403,37 +402,37 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "time": "2017-12-30T13:23:38+00:00" }, { "name": "phpspec/prophecy", - "version": "1.8.1", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -466,7 +465,7 @@ "spy", "stub" ], - "time": "2019-06-13T12:50:23+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -715,6 +714,7 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2017-11-27T05:48:46+00:00" }, { @@ -1074,16 +1074,16 @@ }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -1110,6 +1110,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1118,17 +1122,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -1137,7 +1137,7 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", @@ -1422,16 +1422,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.12.0", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", "shasum": "" }, "require": { @@ -1443,7 +1443,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-main": "1.19-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1476,7 +1480,21 @@ "polyfill", "portable" ], - "time": "2019-08-06T08:03:45+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T09:01:57+00:00" }, { "name": "theseer/tokenizer", @@ -1520,32 +1538,30 @@ }, { "name": "webmozart/assert", - "version": "1.4.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" + }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -1567,7 +1583,7 @@ "check", "validate" ], - "time": "2018-12-25T11:19:39+00:00" + "time": "2020-07-08T17:02:28+00:00" } ], "packages-dev": [], @@ -1580,5 +1596,6 @@ "platform-dev": [], "platform-overrides": { "php": "7.0.20" - } + }, + "plugin-api-version": "1.1.0" } diff --git a/Resources/Private/Php/vendor/composer/ClassLoader.php b/Resources/Private/Php/vendor/composer/ClassLoader.php index fce8549f..03b9bb9c 100644 --- a/Resources/Private/Php/vendor/composer/ClassLoader.php +++ b/Resources/Private/Php/vendor/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/Resources/Private/Php/vendor/composer/autoload_classmap.php b/Resources/Private/Php/vendor/composer/autoload_classmap.php index f6d6751f..2352f546 100644 --- a/Resources/Private/Php/vendor/composer/autoload_classmap.php +++ b/Resources/Private/Php/vendor/composer/autoload_classmap.php @@ -667,6 +667,7 @@ 'TheSeer\\Tokenizer\\Tokenizer' => $vendorDir . '/theseer/tokenizer/src/Tokenizer.php', 'TheSeer\\Tokenizer\\XMLSerializer' => $vendorDir . '/theseer/tokenizer/src/XMLSerializer.php', 'Webmozart\\Assert\\Assert' => $vendorDir . '/webmozart/assert/src/Assert.php', + 'Webmozart\\Assert\\Mixin' => $vendorDir . '/webmozart/assert/src/Mixin.php', 'org\\bovigo\\vfs\\DotDirectory' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/DotDirectory.php', 'org\\bovigo\\vfs\\Quota' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/Quota.php', 'org\\bovigo\\vfs\\content\\FileContent' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/content/FileContent.php', @@ -721,6 +722,7 @@ 'phpDocumentor\\Reflection\\DocBlock\\Tags\\See' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/See.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Since' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Source' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Source.php', + 'phpDocumentor\\Reflection\\DocBlock\\Tags\\TagWithType' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Throws' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Uses' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Uses.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Var_' => $vendorDir . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php', @@ -734,9 +736,11 @@ 'phpDocumentor\\Reflection\\ProjectFactory' => $vendorDir . '/phpdocumentor/reflection-common/src/ProjectFactory.php', 'phpDocumentor\\Reflection\\Type' => $vendorDir . '/phpdocumentor/type-resolver/src/Type.php', 'phpDocumentor\\Reflection\\TypeResolver' => $vendorDir . '/phpdocumentor/type-resolver/src/TypeResolver.php', + 'phpDocumentor\\Reflection\\Types\\AbstractList' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/AbstractList.php', 'phpDocumentor\\Reflection\\Types\\Array_' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/Array_.php', 'phpDocumentor\\Reflection\\Types\\Boolean' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/Boolean.php', 'phpDocumentor\\Reflection\\Types\\Callable_' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/Callable_.php', + 'phpDocumentor\\Reflection\\Types\\Collection' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/Collection.php', 'phpDocumentor\\Reflection\\Types\\Compound' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/Compound.php', 'phpDocumentor\\Reflection\\Types\\Context' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/Context.php', 'phpDocumentor\\Reflection\\Types\\ContextFactory' => $vendorDir . '/phpdocumentor/type-resolver/src/Types/ContextFactory.php', diff --git a/Resources/Private/Php/vendor/composer/autoload_real.php b/Resources/Private/Php/vendor/composer/autoload_real.php index 2771934d..c34e89ab 100644 --- a/Resources/Private/Php/vendor/composer/autoload_real.php +++ b/Resources/Private/Php/vendor/composer/autoload_real.php @@ -13,6 +13,9 @@ public static function loadClassLoader($class) } } + /** + * @return \Composer\Autoload\ClassLoader + */ public static function getLoader() { if (null !== self::$loader) { diff --git a/Resources/Private/Php/vendor/composer/autoload_static.php b/Resources/Private/Php/vendor/composer/autoload_static.php index 4114ee6b..27631b7a 100644 --- a/Resources/Private/Php/vendor/composer/autoload_static.php +++ b/Resources/Private/Php/vendor/composer/autoload_static.php @@ -736,6 +736,7 @@ class ComposerStaticInit45082ac2f329c40aa96c42998983a664 'TheSeer\\Tokenizer\\Tokenizer' => __DIR__ . '/..' . '/theseer/tokenizer/src/Tokenizer.php', 'TheSeer\\Tokenizer\\XMLSerializer' => __DIR__ . '/..' . '/theseer/tokenizer/src/XMLSerializer.php', 'Webmozart\\Assert\\Assert' => __DIR__ . '/..' . '/webmozart/assert/src/Assert.php', + 'Webmozart\\Assert\\Mixin' => __DIR__ . '/..' . '/webmozart/assert/src/Mixin.php', 'org\\bovigo\\vfs\\DotDirectory' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/DotDirectory.php', 'org\\bovigo\\vfs\\Quota' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/Quota.php', 'org\\bovigo\\vfs\\content\\FileContent' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/content/FileContent.php', @@ -790,6 +791,7 @@ class ComposerStaticInit45082ac2f329c40aa96c42998983a664 'phpDocumentor\\Reflection\\DocBlock\\Tags\\See' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/See.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Since' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Source' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Source.php', + 'phpDocumentor\\Reflection\\DocBlock\\Tags\\TagWithType' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Throws' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Uses' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Uses.php', 'phpDocumentor\\Reflection\\DocBlock\\Tags\\Var_' => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php', @@ -803,9 +805,11 @@ class ComposerStaticInit45082ac2f329c40aa96c42998983a664 'phpDocumentor\\Reflection\\ProjectFactory' => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src/ProjectFactory.php', 'phpDocumentor\\Reflection\\Type' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Type.php', 'phpDocumentor\\Reflection\\TypeResolver' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/TypeResolver.php', + 'phpDocumentor\\Reflection\\Types\\AbstractList' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/AbstractList.php', 'phpDocumentor\\Reflection\\Types\\Array_' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/Array_.php', 'phpDocumentor\\Reflection\\Types\\Boolean' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/Boolean.php', 'phpDocumentor\\Reflection\\Types\\Callable_' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/Callable_.php', + 'phpDocumentor\\Reflection\\Types\\Collection' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/Collection.php', 'phpDocumentor\\Reflection\\Types\\Compound' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/Compound.php', 'phpDocumentor\\Reflection\\Types\\Context' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/Context.php', 'phpDocumentor\\Reflection\\Types\\ContextFactory' => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src/Types/ContextFactory.php', diff --git a/Resources/Private/Php/vendor/composer/installed.json b/Resources/Private/Php/vendor/composer/installed.json index b8fe570a..92be1aed 100644 --- a/Resources/Private/Php/vendor/composer/installed.json +++ b/Resources/Private/Php/vendor/composer/installed.json @@ -57,17 +57,17 @@ }, { "name": "mikey179/vfsstream", - "version": "v1.6.7", - "version_normalized": "1.6.7.0", + "version": "v1.6.8", + "version_normalized": "1.6.8.0", "source": { "type": "git", "url": "https://github.com/bovigo/vfsStream.git", - "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb" + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", - "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe", + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe", "shasum": "" }, "require": { @@ -76,7 +76,7 @@ "require-dev": { "phpunit/phpunit": "^4.5|^5.0" }, - "time": "2019-08-01T01:38:37+00:00", + "time": "2019-10-30T15:31:00+00:00", "type": "library", "extra": { "branch-alias": { @@ -96,8 +96,8 @@ "authors": [ { "name": "Frank Kleine", - "role": "Developer", - "homepage": "http://frankkleine.de/" + "homepage": "http://frankkleine.de/", + "role": "Developer" } ], "description": "Virtual file system to mock the real file system in unit tests.", @@ -314,31 +314,32 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", - "version_normalized": "4.3.1.0", + "version": "4.3.4", + "version_normalized": "4.3.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", + "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4" }, - "time": "2019-04-30T17:48:53+00:00", + "time": "2019-12-28T18:55:12+00:00", "type": "library", "extra": { "branch-alias": { @@ -367,28 +368,28 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", - "version_normalized": "0.4.0.0", + "version": "0.5.1", + "version_normalized": "0.5.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "cf842904952e64e703800d094cdf34e715a8a3ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/cf842904952e64e703800d094cdf34e715a8a3ae", + "reference": "cf842904952e64e703800d094cdf34e715a8a3ae", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", + "php": "^7.0", "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, - "time": "2017-07-14T14:27:02+00:00", + "time": "2017-12-30T13:23:38+00:00", "type": "library", "extra": { "branch-alias": { @@ -398,9 +399,7 @@ "installation-source": "dist", "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -416,35 +415,35 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.1", - "version_normalized": "1.8.1.0", + "version": "v1.10.3", + "version_normalized": "1.10.3.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, - "time": "2019-06-13T12:50:23+00:00", + "time": "2020-03-05T15:02:03+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "installation-source": "dist", @@ -736,7 +735,8 @@ "homepage": "https://github.com/sebastianbergmann/php-token-stream/", "keywords": [ "tokenizer" - ] + ], + "abandoned": true }, { "name": "phpunit/phpunit", @@ -1107,17 +1107,17 @@ }, { "name": "sebastian/exporter", - "version": "3.1.0", - "version_normalized": "3.1.0.0", + "version": "3.1.2", + "version_normalized": "3.1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -1128,7 +1128,7 @@ "ext-mbstring": "*", "phpunit/phpunit": "^6.0" }, - "time": "2017-04-03T13:19:02+00:00", + "time": "2019-09-14T09:02:43+00:00", "type": "library", "extra": { "branch-alias": { @@ -1146,6 +1146,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1154,17 +1158,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -1469,17 +1469,17 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.12.0", - "version_normalized": "1.12.0.0", + "version": "v1.19.0", + "version_normalized": "1.19.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", "shasum": "" }, "require": { @@ -1488,11 +1488,15 @@ "suggest": { "ext-ctype": "For best performance" }, - "time": "2019-08-06T08:03:45+00:00", + "time": "2020-10-23T09:01:57+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-main": "1.19-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "installation-source": "dist", @@ -1525,6 +1529,20 @@ "ctype", "polyfill", "portable" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } ] }, { @@ -1571,34 +1589,32 @@ }, { "name": "webmozart/assert", - "version": "1.4.0", - "version_normalized": "1.4.0.0", + "version": "1.9.1", + "version_normalized": "1.9.1.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" + }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, - "time": "2018-12-25T11:19:39+00:00", + "time": "2020-07-08T17:02:28+00:00", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "installation-source": "dist", "autoload": { "psr-4": { diff --git a/Resources/Private/Php/vendor/mikey179/vfsstream/CHANGELOG.md b/Resources/Private/Php/vendor/mikey179/vfsstream/CHANGELOG.md index 1d92bcd7..bbc10553 100644 --- a/Resources/Private/Php/vendor/mikey179/vfsstream/CHANGELOG.md +++ b/Resources/Private/Php/vendor/mikey179/vfsstream/CHANGELOG.md @@ -1,3 +1,8 @@ +1.6.8 (2019-10-30) +------------------ + + * Fix `StringBasedFileContent::doRead` to always return a string (#204) + 1.6.7 (2019-07-31) ------------------ diff --git a/Resources/Private/Php/vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php b/Resources/Private/Php/vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php index 2c805dd4..77adf8e5 100644 --- a/Resources/Private/Php/vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php +++ b/Resources/Private/Php/vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php @@ -60,7 +60,7 @@ public function size() */ protected function doRead($offset, $count) { - return substr($this->content, $offset, $count); + return (string) substr($this->content, $offset, $count); } /** diff --git a/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php b/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php index 0cf151f6..137a0925 100644 --- a/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php +++ b/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php @@ -86,8 +86,10 @@ public function reaMoreThanSizeReturnsWholeContent() */ public function readAfterEndReturnsEmptyString() { - $this->stringBasedFileContent->read(9); - $this->assertEquals('', $this->stringBasedFileContent->read(3)); + // Read more than the length of the string to test substr() returning + // false. + $this->stringBasedFileContent->read(10); + $this->assertSame('', $this->stringBasedFileContent->read(3)); } /** diff --git a/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php b/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php index c51a136b..f2b3234d 100644 --- a/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php +++ b/Resources/Private/Php/vendor/mikey179/vfsstream/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php @@ -777,4 +777,13 @@ public function urlIsUpdatedAfterMove() $this->assertTrue(rename($this->baz1URL, $baz3URL)); $this->assertEquals($baz3URL, $this->baz1->url()); } + + /** + * @test + */ + public function fileCopy() + { + $baz3URL = vfsStream::url('foo/baz3'); + $this->assertTrue(copy($this->baz1URL, $baz3URL)); + } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/appveyor.yml b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/appveyor.yml new file mode 100644 index 00000000..2a650d99 --- /dev/null +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/appveyor.yml @@ -0,0 +1,54 @@ +build: false +clone_folder: c:\reflectiondocblock +max_jobs: 3 +platform: x86 +pull_requests: + do_not_increment_build_number: true +version: '{build}.{branch}' +skip_tags: true +branches: + only: + - master + +environment: + matrix: + - php_ver_target: 7.1 + - php_ver_target: 7.2 +matrix: + fast_finish: false + +cache: + - c:\php -> appveyor.yml + - '%LOCALAPPDATA%\Composer\files' + +init: + - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - SET PHP=1 + - SET ANSICON=121x90 (121x90) + + +install: + - IF EXIST c:\tools\php (SET PHP=0) + - ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') + - cd c:\tools\php + - IF %PHP%==1 copy /Y php.ini-development php.ini + - IF %PHP%==1 echo max_execution_time=1200 >> php.ini + - IF %PHP%==1 echo date.timezone="UTC" >> php.ini + - IF %PHP%==1 echo extension_dir=ext >> php.ini + - IF %PHP%==1 echo extension=php_curl.dll >> php.ini + - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini + - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini + - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini + - IF %PHP%==1 echo zend.assertions=1 >> php.ini + - IF %PHP%==1 echo assert.exception=On >> php.ini + - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat + - appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar + - cd c:\reflectiondocblock + - composer install --no-interaction --prefer-dist --no-progress + - composer global require phpunit/phpunit ^6 + - composer global config bin-dir --absolute + +test_script: + - cd c:\reflectiondocblock + - c:\Users\appveyor\AppData\Roaming\Composer\vendor\bin\phpunit --no-coverage diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/composer.json b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/composer.json index e3dc38a9..9bbf8eb6 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/composer.json +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/composer.json @@ -11,8 +11,8 @@ ], "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "autoload": { @@ -23,8 +23,9 @@ }, "require-dev": { "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4", - "doctrine/instantiator": "~1.0.5" + "doctrine/instantiator": "^1.0.5" }, "extra": { "branch-alias": { diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php index 14bb7177..b549214a 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php @@ -1,4 +1,7 @@ name = 'param'; $this->variableName = $variableName; $this->type = $type; $this->isVariadic = $isVariadic; @@ -65,19 +60,25 @@ public static function create( Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); + list($firstPart, $body) = self::extractTypeFromBody($body); $type = null; + $parts = preg_split('/(\s+)/Su', $body, 2, PREG_SPLIT_DELIM_CAPTURE); $variableName = ''; $isVariadic = false; // if the first item that is encountered is not a variable; it is a type - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { - $type = $typeResolver->resolve(array_shift($parts), $context); - array_shift($parts); + if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) { + $type = $typeResolver->resolve($firstPart, $context); + } else { + // first part is not a type; we should prepend it to the parts array for further processing + array_unshift($parts, $firstPart); } // if the next item starts with a $ or ...$ it must be the variable name - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) { + if (isset($parts[0]) + && (strlen($parts[0]) > 0) + && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$') + ) { $variableName = array_shift($parts); array_shift($parts); @@ -106,16 +107,6 @@ public function getVariableName() return $this->variableName; } - /** - * Returns the variable's type or null if unknown. - * - * @return Type|null - */ - public function getType() - { - return $this->type; - } - /** * Returns whether this tag is variadic. * @@ -134,8 +125,8 @@ public function isVariadic() public function __toString() { return ($this->type ? $this->type . ' ' : '') - . ($this->isVariadic() ? '...' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . ($this->isVariadic() ? '...' : '') + . '$' . $this->variableName + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php index f0ef7c07..96688b9d 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php @@ -22,26 +22,21 @@ /** * Reflection class for a {@}property tag in a Docblock. */ -class Property extends BaseTag implements Factory\StaticMethod +class Property extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'property'; - - /** @var Type */ - private $type; - /** @var string */ protected $variableName = ''; /** - * @param string $variableName - * @param Type $type + * @param string $variableName + * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); + $this->name = 'property'; $this->variableName = $variableName; $this->type = $type; $this->description = $description; @@ -59,14 +54,17 @@ public static function create( Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); + list($firstPart, $body) = self::extractTypeFromBody($body); $type = null; + $parts = preg_split('/(\s+)/Su', $body, 2, PREG_SPLIT_DELIM_CAPTURE); $variableName = ''; // if the first item that is encountered is not a variable; it is a type - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { - $type = $typeResolver->resolve(array_shift($parts), $context); - array_shift($parts); + if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) { + $type = $typeResolver->resolve($firstPart, $context); + } else { + // first part is not a type; we should prepend it to the parts array for further processing + array_unshift($parts, $firstPart); } // if the next item starts with a $ or ...$ it must be the variable name @@ -94,16 +92,6 @@ public function getVariableName() return $this->variableName; } - /** - * Returns the variable's type or null if unknown. - * - * @return Type|null - */ - public function getType() - { - return $this->type; - } - /** * Returns a string representation for this tag. * @@ -112,7 +100,7 @@ public function getType() public function __toString() { return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . '$' . $this->variableName + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php index e41c0c1c..935c79d3 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php @@ -22,26 +22,21 @@ /** * Reflection class for a {@}property-read tag in a Docblock. */ -class PropertyRead extends BaseTag implements Factory\StaticMethod +class PropertyRead extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'property-read'; - - /** @var Type */ - private $type; - /** @var string */ protected $variableName = ''; /** - * @param string $variableName - * @param Type $type + * @param string $variableName + * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); + $this->name = 'property-read'; $this->variableName = $variableName; $this->type = $type; $this->description = $description; @@ -59,14 +54,17 @@ public static function create( Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); + list($firstPart, $body) = self::extractTypeFromBody($body); $type = null; + $parts = preg_split('/(\s+)/Su', $body, 2, PREG_SPLIT_DELIM_CAPTURE); $variableName = ''; // if the first item that is encountered is not a variable; it is a type - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { - $type = $typeResolver->resolve(array_shift($parts), $context); - array_shift($parts); + if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) { + $type = $typeResolver->resolve($firstPart, $context); + } else { + // first part is not a type; we should prepend it to the parts array for further processing + array_unshift($parts, $firstPart); } // if the next item starts with a $ or ...$ it must be the variable name @@ -94,16 +92,6 @@ public function getVariableName() return $this->variableName; } - /** - * Returns the variable's type or null if unknown. - * - * @return Type|null - */ - public function getType() - { - return $this->type; - } - /** * Returns a string representation for this tag. * @@ -112,7 +100,7 @@ public function getType() public function __toString() { return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . '$' . $this->variableName + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php index cfdb0ed0..6ccb2277 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php @@ -22,26 +22,21 @@ /** * Reflection class for a {@}property-write tag in a Docblock. */ -class PropertyWrite extends BaseTag implements Factory\StaticMethod +class PropertyWrite extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'property-write'; - - /** @var Type */ - private $type; - /** @var string */ protected $variableName = ''; /** - * @param string $variableName - * @param Type $type + * @param string $variableName + * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); + $this->name = 'property-write'; $this->variableName = $variableName; $this->type = $type; $this->description = $description; @@ -59,14 +54,17 @@ public static function create( Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); + list($firstPart, $body) = self::extractTypeFromBody($body); $type = null; + $parts = preg_split('/(\s+)/Su', $body, 2, PREG_SPLIT_DELIM_CAPTURE); $variableName = ''; // if the first item that is encountered is not a variable; it is a type - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { - $type = $typeResolver->resolve(array_shift($parts), $context); - array_shift($parts); + if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) { + $type = $typeResolver->resolve($firstPart, $context); + } else { + // first part is not a type; we should prepend it to the parts array for further processing + array_unshift($parts, $firstPart); } // if the next item starts with a $ or ...$ it must be the variable name @@ -94,16 +92,6 @@ public function getVariableName() return $this->variableName; } - /** - * Returns the variable's type or null if unknown. - * - * @return Type|null - */ - public function getType() - { - return $this->type; - } - /** * Returns a string representation for this tag. * @@ -112,7 +100,7 @@ public function getType() public function __toString() { return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . '$' . $this->variableName + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php index ca5bda70..f3c97ce8 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php @@ -22,15 +22,11 @@ /** * Reflection class for a {@}return tag in a Docblock. */ -final class Return_ extends BaseTag implements Factory\StaticMethod +final class Return_ extends TagWithType implements Factory\StaticMethod { - protected $name = 'return'; - - /** @var Type */ - private $type; - public function __construct(Type $type, Description $description = null) { + $this->name = 'return'; $this->type = $type; $this->description = $description; } @@ -47,24 +43,14 @@ public static function create( Assert::string($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/\s+/Su', $body, 2); + list($type, $description) = self::extractTypeFromBody($body); - $type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context); - $description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context); + $type = $typeResolver->resolve($type, $context); + $description = $descriptionFactory->create($description, $context); return new static($type, $description); } - /** - * Returns the type section of the variable. - * - * @return Type - */ - public function getType() - { - return $this->type; - } - public function __toString() { return $this->type . ' ' . $this->description; diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php new file mode 100644 index 00000000..7781caf5 --- /dev/null +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php @@ -0,0 +1,60 @@ + + * @license http://www.opensource.org/licenses/mit-license.php MIT + * @link http://phpdoc.org + */ + +namespace phpDocumentor\Reflection\DocBlock\Tags; + +use phpDocumentor\Reflection\Type; + +abstract class TagWithType extends BaseTag +{ + /** @var Type */ + protected $type; + + /** + * Returns the type section of the variable. + * + * @return Type + */ + public function getType() + { + return $this->type; + } + + protected static function extractTypeFromBody(string $body) : array + { + $type = ''; + $nestingLevel = 0; + for ($i = 0; $i < strlen($body); $i++) { + $character = $body[$i]; + + if (trim($character) === '' && $nestingLevel === 0) { + break; + } + + $type .= $character; + if (in_array($character, ['<', '(', '[', '{'])) { + $nestingLevel++; + } + + if (in_array($character, ['>', ')', ']', '}'])) { + $nestingLevel--; + } + } + + $description = trim(substr($body, strlen($type))); + + return [$type, $description]; + } +} diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php index 349e773b..cf93cd09 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php @@ -22,16 +22,12 @@ /** * Reflection class for a {@}throws tag in a Docblock. */ -final class Throws extends BaseTag implements Factory\StaticMethod +final class Throws extends TagWithType implements Factory\StaticMethod { - protected $name = 'throws'; - - /** @var Type */ - private $type; - public function __construct(Type $type, Description $description = null) { - $this->type = $type; + $this->name = 'throws'; + $this->type = $type; $this->description = $description; } @@ -47,24 +43,14 @@ public static function create( Assert::string($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/\s+/Su', $body, 2); + list($type, $description) = self::extractTypeFromBody($body); - $type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context); - $description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context); + $type = $typeResolver->resolve($type, $context); + $description = $descriptionFactory->create($description, $context); return new static($type, $description); } - /** - * Returns the type section of the variable. - * - * @return Type - */ - public function getType() - { - return $this->type; - } - public function __toString() { return $this->type . ' ' . $this->description; diff --git a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php index 8907c951..a0b40460 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php +++ b/Resources/Private/Php/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php @@ -22,29 +22,24 @@ /** * Reflection class for a {@}var tag in a Docblock. */ -class Var_ extends BaseTag implements Factory\StaticMethod +class Var_ extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'var'; - - /** @var Type */ - private $type; - /** @var string */ protected $variableName = ''; /** - * @param string $variableName - * @param Type $type + * @param string $variableName + * @param Type $type * @param Description $description */ public function __construct($variableName, Type $type = null, Description $description = null) { Assert::string($variableName); + $this->name = 'var'; $this->variableName = $variableName; - $this->type = $type; - $this->description = $description; + $this->type = $type; + $this->description = $description; } /** @@ -59,14 +54,17 @@ public static function create( Assert::stringNotEmpty($body); Assert::allNotNull([$typeResolver, $descriptionFactory]); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); - $type = null; + list($firstPart, $body) = self::extractTypeFromBody($body); + $parts = preg_split('/(\s+)/Su', $body, 2, PREG_SPLIT_DELIM_CAPTURE); + $type = null; $variableName = ''; // if the first item that is encountered is not a variable; it is a type - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] !== '$')) { - $type = $typeResolver->resolve(array_shift($parts), $context); - array_shift($parts); + if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) { + $type = $typeResolver->resolve($firstPart, $context); + } else { + // first part is not a type; we should prepend it to the parts array for further processing + array_unshift($parts, $firstPart); } // if the next item starts with a $ or ...$ it must be the variable name @@ -94,16 +92,6 @@ public function getVariableName() return $this->variableName; } - /** - * Returns the variable's type or null if unknown. - * - * @return Type|null - */ - public function getType() - { - return $this->type; - } - /** * Returns a string representation for this tag. * diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/.coveralls.yml b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/.coveralls.yml new file mode 100644 index 00000000..c512a3d5 --- /dev/null +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/.coveralls.yml @@ -0,0 +1,3 @@ +service_name: travis-ci +coverage_clover: coverage.xml +json_path: coverage.json diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/README.md b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/README.md index fad34006..f186504a 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/README.md +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/README.md @@ -1,5 +1,7 @@ -TypeResolver and FqsenResolver -============================== +# TypeResolver and FqsenResolver + +[![Build Status](https://img.shields.io/travis/phpDocumentor/TypeResolver/master.svg?style=flat-square)](https://travis-ci.org/phpDocumentor/TypeResolver) +[![Code Coverage](https://img.shields.io/coveralls/phpDocumentor/TypeResolver/master.svg?style=flat-square)](https://coveralls.io/github/phpDocumentor/TypeResolver) The specification on types in DocBlocks (PSR-5) describes various keywords and special constructs but also how to statically resolve the partial name of a Class into a Fully Qualified Class Name (FQCN). @@ -22,8 +24,7 @@ The easiest way to install this library is with [Composer](https://getcomposer.o ## Examples -Ready to dive in and don't want to read through all that text below? Just consult the [examples](examples) folder and -check which type of action that your want to accomplish. +Ready to dive in and don't want to read through all that text below? Just consult the [examples](examples) folder and check which type of action that your want to accomplish. ## On Types and Element Names @@ -39,6 +40,7 @@ The TypeResolver can resolve: - a php primitive or pseudo-primitive such as a string or void (`@var string` or `@return void`). - a composite such as an array of string (`@var string[]`). - a compound such as a string or integer (`@var string|integer`). +- an array expression (`@var (string|TypeResolver)[]`) - an object or interface such as the TypeResolver class (`@var TypeResolver` or `@var \phpDocumentor\Reflection\TypeResolver`) @@ -58,8 +60,7 @@ Where the FqsenResolver can resolve: ## Resolving a type -In order to resolve a type you will have to instantiate the class `\phpDocumentor\Reflection\TypeResolver` -and call its `resolve` method like this: +In order to resolve a type you will have to instantiate the class `\phpDocumentor\Reflection\TypeResolver` and call its `resolve` method like this: ```php $typeResolver = new \phpDocumentor\Reflection\TypeResolver(); @@ -70,31 +71,24 @@ In this example you will receive a Value Object of class `\phpDocumentor\Reflect elements, one of type `\phpDocumentor\Reflection\Types\String_` and one of type `\phpDocumentor\Reflection\Types\Integer`. -The real power of this resolver is in its capability to expand partial class names into fully qualified class names; but -in order to do that we need an additional `\phpDocumentor\Reflection\Types\Context` class that will inform the resolver -in which namespace the given expression occurs and which namespace aliases (or imports) apply. +The real power of this resolver is in its capability to expand partial class names into fully qualified class names; but in order to do that we need an additional `\phpDocumentor\Reflection\Types\Context` class that will inform the resolver in which namespace the given expression occurs and which namespace aliases (or imports) apply. ## Resolving an FQSEN -A Fully Qualified Structural Element Name is a reference to another element in your code bases and can be resolved using -the `\phpDocumentor\Reflection\FqsenResolver` class' `resolve` method, like this: +A Fully Qualified Structural Element Name is a reference to another element in your code bases and can be resolved using the `\phpDocumentor\Reflection\FqsenResolver` class' `resolve` method, like this: ```php $fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver(); $fqsen = $fqsenResolver->resolve('\phpDocumentor\Reflection\FqsenResolver::resolve()'); ``` -In this example we resolve a Fully Qualified Structural Element Name (meaning that it includes the full namespace, class -name and element name) and receive a Value Object of type `\phpDocumentor\Reflection\Fqsen`. +In this example we resolve a Fully Qualified Structural Element Name (meaning that it includes the full namespace, class name and element name) and receive a Value Object of type `\phpDocumentor\Reflection\Fqsen`. -The real power of this resolver is in its capability to expand partial element names into Fully Qualified Structural -Element Names; but in order to do that we need an additional `\phpDocumentor\Reflection\Types\Context` class that will -inform the resolver in which namespace the given expression occurs and which namespace aliases (or imports) apply. +The real power of this resolver is in its capability to expand partial element names into Fully Qualified Structural Element Names; but in order to do that we need an additional `\phpDocumentor\Reflection\Types\Context` class that will inform the resolver in which namespace the given expression occurs and which namespace aliases (or imports) apply. ## Resolving partial Classes and Structural Element Names -Perhaps the best feature of this library is that it knows how to resolve partial class names into fully qualified class -names. +Perhaps the best feature of this library is that it knows how to resolve partial class names into fully qualified class names. For example, you have this file: @@ -116,9 +110,8 @@ class Classy ``` Suppose that you would want to resolve (and expand) the type in the `@var` tag and the element name in the `@see` tag. -For the resolvers to know how to expand partial names you have to provide a bit of _Context_ for them by instantiating -a new class named `\phpDocumentor\Reflection\Types\Context` with the name of the namespace and the aliases that are in -play. + +For the resolvers to know how to expand partial names you have to provide a bit of _Context_ for them by instantiating a new class named `\phpDocumentor\Reflection\Types\Context` with the name of the namespace and the aliases that are in play. ### Creating a Context @@ -131,9 +124,7 @@ $context = new \phpDocumentor\Reflection\Types\Context( ); ``` -Or by using the `\phpDocumentor\Reflection\Types\ContextFactory` to instantiate a new context based on a Reflector -object or by providing the namespace that you'd like to extract and the source code of the file in which the given -type expression occurs. +Or by using the `\phpDocumentor\Reflection\Types\ContextFactory` to instantiate a new context based on a Reflector object or by providing the namespace that you'd like to extract and the source code of the file in which the given type expression occurs. ```php $contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory(); @@ -149,8 +140,7 @@ $context = $contextFactory->createForNamespace('\My\Example', file_get_contents( ### Using the Context -After you have obtained a Context it is just a matter of passing it along with the `resolve` method of either Resolver -class as second argument and the Resolvers will take this into account when resolving partial names. +After you have obtained a Context it is just a matter of passing it along with the `resolve` method of either Resolver class as second argument and the Resolvers will take this into account when resolving partial names. To obtain the resolved class name for the `@var` tag in the example above you can do: @@ -159,24 +149,17 @@ $typeResolver = new \phpDocumentor\Reflection\TypeResolver(); $type = $typeResolver->resolve('Types\Context', $context); ``` -When you do this you will receive an object of class `\phpDocumentor\Reflection\Types\Object_` for which you can call -the `getFqsen` method to receive a Value Object that represents the complete FQSEN. So that would be -`phpDocumentor\Reflection\Types\Context`. +When you do this you will receive an object of class `\phpDocumentor\Reflection\Types\Object_` for which you can call the `getFqsen` method to receive a Value Object that represents the complete FQSEN. So that would be `phpDocumentor\Reflection\Types\Context`. > Why is the FQSEN wrapped in another object `Object_`? > -> The resolve method of the TypeResolver only returns object with the interface `Type` and the FQSEN is a common -> type that does not represent a Type. Also: in some cases a type can represent an "Untyped Object", meaning that it -> is an object (signified by the `object` keyword) but does not refer to a specific element using an FQSEN. +> The resolve method of the TypeResolver only returns object with the interface `Type` and the FQSEN is a common type that does not represent a Type. Also: in some cases a type can represent an "Untyped Object", meaning that it is an object (signified by the `object` keyword) but does not refer to a specific element using an FQSEN. -Another example is on how to resolve the FQSEN of a method as can be seen with the `@see` tag in the example above. To -resolve that you can do the following: +Another example is on how to resolve the FQSEN of a method as can be seen with the `@see` tag in the example above. To resolve that you can do the following: ```php $fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver(); $type = $fqsenResolver->resolve('Classy::otherFunction()', $context); ``` -Because Classy is a Class in the current namespace its FQSEN will have the `My\Example` namespace and by calling the -`resolve` method of the FQSEN Resolver you will receive an `Fqsen` object that refers to -`\My\Example\Classy::otherFunction()`. +Because Classy is a Class in the current namespace its FQSEN will have the `My\Example` namespace and by calling the `resolve` method of the FQSEN Resolver you will receive an `Fqsen` object that refers to `\My\Example\Classy::otherFunction()`. diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/composer.json b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/composer.json index 82ead156..922cf24c 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/composer.json +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/composer.json @@ -1,23 +1,30 @@ { - "name": "phpdocumentor/type-resolver", - "type": "library", + "name": "phpdocumentor/type-resolver", + "type": "library", "license": "MIT", "authors": [ - {"name": "Mike van Riel", "email": "me@mikevanriel.com"} + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } ], "require": { - "php": "^5.5 || ^7.0", + "php": "^7.0", "phpdocumentor/reflection-common": "^1.0" }, + "require-dev": { + "phpunit/phpunit": "^6.4", + "mockery/mockery": "^1.0" + }, "autoload": { - "psr-4": {"phpDocumentor\\Reflection\\": ["src/"]} + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } }, "autoload-dev": { - "psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]} - }, - "require-dev": { - "phpunit/phpunit": "^5.2||^4.8.24", - "mockery/mockery": "^0.9.4" + "psr-4": { + "phpDocumentor\\Reflection\\": "tests" + } }, "extra": { "branch-alias": { diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php index 9aa6ba30..d07d37d5 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php @@ -1,4 +1,4 @@ - + * @copyright 2010-2017 Mike van Riel * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,6 +18,9 @@ use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; +use phpDocumentor\Reflection\Types\Collection; +use phpDocumentor\Reflection\Types\String_; +use phpDocumentor\Reflection\Types\Integer; final class TypeResolver { @@ -27,6 +30,19 @@ final class TypeResolver /** @var string Definition of the NAMESPACE operator in PHP */ const OPERATOR_NAMESPACE = '\\'; + /** @var integer the iterator parser is inside a compound context */ + const PARSER_IN_COMPOUND = 0; + + /** @var integer the iterator parser is inside a nullable expression context */ + const PARSER_IN_NULLABLE = 1; + + /** @var integer the iterator parser is inside an array expression context */ + const PARSER_IN_ARRAY_EXPRESSION = 2; + + /** @var integer the iterator parser is inside a collection expression context */ + const PARSER_IN_COLLECTION_EXPRESSION = 3; + + /** @var string[] List of recognized keywords and unto which Value Object they map */ private $keywords = array( 'string' => Types\String_::class, @@ -34,6 +50,7 @@ final class TypeResolver 'integer' => Types\Integer::class, 'bool' => Types\Boolean::class, 'boolean' => Types\Boolean::class, + 'real' => Types\Float_::class, 'float' => Types\Float_::class, 'double' => Types\Float_::class, 'object' => Object_::class, @@ -84,7 +101,7 @@ public function __construct(FqsenResolver $fqsenResolver = null) * @uses Context::getNamespaceAliases() to check whether the first part of the relative type name should not be * replaced with another namespace. * - * @return Type|null + * @return Type */ public function resolve($type, Context $context = null) { @@ -103,13 +120,149 @@ public function resolve($type, Context $context = null) $context = new Context(''); } + // split the type string into tokens `|`, `?`, `(`, `)[]`, '<', '>' and type names + $tokens = preg_split('/(\\||\\?|<|>|,|\\(|\\)(?:\\[\\])+)/', $type, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); + $tokenIterator = new \ArrayIterator($tokens); + + return $this->parseTypes($tokenIterator, $context, self::PARSER_IN_COMPOUND); + } + + /** + * Analyse each tokens and creates types + * + * @param \ArrayIterator $tokens the iterator on tokens + * @param Context $context + * @param integer $parserContext on of self::PARSER_* constants, indicating + * the context where we are in the parsing + * + * @return Type + */ + private function parseTypes(\ArrayIterator $tokens, Context $context, $parserContext) + { + $types = array(); + $token = ''; + while ($tokens->valid()) { + $token = $tokens->current(); + + if ($token == '|') { + if (count($types) == 0) { + throw new \RuntimeException( + 'A type is missing before a type separator' + ); + } + if ($parserContext !== self::PARSER_IN_COMPOUND + && $parserContext !== self::PARSER_IN_ARRAY_EXPRESSION + && $parserContext !== self::PARSER_IN_COLLECTION_EXPRESSION + ) { + throw new \RuntimeException( + 'Unexpected type separator' + ); + } + $tokens->next(); + + } else if ($token == '?') { + if ($parserContext !== self::PARSER_IN_COMPOUND + && $parserContext !== self::PARSER_IN_ARRAY_EXPRESSION + && $parserContext !== self::PARSER_IN_COLLECTION_EXPRESSION + ) { + throw new \RuntimeException( + 'Unexpected nullable character' + ); + } + + $tokens->next(); + $type = $this->parseTypes($tokens, $context, self::PARSER_IN_NULLABLE); + $types[] = new Nullable($type); + + } else if ($token === '(') { + $tokens->next(); + $type = $this->parseTypes($tokens, $context, self::PARSER_IN_ARRAY_EXPRESSION); + + $resolvedType = new Array_($type); + + // we generates arrays corresponding to the number of '[]' + // after the ')' + $numberOfArrays = (strlen($tokens->current()) -1) / 2; + for ($i = 0; $i < $numberOfArrays - 1; $i++) { + $resolvedType = new Array_($resolvedType); + } + $types[] = $resolvedType; + $tokens->next(); + + } else if ($parserContext === self::PARSER_IN_ARRAY_EXPRESSION + && $token[0] === ')' + ) { + break; + + } else if ($token === '<') { + if (count($types) === 0) { + throw new \RuntimeException( + 'Unexpected collection operator "<", class name is missing' + ); + } + $classType = array_pop($types); + + $types[] = $this->resolveCollection($tokens, $classType, $context); + + $tokens->next(); + + } else if ($parserContext === self::PARSER_IN_COLLECTION_EXPRESSION + && ($token === '>' || $token === ',') + ) { + break; + } else { + $type = $this->resolveSingleType($token, $context); + $tokens->next(); + if ($parserContext === self::PARSER_IN_NULLABLE) { + return $type; + } + $types[] = $type; + } + } + + if ($token == '|') { + throw new \RuntimeException( + 'A type is missing after a type separator' + ); + } + + if (count($types) == 0) { + if ($parserContext == self::PARSER_IN_NULLABLE) { + throw new \RuntimeException( + 'A type is missing after a nullable character' + ); + } + if ($parserContext == self::PARSER_IN_ARRAY_EXPRESSION) { + throw new \RuntimeException( + 'A type is missing in an array expression' + ); + } + if ($parserContext == self::PARSER_IN_COLLECTION_EXPRESSION) { + throw new \RuntimeException( + 'A type is missing in a collection expression' + ); + } + throw new \RuntimeException( + 'No types in a compound list' + ); + } else if (count($types) == 1) { + return $types[0]; + } + return new Compound($types); + } + + /** + * resolve the given type into a type object + * + * @param string $type the type string, representing a single type + * @param Context $context + * @return Type|Array_|Object_ + */ + private function resolveSingleType($type, Context $context) + { switch (true) { - case $this->isNullableType($type): - return $this->resolveNullableType($type, $context); case $this->isKeyword($type): return $this->resolveKeyword($type); - case ($this->isCompoundType($type)): - return $this->resolveCompoundType($type, $context); case $this->isTypedArray($type): return $this->resolveTypedArray($type, $context); case $this->isFqsen($type): @@ -200,30 +353,6 @@ private function isFqsen($type) return strpos($type, self::OPERATOR_NAMESPACE) === 0; } - /** - * Tests whether the given type is a compound type (i.e. `string|int`). - * - * @param string $type - * - * @return bool - */ - private function isCompoundType($type) - { - return strpos($type, '|') !== false; - } - - /** - * Test whether the given type is a nullable type (i.e. `?string`) - * - * @param string $type - * - * @return bool - */ - private function isNullableType($type) - { - return $type[0] === '?'; - } - /** * Resolves the given typed array string (i.e. `string[]`) into an Array object with the right types set. * @@ -234,7 +363,7 @@ private function isNullableType($type) */ private function resolveTypedArray($type, Context $context) { - return new Array_($this->resolve(substr($type, 0, -2), $context)); + return new Array_($this->resolveSingleType(substr($type, 0, -2), $context)); } /** @@ -265,34 +394,77 @@ private function resolveTypedObject($type, Context $context = null) } /** - * Resolves a compound type (i.e. `string|int`) into the appropriate Type objects or FQSEN. + * Resolves the collection values and keys * - * @param string $type - * @param Context $context - * - * @return Compound + * @param \ArrayIterator $tokens + * @param Type $classType + * @param Context|null $context + * @return Array_|Collection */ - private function resolveCompoundType($type, Context $context) - { - $types = []; + private function resolveCollection(\ArrayIterator $tokens, Type $classType, Context $context = null) { + + $isArray = ('array' == (string) $classType); - foreach (explode('|', $type) as $part) { - $types[] = $this->resolve($part, $context); + // allow only "array" or class name before "<" + if (!$isArray + && (! $classType instanceof Object_ || $classType->getFqsen() === null)) { + throw new \RuntimeException( + $classType.' is not a collection' + ); } - return new Compound($types); - } + $tokens->next(); - /** - * Resolve nullable types (i.e. `?string`) into a Nullable type wrapper - * - * @param string $type - * @param Context $context - * - * @return Nullable - */ - private function resolveNullableType($type, Context $context) - { - return new Nullable($this->resolve(ltrim($type, '?'), $context)); + $valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION); + $keyType = null; + + if ($tokens->current() == ',') { + // if we have a coma, then we just parsed the key type, not the value type + $keyType = $valueType; + if ($isArray) { + // check the key type for an "array" collection. We allow only + // strings or integers. + if (! $keyType instanceof String_ && + ! $keyType instanceof Integer && + ! $keyType instanceof Compound + ) { + throw new \RuntimeException( + 'An array can have only integers or strings as keys' + ); + } + if ($keyType instanceof Compound) { + foreach($keyType->getIterator() as $item) { + if (! $item instanceof String_ && + ! $item instanceof Integer + ) { + throw new \RuntimeException( + 'An array can have only integers or strings as keys' + ); + } + } + } + } + $tokens->next(); + // now let's parse the value type + $valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION); + } + + if ($tokens->current() !== '>') { + if ($tokens->current() == '') { + throw new \RuntimeException( + 'Collection: ">" is missing' + ); + } + + throw new \RuntimeException( + 'Unexpected character "'.$tokens->current().'", ">" is missing' + ); + } + if ($isArray) { + return new Array_($valueType, $keyType); + } + else { + return new Collection($classType->getFqsen(), $valueType, $keyType); + } } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/AbstractList.php b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/AbstractList.php new file mode 100644 index 00000000..ee626604 --- /dev/null +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/AbstractList.php @@ -0,0 +1,94 @@ + + * @license http://www.opensource.org/licenses/mit-license.php MIT + * @link http://phpdoc.org + */ + +namespace phpDocumentor\Reflection\Types; + +use phpDocumentor\Reflection\Type; + +/** + * Represents a list of values. This is an abstract class for Array_ and Collection. + * + */ +abstract class AbstractList implements Type +{ + /** @var Type */ + protected $valueType; + + /** @var Type|null */ + protected $keyType; + + /** @var Type */ + protected $defaultKeyType; + + /** + * Initializes this representation of an array with the given Type. + * + * @param Type $valueType + * @param Type $keyType + */ + public function __construct(Type $valueType = null, Type $keyType = null) + { + if ($valueType === null) { + $valueType = new Mixed_(); + } + + $this->valueType = $valueType; + $this->defaultKeyType = new Compound([ new String_(), new Integer() ]); + $this->keyType = $keyType; + + } + + /** + * Returns the type for the keys of this array. + * + * @return Type + */ + public function getKeyType() + { + if ($this->keyType === null) { + return $this->defaultKeyType; + } + return $this->keyType; + } + + /** + * Returns the value for the keys of this array. + * + * @return Type + */ + public function getValueType() + { + return $this->valueType; + } + + /** + * Returns a rendered output of the Type as it would be used in a DocBlock. + * + * @return string + */ + public function __toString() + { + if ($this->keyType) { + return 'array<'.$this->keyType.','.$this->valueType.'>'; + } + + if ($this->valueType instanceof Mixed_) { + return 'array'; + } + + if ($this->valueType instanceof Compound) { + return '(' . $this->valueType . ')[]'; + } + + return $this->valueType . '[]'; + } +} diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Array_.php b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Array_.php index 49b7c6ea..a45a78f4 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Array_.php +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Array_.php @@ -1,4 +1,4 @@ -valueType = $valueType; - $this->keyType = $keyType; - } - - /** - * Returns the type for the keys of this array. - * - * @return Type - */ - public function getKeyType() - { - return $this->keyType; - } - - /** - * Returns the value for the keys of this array. - * - * @return Type - */ - public function getValueType() - { - return $this->valueType; - } - - /** - * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string - */ - public function __toString() - { - if ($this->valueType instanceof Mixed_) { - return 'array'; - } - - return $this->valueType . '[]'; - } } diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php index f82b19e5..fde1136b 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php @@ -1,4 +1,4 @@ - + * @license http://www.opensource.org/licenses/mit-license.php MIT + * @link http://phpdoc.org + */ + +namespace phpDocumentor\Reflection\Types; + +use phpDocumentor\Reflection\Type; +use phpDocumentor\Reflection\Fqsen; + +/** + * Represents a collection type as described in the PSR-5, the PHPDoc Standard. + * + * A collection can be represented in two forms: + * + * 1. `ACollectionObject` + * 2. `ACollectionObject` + * + * - ACollectionObject can be 'array' or an object that can act as an array + * - aValueType and aKeyType can be any type expression + */ +final class Collection extends AbstractList +{ + + /** @var Fqsen */ + private $fqsen; + + /** + * Initializes this representation of an array with the given Type or Fqsen. + * + * @param Type $valueType + * @param Type $keyType + */ + public function __construct(Fqsen $fqsen, Type $valueType, Type $keyType = null) + { + parent::__construct($valueType, $keyType); + + $this->fqsen = $fqsen; + } + + /** + * Returns the FQSEN associated with this object. + * + * @return Fqsen + */ + public function getFqsen() + { + return $this->fqsen; + } + + /** + * Returns a rendered output of the Type as it would be used in a DocBlock. + * + * @return string + */ + public function __toString() + { + if ($this->keyType === null) { + return $this->fqsen.'<'.$this->valueType . '>'; + } + + return $this->fqsen.'<'.$this->keyType . ',' . $this->valueType . '>'; + } +} diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Compound.php b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Compound.php index be986c31..d45341b0 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Compound.php +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Compound.php @@ -1,4 +1,4 @@ -getFileName(); $namespace = $reflector->getNamespaceName(); - if (file_exists($fileName)) { + if (is_string($fileName) && file_exists($fileName)) { return $this->createForNamespace($namespace, file_get_contents($fileName)); } diff --git a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Float_.php b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Float_.php index e58d8966..cddcc178 100644 --- a/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Float_.php +++ b/Resources/Private/Php/vendor/phpdocumentor/type-resolver/src/Types/Float_.php @@ -1,4 +1,4 @@ -assertEquals('hashed_pass', $user->getPassword()); } - protected function setup() + protected function setUp() { $this->prophet = new \Prophecy\Prophet; } @@ -206,6 +206,17 @@ $user->setName('everzet')->will(function ($args) use ($user) { And now it doesn't matter how many times or in which order your methods are called. What matters is their behaviors and how well you faked it. +Note: If the method is called several times, you can use the following syntax to return different +values for each call: + +```php +$prophecy->read('123')->willReturn(1, 2, 3); +``` + +This feature is actually not recommended for most cases. Relying on the order of +calls for the same arguments tends to make test fragile, as adding one more call +can break everything. + #### Arguments wildcarding The previous example is awesome (at least I hope it is for you), but that's not diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/composer.json b/Resources/Private/Php/vendor/phpspec/prophecy/composer.json index 13b6658f..7151160f 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/composer.json +++ b/Resources/Private/Php/vendor/phpspec/prophecy/composer.json @@ -19,14 +19,14 @@ "require": { "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", "doctrine/instantiator": "^1.0.2", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, @@ -44,7 +44,7 @@ "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } } } diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php index aa960f3f..045a1b90 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php @@ -59,7 +59,9 @@ public function scoreArgument($argument) try { $comparator->assertEquals($argument, $this->value); return 10; - } catch (ComparisonFailure $failure) {} + } catch (ComparisonFailure $failure) { + return false; + } } // If either one is an object it should be castable to a string diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php index bc936c8f..d4bdba04 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php @@ -12,11 +12,11 @@ namespace Prophecy\Call; use Prophecy\Exception\Prophecy\MethodProphecyException; -use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Argument\ArgumentsWildcard; use Prophecy\Util\StringUtil; use Prophecy\Exception\Call\UnexpectedCallException; +use SplObjectStorage; /** * Calls receiver & manager. @@ -32,6 +32,11 @@ class CallCenter */ private $recordedCalls = array(); + /** + * @var SplObjectStorage + */ + private $unexpectedCalls; + /** * Initializes call center. * @@ -40,6 +45,7 @@ class CallCenter public function __construct(StringUtil $util = null) { $this->util = $util ?: new StringUtil; + $this->unexpectedCalls = new SplObjectStorage(); } /** @@ -74,23 +80,21 @@ public function makeCall(ObjectProphecy $prophecy, $methodName, array $arguments } // If no method prophecies defined, then it's a dummy, so we'll just return null - if ('__destruct' === $methodName || 0 == count($prophecy->getMethodProphecies())) { + if ('__destruct' === strtolower($methodName) || 0 == count($prophecy->getMethodProphecies())) { $this->recordedCalls[] = new Call($methodName, $arguments, null, null, $file, $line); return null; } // There are method prophecies, so it's a fake/stub. Searching prophecy for this call - $matches = array(); - foreach ($prophecy->getMethodProphecies($methodName) as $methodProphecy) { - if (0 < $score = $methodProphecy->getArgumentsWildcard()->scoreArguments($arguments)) { - $matches[] = array($score, $methodProphecy); - } - } + $matches = $this->findMethodProphecies($prophecy, $methodName, $arguments); // If fake/stub doesn't have method prophecy for this call - throw exception if (!count($matches)) { - throw $this->createUnexpectedCallException($prophecy, $methodName, $arguments); + $this->unexpectedCalls->attach(new Call($methodName, $arguments, null, null, $file, $line), $prophecy); + $this->recordedCalls[] = new Call($methodName, $arguments, null, null, $file, $line); + + return null; } // Sort matches by their score value @@ -138,15 +142,33 @@ public function makeCall(ObjectProphecy $prophecy, $methodName, array $arguments */ public function findCalls($methodName, ArgumentsWildcard $wildcard) { + $methodName = strtolower($methodName); + return array_values( array_filter($this->recordedCalls, function (Call $call) use ($methodName, $wildcard) { - return $methodName === $call->getMethodName() + return $methodName === strtolower($call->getMethodName()) && 0 < $call->getScore($wildcard) ; }) ); } + /** + * @throws UnexpectedCallException + */ + public function checkUnexpectedCalls() + { + /** @var Call $call */ + foreach ($this->unexpectedCalls as $call) { + $prophecy = $this->unexpectedCalls[$call]; + + // If fake/stub doesn't have method prophecy for this call - throw exception + if (!count($this->findMethodProphecies($prophecy, $call->getMethodName(), $call->getArguments()))) { + throw $this->createUnexpectedCallException($prophecy, $call->getMethodName(), $call->getArguments()); + } + } + } + private function createUnexpectedCallException(ObjectProphecy $prophecy, $methodName, array $arguments) { @@ -194,28 +216,6 @@ private function createUnexpectedCallException(ObjectProphecy $prophecy, $method ); } - private function formatExceptionMessage(MethodProphecy $methodProphecy) - { - return sprintf( - " - %s(\n". - "%s\n". - " )", - $methodProphecy->getMethodName(), - implode( - ",\n", - $this->indentArguments( - array_map( - function ($token) { - return (string) $token; - }, - $methodProphecy->getArgumentsWildcard()->getTokens() - ), - $indentationLength - ) - ) - ); - } - private function indentArguments(array $arguments, $indentationLength) { return preg_replace_callback( @@ -226,4 +226,23 @@ function () use ($indentationLength) { $arguments ); } + + /** + * @param ObjectProphecy $prophecy + * @param string $methodName + * @param array $arguments + * + * @return array + */ + private function findMethodProphecies(ObjectProphecy $prophecy, $methodName, array $arguments) + { + $matches = array(); + foreach ($prophecy->getMethodProphecies($methodName) as $methodProphecy) { + if (0 < $score = $methodProphecy->getArgumentsWildcard()->scoreArguments($arguments)) { + $matches[] = array($score, $methodProphecy); + } + } + + return $matches; + } } diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php index 874e474c..fa4f578e 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php @@ -27,16 +27,18 @@ public function accepts($expected, $actual) && is_object($actual) && $actual instanceof \Closure; } - public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false) + public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()) { - throw new ComparisonFailure( - $expected, - $actual, - // we don't need a diff - '', - '', - false, - 'all closures are born different' - ); + if ($expected !== $actual) { + throw new ComparisonFailure( + $expected, + $actual, + // we don't need a diff + '', + '', + false, + 'all closures are different if not identical' + ); + } } } diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php index d6b6b1a9..2b875211 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php @@ -21,17 +21,7 @@ */ class CachedDoubler extends Doubler { - private $classes = array(); - - /** - * {@inheritdoc} - */ - public function registerClassPatch(ClassPatch\ClassPatchInterface $patch) - { - $this->classes[] = array(); - - parent::registerClassPatch($patch); - } + private static $classes = array(); /** * {@inheritdoc} @@ -39,11 +29,11 @@ public function registerClassPatch(ClassPatch\ClassPatchInterface $patch) protected function createDoubleClass(ReflectionClass $class = null, array $interfaces) { $classId = $this->generateClassId($class, $interfaces); - if (isset($this->classes[$classId])) { - return $this->classes[$classId]; + if (isset(self::$classes[$classId])) { + return self::$classes[$classId]; } - return $this->classes[$classId] = parent::createDoubleClass($class, $interfaces); + return self::$classes[$classId] = parent::createDoubleClass($class, $interfaces); } /** @@ -61,8 +51,16 @@ private function generateClassId(ReflectionClass $class = null, array $interface foreach ($interfaces as $interface) { $parts[] = $interface->getName(); } + foreach ($this->getClassPatches() as $patch) { + $parts[] = get_class($patch); + } sort($parts); return md5(implode('', $parts)); } + + public function resetCache() + { + self::$classes = array(); + } } diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php index 081dea82..ef403666 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php @@ -43,7 +43,7 @@ public function supports(ClassNode $node) public function apply(ClassNode $node) { $node->addInterface('Prophecy\Prophecy\ProphecySubjectInterface'); - $node->addProperty('objectProphecy', 'private'); + $node->addProperty('objectProphecyClosure', 'private'); foreach ($node->getMethods() as $name => $method) { if ('__construct' === strtolower($name)) { @@ -65,10 +65,10 @@ public function apply(ClassNode $node) $prophecyArgument = new ArgumentNode('prophecy'); $prophecyArgument->setTypeHint('Prophecy\Prophecy\ProphecyInterface'); $prophecySetter->addArgument($prophecyArgument); - $prophecySetter->setCode('$this->objectProphecy = $prophecy;'); + $prophecySetter->setCode('$this->objectProphecyClosure = function () use ($prophecy) { return $prophecy; };'); $prophecyGetter = new MethodNode('getProphecy'); - $prophecyGetter->setCode('return $this->objectProphecy;'); + $prophecyGetter->setCode('return call_user_func($this->objectProphecyClosure);'); if ($node->hasMethod('__call')) { $__call = $node->getMethod('__call'); diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php index c5f9a5c7..6dab2d94 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php @@ -144,7 +144,7 @@ private function reflectMethodToNode(ReflectionMethod $method, Node\ClassNode $c } if (version_compare(PHP_VERSION, '7.0', '>=') && $method->hasReturnType()) { - $returnType = (string) $method->getReturnType(); + $returnType = PHP_VERSION_ID >= 70100 ? $method->getReturnType()->getName() : (string) $method->getReturnType(); $returnTypeLower = strtolower($returnType); if ('self' === $returnTypeLower) { @@ -231,7 +231,7 @@ private function getTypeHint(ReflectionParameter $parameter) } if (version_compare(PHP_VERSION, '7.0', '>=') && true === $parameter->hasType()) { - return (string) $parameter->getType(); + return PHP_VERSION_ID >= 70100 ? $parameter->getType()->getName() : (string) $parameter->getType(); } return null; diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php index 1d2da8f0..9817a447 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php @@ -44,7 +44,15 @@ public function getTagList(\ReflectionClass $reflectionClass) $this->contextFactory->createFromReflector($reflectionClass) ); - return $phpdoc->getTagsByName('method'); + $methods = array(); + + foreach ($phpdoc->getTagsByName('method') as $tag) { + if ($tag instanceof Method) { + $methods[] = $tag; + } + } + + return $methods; } catch (\InvalidArgumentException $e) { return array(); } diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php index 7250fa3c..26ec19ed 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php @@ -41,7 +41,7 @@ class ThrowPromise implements PromiseInterface public function __construct($exception) { if (is_string($exception)) { - if (!class_exists($exception) || !$this->isAValidThrowable($exception)) { + if ((!class_exists($exception) && !interface_exists($exception)) || !$this->isAValidThrowable($exception)) { throw new InvalidArgumentException(sprintf( 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', $exception @@ -94,6 +94,7 @@ public function execute(array $args, ObjectProphecy $object, MethodProphecy $met */ private function isAValidThrowable($exception) { - return is_a($exception, 'Exception', true) || is_subclass_of($exception, 'Throwable', true); + return is_a($exception, 'Exception', true) + || is_a($exception, 'Throwable', true); } } diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php index 7084ed6f..f33364ce 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php @@ -71,7 +71,7 @@ public function __construct(ObjectProphecy $objectProphecy, $methodName, $argume } if (version_compare(PHP_VERSION, '7.0', '>=') && true === $reflectedMethod->hasReturnType()) { - $type = (string) $reflectedMethod->getReturnType(); + $type = PHP_VERSION_ID >= 70100 ? $reflectedMethod->getReturnType()->getName() : (string) $reflectedMethod->getReturnType(); if ('void' === $type) { $this->voidReturnType = true; @@ -180,6 +180,40 @@ public function willReturn() return $this->will(new Promise\ReturnPromise(func_get_args())); } + /** + * @param array $items + * + * @return $this + * + * @throws \Prophecy\Exception\InvalidArgumentException + */ + public function willYield($items) + { + if ($this->voidReturnType) { + throw new MethodProphecyException( + "The method \"$this->methodName\" has a void return type, and so cannot yield anything", + $this + ); + } + + if (!is_array($items)) { + throw new InvalidArgumentException(sprintf( + 'Expected array, but got %s.', + gettype($items) + )); + } + + // Remove eval() when minimum version >=5.5 + /** @var callable $generator */ + $generator = eval('return function() use ($items) { + foreach ($items as $key => $value) { + yield $key => $value; + } + };'); + + return $this->will($generator); + } + /** * Sets return argument promise to the prophecy. * diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php index 8d8f8a1b..11b87cf1 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php @@ -146,7 +146,7 @@ public function addMethodProphecy(MethodProphecy $methodProphecy) ), $methodProphecy); } - $methodName = $methodProphecy->getMethodName(); + $methodName = strtolower($methodProphecy->getMethodName()); if (!isset($this->methodProphecies[$methodName])) { $this->methodProphecies[$methodName] = array(); @@ -168,6 +168,8 @@ public function getMethodProphecies($methodName = null) return $this->methodProphecies; } + $methodName = strtolower($methodName); + if (!isset($this->methodProphecies[$methodName])) { return array(); } @@ -208,12 +210,15 @@ public function findProphecyMethodCalls($methodName, ArgumentsWildcard $wildcard * Checks that registered method predictions do not fail. * * @throws \Prophecy\Exception\Prediction\AggregateException If any of registered predictions fail + * @throws \Prophecy\Exception\Call\UnexpectedCallException */ public function checkProphecyMethodsPredictions() { $exception = new AggregateException(sprintf("%s:\n", get_class($this->reveal()))); $exception->setObjectProphecy($this); + $this->callCenter->checkUnexpectedCalls(); + foreach ($this->methodProphecies as $prophecies) { foreach ($prophecies as $prophecy) { try { diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophet.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophet.php index a4fe4b0d..d37c92a3 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophet.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Prophet.php @@ -11,6 +11,7 @@ namespace Prophecy; +use Prophecy\Doubler\CachedDoubler; use Prophecy\Doubler\Doubler; use Prophecy\Doubler\LazyDouble; use Prophecy\Doubler\ClassPatch; @@ -45,11 +46,13 @@ class Prophet * @param null|RevealerInterface $revealer * @param null|StringUtil $util */ - public function __construct(Doubler $doubler = null, RevealerInterface $revealer = null, - StringUtil $util = null) - { + public function __construct( + Doubler $doubler = null, + RevealerInterface $revealer = null, + StringUtil $util = null + ) { if (null === $doubler) { - $doubler = new Doubler; + $doubler = new CachedDoubler(); $doubler->registerClassPatch(new ClassPatch\SplFileInfoPatch); $doubler->registerClassPatch(new ClassPatch\TraversablePatch); $doubler->registerClassPatch(new ClassPatch\ThrowablePatch); diff --git a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php index 50dd3f32..1090a801 100644 --- a/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php +++ b/Resources/Private/Php/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php @@ -181,9 +181,7 @@ protected static function recursiveExport(&$value, $indentation, $processed = nu if (is_object($value)) { $class = get_class($value); - if ($value instanceof ProphecyInterface) { - return sprintf('%s Object (*Prophecy*)', $class); - } elseif ($hash = $processed->contains($value)) { + if ($hash = $processed->contains($value)) { return sprintf('%s:%s Object', $class, $hash); } diff --git a/Resources/Private/Php/vendor/sebastian/exporter/.github/FUNDING.yml b/Resources/Private/Php/vendor/sebastian/exporter/.github/FUNDING.yml new file mode 100644 index 00000000..b19ea81a --- /dev/null +++ b/Resources/Private/Php/vendor/sebastian/exporter/.github/FUNDING.yml @@ -0,0 +1 @@ +patreon: s_bergmann diff --git a/Resources/Private/Php/vendor/sebastian/exporter/.gitignore b/Resources/Private/Php/vendor/sebastian/exporter/.gitignore index d27d3e9a..c79ecfa8 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/.gitignore +++ b/Resources/Private/Php/vendor/sebastian/exporter/.gitignore @@ -1,4 +1,5 @@ /.idea /composer.lock /vendor +/.php_cs /.php_cs.cache diff --git a/Resources/Private/Php/vendor/sebastian/exporter/.php_cs b/Resources/Private/Php/vendor/sebastian/exporter/.php_cs deleted file mode 100644 index 241ce11f..00000000 --- a/Resources/Private/Php/vendor/sebastian/exporter/.php_cs +++ /dev/null @@ -1,77 +0,0 @@ - - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. -EOF; - -return PhpCsFixer\Config::create() - ->setRiskyAllowed(true) - ->setRules( - [ - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => [ - 'align_double_arrow' => true, - 'align_equals' => true - ], - 'blank_line_after_namespace' => true, - 'blank_line_before_return' => true, - 'braces' => true, - 'cast_spaces' => true, - 'concat_space' => ['spacing' => 'one'], - 'elseif' => true, - 'encoding' => true, - 'full_opening_tag' => true, - 'function_declaration' => true, - 'header_comment' => ['header' => $header, 'separate' => 'none'], - 'indentation_type' => true, - 'line_ending' => true, - 'lowercase_constants' => true, - 'lowercase_keywords' => true, - 'method_argument_space' => true, - 'no_alias_functions' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_closing_tag' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => true, - 'no_leading_namespace_whitespace' => true, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_spaces_after_function_name' => true, - 'no_spaces_inside_parenthesis' => true, - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_whitespace' => true, - 'no_unused_imports' => true, - 'no_whitespace_in_blank_line' => true, - 'phpdoc_align' => true, - 'phpdoc_indent' => true, - 'phpdoc_no_access' => true, - 'phpdoc_no_empty_return' => true, - 'phpdoc_no_package' => true, - 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, - 'phpdoc_to_comment' => true, - 'phpdoc_trim' => true, - 'phpdoc_types' => true, - 'phpdoc_var_without_name' => true, - 'self_accessor' => true, - 'simplified_null_return' => true, - 'single_blank_line_at_eof' => true, - 'single_import_per_statement' => true, - 'single_line_after_imports' => true, - 'single_quote' => true, - 'ternary_operator_spaces' => true, - 'trim_array_spaces' => true, - 'visibility_required' => true, - ] - ) - ->setFinder( - PhpCsFixer\Finder::create() - ->files() - ->in(__DIR__ . '/src') - ->name('*.php') - ); diff --git a/Resources/Private/Php/vendor/sebastian/exporter/.php_cs.dist b/Resources/Private/Php/vendor/sebastian/exporter/.php_cs.dist new file mode 100644 index 00000000..c072f5b1 --- /dev/null +++ b/Resources/Private/Php/vendor/sebastian/exporter/.php_cs.dist @@ -0,0 +1,190 @@ + + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +EOF; + +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules( + [ + 'align_multiline_comment' => true, + 'array_indentation' => true, + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => [ + 'operators' => [ + '=' => 'align', + '=>' => 'align', + ], + ], + 'blank_line_after_namespace' => true, + 'blank_line_before_statement' => [ + 'statements' => [ + 'break', + 'continue', + 'declare', + 'do', + 'for', + 'foreach', + 'if', + 'include', + 'include_once', + 'require', + 'require_once', + 'return', + 'switch', + 'throw', + 'try', + 'while', + 'yield', + ], + ], + 'braces' => true, + 'cast_spaces' => true, + 'class_attributes_separation' => ['elements' => ['const', 'method', 'property']], + 'combine_consecutive_issets' => true, + 'combine_consecutive_unsets' => true, + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => ['space' => 'none'], + 'declare_strict_types' => true, + 'dir_constant' => true, + 'elseif' => true, + 'encoding' => true, + 'full_opening_tag' => true, + 'function_declaration' => true, + 'header_comment' => ['header' => $header, 'separate' => 'none'], + 'indentation_type' => true, + 'is_null' => true, + 'line_ending' => true, + 'list_syntax' => ['syntax' => 'short'], + 'logical_operators' => true, + 'lowercase_cast' => true, + 'lowercase_constants' => true, + 'lowercase_keywords' => true, + 'lowercase_static_reference' => true, + 'magic_constant_casing' => true, + 'method_argument_space' => ['ensure_fully_multiline' => true], + 'modernize_types_casting' => true, + 'multiline_comment_opening_closing' => true, + 'multiline_whitespace_before_semicolons' => true, + 'native_constant_invocation' => true, + 'native_function_casing' => true, + 'native_function_invocation' => true, + 'new_with_braces' => false, + 'no_alias_functions' => true, + 'no_alternative_syntax' => true, + 'no_blank_lines_after_class_opening' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_blank_lines_before_namespace' => true, + 'no_closing_tag' => true, + 'no_empty_comment' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_blank_lines' => true, + 'no_homoglyph_names' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_mixed_echo_print' => ['use' => 'print'], + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_null_property_initialization' => true, + 'no_php4_constructor' => true, + 'no_short_bool_cast' => true, + 'no_short_echo_tag' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_spaces_after_function_name' => true, + 'no_spaces_inside_parenthesis' => true, + 'no_superfluous_elseif' => true, + 'no_superfluous_phpdoc_tags' => true, + 'no_trailing_comma_in_list_call' => true, + 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unneeded_curly_braces' => true, + 'no_unneeded_final_method' => true, + 'no_unreachable_default_argument_value' => true, + 'no_unset_on_property' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'non_printable_character' => true, + 'normalize_index_brace' => true, + 'object_operator_without_whitespace' => true, + 'ordered_class_elements' => [ + 'order' => [ + 'use_trait', + 'constant_public', + 'constant_protected', + 'constant_private', + 'property_public_static', + 'property_protected_static', + 'property_private_static', + 'property_public', + 'property_protected', + 'property_private', + 'method_public_static', + 'construct', + 'destruct', + 'magic', + 'phpunit', + 'method_public', + 'method_protected', + 'method_private', + 'method_protected_static', + 'method_private_static', + ], + ], + 'ordered_imports' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_align' => true, + 'phpdoc_annotation_without_dot' => true, + 'phpdoc_indent' => true, + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_order' => true, + 'phpdoc_return_self_reference' => true, + 'phpdoc_scalar' => true, + 'phpdoc_separation' => true, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_to_comment' => true, + 'phpdoc_trim' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'phpdoc_types' => true, + 'phpdoc_types_order' => true, + 'phpdoc_var_without_name' => true, + 'pow_to_exponentiation' => true, + 'protected_to_private' => true, + 'return_assignment' => true, + 'return_type_declaration' => ['space_before' => 'none'], + 'self_accessor' => true, + 'semicolon_after_instruction' => true, + 'set_type_to_cast' => true, + 'short_scalar_cast' => true, + 'simplified_null_return' => true, + 'single_blank_line_at_eof' => true, + 'single_import_per_statement' => true, + 'single_line_after_imports' => true, + 'single_quote' => true, + 'standardize_not_equals' => true, + 'ternary_to_null_coalescing' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'visibility_required' => true, + //'void_return' => true, + 'whitespace_after_comma_in_array' => true, + ] + ) + ->setFinder( + PhpCsFixer\Finder::create() + ->files() + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') + ); diff --git a/Resources/Private/Php/vendor/sebastian/exporter/.travis.yml b/Resources/Private/Php/vendor/sebastian/exporter/.travis.yml index 5ea0f531..7f3e35bb 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/.travis.yml +++ b/Resources/Private/Php/vendor/sebastian/exporter/.travis.yml @@ -2,12 +2,10 @@ language: php php: - 7.0 - - 7.0snapshot - 7.1 - - 7.1snapshot - - master - -sudo: false + - 7.2 + - 7.3 + - 7.4snapshot before_install: - composer self-update diff --git a/Resources/Private/Php/vendor/sebastian/exporter/ChangeLog.md b/Resources/Private/Php/vendor/sebastian/exporter/ChangeLog.md new file mode 100644 index 00000000..fe555222 --- /dev/null +++ b/Resources/Private/Php/vendor/sebastian/exporter/ChangeLog.md @@ -0,0 +1,15 @@ +# ChangeLog + +All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. + +## [3.1.2] - 2019-09-14 + +### Fixed + +* Fixed [#29](https://github.com/sebastianbergmann/exporter/pull/29): Second parameter for `str_repeat()` must be an integer + +### Removed + +* Remove HHVM-specific code that is no longer needed + +[3.1.2]: https://github.com/sebastianbergmann/exporter/compare/3.1.1...3.1.2 diff --git a/Resources/Private/Php/vendor/sebastian/exporter/LICENSE b/Resources/Private/Php/vendor/sebastian/exporter/LICENSE index de602c10..f77dc5af 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/LICENSE +++ b/Resources/Private/Php/vendor/sebastian/exporter/LICENSE @@ -1,6 +1,6 @@ Exporter -Copyright (c) 2002-2017, Sebastian Bergmann . +Copyright (c) 2002-2019, Sebastian Bergmann . All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Resources/Private/Php/vendor/sebastian/exporter/README.md b/Resources/Private/Php/vendor/sebastian/exporter/README.md index 7bbef504..4c838ab3 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/README.md +++ b/Resources/Private/Php/vendor/sebastian/exporter/README.md @@ -22,7 +22,6 @@ Exception Object &0000000078de0f0d000000002003a261 ( 'code' => 0 'file' => '/home/sebastianbergmann/test.php' 'line' => 34 - 'trace' => Array &0 () 'previous' => null ) */ diff --git a/Resources/Private/Php/vendor/sebastian/exporter/build.xml b/Resources/Private/Php/vendor/sebastian/exporter/build.xml index 489b986c..c835c8a4 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/build.xml +++ b/Resources/Private/Php/vendor/sebastian/exporter/build.xml @@ -14,8 +14,6 @@ - - diff --git a/Resources/Private/Php/vendor/sebastian/exporter/composer.json b/Resources/Private/Php/vendor/sebastian/exporter/composer.json index 33fc5bd0..b49f9535 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/composer.json +++ b/Resources/Private/Php/vendor/sebastian/exporter/composer.json @@ -23,9 +23,14 @@ }, { "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" + "email": "bschussek@gmail.com" } ], + "config": { + "optimize-autoloader": true, + "sort-packages": true + }, + "prefer-stable": true, "require": { "php": "^7.0", "sebastian/recursion-context": "^3.0" diff --git a/Resources/Private/Php/vendor/sebastian/exporter/src/Exporter.php b/Resources/Private/Php/vendor/sebastian/exporter/src/Exporter.php index b0e4ace9..ea31b809 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/src/Exporter.php +++ b/Resources/Private/Php/vendor/sebastian/exporter/src/Exporter.php @@ -1,13 +1,12 @@ - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace SebastianBergmann\Exporter; use SebastianBergmann\RecursionContext\Context; @@ -38,8 +37,7 @@ class Exporter * - Carriage returns and newlines are normalized to \n * - Recursion and repeated rendering is treated properly * - * @param mixed $value - * @param int $indentation The indentation level of the 2nd+ line + * @param int $indentation The indentation level of the 2nd+ line * * @return string */ @@ -49,8 +47,8 @@ public function export($value, $indentation = 0) } /** - * @param mixed $data - * @param Context $context + * @param array $data + * @param Context $context * * @return string */ @@ -67,11 +65,11 @@ public function shortenedRecursiveExport(&$data, Context $context = null) $context->add($data); foreach ($array as $key => $value) { - if (is_array($value)) { + if (\is_array($value)) { if ($context->contains($data[$key]) !== false) { $result[] = '*RECURSION*'; } else { - $result[] = sprintf( + $result[] = \sprintf( 'array(%s)', $this->shortenedRecursiveExport($data[$key], $context) ); @@ -81,7 +79,7 @@ public function shortenedRecursiveExport(&$data, Context $context = null) } } - return implode(', ', $result); + return \implode(', ', $result); } /** @@ -93,42 +91,40 @@ public function shortenedRecursiveExport(&$data, Context $context = null) * Newlines are replaced by the visible string '\n'. * Contents of arrays and objects (if any) are replaced by '...'. * - * @param mixed $value - * * @return string * * @see SebastianBergmann\Exporter\Exporter::export */ public function shortenedExport($value) { - if (is_string($value)) { - $string = str_replace("\n", '', $this->export($value)); + if (\is_string($value)) { + $string = \str_replace("\n", '', $this->export($value)); - if (function_exists('mb_strlen')) { - if (mb_strlen($string) > 40) { - $string = mb_substr($string, 0, 30) . '...' . mb_substr($string, -7); + if (\function_exists('mb_strlen')) { + if (\mb_strlen($string) > 40) { + $string = \mb_substr($string, 0, 30) . '...' . \mb_substr($string, -7); } } else { - if (strlen($string) > 40) { - $string = substr($string, 0, 30) . '...' . substr($string, -7); + if (\strlen($string) > 40) { + $string = \substr($string, 0, 30) . '...' . \substr($string, -7); } } return $string; } - if (is_object($value)) { - return sprintf( + if (\is_object($value)) { + return \sprintf( '%s Object (%s)', - get_class($value), - count($this->toArray($value)) > 0 ? '...' : '' + \get_class($value), + \count($this->toArray($value)) > 0 ? '...' : '' ); } - if (is_array($value)) { - return sprintf( + if (\is_array($value)) { + return \sprintf( 'Array (%s)', - count($value) > 0 ? '...' : '' + \count($value) > 0 ? '...' : '' ); } @@ -139,24 +135,29 @@ public function shortenedExport($value) * Converts an object to an array containing all of its private, protected * and public properties. * - * @param mixed $value - * * @return array */ public function toArray($value) { - if (!is_object($value)) { + if (!\is_object($value)) { return (array) $value; } $array = []; foreach ((array) $value as $key => $val) { + // Exception traces commonly reference hundreds to thousands of + // objects currently loaded in memory. Including them in the result + // has a severe negative performance impact. + if ("\0Error\0trace" === $key || "\0Exception\0trace" === $key) { + continue; + } + // properties are transformed to keys in the following way: // private $property => "\0Classname\0property" // protected $property => "\0*\0property" // public $property => "property" - if (preg_match('/^\0.+\0(.+)$/', $key, $matches)) { + if (\preg_match('/^\0.+\0(.+)$/', (string) $key, $matches)) { $key = $matches[1]; } @@ -172,20 +173,8 @@ public function toArray($value) // above (fast) mechanism nor with reflection in Zend. // Format the output similarly to print_r() in this case if ($value instanceof \SplObjectStorage) { - // However, the fast method does work in HHVM, and exposes the - // internal implementation. Hide it again. - if (property_exists('\SplObjectStorage', '__storage')) { - unset($array['__storage']); - } elseif (property_exists('\SplObjectStorage', 'storage')) { - unset($array['storage']); - } - - if (property_exists('\SplObjectStorage', '__key')) { - unset($array['__key']); - } - foreach ($value as $key => $val) { - $array[spl_object_hash($val)] = [ + $array[\spl_object_hash($val)] = [ 'obj' => $val, 'inf' => $value->getInfo(), ]; @@ -220,27 +209,29 @@ protected function recursiveExport(&$value, $indentation, $processed = null) return 'false'; } - if (is_float($value) && floatval(intval($value)) === $value) { + if (\is_float($value) && (float) ((int) $value) === $value) { return "$value.0"; } - if (is_resource($value)) { - return sprintf( + if (\is_resource($value)) { + return \sprintf( 'resource(%d) of type (%s)', $value, - get_resource_type($value) + \get_resource_type($value) ); } - if (is_string($value)) { + if (\is_string($value)) { // Match for most non printable chars somewhat taking multibyte chars into account - if (preg_match('/[^\x09-\x0d\x1b\x20-\xff]/', $value)) { - return 'Binary String: 0x' . bin2hex($value); + if (\preg_match('/[^\x09-\x0d\x1b\x20-\xff]/', $value)) { + return 'Binary String: 0x' . \bin2hex($value); } return "'" . - str_replace('', "\n", - str_replace( + \str_replace( + '', + "\n", + \str_replace( ["\r\n", "\n\r", "\r", "\n"], ['\r\n', '\n\r', '\r', '\n'], $value @@ -249,13 +240,13 @@ protected function recursiveExport(&$value, $indentation, $processed = null) "'"; } - $whitespace = str_repeat(' ', 4 * $indentation); + $whitespace = \str_repeat(' ', (int)(4 * $indentation)); if (!$processed) { $processed = new Context; } - if (is_array($value)) { + if (\is_array($value)) { if (($key = $processed->contains($value)) !== false) { return 'Array &' . $key; } @@ -264,9 +255,9 @@ protected function recursiveExport(&$value, $indentation, $processed = null) $key = $processed->add($value); $values = ''; - if (count($array) > 0) { + if (\count($array) > 0) { foreach ($array as $k => $v) { - $values .= sprintf( + $values .= \sprintf( '%s %s => %s' . "\n", $whitespace, $this->recursiveExport($k, $indentation), @@ -277,23 +268,23 @@ protected function recursiveExport(&$value, $indentation, $processed = null) $values = "\n" . $values . $whitespace; } - return sprintf('Array &%s (%s)', $key, $values); + return \sprintf('Array &%s (%s)', $key, $values); } - if (is_object($value)) { - $class = get_class($value); + if (\is_object($value)) { + $class = \get_class($value); if ($hash = $processed->contains($value)) { - return sprintf('%s Object &%s', $class, $hash); + return \sprintf('%s Object &%s', $class, $hash); } $hash = $processed->add($value); $values = ''; $array = $this->toArray($value); - if (count($array) > 0) { + if (\count($array) > 0) { foreach ($array as $k => $v) { - $values .= sprintf( + $values .= \sprintf( '%s %s => %s' . "\n", $whitespace, $this->recursiveExport($k, $indentation), @@ -304,9 +295,9 @@ protected function recursiveExport(&$value, $indentation, $processed = null) $values = "\n" . $values . $whitespace; } - return sprintf('%s Object &%s (%s)', $class, $hash, $values); + return \sprintf('%s Object &%s (%s)', $class, $hash, $values); } - return var_export($value, true); + return \var_export($value, true); } } diff --git a/Resources/Private/Php/vendor/sebastian/exporter/tests/ExporterTest.php b/Resources/Private/Php/vendor/sebastian/exporter/tests/ExporterTest.php index 3f66163e..7fac74cc 100644 --- a/Resources/Private/Php/vendor/sebastian/exporter/tests/ExporterTest.php +++ b/Resources/Private/Php/vendor/sebastian/exporter/tests/ExporterTest.php @@ -1,16 +1,16 @@ - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace SebastianBergmann\Exporter; use PHPUnit\Framework\TestCase; +use SebastianBergmann\RecursionContext\Context; /** * @covers SebastianBergmann\Exporter\Exporter @@ -29,40 +29,40 @@ protected function setUp() public function exportProvider() { - $obj2 = new \stdClass; + $obj2 = new \stdClass; $obj2->foo = 'bar'; - $obj3 = (object)array(1,2,"Test\r\n",4,5,6,7,8); + $obj3 = (object) [1, 2, "Test\r\n", 4, 5, 6, 7, 8]; $obj = new \stdClass; //@codingStandardsIgnoreStart $obj->null = null; //@codingStandardsIgnoreEnd - $obj->boolean = true; - $obj->integer = 1; - $obj->double = 1.2; - $obj->string = '1'; - $obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext"; - $obj->object = $obj2; + $obj->boolean = true; + $obj->integer = 1; + $obj->double = 1.2; + $obj->string = '1'; + $obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext"; + $obj->object = $obj2; $obj->objectagain = $obj2; - $obj->array = array('foo' => 'bar'); - $obj->self = $obj; + $obj->array = ['foo' => 'bar']; + $obj->self = $obj; $storage = new \SplObjectStorage; $storage->attach($obj2); $storage->foo = $obj2; - return array( - 'export null' => array(null, 'null'), - 'export boolean true' => array(true, 'true'), - 'export boolean false' => array(false, 'false'), - 'export int 1' => array(1, '1'), - 'export float 1.0' => array(1.0, '1.0'), - 'export float 1.2' => array(1.2, '1.2'), - 'export stream' => array(fopen('php://memory', 'r'), 'resource(%d) of type (stream)'), - 'export numeric string' => array('1', "'1'"), - 'export multidimentional array' => array(array(array(1,2,3), array(3,4,5)), - << [null, 'null'], + 'export boolean true' => [true, 'true'], + 'export boolean false' => [false, 'false'], + 'export int 1' => [1, '1'], + 'export float 1.0' => [1.0, '1.0'], + 'export float 1.2' => [1.2, '1.2'], + 'export stream' => [\fopen('php://memory', 'r'), 'resource(%d) of type (stream)'], + 'export numeric string' => ['1', "'1'"], + 'export multidimentional array' => [[[1, 2, 3], [3, 4, 5]], + << Array &1 ( 0 => 1 @@ -76,10 +76,10 @@ public function exportProvider() ) ) EOF - ), + ], // \n\r and \r is converted to \n - 'export multiline text' => array("this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", - << ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", + << array(new \stdClass, 'stdClass Object &%x ()'), - 'export non empty stdclass' => array($obj, - << [new \stdClass, 'stdClass Object &%x ()'], + 'export non empty stdclass' => [$obj, + << null 'boolean' => true @@ -123,10 +123,10 @@ public function exportProvider() 'self' => stdClass Object &%x ) EOF - ), - 'export empty array' => array(array(), 'Array &%d ()'), - 'export splObjectStorage' => array($storage, - << [[], 'Array &%d ()'], + 'export splObjectStorage' => [$storage, + << stdClass Object &%x ( 'foo' => 'bar' @@ -137,9 +137,9 @@ public function exportProvider() ) ) EOF - ), - 'export stdClass with numeric properties' => array($obj3, - << [$obj3, + << 1 1 => 2 @@ -152,24 +152,50 @@ public function exportProvider() 7 => 8 ) EOF - ), - array( - chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), + ], + [ + \chr(0) . \chr(1) . \chr(2) . \chr(3) . \chr(4) . \chr(5), 'Binary String: 0x000102030405' - ), - array( - implode('', array_map('chr', range(0x0e, 0x1f))), + ], + [ + \implode('', \array_map('chr', \range(0x0e, 0x1f))), 'Binary String: 0x0e0f101112131415161718191a1b1c1d1e1f' - ), - array( - chr(0x00) . chr(0x09), + ], + [ + \chr(0x00) . \chr(0x09), 'Binary String: 0x0009' - ), - array( + ], + [ '', "''" - ), - ); + ], + 'export Exception without trace' => [ + new \Exception('The exception message', 42), + << 'The exception message' + 'string' => '' + 'code' => 42 + 'file' => '%s/tests/ExporterTest.php' + 'line' => %d + 'previous' => null +) +EOF + ], + 'export Error without trace' => [ + new \Error('The exception message', 42), + << 'The exception message' + 'string' => '' + 'code' => 42 + 'file' => '%s/tests/ExporterTest.php' + 'line' => %d + 'previous' => null +) +EOF + ], + ]; } /** @@ -185,25 +211,25 @@ public function testExport($value, $expected) public function testExport2() { - if (PHP_VERSION === '5.3.3') { + if (\PHP_VERSION === '5.3.3') { $this->markTestSkipped('Skipped due to "Nesting level too deep - recursive dependency?" fatal error'); } - $obj = new \stdClass; + $obj = new \stdClass; $obj->foo = 'bar'; - $array = array( - 0 => 0, - 'null' => null, - 'boolean' => true, - 'integer' => 1, - 'double' => 1.2, - 'string' => '1', - 'text' => "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", - 'object' => $obj, + $array = [ + 0 => 0, + 'null' => null, + 'boolean' => true, + 'integer' => 1, + 'double' => 1.2, + 'string' => '1', + 'text' => "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", + 'object' => $obj, 'objectagain' => $obj, - 'array' => array('foo' => 'bar'), - ); + 'array' => ['foo' => 'bar'], + ]; $array['self'] = &$array; @@ -269,27 +295,27 @@ public function testExport2() public function shortenedExportProvider() { - $obj = new \stdClass; + $obj = new \stdClass; $obj->foo = 'bar'; - $array = array( + $array = [ 'foo' => 'bar', - ); + ]; - return array( - 'shortened export null' => array(null, 'null'), - 'shortened export boolean true' => array(true, 'true'), - 'shortened export integer 1' => array(1, '1'), - 'shortened export float 1.0' => array(1.0, '1.0'), - 'shortened export float 1.2' => array(1.2, '1.2'), - 'shortened export numeric string' => array('1', "'1'"), + return [ + 'shortened export null' => [null, 'null'], + 'shortened export boolean true' => [true, 'true'], + 'shortened export integer 1' => [1, '1'], + 'shortened export float 1.0' => [1.0, '1.0'], + 'shortened export float 1.2' => [1.2, '1.2'], + 'shortened export numeric string' => ['1', "'1'"], // \n\r and \r is converted to \n - 'shortened export multilinestring' => array("this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery...\\rtext'"), - 'shortened export empty stdClass' => array(new \stdClass, 'stdClass Object ()'), - 'shortened export not empty stdClass' => array($obj, 'stdClass Object (...)'), - 'shortened export empty array' => array(array(), 'Array ()'), - 'shortened export not empty array' => array($array, 'Array (...)'), - ); + 'shortened export multilinestring' => ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery...\\rtext'"], + 'shortened export empty stdClass' => [new \stdClass, 'stdClass Object ()'], + 'shortened export not empty stdClass' => [$obj, 'stdClass Object (...)'], + 'shortened export empty array' => [[], 'Array ()'], + 'shortened export not empty array' => [$array, 'Array (...)'], + ]; } /** @@ -308,10 +334,10 @@ public function testShortenedExport($value, $expected) */ public function testShortenedExportForMultibyteCharacters() { - $oldMbLanguage = mb_language(); - mb_language('Japanese'); - $oldMbInternalEncoding = mb_internal_encoding(); - mb_internal_encoding('UTF-8'); + $oldMbLanguage = \mb_language(); + \mb_language('Japanese'); + $oldMbInternalEncoding = \mb_internal_encoding(); + \mb_internal_encoding('UTF-8'); try { $this->assertSame( @@ -319,25 +345,25 @@ public function testShortenedExportForMultibyteCharacters() $this->trimNewline($this->exporter->shortenedExport('いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす')) ); } catch (\Exception $e) { - mb_internal_encoding($oldMbInternalEncoding); - mb_language($oldMbLanguage); + \mb_internal_encoding($oldMbInternalEncoding); + \mb_language($oldMbLanguage); + throw $e; } - mb_internal_encoding($oldMbInternalEncoding); - mb_language($oldMbLanguage); + \mb_internal_encoding($oldMbInternalEncoding); + \mb_language($oldMbLanguage); } public function provideNonBinaryMultibyteStrings() { - return array( - array(implode('', array_map('chr', range(0x09, 0x0d))), 9), - array(implode('', array_map('chr', range(0x20, 0x7f))), 96), - array(implode('', array_map('chr', range(0x80, 0xff))), 128), - ); + return [ + [\implode('', \array_map('chr', \range(0x09, 0x0d))), 9], + [\implode('', \array_map('chr', \range(0x20, 0x7f))), 96], + [\implode('', \array_map('chr', \range(0x80, 0xff))), 128], + ]; } - /** * @dataProvider provideNonBinaryMultibyteStrings */ @@ -351,11 +377,56 @@ public function testNonBinaryStringExport($value, $expectedLength) public function testNonObjectCanBeReturnedAsArray() { - $this->assertEquals(array(true), $this->exporter->toArray(true)); + $this->assertEquals([true], $this->exporter->toArray(true)); + } + + public function testIgnoreKeysInValue() + { + // Find out what the actual use case was with the PHP bug + $array = []; + $array["\0gcdata"] = ''; + + $this->assertEquals([], $this->exporter->toArray((object) $array)); } private function trimNewline($string) { - return preg_replace('/[ ]*\n/', "\n", $string); + return \preg_replace('/[ ]*\n/', "\n", $string); + } + + /** + * @dataProvider shortenedRecursiveExportProvider + */ + public function testShortenedRecursiveExport(array $value, string $expected) + { + $this->assertEquals($expected, $this->exporter->shortenedRecursiveExport($value)); + } + + public function shortenedRecursiveExportProvider() + { + return [ + 'export null' => [[null], 'null'], + 'export boolean true' => [[true], 'true'], + 'export boolean false' => [[false], 'false'], + 'export int 1' => [[1], '1'], + 'export float 1.0' => [[1.0], '1.0'], + 'export float 1.2' => [[1.2], '1.2'], + 'export numeric string' => [['1'], "'1'"], + 'export with numeric array key' => [[2 => 1], '1'], + 'export with assoc array key' => [['foo' => 'bar'], '\'bar\''], + 'export multidimentional array' => [[[1, 2, 3], [3, 4, 5]], 'array(1, 2, 3), array(3, 4, 5)'], + 'export object' => [[new \stdClass], 'stdClass Object ()'], + ]; + } + + public function testShortenedRecursiveOccurredRecursion() + { + $recursiveValue = [1]; + $context = new Context(); + $context->add($recursiveValue); + + $value = [$recursiveValue]; + + $this->assertEquals('*RECURSION*', $this->exporter->shortenedRecursiveExport($value, $context)); } } diff --git a/Resources/Private/Php/vendor/symfony/polyfill-ctype/bootstrap.php b/Resources/Private/Php/vendor/symfony/polyfill-ctype/bootstrap.php index 14d1d0fa..0bc45cfd 100644 --- a/Resources/Private/Php/vendor/symfony/polyfill-ctype/bootstrap.php +++ b/Resources/Private/Php/vendor/symfony/polyfill-ctype/bootstrap.php @@ -12,15 +12,35 @@ use Symfony\Polyfill\Ctype as p; if (!function_exists('ctype_alnum')) { - function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); } - function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); } - function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); } - function ctype_digit($text) { return p\Ctype::ctype_digit($text); } - function ctype_graph($text) { return p\Ctype::ctype_graph($text); } - function ctype_lower($text) { return p\Ctype::ctype_lower($text); } - function ctype_print($text) { return p\Ctype::ctype_print($text); } - function ctype_punct($text) { return p\Ctype::ctype_punct($text); } - function ctype_space($text) { return p\Ctype::ctype_space($text); } - function ctype_upper($text) { return p\Ctype::ctype_upper($text); } - function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); } + function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); } +} +if (!function_exists('ctype_alpha')) { + function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); } +} +if (!function_exists('ctype_cntrl')) { + function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); } +} +if (!function_exists('ctype_digit')) { + function ctype_digit($input) { return p\Ctype::ctype_digit($input); } +} +if (!function_exists('ctype_graph')) { + function ctype_graph($input) { return p\Ctype::ctype_graph($input); } +} +if (!function_exists('ctype_lower')) { + function ctype_lower($input) { return p\Ctype::ctype_lower($input); } +} +if (!function_exists('ctype_print')) { + function ctype_print($input) { return p\Ctype::ctype_print($input); } +} +if (!function_exists('ctype_punct')) { + function ctype_punct($input) { return p\Ctype::ctype_punct($input); } +} +if (!function_exists('ctype_space')) { + function ctype_space($input) { return p\Ctype::ctype_space($input); } +} +if (!function_exists('ctype_upper')) { + function ctype_upper($input) { return p\Ctype::ctype_upper($input); } +} +if (!function_exists('ctype_xdigit')) { + function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); } } diff --git a/Resources/Private/Php/vendor/symfony/polyfill-ctype/composer.json b/Resources/Private/Php/vendor/symfony/polyfill-ctype/composer.json index 090f923e..d7c9abb6 100644 --- a/Resources/Private/Php/vendor/symfony/polyfill-ctype/composer.json +++ b/Resources/Private/Php/vendor/symfony/polyfill-ctype/composer.json @@ -28,7 +28,11 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-main": "1.19-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } } } diff --git a/Resources/Private/Php/vendor/webmozart/assert/.editorconfig b/Resources/Private/Php/vendor/webmozart/assert/.editorconfig new file mode 100644 index 00000000..384453bf --- /dev/null +++ b/Resources/Private/Php/vendor/webmozart/assert/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset=utf-8 +end_of_line=lf +trim_trailing_whitespace=true +insert_final_newline=true +indent_style=space +indent_size=4 + +[*.yml] +indent_size=2 diff --git a/Resources/Private/Php/vendor/webmozart/assert/CHANGELOG.md b/Resources/Private/Php/vendor/webmozart/assert/CHANGELOG.md index da4fb3fe..1d379277 100644 --- a/Resources/Private/Php/vendor/webmozart/assert/CHANGELOG.md +++ b/Resources/Private/Php/vendor/webmozart/assert/CHANGELOG.md @@ -3,6 +3,105 @@ Changelog ## UNRELEASED +## 1.9.1 + +## Fixed + +* provisional support for PHP 8.0 + +## 1.9.0 + +* added better Psalm support for `all*` & `nullOr*` methods + * These methods are now understood by Psalm through a mixin. You may need a newer version of Psalm in order to use this +* added `@psalm-pure` annotation to `Assert::notFalse()` +* added more `@psalm-assert` annotations where appropriate + +## Changed + +* the `all*` & `nullOr*` methods are now declared on an interface, instead of `@method` annotations. +This interface is linked to the `Assert` class with a `@mixin` annotation. Most IDE's have supported this +for a long time, and you should not lose any autocompletion capabilities. PHPStan has supported this since +version `0.12.20`. This package is marked incompatible (with a composer conflict) with phpstan version prior to that. +If you do not use PHPStan than this does not matter. + +## 1.8.0 + +### Added + +* added `Assert::notStartsWith()` +* added `Assert::notEndsWith()` +* added `Assert::inArray()` +* added `@psalm-pure` annotations to pure assertions + +### Fixed + +* Exception messages of comparisons between `DateTime(Immutable)` objects now display their date & time. +* Custom Exception messages for `Assert::count()` now use the values to render the exception message. + +## 1.7.0 (2020-02-14) + +### Added + +* added `Assert::notFalse()` +* added `Assert::isAOf()` +* added `Assert::isAnyOf()` +* added `Assert::isNotA()` + +## 1.6.0 (2019-11-24) + +### Added + +* added `Assert::validArrayKey()` +* added `Assert::isNonEmptyList()` +* added `Assert::isNonEmptyMap()` +* added `@throws InvalidArgumentException` annotations to all methods that throw. +* added `@psalm-assert` for the list type to the `isList` assertion. + +### Fixed + +* `ResourceBundle` & `SimpleXMLElement` now pass the `isCountable` assertions. +They are countable, without implementing the `Countable` interface. +* The doc block of `range` now has the proper variables. +* An empty array will now pass `isList` and `isMap`. As it is a valid form of both. +If a non-empty variant is needed, use `isNonEmptyList` or `isNonEmptyMap`. + +### Changed + +* Removed some `@psalm-assert` annotations, that were 'side effect' assertions See: + * [#144](https://github.com/webmozart/assert/pull/144) + * [#145](https://github.com/webmozart/assert/issues/145) + * [#146](https://github.com/webmozart/assert/pull/146) + * [#150](https://github.com/webmozart/assert/pull/150) +* If you use Psalm, the minimum version needed is `3.6.0`. Which is enforced through a composer conflict. +If you don't use Psalm, then this has no impact. + +## 1.5.0 (2019-08-24) + +### Added + +* added `Assert::uniqueValues()` +* added `Assert::unicodeLetters()` +* added: `Assert::email()` +* added support for [Psalm](https://github.com/vimeo/psalm), by adding `@psalm-assert` annotations where appropriate. + +### Fixed + +* `Assert::endsWith()` would not give the correct result when dealing with a multibyte suffix. +* `Assert::length(), minLength, maxLength, lengthBetween` would not give the correct result when dealing with multibyte characters. + +**NOTE**: These 2 changes may break your assertions if you relied on the fact that multibyte characters didn't behave correctly. + +### Changed + +* The names of some variables have been updated to better reflect what they are. +* All function calls are now in their FQN form, slightly increasing performance. +* Tests are now properly ran against HHVM-3.30 and PHP nightly. + +### Deprecation + +* deprecated `Assert::isTraversable()` in favor of `Assert::isIterable()` + * This was already done in 1.3.0, but it was only done through a silenced `trigger_error`. It is now annotated as well. + ## 1.4.0 (2018-12-25) ### Added @@ -22,7 +121,7 @@ Changelog ## 1.3.0 (2018-01-29) -### Added +### Added * added `Assert::minCount()` * added `Assert::maxCount()` diff --git a/Resources/Private/Php/vendor/webmozart/assert/README.md b/Resources/Private/Php/vendor/webmozart/assert/README.md index ce7ba59d..1407a9a1 100644 --- a/Resources/Private/Php/vendor/webmozart/assert/README.md +++ b/Resources/Private/Php/vendor/webmozart/assert/README.md @@ -3,18 +3,15 @@ Webmozart Assert [![Build Status](https://travis-ci.org/webmozart/assert.svg?branch=master)](https://travis-ci.org/webmozart/assert) [![Build status](https://ci.appveyor.com/api/projects/status/lyg83bcsisrr94se/branch/master?svg=true)](https://ci.appveyor.com/project/webmozart/assert/branch/master) +[![Code Coverage](https://scrutinizer-ci.com/g/webmozart/assert/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/webmozart/assert/?branch=master) [![Latest Stable Version](https://poser.pugx.org/webmozart/assert/v/stable.svg)](https://packagist.org/packages/webmozart/assert) [![Total Downloads](https://poser.pugx.org/webmozart/assert/downloads.svg)](https://packagist.org/packages/webmozart/assert) -Latest release: [1.2.0](https://packagist.org/packages/webmozart/assert#1.2.0) - -PHP >= 5.3.9 - This library contains efficient assertions to test the input and output of your methods. With these assertions, you can greatly reduce the amount of coding needed to write a safe implementation. -All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if +All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if they fail. FAQ @@ -26,21 +23,21 @@ This library is heavily inspired by Benjamin Eberlei's wonderful [assert package but fixes a usability issue with error messages that can't be fixed there without breaking backwards compatibility. -This package features usable error messages by default. However, you can also +This package features usable error messages by default. However, you can also easily write custom error messages: ``` Assert::string($path, 'The path is expected to be a string. Got: %s'); ``` -In [beberlei/assert], the ordering of the `%s` placeholders is different for -every assertion. This package, on the contrary, provides consistent placeholder +In [beberlei/assert], the ordering of the `%s` placeholders is different for +every assertion. This package, on the contrary, provides consistent placeholder ordering for all assertions: * `%s`: The tested value as string, e.g. `"/foo/bar"`. * `%2$s`, `%3$s`, ...: Additional assertion-specific values, e.g. the minimum/maximum length, allowed values, etc. - + Check the source code of the assertions to find out details about the additional available placeholders. @@ -73,11 +70,11 @@ If you create an employee with an invalid ID, an exception is thrown: ```php new Employee('foobar'); -// => InvalidArgumentException: +// => InvalidArgumentException: // The employee ID must be an integer. Got: string new Employee(-10); -// => InvalidArgumentException: +// => InvalidArgumentException: // The employee ID must be a positive integer. Got: -10 ``` @@ -107,16 +104,21 @@ Method | Description `isIterable($value, $message = '')` | Check that a value is an array or a `\Traversable` `isCountable($value, $message = '')` | Check that a value is an array or a `\Countable` `isInstanceOf($value, $class, $message = '')` | Check that a value is an `instanceof` a class -`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` a at least one class on the array of classes +`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` at least one class on the array of classes `notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class +`isAOf($value, $class, $message = '')` | Check that a value is of the class or has one of its parents +`isAnyOf($value, array $classes, $message = '')` | Check that a value is of at least one of the classes or has one of its parents +`isNotA($value, $class, $message = '')` | Check that a value is not of the class or has not one of its parents `isArrayAccessible($value, $message = '')` | Check that a value can be accessed as an array +`uniqueValues($values, $message = '')` | Check that the given array contains unique values ### Comparison Assertions Method | Description ------------------------------------------------ | -------------------------------------------------- +----------------------------------------------- | ------------------------------------------------------------------ `true($value, $message = '')` | Check that a value is `true` `false($value, $message = '')` | Check that a value is `false` +`notFalse($value, $message = '')` | Check that a value is not `false` `null($value, $message = '')` | Check that a value is `null` `notNull($value, $message = '')` | Check that a value is not `null` `isEmpty($value, $message = '')` | Check that a value is `empty()` @@ -130,7 +132,8 @@ Method | Description `lessThan($value, $value2, $message = '')` | Check that a value is less than another `lessThanEq($value, $value2, $message = '')` | Check that a value is less than or equal to another `range($value, $min, $max, $message = '')` | Check that a value is within a range -`oneOf($value, array $values, $message = '')` | Check that a value is one of a list of values +`inArray($value, array $values, $message = '')` | Check that a value is one of a list of values +`oneOf($value, array $values, $message = '')` | Check that a value is one of a list of values (alias of `inArray`) ### String Assertions @@ -140,12 +143,15 @@ any of the following assertions. Method | Description --------------------------------------------------- | ----------------------------------------------------------------- `contains($value, $subString, $message = '')` | Check that a string contains a substring -`notContains($value, $subString, $message = '')` | Check that a string does not contains a substring +`notContains($value, $subString, $message = '')` | Check that a string does not contain a substring `startsWith($value, $prefix, $message = '')` | Check that a string has a prefix +`notStartsWith($value, $prefix, $message = '')` | Check that a string does not have a prefix `startsWithLetter($value, $message = '')` | Check that a string starts with a letter `endsWith($value, $suffix, $message = '')` | Check that a string has a suffix +`notEndsWith($value, $suffix, $message = '')` | Check that a string does not have a suffix `regex($value, $pattern, $message = '')` | Check that a string matches a regular expression `notRegex($value, $pattern, $message = '')` | Check that a string does not match a regular expression +`unicodeLetters($value, $message = '')` | Check that a string contains Unicode letters only `alpha($value, $message = '')` | Check that a string contains letters only `digits($value, $message = '')` | Check that a string contains digits only `alnum($value, $message = '')` | Check that a string contains letters and digits only @@ -159,6 +165,7 @@ Method | Description `ip($value, $message = '')` | Check that a string is a valid IP (either IPv4 or IPv6) `ipv4($value, $message = '')` | Check that a string is a valid IPv4 `ipv6($value, $message = '')` | Check that a string is a valid IPv6 +`email($value, $message = '')` | Check that a string is a valid e-mail address `notWhitespaceOnly($value, $message = '')` | Check that a string contains at least one non-whitespace character ### File Assertions @@ -190,12 +197,15 @@ Method | Description -------------------------------------------------- | ------------------------------------------------------------------ `keyExists($array, $key, $message = '')` | Check that a key exists in an array `keyNotExists($array, $key, $message = '')` | Check that a key does not exist in an array +`validArrayKey($key, $message = '')` | Check that a value is a valid array key (int or string) `count($array, $number, $message = '')` | Check that an array contains a specific number of elements `minCount($array, $min, $message = '')` | Check that an array contains at least a certain number of elements `maxCount($array, $max, $message = '')` | Check that an array contains at most a certain number of elements `countBetween($array, $min, $max, $message = '')` | Check that an array has a count in the given range `isList($array, $message = '')` | Check that an array is a non-associative list +`isNonEmptyList($array, $message = '')` | Check that an array is a non-associative list, and not empty `isMap($array, $message = '')` | Check that an array is associative and has strings as keys +`isNonEmptyMap($array, $message = '')` | Check that an array is associative and has strings as keys, and is not empty ### Function Assertions @@ -221,6 +231,27 @@ assertion only if it the value is not `null`: Assert::nullOrString($middleName, 'The middle name must be a string or null. Got: %s'); ``` +### Extending Assert + +The `Assert` class comes with a few methods, which can be overridden to change the class behaviour. You can also extend it to +add your own assertions. + +#### Overriding methods + +Overriding the following methods in your assertion class allows you to change the behaviour of the assertions: + +* `public static function __callStatic($name, $arguments)` + * This method is used to 'create' the `nullOr` and `all` versions of the assertions. +* `protected static function valueToString($value)` + * This method is used for error messages, to convert the value to a string value for displaying. You could use this for representing a value object with a `__toString` method for example. +* `protected static function typeToString($value)` + * This method is used for error messages, to convert the a value to a string representing its type. +* `protected static function strlen($value)` + * This method is used to calculate string length for relevant methods, using the `mb_strlen` if available and useful. +* `protected static function reportInvalidArgument($message)` + * This method is called when an assertion fails, with the specified error message. Here you can throw your own exception, or log something. + + Authors ------- @@ -235,12 +266,6 @@ Contributions to the package are always welcome! * Report any bugs or issues you find on the [issue tracker]. * You can grab the source code at the package's [Git repository]. -Support -------- - -If you are having problems, send a mail to bschussek@gmail.com or shout out to -[@webmozart] on Twitter. - License ------- @@ -249,7 +274,7 @@ All contents of this package are licensed under the [MIT license]. [beberlei/assert]: https://github.com/beberlei/assert [assert package]: https://github.com/beberlei/assert [Composer]: https://getcomposer.org -[Bernhard Schussek]: http://webmozarts.com +[Bernhard Schussek]: https://webmozarts.com [The Community Contributors]: https://github.com/webmozart/assert/graphs/contributors [issue tracker]: https://github.com/webmozart/assert/issues [Git repository]: https://github.com/webmozart/assert diff --git a/Resources/Private/Php/vendor/webmozart/assert/composer.json b/Resources/Private/Php/vendor/webmozart/assert/composer.json index b6002ef3..2e609b63 100644 --- a/Resources/Private/Php/vendor/webmozart/assert/composer.json +++ b/Resources/Private/Php/vendor/webmozart/assert/composer.json @@ -14,17 +14,15 @@ } ], "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } + "conflict": { + "vimeo/psalm": "<3.9.1", + "phpstan/phpstan": "<0.12.20" }, "autoload": { "psr-4": { @@ -33,7 +31,8 @@ }, "autoload-dev": { "psr-4": { - "Webmozart\\Assert\\Tests\\": "tests/" + "Webmozart\\Assert\\Tests\\": "tests/", + "Webmozart\\Assert\\Bin\\": "bin/src" } } } diff --git a/Resources/Private/Php/vendor/webmozart/assert/psalm.xml b/Resources/Private/Php/vendor/webmozart/assert/psalm.xml new file mode 100644 index 00000000..9a430081 --- /dev/null +++ b/Resources/Private/Php/vendor/webmozart/assert/psalm.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/Resources/Private/Php/vendor/webmozart/assert/src/Assert.php b/Resources/Private/Php/vendor/webmozart/assert/src/Assert.php index db04bfbe..b28e1784 100644 --- a/Resources/Private/Php/vendor/webmozart/assert/src/Assert.php +++ b/Resources/Private/Php/vendor/webmozart/assert/src/Assert.php @@ -15,170 +15,19 @@ use BadMethodCallException; use Closure; use Countable; +use DateTime; +use DateTimeImmutable; use Exception; use InvalidArgumentException; +use ResourceBundle; +use SimpleXMLElement; use Throwable; use Traversable; /** * Efficient assertions to validate the input/output of your methods. * - * @method static void nullOrString($value, $message = '') - * @method static void nullOrStringNotEmpty($value, $message = '') - * @method static void nullOrInteger($value, $message = '') - * @method static void nullOrIntegerish($value, $message = '') - * @method static void nullOrFloat($value, $message = '') - * @method static void nullOrNumeric($value, $message = '') - * @method static void nullOrNatural($value, $message = '') - * @method static void nullOrBoolean($value, $message = '') - * @method static void nullOrScalar($value, $message = '') - * @method static void nullOrObject($value, $message = '') - * @method static void nullOrResource($value, $type = null, $message = '') - * @method static void nullOrIsCallable($value, $message = '') - * @method static void nullOrIsArray($value, $message = '') - * @method static void nullOrIsTraversable($value, $message = '') - * @method static void nullOrIsArrayAccessible($value, $message = '') - * @method static void nullOrIsCountable($value, $message = '') - * @method static void nullOrIsIterable($value, $message = '') - * @method static void nullOrIsInstanceOf($value, $class, $message = '') - * @method static void nullOrNotInstanceOf($value, $class, $message = '') - * @method static void nullOrIsInstanceOfAny($value, $classes, $message = '') - * @method static void nullOrIsEmpty($value, $message = '') - * @method static void nullOrNotEmpty($value, $message = '') - * @method static void nullOrTrue($value, $message = '') - * @method static void nullOrFalse($value, $message = '') - * @method static void nullOrIp($value, $message = '') - * @method static void nullOrIpv4($value, $message = '') - * @method static void nullOrIpv6($value, $message = '') - * @method static void nullOrEq($value, $value2, $message = '') - * @method static void nullOrNotEq($value,$value2, $message = '') - * @method static void nullOrSame($value, $value2, $message = '') - * @method static void nullOrNotSame($value, $value2, $message = '') - * @method static void nullOrGreaterThan($value, $value2, $message = '') - * @method static void nullOrGreaterThanEq($value, $value2, $message = '') - * @method static void nullOrLessThan($value, $value2, $message = '') - * @method static void nullOrLessThanEq($value, $value2, $message = '') - * @method static void nullOrRange($value, $min, $max, $message = '') - * @method static void nullOrOneOf($value, $values, $message = '') - * @method static void nullOrContains($value, $subString, $message = '') - * @method static void nullOrNotContains($value, $subString, $message = '') - * @method static void nullOrNotWhitespaceOnly($value, $message = '') - * @method static void nullOrStartsWith($value, $prefix, $message = '') - * @method static void nullOrStartsWithLetter($value, $message = '') - * @method static void nullOrEndsWith($value, $suffix, $message = '') - * @method static void nullOrRegex($value, $pattern, $message = '') - * @method static void nullOrNotRegex($value, $pattern, $message = '') - * @method static void nullOrAlpha($value, $message = '') - * @method static void nullOrDigits($value, $message = '') - * @method static void nullOrAlnum($value, $message = '') - * @method static void nullOrLower($value, $message = '') - * @method static void nullOrUpper($value, $message = '') - * @method static void nullOrLength($value, $length, $message = '') - * @method static void nullOrMinLength($value, $min, $message = '') - * @method static void nullOrMaxLength($value, $max, $message = '') - * @method static void nullOrLengthBetween($value, $min, $max, $message = '') - * @method static void nullOrFileExists($value, $message = '') - * @method static void nullOrFile($value, $message = '') - * @method static void nullOrDirectory($value, $message = '') - * @method static void nullOrReadable($value, $message = '') - * @method static void nullOrWritable($value, $message = '') - * @method static void nullOrClassExists($value, $message = '') - * @method static void nullOrSubclassOf($value, $class, $message = '') - * @method static void nullOrInterfaceExists($value, $message = '') - * @method static void nullOrImplementsInterface($value, $interface, $message = '') - * @method static void nullOrPropertyExists($value, $property, $message = '') - * @method static void nullOrPropertyNotExists($value, $property, $message = '') - * @method static void nullOrMethodExists($value, $method, $message = '') - * @method static void nullOrMethodNotExists($value, $method, $message = '') - * @method static void nullOrKeyExists($value, $key, $message = '') - * @method static void nullOrKeyNotExists($value, $key, $message = '') - * @method static void nullOrCount($value, $key, $message = '') - * @method static void nullOrMinCount($value, $min, $message = '') - * @method static void nullOrMaxCount($value, $max, $message = '') - * @method static void nullOrIsList($value, $message = '') - * @method static void nullOrIsMap($value, $message = '') - * @method static void nullOrCountBetween($value, $min, $max, $message = '') - * @method static void nullOrUuid($values, $message = '') - * @method static void nullOrThrows($expression, $class = 'Exception', $message = '') - * @method static void allString($values, $message = '') - * @method static void allStringNotEmpty($values, $message = '') - * @method static void allInteger($values, $message = '') - * @method static void allIntegerish($values, $message = '') - * @method static void allFloat($values, $message = '') - * @method static void allNumeric($values, $message = '') - * @method static void allNatural($values, $message = '') - * @method static void allBoolean($values, $message = '') - * @method static void allScalar($values, $message = '') - * @method static void allObject($values, $message = '') - * @method static void allResource($values, $type = null, $message = '') - * @method static void allIsCallable($values, $message = '') - * @method static void allIsArray($values, $message = '') - * @method static void allIsTraversable($values, $message = '') - * @method static void allIsArrayAccessible($values, $message = '') - * @method static void allIsCountable($values, $message = '') - * @method static void allIsIterable($values, $message = '') - * @method static void allIsInstanceOf($values, $class, $message = '') - * @method static void allNotInstanceOf($values, $class, $message = '') - * @method static void allIsInstanceOfAny($values, $classes, $message = '') - * @method static void allNull($values, $message = '') - * @method static void allNotNull($values, $message = '') - * @method static void allIsEmpty($values, $message = '') - * @method static void allNotEmpty($values, $message = '') - * @method static void allTrue($values, $message = '') - * @method static void allFalse($values, $message = '') - * @method static void allIp($values, $message = '') - * @method static void allIpv4($values, $message = '') - * @method static void allIpv6($values, $message = '') - * @method static void allEq($values, $value2, $message = '') - * @method static void allNotEq($values,$value2, $message = '') - * @method static void allSame($values, $value2, $message = '') - * @method static void allNotSame($values, $value2, $message = '') - * @method static void allGreaterThan($values, $value2, $message = '') - * @method static void allGreaterThanEq($values, $value2, $message = '') - * @method static void allLessThan($values, $value2, $message = '') - * @method static void allLessThanEq($values, $value2, $message = '') - * @method static void allRange($values, $min, $max, $message = '') - * @method static void allOneOf($values, $values, $message = '') - * @method static void allContains($values, $subString, $message = '') - * @method static void allNotContains($values, $subString, $message = '') - * @method static void allNotWhitespaceOnly($values, $message = '') - * @method static void allStartsWith($values, $prefix, $message = '') - * @method static void allStartsWithLetter($values, $message = '') - * @method static void allEndsWith($values, $suffix, $message = '') - * @method static void allRegex($values, $pattern, $message = '') - * @method static void allNotRegex($values, $pattern, $message = '') - * @method static void allAlpha($values, $message = '') - * @method static void allDigits($values, $message = '') - * @method static void allAlnum($values, $message = '') - * @method static void allLower($values, $message = '') - * @method static void allUpper($values, $message = '') - * @method static void allLength($values, $length, $message = '') - * @method static void allMinLength($values, $min, $message = '') - * @method static void allMaxLength($values, $max, $message = '') - * @method static void allLengthBetween($values, $min, $max, $message = '') - * @method static void allFileExists($values, $message = '') - * @method static void allFile($values, $message = '') - * @method static void allDirectory($values, $message = '') - * @method static void allReadable($values, $message = '') - * @method static void allWritable($values, $message = '') - * @method static void allClassExists($values, $message = '') - * @method static void allSubclassOf($values, $class, $message = '') - * @method static void allInterfaceExists($values, $message = '') - * @method static void allImplementsInterface($values, $interface, $message = '') - * @method static void allPropertyExists($values, $property, $message = '') - * @method static void allPropertyNotExists($values, $property, $message = '') - * @method static void allMethodExists($values, $method, $message = '') - * @method static void allMethodNotExists($values, $method, $message = '') - * @method static void allKeyExists($values, $key, $message = '') - * @method static void allKeyNotExists($values, $key, $message = '') - * @method static void allCount($values, $key, $message = '') - * @method static void allMinCount($values, $min, $message = '') - * @method static void allMaxCount($values, $max, $message = '') - * @method static void allCountBetween($values, $min, $max, $message = '') - * @method static void allIsList($values, $message = '') - * @method static void allIsMap($values, $message = '') - * @method static void allUuid($values, $message = '') - * @method static void allThrows($expressions, $class = 'Exception', $message = '') + * @mixin Mixin * * @since 1.0 * @@ -186,113 +35,213 @@ */ class Assert { + /** + * @psalm-pure + * @psalm-assert string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function string($value, $message = '') { - if (!is_string($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_string($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a string. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert non-empty-string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function stringNotEmpty($value, $message = '') { static::string($value, $message); static::notEq($value, '', $message); } + /** + * @psalm-pure + * @psalm-assert int $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function integer($value, $message = '') { - if (!is_int($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_int($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an integer. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert numeric $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function integerish($value, $message = '') { - if (!is_numeric($value) || $value != (int) $value) { - static::reportInvalidArgument(sprintf( + if (!\is_numeric($value) || $value != (int) $value) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an integerish value. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert float $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function float($value, $message = '') { - if (!is_float($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_float($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a float. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert numeric $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function numeric($value, $message = '') { - if (!is_numeric($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_numeric($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a numeric. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert int $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function natural($value, $message = '') { - if (!is_int($value) || $value < 0) { - static::reportInvalidArgument(sprintf( - $message ?: 'Expected a non-negative integer. Got %s', + if (!\is_int($value) || $value < 0) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected a non-negative integer. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert bool $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function boolean($value, $message = '') { - if (!is_bool($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_bool($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a boolean. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert scalar $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function scalar($value, $message = '') { - if (!is_scalar($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_scalar($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a scalar. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert object $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function object($value, $message = '') { - if (!is_object($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_object($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an object. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert resource $value + * + * @param mixed $value + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php + * @param string $message + * + * @throws InvalidArgumentException + */ public static function resource($value, $type = null, $message = '') { - if (!is_resource($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_resource($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a resource. Got: %s', static::typeToString($value) )); } - if ($type && $type !== get_resource_type($value)) { - static::reportInvalidArgument(sprintf( + if ($type && $type !== \get_resource_type($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a resource of type %2$s. Got: %s', static::typeToString($value), $type @@ -300,78 +249,151 @@ public static function resource($value, $type = null, $message = '') } } + /** + * @psalm-pure + * @psalm-assert callable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isCallable($value, $message = '') { - if (!is_callable($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_callable($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a callable. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert array $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isArray($value, $message = '') { - if (!is_array($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_array($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an array. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @deprecated use "isIterable" or "isInstanceOf" instead + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isTraversable($value, $message = '') { - @trigger_error( - sprintf( + @\trigger_error( + \sprintf( 'The "%s" assertion is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "isIterable" or "isInstanceOf" instead.', __METHOD__ ), - E_USER_DEPRECATED + \E_USER_DEPRECATED ); - if (!is_array($value) && !($value instanceof Traversable)) { - static::reportInvalidArgument(sprintf( + if (!\is_array($value) && !($value instanceof Traversable)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a traversable. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert array|ArrayAccess $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isArrayAccessible($value, $message = '') { - if (!is_array($value) && !($value instanceof ArrayAccess)) { - static::reportInvalidArgument(sprintf( + if (!\is_array($value) && !($value instanceof ArrayAccess)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an array accessible. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert countable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isCountable($value, $message = '') { - if (!is_array($value) && !($value instanceof Countable)) { - static::reportInvalidArgument(sprintf( + if ( + !\is_array($value) + && !($value instanceof Countable) + && !($value instanceof ResourceBundle) + && !($value instanceof SimpleXMLElement) + ) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a countable. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isIterable($value, $message = '') { - if (!is_array($value) && !($value instanceof Traversable)) { - static::reportInvalidArgument(sprintf( + if (!\is_array($value) && !($value instanceof Traversable)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an iterable. Got: %s', static::typeToString($value) )); } } + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert ExpectedType $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isInstanceOf($value, $class, $message = '') { if (!($value instanceof $class)) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an instance of %2$s. Got: %s', static::typeToString($value), $class @@ -379,10 +401,22 @@ public static function isInstanceOf($value, $class, $message = '') } } + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert !ExpectedType $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notInstanceOf($value, $class, $message = '') { if ($value instanceof $class) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an instance other than %2$s. Got: %s', static::typeToString($value), $class @@ -390,6 +424,16 @@ public static function notInstanceOf($value, $class, $message = '') } } + /** + * @psalm-pure + * @psalm-param array $classes + * + * @param mixed $value + * @param array $classes + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isInstanceOfAny($value, array $classes, $message = '') { foreach ($classes as $class) { @@ -398,43 +442,157 @@ public static function isInstanceOfAny($value, array $classes, $message = '') } } - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an instance of any of %2$s. Got: %s', static::typeToString($value), - implode(', ', array_map(array('static', 'valueToString'), $classes)) + \implode(', ', \array_map(array('static', 'valueToString'), $classes)) + )); + } + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert ExpectedType|class-string $value + * + * @param object|string $value + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function isAOf($value, $class, $message = '') + { + static::string($class, 'Expected class as a string. Got: %s'); + + if (!\is_a($value, $class, \is_string($value))) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an instance of this class or to this class among his parents %2$s. Got: %s', + static::typeToString($value), + $class + )); + } + } + + /** + * @psalm-pure + * @psalm-template UnexpectedType of object + * @psalm-param class-string $class + * @psalm-assert !UnexpectedType $value + * @psalm-assert !class-string $value + * + * @param object|string $value + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function isNotA($value, $class, $message = '') + { + static::string($class, 'Expected class as a string. Got: %s'); + + if (\is_a($value, $class, \is_string($value))) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an instance of this class or to this class among his parents other than %2$s. Got: %s', + static::typeToString($value), + $class + )); + } + } + + /** + * @psalm-pure + * @psalm-param array $classes + * + * @param object|string $value + * @param string[] $classes + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function isAnyOf($value, array $classes, $message = '') + { + foreach ($classes as $class) { + static::string($class, 'Expected class as a string. Got: %s'); + + if (\is_a($value, $class, \is_string($value))) { + return; + } + } + + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an any of instance of this class or to this class among his parents other than %2$s. Got: %s', + static::typeToString($value), + \implode(', ', \array_map(array('static', 'valueToString'), $classes)) )); } + /** + * @psalm-pure + * @psalm-assert empty $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isEmpty($value, $message = '') { if (!empty($value)) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an empty value. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert !empty $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notEmpty($value, $message = '') { if (empty($value)) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a non-empty value. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert null $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function null($value, $message = '') { if (null !== $value) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected null. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert !null $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notNull($value, $message = '') { if (null === $value) { @@ -444,102 +602,237 @@ public static function notNull($value, $message = '') } } + /** + * @psalm-pure + * @psalm-assert true $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function true($value, $message = '') { if (true !== $value) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to be true. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert false $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function false($value, $message = '') { if (false !== $value) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to be false. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert !false $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function notFalse($value, $message = '') + { + if (false === $value) { + static::reportInvalidArgument( + $message ?: 'Expected a value other than false.' + ); + } + } + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function ip($value, $message = '') { - if (false === filter_var($value, FILTER_VALIDATE_IP)) { - static::reportInvalidArgument(sprintf( + if (false === \filter_var($value, \FILTER_VALIDATE_IP)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to be an IP. Got: %s', static::valueToString($value) )); } } + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function ipv4($value, $message = '') { - if (false === filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - static::reportInvalidArgument(sprintf( + if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to be an IPv4. Got: %s', static::valueToString($value) )); } } + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function ipv6($value, $message = '') { - if (false === filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - static::reportInvalidArgument(sprintf( - $message ?: 'Expected a value to be an IPv6. Got %s', + if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected a value to be an IPv6. Got: %s', static::valueToString($value) )); } } - public static function eq($value, $value2, $message = '') + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function email($value, $message = '') { - if ($value2 != $value) { - static::reportInvalidArgument(sprintf( + if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected a value to be a valid e-mail address. Got: %s', + static::valueToString($value) + )); + } + } + + /** + * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. + * + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function uniqueValues(array $values, $message = '') + { + $allValues = \count($values); + $uniqueValues = \count(\array_unique($values)); + + if ($allValues !== $uniqueValues) { + $difference = $allValues - $uniqueValues; + + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected an array of unique values, but %s of them %s duplicated', + $difference, + (1 === $difference ? 'is' : 'are') + )); + } + } + + /** + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function eq($value, $expect, $message = '') + { + if ($expect != $value) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value equal to %2$s. Got: %s', static::valueToString($value), - static::valueToString($value2) + static::valueToString($expect) )); } } - public static function notEq($value, $value2, $message = '') + /** + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function notEq($value, $expect, $message = '') { - if ($value2 == $value) { - static::reportInvalidArgument(sprintf( + if ($expect == $value) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a different value than %s.', - static::valueToString($value2) + static::valueToString($expect) )); } } - public static function same($value, $value2, $message = '') + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function same($value, $expect, $message = '') { - if ($value2 !== $value) { - static::reportInvalidArgument(sprintf( + if ($expect !== $value) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value identical to %2$s. Got: %s', static::valueToString($value), - static::valueToString($value2) + static::valueToString($expect) )); } } - public static function notSame($value, $value2, $message = '') + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function notSame($value, $expect, $message = '') { - if ($value2 === $value) { - static::reportInvalidArgument(sprintf( + if ($expect === $value) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value not identical to %s.', - static::valueToString($value2) + static::valueToString($expect) )); } } + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ public static function greaterThan($value, $limit, $message = '') { if ($value <= $limit) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value greater than %2$s. Got: %s', static::valueToString($value), static::valueToString($limit) @@ -547,10 +840,19 @@ public static function greaterThan($value, $limit, $message = '') } } + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ public static function greaterThanEq($value, $limit, $message = '') { if ($value < $limit) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value greater than or equal to %2$s. Got: %s', static::valueToString($value), static::valueToString($limit) @@ -558,10 +860,19 @@ public static function greaterThanEq($value, $limit, $message = '') } } + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ public static function lessThan($value, $limit, $message = '') { if ($value >= $limit) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value less than %2$s. Got: %s', static::valueToString($value), static::valueToString($limit) @@ -569,10 +880,19 @@ public static function lessThan($value, $limit, $message = '') } } + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ public static function lessThanEq($value, $limit, $message = '') { if ($value > $limit) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value less than or equal to %2$s. Got: %s', static::valueToString($value), static::valueToString($limit) @@ -580,10 +900,22 @@ public static function lessThanEq($value, $limit, $message = '') } } + /** + * Inclusive range, so Assert::(3, 3, 5) passes. + * + * @psalm-pure + * + * @param mixed $value + * @param mixed $min + * @param mixed $max + * @param string $message + * + * @throws InvalidArgumentException + */ public static function range($value, $min, $max, $message = '') { if ($value < $min || $value > $max) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value between %2$s and %3$s. Got: %s', static::valueToString($value), static::valueToString($min), @@ -592,21 +924,57 @@ public static function range($value, $min, $max, $message = '') } } + /** + * A more human-readable alias of Assert::inArray(). + * + * @psalm-pure + * + * @param mixed $value + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ public static function oneOf($value, array $values, $message = '') { - if (!in_array($value, $values, true)) { - static::reportInvalidArgument(sprintf( + static::inArray($value, $values, $message); + } + + /** + * Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion. + * + * @psalm-pure + * + * @param mixed $value + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function inArray($value, array $values, $message = '') + { + if (!\in_array($value, $values, true)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected one of: %2$s. Got: %s', static::valueToString($value), - implode(', ', array_map(array('static', 'valueToString'), $values)) + \implode(', ', \array_map(array('static', 'valueToString'), $values)) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param string $subString + * @param string $message + * + * @throws InvalidArgumentException + */ public static function contains($value, $subString, $message = '') { - if (false === strpos($value, $subString)) { - static::reportInvalidArgument(sprintf( + if (false === \strpos($value, $subString)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain %2$s. Got: %s', static::valueToString($value), static::valueToString($subString) @@ -614,10 +982,19 @@ public static function contains($value, $subString, $message = '') } } + /** + * @psalm-pure + * + * @param string $value + * @param string $subString + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notContains($value, $subString, $message = '') { - if (false !== strpos($value, $subString)) { - static::reportInvalidArgument(sprintf( + if (false !== \strpos($value, $subString)) { + static::reportInvalidArgument(\sprintf( $message ?: '%2$s was not expected to be contained in a value. Got: %s', static::valueToString($value), static::valueToString($subString) @@ -625,20 +1002,37 @@ public static function notContains($value, $subString, $message = '') } } + /** + * @psalm-pure + * + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notWhitespaceOnly($value, $message = '') { - if (preg_match('/^\s*$/', $value)) { - static::reportInvalidArgument(sprintf( + if (\preg_match('/^\s*$/', $value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a non-whitespace string. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param string $prefix + * @param string $message + * + * @throws InvalidArgumentException + */ public static function startsWith($value, $prefix, $message = '') { - if (0 !== strpos($value, $prefix)) { - static::reportInvalidArgument(sprintf( + if (0 !== \strpos($value, $prefix)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to start with %2$s. Got: %s', static::valueToString($value), static::valueToString($prefix) @@ -646,29 +1040,68 @@ public static function startsWith($value, $prefix, $message = '') } } + /** + * @psalm-pure + * + * @param string $value + * @param string $prefix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function notStartsWith($value, $prefix, $message = '') + { + if (0 === \strpos($value, $prefix)) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected a value not to start with %2$s. Got: %s', + static::valueToString($value), + static::valueToString($prefix) + )); + } + } + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function startsWithLetter($value, $message = '') { + static::string($value); + $valid = isset($value[0]); if ($valid) { - $locale = setlocale(LC_CTYPE, 0); - setlocale(LC_CTYPE, 'C'); - $valid = ctype_alpha($value[0]); - setlocale(LC_CTYPE, $locale); + $locale = \setlocale(LC_CTYPE, 0); + \setlocale(LC_CTYPE, 'C'); + $valid = \ctype_alpha($value[0]); + \setlocale(LC_CTYPE, $locale); } if (!$valid) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to start with a letter. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param string $suffix + * @param string $message + * + * @throws InvalidArgumentException + */ public static function endsWith($value, $suffix, $message = '') { - if ($suffix !== substr($value, -static::strlen($suffix))) { - static::reportInvalidArgument(sprintf( + if ($suffix !== \substr($value, -\strlen($suffix))) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to end with %2$s. Got: %s', static::valueToString($value), static::valueToString($suffix) @@ -676,20 +1109,58 @@ public static function endsWith($value, $suffix, $message = '') } } + /** + * @psalm-pure + * + * @param string $value + * @param string $suffix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function notEndsWith($value, $suffix, $message = '') + { + if ($suffix === \substr($value, -\strlen($suffix))) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected a value not to end with %2$s. Got: %s', + static::valueToString($value), + static::valueToString($suffix) + )); + } + } + + /** + * @psalm-pure + * + * @param string $value + * @param string $pattern + * @param string $message + * + * @throws InvalidArgumentException + */ public static function regex($value, $pattern, $message = '') { - if (!preg_match($pattern, $value)) { - static::reportInvalidArgument(sprintf( + if (!\preg_match($pattern, $value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The value %s does not match the expected pattern.', static::valueToString($value) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param string $pattern + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notRegex($value, $pattern, $message = '') { - if (preg_match($pattern, $value, $matches, PREG_OFFSET_CAPTURE)) { - static::reportInvalidArgument(sprintf( + if (\preg_match($pattern, $value, $matches, PREG_OFFSET_CAPTURE)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The value %s matches the pattern %s (at offset %d).', static::valueToString($value), static::valueToString($pattern), @@ -698,85 +1169,158 @@ public static function notRegex($value, $pattern, $message = '') } } + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function unicodeLetters($value, $message = '') + { + static::string($value); + + if (!\preg_match('/^\p{L}+$/u', $value)) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected a value to contain only Unicode letters. Got: %s', + static::valueToString($value) + )); + } + } + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function alpha($value, $message = '') { - $locale = setlocale(LC_CTYPE, 0); - setlocale(LC_CTYPE, 'C'); - $valid = !ctype_alpha($value); - setlocale(LC_CTYPE, $locale); + static::string($value); + + $locale = \setlocale(LC_CTYPE, 0); + \setlocale(LC_CTYPE, 'C'); + $valid = !\ctype_alpha($value); + \setlocale(LC_CTYPE, $locale); if ($valid) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain only letters. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function digits($value, $message = '') { - $locale = setlocale(LC_CTYPE, 0); - setlocale(LC_CTYPE, 'C'); - $valid = !ctype_digit($value); - setlocale(LC_CTYPE, $locale); + $locale = \setlocale(LC_CTYPE, 0); + \setlocale(LC_CTYPE, 'C'); + $valid = !\ctype_digit($value); + \setlocale(LC_CTYPE, $locale); if ($valid) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain digits only. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function alnum($value, $message = '') { - $locale = setlocale(LC_CTYPE, 0); - setlocale(LC_CTYPE, 'C'); - $valid = !ctype_alnum($value); - setlocale(LC_CTYPE, $locale); + $locale = \setlocale(LC_CTYPE, 0); + \setlocale(LC_CTYPE, 'C'); + $valid = !\ctype_alnum($value); + \setlocale(LC_CTYPE, $locale); if ($valid) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain letters and digits only. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert lowercase-string $value + * + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function lower($value, $message = '') { - $locale = setlocale(LC_CTYPE, 0); - setlocale(LC_CTYPE, 'C'); - $valid = !ctype_lower($value); - setlocale(LC_CTYPE, $locale); + $locale = \setlocale(LC_CTYPE, 0); + \setlocale(LC_CTYPE, 'C'); + $valid = !\ctype_lower($value); + \setlocale(LC_CTYPE, $locale); if ($valid) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain lowercase characters only. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-assert !lowercase-string $value + * + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function upper($value, $message = '') { - $locale = setlocale(LC_CTYPE, 0); - setlocale(LC_CTYPE, 'C'); - $valid = !ctype_upper($value); - setlocale(LC_CTYPE, $locale); + $locale = \setlocale(LC_CTYPE, 0); + \setlocale(LC_CTYPE, 'C'); + $valid = !\ctype_upper($value); + \setlocale(LC_CTYPE, $locale); if ($valid) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain uppercase characters only. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * + * @param string $value + * @param int $length + * @param string $message + * + * @throws InvalidArgumentException + */ public static function length($value, $length, $message = '') { if ($length !== static::strlen($value)) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain %2$s characters. Got: %s', static::valueToString($value), $length @@ -784,10 +1328,21 @@ public static function length($value, $length, $message = '') } } + /** + * Inclusive min. + * + * @psalm-pure + * + * @param string $value + * @param int|float $min + * @param string $message + * + * @throws InvalidArgumentException + */ public static function minLength($value, $min, $message = '') { if (static::strlen($value) < $min) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain at least %2$s characters. Got: %s', static::valueToString($value), $min @@ -795,10 +1350,21 @@ public static function minLength($value, $min, $message = '') } } + /** + * Inclusive max. + * + * @psalm-pure + * + * @param string $value + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ public static function maxLength($value, $max, $message = '') { if (static::strlen($value) > $max) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain at most %2$s characters. Got: %s', static::valueToString($value), $max @@ -806,12 +1372,24 @@ public static function maxLength($value, $max, $message = '') } } + /** + * Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion. + * + * @psalm-pure + * + * @param string $value + * @param int|float $min + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ public static function lengthBetween($value, $min, $max, $message = '') { $length = static::strlen($value); if ($length < $min || $length > $max) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', static::valueToString($value), $min, @@ -820,76 +1398,128 @@ public static function lengthBetween($value, $min, $max, $message = '') } } + /** + * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function fileExists($value, $message = '') { static::string($value); - if (!file_exists($value)) { - static::reportInvalidArgument(sprintf( + if (!\file_exists($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The file %s does not exist.', static::valueToString($value) )); } } + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function file($value, $message = '') { static::fileExists($value, $message); - if (!is_file($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_file($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The path %s is not a file.', static::valueToString($value) )); } } + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function directory($value, $message = '') { static::fileExists($value, $message); - if (!is_dir($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_dir($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The path %s is no directory.', static::valueToString($value) )); } } + /** + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function readable($value, $message = '') { - if (!is_readable($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_readable($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The path %s is not readable.', static::valueToString($value) )); } } + /** + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function writable($value, $message = '') { - if (!is_writable($value)) { - static::reportInvalidArgument(sprintf( + if (!\is_writable($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'The path %s is not writable.', static::valueToString($value) )); } } + /** + * @psalm-assert class-string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function classExists($value, $message = '') { - if (!class_exists($value)) { - static::reportInvalidArgument(sprintf( + if (!\class_exists($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an existing class name. Got: %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert class-string|ExpectedType $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ public static function subclassOf($value, $class, $message = '') { - if (!is_subclass_of($value, $class)) { - static::reportInvalidArgument(sprintf( + if (!\is_subclass_of($value, $class)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a sub-class of %2$s. Got: %s', static::valueToString($value), static::valueToString($class) @@ -897,20 +1527,40 @@ public static function subclassOf($value, $class, $message = '') } } + /** + * @psalm-assert class-string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function interfaceExists($value, $message = '') { - if (!interface_exists($value)) { - static::reportInvalidArgument(sprintf( + if (!\interface_exists($value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an existing interface name. got %s', static::valueToString($value) )); } } + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $interface + * @psalm-assert class-string $value + * + * @param mixed $value + * @param mixed $interface + * @param string $message + * + * @throws InvalidArgumentException + */ public static function implementsInterface($value, $interface, $message = '') { - if (!in_array($interface, class_implements($value))) { - static::reportInvalidArgument(sprintf( + if (!\in_array($interface, \class_implements($value))) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an implementation of %2$s. Got: %s', static::valueToString($value), static::valueToString($interface) @@ -918,103 +1568,223 @@ public static function implementsInterface($value, $interface, $message = '') } } + /** + * @psalm-pure + * @psalm-param class-string|object $classOrObject + * + * @param string|object $classOrObject + * @param mixed $property + * @param string $message + * + * @throws InvalidArgumentException + */ public static function propertyExists($classOrObject, $property, $message = '') { - if (!property_exists($classOrObject, $property)) { - static::reportInvalidArgument(sprintf( + if (!\property_exists($classOrObject, $property)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the property %s to exist.', static::valueToString($property) )); } } + /** + * @psalm-pure + * @psalm-param class-string|object $classOrObject + * + * @param string|object $classOrObject + * @param mixed $property + * @param string $message + * + * @throws InvalidArgumentException + */ public static function propertyNotExists($classOrObject, $property, $message = '') { - if (property_exists($classOrObject, $property)) { - static::reportInvalidArgument(sprintf( + if (\property_exists($classOrObject, $property)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the property %s to not exist.', static::valueToString($property) )); } } + /** + * @psalm-pure + * @psalm-param class-string|object $classOrObject + * + * @param string|object $classOrObject + * @param mixed $method + * @param string $message + * + * @throws InvalidArgumentException + */ public static function methodExists($classOrObject, $method, $message = '') { - if (!method_exists($classOrObject, $method)) { - static::reportInvalidArgument(sprintf( + if (!(\is_string($classOrObject) || \is_object($classOrObject)) || !\method_exists($classOrObject, $method)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the method %s to exist.', static::valueToString($method) )); } } + /** + * @psalm-pure + * @psalm-param class-string|object $classOrObject + * + * @param string|object $classOrObject + * @param mixed $method + * @param string $message + * + * @throws InvalidArgumentException + */ public static function methodNotExists($classOrObject, $method, $message = '') { - if (method_exists($classOrObject, $method)) { - static::reportInvalidArgument(sprintf( + if ((\is_string($classOrObject) || \is_object($classOrObject)) && \method_exists($classOrObject, $method)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the method %s to not exist.', static::valueToString($method) )); } } + /** + * @psalm-pure + * + * @param array $array + * @param string|int $key + * @param string $message + * + * @throws InvalidArgumentException + */ public static function keyExists($array, $key, $message = '') { - if (!(isset($array[$key]) || array_key_exists($key, $array))) { - static::reportInvalidArgument(sprintf( + if (!(isset($array[$key]) || \array_key_exists($key, $array))) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the key %s to exist.', static::valueToString($key) )); } } + /** + * @psalm-pure + * + * @param array $array + * @param string|int $key + * @param string $message + * + * @throws InvalidArgumentException + */ public static function keyNotExists($array, $key, $message = '') { - if (isset($array[$key]) || array_key_exists($key, $array)) { - static::reportInvalidArgument(sprintf( + if (isset($array[$key]) || \array_key_exists($key, $array)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the key %s to not exist.', static::valueToString($key) )); } } + /** + * Checks if a value is a valid array key (int or string). + * + * @psalm-pure + * @psalm-assert array-key $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function validArrayKey($value, $message = '') + { + if (!(\is_int($value) || \is_string($value))) { + static::reportInvalidArgument(\sprintf( + $message ?: 'Expected string or integer. Got: %s', + static::typeToString($value) + )); + } + } + + /** + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. + * + * @param Countable|array $array + * @param int $number + * @param string $message + * + * @throws InvalidArgumentException + */ public static function count($array, $number, $message = '') { static::eq( - count($array), + \count($array), $number, - $message ?: sprintf('Expected an array to contain %d elements. Got: %d.', $number, count($array)) + \sprintf( + $message ?: 'Expected an array to contain %d elements. Got: %d.', + $number, + \count($array) + ) ); } + /** + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. + * + * @param Countable|array $array + * @param int|float $min + * @param string $message + * + * @throws InvalidArgumentException + */ public static function minCount($array, $min, $message = '') { - if (count($array) < $min) { - static::reportInvalidArgument(sprintf( + if (\count($array) < $min) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', - count($array), + \count($array), $min )); } } + /** + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. + * + * @param Countable|array $array + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ public static function maxCount($array, $max, $message = '') { - if (count($array) > $max) { - static::reportInvalidArgument(sprintf( + if (\count($array) > $max) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', - count($array), + \count($array), $max )); } } + /** + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. + * + * @param Countable|array $array + * @param int|float $min + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ public static function countBetween($array, $min, $max, $message = '') { - $count = count($array); + $count = \count($array); if ($count < $min || $count > $max) { - static::reportInvalidArgument(sprintf( + static::reportInvalidArgument(\sprintf( $message ?: 'Expected an array to contain between %2$d and %3$d elements. Got: %d', $count, $min, @@ -1023,23 +1793,55 @@ public static function countBetween($array, $min, $max, $message = '') } } + /** + * @psalm-pure + * @psalm-assert list $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isList($array, $message = '') { - if (!is_array($array) || !$array || array_keys($array) !== range(0, count($array) - 1)) { + if (!\is_array($array) || $array !== \array_values($array)) { static::reportInvalidArgument( $message ?: 'Expected list - non-associative array.' ); } } + /** + * @psalm-pure + * @psalm-assert non-empty-list $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function isNonEmptyList($array, $message = '') + { + static::isList($array, $message); + static::notEmpty($array, $message); + } + + /** + * @psalm-pure + * @psalm-template T + * @psalm-param mixed|array $array + * @psalm-assert array $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ public static function isMap($array, $message = '') { if ( - !is_array($array) || - !$array || - array_keys($array) !== array_filter(array_keys($array), function ($key) { - return is_string($key); - }) + !\is_array($array) || + \array_keys($array) !== \array_filter(\array_keys($array), '\is_string') ) { static::reportInvalidArgument( $message ?: 'Expected map - associative array with string keys.' @@ -1047,9 +1849,35 @@ public static function isMap($array, $message = '') } } + /** + * @psalm-pure + * @psalm-template T + * @psalm-param mixed|array $array + * @psalm-assert array $array + * @psalm-assert !empty $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function isNonEmptyMap($array, $message = '') + { + static::isMap($array, $message); + static::notEmpty($array, $message); + } + + /** + * @psalm-pure + * + * @param string $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function uuid($value, $message = '') { - $value = str_replace(array('urn:', 'uuid:', '{', '}'), '', $value); + $value = \str_replace(array('urn:', 'uuid:', '{', '}'), '', $value); // The nil UUID is special form of UUID that is specified to have all // 128 bits set to zero. @@ -1057,14 +1885,23 @@ public static function uuid($value, $message = '') return; } - if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) { - static::reportInvalidArgument(sprintf( + if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Value %s is not a valid UUID.', static::valueToString($value) )); } } + /** + * @psalm-param class-string $class + * + * @param Closure $expression + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ public static function throws(Closure $expression, $class = 'Exception', $message = '') { static::string($class); @@ -1074,45 +1911,48 @@ public static function throws(Closure $expression, $class = 'Exception', $messag try { $expression(); } catch (Exception $e) { - $actual = get_class($e); + $actual = \get_class($e); if ($e instanceof $class) { return; } } catch (Throwable $e) { - $actual = get_class($e); + $actual = \get_class($e); if ($e instanceof $class) { return; } } - static::reportInvalidArgument($message ?: sprintf( + static::reportInvalidArgument($message ?: \sprintf( 'Expected to throw "%s", got "%s"', $class, $actual )); } + /** + * @throws BadMethodCallException + */ public static function __callStatic($name, $arguments) { - if ('nullOr' === substr($name, 0, 6)) { + if ('nullOr' === \substr($name, 0, 6)) { if (null !== $arguments[0]) { - $method = lcfirst(substr($name, 6)); - call_user_func_array(array('static', $method), $arguments); + $method = \lcfirst(\substr($name, 6)); + \call_user_func_array(array('static', $method), $arguments); } return; } - if ('all' === substr($name, 0, 3)) { + if ('all' === \substr($name, 0, 3)) { static::isIterable($arguments[0]); - $method = lcfirst(substr($name, 3)); + $method = \lcfirst(\substr($name, 3)); $args = $arguments; foreach ($arguments[0] as $entry) { $args[0] = $entry; - call_user_func_array(array('static', $method), $args); + \call_user_func_array(array('static', $method), $args); } return; @@ -1121,6 +1961,11 @@ public static function __callStatic($name, $arguments) throw new BadMethodCallException('No such method: '.$name); } + /** + * @param mixed $value + * + * @return string + */ protected static function valueToString($value) { if (null === $value) { @@ -1135,47 +1980,63 @@ protected static function valueToString($value) return 'false'; } - if (is_array($value)) { + if (\is_array($value)) { return 'array'; } - if (is_object($value)) { - if (method_exists($value, '__toString')) { - return get_class($value).': '.self::valueToString($value->__toString()); + if (\is_object($value)) { + if (\method_exists($value, '__toString')) { + return \get_class($value).': '.self::valueToString($value->__toString()); + } + + if ($value instanceof DateTime || $value instanceof DateTimeImmutable) { + return \get_class($value).': '.self::valueToString($value->format('c')); } - return get_class($value); + return \get_class($value); } - if (is_resource($value)) { + if (\is_resource($value)) { return 'resource'; } - if (is_string($value)) { + if (\is_string($value)) { return '"'.$value.'"'; } return (string) $value; } + /** + * @param mixed $value + * + * @return string + */ protected static function typeToString($value) { - return is_object($value) ? get_class($value) : gettype($value); + return \is_object($value) ? \get_class($value) : \gettype($value); } protected static function strlen($value) { - if (!function_exists('mb_detect_encoding')) { - return strlen($value); + if (!\function_exists('mb_detect_encoding')) { + return \strlen($value); } - if (false === $encoding = mb_detect_encoding($value)) { - return strlen($value); + if (false === $encoding = \mb_detect_encoding($value)) { + return \strlen($value); } - return mb_strwidth($value, $encoding); + return \mb_strlen($value, $encoding); } + /** + * @param string $message + * + * @throws InvalidArgumentException + * + * @psalm-pure this method is not supposed to perform side-effects + */ protected static function reportInvalidArgument($message) { throw new InvalidArgumentException($message); diff --git a/Resources/Private/Php/vendor/webmozart/assert/src/Mixin.php b/Resources/Private/Php/vendor/webmozart/assert/src/Mixin.php new file mode 100644 index 00000000..3ad9b2d0 --- /dev/null +++ b/Resources/Private/Php/vendor/webmozart/assert/src/Mixin.php @@ -0,0 +1,1971 @@ + $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allString($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|non-empty-string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrStringNotEmpty($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allStringNotEmpty($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|int $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrInteger($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allInteger($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|numeric $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIntegerish($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIntegerish($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|float $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrFloat($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allFloat($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|numeric $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNumeric($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNumeric($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|int $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNatural($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNatural($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|bool $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrBoolean($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allBoolean($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|scalar $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrScalar($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allScalar($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|object $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrObject($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allObject($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|resource $value + * + * @param mixed $value + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrResource($value, $type = null, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allResource($value, $type = null, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|callable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsCallable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsCallable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|array $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsArray($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsArray($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|iterable $value + * + * @deprecated use "isIterable" or "isInstanceOf" instead + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsTraversable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @deprecated use "isIterable" or "isInstanceOf" instead + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsTraversable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|array|ArrayAccess $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsArrayAccessible($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsArrayAccessible($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|countable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsCountable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsCountable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsIterable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsIterable($value, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert null|ExpectedType $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsInstanceOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsInstanceOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotInstanceOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotInstanceOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-param array $classes + * + * @param mixed $value + * @param array $classes + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsInstanceOfAny($value, $classes, $message = ''); + + /** + * @psalm-pure + * @psalm-param array $classes + * + * @param mixed $value + * @param array $classes + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsInstanceOfAny($value, $classes, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert null|ExpectedType|class-string $value + * + * @param null|object|string $value + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsAOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert iterable> $value + * + * @param iterable $value + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsAOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template UnexpectedType of object + * @psalm-param class-string $class + * + * @param null|object|string $value + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsNotA($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template UnexpectedType of object + * @psalm-param class-string $class + * + * @param iterable $value + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsNotA($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-param array $classes + * + * @param null|object|string $value + * @param string[] $classes + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsAnyOf($value, $classes, $message = ''); + + /** + * @psalm-pure + * @psalm-param array $classes + * + * @param iterable $value + * @param string[] $classes + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsAnyOf($value, $classes, $message = ''); + + /** + * @psalm-pure + * @psalm-assert empty $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsEmpty($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsEmpty($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotEmpty($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotEmpty($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNull($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotNull($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|true $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrTrue($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allTrue($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|false $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrFalse($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allFalse($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotFalse($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotFalse($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIp($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIp($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIpv4($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIpv4($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIpv6($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIpv6($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrEmail($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allEmail($value, $message = ''); + + /** + * @param null|array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrUniqueValues($values, $message = ''); + + /** + * @param iterable $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allUniqueValues($values, $message = ''); + + /** + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrEq($value, $expect, $message = ''); + + /** + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allEq($value, $expect, $message = ''); + + /** + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotEq($value, $expect, $message = ''); + + /** + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotEq($value, $expect, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrSame($value, $expect, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allSame($value, $expect, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotSame($value, $expect, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $expect + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotSame($value, $expect, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrGreaterThan($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allGreaterThan($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrGreaterThanEq($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allGreaterThanEq($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrLessThan($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allLessThan($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrLessThanEq($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $limit + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allLessThanEq($value, $limit, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $min + * @param mixed $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrRange($value, $min, $max, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param mixed $min + * @param mixed $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allRange($value, $min, $max, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrOneOf($value, $values, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allOneOf($value, $values, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrInArray($value, $values, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param array $values + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allInArray($value, $values, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $subString + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrContains($value, $subString, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $subString + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allContains($value, $subString, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $subString + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotContains($value, $subString, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $subString + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotContains($value, $subString, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotWhitespaceOnly($value, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotWhitespaceOnly($value, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $prefix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrStartsWith($value, $prefix, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $prefix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allStartsWith($value, $prefix, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $prefix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotStartsWith($value, $prefix, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $prefix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotStartsWith($value, $prefix, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrStartsWithLetter($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allStartsWithLetter($value, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $suffix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrEndsWith($value, $suffix, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $suffix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allEndsWith($value, $suffix, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $suffix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotEndsWith($value, $suffix, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $suffix + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotEndsWith($value, $suffix, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $pattern + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrRegex($value, $pattern, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $pattern + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allRegex($value, $pattern, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $pattern + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrNotRegex($value, $pattern, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $pattern + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allNotRegex($value, $pattern, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrUnicodeLetters($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allUnicodeLetters($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrAlpha($value, $message = ''); + + /** + * @psalm-pure + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allAlpha($value, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrDigits($value, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allDigits($value, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrAlnum($value, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allAlnum($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|lowercase-string $value + * + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrLower($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allLower($value, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrUpper($value, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allUpper($value, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param int $length + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrLength($value, $length, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param int $length + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allLength($value, $length, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param int|float $min + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrMinLength($value, $min, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param int|float $min + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allMinLength($value, $min, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrMaxLength($value, $max, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allMaxLength($value, $max, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param int|float $min + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrLengthBetween($value, $min, $max, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param int|float $min + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allLengthBetween($value, $min, $max, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrFileExists($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allFileExists($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrFile($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allFile($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrDirectory($value, $message = ''); + + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allDirectory($value, $message = ''); + + /** + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrReadable($value, $message = ''); + + /** + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allReadable($value, $message = ''); + + /** + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrWritable($value, $message = ''); + + /** + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allWritable($value, $message = ''); + + /** + * @psalm-assert null|class-string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrClassExists($value, $message = ''); + + /** + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allClassExists($value, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert null|class-string|ExpectedType $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrSubclassOf($value, $class, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $class + * @psalm-assert iterable|ExpectedType> $value + * + * @param mixed $value + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allSubclassOf($value, $class, $message = ''); + + /** + * @psalm-assert null|class-string $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrInterfaceExists($value, $message = ''); + + /** + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allInterfaceExists($value, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $interface + * @psalm-assert null|class-string $value + * + * @param mixed $value + * @param mixed $interface + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrImplementsInterface($value, $interface, $message = ''); + + /** + * @psalm-pure + * @psalm-template ExpectedType of object + * @psalm-param class-string $interface + * @psalm-assert iterable> $value + * + * @param mixed $value + * @param mixed $interface + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allImplementsInterface($value, $interface, $message = ''); + + /** + * @psalm-pure + * @psalm-param null|class-string|object $classOrObject + * + * @param null|string|object $classOrObject + * @param mixed $property + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrPropertyExists($classOrObject, $property, $message = ''); + + /** + * @psalm-pure + * @psalm-param iterable $classOrObject + * + * @param iterable $classOrObject + * @param mixed $property + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allPropertyExists($classOrObject, $property, $message = ''); + + /** + * @psalm-pure + * @psalm-param null|class-string|object $classOrObject + * + * @param null|string|object $classOrObject + * @param mixed $property + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrPropertyNotExists($classOrObject, $property, $message = ''); + + /** + * @psalm-pure + * @psalm-param iterable $classOrObject + * + * @param iterable $classOrObject + * @param mixed $property + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allPropertyNotExists($classOrObject, $property, $message = ''); + + /** + * @psalm-pure + * @psalm-param null|class-string|object $classOrObject + * + * @param null|string|object $classOrObject + * @param mixed $method + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrMethodExists($classOrObject, $method, $message = ''); + + /** + * @psalm-pure + * @psalm-param iterable $classOrObject + * + * @param iterable $classOrObject + * @param mixed $method + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allMethodExists($classOrObject, $method, $message = ''); + + /** + * @psalm-pure + * @psalm-param null|class-string|object $classOrObject + * + * @param null|string|object $classOrObject + * @param mixed $method + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrMethodNotExists($classOrObject, $method, $message = ''); + + /** + * @psalm-pure + * @psalm-param iterable $classOrObject + * + * @param iterable $classOrObject + * @param mixed $method + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allMethodNotExists($classOrObject, $method, $message = ''); + + /** + * @psalm-pure + * + * @param null|array $array + * @param string|int $key + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrKeyExists($array, $key, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $array + * @param string|int $key + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allKeyExists($array, $key, $message = ''); + + /** + * @psalm-pure + * + * @param null|array $array + * @param string|int $key + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrKeyNotExists($array, $key, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $array + * @param string|int $key + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allKeyNotExists($array, $key, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|array-key $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrValidArrayKey($value, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allValidArrayKey($value, $message = ''); + + /** + * @param null|Countable|array $array + * @param int $number + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrCount($array, $number, $message = ''); + + /** + * @param iterable $array + * @param int $number + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allCount($array, $number, $message = ''); + + /** + * @param null|Countable|array $array + * @param int|float $min + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrMinCount($array, $min, $message = ''); + + /** + * @param iterable $array + * @param int|float $min + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allMinCount($array, $min, $message = ''); + + /** + * @param null|Countable|array $array + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrMaxCount($array, $max, $message = ''); + + /** + * @param iterable $array + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allMaxCount($array, $max, $message = ''); + + /** + * @param null|Countable|array $array + * @param int|float $min + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrCountBetween($array, $min, $max, $message = ''); + + /** + * @param iterable $array + * @param int|float $min + * @param int|float $max + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allCountBetween($array, $min, $max, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|list $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsList($array, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsList($array, $message = ''); + + /** + * @psalm-pure + * @psalm-assert null|non-empty-list $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsNonEmptyList($array, $message = ''); + + /** + * @psalm-pure + * @psalm-assert iterable $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsNonEmptyList($array, $message = ''); + + /** + * @psalm-pure + * @psalm-template T + * @psalm-param null|mixed|array $array + * @psalm-assert null|array $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsMap($array, $message = ''); + + /** + * @psalm-pure + * @psalm-template T + * @psalm-param iterable> $array + * @psalm-assert iterable> $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsMap($array, $message = ''); + + /** + * @psalm-pure + * @psalm-template T + * @psalm-param null|mixed|array $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrIsNonEmptyMap($array, $message = ''); + + /** + * @psalm-pure + * @psalm-template T + * @psalm-param iterable> $array + * + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allIsNonEmptyMap($array, $message = ''); + + /** + * @psalm-pure + * + * @param null|string $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrUuid($value, $message = ''); + + /** + * @psalm-pure + * + * @param iterable $value + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allUuid($value, $message = ''); + + /** + * @psalm-param class-string $class + * + * @param null|Closure $expression + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function nullOrThrows($expression, $class = 'Exception', $message = ''); + + /** + * @psalm-param class-string $class + * + * @param iterable $expression + * @param string $class + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function allThrows($expression, $class = 'Exception', $message = ''); +} diff --git a/composer.json b/composer.json index f8548288..e3fc73d2 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "source": "https://github.com/oliverklee/ext-phpunit" }, "require": { - "php": "~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0", + "php": "~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0", "typo3/cms-core": "^8.7.9 || ^9.5", "symfony/console": "^3.2 || ^4.0" }, diff --git a/ext_emconf.php b/ext_emconf.php index a8b38510..ca0d1c4a 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -7,7 +7,7 @@ 'category' => 'misc', 'constraints' => [ 'depends' => [ - 'php' => '7.0.0-7.3.99', + 'php' => '7.0.0-7.4.99', 'typo3' => '8.7.0-9.5.99', ], 'conflicts' => [],