diff --git a/includes/composer.json b/includes/composer.json index 99c722c2..09773d2e 100644 --- a/includes/composer.json +++ b/includes/composer.json @@ -1,6 +1,6 @@ { "require": { - "guzzlehttp/guzzle": "6.*", + "guzzlehttp/guzzle": "~6.0", "guzzlehttp/oauth-subscriber": "*", "peekmo/jsonpath": "dev-master", "phpunit/phpunit": "~4.7" diff --git a/includes/composer.lock b/includes/composer.lock index 15e7a014..f1a6e96b 100644 --- a/includes/composer.lock +++ b/includes/composer.lock @@ -4,31 +4,33 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "32dddf452bf1dd21948c4d0219371f23", + "content-hash": "cff618c636ae29e3dae861bcaac87c69", "packages": [ { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { @@ -53,53 +55,55 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2019-10-21T16:45:58+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "6.3.3", + "version": "6.5.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", "shasum": "" }, "require": { + "ext-json": "*", "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", + "guzzlehttp/psr7": "^1.6.1", "php": ">=5.5" }, "require-dev": { "ext-curl": "*", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" + "psr/log": "^1.1" }, "suggest": { + "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.3-dev" + "dev-master": "6.5-dev" } }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\": "src/" - } + }, + "files": [ + "src/functions_include.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -123,7 +127,7 @@ "rest", "web service" ], - "time": "2018-04-22T15:46:56+00:00" + "time": "2019-12-23T11:57:10+00:00" }, { "name": "guzzlehttp/oauth-subscriber", @@ -229,33 +233,37 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.5.2", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "9f83dded91781a01c63574e387eaa769be769115" + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", - "reference": "9f83dded91781a01c63574e387eaa769be769115", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", "shasum": "" }, "require": { "php": ">=5.4.0", "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5" + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" }, "provide": { "psr/http-message-implementation": "1.0" }, "require-dev": { + "ext-zlib": "*", "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5-dev" + "dev-master": "1.6-dev" } }, "autoload": { @@ -292,7 +300,7 @@ "uri", "url" ], - "time": "2018-12-04T20:46:45+00:00" + "time": "2019-07-01T23:21:34+00:00" }, { "name": "peekmo/jsonpath", @@ -339,35 +347,33 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -389,44 +395,42 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/a48807183a4b819072f26e347bbd0b5199a9d15f", + "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -437,44 +441,47 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "time": "2020-02-09T09:16:15+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -487,42 +494,43 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpspec/prophecy", - "version": "1.8.0", + "version": "v1.10.2", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9", + "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9", "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": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -550,7 +558,7 @@ "spy", "stub" ], - "time": "2018-08-05T17:53:17+00:00" + "time": "2020-01-20T15:57:02+00:00" }, { "name": "phpunit/php-code-coverage", @@ -926,6 +934,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2015-10-02T06:51:40+00:00" }, { @@ -980,24 +989,24 @@ }, { "name": "ralouphie/getallheaders", - "version": "2.0.5", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + "reference": "120b605dfeb996808c31b6477290a714d356e822" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", - "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", "shasum": "" }, "require": { - "php": ">=5.3" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "~3.7.0", - "satooshi/php-coveralls": ">=1.0" + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" }, "type": "library", "autoload": { @@ -1016,7 +1025,7 @@ } ], "description": "A polyfill for getallheaders.", - "time": "2016-02-11T07:05:27+00:00" + "time": "2019-03-08T08:55:37+00:00" }, { "name": "sebastian/comparator", @@ -1392,16 +1401,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.10.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", "shasum": "" }, "require": { @@ -1413,7 +1422,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -1429,13 +1438,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -1446,20 +1455,20 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.21", + "version": "v3.4.37", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "554a59a1ccbaac238a89b19c8e551a556fd0e2ea" + "reference": "aa46bc2233097d5212332c907f9911533acfbf80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/554a59a1ccbaac238a89b19c8e551a556fd0e2ea", - "reference": "554a59a1ccbaac238a89b19c8e551a556fd0e2ea", + "url": "https://api.github.com/repos/symfony/yaml/zipball/aa46bc2233097d5212332c907f9911533acfbf80", + "reference": "aa46bc2233097d5212332c907f9911533acfbf80", "shasum": "" }, "require": { @@ -1505,36 +1514,33 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2019-01-01T13:45:19+00:00" + "time": "2020-01-13T08:00:59+00:00" }, { "name": "webmozart/assert", - "version": "1.4.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "vimeo/psalm": "<3.6.0" + }, "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/" @@ -1556,7 +1562,7 @@ "check", "validate" ], - "time": "2018-12-25T11:19:39+00:00" + "time": "2019-11-24T13:36:37+00:00" } ], "packages-dev": [], diff --git a/includes/vendor/autoload.php b/includes/vendor/autoload.php index 1e0e069c..3e3bfa09 100644 --- a/includes/vendor/autoload.php +++ b/includes/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit4ac7f7880417dc8890a136269c15fb3a::getLoader(); +return ComposerAutoloaderInit1ee16845cf9a8b5384b8efd0076da6fe::getLoader(); diff --git a/includes/vendor/composer/autoload_namespaces.php b/includes/vendor/composer/autoload_namespaces.php index 9dae00ac..ed153bb7 100644 --- a/includes/vendor/composer/autoload_namespaces.php +++ b/includes/vendor/composer/autoload_namespaces.php @@ -6,6 +6,5 @@ $baseDir = dirname($vendorDir); return array( - 'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'), 'Peekmo\\JsonPath' => array($vendorDir . '/peekmo/jsonpath/src'), ); diff --git a/includes/vendor/composer/autoload_psr4.php b/includes/vendor/composer/autoload_psr4.php index f63a3755..f10ee2c2 100644 --- a/includes/vendor/composer/autoload_psr4.php +++ b/includes/vendor/composer/autoload_psr4.php @@ -11,6 +11,7 @@ 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), + 'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'), 'GuzzleHttp\\Subscriber\\Oauth\\' => array($vendorDir . '/guzzlehttp/oauth-subscriber/src'), 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), diff --git a/includes/vendor/composer/autoload_real.php b/includes/vendor/composer/autoload_real.php index 853f58c7..d3bce040 100644 --- a/includes/vendor/composer/autoload_real.php +++ b/includes/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit4ac7f7880417dc8890a136269c15fb3a +class ComposerAutoloaderInit1ee16845cf9a8b5384b8efd0076da6fe { private static $loader; @@ -19,15 +19,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit4ac7f7880417dc8890a136269c15fb3a', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit1ee16845cf9a8b5384b8efd0076da6fe', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit4ac7f7880417dc8890a136269c15fb3a', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit1ee16845cf9a8b5384b8efd0076da6fe', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire4ac7f7880417dc8890a136269c15fb3a($fileIdentifier, $file); + composerRequire1ee16845cf9a8b5384b8efd0076da6fe($fileIdentifier, $file); } return $loader; } } -function composerRequire4ac7f7880417dc8890a136269c15fb3a($fileIdentifier, $file) +function composerRequire1ee16845cf9a8b5384b8efd0076da6fe($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/includes/vendor/composer/autoload_static.php b/includes/vendor/composer/autoload_static.php index 50f25e18..c58ef74d 100644 --- a/includes/vendor/composer/autoload_static.php +++ b/includes/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a +class ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe { public static $files = array ( '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', @@ -31,6 +31,7 @@ class ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a 'P' => array ( 'Psr\\Http\\Message\\' => 17, + 'Prophecy\\' => 9, ), 'G' => array ( @@ -68,6 +69,10 @@ class ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a array ( 0 => __DIR__ . '/..' . '/psr/http-message/src', ), + 'Prophecy\\' => + array ( + 0 => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy', + ), 'GuzzleHttp\\Subscriber\\Oauth\\' => array ( 0 => __DIR__ . '/..' . '/guzzlehttp/oauth-subscriber/src', @@ -93,10 +98,6 @@ class ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a public static $prefixesPsr0 = array ( 'P' => array ( - 'Prophecy\\' => - array ( - 0 => __DIR__ . '/..' . '/phpspec/prophecy/src', - ), 'Peekmo\\JsonPath' => array ( 0 => __DIR__ . '/..' . '/peekmo/jsonpath/src', @@ -555,10 +556,10 @@ class ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a::$prefixesPsr0; - $loader->classMap = ComposerStaticInit4ac7f7880417dc8890a136269c15fb3a::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe::$prefixesPsr0; + $loader->classMap = ComposerStaticInit1ee16845cf9a8b5384b8efd0076da6fe::$classMap; }, null, ClassLoader::class); } diff --git a/includes/vendor/composer/installed.json b/includes/vendor/composer/installed.json index 358808e2..156fae1b 100644 --- a/includes/vendor/composer/installed.json +++ b/includes/vendor/composer/installed.json @@ -1,30 +1,32 @@ [ { "name": "doctrine/instantiator", - "version": "1.1.0", - "version_normalized": "1.1.0.0", + "version": "1.3.0", + "version_normalized": "1.3.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, - "time": "2017-07-22T11:58:36+00:00", + "time": "2019-10-21T16:45:58+00:00", "type": "library", "extra": { "branch-alias": { @@ -49,7 +51,7 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" @@ -57,47 +59,49 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.3.3", - "version_normalized": "6.3.3.0", + "version": "6.5.2", + "version_normalized": "6.5.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", "shasum": "" }, "require": { + "ext-json": "*", "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", + "guzzlehttp/psr7": "^1.6.1", "php": ">=5.5" }, "require-dev": { "ext-curl": "*", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" + "psr/log": "^1.1" }, "suggest": { + "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, - "time": "2018-04-22T15:46:56+00:00", + "time": "2019-12-23T11:57:10+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "6.3-dev" + "dev-master": "6.5-dev" } }, "installation-source": "dist", "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\": "src/" - } + }, + "files": [ + "src/functions_include.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -230,35 +234,39 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.5.2", - "version_normalized": "1.5.2.0", + "version": "1.6.1", + "version_normalized": "1.6.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "9f83dded91781a01c63574e387eaa769be769115" + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", - "reference": "9f83dded91781a01c63574e387eaa769be769115", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", "shasum": "" }, "require": { "php": ">=5.4.0", "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5" + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" }, "provide": { "psr/http-message-implementation": "1.0" }, "require-dev": { + "ext-zlib": "*", "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" }, - "time": "2018-12-04T20:46:45+00:00", + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "time": "2019-07-01T23:21:34+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5-dev" + "dev-master": "1.6-dev" } }, "installation-source": "dist", @@ -344,38 +352,36 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", - "version_normalized": "1.0.1.0", + "version": "2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, - "time": "2017-09-11T18:02:19+00:00", + "time": "2018-08-07T13:53:10+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "installation-source": "dist", "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -400,43 +406,41 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", - "version_normalized": "4.3.0.0", + "version": "5.0.0", + "version_normalized": "5.0.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/a48807183a4b819072f26e347bbd0b5199a9d15f", + "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, - "time": "2017-11-30T07:14:17+00:00", + "time": "2020-02-09T09:16:15+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "installation-source": "dist", "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -447,46 +451,49 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock." }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", - "version_normalized": "0.4.0.0", + "version": "1.0.1", + "version_normalized": "1.0.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, - "time": "2017-07-14T14:27:02+00:00", + "time": "2019-08-22T18:11:29+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "installation-source": "dist", "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -498,45 +505,46 @@ "name": "Mike van Riel", "email": "me@mikevanriel.com" } - ] + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names" }, { "name": "phpspec/prophecy", - "version": "1.8.0", - "version_normalized": "1.8.0.0", + "version": "v1.10.2", + "version_normalized": "1.10.2.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9", + "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9", "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": "2018-08-05T17:53:17+00:00", + "time": "2020-01-20T15:57:02+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -953,7 +961,8 @@ "keywords": [ "mock", "xunit" - ] + ], + "abandoned": true }, { "name": "psr/http-message", @@ -1009,27 +1018,27 @@ }, { "name": "ralouphie/getallheaders", - "version": "2.0.5", - "version_normalized": "2.0.5.0", + "version": "3.0.3", + "version_normalized": "3.0.3.0", "source": { "type": "git", "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + "reference": "120b605dfeb996808c31b6477290a714d356e822" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", - "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", "shasum": "" }, "require": { - "php": ">=5.3" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "~3.7.0", - "satooshi/php-coveralls": ">=1.0" + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" }, - "time": "2016-02-11T07:05:27+00:00", + "time": "2019-03-08T08:55:37+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1437,17 +1446,17 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.10.0", - "version_normalized": "1.10.0.0", + "version": "v1.13.1", + "version_normalized": "1.13.1.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", "shasum": "" }, "require": { @@ -1456,11 +1465,11 @@ "suggest": { "ext-ctype": "For best performance" }, - "time": "2018-08-06T14:22:27+00:00", + "time": "2019-11-27T13:56:44+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.13-dev" } }, "installation-source": "dist", @@ -1477,13 +1486,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -1497,17 +1506,17 @@ }, { "name": "symfony/yaml", - "version": "v3.4.21", - "version_normalized": "3.4.21.0", + "version": "v3.4.37", + "version_normalized": "3.4.37.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "554a59a1ccbaac238a89b19c8e551a556fd0e2ea" + "reference": "aa46bc2233097d5212332c907f9911533acfbf80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/554a59a1ccbaac238a89b19c8e551a556fd0e2ea", - "reference": "554a59a1ccbaac238a89b19c8e551a556fd0e2ea", + "url": "https://api.github.com/repos/symfony/yaml/zipball/aa46bc2233097d5212332c907f9911533acfbf80", + "reference": "aa46bc2233097d5212332c907f9911533acfbf80", "shasum": "" }, "require": { @@ -1523,7 +1532,7 @@ "suggest": { "symfony/console": "For validating YAML files using the lint command" }, - "time": "2019-01-01T13:45:19+00:00", + "time": "2020-01-13T08:00:59+00:00", "type": "library", "extra": { "branch-alias": { @@ -1558,34 +1567,31 @@ }, { "name": "webmozart/assert", - "version": "1.4.0", - "version_normalized": "1.4.0.0", + "version": "1.6.0", + "version_normalized": "1.6.0.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "vimeo/psalm": "<3.6.0" + }, "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": "2019-11-24T13:36:37+00:00", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "installation-source": "dist", "autoload": { "psr-4": { diff --git a/includes/vendor/doctrine/instantiator/.doctrine-project.json b/includes/vendor/doctrine/instantiator/.doctrine-project.json new file mode 100644 index 00000000..4fe86ee8 --- /dev/null +++ b/includes/vendor/doctrine/instantiator/.doctrine-project.json @@ -0,0 +1,26 @@ +{ + "active": true, + "name": "Instantiator", + "slug": "instantiator", + "docsSlug": "doctrine-instantiator", + "codePath": "/src", + "versions": [ + { + "name": "1.1", + "branchName": "master", + "slug": "latest", + "aliases": [ + "current", + "stable" + ], + "maintained": true, + "current": true + }, + { + "name": "1.0", + "branchName": "1.0.x", + "slug": "1.0" + } + ] +} + diff --git a/includes/vendor/doctrine/instantiator/.github/FUNDING.yml b/includes/vendor/doctrine/instantiator/.github/FUNDING.yml new file mode 100644 index 00000000..9a35064f --- /dev/null +++ b/includes/vendor/doctrine/instantiator/.github/FUNDING.yml @@ -0,0 +1,3 @@ +patreon: phpdoctrine +tidelift: packagist/doctrine%2Finstantiator +custom: https://www.doctrine-project.org/sponsorship.html diff --git a/includes/vendor/doctrine/instantiator/CONTRIBUTING.md b/includes/vendor/doctrine/instantiator/CONTRIBUTING.md index 75b84b2a..c1a2c42e 100644 --- a/includes/vendor/doctrine/instantiator/CONTRIBUTING.md +++ b/includes/vendor/doctrine/instantiator/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing - * Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) + * Follow the [Doctrine Coding Standard](https://github.com/doctrine/coding-standard) * The project will follow strict [object calisthenics](http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php) * Any contribution must provide tests for additional introduced conditions * Any un-confirmed issue needs a failing test case before being accepted diff --git a/includes/vendor/doctrine/instantiator/README.md b/includes/vendor/doctrine/instantiator/README.md index b66064bf..eff5a0ca 100644 --- a/includes/vendor/doctrine/instantiator/README.md +++ b/includes/vendor/doctrine/instantiator/README.md @@ -6,7 +6,6 @@ This library provides a way of avoiding usage of constructors when instantiating [![Code Coverage](https://scrutinizer-ci.com/g/doctrine/instantiator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/doctrine/instantiator/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/doctrine/instantiator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/doctrine/instantiator/?branch=master) [![Dependency Status](https://www.versioneye.com/package/php--doctrine--instantiator/badge.svg)](https://www.versioneye.com/package/php--doctrine--instantiator) -[![HHVM Status](http://hhvm.h4cc.de/badge/doctrine/instantiator.png)](http://hhvm.h4cc.de/package/doctrine/instantiator) [![Latest Stable Version](https://poser.pugx.org/doctrine/instantiator/v/stable.png)](https://packagist.org/packages/doctrine/instantiator) [![Latest Unstable Version](https://poser.pugx.org/doctrine/instantiator/v/unstable.png)](https://packagist.org/packages/doctrine/instantiator) diff --git a/includes/vendor/doctrine/instantiator/composer.json b/includes/vendor/doctrine/instantiator/composer.json index 403ee8e6..9002a91a 100644 --- a/includes/vendor/doctrine/instantiator/composer.json +++ b/includes/vendor/doctrine/instantiator/composer.json @@ -3,7 +3,7 @@ "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", "type": "library", "license": "MIT", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "instantiate", "constructor" @@ -21,9 +21,11 @@ "require-dev": { "ext-phar": "*", "ext-pdo": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2", - "athletic/athletic": "~0.1.8" + "doctrine/coding-standard": "^6.0", + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "autoload": { "psr-4": { diff --git a/includes/vendor/doctrine/instantiator/docs/en/index.rst b/includes/vendor/doctrine/instantiator/docs/en/index.rst new file mode 100644 index 00000000..0c85da0b --- /dev/null +++ b/includes/vendor/doctrine/instantiator/docs/en/index.rst @@ -0,0 +1,68 @@ +Introduction +============ + +This library provides a way of avoiding usage of constructors when instantiating PHP classes. + +Installation +============ + +The suggested installation method is via `composer`_: + +.. code-block:: console + + $ composer require doctrine/instantiator + +Usage +===== + +The instantiator is able to create new instances of any class without +using the constructor or any API of the class itself: + +.. code-block:: php + + instantiate(User::class); + +Contributing +============ + +- Follow the `Doctrine Coding Standard`_ +- The project will follow strict `object calisthenics`_ +- Any contribution must provide tests for additional introduced + conditions +- Any un-confirmed issue needs a failing test case before being + accepted +- Pull requests must be sent from a new hotfix/feature branch, not from + ``master``. + +Testing +======= + +The PHPUnit version to be used is the one installed as a dev- dependency +via composer: + +.. code-block:: console + + $ ./vendor/bin/phpunit + +Accepted coverage for new contributions is 80%. Any contribution not +satisfying this requirement won’t be merged. + +Credits +======= + +This library was migrated from `ocramius/instantiator`_, which has been +donated to the doctrine organization, and which is now deprecated in +favour of this package. + +.. _composer: https://getcomposer.org/ +.. _CONTRIBUTING.md: CONTRIBUTING.md +.. _ocramius/instantiator: https://github.com/Ocramius/Instantiator +.. _Doctrine Coding Standard: https://github.com/doctrine/coding-standard +.. _object calisthenics: http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php diff --git a/includes/vendor/doctrine/instantiator/docs/en/sidebar.rst b/includes/vendor/doctrine/instantiator/docs/en/sidebar.rst new file mode 100644 index 00000000..0c364791 --- /dev/null +++ b/includes/vendor/doctrine/instantiator/docs/en/sidebar.rst @@ -0,0 +1,4 @@ +.. toctree:: + :depth: 3 + + index diff --git a/includes/vendor/doctrine/instantiator/phpbench.json b/includes/vendor/doctrine/instantiator/phpbench.json new file mode 100644 index 00000000..fce5dd60 --- /dev/null +++ b/includes/vendor/doctrine/instantiator/phpbench.json @@ -0,0 +1,4 @@ +{ + "bootstrap": "vendor/autoload.php", + "path": "tests/DoctrineTest/InstantiatorPerformance" +} diff --git a/includes/vendor/doctrine/instantiator/phpcs.xml.dist b/includes/vendor/doctrine/instantiator/phpcs.xml.dist new file mode 100644 index 00000000..1fcac4ab --- /dev/null +++ b/includes/vendor/doctrine/instantiator/phpcs.xml.dist @@ -0,0 +1,35 @@ + + + + + + + + + + + + src + tests + + + + + + + + + + tests/DoctrineTest/InstantiatorTestAsset/AbstractClassAsset.php + + + + src/Doctrine/Instantiator/Exception/UnexpectedValueException.php + src/Doctrine/Instantiator/Exception/InvalidArgumentException.php + + + + src/Doctrine/Instantiator/Exception/ExceptionInterface.php + src/Doctrine/Instantiator/InstantiatorInterface.php + + diff --git a/includes/vendor/doctrine/instantiator/phpstan.neon.dist b/includes/vendor/doctrine/instantiator/phpstan.neon.dist new file mode 100644 index 00000000..ecc38eff --- /dev/null +++ b/includes/vendor/doctrine/instantiator/phpstan.neon.dist @@ -0,0 +1,19 @@ +includes: + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-phpunit/rules.neon + +parameters: + level: max + paths: + - src + - tests + + ignoreErrors: + - + message: '#::__construct\(\) does not call parent constructor from#' + path: '*/tests/DoctrineTest/InstantiatorTestAsset/*.php' + + # dynamic properties confuse static analysis + - + message: '#Access to an undefined property object::\$foo\.#' + path: '*/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php' diff --git a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/ExceptionInterface.php b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/ExceptionInterface.php index 3065375a..e6a5195f 100644 --- a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/ExceptionInterface.php +++ b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/ExceptionInterface.php @@ -1,29 +1,12 @@ . - */ namespace Doctrine\Instantiator\Exception; +use Throwable; + /** * Base exception marker interface for the instantiator component - * - * @author Marco Pivetta */ -interface ExceptionInterface +interface ExceptionInterface extends Throwable { } diff --git a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/InvalidArgumentException.php b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/InvalidArgumentException.php index cb57aa86..9188f0ba 100644 --- a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/InvalidArgumentException.php +++ b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/InvalidArgumentException.php @@ -1,31 +1,16 @@ . - */ namespace Doctrine\Instantiator\Exception; use InvalidArgumentException as BaseInvalidArgumentException; use ReflectionClass; +use const PHP_VERSION_ID; +use function interface_exists; +use function sprintf; +use function trait_exists; /** * Exception for invalid arguments provided to the instantiator - * - * @author Marco Pivetta */ class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface { diff --git a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/UnexpectedValueException.php b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/UnexpectedValueException.php index 2b704b92..d946731b 100644 --- a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/UnexpectedValueException.php +++ b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/UnexpectedValueException.php @@ -1,32 +1,14 @@ . - */ namespace Doctrine\Instantiator\Exception; use Exception; use ReflectionClass; use UnexpectedValueException as BaseUnexpectedValueException; +use function sprintf; /** * Exception for given parameters causing invalid/unexpected state on instantiation - * - * @author Marco Pivetta */ class UnexpectedValueException extends BaseUnexpectedValueException implements ExceptionInterface { diff --git a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php index 69fe65da..9c678624 100644 --- a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php +++ b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php @@ -1,33 +1,24 @@ . - */ namespace Doctrine\Instantiator; +use ArrayIterator; use Doctrine\Instantiator\Exception\InvalidArgumentException; use Doctrine\Instantiator\Exception\UnexpectedValueException; use Exception; use ReflectionClass; +use ReflectionException; +use Serializable; +use function class_exists; +use function is_subclass_of; +use function restore_error_handler; +use function set_error_handler; +use function sprintf; +use function strlen; +use function unserialize; /** * {@inheritDoc} - * - * @author Marco Pivetta */ final class Instantiator implements InstantiatorInterface { @@ -36,16 +27,20 @@ final class Instantiator implements InstantiatorInterface * the method {@see \Serializable::unserialize()} when dealing with classes implementing * the {@see \Serializable} interface. */ - const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C'; - const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O'; + public const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C'; + public const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O'; /** - * @var \callable[] used to instantiate specific classes, indexed by class name + * Used to instantiate specific classes, indexed by class name. + * + * @var callable[] */ private static $cachedInstantiators = []; /** - * @var object[] of objects that can directly be cloned, indexed by class name + * Array of objects that can directly be cloned, indexed by class name. + * + * @var object[] */ private static $cachedCloneables = []; @@ -90,7 +85,7 @@ private function buildAndCacheFromFactory(string $className) * * @throws InvalidArgumentException * @throws UnexpectedValueException - * @throws \ReflectionException + * @throws ReflectionException */ private function buildFactory(string $className) : callable { @@ -102,27 +97,23 @@ private function buildFactory(string $className) : callable $serializedString = sprintf( '%s:%d:"%s":0:{}', - self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER, + is_subclass_of($className, Serializable::class) ? self::SERIALIZATION_FORMAT_USE_UNSERIALIZER : self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER, strlen($className), $className ); $this->checkIfUnSerializationIsSupported($reflectionClass, $serializedString); - return function () use ($serializedString) { + return static function () use ($serializedString) { return unserialize($serializedString); }; } /** - * @param string $className - * - * @return ReflectionClass - * * @throws InvalidArgumentException - * @throws \ReflectionException + * @throws ReflectionException */ - private function getReflectionClass($className) : ReflectionClass + private function getReflectionClass(string $className) : ReflectionClass { if (! class_exists($className)) { throw InvalidArgumentException::fromNonExistingClass($className); @@ -138,16 +129,11 @@ private function getReflectionClass($className) : ReflectionClass } /** - * @param ReflectionClass $reflectionClass - * @param string $serializedString - * * @throws UnexpectedValueException - * - * @return void */ - private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionClass, $serializedString) : void + private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionClass, string $serializedString) : void { - set_error_handler(function ($code, $message, $file, $line) use ($reflectionClass, & $error) : void { + set_error_handler(static function (int $code, string $message, string $file, int $line) use ($reflectionClass, &$error) : bool { $error = UnexpectedValueException::fromUncleanUnSerialization( $reflectionClass, $message, @@ -155,11 +141,15 @@ private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionCl $file, $line ); - }); - $this->attemptInstantiationViaUnSerialization($reflectionClass, $serializedString); + return true; + }); - restore_error_handler(); + try { + $this->attemptInstantiationViaUnSerialization($reflectionClass, $serializedString); + } finally { + restore_error_handler(); + } if ($error) { throw $error; @@ -167,20 +157,13 @@ private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionCl } /** - * @param ReflectionClass $reflectionClass - * @param string $serializedString - * * @throws UnexpectedValueException - * - * @return void */ - private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, $serializedString) : void + private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, string $serializedString) : void { try { unserialize($serializedString); } catch (Exception $exception) { - restore_error_handler(); - throw UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $exception); } } @@ -199,7 +182,9 @@ private function hasInternalAncestors(ReflectionClass $reflectionClass) : bool if ($reflectionClass->isInternal()) { return true; } - } while ($reflectionClass = $reflectionClass->getParentClass()); + + $reflectionClass = $reflectionClass->getParentClass(); + } while ($reflectionClass); return false; } @@ -211,6 +196,8 @@ private function hasInternalAncestors(ReflectionClass $reflectionClass) : bool */ private function isSafeToClone(ReflectionClass $reflection) : bool { - return $reflection->isCloneable() && ! $reflection->hasMethod('__clone'); + return $reflection->isCloneable() + && ! $reflection->hasMethod('__clone') + && ! $reflection->isSubclassOf(ArrayIterator::class); } } diff --git a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/InstantiatorInterface.php b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/InstantiatorInterface.php index b665bea8..95299f4a 100644 --- a/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/InstantiatorInterface.php +++ b/includes/vendor/doctrine/instantiator/src/Doctrine/Instantiator/InstantiatorInterface.php @@ -1,28 +1,11 @@ . - */ namespace Doctrine\Instantiator; +use Doctrine\Instantiator\Exception\ExceptionInterface; + /** * Instantiator provides utility methods to build objects without invoking their constructors - * - * @author Marco Pivetta */ interface InstantiatorInterface { @@ -31,7 +14,7 @@ interface InstantiatorInterface * * @return object * - * @throws \Doctrine\Instantiator\Exception\ExceptionInterface + * @throws ExceptionInterface */ public function instantiate($className); } diff --git a/includes/vendor/guzzlehttp/guzzle/.php_cs b/includes/vendor/guzzlehttp/guzzle/.php_cs new file mode 100644 index 00000000..2dd5036c --- /dev/null +++ b/includes/vendor/guzzlehttp/guzzle/.php_cs @@ -0,0 +1,23 @@ +setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'declare_strict_types' => false, + 'concat_space' => ['spacing'=>'one'], + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'ordered_imports' => true, + // 'phpdoc_align' => ['align'=>'vertical'], + // 'native_function_invocation' => true, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__.'/src') + ->in(__DIR__.'/tests') + ->name('*.php') + ) +; + +return $config; diff --git a/includes/vendor/guzzlehttp/guzzle/CHANGELOG.md b/includes/vendor/guzzlehttp/guzzle/CHANGELOG.md index 17badd75..a2b61e71 100644 --- a/includes/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ b/includes/vendor/guzzlehttp/guzzle/CHANGELOG.md @@ -1,5 +1,40 @@ # Change Log +## 6.5.2 - 2019-12-23 + +* idn_to_ascii() fix for old PHP versions [#2489](https://github.com/guzzle/guzzle/pull/2489) + +## 6.5.1 - 2019-12-21 + +* Better defaults for PHP installations with old ICU lib [#2454](https://github.com/guzzle/guzzle/pull/2454) +* IDN support for redirects [#2424](https://github.com/guzzle/guzzle/pull/2424) + +## 6.5.0 - 2019-12-07 + +* Improvement: Added support for reset internal queue in MockHandler. [#2143](https://github.com/guzzle/guzzle/pull/2143) +* Improvement: Added support to pass arbitrary options to `curl_multi_init`. [#2287](https://github.com/guzzle/guzzle/pull/2287) +* Fix: Gracefully handle passing `null` to the `header` option. [#2132](https://github.com/guzzle/guzzle/pull/2132) +* Fix: `RetryMiddleware` did not do exponential delay between retires due unit mismatch. [#2132](https://github.com/guzzle/guzzle/pull/2132) +* Fix: Prevent undefined offset when using array for ssl_key options. [#2348](https://github.com/guzzle/guzzle/pull/2348) +* Deprecated `ClientInterface::VERSION` + +## 6.4.1 - 2019-10-23 + +* No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that +* Added `parent::__construct()` to `FileCookieJar` and `SessionCookieJar` + +## 6.4.0 - 2019-10-23 + +* Improvement: Improved error messages when using curl < 7.21.2 [#2108](https://github.com/guzzle/guzzle/pull/2108) +* Fix: Test if response is readable before returning a summary in `RequestException::getResponseBodySummary()` [#2081](https://github.com/guzzle/guzzle/pull/2081) +* Fix: Add support for GUZZLE_CURL_SELECT_TIMEOUT environment variable [#2161](https://github.com/guzzle/guzzle/pull/2161) +* Improvement: Added `GuzzleHttp\Exception\InvalidArgumentException` [#2163](https://github.com/guzzle/guzzle/pull/2163) +* Improvement: Added `GuzzleHttp\_current_time()` to use `hrtime()` if that function exists. [#2242](https://github.com/guzzle/guzzle/pull/2242) +* Improvement: Added curl's `appconnect_time` in `TransferStats` [#2284](https://github.com/guzzle/guzzle/pull/2284) +* Improvement: Make GuzzleException extend Throwable wherever it's available [#2273](https://github.com/guzzle/guzzle/pull/2273) +* Fix: Prevent concurrent writes to file when saving `CookieJar` [#2335](https://github.com/guzzle/guzzle/pull/2335) +* Improvement: Update `MockHandler` so we can test transfer time [#2362](https://github.com/guzzle/guzzle/pull/2362) + ## 6.3.3 - 2018-04-22 * Fix: Default headers when decode_content is specified diff --git a/includes/vendor/guzzlehttp/guzzle/Dockerfile b/includes/vendor/guzzlehttp/guzzle/Dockerfile new file mode 100644 index 00000000..f6a09523 --- /dev/null +++ b/includes/vendor/guzzlehttp/guzzle/Dockerfile @@ -0,0 +1,18 @@ +FROM composer:latest as setup + +RUN mkdir /guzzle + +WORKDIR /guzzle + +RUN set -xe \ + && composer init --name=guzzlehttp/test --description="Simple project for testing Guzzle scripts" --author="Márk Sági-Kazár " --no-interaction \ + && composer require guzzlehttp/guzzle + + +FROM php:7.3 + +RUN mkdir /guzzle + +WORKDIR /guzzle + +COPY --from=setup /guzzle /guzzle diff --git a/includes/vendor/guzzlehttp/guzzle/README.md b/includes/vendor/guzzlehttp/guzzle/README.md index bcd18b8e..5fdb6c5f 100644 --- a/includes/vendor/guzzlehttp/guzzle/README.md +++ b/includes/vendor/guzzlehttp/guzzle/README.md @@ -21,19 +21,18 @@ trivial to integrate with web services. ```php $client = new \GuzzleHttp\Client(); -$res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); -echo $res->getStatusCode(); -// 200 -echo $res->getHeaderLine('content-type'); -// 'application/json; charset=utf8' -echo $res->getBody(); -// '{"id": 1420053, "name": "guzzle", ...}' - -// Send an asynchronous request. +$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); + +echo $response->getStatusCode(); # 200 +echo $response->getHeaderLine('content-type'); # 'application/json; charset=utf8' +echo $response->getBody(); # '{"id": 1420053, "name": "guzzle", ...}' + +# Send an asynchronous request. $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); $promise = $client->sendAsync($request)->then(function ($response) { echo 'I completed! ' . $response->getBody(); }); + $promise->wait(); ``` @@ -57,7 +56,7 @@ curl -sS https://getcomposer.org/installer | php Next, run the Composer command to install the latest stable version of Guzzle: ```bash -php composer.phar require guzzlehttp/guzzle +composer require guzzlehttp/guzzle ``` After installing, you need to require Composer's autoloader: @@ -69,7 +68,7 @@ require 'vendor/autoload.php'; You can then later update Guzzle using composer: ```bash -composer.phar update +composer update ``` @@ -79,13 +78,13 @@ composer.phar update |---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------| | 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 | | 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 | -| 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | +| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | | 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 | [guzzle-3-repo]: https://github.com/guzzle/guzzle3 [guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x [guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3 [guzzle-6-repo]: https://github.com/guzzle/guzzle -[guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/ +[guzzle-3-docs]: http://guzzle3.readthedocs.org [guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/ [guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/ diff --git a/includes/vendor/guzzlehttp/guzzle/composer.json b/includes/vendor/guzzlehttp/guzzle/composer.json index 1f328e30..bbf0ff20 100644 --- a/includes/vendor/guzzlehttp/guzzle/composer.json +++ b/includes/vendor/guzzlehttp/guzzle/composer.json @@ -2,7 +2,15 @@ "name": "guzzlehttp/guzzle", "type": "library", "description": "Guzzle is a PHP HTTP client library", - "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"], + "keywords": [ + "framework", + "http", + "rest", + "web service", + "curl", + "client", + "HTTP client" + ], "homepage": "http://guzzlephp.org/", "license": "MIT", "authors": [ @@ -14,31 +22,38 @@ ], "require": { "php": ">=5.5", - "guzzlehttp/psr7": "^1.4", - "guzzlehttp/promises": "^1.0" + "ext-json": "*", + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.6.1" }, "require-dev": { "ext-curl": "*", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" + "psr/log": "^1.1" + }, + "suggest": { + "psr/log": "Required for using the Log middleware", + "ext-intl": "Required for Internationalized Domain Name (IDN) support" + }, + "config": { + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "6.5-dev" + } }, "autoload": { - "files": ["src/functions_include.php"], "psr-4": { "GuzzleHttp\\": "src/" - } + }, + "files": [ + "src/functions_include.php" + ] }, "autoload-dev": { "psr-4": { "GuzzleHttp\\Tests\\": "tests/" } - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "extra": { - "branch-alias": { - "dev-master": "6.3-dev" - } } } diff --git a/includes/vendor/guzzlehttp/guzzle/src/Client.php b/includes/vendor/guzzlehttp/guzzle/src/Client.php index 80417918..f2bf2044 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Client.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Client.php @@ -2,11 +2,12 @@ namespace GuzzleHttp; use GuzzleHttp\Cookie\CookieJar; +use GuzzleHttp\Exception\InvalidArgumentException; use GuzzleHttp\Promise; use GuzzleHttp\Psr7; -use Psr\Http\Message\UriInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\UriInterface; /** * @method ResponseInterface get(string|UriInterface $uri, array $options = []) @@ -75,6 +76,12 @@ public function __construct(array $config = []) $this->configureDefaults($config); } + /** + * @param string $method + * @param array $args + * + * @return Promise\PromiseInterface + */ public function __call($method, $args) { if (count($args) < 1) { @@ -89,6 +96,14 @@ public function __call($method, $args) : $this->request($method, $uri, $opts); } + /** + * Asynchronously send an HTTP request. + * + * @param array $options Request options to apply to the given + * request and to the transfer. See \GuzzleHttp\RequestOptions. + * + * @return Promise\PromiseInterface + */ public function sendAsync(RequestInterface $request, array $options = []) { // Merge the base URI into the request URI if needed. @@ -100,12 +115,35 @@ public function sendAsync(RequestInterface $request, array $options = []) ); } + /** + * Send an HTTP request. + * + * @param array $options Request options to apply to the given + * request and to the transfer. See \GuzzleHttp\RequestOptions. + * + * @return ResponseInterface + * @throws GuzzleException + */ public function send(RequestInterface $request, array $options = []) { $options[RequestOptions::SYNCHRONOUS] = true; return $this->sendAsync($request, $options)->wait(); } + /** + * Create and send an asynchronous HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string $method HTTP method + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. + * + * @return Promise\PromiseInterface + */ public function requestAsync($method, $uri = '', array $options = []) { $options = $this->prepareDefaults($options); @@ -125,12 +163,37 @@ public function requestAsync($method, $uri = '', array $options = []) return $this->transfer($request, $options); } + /** + * Create and send an HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string $method HTTP method. + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. + * + * @return ResponseInterface + * @throws GuzzleException + */ public function request($method, $uri = '', array $options = []) { $options[RequestOptions::SYNCHRONOUS] = true; return $this->requestAsync($method, $uri, $options)->wait(); } + /** + * Get a client configuration option. + * + * These options include default request options of the client, a "handler" + * (if utilized by the concrete client), and a "base_uri" if utilized by + * the concrete client. + * + * @param string|null $option The config option to retrieve. + * + * @return mixed + */ public function getConfig($option = null) { return $option === null @@ -138,6 +201,11 @@ public function getConfig($option = null) : (isset($this->config[$option]) ? $this->config[$option] : null); } + /** + * @param string|null $uri + * + * @return UriInterface + */ private function buildUri($uri, array $config) { // for BC we accept null which would otherwise fail in uri_for @@ -147,6 +215,11 @@ private function buildUri($uri, array $config) $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri); } + if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) { + $idnOptions = ($config['idn_conversion'] === true) ? IDNA_DEFAULT : $config['idn_conversion']; + $uri = _idn_uri_convert($uri, $idnOptions); + } + return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri; } @@ -154,6 +227,7 @@ private function buildUri($uri, array $config) * Configures the default options for a client. * * @param array $config + * @return void */ private function configureDefaults(array $config) { @@ -165,12 +239,22 @@ private function configureDefaults(array $config) 'cookies' => false ]; + // idn_to_ascii() is a part of ext-intl and might be not available + $defaults['idn_conversion'] = function_exists('idn_to_ascii') + // Old ICU versions don't have this constant, so we are basically stuck (see https://github.com/guzzle/guzzle/pull/2424 + // and https://github.com/guzzle/guzzle/issues/2448 for details) + && ( + defined('INTL_IDNA_VARIANT_UTS46') + || + PHP_VERSION_ID < 70200 + ); + // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. // We can only trust the HTTP_PROXY environment variable in a CLI // process due to the fact that PHP has no reliable mechanism to // get environment variables that start with "HTTP_". - if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) { + if (php_sapi_name() === 'cli' && getenv('HTTP_PROXY')) { $defaults['proxy']['http'] = getenv('HTTP_PROXY'); } @@ -210,7 +294,7 @@ private function configureDefaults(array $config) * * @return array */ - private function prepareDefaults($options) + private function prepareDefaults(array $options) { $defaults = $this->config; @@ -225,7 +309,7 @@ private function prepareDefaults($options) if (array_key_exists('headers', $options)) { // Allows default headers to be unset. if ($options['headers'] === null) { - $defaults['_conditional'] = null; + $defaults['_conditional'] = []; unset($options['headers']); } elseif (!is_array($options['headers'])) { throw new \InvalidArgumentException('headers must be an array'); @@ -251,8 +335,7 @@ private function prepareDefaults($options) * The URI of the request is not modified and the request options are used * as-is without merging in default options. * - * @param RequestInterface $request - * @param array $options + * @param array $options See \GuzzleHttp\RequestOptions. * * @return Promise\PromiseInterface */ @@ -271,6 +354,7 @@ private function transfer(RequestInterface $request, array $options) } $request = $this->applyOptions($request, $options); + /** @var HandlerStack $handler */ $handler = $options['handler']; try { @@ -411,6 +495,11 @@ private function applyOptions(RequestInterface $request, array &$options) return $request; } + /** + * Throw Exception with pre-set message. + * @return void + * @throws InvalidArgumentException Invalid body. + */ private function invalidBody() { throw new \InvalidArgumentException('Passing in the "body" request ' diff --git a/includes/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/includes/vendor/guzzlehttp/guzzle/src/ClientInterface.php index 2dbcffa4..0c8d42a1 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ b/includes/vendor/guzzlehttp/guzzle/src/ClientInterface.php @@ -1,8 +1,8 @@ cookies as $cookie) { @@ -103,6 +103,8 @@ public function getCookieByName($name) return $cookie; } } + + return null; } public function toArray() @@ -120,7 +122,7 @@ public function clear($domain = null, $path = null, $name = null) } elseif (!$path) { $this->cookies = array_filter( $this->cookies, - function (SetCookie $cookie) use ($path, $domain) { + function (SetCookie $cookie) use ($domain) { return !$cookie->matchesDomain($domain); } ); diff --git a/includes/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/includes/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php index 2cf298a8..6ee11885 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php @@ -58,9 +58,9 @@ public function setCookie(SetCookie $cookie); * arguments, then the cookie with the specified name, path and domain is * removed. * - * @param string $domain Clears cookies matching a domain - * @param string $path Clears cookies matching a domain and path - * @param string $name Clears cookies matching a domain, path, and name + * @param string|null $domain Clears cookies matching a domain + * @param string|null $path Clears cookies matching a domain and path + * @param string|null $name Clears cookies matching a domain, path, and name * * @return CookieJarInterface */ diff --git a/includes/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php b/includes/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php index 9887c1d5..3fb8600e 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php @@ -23,6 +23,7 @@ class FileCookieJar extends CookieJar */ public function __construct($cookieFile, $storeSessionCookies = false) { + parent::__construct(); $this->filename = $cookieFile; $this->storeSessionCookies = $storeSessionCookies; @@ -56,7 +57,7 @@ public function save($filename) } $jsonStr = \GuzzleHttp\json_encode($json); - if (false === file_put_contents($filename, $jsonStr)) { + if (false === file_put_contents($filename, $jsonStr, LOCK_EX)) { throw new \RuntimeException("Unable to save file {$filename}"); } } diff --git a/includes/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php b/includes/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php index 4497bcf0..0224a244 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php @@ -22,6 +22,7 @@ class SessionCookieJar extends CookieJar */ public function __construct($sessionKey, $storeSessionCookies = false) { + parent::__construct(); $this->sessionKey = $sessionKey; $this->storeSessionCookies = $storeSessionCookies; $this->load(); diff --git a/includes/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/includes/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php index f6993943..3d776a70 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php @@ -227,7 +227,7 @@ public function setExpires($timestamp) /** * Get whether or not this is a secure cookie * - * @return null|bool + * @return bool|null */ public function getSecure() { @@ -247,7 +247,7 @@ public function setSecure($secure) /** * Get whether or not this is a session cookie * - * @return null|bool + * @return bool|null */ public function getDiscard() { diff --git a/includes/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php b/includes/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php index f95c09f2..4cfd393c 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php @@ -4,4 +4,6 @@ /** * Exception when a client error is encountered (4xx codes) */ -class ClientException extends BadResponseException {} +class ClientException extends BadResponseException +{ +} diff --git a/includes/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php b/includes/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php index 510778f6..27b2722b 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php @@ -1,13 +1,23 @@ getBody(); - - if (!$body->isSeekable()) { - return null; - } - - $size = $body->getSize(); - - if ($size === 0) { - return null; - } - - $summary = $body->read(120); - $body->rewind(); - - if ($size > 120) { - $summary .= ' (truncated...)'; - } - - // Matches any printable character, including unicode characters: - // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) { - return null; - } - - return $summary; + return \GuzzleHttp\Psr7\get_message_body_summary($response); } /** - * Obfuscates URI if there is an username and a password present + * Obfuscates URI if there is a username and a password present * * @param UriInterface $uri * * @return UriInterface */ - private static function obfuscateUri($uri) + private static function obfuscateUri(UriInterface $uri) { $userInfo = $uri->getUserInfo(); diff --git a/includes/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php b/includes/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php index 7cdd3408..127094c1 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php @@ -4,4 +4,6 @@ /** * Exception when a server error is encountered (5xx codes) */ -class ServerException extends BadResponseException {} +class ServerException extends BadResponseException +{ +} diff --git a/includes/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php b/includes/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php index b60a9678..fff05251 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php @@ -1,4 +1,6 @@ handle); + $curlStats['appconnect_time'] = curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME); $stats = new TransferStats( $easy->request, $easy->response, @@ -136,7 +140,9 @@ private static function finishError( $ctx = [ 'errno' => $easy->errno, 'error' => curl_error($easy->handle), + 'appconnect_time' => curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME), ] + curl_getinfo($easy->handle); + $ctx[self::CURL_VERSION_STR] = curl_version()['version']; $factory->release($easy); // Retry when nothing is present or when curl failed to rewind. @@ -172,13 +178,22 @@ private static function createRejection(EasyHandle $easy, array $ctx) ) ); } - - $message = sprintf( - 'cURL error %s: %s (%s)', - $ctx['errno'], - $ctx['error'], - 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html' - ); + if (version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) { + $message = sprintf( + 'cURL error %s: %s (%s)', + $ctx['errno'], + $ctx['error'], + 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html' + ); + } else { + $message = sprintf( + 'cURL error %s: %s (%s) for %s', + $ctx['errno'], + $ctx['error'], + 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html', + $easy->request->getUri() + ); + } // Create a connection exception if it was a specific error code. $error = isset($connectionErrors[$easy->errno]) @@ -439,11 +454,16 @@ private function applyHandlerOptions(EasyHandle $easy, array &$conf) } if (isset($options['ssl_key'])) { - $sslKey = $options['ssl_key']; - if (is_array($sslKey)) { - $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1]; - $sslKey = $sslKey[0]; + if (is_array($options['ssl_key'])) { + if (count($options['ssl_key']) === 2) { + list($sslKey, $conf[CURLOPT_SSLKEYPASSWD]) = $options['ssl_key']; + } else { + list($sslKey) = $options['ssl_key']; + } } + + $sslKey = isset($sslKey) ? $sslKey: $options['ssl_key']; + if (!file_exists($sslKey)) { throw new \InvalidArgumentException( "SSL private key not found: {$sslKey}" diff --git a/includes/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/includes/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php index 2754d8e4..b73e5c72 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php @@ -1,9 +1,9 @@ factory = isset($options['handle_factory']) ? $options['handle_factory'] : new CurlFactory(50); - $this->selectTimeout = isset($options['select_timeout']) - ? $options['select_timeout'] : 1; + + if (isset($options['select_timeout'])) { + $this->selectTimeout = $options['select_timeout']; + } elseif ($selectTimeout = getenv('GUZZLE_CURL_SELECT_TIMEOUT')) { + $this->selectTimeout = $selectTimeout; + } else { + $this->selectTimeout = 1; + } + + $this->options = isset($options['options']) ? $options['options'] : []; } public function __get($name) { if ($name === '_mh') { - return $this->_mh = curl_multi_init(); + $this->_mh = curl_multi_init(); + + foreach ($this->options as $option => $value) { + // A warning is raised in case of a wrong option. + curl_multi_setopt($this->_mh, $option, $value); + } + + // Further calls to _mh will return the value directly, without entering the + // __get() method at all. + return $this->_mh; } throw new \BadMethodCallException(); @@ -82,7 +102,7 @@ public function tick() { // Add any delayed handles if needed. if ($this->delays) { - $currentTime = microtime(true); + $currentTime = \GuzzleHttp\_current_time(); foreach ($this->delays as $id => $delay) { if ($currentTime >= $delay) { unset($this->delays[$id]); @@ -134,7 +154,7 @@ private function addRequest(array $entry) if (empty($easy->options['delay'])) { curl_multi_add_handle($this->_mh, $easy->handle); } else { - $this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000); + $this->delays[$id] = \GuzzleHttp\_current_time() + ($easy->options['delay'] / 1000); } } @@ -186,7 +206,7 @@ private function processMessages() private function timeToNext() { - $currentTime = microtime(true); + $currentTime = \GuzzleHttp\_current_time(); $nextTime = PHP_INT_MAX; foreach ($this->delays as $time) { if ($time < $nextTime) { diff --git a/includes/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php b/includes/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php index d892061c..5b312bc0 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php @@ -66,7 +66,7 @@ public function __invoke(RequestInterface $request, array $options) throw new \OutOfBoundsException('Mock queue is empty'); } - if (isset($options['delay'])) { + if (isset($options['delay']) && is_numeric($options['delay'])) { usleep($options['delay'] * 1000); } @@ -175,6 +175,11 @@ public function count() return count($this->queue); } + public function reset() + { + $this->queue = []; + } + private function invokeStats( RequestInterface $request, array $options, @@ -182,7 +187,8 @@ private function invokeStats( $reason = null ) { if (isset($options['on_stats'])) { - $stats = new TransferStats($request, $response, 0, $reason); + $transferTime = isset($options['transfer_time']) ? $options['transfer_time'] : 0; + $stats = new TransferStats($request, $response, $transferTime, $reason); call_user_func($options['on_stats'], $stats); } } diff --git a/includes/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/includes/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php index b686545e..a8eba378 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php @@ -1,8 +1,8 @@ getBody()->getSize()) { - $request = $request->withHeader('Content-Length', 0); + $request = $request->withHeader('Content-Length', '0'); } return $this->createResponse( @@ -82,7 +82,7 @@ private function invokeStats( $stats = new TransferStats( $request, $response, - microtime(true) - $startTime, + \GuzzleHttp\_current_time() - $startTime, $error, [] ); @@ -343,13 +343,25 @@ private function resolveHost(RequestInterface $request, array $options) if ('v4' === $options['force_ip_resolve']) { $records = dns_get_record($uri->getHost(), DNS_A); if (!isset($records[0]['ip'])) { - throw new ConnectException(sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request); + throw new ConnectException( + sprintf( + "Could not resolve IPv4 address for host '%s'", + $uri->getHost() + ), + $request + ); } $uri = $uri->withHost($records[0]['ip']); } elseif ('v6' === $options['force_ip_resolve']) { $records = dns_get_record($uri->getHost(), DNS_AAAA); if (!isset($records[0]['ipv6'])) { - throw new ConnectException(sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request); + throw new ConnectException( + sprintf( + "Could not resolve IPv6 address for host '%s'", + $uri->getHost() + ), + $request + ); } $uri = $uri->withHost('[' . $records[0]['ipv6'] . ']'); } diff --git a/includes/vendor/guzzlehttp/guzzle/src/HandlerStack.php b/includes/vendor/guzzlehttp/guzzle/src/HandlerStack.php index 24c46fd9..6a49cc06 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/HandlerStack.php +++ b/includes/vendor/guzzlehttp/guzzle/src/HandlerStack.php @@ -1,7 +1,9 @@ extractCookies($request, $response); return $response; } - ); + ); }; }; } @@ -58,7 +57,7 @@ public static function httpErrors() return $handler($request, $options); } return $handler($request, $options)->then( - function (ResponseInterface $response) use ($request, $handler) { + function (ResponseInterface $response) use ($request) { $code = $response->getStatusCode(); if ($code < 400) { return $response; @@ -183,7 +182,7 @@ public static function retry(callable $decider, callable $delay = null) * * @return callable Returns a function that accepts the next handler. */ - public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO) + public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = 'info' /* \Psr\Log\LogLevel::INFO */) { return function (callable $handler) use ($logger, $formatter, $logLevel) { return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) { diff --git a/includes/vendor/guzzlehttp/guzzle/src/Pool.php b/includes/vendor/guzzlehttp/guzzle/src/Pool.php index 8f1be33c..5838db4f 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/Pool.php +++ b/includes/vendor/guzzlehttp/guzzle/src/Pool.php @@ -1,12 +1,13 @@ each = new EachPromise($requests(), $config); } + /** + * Get promise + * + * @return PromiseInterface + */ public function promise() { return $this->each->promise(); @@ -106,6 +112,11 @@ public static function batch( return $res; } + /** + * Execute callback(s) + * + * @return void + */ private static function cmpCallback(array &$options, $name, array &$results) { if (!isset($options[$name])) { diff --git a/includes/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/includes/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php index 2eb95f9b..568a1e90 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +++ b/includes/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php @@ -66,6 +66,11 @@ public function __invoke(RequestInterface $request, array $options) return $fn(Psr7\modify_request($request, $modify), $options); } + /** + * Add expect header + * + * @return void + */ private function addExpectHeader( RequestInterface $request, array $options, diff --git a/includes/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/includes/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php index 131b7717..2f301261 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +++ b/includes/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php @@ -13,7 +13,7 @@ * Request redirect middleware. * * Apply this middleware like other middleware using - * {@see GuzzleHttp\Middleware::redirect()}. + * {@see \GuzzleHttp\Middleware::redirect()}. */ class RedirectMiddleware { @@ -76,7 +76,7 @@ public function __invoke(RequestInterface $request, array $options) /** * @param RequestInterface $request * @param array $options - * @param ResponseInterface|PromiseInterface $response + * @param ResponseInterface $response * * @return ResponseInterface|PromiseInterface */ @@ -118,6 +118,11 @@ public function checkRedirect( return $promise; } + /** + * Enable tracking on promise. + * + * @return PromiseInterface + */ private function withTracking(PromiseInterface $promise, $uri, $statusCode) { return $promise->then( @@ -135,6 +140,13 @@ function (ResponseInterface $response) use ($uri, $statusCode) { ); } + /** + * Check for too many redirects + * + * @return void + * + * @throws TooManyRedirectsException Too many redirects. + */ private function guardMax(RequestInterface $request, array &$options) { $current = isset($options['__redirect_count']) @@ -172,13 +184,19 @@ public function modifyRequest( // would do. $statusCode = $response->getStatusCode(); if ($statusCode == 303 || - ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict']) + ($statusCode <= 302 && !$options['allow_redirects']['strict']) ) { $modify['method'] = 'GET'; $modify['body'] = ''; } - $modify['uri'] = $this->redirectUri($request, $response, $protocols); + $uri = $this->redirectUri($request, $response, $protocols); + if (isset($options['idn_conversion']) && ($options['idn_conversion'] !== false)) { + $idnOptions = ($options['idn_conversion'] === true) ? IDNA_DEFAULT : $options['idn_conversion']; + $uri = _idn_uri_convert($uri, $idnOptions); + } + + $modify['uri'] = $uri; Psr7\rewind_body($request); // Add the Referer header if it is told to do so and only @@ -186,7 +204,7 @@ public function modifyRequest( if ($options['allow_redirects']['referer'] && $modify['uri']->getScheme() === $request->getUri()->getScheme() ) { - $uri = $request->getUri()->withUserInfo('', ''); + $uri = $request->getUri()->withUserInfo(''); $modify['set_headers']['Referer'] = (string) $uri; } else { $modify['remove_headers'][] = 'Referer'; diff --git a/includes/vendor/guzzlehttp/guzzle/src/RequestOptions.php b/includes/vendor/guzzlehttp/guzzle/src/RequestOptions.php index c6aacfb1..355f658f 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/RequestOptions.php +++ b/includes/vendor/guzzlehttp/guzzle/src/RequestOptions.php @@ -22,7 +22,7 @@ final class RequestOptions * - strict: (bool, default=false) Set to true to use strict redirects * meaning redirect POST requests with POST requests vs. doing what most * browsers do which is redirect POST requests with GET requests - * - referer: (bool, default=true) Set to false to disable the Referer + * - referer: (bool, default=false) Set to true to enable the Referer * header. * - protocols: (array, default=['http', 'https']) Allowed redirect * protocols. @@ -132,6 +132,14 @@ final class RequestOptions */ const HTTP_ERRORS = 'http_errors'; + /** + * idn: (bool|int, default=true) A combination of IDNA_* constants for + * idn_to_ascii() PHP's function (see "options" parameter). Set to false to + * disable IDN support completely, or to true to use the default + * configuration (IDNA_DEFAULT constant). + */ + const IDN_CONVERSION = 'idn_conversion'; + /** * json: (mixed) Adds JSON data to a request. The provided value is JSON * encoded and a Content-Type header of application/json will be added to diff --git a/includes/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php b/includes/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php index f27090fd..5acc8c5c 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +++ b/includes/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php @@ -19,6 +19,9 @@ class RetryMiddleware /** @var callable */ private $decider; + /** @var callable */ + private $delay; + /** * @param callable $decider Function that accepts the number of retries, * a request, [response], and [exception] and @@ -42,13 +45,13 @@ public function __construct( /** * Default exponential backoff delay function. * - * @param $retries + * @param int $retries * - * @return int + * @return int milliseconds. */ public static function exponentialDelay($retries) { - return (int) pow(2, $retries - 1); + return (int) pow(2, $retries - 1) * 1000; } /** @@ -71,6 +74,11 @@ public function __invoke(RequestInterface $request, array $options) ); } + /** + * Execute fulfilled closure + * + * @return mixed + */ private function onFulfilled(RequestInterface $req, array $options) { return function ($value) use ($req, $options) { @@ -87,6 +95,11 @@ private function onFulfilled(RequestInterface $req, array $options) }; } + /** + * Execute rejected closure + * + * @return callable + */ private function onRejected(RequestInterface $req, array $options) { return function ($reason) use ($req, $options) { @@ -103,6 +116,9 @@ private function onRejected(RequestInterface $req, array $options) }; } + /** + * @return self + */ private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) { $options['delay'] = call_user_func($this->delay, ++$options['retries'], $response); diff --git a/includes/vendor/guzzlehttp/guzzle/src/TransferStats.php b/includes/vendor/guzzlehttp/guzzle/src/TransferStats.php index 15f717e1..87fb3c00 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/TransferStats.php +++ b/includes/vendor/guzzlehttp/guzzle/src/TransferStats.php @@ -18,11 +18,11 @@ final class TransferStats private $handlerErrorData; /** - * @param RequestInterface $request Request that was sent. - * @param ResponseInterface $response Response received (if any) - * @param null $transferTime Total handler transfer time. - * @param mixed $handlerErrorData Handler error data. - * @param array $handlerStats Handler specific stats. + * @param RequestInterface $request Request that was sent. + * @param ResponseInterface|null $response Response received (if any) + * @param float|null $transferTime Total handler transfer time. + * @param mixed $handlerErrorData Handler error data. + * @param array $handlerStats Handler specific stats. */ public function __construct( RequestInterface $request, @@ -93,7 +93,7 @@ public function getEffectiveUri() /** * Get the estimated time the request was being transferred by the handler. * - * @return float Time in seconds. + * @return float|null Time in seconds. */ public function getTransferTime() { diff --git a/includes/vendor/guzzlehttp/guzzle/src/functions.php b/includes/vendor/guzzlehttp/guzzle/src/functions.php index a3ac450d..5e806f63 100644 --- a/includes/vendor/guzzlehttp/guzzle/src/functions.php +++ b/includes/vendor/guzzlehttp/guzzle/src/functions.php @@ -1,10 +1,12 @@ getHost()) { + $idnaVariant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0; + $asciiHost = $idnaVariant === 0 + ? idn_to_ascii($uri->getHost(), $options) + : idn_to_ascii($uri->getHost(), $options, $idnaVariant, $info); + if ($asciiHost === false) { + $errorBitSet = isset($info['errors']) ? $info['errors'] : 0; + + $errorConstants = array_filter(array_keys(get_defined_constants()), function ($name) { + return substr($name, 0, 11) === 'IDNA_ERROR_'; + }); + + $errors = []; + foreach ($errorConstants as $errorConstant) { + if ($errorBitSet & constant($errorConstant)) { + $errors[] = $errorConstant; + } + } + + $errorMessage = 'IDN conversion failed'; + if ($errors) { + $errorMessage .= ' (errors: ' . implode(', ', $errors) . ')'; + } + + throw new InvalidArgumentException($errorMessage); + } else { + if ($uri->getHost() !== $asciiHost) { + // Replace URI only if the ASCII version is different + $uri = $uri->withHost($asciiHost); + } + } + } + + return $uri; +} diff --git a/includes/vendor/guzzlehttp/psr7/.editorconfig b/includes/vendor/guzzlehttp/psr7/.editorconfig deleted file mode 100644 index 677e36e2..00000000 --- a/includes/vendor/guzzlehttp/psr7/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true diff --git a/includes/vendor/guzzlehttp/psr7/CHANGELOG.md b/includes/vendor/guzzlehttp/psr7/CHANGELOG.md index 27b65f09..8a3743db 100644 --- a/includes/vendor/guzzlehttp/psr7/CHANGELOG.md +++ b/includes/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -10,6 +10,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.6.0] + +### Added + +- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244) +- Added MIME type for WEBP image format (#246) +- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272) + +### Changed + +- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262) +- Accept port number 0 to be valid (#270) + +### Fixed + +- Fixed subsequent reads from `php://input` in ServerRequest (#247) +- Fixed readable/writable detection for certain stream modes (#248) +- Fixed encoding of special characters in the `userInfo` component of an URI (#253) + + ## [1.5.2] - 2018-12-04 ### Fixed @@ -209,7 +229,8 @@ Currently unsupported: -[Unreleased]: https://github.com/guzzle/psr7/compare/1.5.2...HEAD +[Unreleased]: https://github.com/guzzle/psr7/compare/1.6.0...HEAD +[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0 [1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2 [1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1 [1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0 diff --git a/includes/vendor/guzzlehttp/psr7/composer.json b/includes/vendor/guzzlehttp/psr7/composer.json index 2add153e..168a055b 100644 --- a/includes/vendor/guzzlehttp/psr7/composer.json +++ b/includes/vendor/guzzlehttp/psr7/composer.json @@ -18,14 +18,18 @@ "require": { "php": ">=5.4.0", "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5" + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" }, "require-dev": { - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8", + "ext-zlib": "*" }, "provide": { "psr/http-message-implementation": "1.0" }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, "autoload": { "psr-4": { "GuzzleHttp\\Psr7\\": "src/" @@ -39,7 +43,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.5-dev" + "dev-master": "1.6-dev" } } } diff --git a/includes/vendor/guzzlehttp/psr7/src/LimitStream.php b/includes/vendor/guzzlehttp/psr7/src/LimitStream.php index 3c13d4f4..e4f239e3 100644 --- a/includes/vendor/guzzlehttp/psr7/src/LimitStream.php +++ b/includes/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -72,7 +72,7 @@ public function seek($offset, $whence = SEEK_SET) { if ($whence !== SEEK_SET || $offset < 0) { throw new \RuntimeException(sprintf( - 'Cannot seek to offset % with whence %s', + 'Cannot seek to offset %s with whence %s', $offset, $whence )); diff --git a/includes/vendor/guzzlehttp/psr7/src/MessageTrait.php b/includes/vendor/guzzlehttp/psr7/src/MessageTrait.php index 1e4da649..a7966d10 100644 --- a/includes/vendor/guzzlehttp/psr7/src/MessageTrait.php +++ b/includes/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -66,11 +66,8 @@ public function getHeaderLine($header) public function withHeader($header, $value) { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); $normalized = strtolower($header); $new = clone $this; @@ -85,11 +82,8 @@ public function withHeader($header, $value) public function withAddedHeader($header, $value) { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); $normalized = strtolower($header); $new = clone $this; @@ -144,11 +138,13 @@ private function setHeaders(array $headers) { $this->headerNames = $this->headers = []; foreach ($headers as $header => $value) { - if (!is_array($value)) { - $value = [$value]; + if (is_int($header)) { + // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec + // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass. + $header = (string) $header; } - - $value = $this->trimHeaderValues($value); + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); $normalized = strtolower($header); if (isset($this->headerNames[$normalized])) { $header = $this->headerNames[$normalized]; @@ -160,6 +156,19 @@ private function setHeaders(array $headers) } } + private function normalizeHeaderValue($value) + { + if (!is_array($value)) { + return $this->trimHeaderValues([$value]); + } + + if (count($value) === 0) { + throw new \InvalidArgumentException('Header value can not be an empty array.'); + } + + return $this->trimHeaderValues($value); + } + /** * Trims whitespace from the header values. * @@ -177,7 +186,28 @@ private function setHeaders(array $headers) private function trimHeaderValues(array $values) { return array_map(function ($value) { - return trim($value, " \t"); + if (!is_scalar($value) && null !== $value) { + throw new \InvalidArgumentException(sprintf( + 'Header value must be scalar or null but %s provided.', + is_object($value) ? get_class($value) : gettype($value) + )); + } + + return trim((string) $value, " \t"); }, $values); } + + private function assertHeader($header) + { + if (!is_string($header)) { + throw new \InvalidArgumentException(sprintf( + 'Header name must be a string but %s provided.', + is_object($header) ? get_class($header) : gettype($header) + )); + } + + if ($header === '') { + throw new \InvalidArgumentException('Header name can not be empty.'); + } + } } diff --git a/includes/vendor/guzzlehttp/psr7/src/Request.php b/includes/vendor/guzzlehttp/psr7/src/Request.php index 00066424..59f337db 100644 --- a/includes/vendor/guzzlehttp/psr7/src/Request.php +++ b/includes/vendor/guzzlehttp/psr7/src/Request.php @@ -36,6 +36,7 @@ public function __construct( $body = null, $version = '1.1' ) { + $this->assertMethod($method); if (!($uri instanceof UriInterface)) { $uri = new Uri($uri); } @@ -91,6 +92,7 @@ public function getMethod() public function withMethod($method) { + $this->assertMethod($method); $new = clone $this; $new->method = strtoupper($method); return $new; @@ -139,4 +141,11 @@ private function updateHostFromUri() // See: http://tools.ietf.org/html/rfc7230#section-5.4 $this->headers = [$header => [$host]] + $this->headers; } + + private function assertMethod($method) + { + if (!is_string($method) || $method === '') { + throw new \InvalidArgumentException('Method must be a non-empty string.'); + } + } } diff --git a/includes/vendor/guzzlehttp/psr7/src/Response.php b/includes/vendor/guzzlehttp/psr7/src/Response.php index 6e72c06b..e7e04d86 100644 --- a/includes/vendor/guzzlehttp/psr7/src/Response.php +++ b/includes/vendor/guzzlehttp/psr7/src/Response.php @@ -93,11 +93,11 @@ public function __construct( $version = '1.1', $reason = null ) { - if (filter_var($status, FILTER_VALIDATE_INT) === false) { - throw new \InvalidArgumentException('Status code must be an integer value.'); - } + $this->assertStatusCodeIsInteger($status); + $status = (int) $status; + $this->assertStatusCodeRange($status); - $this->statusCode = (int) $status; + $this->statusCode = $status; if ($body !== '' && $body !== null) { $this->stream = stream_for($body); @@ -125,12 +125,30 @@ public function getReasonPhrase() public function withStatus($code, $reasonPhrase = '') { + $this->assertStatusCodeIsInteger($code); + $code = (int) $code; + $this->assertStatusCodeRange($code); + $new = clone $this; - $new->statusCode = (int) $code; + $new->statusCode = $code; if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { $reasonPhrase = self::$phrases[$new->statusCode]; } $new->reasonPhrase = $reasonPhrase; return $new; } + + private function assertStatusCodeIsInteger($statusCode) + { + if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) { + throw new \InvalidArgumentException('Status code must be an integer value.'); + } + } + + private function assertStatusCodeRange($statusCode) + { + if ($statusCode < 100 || $statusCode >= 600) { + throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.'); + } + } } diff --git a/includes/vendor/guzzlehttp/psr7/src/ServerRequest.php b/includes/vendor/guzzlehttp/psr7/src/ServerRequest.php index 99f453a5..1a09a6c8 100644 --- a/includes/vendor/guzzlehttp/psr7/src/ServerRequest.php +++ b/includes/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -168,7 +168,7 @@ public static function fromGlobals() $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; $headers = getallheaders(); $uri = self::getUriFromGlobals(); - $body = new LazyOpenStream('php://input', 'r+'); + $body = new CachingStream(new LazyOpenStream('php://input', 'r+')); $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); diff --git a/includes/vendor/guzzlehttp/psr7/src/Stream.php b/includes/vendor/guzzlehttp/psr7/src/Stream.php index 111795eb..d9e7409c 100644 --- a/includes/vendor/guzzlehttp/psr7/src/Stream.php +++ b/includes/vendor/guzzlehttp/psr7/src/Stream.php @@ -10,6 +10,17 @@ */ class Stream implements StreamInterface { + /** + * Resource modes. + * + * @var string + * + * @see http://php.net/manual/function.fopen.php + * @see http://php.net/manual/en/function.gzopen.php + */ + const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/'; + const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/'; + private $stream; private $size; private $seekable; @@ -18,22 +29,6 @@ class Stream implements StreamInterface private $uri; private $customMetadata; - /** @var array Hash of readable and writable stream types */ - private static $readWriteHash = [ - 'read' => [ - 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, - 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, - 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a+' => true, 'rb+' => true, - ], - 'write' => [ - 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, - 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, 'rb+' => true, - 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true - ] - ]; - /** * This constructor accepts an associative array of options. * @@ -65,8 +60,8 @@ public function __construct($stream, $options = []) $this->stream = $stream; $meta = stream_get_meta_data($this->stream); $this->seekable = $meta['seekable']; - $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]); - $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]); + $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']); + $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']); $this->uri = $this->getMetadata('uri'); } @@ -197,6 +192,8 @@ public function rewind() public function seek($offset, $whence = SEEK_SET) { + $whence = (int) $whence; + if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); } diff --git a/includes/vendor/guzzlehttp/psr7/src/Uri.php b/includes/vendor/guzzlehttp/psr7/src/Uri.php index 36219568..825a25ee 100644 --- a/includes/vendor/guzzlehttp/psr7/src/Uri.php +++ b/includes/vendor/guzzlehttp/psr7/src/Uri.php @@ -437,9 +437,9 @@ public function withScheme($scheme) public function withUserInfo($user, $password = null) { - $info = $user; - if ($password != '') { - $info .= ':' . $password; + $info = $this->filterUserInfoComponent($user); + if ($password !== null) { + $info .= ':' . $this->filterUserInfoComponent($password); } if ($this->userInfo === $info) { @@ -537,7 +537,9 @@ private function applyParts(array $parts) $this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : ''; - $this->userInfo = isset($parts['user']) ? $parts['user'] : ''; + $this->userInfo = isset($parts['user']) + ? $this->filterUserInfoComponent($parts['user']) + : ''; $this->host = isset($parts['host']) ? $this->filterHost($parts['host']) : ''; @@ -554,7 +556,7 @@ private function applyParts(array $parts) ? $this->filterQueryAndFragment($parts['fragment']) : ''; if (isset($parts['pass'])) { - $this->userInfo .= ':' . $parts['pass']; + $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']); } $this->removeDefaultPort(); @@ -576,6 +578,26 @@ private function filterScheme($scheme) return strtolower($scheme); } + /** + * @param string $component + * + * @return string + * + * @throws \InvalidArgumentException If the user info is invalid. + */ + private function filterUserInfoComponent($component) + { + if (!is_string($component)) { + throw new \InvalidArgumentException('User info must be a string'); + } + + return preg_replace_callback( + '/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $component + ); + } + /** * @param string $host * @@ -606,9 +628,9 @@ private function filterPort($port) } $port = (int) $port; - if (1 > $port || 0xffff < $port) { + if (0 > $port || 0xffff < $port) { throw new \InvalidArgumentException( - sprintf('Invalid port: %d. Must be between 1 and 65535', $port) + sprintf('Invalid port: %d. Must be between 0 and 65535', $port) ); } diff --git a/includes/vendor/guzzlehttp/psr7/src/functions.php b/includes/vendor/guzzlehttp/psr7/src/functions.php index 957bfb42..8e6dafe6 100644 --- a/includes/vendor/guzzlehttp/psr7/src/functions.php +++ b/includes/vendor/guzzlehttp/psr7/src/functions.php @@ -724,6 +724,7 @@ function mimetype_from_extension($extension) 'txt' => 'text/plain', 'wav' => 'audio/x-wav', 'webm' => 'video/webm', + 'webp' => 'image/webp', 'wma' => 'audio/x-ms-wma', 'wmv' => 'video/x-ms-wmv', 'woff' => 'application/x-font-woff', diff --git a/includes/vendor/peekmo/jsonpath/bin/phpunit b/includes/vendor/peekmo/jsonpath/bin/phpunit index e79fe5c9..4ba32564 120000 --- a/includes/vendor/peekmo/jsonpath/bin/phpunit +++ b/includes/vendor/peekmo/jsonpath/bin/phpunit @@ -1 +1 @@ -../../../phpunit/phpunit/phpunit \ No newline at end of file +../vendor/phpunit/phpunit/phpunit \ No newline at end of file diff --git a/includes/vendor/phpdocumentor/reflection-common/.scrutinizer.yml b/includes/vendor/phpdocumentor/reflection-common/.scrutinizer.yml new file mode 100644 index 00000000..b83b01f2 --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-common/.scrutinizer.yml @@ -0,0 +1,48 @@ +before_commands: + - "composer install --no-dev --prefer-source" + +checks: + php: + excluded_dependencies: + - phpstan/phpstan + +tools: + external_code_coverage: + enabled: true + timeout: 300 + filter: + excluded_paths: ["tests", "vendor"] + php_code_sniffer: + enabled: true + config: + standard: PSR2 + filter: + paths: ["src/*", "tests/*"] + excluded_paths: [] + php_cpd: + enabled: true + excluded_dirs: ["tests", "vendor"] + php_cs_fixer: + enabled: true + config: + level: all + filter: + paths: ["src/*", "tests/*"] + php_loc: + enabled: true + excluded_dirs: ["tests", "vendor"] + php_mess_detector: + enabled: true + config: + ruleset: phpmd.xml.dist + design_rules: { eval_expression: false } + filter: + paths: ["src/*"] + php_pdepend: + enabled: true + excluded_dirs: ["tests", "vendor"] + php_analyzer: + enabled: true + filter: + paths: ["src/*", "tests/*"] + sensiolabs_security_checker: true diff --git a/includes/vendor/phpdocumentor/reflection-common/.travis.yml b/includes/vendor/phpdocumentor/reflection-common/.travis.yml index 958ecf86..2263ed43 100644 --- a/includes/vendor/phpdocumentor/reflection-common/.travis.yml +++ b/includes/vendor/phpdocumentor/reflection-common/.travis.yml @@ -1,35 +1,53 @@ language: php -php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - hhvm - - nightly +php: [ 7.1, 7.2, nightly ] +sudo: false + +env: matrix: + fast_finish: true allow_failures: - - php: - - hhvm - - nightly + - php: nightly -cache: - directories: - - $HOME/.composer/cache +install: + - travis_retry composer install --no-interaction --prefer-dist --optimize-autoloader script: - - vendor/bin/phpunit --coverage-clover=coverage.clover -v - - composer update --no-interaction --prefer-source - - vendor/bin/phpunit -v + - ./vendor/bin/phpunit --no-coverage + +jobs: + include: + - stage: analysis + php: 7.1 + script: + - ./vendor/bin/phpunit + after_script: + - travis_retry wget --no-verbose https://phar.io/releases/phive.phar + - travis_retry php phive.phar --no-progress install --trust-gpg-keys E82B2FB314E9906E php-coveralls/php-coveralls && ./tools/php-coveralls --verbose + - travis_retry wget --no-verbose https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml -before_script: - - composer install --no-interaction + - stage: analysis + php: 7.1 + before_script: + - travis_retry wget --no-verbose https://phar.io/releases/phive.phar + - travis_retry php phive.phar --no-progress install --trust-gpg-keys 8E730BA25823D8B5 phpstan + script: + - ./tools/phpstan analyse src --level max --configuration phpstan.neon -after_script: - - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi + - stage: analysis + php: 7.1 + script: + - composer create-project symplify/easy-coding-standard temp/ecs ^3 && temp/ecs/bin/ecs check src tests + +cache: + directories: + - $HOME/.composer + - $HOME/.phive notifications: irc: "irc.freenode.org#phpdocumentor" + slack: + secure: "fjumM0h+4w3EYM4dpgqvpiCug7m4sSIC5+HATgwga/Nrc6IjlbWvGOv3JPgD3kQUhi18VmZfUYPmCv916SIbMnv8JWcrSaJXnPCgmxidvYkuzQDIw1HDJbVppGnkmwQA/qjIrM3sIEMfnu/arLRJQLI363aStZzGPxwIa4PDKcg=" email: - - me@mikevanriel.com - - ashnazg@php.net + - me@mikevanriel.com + - ashnazg@php.net diff --git a/includes/vendor/phpdocumentor/reflection-common/README.md b/includes/vendor/phpdocumentor/reflection-common/README.md index 68a80c82..a8bf63d7 100644 --- a/includes/vendor/phpdocumentor/reflection-common/README.md +++ b/includes/vendor/phpdocumentor/reflection-common/README.md @@ -1,2 +1,12 @@ -# ReflectionCommon -[![Build Status](https://travis-ci.org/phpDocumentor/ReflectionCommon.svg?branch=master)](https://travis-ci.org/phpDocumentor/ReflectionCommon) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![Travis Status](https://img.shields.io/travis/phpDocumentor/ReflectionCommon.svg?label=Linux)](https://travis-ci.org/phpDocumentor/ReflectionCommon) +[![Appveyor Status](https://img.shields.io/appveyor/ci/phpDocumentor/ReflectionCommon.svg?label=Windows)](https://ci.appveyor.com/project/phpDocumentor/ReflectionCommon/branch/master) +[![Coveralls Coverage](https://img.shields.io/coveralls/github/phpDocumentor/ReflectionCommon.svg)](https://coveralls.io/github/phpDocumentor/ReflectionCommon?branch=master) +[![Scrutinizer Code Coverage](https://img.shields.io/scrutinizer/coverage/g/phpDocumentor/ReflectionCommon.svg)](https://scrutinizer-ci.com/g/phpDocumentor/ReflectionCommon/?branch=master) +[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/phpDocumentor/ReflectionCommon.svg)](https://scrutinizer-ci.com/g/phpDocumentor/ReflectionCommon/?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/phpDocumentor/Reflection-Common.svg)](https://packagist.org/packages/phpDocumentor/Reflection-Common) +[![Unstable Version](https://img.shields.io/packagist/vpre/phpDocumentor/Reflection-Common.svg)](https://packagist.org/packages/phpDocumentor/Reflection-Common) + + +ReflectionCommon +================ diff --git a/includes/vendor/phpdocumentor/reflection-common/appveyor.yml b/includes/vendor/phpdocumentor/reflection-common/appveyor.yml new file mode 100644 index 00000000..46e4705e --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-common/appveyor.yml @@ -0,0 +1,52 @@ +build: false +clone_folder: c:\reflectioncommon +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:\reflectioncommon + - composer install --no-interaction --prefer-dist --no-progress + +test_script: + - cd c:\reflectioncommon + - vendor\bin\phpunit --no-coverage diff --git a/includes/vendor/phpdocumentor/reflection-common/composer.json b/includes/vendor/phpdocumentor/reflection-common/composer.json index 90eee0f0..6daeb50e 100644 --- a/includes/vendor/phpdocumentor/reflection-common/composer.json +++ b/includes/vendor/phpdocumentor/reflection-common/composer.json @@ -11,19 +11,19 @@ } ], "require": { - "php": ">=5.5" + "php": ">=7.1" }, "autoload" : { "psr-4" : { - "phpDocumentor\\Reflection\\": ["src"] + "phpDocumentor\\Reflection\\": "src/" } }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } } } diff --git a/includes/vendor/phpdocumentor/reflection-common/easy-coding-standard.neon b/includes/vendor/phpdocumentor/reflection-common/easy-coding-standard.neon new file mode 100644 index 00000000..559a8974 --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-common/easy-coding-standard.neon @@ -0,0 +1,17 @@ +includes: + - temp/ecs/config/clean-code.neon + - temp/ecs/config/psr2.neon + - temp/ecs/config/common.neon + +parameters: + exclude_checkers: + # from temp/ecs/config/common.neon + - PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer + - PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer + - PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer + # from temp/ecs/config/spaces.neon + - PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer + + skip: + PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff: + - */tests/** diff --git a/includes/vendor/phpdocumentor/reflection-common/phive.xml b/includes/vendor/phpdocumentor/reflection-common/phive.xml new file mode 100644 index 00000000..5630fde4 --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-common/phive.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/vendor/phpdocumentor/reflection-common/phpmd.xml.dist b/includes/vendor/phpdocumentor/reflection-common/phpmd.xml.dist new file mode 100644 index 00000000..9abf85cf --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-common/phpmd.xml.dist @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + 40 + + + diff --git a/includes/vendor/phpdocumentor/reflection-common/phpstan.neon b/includes/vendor/phpdocumentor/reflection-common/phpstan.neon new file mode 100644 index 00000000..e69de29b diff --git a/includes/vendor/phpdocumentor/reflection-common/src/Element.php b/includes/vendor/phpdocumentor/reflection-common/src/Element.php index 712e30e8..b3820f8e 100644 --- a/includes/vendor/phpdocumentor/reflection-common/src/Element.php +++ b/includes/vendor/phpdocumentor/reflection-common/src/Element.php @@ -1,10 +1,13 @@ + * @copyright 2010-2018 Mike van Riel * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -19,22 +21,16 @@ interface File { /** * Returns the content of the file as a string. - * - * @return string */ - public function getContents(); + public function getContents(): string; /** * Returns md5 hash of the file. - * - * @return string */ - public function md5(); + public function md5(): string; /** * Returns an relative path to the file. - * - * @return string */ - public function path(); + public function path(): string; } diff --git a/includes/vendor/phpdocumentor/reflection-common/src/Fqsen.php b/includes/vendor/phpdocumentor/reflection-common/src/Fqsen.php index ce88d03f..9fc0c640 100644 --- a/includes/vendor/phpdocumentor/reflection-common/src/Fqsen.php +++ b/includes/vendor/phpdocumentor/reflection-common/src/Fqsen.php @@ -1,16 +1,21 @@ fqsen; } /** * Returns the name of the element without path. - * - * @return string */ - public function getName() + public function getName(): string { return $this->name; } diff --git a/includes/vendor/phpdocumentor/reflection-common/src/Location.php b/includes/vendor/phpdocumentor/reflection-common/src/Location.php index 57603219..fdb18163 100644 --- a/includes/vendor/phpdocumentor/reflection-common/src/Location.php +++ b/includes/vendor/phpdocumentor/reflection-common/src/Location.php @@ -1,11 +1,13 @@ + * @copyright 2010-2018 Mike van Riel * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -17,7 +19,7 @@ */ final class Location { - /** @var int */ + /** @var int */ private $lineNumber = 0; /** @var int */ @@ -25,32 +27,25 @@ final class Location /** * Initializes the location for an element using its line number in the file and optionally the column number. - * - * @param int $lineNumber - * @param int $columnNumber */ - public function __construct($lineNumber, $columnNumber = 0) + public function __construct(int $lineNumber, int $columnNumber = 0) { - $this->lineNumber = $lineNumber; + $this->lineNumber = $lineNumber; $this->columnNumber = $columnNumber; } /** * Returns the line number that is covered by this location. - * - * @return integer */ - public function getLineNumber() + public function getLineNumber(): int { return $this->lineNumber; } /** * Returns the column number (character position on a line) for this location object. - * - * @return integer */ - public function getColumnNumber() + public function getColumnNumber(): int { return $this->columnNumber; } diff --git a/includes/vendor/phpdocumentor/reflection-common/src/Project.php b/includes/vendor/phpdocumentor/reflection-common/src/Project.php index 3ed1e393..7d4b1768 100644 --- a/includes/vendor/phpdocumentor/reflection-common/src/Project.php +++ b/includes/vendor/phpdocumentor/reflection-common/src/Project.php @@ -1,10 +1,13 @@ + + + + diff --git a/includes/vendor/phpdocumentor/reflection-docblock/phpcs.xml.dist b/includes/vendor/phpdocumentor/reflection-docblock/phpcs.xml.dist new file mode 100644 index 00000000..1cb3002e --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-docblock/phpcs.xml.dist @@ -0,0 +1,16 @@ + + + The coding standard for phpDocumentor. + + src + tests/unit + */tests/unit/Types/ContextFactoryTest.php + + + + + + + */src/*/Abstract*.php + + diff --git a/includes/vendor/phpdocumentor/reflection-docblock/phpstan.neon b/includes/vendor/phpdocumentor/reflection-docblock/phpstan.neon new file mode 100644 index 00000000..272dd744 --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-docblock/phpstan.neon @@ -0,0 +1,8 @@ +includes: + - /composer/vendor/phpstan/phpstan-mockery/extension.neon + - /composer/vendor/phpstan/phpstan-webmozart-assert/extension.neon + +parameters: + ignoreErrors: + # false positive + - '#Method phpDocumentor\Reflection\DocBlock\Tags\Method::filterArguments() should return array but returns array#' diff --git a/includes/vendor/phpdocumentor/reflection-docblock/psalm.xml b/includes/vendor/phpdocumentor/reflection-docblock/psalm.xml new file mode 100644 index 00000000..9fedb8ab --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-docblock/psalm.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock.php index 46605b78..a5b9f5ce 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,16 +22,16 @@ final class DocBlock private $summary = ''; /** @var DocBlock\Description The actual description for this docblock. */ - private $description = null; + private $description; /** @var Tag[] An array containing all the tags in this docblock; except inline. */ private $tags = []; - /** @var Types\Context Information about the context of this DocBlock. */ - private $context = null; + /** @var Types\Context|null Information about the context of this DocBlock. */ + private $context; - /** @var Location Information about the location of this DocBlock. */ - private $location = null; + /** @var Location|null Information about the location of this DocBlock. */ + private $location; /** @var bool Is this DocBlock (the start of) a template? */ private $isTemplateStart = false; @@ -39,73 +40,56 @@ final class DocBlock private $isTemplateEnd = false; /** - * @param string $summary - * @param DocBlock\Description $description * @param DocBlock\Tag[] $tags - * @param Types\Context $context The context in which the DocBlock occurs. - * @param Location $location The location within the file that this DocBlock occurs in. - * @param bool $isTemplateStart - * @param bool $isTemplateEnd + * @param Types\Context $context The context in which the DocBlock occurs. + * @param Location $location The location within the file that this DocBlock occurs in. */ public function __construct( - $summary = '', - DocBlock\Description $description = null, + string $summary = '', + ?DocBlock\Description $description = null, array $tags = [], - Types\Context $context = null, - Location $location = null, - $isTemplateStart = false, - $isTemplateEnd = false + ?Types\Context $context = null, + ?Location $location = null, + bool $isTemplateStart = false, + bool $isTemplateEnd = false ) { - Assert::string($summary); - Assert::boolean($isTemplateStart); - Assert::boolean($isTemplateEnd); Assert::allIsInstanceOf($tags, Tag::class); - $this->summary = $summary; + $this->summary = $summary; $this->description = $description ?: new DocBlock\Description(''); foreach ($tags as $tag) { $this->addTag($tag); } - $this->context = $context; + $this->context = $context; $this->location = $location; - $this->isTemplateEnd = $isTemplateEnd; + $this->isTemplateEnd = $isTemplateEnd; $this->isTemplateStart = $isTemplateStart; } - /** - * @return string - */ - public function getSummary() + public function getSummary() : string { return $this->summary; } - /** - * @return DocBlock\Description - */ - public function getDescription() + public function getDescription() : DocBlock\Description { return $this->description; } /** * Returns the current context. - * - * @return Types\Context */ - public function getContext() + public function getContext() : ?Types\Context { return $this->context; } /** * Returns the current location. - * - * @return Location */ - public function getLocation() + public function getLocation() : ?Location { return $this->location; } @@ -128,10 +112,8 @@ public function getLocation() * elements that follow until another DocBlock is found that contains the closing marker (`#@-`). * * @see self::isTemplateEnd() for the check whether a closing marker was provided. - * - * @return boolean */ - public function isTemplateStart() + public function isTemplateStart() : bool { return $this->isTemplateStart; } @@ -140,10 +122,8 @@ public function isTemplateStart() * Returns whether this DocBlock is the end of a Template section. * * @see self::isTemplateStart() for a more complete description of the Docblock Template functionality. - * - * @return boolean */ - public function isTemplateEnd() + public function isTemplateEnd() : bool { return $this->isTemplateEnd; } @@ -153,7 +133,7 @@ public function isTemplateEnd() * * @return Tag[] */ - public function getTags() + public function getTags() : array { return $this->tags; } @@ -166,10 +146,8 @@ public function getTags() * * @return Tag[] */ - public function getTagsByName($name) + public function getTagsByName(string $name) : array { - Assert::string($name); - $result = []; /** @var Tag $tag */ @@ -188,13 +166,9 @@ public function getTagsByName($name) * Checks if a tag of a certain type is present in this DocBlock. * * @param string $name Tag name to check for. - * - * @return bool */ - public function hasTag($name) + public function hasTag(string $name) : bool { - Assert::string($name); - /** @var Tag $tag */ foreach ($this->getTags() as $tag) { if ($tag->getName() === $name) { @@ -208,11 +182,9 @@ public function hasTag($name) /** * Remove a tag from this DocBlock. * - * @param Tag $tag The tag to remove. - * - * @return void + * @param Tag $tagToRemove The tag to remove. */ - public function removeTag(Tag $tagToRemove) + public function removeTag(Tag $tagToRemove) : void { foreach ($this->tags as $key => $tag) { if ($tag === $tagToRemove) { @@ -226,10 +198,8 @@ public function removeTag(Tag $tagToRemove) * Adds a tag to this DocBlock. * * @param Tag $tag The tag to add. - * - * @return void */ - private function addTag(Tag $tag) + private function addTag(Tag $tag) : void { $this->tags[] = $tag; } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Description.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Description.php index 25a79e00..40299fc3 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Description.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Description.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -14,7 +15,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Formatter; use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter; -use Webmozart\Assert\Assert; +use function vsprintf; /** * Object representing to description for a DocBlock. @@ -59,15 +60,12 @@ class Description /** * Initializes a Description with its body (template) and a listing of the tags used in the body template. * - * @param string $bodyTemplate * @param Tag[] $tags */ - public function __construct($bodyTemplate, array $tags = []) + public function __construct(string $bodyTemplate, array $tags = []) { - Assert::string($bodyTemplate); - $this->bodyTemplate = $bodyTemplate; - $this->tags = $tags; + $this->tags = $tags; } /** @@ -75,7 +73,7 @@ public function __construct($bodyTemplate, array $tags = []) * * @return Tag[] */ - public function getTags() + public function getTags() : array { return $this->tags; } @@ -83,12 +81,8 @@ public function getTags() /** * Renders this description as a string where the provided formatter will format the tags in the expected string * format. - * - * @param Formatter|null $formatter - * - * @return string */ - public function render(Formatter $formatter = null) + public function render(?Formatter $formatter = null) : string { if ($formatter === null) { $formatter = new PassthroughFormatter(); @@ -104,10 +98,8 @@ public function render(Formatter $formatter = null) /** * Returns a plain string representation of this description. - * - * @return string */ - public function __toString() + public function __toString() : string { return $this->render(); } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/DescriptionFactory.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/DescriptionFactory.php index 48f9c219..267e5af4 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/DescriptionFactory.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/DescriptionFactory.php @@ -1,18 +1,32 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\Types\Context as TypeContext; +use Webmozart\Assert\Assert; +use const PREG_SPLIT_DELIM_CAPTURE; +use function count; +use function explode; +use function implode; +use function ltrim; +use function min; +use function preg_split; +use function str_replace; +use function strlen; +use function strpos; +use function substr; +use function trim; /** * Creates a new Description object given a body of text. @@ -38,8 +52,6 @@ class DescriptionFactory /** * Initializes this factory with the means to construct (inline) tags. - * - * @param TagFactory $tagFactory */ public function __construct(TagFactory $tagFactory) { @@ -48,27 +60,36 @@ public function __construct(TagFactory $tagFactory) /** * Returns the parsed text of this description. - * - * @param string $contents - * @param TypeContext $context - * - * @return Description */ - public function create($contents, TypeContext $context = null) + public function create(string $contents, ?TypeContext $context = null) : Description { - list($text, $tags) = $this->parse($this->lex($contents), $context); + $tokens = $this->lex($contents); + $count = count($tokens); + $tagCount = 0; + $tags = []; - return new Description($text, $tags); + for ($i = 1; $i < $count; $i += 2) { + $tags[] = $this->tagFactory->create($tokens[$i], $context); + $tokens[$i] = '%' . ++$tagCount . '$s'; + } + + //In order to allow "literal" inline tags, the otherwise invalid + //sequence "{@}" is changed to "@", and "{}" is changed to "}". + //"%" is escaped to "%%" because of vsprintf. + //See unit tests for examples. + for ($i = 0; $i < $count; $i += 2) { + $tokens[$i] = str_replace(['{@}', '{}', '%'], ['@', '}', '%%'], $tokens[$i]); + } + + return new Description(implode('', $tokens), $tags); } /** * Strips the contents from superfluous whitespace and splits the description into a series of tokens. * - * @param string $contents - * * @return string[] A series of tokens of which the description text is composed. */ - private function lex($contents) + private function lex(string $contents) : array { $contents = $this->removeSuperfluousStartingWhitespace($contents); @@ -77,7 +98,7 @@ private function lex($contents) return [$contents]; } - return preg_split( + $parts = preg_split( '/\{ # "{@}" is not a valid inline tag. This ensures that we do not treat it as one, but treat it literally. (?!@\}) @@ -103,39 +124,11 @@ private function lex($contents) ) \}/Sux', $contents, - null, + 0, PREG_SPLIT_DELIM_CAPTURE ); - } - - /** - * Parses the stream of tokens in to a new set of tokens containing Tags. - * - * @param string[] $tokens - * @param TypeContext $context - * - * @return string[]|Tag[] - */ - private function parse($tokens, TypeContext $context) - { - $count = count($tokens); - $tagCount = 0; - $tags = []; - - for ($i = 1; $i < $count; $i += 2) { - $tags[] = $this->tagFactory->create($tokens[$i], $context); - $tokens[$i] = '%' . ++$tagCount . '$s'; - } - - //In order to allow "literal" inline tags, the otherwise invalid - //sequence "{@}" is changed to "@", and "{}" is changed to "}". - //"%" is escaped to "%%" because of vsprintf. - //See unit tests for examples. - for ($i = 0; $i < $count; $i += 2) { - $tokens[$i] = str_replace(['{@}', '{}', '%'], ['@', '}', '%%'], $tokens[$i]); - } - - return [implode('', $tokens), $tags]; + Assert::isArray($parts); + return $parts; } /** @@ -151,12 +144,8 @@ private function parse($tokens, TypeContext $context) * * If we do not normalize the indentation then we have superfluous whitespace on the second and subsequent * lines and this may cause rendering issues when, for example, using a Markdown converter. - * - * @param string $contents - * - * @return string */ - private function removeSuperfluousStartingWhitespace($contents) + private function removeSuperfluousStartingWhitespace(string $contents) : string { $lines = explode("\n", $contents); @@ -168,7 +157,7 @@ private function removeSuperfluousStartingWhitespace($contents) // determine how many whitespace characters need to be stripped $startingSpaceCount = 9999999; - for ($i = 1; $i < count($lines); $i++) { + for ($i = 1; $i < count($lines); ++$i) { // lines with a no length do not count as they are not indented at all if (strlen(trim($lines[$i])) === 0) { continue; @@ -181,7 +170,7 @@ private function removeSuperfluousStartingWhitespace($contents) // strip the number of spaces from each line if ($startingSpaceCount > 0) { - for ($i = 1; $i < count($lines); $i++) { + for ($i = 1; $i < count($lines); ++$i) { $lines[$i] = substr($lines[$i], $startingSpaceCount); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/ExampleFinder.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/ExampleFinder.php index 571ed749..db42be71 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/ExampleFinder.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/ExampleFinder.php @@ -1,18 +1,28 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock\Tags\Example; +use const DIRECTORY_SEPARATOR; +use function array_slice; +use function file; +use function getcwd; +use function implode; +use function is_readable; +use function rtrim; +use function sprintf; +use function trim; /** * Class used to find an example file's location based on a given ExampleDescriptor. @@ -27,18 +37,14 @@ class ExampleFinder /** * Attempts to find the example contents for the given descriptor. - * - * @param Example $example - * - * @return string */ - public function find(Example $example) + public function find(Example $example) : string { $filename = $example->getFilePath(); $file = $this->getExampleFileContents($filename); if (!$file) { - return "** File not found : {$filename} **"; + return sprintf('** File not found : %s **', $filename); } return implode('', array_slice($file, $example->getStartingLine() - 1, $example->getLineCount())); @@ -46,22 +52,16 @@ public function find(Example $example) /** * Registers the project's root directory where an 'examples' folder can be expected. - * - * @param string $directory - * - * @return void */ - public function setSourceDirectory($directory = '') + public function setSourceDirectory(string $directory = '') : void { $this->sourceDirectory = $directory; } /** * Returns the project's root directory where an 'examples' folder can be expected. - * - * @return string */ - public function getSourceDirectory() + public function getSourceDirectory() : string { return $this->sourceDirectory; } @@ -71,7 +71,7 @@ public function getSourceDirectory() * * @param string[] $directories */ - public function setExampleDirectories(array $directories) + public function setExampleDirectories(array $directories) : void { $this->exampleDirectories = $directories; } @@ -81,7 +81,7 @@ public function setExampleDirectories(array $directories) * * @return string[] */ - public function getExampleDirectories() + public function getExampleDirectories() : array { return $this->exampleDirectories; } @@ -97,11 +97,9 @@ public function getExampleDirectories() * 3. Checks the 'examples' folder in the current working directory for examples * 4. Checks the path relative to the current working directory for the given filename * - * @param string $filename - * - * @return string|null + * @return string[] all lines of the example file */ - private function getExampleFileContents($filename) + private function getExampleFileContents(string $filename) : ?array { $normalizedPath = null; @@ -123,42 +121,30 @@ private function getExampleFileContents($filename) } } - return $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : null; + $lines = $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : false; + return $lines !== false ? $lines : null; } /** * Get example filepath based on the example directory inside your project. - * - * @param string $file - * - * @return string */ - private function getExamplePathFromExampleDirectory($file) + private function getExamplePathFromExampleDirectory(string $file) : string { return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file; } /** * Returns a path to the example file in the given directory.. - * - * @param string $directory - * @param string $file - * - * @return string */ - private function constructExamplePath($directory, $file) + private function constructExamplePath(string $directory, string $file) : string { return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file; } /** * Get example filepath based on sourcecode. - * - * @param string $file - * - * @return string */ - private function getExamplePathFromSource($file) + private function getExamplePathFromSource(string $file) : string { return sprintf( '%s%s%s', diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Serializer.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Serializer.php index 0f355f58..e8a5c647 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Serializer.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Serializer.php @@ -1,19 +1,26 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlock; -use Webmozart\Assert\Assert; +use phpDocumentor\Reflection\DocBlock\Tags\Formatter; +use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter; +use function sprintf; +use function str_repeat; +use function str_replace; +use function strlen; +use function wordwrap; /** * Converts a DocBlock back from an object to a complete DocComment including Asterisks. @@ -30,33 +37,32 @@ class Serializer protected $isFirstLineIndented = true; /** @var int|null The max length of a line. */ - protected $lineLength = null; + protected $lineLength; - /** @var DocBlock\Tags\Formatter A custom tag formatter. */ - protected $tagFormatter = null; + /** @var Formatter A custom tag formatter. */ + protected $tagFormatter; /** * Create a Serializer instance. * - * @param int $indent The number of times the indent string is repeated. - * @param string $indentString The string to indent the comment with. - * @param bool $indentFirstLine Whether to indent the first line. - * @param int|null $lineLength The max length of a line or NULL to disable line wrapping. - * @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter. + * @param int $indent The number of times the indent string is repeated. + * @param string $indentString The string to indent the comment with. + * @param bool $indentFirstLine Whether to indent the first line. + * @param int|null $lineLength The max length of a line or NULL to disable line wrapping. + * @param Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter. */ - public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null, $tagFormatter = null) - { - Assert::integer($indent); - Assert::string($indentString); - Assert::boolean($indentFirstLine); - Assert::nullOrInteger($lineLength); - Assert::nullOrIsInstanceOf($tagFormatter, 'phpDocumentor\Reflection\DocBlock\Tags\Formatter'); - - $this->indent = $indent; - $this->indentString = $indentString; + public function __construct( + int $indent = 0, + string $indentString = ' ', + bool $indentFirstLine = true, + ?int $lineLength = null, + ?Formatter $tagFormatter = null + ) { + $this->indent = $indent; + $this->indentString = $indentString; $this->isFirstLineIndented = $indentFirstLine; - $this->lineLength = $lineLength; - $this->tagFormatter = $tagFormatter ?: new DocBlock\Tags\Formatter\PassthroughFormatter(); + $this->lineLength = $lineLength; + $this->tagFormatter = $tagFormatter ?: new PassthroughFormatter(); } /** @@ -66,9 +72,9 @@ public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = * * @return string The serialized doc block. */ - public function getDocComment(DocBlock $docblock) + public function getDocComment(DocBlock $docblock) : string { - $indent = str_repeat($this->indentString, $this->indent); + $indent = str_repeat($this->indentString, $this->indent); $firstIndent = $this->isFirstLineIndented ? $indent : ''; // 3 === strlen(' * ') $wrapLength = $this->lineLength ? $this->lineLength - strlen($indent) - 3 : null; @@ -81,46 +87,43 @@ public function getDocComment(DocBlock $docblock) ) ); - $comment = "{$firstIndent}/**\n"; + $comment = $firstIndent . "/**\n"; if ($text) { - $comment .= "{$indent} * {$text}\n"; - $comment .= "{$indent} *\n"; + $comment .= $indent . ' * ' . $text . "\n"; + $comment .= $indent . " *\n"; } $comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment); - $comment .= $indent . ' */'; - - return $comment; + return $comment . $indent . ' */'; } /** - * @param $indent - * @param $text * @return mixed */ - private function removeTrailingSpaces($indent, $text) + private function removeTrailingSpaces(string $indent, string $text) { - return str_replace("\n{$indent} * \n", "\n{$indent} *\n", $text); + return str_replace( + sprintf("\n%s * \n", $indent), + sprintf("\n%s *\n", $indent), + $text + ); } /** - * @param $indent - * @param $text * @return mixed */ - private function addAsterisksForEachLine($indent, $text) + private function addAsterisksForEachLine(string $indent, string $text) { - return str_replace("\n", "\n{$indent} * ", $text); + return str_replace( + "\n", + sprintf("\n%s * ", $indent), + $text + ); } - /** - * @param DocBlock $docblock - * @param $wrapLength - * @return string - */ - private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLength) + private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wrapLength) : string { - $text = $docblock->getSummary() . ((string)$docblock->getDescription() ? "\n\n" . $docblock->getDescription() + $text = $docblock->getSummary() . ((string) $docblock->getDescription() ? "\n\n" . $docblock->getDescription() : ''); if ($wrapLength !== null) { $text = wordwrap($text, $wrapLength); @@ -130,14 +133,7 @@ private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLeng return $text; } - /** - * @param DocBlock $docblock - * @param $wrapLength - * @param $indent - * @param $comment - * @return string - */ - private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment) + private function addTagBlock(DocBlock $docblock, ?int $wrapLength, string $indent, string $comment) : string { foreach ($docblock->getTags() as $tag) { $tagText = $this->tagFormatter->format($tag); @@ -145,9 +141,13 @@ private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment) $tagText = wordwrap($tagText, $wrapLength); } - $tagText = str_replace("\n", "\n{$indent} * ", $tagText); + $tagText = str_replace( + "\n", + sprintf("\n%s * ", $indent), + $tagText + ); - $comment .= "{$indent} * {$tagText}\n"; + $comment .= sprintf("%s * %s\n", $indent, $tagText); } return $comment; diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php index 5a8143cf..7b348c7f 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php @@ -1,22 +1,52 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; +use InvalidArgumentException; +use phpDocumentor\Reflection\DocBlock\Tags\Author; +use phpDocumentor\Reflection\DocBlock\Tags\Covers; +use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod; use phpDocumentor\Reflection\DocBlock\Tags\Generic; +use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag; +use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag; +use phpDocumentor\Reflection\DocBlock\Tags\Method; +use phpDocumentor\Reflection\DocBlock\Tags\Param; +use phpDocumentor\Reflection\DocBlock\Tags\Property; +use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead; +use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite; +use phpDocumentor\Reflection\DocBlock\Tags\Return_; +use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag; +use phpDocumentor\Reflection\DocBlock\Tags\Since; +use phpDocumentor\Reflection\DocBlock\Tags\Source; +use phpDocumentor\Reflection\DocBlock\Tags\Throws; +use phpDocumentor\Reflection\DocBlock\Tags\Uses; +use phpDocumentor\Reflection\DocBlock\Tags\Var_; +use phpDocumentor\Reflection\DocBlock\Tags\Version; use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; +use ReflectionMethod; +use ReflectionParameter; use Webmozart\Assert\Assert; +use function array_merge; +use function array_slice; +use function call_user_func_array; +use function count; +use function get_class; +use function preg_match; +use function strpos; +use function trim; /** * Creates a Tag object given the contents of a tag. @@ -38,41 +68,47 @@ final class StandardTagFactory implements TagFactory { /** PCRE regular expression matching a tag name. */ - const REGEX_TAGNAME = '[\w\-\_\\\\]+'; + public const REGEX_TAGNAME = '[\w\-\_\\\\:]+'; /** - * @var string[] An array with a tag as a key, and an FQCN to a class that handles it as an array value. + * @var string[] An array with a tag as a key, and an + * FQCN to a class that handles it as an array value. */ private $tagHandlerMappings = [ - 'author' => '\phpDocumentor\Reflection\DocBlock\Tags\Author', - 'covers' => '\phpDocumentor\Reflection\DocBlock\Tags\Covers', - 'deprecated' => '\phpDocumentor\Reflection\DocBlock\Tags\Deprecated', + 'author' => Author::class, + 'covers' => Covers::class, + 'deprecated' => Deprecated::class, // 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example', - 'link' => '\phpDocumentor\Reflection\DocBlock\Tags\Link', - 'method' => '\phpDocumentor\Reflection\DocBlock\Tags\Method', - 'param' => '\phpDocumentor\Reflection\DocBlock\Tags\Param', - 'property-read' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyRead', - 'property' => '\phpDocumentor\Reflection\DocBlock\Tags\Property', - 'property-write' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite', - 'return' => '\phpDocumentor\Reflection\DocBlock\Tags\Return_', - 'see' => '\phpDocumentor\Reflection\DocBlock\Tags\See', - 'since' => '\phpDocumentor\Reflection\DocBlock\Tags\Since', - 'source' => '\phpDocumentor\Reflection\DocBlock\Tags\Source', - 'throw' => '\phpDocumentor\Reflection\DocBlock\Tags\Throws', - 'throws' => '\phpDocumentor\Reflection\DocBlock\Tags\Throws', - 'uses' => '\phpDocumentor\Reflection\DocBlock\Tags\Uses', - 'var' => '\phpDocumentor\Reflection\DocBlock\Tags\Var_', - 'version' => '\phpDocumentor\Reflection\DocBlock\Tags\Version' + 'link' => LinkTag::class, + 'method' => Method::class, + 'param' => Param::class, + 'property-read' => PropertyRead::class, + 'property' => Property::class, + 'property-write' => PropertyWrite::class, + 'return' => Return_::class, + 'see' => SeeTag::class, + 'since' => Since::class, + 'source' => Source::class, + 'throw' => Throws::class, + 'throws' => Throws::class, + 'uses' => Uses::class, + 'var' => Var_::class, + 'version' => Version::class, ]; /** - * @var \ReflectionParameter[][] a lazy-loading cache containing parameters for each tagHandler that has been used. + * @var string[] An array with a anotation s a key, and an + * FQCN to a class that handles it as an array value. */ - private $tagHandlerParameterCache = []; + private $annotationMappings = []; /** - * @var FqsenResolver + * @var ReflectionParameter[][] a lazy-loading cache containing parameters + * for each tagHandler that has been used. */ + private $tagHandlerParameterCache = []; + + /** @var FqsenResolver */ private $fqsenResolver; /** @@ -87,12 +123,11 @@ final class StandardTagFactory implements TagFactory * If no tag handlers are provided than the default list in the {@see self::$tagHandlerMappings} property * is used. * - * @param FqsenResolver $fqsenResolver - * @param string[] $tagHandlers - * * @see self::registerTagHandler() to add a new tag handler to the existing default list. + * + * @param string[] $tagHandlers */ - public function __construct(FqsenResolver $fqsenResolver, array $tagHandlers = null) + public function __construct(FqsenResolver $fqsenResolver, ?array $tagHandlers = null) { $this->fqsenResolver = $fqsenResolver; if ($tagHandlers !== null) { @@ -105,27 +140,21 @@ public function __construct(FqsenResolver $fqsenResolver, array $tagHandlers = n /** * {@inheritDoc} */ - public function create($tagLine, TypeContext $context = null) + public function create(string $tagLine, ?TypeContext $context = null) : Tag { - if (! $context) { + if (!$context) { $context = new TypeContext(''); } - list($tagName, $tagBody) = $this->extractTagParts($tagLine); + [$tagName, $tagBody] = $this->extractTagParts($tagLine); - if ($tagBody !== '' && $tagBody[0] === '[') { - throw new \InvalidArgumentException( - 'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors' - ); - } - - return $this->createTag($tagBody, $tagName, $context); + return $this->createTag(trim($tagBody), $tagName, $context); } /** * {@inheritDoc} */ - public function addParameter($name, $value) + public function addParameter(string $name, $value) : void { $this->serviceLocator[$name] = $value; } @@ -133,7 +162,7 @@ public function addParameter($name, $value) /** * {@inheritDoc} */ - public function addService($service, $alias = null) + public function addService(object $service, ?string $alias = null) : void { $this->serviceLocator[$alias ?: get_class($service)] = $service; } @@ -141,15 +170,15 @@ public function addService($service, $alias = null) /** * {@inheritDoc} */ - public function registerTagHandler($tagName, $handler) + public function registerTagHandler(string $tagName, string $handler) : void { Assert::stringNotEmpty($tagName); - Assert::stringNotEmpty($handler); Assert::classExists($handler); + /** @var object $handler stupid hack to make phpstan happy. */ Assert::implementsInterface($handler, StaticMethod::class); if (strpos($tagName, '\\') && $tagName[0] !== '\\') { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'A namespaced tag must have a leading backslash as it must be fully qualified' ); } @@ -160,15 +189,13 @@ public function registerTagHandler($tagName, $handler) /** * Extracts all components for a tag. * - * @param string $tagLine - * * @return string[] */ - private function extractTagParts($tagLine) + private function extractTagParts(string $tagLine) : array { $matches = []; - if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) { - throw new \InvalidArgumentException( + if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{])\s*([^\s].*)|$)/us', $tagLine, $matches)) { + throw new InvalidArgumentException( 'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors' ); } @@ -183,14 +210,8 @@ private function extractTagParts($tagLine) /** * Creates a new tag object with the given name and body or returns null if the tag name was recognized but the * body was invalid. - * - * @param string $body - * @param string $name - * @param TypeContext $context - * - * @return Tag|null */ - private function createTag($body, $name, TypeContext $context) + private function createTag(string $body, string $name, TypeContext $context) : Tag { $handlerClassName = $this->findHandlerClassName($name, $context); $arguments = $this->getArgumentsForParametersFromWiring( @@ -198,28 +219,30 @@ private function createTag($body, $name, TypeContext $context) $this->getServiceLocatorWithDynamicParameters($context, $name, $body) ); - return call_user_func_array([$handlerClassName, 'create'], $arguments); + try { + /** @var callable $callable */ + $callable = [$handlerClassName, 'create']; + $tag = call_user_func_array($callable, $arguments); + return $tag ?? InvalidTag::create($body, $name); + } catch (InvalidArgumentException $e) { + return InvalidTag::create($body, $name)->withError($e); + } } /** * Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`). - * - * @param string $tagName - * @param TypeContext $context - * - * @return string */ - private function findHandlerClassName($tagName, TypeContext $context) + private function findHandlerClassName(string $tagName, TypeContext $context) : string { $handlerClassName = Generic::class; if (isset($this->tagHandlerMappings[$tagName])) { $handlerClassName = $this->tagHandlerMappings[$tagName]; } elseif ($this->isAnnotation($tagName)) { // TODO: Annotation support is planned for a later stage and as such is disabled for now - // $tagName = (string)$this->fqsenResolver->resolve($tagName, $context); - // if (isset($this->annotationMappings[$tagName])) { - // $handlerClassName = $this->annotationMappings[$tagName]; - // } + $tagName = (string) $this->fqsenResolver->resolve($tagName, $context); + if (isset($this->annotationMappings[$tagName])) { + $handlerClassName = $this->annotationMappings[$tagName]; + } } return $handlerClassName; @@ -228,17 +251,22 @@ private function findHandlerClassName($tagName, TypeContext $context) /** * Retrieves the arguments that need to be passed to the Factory Method with the given Parameters. * - * @param \ReflectionParameter[] $parameters - * @param mixed[] $locator + * @param ReflectionParameter[] $parameters + * @param mixed[] $locator * * @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters * is provided with this method. */ - private function getArgumentsForParametersFromWiring($parameters, $locator) + private function getArgumentsForParametersFromWiring(array $parameters, array $locator) : array { $arguments = []; - foreach ($parameters as $index => $parameter) { - $typeHint = $parameter->getClass() ? $parameter->getClass()->getName() : null; + foreach ($parameters as $parameter) { + $class = $parameter->getClass(); + $typeHint = null; + if ($class !== null) { + $typeHint = $class->getName(); + } + if (isset($locator[$typeHint])) { $arguments[] = $locator[$typeHint]; continue; @@ -260,14 +288,12 @@ private function getArgumentsForParametersFromWiring($parameters, $locator) * Retrieves a series of ReflectionParameter objects for the static 'create' method of the given * tag handler class name. * - * @param string $handlerClassName - * - * @return \ReflectionParameter[] + * @return ReflectionParameter[] */ - private function fetchParametersForHandlerFactoryMethod($handlerClassName) + private function fetchParametersForHandlerFactoryMethod(string $handlerClassName) : array { - if (! isset($this->tagHandlerParameterCache[$handlerClassName])) { - $methodReflection = new \ReflectionMethod($handlerClassName, 'create'); + if (!isset($this->tagHandlerParameterCache[$handlerClassName])) { + $methodReflection = new ReflectionMethod($handlerClassName, 'create'); $this->tagHandlerParameterCache[$handlerClassName] = $methodReflection->getParameters(); } @@ -275,39 +301,39 @@ private function fetchParametersForHandlerFactoryMethod($handlerClassName) } /** - * Returns a copy of this class' Service Locator with added dynamic parameters, such as the tag's name, body and - * Context. + * Returns a copy of this class' Service Locator with added dynamic parameters, + * such as the tag's name, body and Context. * - * @param TypeContext $context The Context (namespace and aliasses) that may be passed and is used to resolve FQSENs. - * @param string $tagName The name of the tag that may be passed onto the factory method of the Tag class. - * @param string $tagBody The body of the tag that may be passed onto the factory method of the Tag class. + * @param TypeContext $context The Context (namespace and aliasses) that may be + * passed and is used to resolve FQSENs. + * @param string $tagName The name of the tag that may be + * passed onto the factory method of the Tag class. + * @param string $tagBody The body of the tag that may be + * passed onto the factory method of the Tag class. * * @return mixed[] */ - private function getServiceLocatorWithDynamicParameters(TypeContext $context, $tagName, $tagBody) - { - $locator = array_merge( + private function getServiceLocatorWithDynamicParameters( + TypeContext $context, + string $tagName, + string $tagBody + ) : array { + return array_merge( $this->serviceLocator, [ - 'name' => $tagName, - 'body' => $tagBody, - TypeContext::class => $context + 'name' => $tagName, + 'body' => $tagBody, + TypeContext::class => $context, ] ); - - return $locator; } /** * Returns whether the given tag belongs to an annotation. * - * @param string $tagContent - * * @todo this method should be populated once we implement Annotation notation support. - * - * @return bool */ - private function isAnnotation($tagContent) + private function isAnnotation(string $tagContent) : bool { // 1. Contains a namespace separator // 2. Contains parenthesis diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tag.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tag.php index e7653678..647f018f 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tag.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tag.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -16,11 +17,14 @@ interface Tag { - public function getName(); + public function getName() : string; - public static function create($body); + /** + * @return Tag|mixed Class that implements Tag + */ + public static function create(string $body); - public function render(Formatter $formatter = null); + public function render(?Formatter $formatter = null) : string; - public function __toString(); + public function __toString() : string; } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/TagFactory.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/TagFactory.php index 3c1d1132..1a2dc893 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/TagFactory.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/TagFactory.php @@ -1,17 +1,19 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; +use InvalidArgumentException; use phpDocumentor\Reflection\Types\Context as TypeContext; interface TagFactory @@ -34,60 +36,49 @@ interface TagFactory * * These parameters are injected at the last moment and will override any existing parameter with those names. * - * @param string $name - * @param mixed $value - * - * @return void + * @param mixed $value */ - public function addParameter($name, $value); + public function addParameter(string $name, $value) : void; /** - * Registers a service with the Service Locator using the FQCN of the class or the alias, if provided. - * - * When calling a tag's "create" method we always check the signature for dependencies to inject. If a parameter - * has a typehint then the ServiceLocator is queried to see if a Service is registered for that typehint. + * Factory method responsible for instantiating the correct sub type. * - * Because interfaces are regularly used as type-hints this method provides an alias parameter; if the FQCN of the - * interface is passed as alias then every time that interface is requested the provided service will be returned. + * @param string $tagLine The text for this tag, including description. * - * @param object $service - * @param string $alias + * @return Tag A new tag object. * - * @return void + * @throws InvalidArgumentException If an invalid tag line was presented. */ - public function addService($service); + public function create(string $tagLine, ?TypeContext $context = null) : Tag; /** - * Factory method responsible for instantiating the correct sub type. - * - * @param string $tagLine The text for this tag, including description. - * @param TypeContext $context + * Registers a service with the Service Locator using the FQCN of the class or the alias, if provided. * - * @throws \InvalidArgumentException if an invalid tag line was presented. + * When calling a tag's "create" method we always check the signature for dependencies to inject. If a parameter + * has a typehint then the ServiceLocator is queried to see if a Service is registered for that typehint. * - * @return Tag A new tag object. + * Because interfaces are regularly used as type-hints this method provides an alias parameter; if the FQCN of the + * interface is passed as alias then every time that interface is requested the provided service will be returned. */ - public function create($tagLine, TypeContext $context = null); + public function addService(object $service) : void; /** * Registers a handler for tags. * - * If you want to use your own tags then you can use this method to instruct the TagFactory to register the name - * of a tag with the FQCN of a 'Tag Handler'. The Tag handler should implement the {@see Tag} interface (and thus - * the create method). + * If you want to use your own tags then you can use this method to instruct the TagFactory + * to register the name of a tag with the FQCN of a 'Tag Handler'. The Tag handler should implement + * the {@see Tag} interface (and thus the create method). * - * @param string $tagName Name of tag to register a handler for. When registering a namespaced tag, the full - * name, along with a prefixing slash MUST be provided. + * @param string $tagName Name of tag to register a handler for. When registering a namespaced tag, + * the full name, along with a prefixing slash MUST be provided. * @param string $handler FQCN of handler. * - * @throws \InvalidArgumentException if the tag name is not a string - * @throws \InvalidArgumentException if the tag name is namespaced (contains backslashes) but does not start with - * a backslash - * @throws \InvalidArgumentException if the handler is not a string - * @throws \InvalidArgumentException if the handler is not an existing class - * @throws \InvalidArgumentException if the handler does not implement the {@see Tag} interface - * - * @return void + * @throws InvalidArgumentException If the tag name is not a string. + * @throws InvalidArgumentException If the tag name is namespaced (contains backslashes) but + * does not start with a backslash. + * @throws InvalidArgumentException If the handler is not a string. + * @throws InvalidArgumentException If the handler is not an existing class. + * @throws InvalidArgumentException If the handler does not implement the {@see Tag} interface. */ - public function registerTagHandler($tagName, $handler); + public function registerTagHandler(string $tagName, string $handler) : void; } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Author.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Author.php index 29d7f1de..4bebe494 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Author.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Author.php @@ -1,18 +1,24 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; -use Webmozart\Assert\Assert; +use InvalidArgumentException; +use const FILTER_VALIDATE_EMAIL; +use function filter_var; +use function preg_match; +use function strlen; +use function trim; /** * Reflection class for an {@}author tag in a Docblock. @@ -30,16 +36,11 @@ final class Author extends BaseTag implements Factory\StaticMethod /** * Initializes this tag with the author name and e-mail. - * - * @param string $authorName - * @param string $authorEmail */ - public function __construct($authorName, $authorEmail) + public function __construct(string $authorName, string $authorEmail) { - Assert::string($authorName); - Assert::string($authorEmail); if ($authorEmail && !filter_var($authorEmail, FILTER_VALIDATE_EMAIL)) { - throw new \InvalidArgumentException('The author tag does not have a valid e-mail address'); + throw new InvalidArgumentException('The author tag does not have a valid e-mail address'); } $this->authorName = $authorName; @@ -51,7 +52,7 @@ public function __construct($authorName, $authorEmail) * * @return string The author's name. */ - public function getAuthorName() + public function getAuthorName() : string { return $this->authorName; } @@ -61,39 +62,31 @@ public function getAuthorName() * * @return string The author's email. */ - public function getEmail() + public function getEmail() : string { return $this->authorEmail; } /** * Returns this tag in string form. - * - * @return string */ - public function __toString() + public function __toString() : string { return $this->authorName . (strlen($this->authorEmail) ? ' <' . $this->authorEmail . '>' : ''); } /** * Attempts to create a new Author object based on †he tag body. - * - * @param string $body - * - * @return static */ - public static function create($body) + public static function create(string $body) : ?self { - Assert::string($body); - $splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches); if (!$splitTagContent) { return null; } $authorName = trim($matches[1]); - $email = isset($matches[2]) ? trim($matches[2]) : ''; + $email = isset($matches[2]) ? trim($matches[2]) : ''; return new static($authorName, $email); } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php index 14bb7177..fbcd4022 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/BaseTag.php @@ -1,13 +1,14 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; @@ -31,17 +32,17 @@ abstract class BaseTag implements DocBlock\Tag * * @return string The name of this tag. */ - public function getName() + public function getName() : string { return $this->name; } - public function getDescription() + public function getDescription() : ?Description { return $this->description; } - public function render(Formatter $formatter = null) + public function render(?Formatter $formatter = null) : string { if ($formatter === null) { $formatter = new Formatter\PassthroughFormatter(); diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Covers.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Covers.php index 8d65403f..5d165f80 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Covers.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Covers.php @@ -1,13 +1,14 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; @@ -18,26 +19,25 @@ use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_split; /** * Reflection class for a @covers tag in a Docblock. */ final class Covers extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'covers'; /** @var Fqsen */ - private $refers = null; + private $refers; /** * Initializes this tag. - * - * @param Fqsen $refers - * @param Description $description */ - public function __construct(Fqsen $refers, Description $description = null) + public function __construct(Fqsen $refers, ?Description $description = null) { - $this->refers = $refers; + $this->refers = $refers; $this->description = $description; } @@ -45,38 +45,36 @@ public function __construct(Fqsen $refers, Description $description = null) * {@inheritdoc} */ public static function create( - $body, - DescriptionFactory $descriptionFactory = null, - FqsenResolver $resolver = null, - TypeContext $context = null - ) { - Assert::string($body); + string $body, + ?DescriptionFactory $descriptionFactory = null, + ?FqsenResolver $resolver = null, + ?TypeContext $context = null + ) : self { Assert::notEmpty($body); + Assert::notNull($descriptionFactory); + Assert::notNull($resolver); $parts = preg_split('/\s+/Su', $body, 2); + Assert::isArray($parts); return new static( $resolver->resolve($parts[0], $context), - $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context) + $descriptionFactory->create($parts[1] ?? '', $context) ); } /** * Returns the structural element this tag refers to. - * - * @return Fqsen */ - public function getReference() + public function getReference() : Fqsen { return $this->refers; } /** * Returns a string representation of this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { return $this->refers . ($this->description ? ' ' . $this->description->render() : ''); } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Deprecated.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Deprecated.php index 822c3050..130d8449 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Deprecated.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Deprecated.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -16,19 +17,21 @@ use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_match; /** * Reflection class for a {@}deprecated tag in a Docblock. */ final class Deprecated extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'deprecated'; /** * PCRE regular expression matching a version vector. * Assumes the "x" modifier. */ - const REGEX_VECTOR = '(?: + public const REGEX_VECTOR = '(?: # Normal release vectors. \d\S* | @@ -40,23 +43,25 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod [^\s\:]+\:\s*\$[^\$]+\$ )'; - /** @var string The version vector. */ + /** @var string|null The version vector. */ private $version = ''; - public function __construct($version = null, Description $description = null) + public function __construct(?string $version = null, ?Description $description = null) { Assert::nullOrStringNotEmpty($version); - $this->version = $version; + $this->version = $version; $this->description = $description; } /** * @return static */ - public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) - { - Assert::nullOrString($body); + public static function create( + ?string $body, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { if (empty($body)) { return new static(); } @@ -65,33 +70,30 @@ public static function create($body, DescriptionFactory $descriptionFactory = nu if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { return new static( null, - null !== $descriptionFactory ? $descriptionFactory->create($body, $context) : null + $descriptionFactory !== null ? $descriptionFactory->create($body, $context) : null ); } + Assert::notNull($descriptionFactory); return new static( $matches[1], - $descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context) + $descriptionFactory->create($matches[2] ?? '', $context) ); } /** * Gets the version section of the tag. - * - * @return string */ - public function getVersion() + public function getVersion() : ?string { return $this->version; } /** * Returns a string representation for this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { - return $this->version . ($this->description ? ' ' . $this->description->render() : ''); + return ($this->version ?? '') . ($this->description ? ' ' . $this->description->render() : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Example.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Example.php index ecb199b4..d27ed477 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Example.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Example.php @@ -1,29 +1,33 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; -use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\Tag; use Webmozart\Assert\Assert; +use function array_key_exists; +use function preg_match; +use function rawurlencode; +use function str_replace; +use function strpos; +use function trim; /** * Reflection class for a {@}example tag in a Docblock. */ -final class Example extends BaseTag +final class Example implements Tag, Factory\StaticMethod { - /** - * @var string Path to a file to use as an example. May also be an absolute URI. - */ + /** @var string Path to a file to use as an example. May also be an absolute URI. */ private $filePath; /** @@ -32,72 +36,72 @@ final class Example extends BaseTag */ private $isURI = false; - /** - * @var int - */ + /** @var int */ private $startingLine; - /** - * @var int - */ + /** @var int */ private $lineCount; - public function __construct($filePath, $isURI, $startingLine, $lineCount, $description) + /** @var string|null */ + private $content; + + public function __construct(string $filePath, bool $isURI, int $startingLine, int $lineCount, ?string $content) { Assert::notEmpty($filePath); - Assert::integer($startingLine); Assert::greaterThanEq($startingLine, 0); + Assert::greaterThanEq($lineCount, 0); - $this->filePath = $filePath; + $this->filePath = $filePath; $this->startingLine = $startingLine; - $this->lineCount = $lineCount; - $this->name = 'example'; - if ($description !== null) { - $this->description = trim($description); + $this->lineCount = $lineCount; + if ($content !== null) { + $this->content = trim((string) $content); } $this->isURI = $isURI; } - /** - * {@inheritdoc} - */ - public function getContent() + public function getContent() : string { - if (null === $this->description) { + if ($this->content === null) { $filePath = '"' . $this->filePath . '"'; if ($this->isURI) { $filePath = $this->isUriRelative($this->filePath) ? str_replace('%2F', '/', rawurlencode($this->filePath)) - :$this->filePath; + : $this->filePath; } - return trim($filePath . ' ' . parent::getDescription()); + return trim($filePath); } - return $this->description; + return $this->content; + } + + public function getDescription() : ?string + { + return $this->content; } /** * {@inheritdoc} */ - public static function create($body) + public static function create(string $body) : ?Tag { // File component: File path in quotes or File URI / Source information - if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) { + if (!preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) { return null; } $filePath = null; $fileUri = null; - if ('' !== $matches[1]) { + if ($matches[1] !== '') { $filePath = $matches[1]; } else { $fileUri = $matches[2]; } $startingLine = 1; - $lineCount = null; + $lineCount = 0; $description = null; if (array_key_exists(3, $matches)) { @@ -105,9 +109,9 @@ public static function create($body) // Starting line / Number of lines / Description if (preg_match('/^([1-9]\d*)(?:\s+((?1))\s*)?(.*)$/sux', $matches[3], $contentMatches)) { - $startingLine = (int)$contentMatches[1]; + $startingLine = (int) $contentMatches[1]; if (isset($contentMatches[2]) && $contentMatches[2] !== '') { - $lineCount = (int)$contentMatches[2]; + $lineCount = (int) $contentMatches[2]; } if (array_key_exists(3, $contentMatches)) { @@ -117,7 +121,7 @@ public static function create($body) } return new static( - $filePath !== null?$filePath:$fileUri, + $filePath ?? ($fileUri ?? ''), $fileUri !== null, $startingLine, $lineCount, @@ -131,46 +135,48 @@ public static function create($body) * @return string Path to a file to use as an example. * May also be an absolute URI. */ - public function getFilePath() + public function getFilePath() : string { return $this->filePath; } /** * Returns a string representation for this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { - return $this->filePath . ($this->description ? ' ' . $this->description : ''); + return $this->filePath . ($this->content ? ' ' . $this->content : ''); } /** * Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute). - * - * @param string $uri - * - * @return bool */ - private function isUriRelative($uri) + private function isUriRelative(string $uri) : bool { - return false === strpos($uri, ':'); + return strpos($uri, ':') === false; } - /** - * @return int - */ - public function getStartingLine() + public function getStartingLine() : int { return $this->startingLine; } - /** - * @return int - */ - public function getLineCount() + public function getLineCount() : int { return $this->lineCount; } + + public function getName() : string + { + return 'example'; + } + + public function render(?Formatter $formatter = null) : string + { + if ($formatter === null) { + $formatter = new Formatter\PassthroughFormatter(); + } + + return $formatter->format($this); + } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/StaticMethod.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/StaticMethod.php index 98aea455..b21a3f02 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/StaticMethod.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/StaticMethod.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -14,5 +15,8 @@ interface StaticMethod { - public static function create($body); + /** + * @return mixed + */ + public static function create(string $body); } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/Strategy.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/Strategy.php deleted file mode 100644 index b9ca0b8a..00000000 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/Strategy.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org - */ - -namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; - -interface Strategy -{ - public function create($body); -} diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter.php index 64b2c603..92fb9e6c 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,10 +19,6 @@ interface Formatter { /** * Formats a tag into a string representation according to a specific format, such as Markdown. - * - * @param Tag $tag - * - * @return string */ - public function format(Tag $tag); + public function format(Tag $tag) : string; } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/AlignFormatter.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/AlignFormatter.php index ceb40cc3..b1a406c0 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/AlignFormatter.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/AlignFormatter.php @@ -1,13 +1,13 @@ - * @copyright 2017 Mike van Riel - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -15,6 +15,9 @@ use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\Tags\Formatter; +use function max; +use function str_repeat; +use function strlen; class AlignFormatter implements Formatter { @@ -22,8 +25,6 @@ class AlignFormatter implements Formatter protected $maxLen = 0; /** - * Constructor. - * * @param Tag[] $tags All tags that should later be aligned with the formatter. */ public function __construct(array $tags) @@ -35,13 +36,14 @@ public function __construct(array $tags) /** * Formats the given tag to return a simple plain text version. - * - * @param Tag $tag - * - * @return string */ - public function format(Tag $tag) + public function format(Tag $tag) : string { - return '@' . $tag->getName() . str_repeat(' ', $this->maxLen - strlen($tag->getName()) + 1) . (string)$tag; + return '@' . $tag->getName() . + str_repeat( + ' ', + $this->maxLen - strlen($tag->getName()) + 1 + ) . + $tag; } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/PassthroughFormatter.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/PassthroughFormatter.php index 4e2c5762..f26d22fb 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/PassthroughFormatter.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/PassthroughFormatter.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -14,18 +15,15 @@ use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\Tags\Formatter; +use function trim; class PassthroughFormatter implements Formatter { /** * Formats the given tag to return a simple plain text version. - * - * @param Tag $tag - * - * @return string */ - public function format(Tag $tag) + public function format(Tag $tag) : string { - return trim('@' . $tag->getName() . ' ' . (string)$tag); + return trim('@' . $tag->getName() . ' ' . $tag); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Generic.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Generic.php index e4c53e00..7509ff1a 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Generic.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Generic.php @@ -1,88 +1,79 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; +use InvalidArgumentException; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\StandardTagFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_match; /** * Parses a tag definition for a DocBlock. */ -class Generic extends BaseTag implements Factory\StaticMethod +final class Generic extends BaseTag implements Factory\StaticMethod { /** * Parses a tag and populates the member variables. * - * @param string $name Name of the tag. + * @param string $name Name of the tag. * @param Description $description The contents of the given tag. */ - public function __construct($name, Description $description = null) + public function __construct(string $name, ?Description $description = null) { $this->validateTagName($name); - $this->name = $name; + $this->name = $name; $this->description = $description; } /** * Creates a new tag that represents any unknown tag type. * - * @param string $body - * @param string $name - * @param DescriptionFactory $descriptionFactory - * @param TypeContext $context - * * @return static */ public static function create( - $body, - $name = '', - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { - Assert::string($body); + string $body, + string $name = '', + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($name); Assert::notNull($descriptionFactory); - $description = $descriptionFactory && $body ? $descriptionFactory->create($body, $context) : null; + $description = $body !== '' ? $descriptionFactory->create($body, $context) : null; return new static($name, $description); } /** * Returns the tag as a serialized string - * - * @return string */ - public function __toString() + public function __toString() : string { - return ($this->description ? $this->description->render() : ''); + return $this->description ? $this->description->render() : ''; } /** * Validates if the tag name matches the expected format, otherwise throws an exception. - * - * @param string $name - * - * @return void */ - private function validateTagName($name) + private function validateTagName(string $name) : void { - if (! preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) { - throw new \InvalidArgumentException( + if (!preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) { + throw new InvalidArgumentException( 'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, ' . 'hyphens and backslashes.' ); diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/InvalidTag.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/InvalidTag.php new file mode 100644 index 00000000..a531c036 --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/InvalidTag.php @@ -0,0 +1,133 @@ +name = $name; + $this->body = $body; + } + + public function getException() : ?Throwable + { + return $this->throwable; + } + + public function getName() : string + { + return $this->name; + } + + /** + * @return self + * + * @inheritDoc + */ + public static function create(string $body, string $name = '') + { + return new self($name, $body); + } + + public function withError(Throwable $exception) : self + { + $this->flattenExceptionBacktrace($exception); + $tag = new self($this->name, $this->body); + $tag->throwable = $exception; + + return $tag; + } + + /** + * Removes all complex types from backtrace + * + * Not all objects are serializable. So we need to remove them from the + * stored exception to be sure that we do not break existing library usage. + */ + private function flattenExceptionBacktrace(Throwable $exception) : void + { + $traceProperty = (new ReflectionClass('Exception'))->getProperty('trace'); + $traceProperty->setAccessible(true); + + $flatten = + /** @param mixed $value */ + static function (&$value) : void { + if ($value instanceof Closure) { + $closureReflection = new ReflectionFunction($value); + $value = sprintf( + '(Closure at %s:%s)', + $closureReflection->getFileName(), + $closureReflection->getStartLine() + ); + } elseif (is_object($value)) { + $value = sprintf('object(%s)', get_class($value)); + } elseif (is_resource($value)) { + $value = sprintf('resource(%s)', get_resource_type($value)); + } + }; + + do { + $trace = array_map( + static function (array $call) use ($flatten) : array { + array_walk_recursive($call['args'], $flatten); + + return $call; + }, + $exception->getTrace() + ); + $traceProperty->setValue($exception, $trace); + $exception = $exception->getPrevious(); + } while ($exception !== null); + + $traceProperty->setAccessible(false); + } + + public function render(?Formatter $formatter = null) : string + { + if ($formatter === null) { + $formatter = new Formatter\PassthroughFormatter(); + } + + return $formatter->format($this); + } + + public function __toString() : string + { + return $this->body; + } +} diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Link.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Link.php index 9c0e367e..a50c813a 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Link.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Link.php @@ -1,13 +1,14 @@ - * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; @@ -16,61 +17,57 @@ use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_split; /** * Reflection class for a @link tag in a Docblock. */ final class Link extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'link'; /** @var string */ - private $link = ''; + private $link; /** * Initializes a link to a URL. - * - * @param string $link - * @param Description $description */ - public function __construct($link, Description $description = null) + public function __construct(string $link, ?Description $description = null) { - Assert::string($link); - - $this->link = $link; + $this->link = $link; $this->description = $description; } /** * {@inheritdoc} */ - public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) - { - Assert::string($body); + public static function create( + string $body, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::notNull($descriptionFactory); $parts = preg_split('/\s+/Su', $body, 2); + Assert::isArray($parts); $description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null; return new static($parts[0], $description); } /** - * Gets the link - * - * @return string - */ - public function getLink() + * Gets the link + */ + public function getLink() : string { return $this->link; } /** * Returns a string representation for this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { return $this->link . ($this->description ? ' ' . $this->description->render() : ''); } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Method.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Method.php index 75225299..c7a00e4d 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Method.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Method.php @@ -1,36 +1,50 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; +use InvalidArgumentException; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; +use phpDocumentor\Reflection\Types\Mixed_; use phpDocumentor\Reflection\Types\Void_; use Webmozart\Assert\Assert; +use function array_keys; +use function explode; +use function implode; +use function is_string; +use function preg_match; +use function sort; +use function strpos; +use function substr; +use function trim; +use function var_export; /** * Reflection class for an {@}method in a Docblock. */ final class Method extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'method'; /** @var string */ private $methodName = ''; - /** @var string[] */ + /** @var string[][] */ private $arguments = []; /** @var bool */ @@ -39,15 +53,19 @@ final class Method extends BaseTag implements Factory\StaticMethod /** @var Type */ private $returnType; + /** + * @param mixed[][] $arguments + * + * @psalm-param array|string> $arguments + */ public function __construct( - $methodName, + string $methodName, array $arguments = [], - Type $returnType = null, - $static = false, - Description $description = null + ?Type $returnType = null, + bool $static = false, + ?Description $description = null ) { Assert::stringNotEmpty($methodName); - Assert::boolean($static); if ($returnType === null) { $returnType = new Void_(); @@ -64,13 +82,14 @@ public function __construct( * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : ?self { Assert::stringNotEmpty($body); - Assert::allNotNull([ $typeResolver, $descriptionFactory ]); + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); // 1. none or more whitespace // 2. optionally the keyword "static" followed by whitespace @@ -91,23 +110,19 @@ public static function create( )? # Return type (?: - ( + ( (?:[\w\|_\\\\]*\$this[\w\|_\\\\]*) | (?: (?:[\w\|_\\\\]+) - # array notation + # array notation (?:\[\])* )* ) \s+ )? - # Legacy method name (not captured) - (?: - [\w_]+\(\)\s+ - )? # Method name - ([\w\|_\\\\]+) + ([\w_]+) # Arguments (?: \(([^\)]*)\) @@ -122,9 +137,9 @@ public static function create( return null; } - list(, $static, $returnType, $methodName, $arguments, $description) = $matches; + [, $static, $returnType, $methodName, $arguments, $description] = $matches; - $static = $static === 'static'; + $static = $static === 'static'; if ($returnType === '') { $returnType = 'void'; @@ -133,23 +148,23 @@ public static function create( $returnType = $typeResolver->resolve($returnType, $context); $description = $descriptionFactory->create($description, $context); - if (is_string($arguments) && strlen($arguments) > 0) { + if ($arguments !== '') { $arguments = explode(',', $arguments); foreach ($arguments as &$argument) { $argument = explode(' ', self::stripRestArg(trim($argument)), 2); if ($argument[0][0] === '$') { $argumentName = substr($argument[0], 1); - $argumentType = new Void_(); + $argumentType = new Mixed_(); } else { $argumentType = $typeResolver->resolve($argument[0], $context); $argumentName = ''; if (isset($argument[1])) { - $argument[1] = self::stripRestArg($argument[1]); + $argument[1] = self::stripRestArg($argument[1]); $argumentName = substr($argument[1], 1); } } - $argument = [ 'name' => $argumentName, 'type' => $argumentType]; + $argument = ['name' => $argumentName, 'type' => $argumentType]; } } else { $arguments = []; @@ -160,18 +175,16 @@ public static function create( /** * Retrieves the method name. - * - * @return string */ - public function getMethodName() + public function getMethodName() : string { return $this->methodName; } /** - * @return string[] + * @return string[][] */ - public function getArguments() + public function getArguments() : array { return $this->arguments; } @@ -181,20 +194,17 @@ public function getArguments() * * @return bool TRUE if the method declaration is for a static method, FALSE otherwise. */ - public function isStatic() + public function isStatic() : bool { return $this->isStatic; } - /** - * @return Type - */ - public function getReturnType() + public function getReturnType() : Type { return $this->returnType; } - public function __toString() + public function __toString() : string { $arguments = []; foreach ($this->arguments as $argument) { @@ -202,36 +212,47 @@ public function __toString() } return trim(($this->isStatic() ? 'static ' : '') - . (string)$this->returnType . ' ' + . (string) $this->returnType . ' ' . $this->methodName . '(' . implode(', ', $arguments) . ')' . ($this->description ? ' ' . $this->description->render() : '')); } - private function filterArguments($arguments) + /** + * @param mixed[][]|string[] $arguments + * + * @return mixed[][] + * + * @psalm-param array|string> $arguments + * @psalm-return array> $arguments + */ + private function filterArguments(array $arguments = []) : array { - foreach ($arguments as &$argument) { + $result = []; + foreach ($arguments as $argument) { if (is_string($argument)) { - $argument = [ 'name' => $argument ]; + $argument = ['name' => $argument]; } - if (! isset($argument['type'])) { - $argument['type'] = new Void_(); + if (!isset($argument['type'])) { + $argument['type'] = new Mixed_(); } $keys = array_keys($argument); sort($keys); - if ($keys !== [ 'name', 'type' ]) { - throw new \InvalidArgumentException( + if ($keys !== ['name', 'type']) { + throw new InvalidArgumentException( 'Arguments can only have the "name" and "type" fields, found: ' . var_export($keys, true) ); } + + $result[] = $argument; } - return $arguments; + return $result; } - private static function stripRestArg($argument) + private static function stripRestArg(string $argument) : string { if (strpos($argument, '...') === 0) { $argument = trim(substr($argument, 3)); diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Param.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Param.php index 7d699d88..658ea973 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Param.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Param.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,75 +19,81 @@ use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use const PREG_SPLIT_DELIM_CAPTURE; +use function array_shift; +use function array_unshift; +use function implode; +use function preg_split; +use function strlen; +use function strpos; +use function substr; /** * Reflection class for the {@}param tag in a Docblock. */ -final class Param extends BaseTag implements Factory\StaticMethod +final class Param extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'param'; - - /** @var Type */ - private $type; - - /** @var string */ - private $variableName = ''; + /** @var string|null */ + private $variableName; /** @var bool determines whether this is a variadic argument */ - private $isVariadic = false; - - /** - * @param string $variableName - * @param Type $type - * @param bool $isVariadic - * @param Description $description - */ - public function __construct($variableName, Type $type = null, $isVariadic = false, Description $description = null) - { - Assert::string($variableName); - Assert::boolean($isVariadic); + private $isVariadic; + public function __construct( + ?string $variableName, + ?Type $type = null, + bool $isVariadic = false, + ?Description $description = null + ) { + $this->name = 'param'; $this->variableName = $variableName; - $this->type = $type; - $this->isVariadic = $isVariadic; - $this->description = $description; + $this->type = $type; + $this->isVariadic = $isVariadic; + $this->description = $description; } /** * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); + + [$firstPart, $body] = self::extractTypeFromBody($body); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); - $type = null; + $type = null; + $parts = preg_split('/(\s+)/Su', $body, 2, PREG_SPLIT_DELIM_CAPTURE); $variableName = ''; - $isVariadic = false; + $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); - if (substr($variableName, 0, 3) === '...') { - $isVariadic = true; + if ($variableName !== null && strpos($variableName, '...') === 0) { + $isVariadic = true; $variableName = substr($variableName, 3); } - if (substr($variableName, 0, 1) === '$') { + if ($variableName !== null && strpos($variableName, '$') === 0) { $variableName = substr($variableName, 1); } } @@ -98,44 +105,28 @@ public static function create( /** * Returns the variable's name. - * - * @return string */ - public function getVariableName() + public function getVariableName() : ?string { 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. - * - * @return boolean */ - public function isVariadic() + public function isVariadic() : bool { return $this->isVariadic; } /** * Returns a string representation for this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { return ($this->type ? $this->type . ' ' : '') - . ($this->isVariadic() ? '...' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . ($this->isVariadic() ? '...' : '') + . ($this->variableName !== null ? '$' . $this->variableName : '') + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php index f0ef7c07..81bff40c 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Property.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,63 +19,65 @@ use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use const PREG_SPLIT_DELIM_CAPTURE; +use function array_shift; +use function array_unshift; +use function implode; +use function preg_split; +use function strlen; +use function strpos; +use function substr; /** * Reflection class for a {@}property tag in a Docblock. */ -class Property extends BaseTag implements Factory\StaticMethod +final class Property extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'property'; - - /** @var Type */ - private $type; - - /** @var string */ + /** @var string|null */ protected $variableName = ''; - /** - * @param string $variableName - * @param Type $type - * @param Description $description - */ - public function __construct($variableName, Type $type = null, Description $description = null) + public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null) { Assert::string($variableName); + $this->name = 'property'; $this->variableName = $variableName; - $this->type = $type; - $this->description = $description; + $this->type = $type; + $this->description = $description; } /** * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); - $type = null; - $variableName = ''; + [$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 - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { + if (isset($parts[0]) && ($parts[0] !== '') && (strpos($parts[0], '$') === 0)) { $variableName = array_shift($parts); array_shift($parts); - if (substr($variableName, 0, 1) === '$') { + if ($variableName !== null && strpos($variableName, '$') === 0) { $variableName = substr($variableName, 1); } } @@ -86,33 +89,19 @@ public static function create( /** * Returns the variable's name. - * - * @return string */ - public function getVariableName() + public function getVariableName() : ?string { 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. - * - * @return string */ - public function __toString() + public function __toString() : string { return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . ($this->variableName ? '$' . $this->variableName : '') + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php index e41c0c1c..a1f8c8a5 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyRead.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,63 +19,65 @@ use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use const PREG_SPLIT_DELIM_CAPTURE; +use function array_shift; +use function array_unshift; +use function implode; +use function preg_split; +use function strlen; +use function strpos; +use function substr; /** * Reflection class for a {@}property-read tag in a Docblock. */ -class PropertyRead extends BaseTag implements Factory\StaticMethod +final class PropertyRead extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'property-read'; - - /** @var Type */ - private $type; - - /** @var string */ + /** @var string|null */ protected $variableName = ''; - /** - * @param string $variableName - * @param Type $type - * @param Description $description - */ - public function __construct($variableName, Type $type = null, Description $description = null) + public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null) { Assert::string($variableName); + $this->name = 'property-read'; $this->variableName = $variableName; - $this->type = $type; - $this->description = $description; + $this->type = $type; + $this->description = $description; } /** * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); - $type = null; - $variableName = ''; + [$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 - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { + if (isset($parts[0]) && ($parts[0] !== '') && (strpos($parts[0], '$') === 0)) { $variableName = array_shift($parts); array_shift($parts); - if (substr($variableName, 0, 1) === '$') { + if ($variableName !== null && strpos($variableName, '$') === 0) { $variableName = substr($variableName, 1); } } @@ -86,33 +89,19 @@ public static function create( /** * Returns the variable's name. - * - * @return string */ - public function getVariableName() + public function getVariableName() : ?string { 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. - * - * @return string */ - public function __toString() + public function __toString() : string { return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . ($this->variableName ? '$' . $this->variableName : '') + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php index cfdb0ed0..ae57fdc3 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/PropertyWrite.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,55 +19,57 @@ use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use const PREG_SPLIT_DELIM_CAPTURE; +use function array_shift; +use function array_unshift; +use function implode; +use function preg_split; +use function strlen; +use function strpos; +use function substr; /** * Reflection class for a {@}property-write tag in a Docblock. */ -class PropertyWrite extends BaseTag implements Factory\StaticMethod +final 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 Description $description - */ - public function __construct($variableName, Type $type = null, Description $description = null) + public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null) { Assert::string($variableName); + $this->name = 'property-write'; $this->variableName = $variableName; - $this->type = $type; - $this->description = $description; + $this->type = $type; + $this->description = $description; } /** * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); - $type = null; - $variableName = ''; + [$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 @@ -74,7 +77,7 @@ public static function create( $variableName = array_shift($parts); array_shift($parts); - if (substr($variableName, 0, 1) === '$') { + if ($variableName !== null && strpos($variableName, '$') === 0) { $variableName = substr($variableName, 1); } } @@ -86,33 +89,19 @@ public static function create( /** * Returns the variable's name. - * - * @return string */ - public function getVariableName() + public function getVariableName() : ?string { 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. - * - * @return string */ - public function __toString() + public function __toString() : string { return ($this->type ? $this->type . ' ' : '') - . '$' . $this->variableName - . ($this->description ? ' ' . $this->description : ''); + . ($this->variableName ? '$' . $this->variableName : '') + . ($this->description ? ' ' . $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Fqsen.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Fqsen.php index dc7b8b6d..cede74c1 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Fqsen.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Fqsen.php @@ -1,13 +1,14 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference; @@ -15,18 +16,13 @@ use phpDocumentor\Reflection\Fqsen as RealFqsen; /** - * Fqsen reference used by {@see phpDocumentor\Reflection\DocBlock\Tags\See} + * Fqsen reference used by {@see \phpDocumentor\Reflection\DocBlock\Tags\See} */ final class Fqsen implements Reference { - /** - * @var RealFqsen - */ + /** @var RealFqsen */ private $fqsen; - /** - * Fqsen constructor. - */ public function __construct(RealFqsen $fqsen) { $this->fqsen = $fqsen; @@ -35,8 +31,8 @@ public function __construct(RealFqsen $fqsen) /** * @return string string representation of the referenced fqsen */ - public function __toString() + public function __toString() : string { - return (string)$this->fqsen; + return (string) $this->fqsen; } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Reference.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Reference.php index a3ffd24c..5eedcbc3 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Reference.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Reference.php @@ -1,21 +1,22 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference; /** - * Interface for references in {@see phpDocumentor\Reflection\DocBlock\Tags\See} + * Interface for references in {@see \phpDocumentor\Reflection\DocBlock\Tags\See} */ interface Reference { - public function __toString(); + public function __toString() : string; } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php index 2671d5e1..1b2374b9 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php @@ -1,13 +1,14 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference; @@ -15,25 +16,20 @@ use Webmozart\Assert\Assert; /** - * Url reference used by {@see phpDocumentor\Reflection\DocBlock\Tags\See} + * Url reference used by {@see \phpDocumentor\Reflection\DocBlock\Tags\See} */ final class Url implements Reference { - /** - * @var string - */ + /** @var string */ private $uri; - /** - * Url constructor. - */ - public function __construct($uri) + public function __construct(string $uri) { Assert::stringNotEmpty($uri); $this->uri = $uri; } - public function __toString() + public function __toString() : string { return $this->uri; } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php index ca5bda70..96808757 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -22,16 +23,12 @@ /** * 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) + public function __construct(Type $type, ?Description $description = null) { - $this->type = $type; + $this->name = 'return'; + $this->type = $type; $this->description = $description; } @@ -39,34 +36,24 @@ public function __construct(Type $type, Description $description = null) * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { - Assert::string($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); - $parts = preg_split('/\s+/Su', $body, 2); + [$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() + public function __toString() : string { - return $this->type . ' ' . $this->description; + return ($this->type ?: 'mixed') . ' ' . (string) $this->description; } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/See.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/See.php index 9e9e723b..21d85910 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/See.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/See.php @@ -1,13 +1,14 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; @@ -20,26 +21,26 @@ use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_match; +use function preg_split; /** * Reflection class for an {@}see tag in a Docblock. */ -class See extends BaseTag implements Factory\StaticMethod +final class See extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'see'; /** @var Reference */ - protected $refers = null; + protected $refers; /** * Initializes this tag. - * - * @param Reference $refers - * @param Description $description */ - public function __construct(Reference $refers, Description $description = null) + public function __construct(Reference $refers, ?Description $description = null) { - $this->refers = $refers; + $this->refers = $refers; $this->description = $description; } @@ -47,15 +48,16 @@ public function __construct(Reference $refers, Description $description = null) * {@inheritdoc} */ public static function create( - $body, - FqsenResolver $resolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { - Assert::string($body); - Assert::allNotNull([$resolver, $descriptionFactory]); + string $body, + ?FqsenResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); - $parts = preg_split('/\s+/Su', $body, 2); + $parts = preg_split('/\s+/Su', $body, 2); + Assert::isArray($parts); $description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null; // https://tools.ietf.org/html/rfc2396#section-3 @@ -63,25 +65,21 @@ public static function create( return new static(new Url($parts[0]), $description); } - return new static(new FqsenRef($resolver->resolve($parts[0], $context)), $description); + return new static(new FqsenRef($typeResolver->resolve($parts[0], $context)), $description); } /** * Returns the ref of this tag. - * - * @return Reference */ - public function getReference() + public function getReference() : Reference { return $this->refers; } /** * Returns a string representation of this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { return $this->refers . ($this->description ? ' ' . $this->description->render() : ''); } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php index 835fb0dc..31ce54c9 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -16,19 +17,21 @@ use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_match; /** * Reflection class for a {@}since tag in a Docblock. */ final class Since extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'since'; /** * PCRE regular expression matching a version vector. * Assumes the "x" modifier. */ - const REGEX_VECTOR = '(?: + public const REGEX_VECTOR = '(?: # Normal release vectors. \d\S* | @@ -40,10 +43,10 @@ final class Since extends BaseTag implements Factory\StaticMethod [^\s\:]+\:\s*\$[^\$]+\$ )'; - /** @var string The version vector. */ + /** @var string|null The version vector. */ private $version = ''; - public function __construct($version = null, Description $description = null) + public function __construct(?string $version = null, ?Description $description = null) { Assert::nullOrStringNotEmpty($version); @@ -51,44 +54,40 @@ public function __construct($version = null, Description $description = null) $this->description = $description; } - /** - * @return static - */ - public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) - { - Assert::nullOrString($body); + public static function create( + ?string $body, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : ?self { if (empty($body)) { return new static(); } $matches = []; - if (! preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { + if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { return null; } + Assert::notNull($descriptionFactory); return new static( $matches[1], - $descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context) + $descriptionFactory->create($matches[2] ?? '', $context) ); } /** * Gets the version section of the tag. - * - * @return string */ - public function getVersion() + public function getVersion() : ?string { return $this->version; } /** * Returns a string representation for this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { - return $this->version . ($this->description ? ' ' . $this->description->render() : ''); + return (string) $this->version . ($this->description ? ' ' . (string) $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Source.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Source.php index 247b1b3b..b678806e 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Source.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Source.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -16,6 +17,7 @@ use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_match; /** * Reflection class for a {@}source tag in a Docblock. @@ -29,23 +31,30 @@ final class Source extends BaseTag implements Factory\StaticMethod private $startingLine = 1; /** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */ - private $lineCount = null; + private $lineCount; - public function __construct($startingLine, $lineCount = null, Description $description = null) + /** + * @param int|string $startingLine should be a to int convertible value + * @param int|string|null $lineCount should be a to int convertible value + */ + public function __construct($startingLine, $lineCount = null, ?Description $description = null) { Assert::integerish($startingLine); Assert::nullOrIntegerish($lineCount); - $this->startingLine = (int)$startingLine; - $this->lineCount = $lineCount !== null ? (int)$lineCount : null; + $this->startingLine = (int) $startingLine; + $this->lineCount = $lineCount !== null ? (int) $lineCount : null; $this->description = $description; } /** * {@inheritdoc} */ - public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) - { + public static function create( + string $body, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($body); Assert::notNull($descriptionFactory); @@ -55,15 +64,15 @@ public static function create($body, DescriptionFactory $descriptionFactory = nu // Starting line / Number of lines / Description if (preg_match('/^([1-9]\d*)\s*(?:((?1))\s+)?(.*)$/sux', $body, $matches)) { - $startingLine = (int)$matches[1]; + $startingLine = (int) $matches[1]; if (isset($matches[2]) && $matches[2] !== '') { - $lineCount = (int)$matches[2]; + $lineCount = (int) $matches[2]; } $description = $matches[3]; } - return new static($startingLine, $lineCount, $descriptionFactory->create($description, $context)); + return new static($startingLine, $lineCount, $descriptionFactory->create($description??'', $context)); } /** @@ -72,7 +81,7 @@ public static function create($body, DescriptionFactory $descriptionFactory = nu * @return int The starting line, relative to the structural element's * location. */ - public function getStartingLine() + public function getStartingLine() : int { return $this->startingLine; } @@ -83,15 +92,15 @@ public function getStartingLine() * @return int|null The number of lines, relative to the starting line. NULL * means "to the end". */ - public function getLineCount() + public function getLineCount() : ?int { return $this->lineCount; } - public function __toString() + public function __toString() : string { return $this->startingLine - . ($this->lineCount !== null ? ' ' . $this->lineCount : '') - . ($this->description ? ' ' . $this->description->render() : ''); + . ($this->lineCount !== null ? ' ' . $this->lineCount : '') + . ($this->description ? ' ' . (string) $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php new file mode 100644 index 00000000..9cd485cb --- /dev/null +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/TagWithType.php @@ -0,0 +1,65 @@ +type; + } + + /** + * @return string[] + */ + 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++; + continue; + } + + if (in_array($character, ['>', ')', ']', '}'])) { + $nestingLevel--; + continue; + } + } + + $description = trim(substr($body, strlen($type))); + + return [$type, $description]; + } +} diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php index 349e773b..549883aa 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Throws.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -22,15 +23,11 @@ /** * 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) + public function __construct(Type $type, ?Description $description = null) { + $this->name = 'throws'; $this->type = $type; $this->description = $description; } @@ -39,34 +36,24 @@ public function __construct(Type $type, Description $description = null) * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { - Assert::string($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); - $parts = preg_split('/\s+/Su', $body, 2); + [$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() + public function __toString() : string { - return $this->type . ' ' . $this->description; + return (string) $this->type . ' ' . (string) $this->description; } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Uses.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Uses.php index 00dc3e3b..7a69642d 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Uses.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Uses.php @@ -1,13 +1,14 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; @@ -18,24 +19,23 @@ use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_split; /** * Reflection class for a {@}uses tag in a Docblock. */ final class Uses extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'uses'; /** @var Fqsen */ - protected $refers = null; + protected $refers; /** * Initializes this tag. - * - * @param Fqsen $refers - * @param Description $description */ - public function __construct(Fqsen $refers, Description $description = null) + public function __construct(Fqsen $refers, ?Description $description = null) { $this->refers = $refers; $this->description = $description; @@ -45,39 +45,37 @@ public function __construct(Fqsen $refers, Description $description = null) * {@inheritdoc} */ public static function create( - $body, - FqsenResolver $resolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { - Assert::string($body); - Assert::allNotNull([$resolver, $descriptionFactory]); + string $body, + ?FqsenResolver $resolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { + Assert::notNull($resolver); + Assert::notNull($descriptionFactory); $parts = preg_split('/\s+/Su', $body, 2); + Assert::isArray($parts); + Assert::allString($parts); return new static( $resolver->resolve($parts[0], $context), - $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context) + $descriptionFactory->create($parts[1] ?? '', $context) ); } /** * Returns the structural element this tag refers to. - * - * @return Fqsen */ - public function getReference() + public function getReference() : Fqsen { return $this->refers; } /** * Returns a string representation of this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { - return $this->refers . ' ' . $this->description->render(); + return $this->refers . ' ' . (string) $this->description; } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php index 8907c951..8f1ae426 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Var_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,30 +19,28 @@ use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use const PREG_SPLIT_DELIM_CAPTURE; +use function array_shift; +use function array_unshift; +use function implode; +use function preg_split; +use function strlen; +use function strpos; +use function substr; /** * Reflection class for a {@}var tag in a Docblock. */ -class Var_ extends BaseTag implements Factory\StaticMethod +final class Var_ extends TagWithType implements Factory\StaticMethod { - /** @var string */ - protected $name = 'var'; - - /** @var Type */ - private $type; - - /** @var string */ + /** @var string|null */ protected $variableName = ''; - /** - * @param string $variableName - * @param Type $type - * @param Description $description - */ - public function __construct($variableName, Type $type = null, Description $description = null) + public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null) { Assert::string($variableName); + $this->name = 'var'; $this->variableName = $variableName; $this->type = $type; $this->description = $description; @@ -51,30 +50,35 @@ public function __construct($variableName, Type $type = null, Description $descr * {@inheritdoc} */ public static function create( - $body, - TypeResolver $typeResolver = null, - DescriptionFactory $descriptionFactory = null, - TypeContext $context = null - ) { + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : self { Assert::stringNotEmpty($body); - Assert::allNotNull([$typeResolver, $descriptionFactory]); + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); + + [$firstPart, $body] = self::extractTypeFromBody($body); - $parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE); + $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 - if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) { + if (isset($parts[0]) && ($parts[0] !== '') && (strpos($parts[0], '$') === 0)) { $variableName = array_shift($parts); array_shift($parts); - if (substr($variableName, 0, 1) === '$') { + if ($variableName !== null && strpos($variableName, '$') === 0) { $variableName = substr($variableName, 1); } } @@ -86,33 +90,19 @@ public static function create( /** * Returns the variable's name. - * - * @return string */ - public function getVariableName() + public function getVariableName() : ?string { 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. - * - * @return string */ - public function __toString() + public function __toString() : string { return ($this->type ? $this->type . ' ' : '') - . (empty($this->variableName) ? null : ('$' . $this->variableName)) + . (empty($this->variableName) ? '' : ('$' . $this->variableName)) . ($this->description ? ' ' . $this->description : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Version.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Version.php index 7bb04207..7fdb590b 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Version.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Version.php @@ -1,13 +1,14 @@ - * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) - * @license http://www.opensource.org/licenses/mit-license.php MIT - * @link http://phpdoc.org + * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock\Tags; @@ -16,19 +17,21 @@ use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\Types\Context as TypeContext; use Webmozart\Assert\Assert; +use function preg_match; /** * Reflection class for a {@}version tag in a Docblock. */ final class Version extends BaseTag implements Factory\StaticMethod { + /** @var string */ protected $name = 'version'; /** * PCRE regular expression matching a version vector. * Assumes the "x" modifier. */ - const REGEX_VECTOR = '(?: + public const REGEX_VECTOR = '(?: # Normal release vectors. \d\S* | @@ -40,23 +43,22 @@ final class Version extends BaseTag implements Factory\StaticMethod [^\s\:]+\:\s*\$[^\$]+\$ )'; - /** @var string The version vector. */ + /** @var string|null The version vector. */ private $version = ''; - public function __construct($version = null, Description $description = null) + public function __construct(?string $version = null, ?Description $description = null) { Assert::nullOrStringNotEmpty($version); - $this->version = $version; + $this->version = $version; $this->description = $description; } - /** - * @return static - */ - public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null) - { - Assert::nullOrString($body); + public static function create( + ?string $body, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ) : ?self { if (empty($body)) { return new static(); } @@ -66,29 +68,31 @@ public static function create($body, DescriptionFactory $descriptionFactory = nu return null; } + $description = null; + if ($descriptionFactory !== null) { + $description = $descriptionFactory->create($matches[2] ?? '', $context); + } + return new static( $matches[1], - $descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context) + $description ); } /** * Gets the version section of the tag. - * - * @return string */ - public function getVersion() + public function getVersion() : ?string { return $this->version; } /** * Returns a string representation for this tag. - * - * @return string */ - public function __toString() + public function __toString() : string { - return $this->version . ($this->description ? ' ' . $this->description->render() : ''); + return ((string) $this->version) . + ($this->description instanceof Description ? ' ' . $this->description->render() : ''); } } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php index 1bdb8f4d..1e669b5e 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php @@ -1,22 +1,35 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use InvalidArgumentException; +use LogicException; use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\StandardTagFactory; -use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\TagFactory; use Webmozart\Assert\Assert; +use function array_shift; +use function count; +use function explode; +use function is_object; +use function method_exists; +use function preg_match; +use function preg_replace; +use function str_replace; +use function strpos; +use function substr; +use function trim; final class DocBlockFactory implements DocBlockFactoryInterface { @@ -28,27 +41,22 @@ final class DocBlockFactory implements DocBlockFactoryInterface /** * Initializes this factory with the required subcontractors. - * - * @param DescriptionFactory $descriptionFactory - * @param TagFactory $tagFactory */ public function __construct(DescriptionFactory $descriptionFactory, TagFactory $tagFactory) { $this->descriptionFactory = $descriptionFactory; - $this->tagFactory = $tagFactory; + $this->tagFactory = $tagFactory; } /** * Factory method for easy instantiation. * * @param string[] $additionalTags - * - * @return DocBlockFactory */ - public static function createInstance(array $additionalTags = []) + public static function createInstance(array $additionalTags = []) : self { - $fqsenResolver = new FqsenResolver(); - $tagFactory = new StandardTagFactory($fqsenResolver); + $fqsenResolver = new FqsenResolver(); + $tagFactory = new StandardTagFactory($fqsenResolver); $descriptionFactory = new DescriptionFactory($tagFactory); $tagFactory->addService($descriptionFactory); @@ -65,17 +73,13 @@ public static function createInstance(array $additionalTags = []) /** * @param object|string $docblock A string containing the DocBlock to parse or an object supporting the * getDocComment method (such as a ReflectionClass object). - * @param Types\Context $context - * @param Location $location - * - * @return DocBlock */ - public function create($docblock, Types\Context $context = null, Location $location = null) + public function create($docblock, ?Types\Context $context = null, ?Location $location = null) : DocBlock { if (is_object($docblock)) { if (!method_exists($docblock, 'getDocComment')) { $exceptionMessage = 'Invalid object passed; the given object must support the getDocComment method'; - throw new \InvalidArgumentException($exceptionMessage); + throw new InvalidArgumentException($exceptionMessage); } $docblock = $docblock->getDocComment(); @@ -88,14 +92,13 @@ public function create($docblock, Types\Context $context = null, Location $locat } $parts = $this->splitDocBlock($this->stripDocComment($docblock)); - list($templateMarker, $summary, $description, $tags) = $parts; + + [$templateMarker, $summary, $description, $tags] = $parts; return new DocBlock( $summary, $description ? $this->descriptionFactory->create($description, $context) : null, - array_filter($this->parseTagBlock($tags, $context), function ($tag) { - return $tag instanceof Tag; - }), + $this->parseTagBlock($tags, $context), $context, $location, $templateMarker === '#@+', @@ -103,7 +106,7 @@ public function create($docblock, Types\Context $context = null, Location $locat ); } - public function registerTagHandler($tagName, $handler) + public function registerTagHandler(string $tagName, string $handler) : void { $this->tagFactory->registerTagHandler($tagName, $handler); } @@ -112,12 +115,12 @@ public function registerTagHandler($tagName, $handler) * Strips the asterisks from the DocBlock comment. * * @param string $comment String containing the comment text. - * - * @return string */ - private function stripDocComment($comment) + private function stripDocComment(string $comment) : string { - $comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment)); + /** @var string $comment */ + $comment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment); + $comment = trim($comment); // reg ex above is not able to remove */ from a single line docblock if (substr($comment, -2) === '*/') { @@ -127,17 +130,19 @@ private function stripDocComment($comment) return str_replace(["\r\n", "\r"], "\n", $comment); } + // phpcs:disable SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden /** * Splits the DocBlock into a template marker, summary, description and block of tags. * * @param string $comment Comment to split into the sub-parts. * - * @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split. + * @return string[] containing the template marker (if any), summary, description and a string containing the tags. + * * @author Mike van Riel for extending the regex with template marker support. * - * @return string[] containing the template marker (if any), summary, description and a string containing the tags. + * @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split. */ - private function splitDocBlock($comment) + private function splitDocBlock(string $comment) : array { // Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This // method does not split tags so we return this verbatim as the fourth result (tags). This saves us the @@ -147,6 +152,7 @@ private function splitDocBlock($comment) } // clears all extra horizontal whitespace from the line endings to prevent parsing issues + /** @var string $comment */ $comment = preg_replace('/\h*$/Sum', '', $comment); /* @@ -176,7 +182,7 @@ private function splitDocBlock($comment) [^\n.]+ (?: (?! \. \n | \n{2} ) # End summary upon a dot followed by newline or two newlines - [\n.] (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line + [\n.]* (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line [^\n.]+ # Include anything else )* \.? @@ -214,20 +220,21 @@ private function splitDocBlock($comment) /** * Creates the tag objects. * - * @param string $tags Tag block to parse. + * @param string $tags Tag block to parse. * @param Types\Context $context Context of the parsed Tag * * @return DocBlock\Tag[] */ - private function parseTagBlock($tags, Types\Context $context) + private function parseTagBlock(string $tags, Types\Context $context) : array { $tags = $this->filterTagBlock($tags); - if (!$tags) { + if ($tags === null) { return []; } - $result = $this->splitTagBlockIntoTagLines($tags); - foreach ($result as $key => $tagLine) { + $result = []; + $lines = $this->splitTagBlockIntoTagLines($tags); + foreach ($lines as $key => $tagLine) { $result[$key] = $this->tagFactory->create(trim($tagLine), $context); } @@ -235,11 +242,9 @@ private function parseTagBlock($tags, Types\Context $context) } /** - * @param string $tags - * * @return string[] */ - private function splitTagBlockIntoTagLines($tags) + private function splitTagBlockIntoTagLines(string $tags) : array { $result = []; foreach (explode("\n", $tags) as $tag_line) { @@ -253,22 +258,18 @@ private function splitTagBlockIntoTagLines($tags) return $result; } - /** - * @param $tags - * @return string - */ - private function filterTagBlock($tags) + private function filterTagBlock(string $tags) : ?string { $tags = trim($tags); if (!$tags) { return null; } - if ('@' !== $tags[0]) { + if ($tags[0] !== '@') { // @codeCoverageIgnoreStart // Can't simulate this; this only happens if there is an error with the parsing of the DocBlock that // we didn't foresee. - throw new \LogicException('A tag block started with text instead of an at-sign(@): ' . $tags); + throw new LogicException('A tag block started with text instead of an at-sign(@): ' . $tags); // @codeCoverageIgnoreEnd } diff --git a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactoryInterface.php b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactoryInterface.php index b3533429..c1619569 100644 --- a/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactoryInterface.php +++ b/includes/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactoryInterface.php @@ -1,23 +1,21 @@ 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 +124,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 +138,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 +154,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 +163,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/includes/vendor/phpdocumentor/type-resolver/appveyor.yml b/includes/vendor/phpdocumentor/type-resolver/appveyor.yml new file mode 100644 index 00000000..9dda46ca --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/appveyor.yml @@ -0,0 +1,52 @@ +build: false +clone_folder: c:\typeresolver +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:\typeresolver + - composer install --no-interaction --prefer-dist --no-progress + +test_script: + - cd c:\typeresolver + - vendor\bin\phpunit --no-coverage diff --git a/includes/vendor/phpdocumentor/type-resolver/composer-require-config.json b/includes/vendor/phpdocumentor/type-resolver/composer-require-config.json new file mode 100644 index 00000000..19eee4ff --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/composer-require-config.json @@ -0,0 +1,15 @@ +{ + "symbol-whitelist" : [ + "null", "true", "false", + "static", "self", "parent", + "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor" + ], + "php-core-extensions" : [ + "Core", + "pcre", + "Reflection", + "tokenizer", + "SPL", + "standard" + ] +} diff --git a/includes/vendor/phpdocumentor/type-resolver/composer.json b/includes/vendor/phpdocumentor/type-resolver/composer.json index 82ead156..f784935c 100644 --- a/includes/vendor/phpdocumentor/type-resolver/composer.json +++ b/includes/vendor/phpdocumentor/type-resolver/composer.json @@ -1,27 +1,36 @@ { - "name": "phpdocumentor/type-resolver", - "type": "library", + "name": "phpdocumentor/type-resolver", + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "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", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "mockery/mockery": "~1", + "ext-tokenizer": "^7.1", + "phpunit/phpunit": "^7.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/unit" + } }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } } } diff --git a/includes/vendor/phpdocumentor/type-resolver/composer.lock b/includes/vendor/phpdocumentor/type-resolver/composer.lock new file mode 100644 index 00000000..529abe60 --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/composer.lock @@ -0,0 +1,1448 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "8168e5df1ad1444a9512e8b63bab2bfe", + "packages": [ + { + "name": "phpdocumentor/reflection-common", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2018-08-07T13:53:10+00:00" + } + ], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "a2c590166b2133a4633738648b6b064edae0814a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2019-03-17T17:37:11+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2016-01-20T08:20:44+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2", + "reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~2.0", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2019-02-13T09:37:52+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2019-04-07T13:18:21+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2016-01-25T08:17:30+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "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" + }, + "require-dev": { + "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" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2018-08-05T17:53:17+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "6.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.1 || ^4.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "suggest": { + "ext-xdebug": "^2.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2018-10-31T16:06:48+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "050bedf145a257b1ff02746c31894800e5122946" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2018-09-13T20:33:42+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "2.1.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2019-06-07T04:22:29+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2018-10-30T05:52:18+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "7.5.12", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.1", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^4.0", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0", + "sebastian/version": "^2.0.1" + }, + "conflict": { + "phpunit/phpunit-mock-objects": "*" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*", + "phpunit/php-invoker": "^2.0" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2019-05-28T11:59:40+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "shasum": "" + }, + "require": { + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2018-07-12T15:12:46+00:00" + }, + { + "name": "sebastian/diff", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2019-02-04T06:01:07+00:00" + }, + { + "name": "sebastian/environment", + "version": "4.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2019-05-05T09:05:15+00:00" + }, + { + "name": "sebastian/exporter", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "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" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2017-04-03T13:19:02+00:00" + }, + { + "name": "sebastian/global-state", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2017-04-27T15:39:26+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2017-03-03T06:23:57+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2018-10-04T04:07:39+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8", + "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2019-04-04T09:56:43+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^7.1" + }, + "platform-dev": { + "ext-tokenizer": "^7.1" + } +} diff --git a/includes/vendor/phpdocumentor/type-resolver/phive.xml b/includes/vendor/phpdocumentor/type-resolver/phive.xml new file mode 100644 index 00000000..9908931e --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/phive.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/vendor/phpdocumentor/type-resolver/phpcs.xml.dist b/includes/vendor/phpdocumentor/type-resolver/phpcs.xml.dist new file mode 100644 index 00000000..c030e8de --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/phpcs.xml.dist @@ -0,0 +1,30 @@ + + + The coding standard for phpDocumentor. + + src + tests/unit + */tests/unit/Types/ContextFactoryTest.php + + + *\.php + + + + + + + + */src/*_.php + + + + */src/*/Abstract*.php + + + + + + + + diff --git a/includes/vendor/phpdocumentor/type-resolver/phpstan.neon b/includes/vendor/phpdocumentor/type-resolver/phpstan.neon new file mode 100644 index 00000000..73a7e516 --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/phpstan.neon @@ -0,0 +1,7 @@ +parameters: + ignoreErrors: + - + message: '#Parameter \#1 \$types of class phpDocumentor\\Reflection\\Types\\Compound constructor expects array, array given\.#' + path: %currentWorkingDirectory%/tests/unit/Types/CompoundTest.php + - message: '#Parameter \#2 \$fileContents of method phpDocumentor\\Reflection\\Types\\ContextFactory::createForNamespace\(\) expects string, string|false given\.#' + path: %currentWorkingDirectory%/tests/unit/Types/ContextFactoryTest.php diff --git a/includes/vendor/phpdocumentor/type-resolver/psalm.xml b/includes/vendor/phpdocumentor/type-resolver/psalm.xml new file mode 100644 index 00000000..9fedb8ab --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/psalm.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/includes/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php b/includes/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php index 9aa6ba30..1f9fe501 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php @@ -1,25 +1,30 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use InvalidArgumentException; use phpDocumentor\Reflection\Types\Context; +use function explode; +use function implode; +use function strpos; class FqsenResolver { /** @var string Definition of the NAMESPACE operator in PHP */ - const OPERATOR_NAMESPACE = '\\'; + private const OPERATOR_NAMESPACE = '\\'; - public function resolve($fqsen, Context $context = null) + public function resolve(string $fqsen, ?Context $context = null) : Fqsen { if ($context === null) { $context = new Context(''); @@ -34,12 +39,8 @@ public function resolve($fqsen, Context $context = null) /** * Tests whether the given type is a Fully Qualified Structural Element Name. - * - * @param string $type - * - * @return bool */ - private function isFqsen($type) + private function isFqsen(string $type) : bool { return strpos($type, self::OPERATOR_NAMESPACE) === 0; } @@ -48,13 +49,9 @@ private function isFqsen($type) * Resolves a partial Structural Element Name (i.e. `Reflection\DocBlock`) to its FQSEN representation * (i.e. `\phpDocumentor\Reflection\DocBlock`) based on the Namespace and aliases mentioned in the Context. * - * @param string $type - * @param Context $context - * - * @return Fqsen - * @throws \InvalidArgumentException when type is not a valid FQSEN. + * @throws InvalidArgumentException When type is not a valid FQSEN. */ - private function resolvePartialStructuralElementName($type, Context $context) + private function resolvePartialStructuralElementName(string $type, Context $context) : Fqsen { $typeParts = explode(self::OPERATOR_NAMESPACE, $type, 2); @@ -63,7 +60,7 @@ private function resolvePartialStructuralElementName($type, Context $context) // if the first segment is not an alias; prepend namespace name and return if (!isset($namespaceAliases[$typeParts[0]])) { $namespace = $context->getNamespace(); - if ('' !== $namespace) { + if ($namespace !== '') { $namespace .= self::OPERATOR_NAMESPACE; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Type.php b/includes/vendor/phpdocumentor/type-resolver/src/Type.php index 33ca5595..fc931ebd 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Type.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Type.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -14,5 +15,8 @@ interface Type { - public function __toString(); + /** + * Returns a rendered output of the Type as it would be used in a DocBlock. + */ + public function __toString() : string; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/TypeResolver.php b/includes/vendor/phpdocumentor/type-resolver/src/TypeResolver.php index 08b2a5f8..d849d5a3 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/TypeResolver.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/TypeResolver.php @@ -1,39 +1,76 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection; +use ArrayIterator; +use InvalidArgumentException; use phpDocumentor\Reflection\Types\Array_; +use phpDocumentor\Reflection\Types\Collection; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Context; +use phpDocumentor\Reflection\Types\Integer; use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; +use phpDocumentor\Reflection\Types\String_; +use RuntimeException; +use const PREG_SPLIT_DELIM_CAPTURE; +use const PREG_SPLIT_NO_EMPTY; +use function array_keys; +use function array_pop; +use function class_exists; +use function class_implements; +use function count; +use function in_array; +use function preg_split; +use function strlen; +use function strpos; +use function strtolower; +use function substr; +use function trim; final class TypeResolver { /** @var string Definition of the ARRAY operator for types */ - const OPERATOR_ARRAY = '[]'; + private const OPERATOR_ARRAY = '[]'; /** @var string Definition of the NAMESPACE operator in PHP */ - const OPERATOR_NAMESPACE = '\\'; + private const OPERATOR_NAMESPACE = '\\'; + + /** @var int the iterator parser is inside a compound context */ + private const PARSER_IN_COMPOUND = 0; + + /** @var int the iterator parser is inside a nullable expression context */ + private const PARSER_IN_NULLABLE = 1; - /** @var string[] List of recognized keywords and unto which Value Object they map */ - private $keywords = array( + /** @var int the iterator parser is inside an array expression context */ + private const PARSER_IN_ARRAY_EXPRESSION = 2; + + /** @var int the iterator parser is inside a collection expression context */ + private const PARSER_IN_COLLECTION_EXPRESSION = 3; + + /** + * @var array List of recognized keywords and unto which Value Object they map + * @psalm-var array> + */ + private $keywords = [ 'string' => Types\String_::class, 'int' => Types\Integer::class, '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, @@ -52,17 +89,15 @@ final class TypeResolver 'static' => Types\Static_::class, 'parent' => Types\Parent_::class, 'iterable' => Iterable_::class, - ); + ]; /** @var FqsenResolver */ private $fqsenResolver; /** * Initializes this TypeResolver with the means to create and resolve Fqsen objects. - * - * @param FqsenResolver $fqsenResolver */ - public function __construct(FqsenResolver $fqsenResolver = null) + public function __construct(?FqsenResolver $fqsenResolver = null) { $this->fqsenResolver = $fqsenResolver ?: new FqsenResolver(); } @@ -77,39 +112,177 @@ public function __construct(FqsenResolver $fqsenResolver = null) * This method only works as expected if the namespace and aliases are set; * no dynamic reflection is being performed here. * - * @param string $type The relative or absolute type. - * @param Context $context - * - * @uses Context::getNamespace() to determine with what to prefix the type name. * @uses Context::getNamespaceAliases() to check whether the first part of the relative type name should not be - * replaced with another namespace. + * replaced with another namespace. + * @uses Context::getNamespace() to determine with what to prefix the type name. * - * @return Type|null + * @param string $type The relative or absolute type. */ - public function resolve($type, Context $context = null) + public function resolve(string $type, ?Context $context = null) : Type { - if (!is_string($type)) { - throw new \InvalidArgumentException( - 'Attempted to resolve type but it appeared not to be a string, received: ' . var_export($type, true) - ); - } - $type = trim($type); if (!$type) { - throw new \InvalidArgumentException('Attempted to resolve "' . $type . '" but it appears to be empty'); + throw new InvalidArgumentException('Attempted to resolve "' . $type . '" but it appears to be empty'); } if ($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 + ); + + if ($tokens === false) { + throw new InvalidArgumentException('Unable to split the type string "' . $type . '" into tokens'); + } + + $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 int $parserContext on of self::PARSER_* constants, indicating + * the context where we are in the parsing + */ + private function parseTypes(ArrayIterator $tokens, Context $context, int $parserContext) : Type + { + $types = []; + $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(); + } elseif ($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); + } elseif ($token === '(') { + $tokens->next(); + $type = $this->parseTypes($tokens, $context, self::PARSER_IN_ARRAY_EXPRESSION); + + $resolvedType = new Array_($type); + + $token = $tokens->current(); + // Someone did not properly close their array expression .. + if ($token === null) { + break; + } + + // we generate arrays corresponding to the number of '[]' after the ')' + $numberOfArrays = (strlen($token) - 1) / 2; + for ($i = 0; $i < $numberOfArrays - 1; ++$i) { + $resolvedType = new Array_($resolvedType); + } + + $types[] = $resolvedType; + $tokens->next(); + } elseif ($parserContext === self::PARSER_IN_ARRAY_EXPRESSION && $token[0] === ')') { + break; + } elseif ($token === '<') { + if (count($types) === 0) { + throw new RuntimeException( + 'Unexpected collection operator "<", class name is missing' + ); + } + + $classType = array_pop($types); + if ($classType !== null) { + $types[] = $this->resolveCollection($tokens, $classType, $context); + } + + $tokens->next(); + } elseif ($parserContext === self::PARSER_IN_COLLECTION_EXPRESSION + && ($token === '>' || trim($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' + ); + } + } elseif (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 + * + * @return Type|Array_|Object_ + */ + private function resolveSingleType(string $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): @@ -119,32 +292,28 @@ public function resolve($type, Context $context = null) // @codeCoverageIgnoreStart default: // I haven't got the foggiest how the logic would come here but added this as a defense. - throw new \RuntimeException( + throw new RuntimeException( 'Unable to resolve type "' . $type . '", there is no known method to resolve it' ); } + // @codeCoverageIgnoreEnd } /** * Adds a keyword to the list of Keywords and associates it with a specific Value Object. - * - * @param string $keyword - * @param string $typeClassName - * - * @return void */ - public function addKeyword($keyword, $typeClassName) + public function addKeyword(string $keyword, string $typeClassName) : void { if (!class_exists($typeClassName)) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'The Value Object that needs to be created with a keyword "' . $keyword . '" must be an existing class' . ' but we could not find the class ' . $typeClassName ); } - if (!in_array(Type::class, class_implements($typeClassName))) { - throw new \InvalidArgumentException( + if (!in_array(Type::class, class_implements($typeClassName), true)) { + throw new InvalidArgumentException( 'The class "' . $typeClassName . '" must implement the interface "phpDocumentor\Reflection\Type"' ); } @@ -156,10 +325,8 @@ public function addKeyword($keyword, $typeClassName) * Detects whether the given type represents an array. * * @param string $type A relative or absolute type as defined in the phpDocumentor documentation. - * - * @return bool */ - private function isTypedArray($type) + private function isTypedArray(string $type) : bool { return substr($type, -2) === self::OPERATOR_ARRAY; } @@ -168,10 +335,8 @@ private function isTypedArray($type) * Detects whether the given type represents a PHPDoc keyword. * * @param string $type A relative or absolute type as defined in the phpDocumentor documentation. - * - * @return bool */ - private function isKeyword($type) + private function isKeyword(string $type) : bool { return in_array(strtolower($type), array_keys($this->keywords), true); } @@ -180,119 +345,126 @@ private function isKeyword($type) * Detects whether the given type represents a relative structural element name. * * @param string $type A relative or absolute type as defined in the phpDocumentor documentation. - * - * @return bool */ - private function isPartialStructuralElementName($type) + private function isPartialStructuralElementName(string $type) : bool { return ($type[0] !== self::OPERATOR_NAMESPACE) && !$this->isKeyword($type); } /** * Tests whether the given type is a Fully Qualified Structural Element Name. - * - * @param string $type - * - * @return bool */ - private function isFqsen($type) + private function isFqsen(string $type) : bool { 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. - * - * @param string $type - * @param Context $context - * - * @return Array_ */ - private function resolveTypedArray($type, Context $context) + private function resolveTypedArray(string $type, Context $context) : Array_ { - return new Array_($this->resolve(substr($type, 0, -2), $context)); + return new Array_($this->resolveSingleType(substr($type, 0, -2), $context)); } /** * Resolves the given keyword (such as `string`) into a Type object representing that keyword. - * - * @param string $type - * - * @return Type */ - private function resolveKeyword($type) + private function resolveKeyword(string $type) : Type { $className = $this->keywords[strtolower($type)]; - return new $className(); } /** * Resolves the given FQSEN string into an FQSEN object. - * - * @param string $type - * @param Context|null $context - * - * @return Object_ */ - private function resolveTypedObject($type, Context $context = null) + private function resolveTypedObject(string $type, ?Context $context = null) : Object_ { return new Object_($this->fqsenResolver->resolve($type, $context)); } /** - * 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 + * @return Array_|Collection */ - private function resolveCompoundType($type, Context $context) + private function resolveCollection(ArrayIterator $tokens, Type $classType, Context $context) : Type { - $types = []; + $isArray = ((string) $classType === 'array'); + + // allow only "array" or class name before "<" + if (!$isArray + && (!$classType instanceof Object_ || $classType->getFqsen() === null)) { + throw new RuntimeException( + $classType . ' is not a collection' + ); + } + + $tokens->next(); + + $valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION); + $keyType = null; - foreach (explode('|', $type) as $part) { - $types[] = $this->resolve($part, $context); + if ($tokens->current() !== null && trim($tokens->current()) === ',') { + // if we have a comma, 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); } - return new Compound($types); + if ($tokens->current() !== '>') { + if (empty($tokens->current())) { + throw new RuntimeException( + 'Collection: ">" is missing' + ); + } + + throw new RuntimeException( + 'Unexpected character "' . $tokens->current() . '", ">" is missing' + ); + } + + if ($isArray) { + return new Array_($valueType, $keyType); + } + + /** @psalm-suppress RedundantCondition */ + if ($classType instanceof Object_) { + return $this->makeCollectionFromObject($classType, $valueType, $keyType); + } + + throw new RuntimeException('Invalid $classType provided'); } - /** - * 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) + private function makeCollectionFromObject(Object_ $object, Type $valueType, ?Type $keyType = null) : Collection { - return new Nullable($this->resolve(ltrim($type, '?'), $context)); + return new Collection($object->getFqsen(), $valueType, $keyType); } } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/AbstractList.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/AbstractList.php new file mode 100644 index 00000000..06260bcc --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/AbstractList.php @@ -0,0 +1,85 @@ +valueType = $valueType; + $this->defaultKeyType = new Compound([new String_(), new Integer()]); + $this->keyType = $keyType; + } + + /** + * Returns the type for the keys of this array. + */ + public function getKeyType() : Type + { + if ($this->keyType === null) { + return $this->defaultKeyType; + } + + return $this->keyType; + } + + /** + * Returns the value for the keys of this array. + */ + public function getValueType() : Type + { + return $this->valueType; + } + + /** + * Returns a rendered output of the Type as it would be used in a DocBlock. + */ + public function __toString() : string + { + 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/includes/vendor/phpdocumentor/type-resolver/src/Types/Array_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Array_.php index 49b7c6ea..7e3b13fb 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Array_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Array_.php @@ -1,19 +1,18 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; -use phpDocumentor\Reflection\Type; - /** * Represents an array type as described in the PSR-5, the PHPDoc Standard. * @@ -23,64 +22,6 @@ * 2. Types (`string[]`), where the value type is provided by preceding an opening and closing square bracket with a * type name. */ -final class Array_ implements Type +final class Array_ extends AbstractList { - /** @var Type */ - private $valueType; - - /** @var Type */ - private $keyType; - - /** - * Initializes this representation of an array with the given Type or Fqsen. - * - * @param Type $valueType - * @param Type $keyType - */ - public function __construct(Type $valueType = null, Type $keyType = null) - { - if ($keyType === null) { - $keyType = new Compound([ new String_(), new Integer() ]); - } - if ($valueType === null) { - $valueType = new Mixed_(); - } - - $this->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/includes/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php index f82b19e5..24909176 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Boolean.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Boolean implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'bool'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Callable_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Callable_.php index 68ebfbd0..a0c37340 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Callable_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Callable_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Callable_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'callable'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Collection.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Collection.php new file mode 100644 index 00000000..8699df6b --- /dev/null +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Collection.php @@ -0,0 +1,66 @@ +` + * 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|null */ + private $fqsen; + + /** + * Initializes this representation of an array with the given Type or Fqsen. + */ + public function __construct(?Fqsen $fqsen, Type $valueType, ?Type $keyType = null) + { + parent::__construct($valueType, $keyType); + + $this->fqsen = $fqsen; + } + + /** + * Returns the FQSEN associated with this object. + */ + public function getFqsen() : ?Fqsen + { + return $this->fqsen; + } + + /** + * Returns a rendered output of the Type as it would be used in a DocBlock. + */ + public function __toString() : string + { + $objectType = (string) ($this->fqsen ?? 'object'); + + if ($this->keyType === null) { + return $objectType . '<' . $this->valueType . '>'; + } + + return $objectType . '<' . $this->keyType . ',' . $this->valueType . '>'; + } +} diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Compound.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Compound.php index be986c31..1da7bf97 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Compound.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Compound.php @@ -1,20 +1,23 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; use ArrayIterator; +use InvalidArgumentException; use IteratorAggregate; use phpDocumentor\Reflection\Type; +use function implode; /** * Value Object representing a Compound Type. @@ -32,13 +35,15 @@ final class Compound implements Type, IteratorAggregate * Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface. * * @param Type[] $types - * @throws \InvalidArgumentException when types are not all instance of Type + * + * @throws InvalidArgumentException When types are not all instance of Type. */ public function __construct(array $types) { foreach ($types as $type) { + /** @psalm-suppress RedundantConditionGivenDocblockType */ if (!$type instanceof Type) { - throw new \InvalidArgumentException('A compound type can only have other types as elements'); + throw new InvalidArgumentException('A compound type can only have other types as elements'); } } @@ -47,12 +52,8 @@ public function __construct(array $types) /** * Returns the type at the given index. - * - * @param integer $index - * - * @return Type|null */ - public function get($index) + public function get(int $index) : ?Type { if (!$this->has($index)) { return null; @@ -63,22 +64,16 @@ public function get($index) /** * Tests if this compound type has a type with the given index. - * - * @param integer $index - * - * @return bool */ - public function has($index) + public function has(int $index) : bool { return isset($this->types[$index]); } /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return implode('|', $this->types); } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Context.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Context.php index 4e9ce5a0..6e29baa7 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Context.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Context.php @@ -1,17 +1,22 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use function strlen; +use function substr; +use function trim; + /** * Provides information about the Context in which the DocBlock occurs that receives this context. * @@ -31,26 +36,27 @@ final class Context /** @var string The current namespace. */ private $namespace; - /** @var array List of namespace aliases => Fully Qualified Namespace. */ + /** @var string[] List of namespace aliases => Fully Qualified Namespace. */ private $namespaceAliases; /** * Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN) * format (without a preceding `\`). * - * @param string $namespace The namespace where this DocBlock resides in. - * @param array $namespaceAliases List of namespace aliases => Fully Qualified Namespace. + * @param string $namespace The namespace where this DocBlock resides in. + * @param string[] $namespaceAliases List of namespace aliases => Fully Qualified Namespace. */ - public function __construct($namespace, array $namespaceAliases = []) + public function __construct(string $namespace, array $namespaceAliases = []) { - $this->namespace = ('global' !== $namespace && 'default' !== $namespace) - ? trim((string)$namespace, '\\') + $this->namespace = $namespace !== 'global' && $namespace !== 'default' + ? trim($namespace, '\\') : ''; foreach ($namespaceAliases as $alias => $fqnn) { if ($fqnn[0] === '\\') { $fqnn = substr($fqnn, 1); } + if ($fqnn[strlen($fqnn) - 1] === '\\') { $fqnn = substr($fqnn, 0, -1); } @@ -63,10 +69,8 @@ public function __construct($namespace, array $namespaceAliases = []) /** * Returns the Qualified Namespace Name (thus without `\` in front) where the associated element is in. - * - * @return string */ - public function getNamespace() + public function getNamespace() : string { return $this->namespace; } @@ -77,7 +81,7 @@ public function getNamespace() * * @return string[] */ - public function getNamespaceAliases() + public function getNamespaceAliases() : array { return $this->namespaceAliases; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/ContextFactory.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/ContextFactory.php index 30936a30..851a3c22 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/ContextFactory.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/ContextFactory.php @@ -1,17 +1,44 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use ArrayIterator; +use InvalidArgumentException; +use ReflectionClass; +use ReflectionClassConstant; +use ReflectionMethod; +use ReflectionParameter; +use ReflectionProperty; +use Reflector; +use RuntimeException; +use UnexpectedValueException; +use const T_AS; +use const T_CLASS; +use const T_CURLY_OPEN; +use const T_DOLLAR_OPEN_CURLY_BRACES; +use const T_NAMESPACE; +use const T_NS_SEPARATOR; +use const T_STRING; +use const T_USE; +use function array_merge; +use function file_exists; +use function file_get_contents; +use function get_class; +use function is_string; +use function token_get_all; +use function trim; + /** * Convenience class to create a Context for DocBlocks when not using the Reflection Component of phpDocumentor. * @@ -24,31 +51,78 @@ final class ContextFactory { /** The literal used at the end of a use statement. */ - const T_LITERAL_END_OF_USE = ';'; + private const T_LITERAL_END_OF_USE = ';'; /** The literal used between sets of use statements */ - const T_LITERAL_USE_SEPARATOR = ','; + private const T_LITERAL_USE_SEPARATOR = ','; /** * Build a Context given a Class Reflection. * - * @param \Reflector $reflector - * * @see Context for more information on Contexts. - * - * @return Context */ - public function createFromReflector(\Reflector $reflector) + public function createFromReflector(Reflector $reflector) : Context + { + if ($reflector instanceof ReflectionClass) { + return $this->createFromReflectionClass($reflector); + } + + if ($reflector instanceof ReflectionParameter) { + return $this->createFromReflectionParameter($reflector); + } + + if ($reflector instanceof ReflectionMethod) { + return $this->createFromReflectionMethod($reflector); + } + + if ($reflector instanceof ReflectionProperty) { + return $this->createFromReflectionProperty($reflector); + } + + if ($reflector instanceof ReflectionClassConstant) { + return $this->createFromReflectionClassConstant($reflector); + } + + throw new UnexpectedValueException('Unhandled \Reflector instance given: ' . get_class($reflector)); + } + + private function createFromReflectionParameter(ReflectionParameter $parameter) : Context { - if (method_exists($reflector, 'getDeclaringClass')) { - $reflector = $reflector->getDeclaringClass(); + $class = $parameter->getDeclaringClass(); + if ($class) { + return $this->createFromReflectionClass($class); } - $fileName = $reflector->getFileName(); - $namespace = $reflector->getNamespaceName(); + throw new InvalidArgumentException('Unable to get class of ' . $parameter->getName()); + } + + private function createFromReflectionMethod(ReflectionMethod $method) : Context + { + return $this->createFromReflectionClass($method->getDeclaringClass()); + } + + private function createFromReflectionProperty(ReflectionProperty $property) : Context + { + return $this->createFromReflectionClass($property->getDeclaringClass()); + } + + private function createFromReflectionClassConstant(ReflectionClassConstant $constant) : Context + { + return $this->createFromReflectionClass($constant->getDeclaringClass()); + } + + private function createFromReflectionClass(ReflectionClass $class) : Context + { + $fileName = $class->getFileName(); + $namespace = $class->getNamespaceName(); + + if (is_string($fileName) && file_exists($fileName)) { + $contents = file_get_contents($fileName); + if ($contents === false) { + throw new RuntimeException('Unable to read file "' . $fileName . '"'); + } - if (file_exists($fileName)) { - return $this->createForNamespace($namespace, file_get_contents($fileName)); + return $this->createForNamespace($namespace, $contents); } return new Context($namespace, []); @@ -57,19 +131,18 @@ public function createFromReflector(\Reflector $reflector) /** * Build a Context for a namespace in the provided file contents. * - * @param string $namespace It does not matter if a `\` precedes the namespace name, this method first normalizes. - * @param string $fileContents the file's contents to retrieve the aliases from with the given namespace. - * * @see Context for more information on Contexts. * - * @return Context + * @param string $namespace It does not matter if a `\` precedes the namespace name, + * this method first normalizes. + * @param string $fileContents The file's contents to retrieve the aliases from with the given namespace. */ - public function createForNamespace($namespace, $fileContents) + public function createForNamespace(string $namespace, string $fileContents) : Context { - $namespace = trim($namespace, '\\'); - $useStatements = []; + $namespace = trim($namespace, '\\'); + $useStatements = []; $currentNamespace = ''; - $tokens = new \ArrayIterator(token_get_all($fileContents)); + $tokens = new ArrayIterator(token_get_all($fileContents)); while ($tokens->valid()) { switch ($tokens->current()[0]) { @@ -80,7 +153,7 @@ public function createForNamespace($namespace, $fileContents) // Fast-forward the iterator through the class so that any // T_USE tokens found within are skipped - these are not // valid namespace use statements so should be ignored. - $braceLevel = 0; + $braceLevel = 0; $firstBraceFound = false; while ($tokens->valid() && ($braceLevel > 0 || !$firstBraceFound)) { if ($tokens->current() === '{' @@ -89,12 +162,14 @@ public function createForNamespace($namespace, $fileContents) if (!$firstBraceFound) { $firstBraceFound = true; } - $braceLevel++; + + ++$braceLevel; } if ($tokens->current() === '}') { - $braceLevel--; + --$braceLevel; } + $tokens->next(); } break; @@ -104,6 +179,7 @@ public function createForNamespace($namespace, $fileContents) } break; } + $tokens->next(); } @@ -112,12 +188,8 @@ public function createForNamespace($namespace, $fileContents) /** * Deduce the name from tokens when we are at the T_NAMESPACE token. - * - * @param \ArrayIterator $tokens - * - * @return string */ - private function parseNamespace(\ArrayIterator $tokens) + private function parseNamespace(ArrayIterator $tokens) : string { // skip to the first string or namespace separator $this->skipToNextStringOrNamespaceSeparator($tokens); @@ -135,22 +207,18 @@ private function parseNamespace(\ArrayIterator $tokens) /** * Deduce the names of all imports when we are at the T_USE token. * - * @param \ArrayIterator $tokens - * * @return string[] */ - private function parseUseStatement(\ArrayIterator $tokens) + private function parseUseStatement(ArrayIterator $tokens) : array { $uses = []; - $continue = true; - while ($continue) { + while (true) { $this->skipToNextStringOrNamespaceSeparator($tokens); - list($alias, $fqnn) = $this->extractUseStatement($tokens); - $uses[$alias] = $fqnn; + $uses = array_merge($uses, $this->extractUseStatements($tokens)); if ($tokens->current()[0] === self::T_LITERAL_END_OF_USE) { - $continue = false; + return $uses; } } @@ -159,12 +227,8 @@ private function parseUseStatement(\ArrayIterator $tokens) /** * Fast-forwards the iterator as longs as we don't encounter a T_STRING or T_NS_SEPARATOR token. - * - * @param \ArrayIterator $tokens - * - * @return void */ - private function skipToNextStringOrNamespaceSeparator(\ArrayIterator $tokens) + private function skipToNextStringOrNamespaceSeparator(ArrayIterator $tokens) : void { while ($tokens->valid() && ($tokens->current()[0] !== T_STRING) && ($tokens->current()[0] !== T_NS_SEPARATOR)) { $tokens->next(); @@ -173,38 +237,114 @@ private function skipToNextStringOrNamespaceSeparator(\ArrayIterator $tokens) /** * Deduce the namespace name and alias of an import when we are at the T_USE token or have not reached the end of - * a USE statement yet. + * a USE statement yet. This will return a key/value array of the alias => namespace. * - * @param \ArrayIterator $tokens + * @return string[] * - * @return string + * @psalm-suppress TypeDoesNotContainType */ - private function extractUseStatement(\ArrayIterator $tokens) + private function extractUseStatements(ArrayIterator $tokens) : array { - $result = ['']; - while ($tokens->valid() - && ($tokens->current()[0] !== self::T_LITERAL_USE_SEPARATOR) - && ($tokens->current()[0] !== self::T_LITERAL_END_OF_USE) - ) { - if ($tokens->current()[0] === T_AS) { - $result[] = ''; + $extractedUseStatements = []; + $groupedNs = ''; + $currentNs = ''; + $currentAlias = ''; + $state = 'start'; + + while ($tokens->valid()) { + $currentToken = $tokens->current(); + $tokenId = is_string($currentToken) ? $currentToken : $currentToken[0]; + $tokenValue = is_string($currentToken) ? null : $currentToken[1]; + switch ($state) { + case 'start': + switch ($tokenId) { + case T_STRING: + case T_NS_SEPARATOR: + $currentNs .= $tokenValue; + $currentAlias = $tokenValue; + break; + case T_CURLY_OPEN: + case '{': + $state = 'grouped'; + $groupedNs = $currentNs; + break; + case T_AS: + $state = 'start-alias'; + break; + case self::T_LITERAL_USE_SEPARATOR: + case self::T_LITERAL_END_OF_USE: + $state = 'end'; + break; + default: + break; + } + break; + case 'start-alias': + switch ($tokenId) { + case T_STRING: + $currentAlias = $tokenValue; + break; + case self::T_LITERAL_USE_SEPARATOR: + case self::T_LITERAL_END_OF_USE: + $state = 'end'; + break; + default: + break; + } + break; + case 'grouped': + switch ($tokenId) { + case T_STRING: + case T_NS_SEPARATOR: + $currentNs .= $tokenValue; + $currentAlias = $tokenValue; + break; + case T_AS: + $state = 'grouped-alias'; + break; + case self::T_LITERAL_USE_SEPARATOR: + $state = 'grouped'; + $extractedUseStatements[$currentAlias] = $currentNs; + $currentNs = $groupedNs; + $currentAlias = ''; + break; + case self::T_LITERAL_END_OF_USE: + $state = 'end'; + break; + default: + break; + } + break; + case 'grouped-alias': + switch ($tokenId) { + case T_STRING: + $currentAlias = $tokenValue; + break; + case self::T_LITERAL_USE_SEPARATOR: + $state = 'grouped'; + $extractedUseStatements[$currentAlias] = $currentNs; + $currentNs = $groupedNs; + $currentAlias = ''; + break; + case self::T_LITERAL_END_OF_USE: + $state = 'end'; + break; + default: + break; + } } - if ($tokens->current()[0] === T_STRING || $tokens->current()[0] === T_NS_SEPARATOR) { - $result[count($result) - 1] .= $tokens->current()[1]; + + if ($state === 'end') { + break; } + $tokens->next(); } - if (count($result) == 1) { - $backslashPos = strrpos($result[0], '\\'); - - if (false !== $backslashPos) { - $result[] = substr($result[0], $backslashPos + 1); - } else { - $result[] = $result[0]; - } + if ($groupedNs !== $currentNs) { + $extractedUseStatements[$currentAlias] = $currentNs; } - return array_reverse($result); + return $extractedUseStatements; } } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Float_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Float_.php index e58d8966..7149c93a 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Float_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Float_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Float_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'float'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Integer.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Integer.php index be4555ef..25d52e74 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Integer.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Integer.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -18,10 +19,8 @@ final class Integer implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'int'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Iterable_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Iterable_.php index 0cbf48f7..49169518 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Iterable_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Iterable_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Iterable_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'iterable'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Mixed_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Mixed_.php index c1c165f4..470c60af 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Mixed_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Mixed_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Mixed_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'mixed'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Null_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Null_.php index 203b4227..725f9d8a 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Null_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Null_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Null_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'null'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Nullable.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Nullable.php index 3c6d1b13..0d38228e 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Nullable.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Nullable.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -19,15 +20,11 @@ */ final class Nullable implements Type { - /** - * @var Type - */ + /** @var Type The actual type that is wrapped */ private $realType; /** * Initialises this nullable type using the real type embedded - * - * @param Type $realType */ public function __construct(Type $realType) { @@ -36,20 +33,16 @@ public function __construct(Type $realType) /** * Provide access to the actual type directly, if needed. - * - * @return Type */ - public function getActualType() + public function getActualType() : Type { return $this->realType; } /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return '?' . $this->realType->__toString(); } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Object_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Object_.php index 389f7c70..31556999 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Object_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Object_.php @@ -1,19 +1,22 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\Types; +use InvalidArgumentException; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\Type; +use function strpos; /** * Value Object representing an object. @@ -30,15 +33,14 @@ final class Object_ implements Type /** * Initializes this object with an optional FQSEN, if not provided this object is considered 'untyped'. * - * @param Fqsen $fqsen - * @throws \InvalidArgumentException when provided $fqsen is not a valid type. + * @throws InvalidArgumentException When provided $fqsen is not a valid type. */ - public function __construct(Fqsen $fqsen = null) + public function __construct(?Fqsen $fqsen = null) { - if (strpos((string)$fqsen, '::') !== false || strpos((string)$fqsen, '()') !== false) { - throw new \InvalidArgumentException( + if (strpos((string) $fqsen, '::') !== false || strpos((string) $fqsen, '()') !== false) { + throw new InvalidArgumentException( 'Object types can only refer to a class, interface or trait but a method, function, constant or ' - . 'property was received: ' . (string)$fqsen + . 'property was received: ' . (string) $fqsen ); } @@ -47,23 +49,16 @@ public function __construct(Fqsen $fqsen = null) /** * Returns the FQSEN associated with this object. - * - * @return Fqsen|null */ - public function getFqsen() + public function getFqsen() : ?Fqsen { return $this->fqsen; } - /** - * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string - */ - public function __toString() + public function __toString() : string { if ($this->fqsen) { - return (string)$this->fqsen; + return (string) $this->fqsen; } return 'object'; diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Parent_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Parent_.php index aabdbfb3..8d7efb67 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Parent_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Parent_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -23,10 +24,8 @@ final class Parent_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'parent'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Resource_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Resource_.php index a1b613dc..b46ea9ae 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Resource_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Resource_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Resource_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'resource'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Scalar.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Scalar.php index 1e2a6602..6ce586ca 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Scalar.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Scalar.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class Scalar implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'scalar'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Self_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Self_.php index 1ba3fc5a..bcce03d9 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Self_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Self_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -23,10 +24,8 @@ final class Self_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'self'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Static_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Static_.php index 9eb67299..112bf875 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Static_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Static_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -28,10 +29,8 @@ final class Static_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'static'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/String_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/String_.php index 8db59685..2af6342e 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/String_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/String_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -21,10 +22,8 @@ final class String_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'string'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/This.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/This.php index c098a939..4e1b33d9 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/This.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/This.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -24,10 +25,8 @@ final class This implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return '$this'; } diff --git a/includes/vendor/phpdocumentor/type-resolver/src/Types/Void_.php b/includes/vendor/phpdocumentor/type-resolver/src/Types/Void_.php index 3d1be272..176039f4 100644 --- a/includes/vendor/phpdocumentor/type-resolver/src/Types/Void_.php +++ b/includes/vendor/phpdocumentor/type-resolver/src/Types/Void_.php @@ -1,12 +1,13 @@ - * @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ @@ -24,10 +25,8 @@ final class Void_ implements Type { /** * Returns a rendered output of the Type as it would be used in a DocBlock. - * - * @return string */ - public function __toString() + public function __toString() : string { return 'void'; } diff --git a/includes/vendor/phpspec/prophecy/CHANGES.md b/includes/vendor/phpspec/prophecy/CHANGES.md index fddfc412..5d82505f 100644 --- a/includes/vendor/phpspec/prophecy/CHANGES.md +++ b/includes/vendor/phpspec/prophecy/CHANGES.md @@ -1,3 +1,33 @@ +1.10.2 / 2020/01/20 +=================== + +* [added] support for new versions of (@sebastianbergmann) + +1.10.1 / 2019/12/22 +=================== + +* [fixed] identical callables no longer match as arguments (@ciaranmcnulty) + +1.10.0 / 2019/12/17 +=================== + +* [added] shouldHaveBeenCalled evaluation happens later so un-stubbed calls don't throw (@elvetemedve) +* [added] methods can now be doubled case-insensitively to match PHP semantics (@michalbundyra) +* [fixed] reduced memory usage by optimising CachedDoubler (@DonCallisto) +* [fixed] removed fatal error nesting level when comparing large objects (@scroach) + +1.9.0 / 2019/10/03 +================== + +* [added] Add willYield feature to Method Prophecy(@tkotosz) +* [fixed] Allow `MethodProphecy::willThrow()` to accept Throwable as string (@timoschinkel ) +* [fixed] Allow new version of phpdocumentor/reflection-docblock (@ricpelo) + +1.8.1 / 2019/06/13 +================== + +* [fixed] Don't try to patch final constructors (@NiR) + 1.8.0 / 2018/08/05 ================== diff --git a/includes/vendor/phpspec/prophecy/README.md b/includes/vendor/phpspec/prophecy/README.md index b190d43e..3da9b591 100644 --- a/includes/vendor/phpspec/prophecy/README.md +++ b/includes/vendor/phpspec/prophecy/README.md @@ -12,7 +12,7 @@ enough to be used inside any testing framework out there with minimal effort. ```php 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/includes/vendor/phpspec/prophecy/composer.json b/includes/vendor/phpspec/prophecy/composer.json index 816f147e..7151160f 100644 --- a/includes/vendor/phpspec/prophecy/composer.json +++ b/includes/vendor/phpspec/prophecy/composer.json @@ -19,20 +19,20 @@ "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" }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, @@ -44,7 +44,7 @@ "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } } } diff --git a/includes/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php index aa960f3f..045a1b90 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Argument/Token/ExactValueToken.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php index bc936c8f..d4bdba04 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Call/CallCenter.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php index 874e474c..fa4f578e 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php index d6b6b1a9..2b875211 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/DisableConstructorPatch.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/DisableConstructorPatch.php index 61998fc4..9d843099 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/DisableConstructorPatch.php +++ b/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/DisableConstructorPatch.php @@ -41,6 +41,10 @@ public function supports(ClassNode $node) */ public function apply(ClassNode $node) { + if (!$node->isExtendable('__construct')) { + return; + } + if (!$node->hasMethod('__construct')) { $node->addMethod(new MethodNode('__construct', '')); diff --git a/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php index 081dea82..ef403666 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php index c5f9a5c7..6dab2d94 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php index 7250fa3c..26ec19ed 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Promise/ThrowPromise.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php index 7084ed6f..f33364ce 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php index 8d8f8a1b..11b87cf1 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Prophet.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Prophet.php index a4fe4b0d..d37c92a3 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Prophet.php +++ b/includes/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/includes/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php b/includes/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php index 50dd3f32..1090a801 100644 --- a/includes/vendor/phpspec/prophecy/src/Prophecy/Util/ExportUtil.php +++ b/includes/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/includes/vendor/ralouphie/getallheaders/.gitignore b/includes/vendor/ralouphie/getallheaders/.gitignore deleted file mode 100644 index 1324e7d3..00000000 --- a/includes/vendor/ralouphie/getallheaders/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.idea -.DS_store -/vendor/ -composer.phar -composer.lock diff --git a/includes/vendor/ralouphie/getallheaders/.travis.yml b/includes/vendor/ralouphie/getallheaders/.travis.yml deleted file mode 100644 index f45b55fa..00000000 --- a/includes/vendor/ralouphie/getallheaders/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - -before_script: - - composer install - -script: - - mkdir -p build/logs - - php vendor/bin/phpunit -c phpunit.xml - -after_script: - - php vendor/bin/coveralls -v \ No newline at end of file diff --git a/includes/vendor/ralouphie/getallheaders/README.md b/includes/vendor/ralouphie/getallheaders/README.md index f3329d66..9430d76b 100644 --- a/includes/vendor/ralouphie/getallheaders/README.md +++ b/includes/vendor/ralouphie/getallheaders/README.md @@ -14,6 +14,14 @@ This is a simple polyfill for [`getallheaders()`](http://www.php.net/manual/en/f ## Install +For PHP version **`>= 5.6`**: + ``` composer require ralouphie/getallheaders ``` + +For PHP version **`< 5.6`**: + +``` +composer require ralouphie/getallheaders "^2" +``` diff --git a/includes/vendor/ralouphie/getallheaders/composer.json b/includes/vendor/ralouphie/getallheaders/composer.json index 5a0d595c..de8ce62e 100644 --- a/includes/vendor/ralouphie/getallheaders/composer.json +++ b/includes/vendor/ralouphie/getallheaders/composer.json @@ -9,13 +9,18 @@ } ], "require": { - "php": ">=5.3" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "~3.7.0", - "satooshi/php-coveralls": ">=1.0" + "phpunit/phpunit": "^5 || ^6.5", + "php-coveralls/php-coveralls": "^2.1" }, "autoload": { "files": ["src/getallheaders.php"] + }, + "autoload-dev": { + "psr-4": { + "getallheaders\\Tests\\": "tests/" + } } -} \ No newline at end of file +} diff --git a/includes/vendor/ralouphie/getallheaders/phpunit.xml b/includes/vendor/ralouphie/getallheaders/phpunit.xml deleted file mode 100644 index 7255b23d..00000000 --- a/includes/vendor/ralouphie/getallheaders/phpunit.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - ./tests - - - - - src - - - - - - - - \ No newline at end of file diff --git a/includes/vendor/ralouphie/getallheaders/tests/GetAllHeadersTest.php b/includes/vendor/ralouphie/getallheaders/tests/GetAllHeadersTest.php deleted file mode 100644 index 8e3d1790..00000000 --- a/includes/vendor/ralouphie/getallheaders/tests/GetAllHeadersTest.php +++ /dev/null @@ -1,121 +0,0 @@ - $val) { - $_SERVER[$key] = $val; - } - $result = getallheaders(); - $this->assertEquals($expected, $result, "Error testing $test_type works."); - } - - public function testWorksData() - { - return array( - array( - 'normal case', - array( - 'Key-One' => 'foo', - 'Key-Two' => 'bar', - 'Another-Key-For-Testing' => 'baz' - ), - array( - 'HTTP_KEY_ONE' => 'foo', - 'HTTP_KEY_TWO' => 'bar', - 'HTTP_ANOTHER_KEY_FOR_TESTING' => 'baz' - ) - ), - array( - 'Content-Type', - array( - 'Content-Type' => 'two' - ), - array( - 'HTTP_CONTENT_TYPE' => 'one', - 'CONTENT_TYPE' => 'two' - ) - ), - array( - 'Content-Length', - array( - 'Content-Length' => '222' - ), - array( - 'CONTENT_LENGTH' => '222', - 'HTTP_CONTENT_LENGTH' => '111' - ) - ), - array( - 'Content-Length (HTTP_CONTENT_LENGTH only)', - array( - 'Content-Length' => '111' - ), - array( - 'HTTP_CONTENT_LENGTH' => '111' - ) - ), - array( - 'Content-MD5', - array( - 'Content-Md5' => 'aef123' - ), - array( - 'CONTENT_MD5' => 'aef123', - 'HTTP_CONTENT_MD5' => 'fea321' - ) - ), - array( - 'Content-MD5 (HTTP_CONTENT_MD5 only)', - array( - 'Content-Md5' => 'f123' - ), - array( - 'HTTP_CONTENT_MD5' => 'f123' - ) - ), - array( - 'Authorization (normal)', - array( - 'Authorization' => 'testing' - ), - array( - 'HTTP_AUTHORIZATION' => 'testing', - ) - ), - array( - 'Authorization (redirect)', - array( - 'Authorization' => 'testing redirect' - ), - array( - 'REDIRECT_HTTP_AUTHORIZATION' => 'testing redirect', - ) - ), - array( - 'Authorization (PHP_AUTH_USER + PHP_AUTH_PW)', - array( - 'Authorization' => 'Basic ' . base64_encode('foo:bar') - ), - array( - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar' - ) - ), - array( - 'Authorization (PHP_AUTH_DIGEST)', - array( - 'Authorization' => 'example-digest' - ), - array( - 'PHP_AUTH_DIGEST' => 'example-digest' - ) - ) - ); - } -} diff --git a/includes/vendor/symfony/polyfill-ctype/LICENSE b/includes/vendor/symfony/polyfill-ctype/LICENSE index ad399a79..3f853aaf 100644 --- a/includes/vendor/symfony/polyfill-ctype/LICENSE +++ b/includes/vendor/symfony/polyfill-ctype/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018 Fabien Potencier +Copyright (c) 2018-2019 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/includes/vendor/symfony/polyfill-ctype/composer.json b/includes/vendor/symfony/polyfill-ctype/composer.json index 094f8d86..2a2ea044 100644 --- a/includes/vendor/symfony/polyfill-ctype/composer.json +++ b/includes/vendor/symfony/polyfill-ctype/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.13-dev" } } } diff --git a/includes/vendor/symfony/yaml/CHANGELOG.md b/includes/vendor/symfony/yaml/CHANGELOG.md index 1b07b239..fd41c9dd 100644 --- a/includes/vendor/symfony/yaml/CHANGELOG.md +++ b/includes/vendor/symfony/yaml/CHANGELOG.md @@ -113,7 +113,7 @@ CHANGELOG * Added support for customizing the dumped YAML string through an optional bit field: ```php - Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE | Yaml::DUMP_OBJECT); + Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE | Yaml::DUMP_OBJECT); ``` 3.0.0 diff --git a/includes/vendor/symfony/yaml/Command/LintCommand.php b/includes/vendor/symfony/yaml/Command/LintCommand.php index 36e7e8b9..f6732ecf 100644 --- a/includes/vendor/symfony/yaml/Command/LintCommand.php +++ b/includes/vendor/symfony/yaml/Command/LintCommand.php @@ -91,14 +91,14 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new RuntimeException('Please provide a filename or pipe file content to STDIN.'); } - return $this->display($io, array($this->validate($stdin, $flags))); + return $this->display($io, [$this->validate($stdin, $flags)]); } if (!$this->isReadable($filename)) { throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename)); } - $filesInfo = array(); + $filesInfo = []; foreach ($this->getFiles($filename) as $file) { $filesInfo[] = $this->validate(file_get_contents($file), $flags, $file); } @@ -119,12 +119,12 @@ private function validate($content, $flags, $file = null) try { $this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags); } catch (ParseException $e) { - return array('file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage()); + return ['file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage()]; } finally { restore_error_handler(); } - return array('file' => $file, 'valid' => true); + return ['file' => $file, 'valid' => true]; } private function display(SymfonyStyle $io, array $files) @@ -188,7 +188,7 @@ private function getFiles($fileOrDirectory) } foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) { - if (!\in_array($file->getExtension(), array('yml', 'yaml'))) { + if (!\in_array($file->getExtension(), ['yml', 'yaml'])) { continue; } @@ -196,10 +196,13 @@ private function getFiles($fileOrDirectory) } } + /** + * @return string|null + */ private function getStdin() { if (0 !== ftell(STDIN)) { - return; + return null; } $inputs = ''; diff --git a/includes/vendor/symfony/yaml/Dumper.php b/includes/vendor/symfony/yaml/Dumper.php index d2a2ebcf..641dcd7f 100644 --- a/includes/vendor/symfony/yaml/Dumper.php +++ b/includes/vendor/symfony/yaml/Dumper.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Yaml; +use Symfony\Component\Yaml\Tag\TaggedValue; + /** * Dumper dumps PHP variables to YAML strings. * @@ -91,7 +93,7 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0) $dumpObjectAsInlineMap = empty((array) $input); } - if ($inline <= 0 || (!\is_array($input) && $dumpObjectAsInlineMap) || empty($input)) { + if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) { $output .= $prefix.Inline::dump($input, $flags); } else { $dumpAsMap = Inline::isHash($input); @@ -103,13 +105,39 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0) $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); - foreach (preg_split('/\n|\r\n/', $value) as $row) { + foreach (explode("\n", $value) as $row) { $output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row); } continue; } + if ($value instanceof TaggedValue) { + $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); + + if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { + // If the first line starts with a space character, the spec requires a blockIndicationIndicator + // http://www.yaml.org/spec/1.2/spec.html#id2793979 + $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : ''; + $output .= sprintf(" |%s\n", $blockIndentationIndicator); + + foreach (explode("\n", $value->getValue()) as $row) { + $output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row); + } + + continue; + } + + if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) { + $output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n"; + } else { + $output .= "\n"; + $output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags); + } + + continue; + } + $dumpObjectAsInlineMap = true; if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { diff --git a/includes/vendor/symfony/yaml/Escaper.php b/includes/vendor/symfony/yaml/Escaper.php index 2b1321f6..4d3ce244 100644 --- a/includes/vendor/symfony/yaml/Escaper.php +++ b/includes/vendor/symfony/yaml/Escaper.php @@ -28,20 +28,20 @@ class Escaper // first to ensure proper escaping because str_replace operates iteratively // on the input arrays. This ordering of the characters avoids the use of strtr, // which performs more slowly. - private static $escapees = array('\\', '\\\\', '\\"', '"', + private static $escapees = ['\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", - ); - private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', + ]; + private static $escaped = ['\\\\', '\\"', '\\\\', '\\"', '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', '\\N', '\\_', '\\L', '\\P', - ); + ]; /** * Determines if a PHP value would require double quoting in YAML. @@ -78,7 +78,7 @@ public static function requiresSingleQuoting($value) { // Determines if a PHP value is entirely composed of a value that would // require single quoting in YAML. - if (\in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) { + if (\in_array(strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'])) { return true; } diff --git a/includes/vendor/symfony/yaml/Inline.php b/includes/vendor/symfony/yaml/Inline.php index 42b6cb10..73aba3cb 100644 --- a/includes/vendor/symfony/yaml/Inline.php +++ b/includes/vendor/symfony/yaml/Inline.php @@ -63,7 +63,7 @@ public static function initialize($flags, $parsedLineNumber = null, $parsedFilen * * @throws ParseException */ - public static function parse($value, $flags = 0, $references = array()) + public static function parse($value, $flags = 0, $references = []) { if (\is_bool($flags)) { @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); @@ -93,7 +93,7 @@ public static function parse($value, $flags = 0, $references = array()) if (\func_num_args() >= 5) { $references = func_get_arg(4); } else { - $references = array(); + $references = []; } } @@ -126,15 +126,15 @@ public static function parse($value, $flags = 0, $references = array()) $result = self::parseScalar($value, $flags, null, $i, null === $tag, $references); } - if (null !== $tag) { - return new TaggedValue($tag, $result); - } - // some comments are allowed at the end if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename); } + if (null !== $tag) { + return new TaggedValue($tag, $result); + } + return $result; } finally { if (isset($mbEncoding)) { @@ -285,7 +285,7 @@ private static function dumpArray($value, $flags) { // array if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) { - $output = array(); + $output = []; foreach ($value as $val) { $output[] = self::dump($val, $flags); } @@ -294,7 +294,7 @@ private static function dumpArray($value, $flags) } // hash - $output = array(); + $output = []; foreach ($value as $key => $val) { $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags)); } @@ -318,9 +318,9 @@ private static function dumpArray($value, $flags) * * @internal */ - public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array(), $legacyOmittedKeySupport = false) + public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = [], $legacyOmittedKeySupport = false) { - if (\in_array($scalar[$i], array('"', "'"))) { + if (\in_array($scalar[$i], ['"', "'"])) { // quoted scalar $output = self::parseQuotedScalar($scalar, $i); @@ -409,9 +409,9 @@ private static function parseQuotedScalar($scalar, &$i) * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseSequence($sequence, $flags, &$i = 0, $references = array()) + private static function parseSequence($sequence, $flags, &$i = 0, $references = []) { - $output = array(); + $output = []; $len = \strlen($sequence); ++$i; @@ -437,8 +437,8 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references = $value = self::parseMapping($sequence, $flags, $i, $references); break; default: - $isQuoted = \in_array($sequence[$i], array('"', "'")); - $value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references); + $isQuoted = \in_array($sequence[$i], ['"', "'"]); + $value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references); // the value can be an array if a reference has been resolved to an array var if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) { @@ -478,9 +478,9 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references = * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseMapping($mapping, $flags, &$i = 0, $references = array()) + private static function parseMapping($mapping, $flags, &$i = 0, $references = []) { - $output = array(); + $output = []; $len = \strlen($mapping); ++$i; $allowOverwrite = false; @@ -501,8 +501,13 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar } // key - $isKeyQuoted = \in_array($mapping[$i], array('"', "'"), true); - $key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true); + $isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true); + $key = self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true); + + if ('!php/const' === $key) { + $key .= self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true); + $key = self::evaluateScalar($key, $flags); + } if (':' !== $key && false === $i = strpos($mapping, ':', $i)) { break; @@ -520,7 +525,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar } } - if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) { + if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], [' ', ',', '[', ']', '{', '}'], true))) { @trigger_error(self::getDeprecationMessage('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0.'), E_USER_DEPRECATED); } @@ -578,7 +583,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar } break; default: - $value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references); + $value = self::parseScalar($mapping, $flags, [',', '}'], $i, null === $tag, $references); // Spec: Keys MUST be unique; first one wins. // Parser cannot abort this mapping earlier, since lines // are processed sequentially. @@ -616,7 +621,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar * * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved */ - private static function evaluateScalar($scalar, $flags, $references = array()) + private static function evaluateScalar($scalar, $flags, $references = []) { $scalar = trim($scalar); $scalarLower = strtolower($scalar); @@ -633,7 +638,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename); } - if (!array_key_exists($value, $references)) { + if (!\array_key_exists($value, $references)) { throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename); } @@ -644,7 +649,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) case 'null' === $scalarLower: case '' === $scalar: case '~' === $scalar: - return; + return null; case 'true' === $scalarLower: return true; case 'false' === $scalarLower: @@ -672,7 +677,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } - return; + return null; case 0 === strpos($scalar, '!!php/object:'): if (self::$objectSupport) { @trigger_error(self::getDeprecationMessage('The !!php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.1 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED); @@ -684,7 +689,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } - return; + return null; case 0 === strpos($scalar, '!php/object'): if (self::$objectSupport) { return unserialize(self::parseScalar(substr($scalar, 12))); @@ -694,7 +699,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } - return; + return null; case 0 === strpos($scalar, '!php/const:'): if (self::$constantSupport) { @trigger_error(self::getDeprecationMessage('The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead.'), E_USER_DEPRECATED); @@ -709,7 +714,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } - return; + return null; case 0 === strpos($scalar, '!php/const'): if (self::$constantSupport) { $i = 0; @@ -723,7 +728,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } - return; + return null; case 0 === strpos($scalar, '!!float '): return (float) substr($scalar, 8); case 0 === strpos($scalar, '!!binary '): @@ -735,11 +740,11 @@ private static function evaluateScalar($scalar, $flags, $references = array()) // Optimize for returning strings. // no break case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]): + if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) { + $scalar = str_replace('_', '', (string) $scalar); + } + switch (true) { - case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar): - $scalar = str_replace('_', '', (string) $scalar); - // omitting the break / return as integers are handled in the next case - // no break case ctype_digit($scalar): $raw = $scalar; $cast = (int) $scalar; @@ -749,7 +754,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) $raw = $scalar; $cast = (int) $scalar; - return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw); + return '0' == $scalar[1] ? -octdec(substr($scalar, 1)) : (($raw === (string) $cast) ? $cast : $raw); case is_numeric($scalar): case Parser::preg_match(self::getHexRegex(), $scalar): $scalar = str_replace('_', '', $scalar); @@ -766,7 +771,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) @trigger_error(self::getDeprecationMessage('Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0.'), E_USER_DEPRECATED); } - return (float) str_replace(array(',', '_'), '', $scalar); + return (float) str_replace([',', '_'], '', $scalar); case Parser::preg_match(self::getTimestampRegex(), $scalar): if (Yaml::PARSE_DATETIME & $flags) { // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. @@ -795,7 +800,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) private static function parseTag($value, &$i, $flags) { if ('!' !== $value[$i]) { - return; + return null; } $tagLength = strcspn($value, " \t\n", $i + 1); @@ -805,9 +810,9 @@ private static function parseTag($value, &$i, $flags) $nextOffset += strspn($value, ' ', $nextOffset); // Is followed by a scalar - if ((!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], array('[', '{'), true)) && 'tagged' !== $tag) { + if ((!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && 'tagged' !== $tag) { // Manage non-whitelisted scalars in {@link self::evaluateScalar()} - return; + return null; } // Built-in tags diff --git a/includes/vendor/symfony/yaml/LICENSE b/includes/vendor/symfony/yaml/LICENSE index a677f437..9e936ec0 100644 --- a/includes/vendor/symfony/yaml/LICENSE +++ b/includes/vendor/symfony/yaml/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2019 Fabien Potencier +Copyright (c) 2004-2020 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/includes/vendor/symfony/yaml/Parser.php b/includes/vendor/symfony/yaml/Parser.php index 8b3b6992..7d6112e3 100644 --- a/includes/vendor/symfony/yaml/Parser.php +++ b/includes/vendor/symfony/yaml/Parser.php @@ -29,13 +29,13 @@ class Parser private $filename; private $offset = 0; private $totalNumberOfLines; - private $lines = array(); + private $lines = []; private $currentLineNb = -1; private $currentLine = ''; - private $refs = array(); - private $skippedLineNumbers = array(); - private $locallySkippedLineNumbers = array(); - private $refsBeingParsed = array(); + private $refs = []; + private $skippedLineNumbers = []; + private $locallySkippedLineNumbers = []; + private $refsBeingParsed = []; public function __construct() { @@ -127,7 +127,7 @@ public function parse($value, $flags = 0) throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename); } - $this->refs = array(); + $this->refs = []; $mbEncoding = null; $e = null; @@ -148,11 +148,11 @@ public function parse($value, $flags = 0) mb_internal_encoding($mbEncoding); } - $this->lines = array(); + $this->lines = []; $this->currentLine = ''; - $this->refs = array(); - $this->skippedLineNumbers = array(); - $this->locallySkippedLineNumbers = array(); + $this->refs = []; + $this->skippedLineNumbers = []; + $this->locallySkippedLineNumbers = []; if (null !== $e) { throw $e; @@ -167,7 +167,7 @@ private function doParse($value, $flags) $this->currentLine = ''; $value = $this->cleanup($value); $this->lines = explode("\n", $value); - $this->locallySkippedLineNumbers = array(); + $this->locallySkippedLineNumbers = []; if (null === $this->totalNumberOfLines) { $this->totalNumberOfLines = \count($this->lines); @@ -177,7 +177,7 @@ private function doParse($value, $flags) return null; } - $data = array(); + $data = []; $context = null; $allowOverwrite = false; @@ -250,7 +250,7 @@ private function doParse($value, $flags) } } elseif ( self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P.+))?$#u', rtrim($this->currentLine), $values) - && (false === strpos($values['key'], ' #') || \in_array($values['key'][0], array('"', "'"))) + && (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) ) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine, $this->filename); @@ -289,7 +289,7 @@ private function doParse($value, $flags) $allowOverwrite = true; if (isset($values['value'][0]) && '*' === $values['value'][0]) { $refName = substr(rtrim($values['value']), 1); - if (!array_key_exists($refName, $this->refs)) { + if (!\array_key_exists($refName, $this->refs)) { if (false !== $pos = array_search($refName, $this->refsBeingParsed, true)) { throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $refName, $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename); } @@ -436,6 +436,9 @@ private function doParse($value, $flags) $value = ''; foreach ($this->lines as $line) { + if ('' !== ltrim($line) && '#' === ltrim($line)[0]) { + continue; + } // If the indentation is not consistent at offset 0, it is to be considered as a ParseError if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); @@ -561,7 +564,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) $oldLineIndentation = $this->getCurrentLineIndentation(); if (!$this->moveToNextLine()) { - return; + return ''; } if (null === $indentation) { @@ -596,7 +599,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) $newIndent = $indentation; } - $data = array(); + $data = []; if ($this->getCurrentLineIndentation() >= $newIndent) { $data[] = substr($this->currentLine, $newIndent); } elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) { @@ -604,7 +607,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) } else { $this->moveToPreviousLine(); - return; + return ''; } if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) { @@ -612,7 +615,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) // and therefore no nested list or mapping $this->moveToPreviousLine(); - return; + return ''; } $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); @@ -698,7 +701,7 @@ private function parseValue($value, $flags, $context) $value = substr($value, 1); } - if (!array_key_exists($value, $this->refs)) { + if (!\array_key_exists($value, $this->refs)) { if (false !== $pos = array_search($value, $this->refsBeingParsed, true)) { throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $value, $value), $this->currentLineNb + 1, $this->currentLine, $this->filename); } @@ -712,7 +715,7 @@ private function parseValue($value, $flags, $context) if (self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; - $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers)); + $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs((int) $modifiers)); if ('' !== $matches['tag']) { if ('!!binary' === $matches['tag']) { @@ -735,7 +738,7 @@ private function parseValue($value, $flags, $context) return Inline::parse($value, $flags, $this->refs); } - $lines = array(); + $lines = []; while ($this->moveToNextLine()) { // unquoted strings end before the first unindented line @@ -800,7 +803,7 @@ private function parseBlockScalar($style, $chomping = '', $indentation = 0) } $isCurrentLineBlank = $this->isCurrentLineBlank(); - $blockLines = array(); + $blockLines = []; // leading blank lines are consumed before determining indentation while ($notEOF && $isCurrentLineBlank) { @@ -972,7 +975,7 @@ private function isCurrentLineLastLineInDocument() */ private function cleanup($value) { - $value = str_replace(array("\r\n", "\r"), "\n", $value); + $value = str_replace(["\r\n", "\r"], "\n", $value); // strip YAML header $count = 0; @@ -1099,14 +1102,17 @@ private function trimTag($value) return $value; } + /** + * @return string|null + */ private function getLineTag($value, $flags, $nextLineCheck = true) { if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) { - return; + return null; } if ($nextLineCheck && !$this->isNextLineIndented()) { - return; + return null; } $tag = substr($matches['tag'], 1); diff --git a/includes/vendor/symfony/yaml/README.md b/includes/vendor/symfony/yaml/README.md index 0d324881..b914e783 100644 --- a/includes/vendor/symfony/yaml/README.md +++ b/includes/vendor/symfony/yaml/README.md @@ -6,7 +6,7 @@ The Yaml component loads and dumps YAML files. Resources --------- - * [Documentation](https://symfony.com/doc/current/components/yaml/index.html) + * [Documentation](https://symfony.com/doc/current/components/yaml.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) diff --git a/includes/vendor/symfony/yaml/Tests/Command/LintCommandTest.php b/includes/vendor/symfony/yaml/Tests/Command/LintCommandTest.php index a5baf234..34989785 100644 --- a/includes/vendor/symfony/yaml/Tests/Command/LintCommandTest.php +++ b/includes/vendor/symfony/yaml/Tests/Command/LintCommandTest.php @@ -31,7 +31,7 @@ public function testLintCorrectFile() $tester = $this->createCommandTester(); $filename = $this->createFile('foo: bar'); - $ret = $tester->execute(array('filename' => $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); + $ret = $tester->execute(['filename' => $filename], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertRegExp('/^\/\/ OK in /', trim($tester->getDisplay())); @@ -45,10 +45,10 @@ public function testLintIncorrectFile() $tester = $this->createCommandTester(); $filename = $this->createFile($incorrectContent); - $ret = $tester->execute(array('filename' => $filename), array('decorated' => false)); + $ret = $tester->execute(['filename' => $filename], ['decorated' => false]); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); - $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay())); + $this->assertStringContainsString('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay())); } public function testConstantAsKey() @@ -56,7 +56,7 @@ public function testConstantAsKey() $yaml = <<createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); + $ret = $this->createCommandTester()->execute(['filename' => $this->createFile($yaml)], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]); $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success'); } @@ -65,7 +65,7 @@ public function testCustomTags() $yaml = <<createCommandTester()->execute(array('filename' => $this->createFile($yaml), '--parse-tags' => true), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); + $ret = $this->createCommandTester()->execute(['filename' => $this->createFile($yaml), '--parse-tags' => true], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]); $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success'); } @@ -74,20 +74,18 @@ public function testCustomTagsError() $yaml = <<createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); + $ret = $this->createCommandTester()->execute(['filename' => $this->createFile($yaml)], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]); $this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error'); } - /** - * @expectedException \RuntimeException - */ public function testLintFileNotReadable() { + $this->expectException('RuntimeException'); $tester = $this->createCommandTester(); $filename = $this->createFile(''); unlink($filename); - $ret = $tester->execute(array('filename' => $filename), array('decorated' => false)); + $tester->execute(['filename' => $filename], ['decorated' => false]); } /** @@ -117,7 +115,7 @@ protected function createCommandTester() protected function setUp() { - $this->files = array(); + $this->files = []; @mkdir(sys_get_temp_dir().'/framework-yml-lint-test'); } diff --git a/includes/vendor/symfony/yaml/Tests/DumperTest.php b/includes/vendor/symfony/yaml/Tests/DumperTest.php index d84a1408..231cf9a8 100644 --- a/includes/vendor/symfony/yaml/Tests/DumperTest.php +++ b/includes/vendor/symfony/yaml/Tests/DumperTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Yaml\Dumper; use Symfony\Component\Yaml\Parser; +use Symfony\Component\Yaml\Tag\TaggedValue; use Symfony\Component\Yaml\Yaml; class DumperTest extends TestCase @@ -22,20 +23,20 @@ class DumperTest extends TestCase protected $dumper; protected $path; - protected $array = array( + protected $array = [ '' => 'bar', 'foo' => '#bar', - 'foo\'bar' => array(), - 'bar' => array(1, 'foo'), - 'foobar' => array( + 'foo\'bar' => [], + 'bar' => [1, 'foo'], + 'foobar' => [ 'foo' => 'bar', - 'bar' => array(1, 'foo'), - 'foobar' => array( + 'bar' => [1, 'foo'], + 'foobar' => [ 'foo' => 'bar', - 'bar' => array(1, 'foo'), - ), - ), - ); + 'bar' => [1, 'foo'], + ], + ], + ]; protected function setUp() { @@ -208,7 +209,7 @@ public function testInlineLevel() public function testObjectSupportEnabled() { - $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_OBJECT); + $dump = $this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_OBJECT); $this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects'); } @@ -218,44 +219,42 @@ public function testObjectSupportEnabled() */ public function testObjectSupportEnabledPassingTrue() { - $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); + $dump = $this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, false, true); $this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects'); } public function testObjectSupportDisabledButNoExceptions() { - $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1)); + $dump = $this->dumper->dump(['foo' => new A(), 'bar' => 1]); $this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\DumpException - */ public function testObjectSupportDisabledWithExceptions() { - $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); + $this->expectException('Symfony\Component\Yaml\Exception\DumpException'); + $this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); } /** * @group legacy - * @expectedException \Symfony\Component\Yaml\Exception\DumpException */ public function testObjectSupportDisabledWithExceptionsPassingTrue() { - $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true); + $this->expectException('Symfony\Component\Yaml\Exception\DumpException'); + $this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, true); } public function testEmptyArray() { - $dump = $this->dumper->dump(array()); + $dump = $this->dumper->dump([]); $this->assertEquals('{ }', $dump); - $dump = $this->dumper->dump(array(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); + $dump = $this->dumper->dump([], 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); $this->assertEquals('[]', $dump); - $dump = $this->dumper->dump(array(), 9, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); + $dump = $this->dumper->dump([], 9, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); $this->assertEquals('[]', $dump); $dump = $this->dumper->dump(new \ArrayObject(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP); @@ -275,27 +274,27 @@ public function testEscapedEscapeSequencesInQuotedScalar($input, $expected) public function getEscapeSequences() { - return array( - 'empty string' => array('', "''"), - 'null' => array("\x0", '"\\0"'), - 'bell' => array("\x7", '"\\a"'), - 'backspace' => array("\x8", '"\\b"'), - 'horizontal-tab' => array("\t", '"\\t"'), - 'line-feed' => array("\n", '"\\n"'), - 'vertical-tab' => array("\v", '"\\v"'), - 'form-feed' => array("\xC", '"\\f"'), - 'carriage-return' => array("\r", '"\\r"'), - 'escape' => array("\x1B", '"\\e"'), - 'space' => array(' ', "' '"), - 'double-quote' => array('"', "'\"'"), - 'slash' => array('/', '/'), - 'backslash' => array('\\', '\\'), - 'next-line' => array("\xC2\x85", '"\\N"'), - 'non-breaking-space' => array("\xc2\xa0", '"\\_"'), - 'line-separator' => array("\xE2\x80\xA8", '"\\L"'), - 'paragraph-separator' => array("\xE2\x80\xA9", '"\\P"'), - 'colon' => array(':', "':'"), - ); + return [ + 'empty string' => ['', "''"], + 'null' => ["\x0", '"\\0"'], + 'bell' => ["\x7", '"\\a"'], + 'backspace' => ["\x8", '"\\b"'], + 'horizontal-tab' => ["\t", '"\\t"'], + 'line-feed' => ["\n", '"\\n"'], + 'vertical-tab' => ["\v", '"\\v"'], + 'form-feed' => ["\xC", '"\\f"'], + 'carriage-return' => ["\r", '"\\r"'], + 'escape' => ["\x1B", '"\\e"'], + 'space' => [' ', "' '"], + 'double-quote' => ['"', "'\"'"], + 'slash' => ['/', '/'], + 'backslash' => ['\\', '\\'], + 'next-line' => ["\xC2\x85", '"\\N"'], + 'non-breaking-space' => ["\xc2\xa0", '"\\_"'], + 'line-separator' => ["\xE2\x80\xA8", '"\\L"'], + 'paragraph-separator' => ["\xE2\x80\xA9", '"\\P"'], + 'colon' => [':', "':'"], + ]; } public function testBinaryDataIsDumpedBase64Encoded() @@ -303,7 +302,7 @@ public function testBinaryDataIsDumpedBase64Encoded() $binaryData = file_get_contents(__DIR__.'/Fixtures/arrow.gif'); $expected = '{ data: !!binary '.base64_encode($binaryData).' }'; - $this->assertSame($expected, $this->dumper->dump(array('data' => $binaryData))); + $this->assertSame($expected, $this->dumper->dump(['data' => $binaryData])); } public function testNonUtf8DataIsDumpedBase64Encoded() @@ -324,18 +323,18 @@ public function testDumpObjectAsMap($object, $expected) public function objectAsMapProvider() { - $tests = array(); + $tests = []; $bar = new \stdClass(); $bar->class = 'classBar'; - $bar->args = array('bar'); + $bar->args = ['bar']; $zar = new \stdClass(); $foo = new \stdClass(); $foo->bar = $bar; $foo->zar = $zar; $object = new \stdClass(); $object->foo = $foo; - $tests['stdClass'] = array($object, $object); + $tests['stdClass'] = [$object, $object]; $arrayObject = new \ArrayObject(); $arrayObject['foo'] = 'bar'; @@ -343,19 +342,19 @@ public function objectAsMapProvider() $parsedArrayObject = new \stdClass(); $parsedArrayObject->foo = 'bar'; $parsedArrayObject->baz = 'foobar'; - $tests['ArrayObject'] = array($arrayObject, $parsedArrayObject); + $tests['ArrayObject'] = [$arrayObject, $parsedArrayObject]; $a = new A(); - $tests['arbitrary-object'] = array($a, null); + $tests['arbitrary-object'] = [$a, null]; return $tests; } public function testDumpingArrayObjectInstancesRespectsInlineLevel() { - $deep = new \ArrayObject(array('deep1' => 'd', 'deep2' => 'e')); - $inner = new \ArrayObject(array('inner1' => 'b', 'inner2' => 'c', 'inner3' => $deep)); - $outer = new \ArrayObject(array('outer1' => 'a', 'outer2' => $inner)); + $deep = new \ArrayObject(['deep1' => 'd', 'deep2' => 'e']); + $inner = new \ArrayObject(['inner1' => 'b', 'inner2' => 'c', 'inner3' => $deep]); + $outer = new \ArrayObject(['outer1' => 'a', 'outer2' => $inner]); $yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP); @@ -372,9 +371,9 @@ public function testDumpingArrayObjectInstancesRespectsInlineLevel() public function testDumpingArrayObjectInstancesWithNumericKeysInlined() { - $deep = new \ArrayObject(array('d', 'e')); - $inner = new \ArrayObject(array('b', 'c', $deep)); - $outer = new \ArrayObject(array('a', $inner)); + $deep = new \ArrayObject(['d', 'e']); + $inner = new \ArrayObject(['b', 'c', $deep]); + $outer = new \ArrayObject(['a', $inner]); $yaml = $this->dumper->dump($outer, 0, 0, Yaml::DUMP_OBJECT_AS_MAP); $expected = <<dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP); $expected = <<assertSame($expected, $yaml); } + public function testDumpingTaggedValueSequenceRespectsInlineLevel() + { + $data = [ + new TaggedValue('user', [ + 'username' => 'jane', + ]), + new TaggedValue('user', [ + 'username' => 'john', + ]), + ]; + + $yaml = $this->dumper->dump($data, 2); + + $expected = <<assertSame($expected, $yaml); + } + + public function testDumpingTaggedValueSequenceWithInlinedTagValues() + { + $data = [ + new TaggedValue('user', [ + 'username' => 'jane', + ]), + new TaggedValue('user', [ + 'username' => 'john', + ]), + ]; + + $yaml = $this->dumper->dump($data, 1); + + $expected = <<assertSame($expected, $yaml); + } + + public function testDumpingTaggedValueMapRespectsInlineLevel() + { + $data = [ + 'user1' => new TaggedValue('user', [ + 'username' => 'jane', + ]), + 'user2' => new TaggedValue('user', [ + 'username' => 'john', + ]), + ]; + + $yaml = $this->dumper->dump($data, 2); + + $expected = <<assertSame($expected, $yaml); + } + + public function testDumpingTaggedValueMapWithInlinedTagValues() + { + $data = [ + 'user1' => new TaggedValue('user', [ + 'username' => 'jane', + ]), + 'user2' => new TaggedValue('user', [ + 'username' => 'john', + ]), + ]; + + $yaml = $this->dumper->dump($data, 1); + + $expected = <<assertSame($expected, $yaml); + } + + public function testDumpingNotInlinedScalarTaggedValue() + { + $data = [ + 'user1' => new TaggedValue('user', 'jane'), + 'user2' => new TaggedValue('user', 'john'), + ]; + $expected = <<assertSame($expected, $this->dumper->dump($data, 2)); + } + + public function testDumpingNotInlinedNullTaggedValue() + { + $data = [ + 'foo' => new TaggedValue('bar', null), + ]; + $expected = <<assertSame($expected, $this->dumper->dump($data, 2)); + } + + public function testDumpingMultiLineStringAsScalarBlockTaggedValue() + { + $data = [ + 'foo' => new TaggedValue('bar', "foo\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz"), + ]; + $expected = <<assertSame($expected, $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); + } + + public function testDumpingInlinedMultiLineIfRnBreakLineInTaggedValue() + { + $data = [ + 'data' => [ + 'foo' => new TaggedValue('bar', "foo\r\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz"), + ], + ]; + + $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_for_tagged_values.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); + } + public function testDumpMultiLineStringAsScalarBlock() { - $data = array( - 'data' => array( + $data = [ + 'data' => [ 'single_line' => 'foo bar baz', 'multi_line' => "foo\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz", 'multi_line_with_carriage_return' => "foo\nbar\r\nbaz", - 'nested_inlined_multi_line_string' => array( + 'nested_inlined_multi_line_string' => [ 'inlined_multi_line' => "foo\nbar\r\nempty line:\n\nbaz", - ), - ), - ); + ], + ], + ]; $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); } public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace() { - $data = array( - 'data' => array( + $data = [ + 'data' => [ 'multi_line' => " the first line has leading spaces\nThe second line does not.", - ), - ); + ], + ]; $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); } public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock() { - $this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); + $this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(["a\r\nb\nc"], 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The indentation must be greater than zero - */ public function testZeroIndentationThrowsException() { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('The indentation must be greater than zero'); new Dumper(0); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The indentation must be greater than zero - */ public function testNegativeIndentationThrowsException() { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('The indentation must be greater than zero'); new Dumper(-4); } } diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml index 5f9c9427..81b4129a 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml @@ -14,7 +14,7 @@ yaml: | - Oren - *showell php: | - array('Steve', 'Clark', 'Brian', 'Oren', 'Steve') + ['Steve', 'Clark', 'Brian', 'Oren', 'Steve'] --- test: Alias of a Mapping @@ -28,4 +28,4 @@ yaml: | - banana - *hello php: | - array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato')) + [['Meat'=>'pork', 'Starch'=>'potato'], 'banana', ['Meat'=>'pork', 'Starch'=>'potato']] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml index dfd93021..1a08d8ea 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml @@ -9,7 +9,7 @@ yaml: | - banana - carrot php: | - array('apple', 'banana', 'carrot') + ['apple', 'banana', 'carrot'] --- test: Sequence With Item Being Null In The Middle brief: | @@ -21,7 +21,7 @@ yaml: | - - carrot php: | - array('apple', null, 'carrot') + ['apple', null, 'carrot'] --- test: Sequence With Last Item Being Null brief: | @@ -33,7 +33,7 @@ yaml: | - banana - php: | - array('apple', 'banana', null) + ['apple', 'banana', null] --- test: Nested Sequences brief: | @@ -46,7 +46,7 @@ yaml: | - bar - baz php: | - array(array('foo', 'bar', 'baz')) + [['foo', 'bar', 'baz']] --- test: Mixed Sequences brief: | @@ -61,7 +61,7 @@ yaml: | - banana - carrot php: | - array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot') + ['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot'] --- test: Deeply Nested Sequences brief: | @@ -74,7 +74,7 @@ yaml: | - uno - dos php: | - array(array(array('uno', 'dos'))) + [[['uno', 'dos']]] --- test: Simple Mapping brief: | @@ -87,7 +87,7 @@ yaml: | foo: whatever bar: stuff php: | - array('foo' => 'whatever', 'bar' => 'stuff') + ['foo' => 'whatever', 'bar' => 'stuff'] --- test: Sequence in a Mapping brief: | @@ -98,7 +98,7 @@ yaml: | - uno - dos php: | - array('foo' => 'whatever', 'bar' => array('uno', 'dos')) + ['foo' => 'whatever', 'bar' => ['uno', 'dos']] --- test: Nested Mappings brief: | @@ -110,14 +110,14 @@ yaml: | name: steve sport: baseball php: | - array( + [ 'foo' => 'whatever', - 'bar' => array( + 'bar' => [ 'fruit' => 'apple', 'name' => 'steve', 'sport' => 'baseball' - ) - ) + ] + ] --- test: Mixed Mapping brief: | @@ -136,22 +136,22 @@ yaml: | perl: papers ruby: scissorses php: | - array( + [ 'foo' => 'whatever', - 'bar' => array( - array( + 'bar' => [ + [ 'fruit' => 'apple', 'name' => 'steve', 'sport' => 'baseball' - ), + ], 'more', - array( + [ 'python' => 'rocks', 'perl' => 'papers', 'ruby' => 'scissorses' - ) - ) - ) + ] + ] + ] --- test: Mapping-in-Sequence Shortcut todo: true @@ -163,7 +163,7 @@ yaml: | - work on YAML.py: - work on Store php: | - array(array('work on YAML.py' => array('work on Store'))) + [['work on YAML.py' => ['work on Store']]] --- test: Sequence-in-Mapping Shortcut todo: true @@ -177,7 +177,7 @@ yaml: | - '%.sourceforge.net' - '%.freepan.org' php: | - array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org')) + ['allow' => ['localhost', '%.sourceforge.net', '%.freepan.org']] --- todo: true test: Merge key @@ -192,11 +192,11 @@ yaml: | <<: age: 38 php: | - array( + [ 'mapping' => - array( + [ 'name' => 'Joe', 'job' => 'Accountant', 'age' => 38 - ) - ) + ] + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml index f7ca469b..1f3a2e54 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml @@ -5,7 +5,7 @@ brief: | yaml: | foo: bar php: | - array('foo' => 'bar') + ['foo' => 'bar'] --- test: Multi Element Mapping brief: | @@ -15,11 +15,11 @@ yaml: | white: walls blue: berries php: | - array( + [ 'red' => 'baron', 'white' => 'walls', 'blue' => 'berries', - ) + ] --- test: Values aligned brief: | @@ -30,11 +30,11 @@ yaml: | white: walls blue: berries php: | - array( + [ 'red' => 'baron', 'white' => 'walls', 'blue' => 'berries', - ) + ] --- test: Colons aligned brief: | @@ -44,8 +44,8 @@ yaml: | white : walls blue : berries php: | - array( + [ 'red' => 'baron', 'white' => 'walls', 'blue' => 'berries', - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml index d9881025..67cb47ad 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml @@ -49,7 +49,7 @@ yaml: | foo: 1 bar: 2 php: | - array('foo' => 1, 'bar' => 2) + ['foo' => 1, 'bar' => 2] documents: 1 --- @@ -63,7 +63,7 @@ yaml: | foo: | --- php: | - array('foo' => "---\n") + ['foo' => "---\n"] --- test: Multiple Document Separators in Block @@ -79,7 +79,7 @@ yaml: | bar: | fooness php: | - array( + [ 'foo' => "---\nfoo: bar\n---\nyo: baz\n", 'bar' => "fooness\n" - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml index e8506fcb..e8697f93 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml @@ -22,4 +22,4 @@ yaml: | firstline: 1 secondline: 2 php: | - array('foo' => null, 'firstline' => 1, 'secondline' => 2) + ['foo' => null, 'firstline' => 1, 'secondline' => 2] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml index 03090e4a..cc562cd9 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml @@ -8,7 +8,7 @@ brief: > yaml: | seq: [ a, b, c ] php: | - array('seq' => array('a', 'b', 'c')) + ['seq' => ['a', 'b', 'c']] --- test: Simple Inline Hash brief: > @@ -21,7 +21,7 @@ brief: > yaml: | hash: { name: Steve, foo: bar } php: | - array('hash' => array('name' => 'Steve', 'foo' => 'bar')) + ['hash' => ['name' => 'Steve', 'foo' => 'bar']] --- test: Multi-line Inline Collections todo: true @@ -38,15 +38,15 @@ yaml: | Python: python.org, Perl: use.perl.org } php: | - array( - 'languages' => array('Ruby', 'Perl', 'Python'), - 'websites' => array( + [ + 'languages' => ['Ruby', 'Perl', 'Python'], + 'websites' => [ 'YAML' => 'yaml.org', 'Ruby' => 'ruby-lang.org', 'Python' => 'python.org', 'Perl' => 'use.perl.org' - ) - ) + ] + ] --- test: Commas in Values (not in the spec!) todo: true @@ -57,4 +57,4 @@ brief: > yaml: | attendances: [ 45,123, 70,000, 17,222 ] php: | - array('attendances' => array(45123, 70000, 17222)) + ['attendances' => [45123, 70000, 17222]] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml index a14735a5..2895202a 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml @@ -12,7 +12,7 @@ yaml: | Foo Bar php: | - array('this' => "Foo\nBar\n") + ['this' => "Foo\nBar\n"] --- test: The '+' indicator brief: > @@ -28,11 +28,11 @@ yaml: | dummy: value php: | - array( + [ 'normal' => "extra new lines not kept\n", 'preserving' => "extra new lines are kept\n\n\n", 'dummy' => 'value' - ) + ] --- test: Three trailing newlines in literals brief: > @@ -64,14 +64,14 @@ yaml: | same as "kept" above: "This has four newlines.\n\n\n\n" php: | - array( + [ 'clipped' => "This has one newline.\n", 'same as "clipped" above' => "This has one newline.\n", 'stripped' => 'This has no newline.', 'same as "stripped" above' => 'This has no newline.', 'kept' => "This has four newlines.\n\n\n\n", 'same as "kept" above' => "This has four newlines.\n\n\n\n" - ) + ] --- test: Extra trailing newlines with spaces todo: true @@ -95,8 +95,8 @@ yaml: | php: | - array('this' => "Foo\n\n \n", - 'kept' => "Foo\n\n \n" ) + ['this' => "Foo\n\n \n", + 'kept' => "Foo\n\n \n"] --- test: Folded Block in a Sequence @@ -115,12 +115,12 @@ yaml: | hmm - dog php: | - array( + [ 'apple', 'banana', "can't you see the beauty of yaml? hmm\n", 'dog' - ) + ] --- test: Folded Block as a Mapping Value brief: > @@ -135,10 +135,10 @@ yaml: | by a knee injury. source: espn php: | - array( + [ 'quote' => "Mark McGwire's year was crippled by a knee injury.\n", 'source' => 'espn' - ) + ] --- test: Three trailing newlines in folded blocks brief: > @@ -166,11 +166,11 @@ yaml: | same as "kept" above: "This has four newlines.\n\n\n\n" php: | - array( + [ 'clipped' => "This has one newline.\n", 'same as "clipped" above' => "This has one newline.\n", 'stripped' => 'This has no newline.', 'same as "stripped" above' => 'This has no newline.', 'kept' => "This has four newlines.\n\n\n\n", 'same as "kept" above' => "This has four newlines.\n\n\n\n" - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml index 9a5300f2..ea8e36ed 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml @@ -6,7 +6,7 @@ brief: > yaml: | empty: [] php: | - array('empty' => array()) + ['empty' => []] --- test: Empty Mapping brief: > @@ -15,19 +15,19 @@ brief: > yaml: | empty: {} php: | - array('empty' => array()) + ['empty' => []] --- test: Empty Sequence as Entire Document yaml: | [] php: | - array() + [] --- test: Empty Mapping as Entire Document yaml: | {} php: | - array() + [] --- test: Null as Document yaml: | diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml index 3f93c982..dd2d776f 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml @@ -6,7 +6,7 @@ yaml: | - Sammy Sosa - Ken Griffey php: | - array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey') + ['Mark McGwire', 'Sammy Sosa', 'Ken Griffey'] --- test: Mapping of scalars to scalars spec: 2.2 @@ -15,7 +15,7 @@ yaml: | avg: 0.278 rbi: 147 php: | - array('hr' => 65, 'avg' => 0.278, 'rbi' => 147) + ['hr' => 65, 'avg' => 0.278, 'rbi' => 147] --- test: Mapping of scalars to sequences spec: 2.3 @@ -29,13 +29,13 @@ yaml: | - Chicago Cubs - Atlanta Braves php: | - array('american' => - array( 'Boston Red Sox', 'Detroit Tigers', - 'New York Yankees' ), + ['american' => + ['Boston Red Sox', 'Detroit Tigers', + 'New York Yankees'], 'national' => - array( 'New York Mets', 'Chicago Cubs', - 'Atlanta Braves' ) - ) + ['New York Mets', 'Chicago Cubs', + 'Atlanta Braves'] + ] --- test: Sequence of mappings spec: 2.4 @@ -49,10 +49,10 @@ yaml: | hr: 63 avg: 0.288 php: | - array( - array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278), - array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288) - ) + [ + ['name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278], + ['name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288] + ] --- test: Legacy A5 todo: true @@ -72,7 +72,7 @@ yaml: | - 2001-07-23 perl-busted: > YAML.pm will be able to emulate this behavior soon. In this regard - it may be somewhat more correct than Python's native behaviour which + it may be somewhat more correct than Python's native behavior which can only use tuples as mapping keys. PyYAML will also need to figure out some clever way to roundtrip structured keys. python: | @@ -134,11 +134,11 @@ yaml: | - [ Mark McGwire , 65 , 0.278 ] - [ Sammy Sosa , 63 , 0.288 ] php: | - array( - array( 'name', 'hr', 'avg' ), - array( 'Mark McGwire', 65, 0.278 ), - array( 'Sammy Sosa', 63, 0.288 ) - ) + [ + [ 'name', 'hr', 'avg' ], + [ 'Mark McGwire', 65, 0.278 ], + [ 'Sammy Sosa', 63, 0.288 ] + ] --- test: Mapping of mappings todo: true @@ -150,12 +150,12 @@ yaml: | avg: 0.288 } php: | - array( + [ 'Mark McGwire' => - array( 'hr' => 65, 'avg' => 0.278 ), + [ 'hr' => 65, 'avg' => 0.278 ], 'Sammy Sosa' => - array( 'hr' => 63, 'avg' => 0.288 ) - ) + [ 'hr' => 63, 'avg' => 0.288 ] + ] --- test: Two documents in a stream each with a leading comment todo: true @@ -208,10 +208,10 @@ yaml: | - Sammy Sosa - Ken Griffey php: | - array( - 'hr' => array( 'Mark McGwire', 'Sammy Sosa' ), - 'rbi' => array( 'Sammy Sosa', 'Ken Griffey' ) - ) + [ + 'hr' => [ 'Mark McGwire', 'Sammy Sosa' ], + 'rbi' => [ 'Sammy Sosa', 'Ken Griffey' ] + ] --- test: Node for Sammy Sosa appears twice in this document spec: 2.10 @@ -225,12 +225,12 @@ yaml: | - *SS # Subsequent occurrence - Ken Griffey php: | - array( + [ 'hr' => - array('Mark McGwire', 'Sammy Sosa'), + ['Mark McGwire', 'Sammy Sosa'], 'rbi' => - array('Sammy Sosa', 'Ken Griffey') - ) + ['Sammy Sosa', 'Ken Griffey'] + ] --- test: Mapping between sequences todo: true @@ -297,20 +297,20 @@ yaml: | - item : Big Shoes quantity: 1 php: | - array ( - array ( + [ + [ 'item' => 'Super Hoop', 'quantity' => 1, - ), - array ( + ], + [ 'item' => 'Basketball', 'quantity' => 4, - ), - array ( + ], + [ 'item' => 'Big Shoes', 'quantity' => 1, - ) - ) + ] + ] perl: | [ { item => 'Super Hoop', quantity => 1 }, @@ -462,11 +462,11 @@ yaml: | 65 Home Runs 0.278 Batting Average php: | - array( + [ 'name' => 'Mark McGwire', 'accomplishment' => "Mark set a major league home run record in 1998.\n", 'stats' => "65 Home Runs\n0.278 Batting Average\n" - ) + ] --- test: Quoted scalars todo: true @@ -512,11 +512,11 @@ yaml: | octal: 014 hexadecimal: 0xC php: | - array( + [ 'canonical' => 12345, 'octal' => 014, 'hexadecimal' => 0xC - ) + ] --- test: Decimal Integer deprecated: true @@ -524,9 +524,9 @@ spec: 2.19 yaml: | decimal: +12,345 php: | - array( + [ 'decimal' => 12345.0, - ) + ] --- # FIX: spec shows parens around -inf and NaN test: Floating point @@ -538,13 +538,13 @@ yaml: | not a number: .NaN float as whole number: !!float 1 php: | - array( + [ 'canonical' => 1230.15, 'exponential' => 1230.15, 'negative infinity' => log(0), 'not a number' => -log(0), 'float as whole number' => (float) 1 - ) + ] --- test: Fixed Floating point deprecated: true @@ -552,9 +552,9 @@ spec: 2.20 yaml: | fixed: 1,230.15 php: | - array( + [ 'fixed' => 1230.15, - ) + ] --- test: Timestamps todo: true @@ -565,12 +565,12 @@ yaml: | spaced: 2001-12-14 21:59:43.10 -05:00 date: 2002-12-14 # Time is noon UTC php: | - array( + [ 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ), 'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), 'date' => Date.new( 2002, 12, 14 ) - ) + ] --- test: legacy Timestamps test todo: true @@ -581,12 +581,12 @@ yaml: | spaced: 2001-12-14 21:59:43.00 -05:00 date: 2002-12-14 php: | - array( + [ 'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ), 'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ), 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ), 'date' => Date.new( 2002, 12, 14 ) - ) + ] --- test: Various explicit families todo: true @@ -754,20 +754,20 @@ yaml: | Backup contact is Nancy Billsmer @ 338-4338. php: | - array( + [ 'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001), 'bill-to' => - array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) + [ 'given' => 'Chris', 'family' => 'Dumars', 'address' => [ 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ] ] , 'ship-to' => - array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) + [ 'given' => 'Chris', 'family' => 'Dumars', 'address' => [ 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ] ] , 'product' => - array( - array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ), - array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 ) - ), + [ + [ 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ], + [ 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 ] + ], 'tax' => 251.42, 'total' => 4443.52, 'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n" - ) + ] --- test: Log file todo: true @@ -826,9 +826,9 @@ yaml: | # These are three throwaway comment # lines (the first line is empty). php: | - array( + [ 'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n" - ) + ] --- test: Document with a single value todo: true @@ -878,11 +878,11 @@ yaml: | date : 2001-01-23 total : 4443.52 php: | - array( + [ 'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001), 'total' => 4443.52 - ) + ] --- test: Single-line documents todo: true @@ -934,7 +934,7 @@ yaml: | also int: ! "12" string: !!str 12 php: | - array( 'integer' => 12, 'also int' => 12, 'string' => '12' ) + [ 'integer' => 12, 'also int' => 12, 'string' => '12' ] --- test: Private types todo: true @@ -966,7 +966,7 @@ yaml: | # The URI is 'tag:yaml.org,2002:str' - !!str a Unicode string php: | - array( 'a Unicode string' ) + [ 'a Unicode string' ] --- test: Type family under perl.yaml.org todo: true @@ -1039,9 +1039,9 @@ yaml: | repeated use of this value. alias : *A001 php: | - array( 'anchor' => 'This scalar has an anchor.', + [ 'anchor' => 'This scalar has an anchor.', 'override' => "The alias node below is a repeated use of this value.\n", - 'alias' => "The alias node below is a repeated use of this value.\n" ) + 'alias' => "The alias node below is a repeated use of this value.\n"] --- test: Flow and block formatting todo: true @@ -1152,12 +1152,12 @@ yaml: | redundant: |2 This value is indented 2 spaces. php: | - array( + [ 'leading spaces' => " This value starts with four spaces.\n", 'leading line break' => "\nThis value starts with a line break.\n", 'leading comment indicator' => "# first line starts with a\n# character.\n", 'redundant' => "This value is indented 2 spaces.\n" - ) + ] --- test: Chomping and keep modifiers yaml: | @@ -1176,14 +1176,14 @@ yaml: | same as "kept" above: "This has two newlines.\n\n" php: | - array( + [ 'clipped' => "This has one newline.\n", 'same as "clipped" above' => "This has one newline.\n", 'stripped' => 'This has no newline.', 'same as "stripped" above' => 'This has no newline.', 'kept' => "This has two newlines.\n\n", 'same as "kept" above' => "This has two newlines.\n\n" - ) + ] --- test: Literal combinations todo: true @@ -1221,7 +1221,7 @@ yaml: | both are equal to: " This has no newline." php: | - array( + [ 'empty' => '', 'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " + "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" + @@ -1232,7 +1232,7 @@ php: | 'indented and chomped' => ' This has no newline.', 'also written as' => ' This has no newline.', 'both are equal to' => ' This has no newline.' - ) + [ --- test: Folded combinations todo: true @@ -1288,7 +1288,7 @@ yaml: | # Explicit comments may follow # but must be less indented. php: | - array( + [ 'empty' => '', 'one paragraph' => 'Line feeds are converted to spaces, so this value'. " contains no line breaks except for the final one.\n", @@ -1300,7 +1300,7 @@ php: | 'above is equal to' => "This is a folded paragraph followed by a list:\n". " * first entry\n * second entry\nFollowed by another folded paragraph, ". "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n" - ) + ] --- test: Single quotes todo: true @@ -1315,13 +1315,13 @@ yaml: | line break' is same as: "this contains six spaces\nand one line break" php: | - array( + [ 'empty' => '', 'second' => '! : \\ etc. can be used freely.', 'third' => "a single quote ' must be escaped.", 'span' => "this contains six spaces\nand one line break", 'is same as' => "this contains six spaces\nand one line break" - ) + ] --- test: Double quotes todo: true @@ -1335,14 +1335,14 @@ yaml: | spaces" is equal to: "this contains four spaces" php: | - array( + [ 'empty' => '', 'second' => '! : etc. can be used freely.', 'third' => 'a " or a \\ must be escaped.', 'fourth' => "this value ends with an LF.\n", 'span' => "this contains four spaces", 'is equal to' => "this contains four spaces" - ) + ] --- test: Unquoted strings todo: true @@ -1371,7 +1371,7 @@ yaml: | note: { one-line keys: but multi-line values } php: | - array( + [ 'first' => 'There is no unquoted empty string.', 'second' => 12, 'third' => '12', @@ -1379,7 +1379,7 @@ php: | 'indicators' => "this has no comments. #:foo and bar# are both text.", 'flow' => [ 'can span lines', 'like this' ], 'note' => { 'one-line keys' => 'but multi-line values' } - ) + ] --- test: Spanning sequences todo: true @@ -1393,11 +1393,11 @@ yaml: | - one - two php: | - array( + [ 'flow' => [ 'one', 'two' ], 'spanning' => [ 'one', 'two' ], 'block' => [ 'one', 'two' ] - ) + ] --- test: Flow mappings yaml: | @@ -1408,10 +1408,10 @@ yaml: | one: 1 two: 2 php: | - array( - 'flow' => array( 'one' => 1, 'two' => 2 ), - 'block' => array( 'one' => 1, 'two' => 2 ) - ) + [ + 'flow' => [ 'one' => 1, 'two' => 2 ], + 'block' => [ 'one' => 1, 'two' => 2 ] + ] --- test: Representations of 12 todo: true @@ -1433,7 +1433,7 @@ yaml: | - foo/bar - /a.*b/ php: | - array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' ) + [ 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' ] --- test: "Null" todo: true @@ -1455,12 +1455,12 @@ yaml: | only two with values. php: | - array ( + [ 'canonical' => null, 'english' => null, - 'sparse' => array( null, '2nd entry', null, '4th entry', null ]), + 'sparse' => [ null, '2nd entry', null, '4th entry', null ]], 'four' => 'This mapping has five keys, only two with values.' - ) + ] --- test: Omap todo: true @@ -1525,29 +1525,29 @@ yaml: | octal: 014 hexadecimal: 0xC php: | - array( + [ 'canonical' => 12345, 'octal' => 12, 'hexadecimal' => 12 - ) + ] --- test: Decimal deprecated: true yaml: | decimal: +12,345 php: | - array( + [ 'decimal' => 12345.0, - ) + ] --- test: Fixed Float deprecated: true yaml: | fixed: 1,230.15 php: | - array( + [ 'fixed' => 1230.15, - ) + ] --- test: Float yaml: | @@ -1556,12 +1556,12 @@ yaml: | negative infinity: -.inf not a number: .NaN php: | - array( + [ 'canonical' => 1230.15, 'exponential' => 1230.15, 'negative infinity' => log(0), 'not a number' => -log(0) - ) + ] --- test: Timestamp todo: true @@ -1571,12 +1571,12 @@ yaml: | space separated: 2001-12-14 21:59:43.10 -05:00 date (noon UTC): 2002-12-14 ruby: | - array( + [ 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ), 'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), 'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), 'date (noon UTC)' => Date.new( 2002, 12, 14 ) - ) + ] --- test: Binary todo: true diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml index dea0be01..e96b5536 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml @@ -25,14 +25,14 @@ yaml: | - No, I mean, "And what about Yaml?" - Oh, oh yeah. Uh.. Yaml for Ruby. php: | - array( + [ "What's Yaml?", "It's for writing data structures in plain text.", "And?", "And what? That's not good enough for you?", "No, I mean, \"And what about Yaml?\"", "Oh, oh yeah. Uh.. Yaml for Ruby." - ) + ] --- test: Indicators in Strings brief: > @@ -43,11 +43,11 @@ yaml: | same for the pound sign: here we have it#in a string the comma can, honestly, be used in most cases: [ but not in, inline collections ] php: | - array( + [ 'the colon followed by space is an indicator' => 'but is a string:right here', 'same for the pound sign' => 'here we have it#in a string', - 'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections') - ) + 'the comma can, honestly, be used in most cases' => ['but not in', 'inline collections'] + ] --- test: Forcing Strings brief: > @@ -57,10 +57,10 @@ yaml: | date string: !!str 2001-08-01 number string: !!str 192 php: | - array( + [ 'date string' => '2001-08-01', 'number string' => '192' - ) + ] --- test: Single-quoted Strings brief: > @@ -75,12 +75,12 @@ yaml: | why do i hate them?: 'it''s very hard to explain' entities: '£ me' php: | - array( + [ 'all my favorite symbols' => '#:!/%.)', 'a few i hate' => '&(*', 'why do i hate them?' => 'it\'s very hard to explain', 'entities' => '£ me' - ) + ] --- test: Double-quoted Strings brief: > @@ -90,9 +90,9 @@ brief: > yaml: | i know where i want my line breaks: "one here\nand another here\n" php: | - array( + [ 'i know where i want my line breaks' => "one here\nand another here\n" - ) + ] --- test: Multi-line Quoted Strings todo: true @@ -106,10 +106,10 @@ yaml: | let it go on and on to other lines until i end it with a quote." php: | - array('i want a long string' => "so i'm going to ". + ['i want a long string' => "so i'm going to ". "let it go on and on to other lines ". "until i end it with a quote." - ) + ] --- test: Plain scalars @@ -128,7 +128,7 @@ yaml: | - This would impair my skiing ability somewhat for the duration, as can be imagined. php: | - array( + [ "My little toe is broken in two places;", "I'm crazy to have skied this way;", "I'm not the craziest he's seen, since there was always ". @@ -139,7 +139,7 @@ php: | "He's going to put my foot in plaster for a month;", "This would impair my skiing ability somewhat for the duration, ". "as can be imagined." - ) + ] --- test: 'Null' brief: > @@ -149,11 +149,11 @@ yaml: | hosted by: Bob and David date of next season: ~ php: | - array( + [ 'name' => 'Mr. Show', 'hosted by' => 'Bob and David', 'date of next season' => null - ) + ] --- test: Boolean brief: > @@ -162,10 +162,10 @@ yaml: | Is Gus a Liar?: true Do I rely on Gus for Sustenance?: false php: | - array( + [ 'Is Gus a Liar?' => true, 'Do I rely on Gus for Sustenance?' => false - ) + ] --- test: Integers dump_skip: true @@ -177,10 +177,10 @@ yaml: | zero: 0 simple: 12 php: | - array( + [ 'zero' => 0, 'simple' => 12, - ) + ] --- test: Positive Big Integer deprecated: true @@ -192,9 +192,9 @@ brief: > yaml: | one-thousand: 1,000 php: | - array( + [ 'one-thousand' => 1000.0, - ) + ] --- test: Negative Big Integer deprecated: true @@ -206,9 +206,9 @@ brief: > yaml: | negative one-thousand: -1,000 php: | - array( + [ 'negative one-thousand' => -1000.0 - ) + ] --- test: Floats dump_skip: true @@ -220,10 +220,10 @@ yaml: | a simple float: 2.00 scientific notation: 1.00009e+3 php: | - array( + [ 'a simple float' => 2.0, 'scientific notation' => 1000.09 - ) + ] --- test: Larger Float dump_skip: true @@ -235,9 +235,9 @@ brief: > yaml: | larger float: 1,000.09 php: | - array( + [ 'larger float' => 1000.09, - ) + ] --- test: Time todo: true @@ -250,10 +250,10 @@ yaml: | iso8601: 2001-12-14t21:59:43.10-05:00 space separated: 2001-12-14 21:59:43.10 -05:00 php: | - array( + [ 'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), 'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ) - ) + ] --- test: Date todo: true diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml index 26799e8e..88287f1b 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml @@ -5,7 +5,7 @@ yaml: | true: true false: false php: | - array( + [ 'true' => true, 'false' => false, - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml index cc0356d3..87d352db 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml @@ -142,14 +142,14 @@ test: Double quotes with a line feed yaml: | { double: "some value\n \"some quoted string\" and 'some single quotes one'" } php: | - array( + [ 'double' => "some value\n \"some quoted string\" and 'some single quotes one'" - ) + ] --- test: Backslashes yaml: | { single: 'foo\Var', no-quotes: foo\Var, double: "foo\\Var" } php: | - array( + [ 'single' => 'foo\Var', 'no-quotes' => 'foo\Var', 'double' => 'foo\Var' - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml index 5e8d0917..db950165 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml @@ -5,10 +5,10 @@ yaml: | true: true false: false php: | - array( + [ 1 => true, 0 => false, - ) + ] --- test: Boolean yaml: | @@ -16,8 +16,8 @@ yaml: | logical: true answer: false php: | - array( + [ false => 'used as key', 'logical' => true, 'answer' => false - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml index 551a6205..14f93c2d 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml @@ -4,6 +4,6 @@ spec: 2.21 yaml: | null: ~ php: | - array( + [ '' => null, - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block_for_tagged_values.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block_for_tagged_values.yml new file mode 100644 index 00000000..f8c9112f --- /dev/null +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block_for_tagged_values.yml @@ -0,0 +1,2 @@ +data: + foo: !bar "foo\r\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz" diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml index 7dcadc72..cd90f7b4 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml @@ -4,6 +4,6 @@ spec: 2.21 yaml: | null: ~ php: | - array( + [ 'null' => null, - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml index 9cfb7713..246447e4 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml @@ -6,7 +6,7 @@ yaml: | 1: foo 0: bar php: | - array(1 => 'foo', 0 => 'bar') + [1 => 'foo', 0 => 'bar'] --- test: Integers as Map Keys brief: > @@ -16,8 +16,8 @@ yaml: | 2: two 3: three php: | - array( + [ 1 => 'one', 2 => 'two', 3 => 'three' - ) + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/sfComments.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/sfComments.yml index b72a9b69..af3ab385 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/sfComments.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/sfComments.yml @@ -11,7 +11,7 @@ yaml: | ex6: foo#foo # comment here ex7: foo # ignore me # and me php: | - array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo', 'ex6' => 'foo#foo', 'ex7' => 'foo') + ['ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo', 'ex6' => 'foo#foo', 'ex7' => 'foo'] --- test: Comments in the middle brief: > @@ -24,7 +24,7 @@ yaml: | # some comment # some comment php: | - array('foo' => array('bar' => 'foo')) + ['foo' => ['bar' => 'foo']] --- test: Comments on a hash line brief: > @@ -33,7 +33,7 @@ yaml: | foo: # a comment foo: bar # a comment php: | - array('foo' => array('foo' => 'bar')) + ['foo' => ['foo' => 'bar']] --- test: 'Value starting with a #' brief: > @@ -41,7 +41,7 @@ brief: > yaml: | foo: '#bar' php: | - array('foo' => '#bar') + ['foo' => '#bar'] --- test: Document starting with a comment and a separator brief: > @@ -51,7 +51,7 @@ yaml: | --- foo: bar # a comment php: | - array('foo' => 'bar') + ['foo' => 'bar'] --- test: Comment containing a colon on a hash line brief: > @@ -65,7 +65,7 @@ brief: > 'Hash key containing a #' yaml: 'foo#bar: baz' php: | - array('foo#bar' => 'baz') + ['foo#bar' => 'baz'] --- test: 'Hash key ending with a space and a #' brief: > @@ -73,4 +73,4 @@ brief: > yaml: | 'foo #': baz php: | - array('foo #' => 'baz') + ['foo #' => 'baz'] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml index 1339d23a..8cadae2c 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml @@ -13,22 +13,22 @@ yaml: | nick: Biggies quantity: 1 php: | - array ( - array ( + [ + [ 'item' => 'Super Hoop', - ), - array ( + ], + [ 'item' => 'Basketball', 'quantity' => 1, - ), - array ( - 'item' => array( + ], + [ + 'item' => [ 'name' => 'Big Shoes', 'nick' => 'Biggies' - ), + ], 'quantity' => 1 - ) - ) + ] + ] --- test: Compact notation combined with inline notation brief: | @@ -39,18 +39,18 @@ yaml: | - { item: Super Hoop, quantity: 1 } - [ Basketball, Big Shoes ] php: | - array ( - 'items' => array ( - array ( + [ + 'items' => [ + [ 'item' => 'Super Hoop', 'quantity' => 1, - ), - array ( + ], + [ 'Basketball', 'Big Shoes' - ) - ) - ) + ] + ] + ] --- %YAML:1.0 test: Compact notation brief: | @@ -66,22 +66,22 @@ yaml: | nick: Biggies quantity: 1 php: | - array ( - array ( + [ + [ 'item' => 'Super Hoop', - ), - array ( + ], + [ 'item' => 'Basketball', 'quantity' => 1, - ), - array ( - 'item' => array( + ], + [ + 'item' => [ 'name' => 'Big Shoes', 'nick' => 'Biggies' - ), + ], 'quantity' => 1 - ) - ) + ] + ] --- test: Compact notation combined with inline notation brief: | @@ -92,18 +92,18 @@ yaml: | - { item: Super Hoop, quantity: 1 } - [ Basketball, Big Shoes ] php: | - array ( - 'items' => array ( - array ( + [ + 'items' => [ + [ 'item' => 'Super Hoop', 'quantity' => 1, - ), - array ( + ], + [ 'Basketball', 'Big Shoes' - ) - ) - ) + ] + ] + ] --- %YAML:1.0 test: Compact notation brief: | @@ -119,22 +119,22 @@ yaml: | nick: Biggies quantity: 1 php: | - array ( - array ( + [ + [ 'item' => 'Super Hoop', - ), - array ( + ], + [ 'item' => 'Basketball', 'quantity' => 1, - ), - array ( - 'item' => array( + ], + [ + 'item' => [ 'name' => 'Big Shoes', 'nick' => 'Biggies' - ), + ], 'quantity' => 1 - ) - ) + ] + ] --- test: Compact notation combined with inline notation brief: | @@ -145,15 +145,15 @@ yaml: | - { item: Super Hoop, quantity: 1 } - [ Basketball, Big Shoes ] php: | - array ( - 'items' => array ( - array ( + [ + 'items' => [ + [ 'item' => 'Super Hoop', 'quantity' => 1, - ), - array ( + ], + [ 'Basketball', 'Big Shoes' - ) - ) - ) + ] + ] + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml index 83264cfa..af787ae4 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml @@ -46,16 +46,16 @@ yaml: | head_inline: &head_inline { <<: [ *foo , *dong , *foo2 ] } recursive_inline: { <<: *head_inline, c: { <<: *foo2 } } php: | - array( - 'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'), - 'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'), - 'bar_inline' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'e' => 'notnull', 'x' => 'Oren'), - 'foo2' => array('a' => 'Ballmer'), - 'ding' => array('fi', 'fei', 'fo', 'fam'), - 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'), - 'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'), - 'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)), - 'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)), - 'head_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'), - 'recursive_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => array('a' => 'Ballmer'), 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'), - ) + [ + 'foo' => ['a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'], + 'bar' => ['a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => ['foo' => 'bar', 'bar' => 'foo'], 'x' => 'Oren'], + 'bar_inline' => ['a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => ['foo' => 'bar', 'bar' => 'foo'], 'e' => 'notnull', 'x' => 'Oren'], + 'foo2' => ['a' => 'Ballmer'], + 'ding' => ['fi', 'fei', 'fo', 'fam'], + 'check' => ['a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'], + 'head' => ['a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'], + 'taz' => ['a' => 'Steve', 'w' => ['p' => 1234]], + 'nested' => ['a' => 'Steve', 'w' => ['p' => 12345], 'd' => 'Doug', 'z' => ['p' => 12345]], + 'head_inline' => ['a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'], + 'recursive_inline' => ['a' => 'Steve', 'b' => 'Clark', 'c' => ['a' => 'Ballmer'], 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'], + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml index ee124b24..144615f2 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml @@ -8,4 +8,4 @@ yaml: | ex3: 'foo # bar' # comment ex4: foo # comment php: | - array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo') + ['ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo'] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml index 7c60baec..c8326fdb 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml @@ -5,7 +5,7 @@ brief: > yaml: | foo: '| bar' php: | - array('foo' => '| bar') + ['foo' => '| bar'] --- test: A key can be a quoted string brief: > @@ -19,15 +19,15 @@ yaml: | "foo4: ": bar foo5: { "foo \" bar: ": bar, 'foo '' bar: ': bar } php: | - array( + [ 'foo1' => 'bar', 'foo2' => 'bar', 'foo " bar' => 'bar', 'foo \' bar' => 'bar', 'foo3: ' => 'bar', 'foo4: ' => 'bar', - 'foo5' => array( + 'foo5' => [ 'foo " bar: ' => 'bar', 'foo \' bar: ' => 'bar', - ), - ) + ], + ] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/sfTests.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/sfTests.yml index 2a0b9c87..2ea417a7 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/sfTests.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/sfTests.yml @@ -5,19 +5,19 @@ brief: > yaml: | stripped_title: { name: "foo bar", help: "bar foo" } php: | - array('stripped_title' => array('name' => 'foo bar', 'help' => 'bar foo')) + ['stripped_title' => ['name' => 'foo bar', 'help' => 'bar foo']] --- test: Empty sequence yaml: | foo: [ ] php: | - array('foo' => array()) + ['foo' => []] --- test: Empty value yaml: | foo: php: | - array('foo' => null) + ['foo' => null] --- test: Inline string parsing brief: > @@ -25,7 +25,7 @@ brief: > yaml: | test: ['complex: string', 'another [string]'] php: | - array('test' => array('complex: string', 'another [string]')) + ['test' => ['complex: string', 'another [string]']] --- test: Boolean brief: > @@ -40,7 +40,7 @@ yaml: | - 'null' - '~' php: | - array( + [ false, true, null, @@ -49,7 +49,7 @@ php: | 'true', 'null', '~', - ) + ] --- test: Empty lines in literal blocks brief: > @@ -63,7 +63,7 @@ yaml: | bar php: | - array('foo' => array('bar' => "foo\n\n\n \nbar\n")) + ['foo' => ['bar' => "foo\n\n\n \nbar\n"]] --- test: Empty lines in folded blocks brief: > @@ -77,7 +77,7 @@ yaml: | bar php: | - array('foo' => array('bar' => "\nfoo\n\nbar\n")) + ['foo' => ['bar' => "\nfoo\n\nbar\n"]] --- test: IP addresses brief: > @@ -85,7 +85,7 @@ brief: > yaml: | foo: 10.0.0.2 php: | - array('foo' => '10.0.0.2') + ['foo' => '10.0.0.2'] --- test: A sequence with an embedded mapping brief: > @@ -94,28 +94,28 @@ yaml: | - foo - bar: { bar: foo } php: | - array('foo', array('bar' => array('bar' => 'foo'))) + ['foo', ['bar' => ['bar' => 'foo']]] --- test: Octal brief: as in spec example 2.19, octal value is converted yaml: | foo: 0123 php: | - array('foo' => 83) + ['foo' => 83] --- test: Octal strings brief: Octal notation in a string must remain a string yaml: | foo: "0123" php: | - array('foo' => '0123') + ['foo' => '0123'] --- test: Octal strings brief: Octal notation in a string must remain a string yaml: | foo: '0123' php: | - array('foo' => '0123') + ['foo' => '0123'] --- test: Octal strings brief: Octal notation in a string must remain a string @@ -123,18 +123,18 @@ yaml: | foo: | 0123 php: | - array('foo' => "0123\n") + ['foo' => "0123\n"] --- test: Document as a simple hash brief: Document as a simple hash yaml: | { foo: bar } php: | - array('foo' => 'bar') + ['foo' => 'bar'] --- test: Document as a simple array brief: Document as a simple array yaml: | [ foo, bar ] php: | - array('foo', 'bar') + ['foo', 'bar'] diff --git a/includes/vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml b/includes/vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml index 0c96108e..c85952df 100644 --- a/includes/vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml +++ b/includes/vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml @@ -8,7 +8,7 @@ yaml: | - item2 - item3 php: | - array('collection' => array('item1', 'item2', 'item3')) + ['collection' => ['item1', 'item2', 'item3']] --- test: Nested unindented collection (two levels) brief: > @@ -20,7 +20,7 @@ yaml: | - b - c php: | - array('collection' => array('key' => array('a', 'b', 'c'))) + ['collection' => ['key' => ['a', 'b', 'c']]] --- test: Nested unindented collection (three levels) brief: > @@ -33,7 +33,7 @@ yaml: | - two - three php: | - array('collection' => array('key' => array('subkey' => array('one', 'two', 'three')))) + ['collection' => ['key' => ['subkey' => ['one', 'two', 'three']]]] --- test: Key/value after unindented collection (1) brief: > @@ -46,7 +46,7 @@ yaml: | - c foo: bar php: | - array('collection' => array('key' => array('a', 'b', 'c')), 'foo' => 'bar') + ['collection' => ['key' => ['a', 'b', 'c']], 'foo' => 'bar'] --- test: Key/value after unindented collection (at the same level) brief: > @@ -59,7 +59,7 @@ yaml: | - c foo: bar php: | - array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar')) + ['collection' => ['key' => ['a', 'b', 'c'], 'foo' => 'bar']] --- test: Shortcut Key after unindented collection brief: > @@ -69,7 +69,7 @@ yaml: | - key: foo foo: bar php: | - array('collection' => array(array('key' => 'foo', 'foo' => 'bar'))) + ['collection' => [['key' => 'foo', 'foo' => 'bar']]] --- test: Shortcut Key after unindented collection with custom spaces brief: > @@ -79,4 +79,4 @@ yaml: | - key: foo foo: bar php: | - array('collection' => array(array('key' => 'foo', 'foo' => 'bar'))) + ['collection' => [['key' => 'foo', 'foo' => 'bar']]] diff --git a/includes/vendor/symfony/yaml/Tests/InlineTest.php b/includes/vendor/symfony/yaml/Tests/InlineTest.php index f2c4ab60..54372d69 100644 --- a/includes/vendor/symfony/yaml/Tests/InlineTest.php +++ b/includes/vendor/symfony/yaml/Tests/InlineTest.php @@ -53,30 +53,27 @@ public function testParsePhpConstants($yaml, $value) public function getTestsForParsePhpConstants() { - return array( - array('!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT), - array('!php/const PHP_INT_MAX', PHP_INT_MAX), - array('[!php/const PHP_INT_MAX]', array(PHP_INT_MAX)), - array('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)), - array('!php/const NULL', null), - ); + return [ + ['!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT], + ['!php/const PHP_INT_MAX', PHP_INT_MAX], + ['[!php/const PHP_INT_MAX]', [PHP_INT_MAX]], + ['{ foo: !php/const PHP_INT_MAX }', ['foo' => PHP_INT_MAX]], + ['{ !php/const PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']], + ['!php/const NULL', null], + ]; } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage The constant "WRONG_CONSTANT" is not defined - */ public function testParsePhpConstantThrowsExceptionWhenUndefined() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('The constant "WRONG_CONSTANT" is not defined'); Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessageRegExp #The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*# - */ public function testParsePhpConstantThrowsExceptionOnInvalidType() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessageRegExp('#The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#'); Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); } @@ -92,13 +89,14 @@ public function testDeprecatedConstantTag($yaml, $expectedValue) public function getTestsForParseLegacyPhpConstants() { - return array( - array('!php/const:Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT), - array('!php/const:PHP_INT_MAX', PHP_INT_MAX), - array('[!php/const:PHP_INT_MAX]', array(PHP_INT_MAX)), - array('{ foo: !php/const:PHP_INT_MAX }', array('foo' => PHP_INT_MAX)), - array('!php/const:NULL', null), - ); + return [ + ['!php/const:Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT], + ['!php/const:PHP_INT_MAX', PHP_INT_MAX], + ['[!php/const:PHP_INT_MAX]', [PHP_INT_MAX]], + ['{ foo: !php/const:PHP_INT_MAX }', ['foo' => PHP_INT_MAX]], + ['{ !php/const:PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']], + ['!php/const:NULL', null], + ]; } /** @@ -130,13 +128,13 @@ public function testDumpNumericValueWithLocale() } try { - $requiredLocales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); + $requiredLocales = ['fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252']; if (false === setlocale(LC_NUMERIC, $requiredLocales)) { $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales)); } $this->assertEquals('1.2', Inline::dump(1.2)); - $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0))); + $this->assertStringContainsStringIgnoringCase('fr', setlocale(LC_NUMERIC, 0)); } finally { setlocale(LC_NUMERIC, $locale); } @@ -149,46 +147,36 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo $this->assertSame($value, Inline::parse(Inline::dump($value))); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Found unknown escape character "\V". - */ public function testParseScalarWithNonEscapedBlackslashShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Found unknown escape character "\V".'); Inline::parse('"Foo\Var"'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); Inline::parse('"Foo\\"'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $value = "'don't do somthin' like that'"; Inline::parse($value); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $value = '"don"t do somthin" like that"'; Inline::parse($value); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testParseInvalidMappingKeyShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $value = '{ "foo " bar": "bar" }'; Inline::parse($value); } @@ -203,22 +191,24 @@ public function testParseMappingKeyWithColonNotFollowedBySpace() Inline::parse('{1:""}'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testParseInvalidMappingShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); Inline::parse('[foo] bar'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testParseInvalidSequenceShouldThrowException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); Inline::parse('{ foo: bar } bar'); } + public function testParseInvalidTaggedSequenceShouldThrowException() + { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + Inline::parse('!foo { bar: baz } qux', Yaml::PARSE_CUSTOM_TAGS); + } + public function testParseScalarWithCorrectlyQuotedStringShouldReturnString() { $value = "'don''t do somthin'' like that'"; @@ -232,7 +222,7 @@ public function testParseScalarWithCorrectlyQuotedStringShouldReturnString() */ public function testParseReferences($yaml, $expected) { - $this->assertSame($expected, Inline::parse($yaml, 0, array('var' => 'var-value'))); + $this->assertSame($expected, Inline::parse($yaml, 0, ['var' => 'var-value'])); } /** @@ -241,31 +231,31 @@ public function testParseReferences($yaml, $expected) */ public function testParseReferencesAsFifthArgument($yaml, $expected) { - $this->assertSame($expected, Inline::parse($yaml, false, false, false, array('var' => 'var-value'))); + $this->assertSame($expected, Inline::parse($yaml, false, false, false, ['var' => 'var-value'])); } public function getDataForParseReferences() { - return array( - 'scalar' => array('*var', 'var-value'), - 'list' => array('[ *var ]', array('var-value')), - 'list-in-list' => array('[[ *var ]]', array(array('var-value'))), - 'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))), - 'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))), - 'map' => array('{ key: *var }', array('key' => 'var-value')), - 'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))), - 'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))), - ); + return [ + 'scalar' => ['*var', 'var-value'], + 'list' => ['[ *var ]', ['var-value']], + 'list-in-list' => ['[[ *var ]]', [['var-value']]], + 'map-in-list' => ['[ { key: *var } ]', [['key' => 'var-value']]], + 'embedded-mapping-in-list' => ['[ key: *var ]', [['key' => 'var-value']]], + 'map' => ['{ key: *var }', ['key' => 'var-value']], + 'list-in-map' => ['{ key: [*var] }', ['key' => ['var-value']]], + 'map-in-map' => ['{ foo: { bar: *var } }', ['foo' => ['bar' => 'var-value']]], + ]; } public function testParseMapReferenceInSequence() { - $foo = array( + $foo = [ 'a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', - ); - $this->assertSame(array($foo), Inline::parse('[*foo]', 0, array('foo' => $foo))); + ]; + $this->assertSame([$foo], Inline::parse('[*foo]', 0, ['foo' => $foo])); } /** @@ -273,29 +263,25 @@ public function testParseMapReferenceInSequence() */ public function testParseMapReferenceInSequenceAsFifthArgument() { - $foo = array( + $foo = [ 'a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', - ); - $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, false, array('foo' => $foo))); + ]; + $this->assertSame([$foo], Inline::parse('[*foo]', false, false, false, ['foo' => $foo])); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage A reference must contain at least one character at line 1. - */ public function testParseUnquotedAsterisk() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('A reference must contain at least one character at line 1.'); Inline::parse('{ foo: * }'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage A reference must contain at least one character at line 1. - */ public function testParseUnquotedAsteriskFollowedByAComment() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('A reference must contain at least one character at line 1.'); Inline::parse('{ foo: * #foo }'); } @@ -304,19 +290,15 @@ public function testParseUnquotedAsteriskFollowedByAComment() */ public function testParseUnquotedScalarStartingWithReservedIndicator($indicator) { - if (method_exists($this, 'expectExceptionMessage')) { - $this->expectException(ParseException::class); - $this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator)); - } else { - $this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator)); - } + $this->expectException(ParseException::class); + $this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator)); Inline::parse(sprintf('{ foo: %sfoo }', $indicator)); } public function getReservedIndicators() { - return array(array('@'), array('`')); + return [['@'], ['`']]; } /** @@ -324,19 +306,15 @@ public function getReservedIndicators() */ public function testParseUnquotedScalarStartingWithScalarIndicator($indicator) { - if (method_exists($this, 'expectExceptionMessage')) { - $this->expectException(ParseException::class); - $this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator)); - } else { - $this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator)); - } + $this->expectException(ParseException::class); + $this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator)); Inline::parse(sprintf('{ foo: %sfoo }', $indicator)); } public function getScalarIndicators() { - return array(array('|'), array('>')); + return [['|'], ['>']]; } /** @@ -359,240 +337,240 @@ public function testIsHash($array, $expected) public function getDataForIsHash() { - return array( - array(array(), false), - array(array(1, 2, 3), false), - array(array(2 => 1, 1 => 2, 0 => 3), true), - array(array('foo' => 1, 'bar' => 2), true), - ); + return [ + [[], false], + [[1, 2, 3], false], + [[2 => 1, 1 => 2, 0 => 3], true], + [['foo' => 1, 'bar' => 2], true], + ]; } public function getTestsForParse() { - return array( - array('', ''), - array('null', null), - array('false', false), - array('true', true), - array('12', 12), - array('-12', -12), - array('1_2', 12), - array('_12', '_12'), - array('12_', 12), - array('"quoted string"', 'quoted string'), - array("'quoted string'", 'quoted string'), - array('12.30e+02', 12.30e+02), - array('123.45_67', 123.4567), - array('0x4D2', 0x4D2), - array('0x_4_D_2_', 0x4D2), - array('02333', 02333), - array('0_2_3_3_3', 02333), - array('.Inf', -log(0)), - array('-.Inf', log(0)), - array("'686e444'", '686e444'), - array('686e444', 646e444), - array('123456789123456789123456789123456789', '123456789123456789123456789123456789'), - array('"foo\r\nbar"', "foo\r\nbar"), - array("'foo#bar'", 'foo#bar'), - array("'foo # bar'", 'foo # bar'), - array("'#cfcfcf'", '#cfcfcf'), - array('::form_base.html.twig', '::form_base.html.twig'), + return [ + ['', ''], + ['null', null], + ['false', false], + ['true', true], + ['12', 12], + ['-12', -12], + ['1_2', 12], + ['_12', '_12'], + ['12_', 12], + ['"quoted string"', 'quoted string'], + ["'quoted string'", 'quoted string'], + ['12.30e+02', 12.30e+02], + ['123.45_67', 123.4567], + ['0x4D2', 0x4D2], + ['0x_4_D_2_', 0x4D2], + ['02333', 02333], + ['0_2_3_3_3', 02333], + ['.Inf', -log(0)], + ['-.Inf', log(0)], + ["'686e444'", '686e444'], + ['686e444', 646e444], + ['123456789123456789123456789123456789', '123456789123456789123456789123456789'], + ['"foo\r\nbar"', "foo\r\nbar"], + ["'foo#bar'", 'foo#bar'], + ["'foo # bar'", 'foo # bar'], + ["'#cfcfcf'", '#cfcfcf'], + ['::form_base.html.twig', '::form_base.html.twig'], // Pre-YAML-1.2 booleans - array("'y'", 'y'), - array("'n'", 'n'), - array("'yes'", 'yes'), - array("'no'", 'no'), - array("'on'", 'on'), - array("'off'", 'off'), - - array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)), - array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)), - array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)), - array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)), - array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)), - - array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''), - array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''), + ["'y'", 'y'], + ["'n'", 'n'], + ["'yes'", 'yes'], + ["'no'", 'no'], + ["'on'", 'on'], + ["'off'", 'off'], + + ['2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)], + ['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)], + ['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)], + ['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)], + ['1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)], + + ['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''], + ["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''], // sequences // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon - array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)), - array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)), - array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')), + ['[foo, http://urls.are/no/mappings, false, null, 12]', ['foo', 'http://urls.are/no/mappings', false, null, 12]], + ['[ foo , bar , false , null , 12 ]', ['foo', 'bar', false, null, 12]], + ['[\'foo,bar\', \'foo bar\']', ['foo,bar', 'foo bar']], // mappings - array('{foo: bar,bar: foo,"false": false, "null": null,integer: 12}', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)), - array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)), - array('{foo: \'bar\', bar: \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')), - array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')), - array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', array('foo\'' => 'bar', 'bar"' => 'foo: bar')), - array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', array('foo: ' => 'bar', 'bar: ' => 'foo: bar')), - array('{"foo:bar": "baz"}', array('foo:bar' => 'baz')), - array('{"foo":"bar"}', array('foo' => 'bar')), + ['{foo: bar,bar: foo,"false": false, "null": null,integer: 12}', ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12]], + ['{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12]], + ['{foo: \'bar\', bar: \'foo: bar\'}', ['foo' => 'bar', 'bar' => 'foo: bar']], + ['{\'foo\': \'bar\', "bar": \'foo: bar\'}', ['foo' => 'bar', 'bar' => 'foo: bar']], + ['{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', ['foo\'' => 'bar', 'bar"' => 'foo: bar']], + ['{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', ['foo: ' => 'bar', 'bar: ' => 'foo: bar']], + ['{"foo:bar": "baz"}', ['foo:bar' => 'baz']], + ['{"foo":"bar"}', ['foo' => 'bar']], // nested sequences and mappings - array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))), - array('[foo, {bar: foo}]', array('foo', array('bar' => 'foo'))), - array('{ foo: {bar: foo} }', array('foo' => array('bar' => 'foo'))), - array('{ foo: [bar, foo] }', array('foo' => array('bar', 'foo'))), - array('{ foo:{bar: foo} }', array('foo' => array('bar' => 'foo'))), - array('{ foo:[bar, foo] }', array('foo' => array('bar', 'foo'))), + ['[foo, [bar, foo]]', ['foo', ['bar', 'foo']]], + ['[foo, {bar: foo}]', ['foo', ['bar' => 'foo']]], + ['{ foo: {bar: foo} }', ['foo' => ['bar' => 'foo']]], + ['{ foo: [bar, foo] }', ['foo' => ['bar', 'foo']]], + ['{ foo:{bar: foo} }', ['foo' => ['bar' => 'foo']]], + ['{ foo:[bar, foo] }', ['foo' => ['bar', 'foo']]], - array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))), + ['[ foo, [ bar, foo ] ]', ['foo', ['bar', 'foo']]], - array('[{ foo: {bar: foo} }]', array(array('foo' => array('bar' => 'foo')))), + ['[{ foo: {bar: foo} }]', [['foo' => ['bar' => 'foo']]]], - array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))), + ['[foo, [bar, [foo, [bar, foo]], foo]]', ['foo', ['bar', ['foo', ['bar', 'foo']], 'foo']]], - array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))), + ['[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', ['foo', ['bar' => 'foo', 'foo' => ['foo', ['bar' => 'foo']]], ['foo', ['bar' => 'foo']]]], - array('[foo, bar: { foo: bar }]', array('foo', '1' => array('bar' => array('foo' => 'bar')))), - array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')), - ); + ['[foo, bar: { foo: bar }]', ['foo', '1' => ['bar' => ['foo' => 'bar']]]], + ['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']], + ]; } public function getTestsForParseWithMapObjects() { - return array( - array('', ''), - array('null', null), - array('false', false), - array('true', true), - array('12', 12), - array('-12', -12), - array('"quoted string"', 'quoted string'), - array("'quoted string'", 'quoted string'), - array('12.30e+02', 12.30e+02), - array('0x4D2', 0x4D2), - array('02333', 02333), - array('.Inf', -log(0)), - array('-.Inf', log(0)), - array("'686e444'", '686e444'), - array('686e444', 646e444), - array('123456789123456789123456789123456789', '123456789123456789123456789123456789'), - array('"foo\r\nbar"', "foo\r\nbar"), - array("'foo#bar'", 'foo#bar'), - array("'foo # bar'", 'foo # bar'), - array("'#cfcfcf'", '#cfcfcf'), - array('::form_base.html.twig', '::form_base.html.twig'), - - array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)), - array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)), - array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)), - array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)), - array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)), - - array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''), - array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''), + return [ + ['', ''], + ['null', null], + ['false', false], + ['true', true], + ['12', 12], + ['-12', -12], + ['"quoted string"', 'quoted string'], + ["'quoted string'", 'quoted string'], + ['12.30e+02', 12.30e+02], + ['0x4D2', 0x4D2], + ['02333', 02333], + ['.Inf', -log(0)], + ['-.Inf', log(0)], + ["'686e444'", '686e444'], + ['686e444', 646e444], + ['123456789123456789123456789123456789', '123456789123456789123456789123456789'], + ['"foo\r\nbar"', "foo\r\nbar"], + ["'foo#bar'", 'foo#bar'], + ["'foo # bar'", 'foo # bar'], + ["'#cfcfcf'", '#cfcfcf'], + ['::form_base.html.twig', '::form_base.html.twig'], + + ['2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)], + ['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)], + ['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)], + ['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)], + ['1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)], + + ['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''], + ["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''], // sequences // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon - array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)), - array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)), - array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')), + ['[foo, http://urls.are/no/mappings, false, null, 12]', ['foo', 'http://urls.are/no/mappings', false, null, 12]], + ['[ foo , bar , false , null , 12 ]', ['foo', 'bar', false, null, 12]], + ['[\'foo,bar\', \'foo bar\']', ['foo,bar', 'foo bar']], // mappings - array('{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP), - array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP), - array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')), - array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')), - array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', 'bar"' => 'foo: bar')), - array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', 'bar: ' => 'foo: bar')), - array('{"foo:bar": "baz"}', (object) array('foo:bar' => 'baz')), - array('{"foo":"bar"}', (object) array('foo' => 'bar')), + ['{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object) ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12], Yaml::PARSE_OBJECT_FOR_MAP], + ['{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object) ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12], Yaml::PARSE_OBJECT_FOR_MAP], + ['{foo: \'bar\', bar: \'foo: bar\'}', (object) ['foo' => 'bar', 'bar' => 'foo: bar']], + ['{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) ['foo' => 'bar', 'bar' => 'foo: bar']], + ['{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) ['foo\'' => 'bar', 'bar"' => 'foo: bar']], + ['{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) ['foo: ' => 'bar', 'bar: ' => 'foo: bar']], + ['{"foo:bar": "baz"}', (object) ['foo:bar' => 'baz']], + ['{"foo":"bar"}', (object) ['foo' => 'bar']], // nested sequences and mappings - array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))), - array('[foo, {bar: foo}]', array('foo', (object) array('bar' => 'foo'))), - array('{ foo: {bar: foo} }', (object) array('foo' => (object) array('bar' => 'foo'))), - array('{ foo: [bar, foo] }', (object) array('foo' => array('bar', 'foo'))), + ['[foo, [bar, foo]]', ['foo', ['bar', 'foo']]], + ['[foo, {bar: foo}]', ['foo', (object) ['bar' => 'foo']]], + ['{ foo: {bar: foo} }', (object) ['foo' => (object) ['bar' => 'foo']]], + ['{ foo: [bar, foo] }', (object) ['foo' => ['bar', 'foo']]], - array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))), + ['[ foo, [ bar, foo ] ]', ['foo', ['bar', 'foo']]], - array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))), + ['[{ foo: {bar: foo} }]', [(object) ['foo' => (object) ['bar' => 'foo']]]], - array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))), + ['[foo, [bar, [foo, [bar, foo]], foo]]', ['foo', ['bar', ['foo', ['bar', 'foo']], 'foo']]], - array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', (object) array('bar' => 'foo', 'foo' => array('foo', (object) array('bar' => 'foo'))), array('foo', (object) array('bar' => 'foo')))), + ['[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', ['foo', (object) ['bar' => 'foo', 'foo' => ['foo', (object) ['bar' => 'foo']]], ['foo', (object) ['bar' => 'foo']]]], - array('[foo, bar: { foo: bar }]', array('foo', '1' => (object) array('bar' => (object) array('foo' => 'bar')))), - array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', (object) array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')), + ['[foo, bar: { foo: bar }]', ['foo', '1' => (object) ['bar' => (object) ['foo' => 'bar']]]], + ['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', (object) ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']], - array('{}', new \stdClass()), - array('{ foo : bar, bar : {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())), - array('{ foo : [], bar : {} }', (object) array('foo' => array(), 'bar' => new \stdClass())), - array('{foo: \'bar\', bar: {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())), - array('{\'foo\': \'bar\', "bar": {}}', (object) array('foo' => 'bar', 'bar' => new \stdClass())), - array('{\'foo\': \'bar\', "bar": \'{}\'}', (object) array('foo' => 'bar', 'bar' => '{}')), + ['{}', new \stdClass()], + ['{ foo : bar, bar : {} }', (object) ['foo' => 'bar', 'bar' => new \stdClass()]], + ['{ foo : [], bar : {} }', (object) ['foo' => [], 'bar' => new \stdClass()]], + ['{foo: \'bar\', bar: {} }', (object) ['foo' => 'bar', 'bar' => new \stdClass()]], + ['{\'foo\': \'bar\', "bar": {}}', (object) ['foo' => 'bar', 'bar' => new \stdClass()]], + ['{\'foo\': \'bar\', "bar": \'{}\'}', (object) ['foo' => 'bar', 'bar' => '{}']], - array('[foo, [{}, {}]]', array('foo', array(new \stdClass(), new \stdClass()))), - array('[foo, [[], {}]]', array('foo', array(array(), new \stdClass()))), - array('[foo, [[{}, {}], {}]]', array('foo', array(array(new \stdClass(), new \stdClass()), new \stdClass()))), - array('[foo, {bar: {}}]', array('foo', '1' => (object) array('bar' => new \stdClass()))), - ); + ['[foo, [{}, {}]]', ['foo', [new \stdClass(), new \stdClass()]]], + ['[foo, [[], {}]]', ['foo', [[], new \stdClass()]]], + ['[foo, [[{}, {}], {}]]', ['foo', [[new \stdClass(), new \stdClass()], new \stdClass()]]], + ['[foo, {bar: {}}]', ['foo', '1' => (object) ['bar' => new \stdClass()]]], + ]; } public function getTestsForDump() { - return array( - array('null', null), - array('false', false), - array('true', true), - array('12', 12), - array("'1_2'", '1_2'), - array('_12', '_12'), - array("'12_'", '12_'), - array("'quoted string'", 'quoted string'), - array('!!float 1230', 12.30e+02), - array('1234', 0x4D2), - array('1243', 02333), - array("'0x_4_D_2_'", '0x_4_D_2_'), - array("'0_2_3_3_3'", '0_2_3_3_3'), - array('.Inf', -log(0)), - array('-.Inf', log(0)), - array("'686e444'", '686e444'), - array('"foo\r\nbar"', "foo\r\nbar"), - array("'foo#bar'", 'foo#bar'), - array("'foo # bar'", 'foo # bar'), - array("'#cfcfcf'", '#cfcfcf'), - - array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''), - - array("'-dash'", '-dash'), - array("'-'", '-'), + return [ + ['null', null], + ['false', false], + ['true', true], + ['12', 12], + ["'1_2'", '1_2'], + ['_12', '_12'], + ["'12_'", '12_'], + ["'quoted string'", 'quoted string'], + ['!!float 1230', 12.30e+02], + ['1234', 0x4D2], + ['1243', 02333], + ["'0x_4_D_2_'", '0x_4_D_2_'], + ["'0_2_3_3_3'", '0_2_3_3_3'], + ['.Inf', -log(0)], + ['-.Inf', log(0)], + ["'686e444'", '686e444'], + ['"foo\r\nbar"', "foo\r\nbar"], + ["'foo#bar'", 'foo#bar'], + ["'foo # bar'", 'foo # bar'], + ["'#cfcfcf'", '#cfcfcf'], + + ["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''], + + ["'-dash'", '-dash'], + ["'-'", '-'], // Pre-YAML-1.2 booleans - array("'y'", 'y'), - array("'n'", 'n'), - array("'yes'", 'yes'), - array("'no'", 'no'), - array("'on'", 'on'), - array("'off'", 'off'), + ["'y'", 'y'], + ["'n'", 'n'], + ["'yes'", 'yes'], + ["'no'", 'no'], + ["'on'", 'on'], + ["'off'", 'off'], // sequences - array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)), - array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')), + ['[foo, bar, false, null, 12]', ['foo', 'bar', false, null, 12]], + ['[\'foo,bar\', \'foo bar\']', ['foo,bar', 'foo bar']], // mappings - array('{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)), - array('{ foo: bar, bar: \'foo: bar\' }', array('foo' => 'bar', 'bar' => 'foo: bar')), + ['{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', ['foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12]], + ['{ foo: bar, bar: \'foo: bar\' }', ['foo' => 'bar', 'bar' => 'foo: bar']], // nested sequences and mappings - array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))), + ['[foo, [bar, foo]]', ['foo', ['bar', 'foo']]], - array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))), + ['[foo, [bar, [foo, [bar, foo]], foo]]', ['foo', ['bar', ['foo', ['bar', 'foo']], 'foo']]], - array('{ foo: { bar: foo } }', array('foo' => array('bar' => 'foo'))), + ['{ foo: { bar: foo } }', ['foo' => ['bar' => 'foo']]], - array('[foo, { bar: foo }]', array('foo', array('bar' => 'foo'))), + ['[foo, { bar: foo }]', ['foo', ['bar' => 'foo']]], - array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))), + ['[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', ['foo', ['bar' => 'foo', 'foo' => ['foo', ['bar' => 'foo']]], ['foo', ['bar' => 'foo']]]], - array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')), + ['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']], - array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))), - ); + ['{ foo: { bar: { 1: 2, baz: 3 } } }', ['foo' => ['bar' => [1 => 2, 'baz' => 3]]]], + ]; } /** @@ -625,12 +603,12 @@ public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $ public function getTimestampTests() { - return array( - 'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1, '+0000'), - 'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1, '-0500'), - 'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1, '-0500'), - 'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0, '+0000'), - ); + return [ + 'canonical' => ['2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1, '+0000'], + 'ISO-8601' => ['2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1, '-0500'], + 'spaced' => ['2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1, '-0500'], + 'date' => ['2001-12-15', 2001, 12, 15, 0, 0, 0, '+0000'], + ]; } /** @@ -647,7 +625,7 @@ public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $mont $expected->setTime($hour, $minute, $second); } - $expectedNested = array('nested' => array($expected)); + $expectedNested = ['nested' => [$expected]]; $yamlNested = "{nested: [$yaml]}"; $this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME)); @@ -663,13 +641,13 @@ public function testDumpDateTime($dateTime, $expected) public function getDateTimeDumpTests() { - $tests = array(); + $tests = []; $dateTime = new \DateTime('2001-12-15 21:59:43', new \DateTimeZone('UTC')); - $tests['date-time-utc'] = array($dateTime, '2001-12-15T21:59:43+00:00'); + $tests['date-time-utc'] = [$dateTime, '2001-12-15T21:59:43+00:00']; $dateTime = new \DateTimeImmutable('2001-07-15 21:59:43', new \DateTimeZone('Europe/Berlin')); - $tests['immutable-date-time-europe-berlin'] = array($dateTime, '2001-07-15T21:59:43+02:00'); + $tests['immutable-date-time-europe-berlin'] = [$dateTime, '2001-07-15T21:59:43+02:00']; return $tests; } @@ -684,44 +662,38 @@ public function testParseBinaryData($data) public function getBinaryData() { - return array( - 'enclosed with double quotes' => array('!!binary "SGVsbG8gd29ybGQ="'), - 'enclosed with single quotes' => array("!!binary 'SGVsbG8gd29ybGQ='"), - 'containing spaces' => array('!!binary "SGVs bG8gd 29ybGQ="'), - ); + return [ + 'enclosed with double quotes' => ['!!binary "SGVsbG8gd29ybGQ="'], + 'enclosed with single quotes' => ["!!binary 'SGVsbG8gd29ybGQ='"], + 'containing spaces' => ['!!binary "SGVs bG8gd 29ybGQ="'], + ]; } /** * @dataProvider getInvalidBinaryData - * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testParseInvalidBinaryData($data, $expectedMessage) { - if (method_exists($this, 'expectException')) { - $this->expectExceptionMessageRegExp($expectedMessage); - } else { - $this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage); - } + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessageRegExp($expectedMessage); Inline::parse($data); } public function getInvalidBinaryData() { - return array( - 'length not a multiple of four' => array('!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'), - 'invalid characters' => array('!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'), - 'too many equals characters' => array('!!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'), - 'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'), - ); + return [ + 'length not a multiple of four' => ['!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'], + 'invalid characters' => ['!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'], + 'too many equals characters' => ['!!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'], + 'misplaced equals character' => ['!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'], + ]; } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1. - */ public function testNotSupportedMissingValue() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Malformed inline YAML string: {this, is not, supported} at line 1.'); Inline::parse('{this, is not, supported}'); } @@ -729,7 +701,7 @@ public function testVeryLongQuotedStrings() { $longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000); - $yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes)); + $yamlString = Inline::dump(['longStringWithQuotes' => $longStringWithQuotes]); $arrayFromYaml = Inline::parse($yamlString); $this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']); @@ -741,7 +713,7 @@ public function testVeryLongQuotedStrings() */ public function testOmittedMappingKeyIsParsedAsColon() { - $this->assertSame(array(':' => 'foo'), Inline::parse('{: foo}')); + $this->assertSame([':' => 'foo'], Inline::parse('{: foo}')); } /** @@ -754,15 +726,15 @@ public function testParseMissingMappingValueAsNull($yaml, $expected) public function getTestsForNullValues() { - return array( - 'null before closing curly brace' => array('{foo:}', array('foo' => null)), - 'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')), - ); + return [ + 'null before closing curly brace' => ['{foo:}', ['foo' => null]], + 'null before comma' => ['{foo:, bar: baz}', ['foo' => null, 'bar' => 'baz']], + ]; } public function testTheEmptyStringIsAValidMappingKey() { - $this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }')); + $this->assertSame(['' => 'foo'], Inline::parse('{ "": foo }')); } /** @@ -788,12 +760,12 @@ public function testExplicitStringCastingOfMappingKeys($yaml, $expected) public function getNotPhpCompatibleMappingKeyData() { - return array( - 'boolean-true' => array('{true: "foo"}', array('true' => 'foo')), - 'boolean-false' => array('{false: "foo"}', array('false' => 'foo')), - 'null' => array('{null: "foo"}', array('null' => 'foo')), - 'float' => array('{0.25: "foo"}', array('0.25' => 'foo')), - ); + return [ + 'boolean-true' => ['{true: "foo"}', ['true' => 'foo']], + 'boolean-false' => ['{false: "foo"}', ['false' => 'foo']], + 'null' => ['{null: "foo"}', ['null' => 'foo']], + 'float' => ['{0.25: "foo"}', ['0.25' => 'foo']], + ]; } /** @@ -802,15 +774,29 @@ public function getNotPhpCompatibleMappingKeyData() */ public function testDeprecatedStrTag() { - $this->assertSame(array('foo' => 'bar'), Inline::parse('{ foo: !str bar }')); + $this->assertSame(['foo' => 'bar'], Inline::parse('{ foo: !str bar }')); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Unexpected end of line, expected one of ",}" at line 1 (near "{abc: 'def'"). - */ public function testUnfinishedInlineMap() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Unexpected end of line, expected one of ",}" at line 1 (near "{abc: \'def\'").'); Inline::parse("{abc: 'def'"); } + + /** + * @dataProvider getTestsForOctalNumbers + */ + public function testParseOctalNumbers($expected, $yaml) + { + self::assertSame($expected, Inline::parse($yaml)); + } + + public function getTestsForOctalNumbers() + { + return [ + 'positive octal number' => [28, '034'], + 'negative octal number' => [-28, '-034'], + ]; + } } diff --git a/includes/vendor/symfony/yaml/Tests/ParserTest.php b/includes/vendor/symfony/yaml/Tests/ParserTest.php index 38ed1b34..dc7c122d 100644 --- a/includes/vendor/symfony/yaml/Tests/ParserTest.php +++ b/includes/vendor/symfony/yaml/Tests/ParserTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Yaml\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Tag\TaggedValue; use Symfony\Component\Yaml\Yaml; @@ -39,21 +38,19 @@ protected function tearDown() */ public function testSpecifications($expected, $yaml, $comment, $deprecated) { - $deprecations = array(); + $deprecations = []; if ($deprecated) { set_error_handler(function ($type, $msg) use (&$deprecations) { if (E_USER_DEPRECATED !== $type) { restore_error_handler(); - if (class_exists('PHPUnit_Util_ErrorHandler')) { - return \call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', \func_get_args()); - } - return \call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', \func_get_args()); } $deprecations[] = $msg; + + return null; }); } @@ -63,7 +60,7 @@ public function testSpecifications($expected, $yaml, $comment, $deprecated) restore_error_handler(); $this->assertCount(1, $deprecations); - $this->assertContains(true !== $deprecated ? $deprecated : 'Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0 on line 1.', $deprecations[0]); + $this->assertStringContainsString(true !== $deprecated ? $deprecated : 'Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0 on line 1.', $deprecations[0]); } } @@ -104,16 +101,16 @@ public function getLegacyNonStringMappingKeysData() public function testTabsInYaml() { // test tabs in YAML - $yamls = array( + $yamls = [ "foo:\n bar", "foo:\n bar", "foo:\n bar", "foo:\n bar", - ); + ]; foreach ($yamls as $yaml) { try { - $content = $this->parser->parse($yaml); + $this->parser->parse($yaml); $this->fail('YAML files must not contain tabs'); } catch (\Exception $e) { @@ -136,7 +133,7 @@ public function testEndOfTheDocumentMarker() public function getBlockChompingTests() { - $tests = array(); + $tests = []; $yaml = <<<'EOF' foo: |- @@ -147,11 +144,11 @@ public function getBlockChompingTests() two EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo", 'bar' => "one\ntwo", - ); - $tests['Literal block chomping strip with single trailing newline'] = array($expected, $yaml); + ]; + $tests['Literal block chomping strip with single trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: |- @@ -164,19 +161,19 @@ public function getBlockChompingTests() EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo", 'bar' => "one\ntwo", - ); - $tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml); + ]; + $tests['Literal block chomping strip with multiple trailing newlines'] = [$expected, $yaml]; $yaml = <<<'EOF' {} EOF; - $expected = array(); - $tests['Literal block chomping strip with multiple trailing newlines after a 1-liner'] = array($expected, $yaml); + $expected = []; + $tests['Literal block chomping strip with multiple trailing newlines after a 1-liner'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: |- @@ -186,11 +183,11 @@ public function getBlockChompingTests() one two EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo", 'bar' => "one\ntwo", - ); - $tests['Literal block chomping strip without trailing newline'] = array($expected, $yaml); + ]; + $tests['Literal block chomping strip without trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: | @@ -201,11 +198,11 @@ public function getBlockChompingTests() two EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo\n", 'bar' => "one\ntwo\n", - ); - $tests['Literal block chomping clip with single trailing newline'] = array($expected, $yaml); + ]; + $tests['Literal block chomping clip with single trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: | @@ -218,11 +215,11 @@ public function getBlockChompingTests() EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo\n", 'bar' => "one\ntwo\n", - ); - $tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml); + ]; + $tests['Literal block chomping clip with multiple trailing newlines'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: @@ -231,14 +228,14 @@ public function getBlockChompingTests() two EOF; - $expected = array( - 'foo' => array( - array( + $expected = [ + 'foo' => [ + [ 'bar' => "one\n\ntwo", - ), - ), - ); - $tests['Literal block chomping clip with embedded blank line inside unindented collection'] = array($expected, $yaml); + ], + ], + ]; + $tests['Literal block chomping clip with embedded blank line inside unindented collection'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: | @@ -248,11 +245,11 @@ public function getBlockChompingTests() one two EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo\n", 'bar' => "one\ntwo", - ); - $tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml); + ]; + $tests['Literal block chomping clip without trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: |+ @@ -263,11 +260,11 @@ public function getBlockChompingTests() two EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo\n", 'bar' => "one\ntwo\n", - ); - $tests['Literal block chomping keep with single trailing newline'] = array($expected, $yaml); + ]; + $tests['Literal block chomping keep with single trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: |+ @@ -280,11 +277,11 @@ public function getBlockChompingTests() EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo\n\n", 'bar' => "one\ntwo\n\n", - ); - $tests['Literal block chomping keep with multiple trailing newlines'] = array($expected, $yaml); + ]; + $tests['Literal block chomping keep with multiple trailing newlines'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: |+ @@ -294,11 +291,11 @@ public function getBlockChompingTests() one two EOF; - $expected = array( + $expected = [ 'foo' => "one\ntwo\n", 'bar' => "one\ntwo", - ); - $tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml); + ]; + $tests['Literal block chomping keep without trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: >- @@ -309,11 +306,11 @@ public function getBlockChompingTests() two EOF; - $expected = array( + $expected = [ 'foo' => 'one two', 'bar' => 'one two', - ); - $tests['Folded block chomping strip with single trailing newline'] = array($expected, $yaml); + ]; + $tests['Folded block chomping strip with single trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: >- @@ -326,11 +323,11 @@ public function getBlockChompingTests() EOF; - $expected = array( + $expected = [ 'foo' => 'one two', 'bar' => 'one two', - ); - $tests['Folded block chomping strip with multiple trailing newlines'] = array($expected, $yaml); + ]; + $tests['Folded block chomping strip with multiple trailing newlines'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: >- @@ -340,11 +337,11 @@ public function getBlockChompingTests() one two EOF; - $expected = array( + $expected = [ 'foo' => 'one two', 'bar' => 'one two', - ); - $tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml); + ]; + $tests['Folded block chomping strip without trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: > @@ -355,11 +352,11 @@ public function getBlockChompingTests() two EOF; - $expected = array( + $expected = [ 'foo' => "one two\n", 'bar' => "one two\n", - ); - $tests['Folded block chomping clip with single trailing newline'] = array($expected, $yaml); + ]; + $tests['Folded block chomping clip with single trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: > @@ -372,11 +369,11 @@ public function getBlockChompingTests() EOF; - $expected = array( + $expected = [ 'foo' => "one two\n", 'bar' => "one two\n", - ); - $tests['Folded block chomping clip with multiple trailing newlines'] = array($expected, $yaml); + ]; + $tests['Folded block chomping clip with multiple trailing newlines'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: > @@ -386,11 +383,11 @@ public function getBlockChompingTests() one two EOF; - $expected = array( + $expected = [ 'foo' => "one two\n", 'bar' => 'one two', - ); - $tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml); + ]; + $tests['Folded block chomping clip without trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: >+ @@ -401,11 +398,11 @@ public function getBlockChompingTests() two EOF; - $expected = array( + $expected = [ 'foo' => "one two\n", 'bar' => "one two\n", - ); - $tests['Folded block chomping keep with single trailing newline'] = array($expected, $yaml); + ]; + $tests['Folded block chomping keep with single trailing newline'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: >+ @@ -418,11 +415,11 @@ public function getBlockChompingTests() EOF; - $expected = array( + $expected = [ 'foo' => "one two\n\n", 'bar' => "one two\n\n", - ); - $tests['Folded block chomping keep with multiple trailing newlines'] = array($expected, $yaml); + ]; + $tests['Folded block chomping keep with multiple trailing newlines'] = [$expected, $yaml]; $yaml = <<<'EOF' foo: >+ @@ -432,11 +429,11 @@ public function getBlockChompingTests() one two EOF; - $expected = array( + $expected = [ 'foo' => "one two\n", 'bar' => 'one two', - ); - $tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml); + ]; + $tests['Folded block chomping keep without trailing newline'] = [$expected, $yaml]; return $tests; } @@ -463,9 +460,9 @@ public function testBlockLiteralWithLeadingNewlines() bar EOF; - $expected = array( + $expected = [ 'foo' => "\n\nbar", - ); + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -476,7 +473,7 @@ public function testObjectSupportEnabled() foo: !php/object O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";} bar: 1 EOF; - $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects'); + $this->assertEquals(['foo' => new B(), 'bar' => 1], $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects'); } /** @@ -488,7 +485,7 @@ public function testObjectSupportEnabledPassingTrue() foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";} bar: 1 EOF; - $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects'); + $this->assertEquals(['foo' => new B(), 'bar' => 1], $this->parser->parse($input, false, true), '->parse() is able to parse objects'); } /** @@ -497,25 +494,25 @@ public function testObjectSupportEnabledPassingTrue() */ public function testObjectSupportEnabledWithDeprecatedTag($yaml) { - $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($yaml, Yaml::PARSE_OBJECT), '->parse() is able to parse objects'); + $this->assertEquals(['foo' => new B(), 'bar' => 1], $this->parser->parse($yaml, Yaml::PARSE_OBJECT), '->parse() is able to parse objects'); } public function deprecatedObjectValueProvider() { - return array( - array( + return [ + [ <<assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects'); + $this->assertEquals(['foo' => null, 'bar' => 1], $this->parser->parse($input), '->parse() does not parse objects'); } /** @@ -547,7 +544,7 @@ public function testObjectForMapEnabledWithMappingUsingBooleanToggles($yaml, $ex public function getObjectForMapTests() { - $tests = array(); + $tests = []; $yaml = <<<'EOF' foo: @@ -555,20 +552,20 @@ public function getObjectForMapTests() EOF; $expected = new \stdClass(); $expected->foo = new \stdClass(); - $expected->foo->fiz = array('cat'); - $tests['mapping'] = array($yaml, $expected); + $expected->foo->fiz = ['cat']; + $tests['mapping'] = [$yaml, $expected]; $yaml = '{ "foo": "bar", "fiz": "cat" }'; $expected = new \stdClass(); $expected->foo = 'bar'; $expected->fiz = 'cat'; - $tests['inline-mapping'] = array($yaml, $expected); + $tests['inline-mapping'] = [$yaml, $expected]; $yaml = "foo: bar\nbaz: foobar"; $expected = new \stdClass(); $expected->foo = 'bar'; $expected->baz = 'foobar'; - $tests['object-for-map-is-applied-after-parsing'] = array($yaml, $expected); + $tests['object-for-map-is-applied-after-parsing'] = [$yaml, $expected]; $yaml = <<<'EOT' array: @@ -576,12 +573,12 @@ public function getObjectForMapTests() - key: two EOT; $expected = new \stdClass(); - $expected->array = array(); + $expected->array = []; $expected->array[0] = new \stdClass(); $expected->array[0]->key = 'one'; $expected->array[1] = new \stdClass(); $expected->array[1]->key = 'two'; - $tests['nest-map-and-sequence'] = array($yaml, $expected); + $tests['nest-map-and-sequence'] = [$yaml, $expected]; $yaml = <<<'YAML' map: @@ -592,7 +589,7 @@ public function getObjectForMapTests() $expected->map = new \stdClass(); $expected->map->{1} = 'one'; $expected->map->{2} = 'two'; - $tests['numeric-keys'] = array($yaml, $expected); + $tests['numeric-keys'] = [$yaml, $expected]; $yaml = <<<'YAML' map: @@ -603,17 +600,17 @@ public function getObjectForMapTests() $expected->map = new \stdClass(); $expected->map->{0} = 'one'; $expected->map->{1} = 'two'; - $tests['zero-indexed-numeric-keys'] = array($yaml, $expected); + $tests['zero-indexed-numeric-keys'] = [$yaml, $expected]; return $tests; } /** * @dataProvider invalidDumpedObjectProvider - * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testObjectsSupportDisabledWithExceptions($yaml) { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); } @@ -621,9 +618,9 @@ public function testCanParseContentWithTrailingSpaces() { $yaml = "items: \n foo: bar"; - $expected = array( - 'items' => array('foo' => 'bar'), - ); + $expected = [ + 'items' => ['foo' => 'bar'], + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -631,10 +628,10 @@ public function testCanParseContentWithTrailingSpaces() /** * @group legacy * @dataProvider invalidDumpedObjectProvider - * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testObjectsSupportDisabledWithExceptionsUsingBooleanToggles($yaml) { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $this->parser->parse($yaml, true); } @@ -649,10 +646,10 @@ public function invalidDumpedObjectProvider() bar: 1 EOF; - return array( - 'yaml-tag' => array($yamlTag), - 'local-tag' => array($localTag), - ); + return [ + 'yaml-tag' => [$yamlTag], + 'local-tag' => [$localTag], + ]; } /** @@ -660,11 +657,11 @@ public function invalidDumpedObjectProvider() */ public function testNonUtf8Exception() { - $yamls = array( + $yamls = [ iconv('UTF-8', 'ISO-8859-1', "foo: 'äöüß'"), iconv('UTF-8', 'ISO-8859-15', "euro: '€'"), iconv('UTF-8', 'CP1252', "cp1252: '©ÉÇáñ'"), - ); + ]; foreach ($yamls as $yaml) { try { @@ -677,11 +674,9 @@ public function testNonUtf8Exception() } } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testUnindentedCollectionException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $yaml = <<<'EOF' collection: @@ -694,11 +689,9 @@ public function testUnindentedCollectionException() $this->parser->parse($yaml); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testShortcutKeyUnindentedCollectionException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $yaml = <<<'EOF' collection: @@ -710,12 +703,10 @@ public function testShortcutKeyUnindentedCollectionException() $this->parser->parse($yaml); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessageRegExp /^Multiple documents are not supported.+/ - */ public function testMultipleDocumentsNotSupportedException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessageRegExp('/^Multiple documents are not supported.+/'); Yaml::parse(<<<'EOL' # Ranking of 1998 home runs --- @@ -731,11 +722,9 @@ public function testMultipleDocumentsNotSupportedException() ); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testSequenceInAMapping() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); Yaml::parse(<<<'EOF' yaml: hash: me @@ -755,19 +744,19 @@ public function testSequenceInMappingStartedBySingleDashLine() - foo d: e EOT; - $expected = array( - 'a' => array( - array( - 'b' => array( - array( + $expected = [ + 'a' => [ + [ + 'b' => [ + [ 'bar' => 'baz', - ), - ), - ), + ], + ], + ], 'foo', - ), + ], 'd' => 'e', - ); + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -781,12 +770,12 @@ public function testSequenceFollowedByCommentEmbeddedInMapping() # comment d: e EOT; - $expected = array( - 'a' => array( - 'b' => array('c'), + $expected = [ + 'a' => [ + 'b' => ['c'], 'd' => 'e', - ), - ); + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -802,25 +791,25 @@ public function testNonStringFollowedByCommentEmbeddedInMapping() 1.1 # another comment EOT; - $expected = array( - 'a' => array( - 'b' => array(), + $expected = [ + 'a' => [ + 'b' => [], 'd' => 1.1, - ), - ); + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } public function getParseExceptionNotAffectedMultiLineStringLastResortParsing() { - $tests = array(); + $tests = []; $yaml = <<<'EOT' a b: EOT; - $tests['parse error on first line'] = array($yaml); + $tests['parse error on first line'] = [$yaml]; $yaml = <<<'EOT' a @@ -828,22 +817,22 @@ public function getParseExceptionNotAffectedMultiLineStringLastResortParsing() b c: EOT; - $tests['parse error due to inconsistent indentation'] = array($yaml); + $tests['parse error due to inconsistent indentation'] = [$yaml]; $yaml = <<<'EOT' & * ! | > ' " % @ ` #, { asd a;sdasd }-@^qw3 EOT; - $tests['symfony/symfony/issues/22967#issuecomment-322067742'] = array($yaml); + $tests['symfony/symfony/issues/22967#issuecomment-322067742'] = [$yaml]; return $tests; } /** * @dataProvider getParseExceptionNotAffectedMultiLineStringLastResortParsing - * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testParseExceptionNotAffectedByMultiLineStringLastResortParsing($yaml) { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $this->parser->parse($yaml); } @@ -855,9 +844,9 @@ public function testMultiLineStringLastResortParsing() true yes you can EOT; - $expected = array( + $expected = [ 'test' => 'You can have things that don\'t look like strings here true yes you can', - ); + ]; $this->assertSame($expected, $this->parser->parse($yaml)); @@ -866,18 +855,16 @@ public function testMultiLineStringLastResortParsing() b c EOT; - $expected = array( + $expected = [ 'a' => 'b c', - ); + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - */ public function testMappingInASequence() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); Yaml::parse(<<<'EOF' yaml: - array stuff @@ -886,12 +873,10 @@ public function testMappingInASequence() ); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage missing colon - */ public function testScalarInSequence() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('missing colon'); Yaml::parse(<<<'EOF' foo: - bar @@ -922,11 +907,11 @@ public function testMappingDuplicateKeyBlock() child: duplicate child: duplicate EOD; - $expected = array( - 'parent' => array( + $expected = [ + 'parent' => [ 'child' => 'first', - ), - ); + ], + ]; $this->assertSame($expected, Yaml::parse($input)); } @@ -939,11 +924,11 @@ public function testMappingDuplicateKeyFlow() parent: { child: first, child: duplicate } parent: { child: duplicate, child: duplicate } EOD; - $expected = array( - 'parent' => array( + $expected = [ + 'parent' => [ 'child' => 'first', - ), - ); + ], + ]; $this->assertSame($expected, Yaml::parse($input)); } @@ -960,30 +945,30 @@ public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber public function getParseExceptionOnDuplicateData() { - $tests = array(); + $tests = []; $yaml = <<assertEquals(array('hash' => null), Yaml::parse($input)); + $this->assertEquals(['hash' => null], Yaml::parse($input)); } public function testCommentAtTheRootIndent() { - $this->assertEquals(array( - 'services' => array( - 'app.foo_service' => array( + $this->assertEquals([ + 'services' => [ + 'app.foo_service' => [ 'class' => 'Foo', - ), - 'app/bar_service' => array( + ], + 'app/bar_service' => [ 'class' => 'Bar', - ), - ), - ), Yaml::parse(<<<'EOF' + ], + ], + ], Yaml::parse(<<<'EOF' # comment 1 services: # comment 2 @@ -1052,7 +1037,7 @@ class: Bar public function testStringBlockWithComments() { - $this->assertEquals(array('content' => <<<'EOT' + $this->assertEquals(['content' => <<<'EOT' # comment 1 header @@ -1063,7 +1048,7 @@ public function testStringBlockWithComments() footer # comment3 EOT - ), Yaml::parse(<<<'EOF' + ], Yaml::parse(<<<'EOF' content: | # comment 1 header @@ -1080,7 +1065,7 @@ public function testStringBlockWithComments() public function testFoldedStringBlockWithComments() { - $this->assertEquals(array(array('content' => <<<'EOT' + $this->assertEquals([['content' => <<<'EOT' # comment 1 header @@ -1091,7 +1076,7 @@ public function testFoldedStringBlockWithComments() footer # comment3 EOT - )), Yaml::parse(<<<'EOF' + ]], Yaml::parse(<<<'EOF' - content: | # comment 1 @@ -1109,7 +1094,7 @@ public function testFoldedStringBlockWithComments() public function testNestedFoldedStringBlockWithComments() { - $this->assertEquals(array(array( + $this->assertEquals([[ 'title' => 'some title', 'content' => <<<'EOT' # comment 1 @@ -1122,7 +1107,7 @@ public function testNestedFoldedStringBlockWithComments() footer # comment3 EOT - )), Yaml::parse(<<<'EOF' + ]], Yaml::parse(<<<'EOF' - title: some title content: | @@ -1141,17 +1126,17 @@ public function testNestedFoldedStringBlockWithComments() public function testReferenceResolvingInInlineStrings() { - $this->assertEquals(array( + $this->assertEquals([ 'var' => 'var-value', 'scalar' => 'var-value', - 'list' => array('var-value'), - 'list_in_list' => array(array('var-value')), - 'map_in_list' => array(array('key' => 'var-value')), - 'embedded_mapping' => array(array('key' => 'var-value')), - 'map' => array('key' => 'var-value'), - 'list_in_map' => array('key' => array('var-value')), - 'map_in_map' => array('foo' => array('bar' => 'var-value')), - ), Yaml::parse(<<<'EOF' + 'list' => ['var-value'], + 'list_in_list' => [['var-value']], + 'map_in_list' => [['key' => 'var-value']], + 'embedded_mapping' => [['key' => 'var-value']], + 'map' => ['key' => 'var-value'], + 'list_in_map' => ['key' => ['var-value']], + 'map_in_map' => ['foo' => ['bar' => 'var-value']], + ], Yaml::parse(<<<'EOF' var: &var var-value scalar: *var list: [ *var ] @@ -1173,7 +1158,7 @@ public function testYamlDirective() foo: 1 bar: 2 EOF; - $this->assertEquals(array('foo' => 1, 'bar' => 2), $this->parser->parse($yaml)); + $this->assertEquals(['foo' => 1, 'bar' => 2], $this->parser->parse($yaml)); } /** @@ -1188,12 +1173,12 @@ public function testFloatKeys() 1.3: "baz" EOF; - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ '1.2' => 'bar', '1.3' => 'baz', - ), - ); + ], + ]; $this->assertEquals($expected, $this->parser->parse($yaml)); } @@ -1209,10 +1194,10 @@ public function testBooleanKeys() false: bar EOF; - $expected = array( + $expected = [ 1 => 'foo', 0 => 'bar', - ); + ]; $this->assertEquals($expected, $this->parser->parse($yaml)); } @@ -1230,24 +1215,22 @@ public function testExplicitStringCasting() '~': 'null' EOF; - $expected = array( + $expected = [ '1.2' => 'bar', '1.3' => 'baz', 'true' => 'foo', 'false' => 'bar', 'null' => 'null', '~' => 'null', - ); + ]; $this->assertEquals($expected, $this->parser->parse($yaml)); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage A colon cannot be used in an unquoted mapping value - */ public function testColonInMappingValueException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('A colon cannot be used in an unquoted mapping value'); $yaml = <<<'EOF' foo: bar: baz EOF; @@ -1262,7 +1245,7 @@ public function testColonInMappingValueExceptionNotTriggeredByColonInComment() bar: foobar # Note: a comment after a colon EOT; - $this->assertSame(array('foo' => array('bar' => 'foobar')), $this->parser->parse($yaml)); + $this->assertSame(['foo' => ['bar' => 'foobar']], $this->parser->parse($yaml)); } /** @@ -1275,7 +1258,7 @@ public function testCommentLikeStringsAreNotStrippedInBlockScalars($yaml, $expec public function getCommentLikeStringInScalarBlockData() { - $tests = array(); + $tests = []; $yaml = <<<'EOT' pages: @@ -1292,9 +1275,9 @@ public function getCommentLikeStringInScalarBlockData() footer # comment3 EOT; - $expected = array( - 'pages' => array( - array( + $expected = [ + 'pages' => [ + [ 'title' => 'some title', 'content' => <<<'EOT' # comment 1 @@ -1308,10 +1291,10 @@ public function getCommentLikeStringInScalarBlockData() footer # comment3 EOT , - ), - ), - ); - $tests[] = array($yaml, $expected); + ], + ], + ]; + $tests[] = [$yaml, $expected]; $yaml = <<<'EOT' test: | @@ -1328,7 +1311,7 @@ public function getCommentLikeStringInScalarBlockData() # bar baz EOT; - $expected = array( + $expected = [ 'test' => <<<'EOT' foo # bar @@ -1336,8 +1319,8 @@ public function getCommentLikeStringInScalarBlockData() EOT , - 'collection' => array( - array( + 'collection' => [ + [ 'one' => <<<'EOT' foo # bar @@ -1345,18 +1328,18 @@ public function getCommentLikeStringInScalarBlockData() EOT , - ), - array( + ], + [ 'two' => <<<'EOT' foo # bar baz EOT , - ), - ), - ); - $tests[] = array($yaml, $expected); + ], + ], + ]; + $tests[] = [$yaml, $expected]; $yaml = <<<'EOT' foo: @@ -1368,17 +1351,17 @@ public function getCommentLikeStringInScalarBlockData() # comment foobar: ~ EOT; - $expected = array( - 'foo' => array( - 'bar' => array( + $expected = [ + 'foo' => [ + 'bar' => [ 'scalar-block' => "line1 line2>\n", - ), - 'baz' => array( + ], + 'baz' => [ 'foobar' => null, - ), - ), - ); - $tests[] = array($yaml, $expected); + ], + ], + ]; + $tests[] = [$yaml, $expected]; $yaml = <<<'EOT' a: @@ -1388,13 +1371,13 @@ public function getCommentLikeStringInScalarBlockData() # second row d: hello EOT; - $expected = array( - 'a' => array( + $expected = [ + 'a' => [ 'b' => 'hello', 'd' => 'hello', - ), - ); - $tests[] = array($yaml, $expected); + ], + ]; + $tests[] = [$yaml, $expected]; return $tests; } @@ -1412,13 +1395,13 @@ public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks() EOT; $this->assertSame( - array( + [ 'test' => <<<'EOT'

A heading

  • a list
  • may be a good example
EOT , - ), + ], $this->parser->parse($yaml) ); } @@ -1436,7 +1419,7 @@ public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks() EOT; $this->assertSame( - array( + [ 'test' => <<<'EOT'

A heading

    @@ -1445,7 +1428,7 @@ public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks()
EOT , - ), + ], $this->parser->parse($yaml) ); } @@ -1455,85 +1438,81 @@ public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks() */ public function testParseBinaryData($data) { - $this->assertSame(array('data' => 'Hello world'), $this->parser->parse($data)); + $this->assertSame(['data' => 'Hello world'], $this->parser->parse($data)); } public function getBinaryData() { - return array( - 'enclosed with double quotes' => array('data: !!binary "SGVsbG8gd29ybGQ="'), - 'enclosed with single quotes' => array("data: !!binary 'SGVsbG8gd29ybGQ='"), - 'containing spaces' => array('data: !!binary "SGVs bG8gd 29ybGQ="'), - 'in block scalar' => array( + return [ + 'enclosed with double quotes' => ['data: !!binary "SGVsbG8gd29ybGQ="'], + 'enclosed with single quotes' => ["data: !!binary 'SGVsbG8gd29ybGQ='"], + 'containing spaces' => ['data: !!binary "SGVs bG8gd 29ybGQ="'], + 'in block scalar' => [ <<<'EOT' data: !!binary | SGVsbG8gd29ybGQ= EOT - ), - 'containing spaces in block scalar' => array( + ], + 'containing spaces in block scalar' => [ <<<'EOT' data: !!binary | SGVs bG8gd 29ybGQ= EOT - ), - ); + ], + ]; } /** * @dataProvider getInvalidBinaryData - * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testParseInvalidBinaryData($data, $expectedMessage) { - if (method_exists($this, 'expectException')) { - $this->expectExceptionMessageRegExp($expectedMessage); - } else { - $this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage); - } + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessageRegExp($expectedMessage); $this->parser->parse($data); } public function getInvalidBinaryData() { - return array( - 'length not a multiple of four' => array('data: !!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'), - 'invalid characters' => array('!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'), - 'too many equals characters' => array('data: !!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'), - 'misplaced equals character' => array('data: !!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'), - 'length not a multiple of four in block scalar' => array( + return [ + 'length not a multiple of four' => ['data: !!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'], + 'invalid characters' => ['!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'], + 'too many equals characters' => ['data: !!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'], + 'misplaced equals character' => ['data: !!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'], + 'length not a multiple of four in block scalar' => [ <<<'EOT' data: !!binary | SGVsbG8d29ybGQ= EOT , '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/', - ), - 'invalid characters in block scalar' => array( + ], + 'invalid characters in block scalar' => [ <<<'EOT' data: !!binary | SGVsbG8#d29ybGQ= EOT , '/The base64 encoded data \(.*\) contains invalid characters/', - ), - 'too many equals characters in block scalar' => array( + ], + 'too many equals characters in block scalar' => [ <<<'EOT' data: !!binary | SGVsbG8gd29yb=== EOT , '/The base64 encoded data \(.*\) contains invalid characters/', - ), - 'misplaced equals character in block scalar' => array( + ], + 'misplaced equals character in block scalar' => [ <<<'EOT' data: !!binary | SGVsbG8gd29ybG=Q EOT , '/The base64 encoded data \(.*\) contains invalid characters/', - ), - ); + ], + ]; } public function testParseDateAsMappingValue() @@ -1546,7 +1525,7 @@ public function testParseDateAsMappingValue() $expectedDate->setDate(2002, 12, 14); $expectedDate->setTime(0, 0, 0); - $this->assertEquals(array('date' => $expectedDate), $this->parser->parse($yaml, Yaml::PARSE_DATETIME)); + $this->assertEquals(['date' => $expectedDate], $this->parser->parse($yaml, Yaml::PARSE_DATETIME)); } /** @@ -1556,20 +1535,16 @@ public function testParseDateAsMappingValue() */ public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml) { - if (method_exists($this, 'expectException')) { - $this->expectException('\Symfony\Component\Yaml\Exception\ParseException'); - $this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber)); - } else { - $this->setExpectedException('\Symfony\Component\Yaml\Exception\ParseException', sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber)); - } + $this->expectException('\Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber)); $this->parser->parse($yaml); } public function parserThrowsExceptionWithCorrectLineNumberProvider() { - return array( - array( + return [ + [ 4, <<<'YAML' foo: @@ -1577,8 +1552,8 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider() # bar bar: "123", YAML - ), - array( + ], + [ 5, <<<'YAML' foo: @@ -1587,8 +1562,8 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider() # bar bar: "123", YAML - ), - array( + ], + [ 8, <<<'YAML' foo: @@ -1600,8 +1575,8 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider() # bar bar: "123", YAML - ), - array( + ], + [ 10, <<<'YAML' foo: @@ -1615,8 +1590,8 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider() # bar bar: "123", YAML - ), - ); + ], + ]; } public function testParseMultiLineQuotedString() @@ -1629,7 +1604,7 @@ public function testParseMultiLineQuotedString() bar: baz EOT; - $this->assertSame(array('foo' => 'bar baz foobar foo', 'bar' => 'baz'), $this->parser->parse($yaml)); + $this->assertSame(['foo' => 'bar baz foobar foo', 'bar' => 'baz'], $this->parser->parse($yaml)); } public function testMultiLineQuotedStringWithTrailingBackslash() @@ -1640,7 +1615,7 @@ public function testMultiLineQuotedStringWithTrailingBackslash() bar" YAML; - $this->assertSame(array('foobar' => 'foobar'), $this->parser->parse($yaml)); + $this->assertSame(['foobar' => 'foobar'], $this->parser->parse($yaml)); } public function testCommentCharactersInMultiLineQuotedStrings() @@ -1651,12 +1626,12 @@ public function testCommentCharactersInMultiLineQuotedStrings() #bar' bar: baz YAML; - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ 'foobar' => 'foo #bar', 'bar' => 'baz', - ), - ); + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -1668,9 +1643,9 @@ public function testBlankLinesInQuotedMultiLineString() bar' YAML; - $expected = array( + $expected = [ 'foobar' => "foo\nbar", - ); + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -1685,7 +1660,7 @@ public function testParseMultiLineUnquotedString() bar: baz EOT; - $this->assertSame(array('foo' => 'bar baz foobar foo', 'bar' => 'baz'), $this->parser->parse($yaml)); + $this->assertSame(['foo' => 'bar baz foobar foo', 'bar' => 'baz'], $this->parser->parse($yaml)); } public function testParseMultiLineString() @@ -1703,7 +1678,7 @@ public function testParseMultiLineMappingValue($yaml, $expected, $parseError) public function multiLineDataProvider() { - $tests = array(); + $tests = []; $yaml = <<<'EOF' foo: @@ -1713,15 +1688,15 @@ public function multiLineDataProvider() two three EOF; - $expected = array( - 'foo' => array( - array( + $expected = [ + 'foo' => [ + [ 'bar' => "one\ntwo three", - ), - ), - ); + ], + ], + ]; - $tests[] = array($yaml, $expected, false); + $tests[] = [$yaml, $expected, false]; $yaml = <<<'EOF' bar @@ -1729,7 +1704,7 @@ public function multiLineDataProvider() EOF; $expected = 'bar "foo"'; - $tests[] = array($yaml, $expected, false); + $tests[] = [$yaml, $expected, false]; $yaml = <<<'EOF' bar @@ -1737,7 +1712,7 @@ public function multiLineDataProvider() EOF; $expected = 'bar "foo'; - $tests[] = array($yaml, $expected, false); + $tests[] = [$yaml, $expected, false]; $yaml = <<<'EOF' bar @@ -1746,7 +1721,7 @@ public function multiLineDataProvider() EOF; $expected = "bar\n'foo'"; - $tests[] = array($yaml, $expected, false); + $tests[] = [$yaml, $expected, false]; $yaml = <<<'EOF' bar @@ -1755,14 +1730,14 @@ public function multiLineDataProvider() EOF; $expected = "bar\nfoo'"; - $tests[] = array($yaml, $expected, false); + $tests[] = [$yaml, $expected, false]; return $tests; } public function testTaggedInlineMapping() { - $this->assertEquals(new TaggedValue('foo', array('foo' => 'bar')), $this->parser->parse('!foo {foo: bar}', Yaml::PARSE_CUSTOM_TAGS)); + $this->assertEquals(new TaggedValue('foo', ['foo' => 'bar']), $this->parser->parse('!foo {foo: bar}', Yaml::PARSE_CUSTOM_TAGS)); } /** @@ -1775,40 +1750,38 @@ public function testCustomTagSupport($expected, $yaml) public function taggedValuesProvider() { - return array( - 'sequences' => array( - array(new TaggedValue('foo', array('yaml')), new TaggedValue('quz', array('bar'))), + return [ + 'sequences' => [ + [new TaggedValue('foo', ['yaml']), new TaggedValue('quz', ['bar'])], << array( - new TaggedValue('foo', array('foo' => new TaggedValue('quz', array('bar')), 'quz' => new TaggedValue('foo', array('quz' => 'bar')))), + ], + 'mappings' => [ + new TaggedValue('foo', ['foo' => new TaggedValue('quz', ['bar']), 'quz' => new TaggedValue('foo', ['quz' => 'bar'])]), << array( - array(new TaggedValue('foo', array('foo', 'bar')), new TaggedValue('quz', array('foo' => 'bar', 'quz' => new TaggedValue('bar', array('one' => 'bar'))))), + ], + 'inline' => [ + [new TaggedValue('foo', ['foo', 'bar']), new TaggedValue('quz', ['foo' => 'bar', 'quz' => new TaggedValue('bar', ['one' => 'bar'])])], <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!iterator" at line 1 (near "!iterator [foo]").'); $this->parser->parse('!iterator [foo]'); } @@ -1821,12 +1794,10 @@ public function testUnsupportedTagWithScalar() $this->assertEquals('!iterator foo', $this->parser->parse('!iterator foo')); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage The built-in tag "!!foo" is not implemented at line 1 (near "!!foo"). - */ public function testExceptionWhenUsingUnsuportedBuiltInTags() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").'); $this->parser->parse('!!foo'); } @@ -1876,12 +1847,10 @@ public function testComplexMappingNestedInSequenceThrowsParseException() $this->parser->parse($yaml); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Unable to parse at line 1 (near "[parameters]"). - */ public function testParsingIniThrowsException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Unable to parse at line 1 (near "[parameters]").'); $ini = <<parseFile(__DIR__.'/Fixtures/'.$testsFile); foreach ($files as $file) { $yamls = file_get_contents(__DIR__.'/Fixtures/'.$file.'.yml'); @@ -1912,7 +1881,7 @@ private function loadTestsFromFixtureFiles($testsFile) } else { eval('$expected = '.trim($test['php']).';'); - $tests[] = array(var_export($expected, true), $test['yaml'], $test['test'], isset($test['deprecated']) ? $test['deprecated'] : false); + $tests[] = [var_export($expected, true), $test['yaml'], $test['test'], isset($test['deprecated']) ? $test['deprecated'] : false]; } } } @@ -1923,7 +1892,7 @@ private function loadTestsFromFixtureFiles($testsFile) public function testCanParseVeryLongValue() { $longStringWithSpaces = str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ', 20000); - $trickyVal = array('x' => $longStringWithSpaces); + $trickyVal = ['x' => $longStringWithSpaces]; $yamlString = Yaml::dump($trickyVal); $arrayFromYaml = $this->parser->parse($yamlString); @@ -1931,12 +1900,10 @@ public function testCanParseVeryLongValue() $this->assertEquals($trickyVal, $arrayFromYaml); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Reference "foo" does not exist at line 2 - */ public function testParserCleansUpReferencesBetweenRuns() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Reference "foo" does not exist at line 2'); $yaml = << array( - 'foo' => array( - 'from' => array( + $expected = [ + 'transitions' => [ + 'foo' => [ + 'from' => [ 'bar', - ), + ], 'to' => 'baz', - ), - ), - ); + ], + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT)); } @@ -1990,16 +1957,16 @@ public function testDeprecatedPhpConstantTagMappingKey() - !php/const:Symfony\Component\Yaml\Tests\B::BAR to: !php/const:Symfony\Component\Yaml\Tests\B::BAZ YAML; - $expected = array( - 'transitions' => array( - 'foo' => array( - 'from' => array( + $expected = [ + 'transitions' => [ + 'foo' => [ + 'from' => [ 'bar', - ), + ], 'to' => 'baz', - ), - ), - ); + ], + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT)); } @@ -2017,16 +1984,16 @@ public function testPhpConstantTagMappingKeyWithKeysCastToStrings() - !php/const 'Symfony\Component\Yaml\Tests\B::BAR' to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ' YAML; - $expected = array( - 'transitions' => array( - 'foo' => array( - 'from' => array( + $expected = [ + 'transitions' => [ + 'foo' => [ + 'from' => [ 'bar', - ), + ], 'to' => 'baz', - ), - ), - ); + ], + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT | Yaml::PARSE_KEYS_AS_STRINGS)); } @@ -2047,23 +2014,23 @@ public function testMergeKeysWhenMappingsAreParsedAsObjects() bar: ~ <<: [*FOO, *BAR] YAML; - $expected = (object) array( - 'foo' => (object) array( + $expected = (object) [ + 'foo' => (object) [ 'bar' => 1, - ), - 'bar' => (object) array( + ], + 'bar' => (object) [ 'baz' => 2, 'bar' => 1, - ), - 'baz' => (object) array( + ], + 'baz' => (object) [ 'baz_foo' => 3, 'baz_bar' => 4, - ), - 'foobar' => (object) array( + ], + 'foobar' => (object) [ 'bar' => null, 'baz' => 2, - ), - ); + ], + ]; $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP)); } @@ -2077,24 +2044,20 @@ public function testFilenamesAreParsedAsStringsWithoutFlag() public function testParseFile() { - $this->assertInternalType('array', $this->parser->parseFile(__DIR__.'/Fixtures/index.yml')); + $this->assertIsArray($this->parser->parseFile(__DIR__.'/Fixtures/index.yml')); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessageRegExp #^File ".+/Fixtures/nonexistent.yml" does not exist\.$# - */ public function testParsingNonExistentFilesThrowsException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessageRegExp('#^File ".+/Fixtures/nonexistent.yml" does not exist\.$#'); $this->parser->parseFile(__DIR__.'/Fixtures/nonexistent.yml'); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessageRegExp #^File ".+/Fixtures/not_readable.yml" cannot be read\.$# - */ public function testParsingNotReadableFilesThrowsException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessageRegExp('#^File ".+/Fixtures/not_readable.yml" cannot be read\.$#'); if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('chmod is not supported on Windows'); } @@ -2121,18 +2084,18 @@ public function testParseReferencesOnMergeKeys() d: quux <<: *quux YAML; - $expected = array( - 'mergekeyrefdef' => array( + $expected = [ + 'mergekeyrefdef' => [ 'a' => 'foo', 'b' => 'bar', 'c' => 'baz', - ), - 'mergekeyderef' => array( + ], + 'mergekeyderef' => [ 'd' => 'quux', 'b' => 'bar', 'c' => 'baz', - ), - ); + ], + ]; $this->assertSame($expected, $this->parser->parse($yaml)); } @@ -2149,28 +2112,26 @@ public function testParseReferencesOnMergeKeysWithMappingsParsedAsObjects() d: quux <<: *quux YAML; - $expected = (object) array( - 'mergekeyrefdef' => (object) array( + $expected = (object) [ + 'mergekeyrefdef' => (object) [ 'a' => 'foo', 'b' => 'bar', 'c' => 'baz', - ), - 'mergekeyderef' => (object) array( + ], + 'mergekeyderef' => (object) [ 'd' => 'quux', 'b' => 'bar', 'c' => 'baz', - ), - ); + ], + ]; $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP)); } - /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Reference "foo" does not exist - */ public function testEvalRefException() { + $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Reference "foo" does not exist'); $yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectExceptionMessage('Circular reference [foo, bar, foo] detected'); $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS); } public function circularReferenceProvider() { - $tests = array(); + $tests = []; $yaml = << array( - array( + $expected = [ + 'foo' => [ + [ 'bar' => 'foobar', 'baz' => 'foobaz', - ), - ), - ); - $tests['comment line is first line in indented block'] = array($yaml, $expected); + ], + ], + ]; + $tests['comment line is first line in indented block'] = [$yaml, $expected]; $yaml = << array( - array( - 'bar' => array( - 'baz' => array(1, 2, 3), - ), - ), - ), - ); - $tests['mapping value on new line starting with a comment line'] = array($yaml, $expected); + $expected = [ + 'foo' => [ + [ + 'bar' => [ + 'baz' => [1, 2, 3], + ], + ], + ], + ]; + $tests['mapping value on new line starting with a comment line'] = [$yaml, $expected]; $yaml = << array( - array( + $expected = [ + 'foo' => [ + [ 'bar' => 'foobar', - ), - ), - ); - $tests['mapping in sequence starting on a new line'] = array($yaml, $expected); + ], + ], + ]; + $tests['mapping in sequence starting on a new line'] = [$yaml, $expected]; $yaml = << array( + $expected = [ + 'foo' => [ 'bar' => 'baz', - ), - ); - $tests['blank line at the beginning of an indented mapping value'] = array($yaml, $expected); + ], + ]; + $tests['blank line at the beginning of an indented mapping value'] = [$yaml, $expected]; return $tests; } + + public function testMultiLineComment() + { + $yaml = <<assertSame(['parameters' => 'abc'], $this->parser->parse($yaml)); + } + + public function testParseValueWithModifiers() + { + $yaml = <<assertSame( + [ + 'parameters' => [ + 'abc' => implode("\n", ['one', 'two', 'three', 'four', 'five']), + ], + ], + $this->parser->parse($yaml) + ); + } + + public function testParseValueWithNegativeModifiers() + { + $yaml = <<assertSame( + [ + 'parameters' => [ + 'abc' => implode("\n", ['one', 'two', 'three', 'four', 'five']), + ], + ], + $this->parser->parse($yaml) + ); + } } class B diff --git a/includes/vendor/symfony/yaml/Tests/YamlTest.php b/includes/vendor/symfony/yaml/Tests/YamlTest.php index 3f6c2525..7be12664 100644 --- a/includes/vendor/symfony/yaml/Tests/YamlTest.php +++ b/includes/vendor/symfony/yaml/Tests/YamlTest.php @@ -18,27 +18,23 @@ class YamlTest extends TestCase { public function testParseAndDump() { - $data = array('lorem' => 'ipsum', 'dolor' => 'sit'); + $data = ['lorem' => 'ipsum', 'dolor' => 'sit']; $yml = Yaml::dump($data); $parsed = Yaml::parse($yml); $this->assertEquals($data, $parsed); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The indentation must be greater than zero - */ public function testZeroIndentationThrowsException() { - Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('The indentation must be greater than zero'); + Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, 0); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The indentation must be greater than zero - */ public function testNegativeIndentationThrowsException() { - Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('The indentation must be greater than zero'); + Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, -4); } } diff --git a/includes/vendor/webmozart/assert/.editorconfig b/includes/vendor/webmozart/assert/.editorconfig new file mode 100644 index 00000000..384453bf --- /dev/null +++ b/includes/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/includes/vendor/webmozart/assert/CHANGELOG.md b/includes/vendor/webmozart/assert/CHANGELOG.md index da4fb3fe..2af1baa2 100644 --- a/includes/vendor/webmozart/assert/CHANGELOG.md +++ b/includes/vendor/webmozart/assert/CHANGELOG.md @@ -3,6 +3,61 @@ Changelog ## UNRELEASED +## 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 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 +77,7 @@ Changelog ## 1.3.0 (2018-01-29) -### Added +### Added * added `Assert::minCount()` * added `Assert::maxCount()` diff --git a/includes/vendor/webmozart/assert/README.md b/includes/vendor/webmozart/assert/README.md index ce7ba59d..615c8b27 100644 --- a/includes/vendor/webmozart/assert/README.md +++ b/includes/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 ``` @@ -110,6 +107,7 @@ Method | Description `isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` a at least one class on the array of classes `notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class `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 @@ -146,6 +144,7 @@ Method | Description `endsWith($value, $suffix, $message = '')` | Check that a string has 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 +158,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 +190,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 +224,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 lenght for relevant methods, using the `mb_strlen` if available and usefull. +* `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 +259,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 ------- diff --git a/includes/vendor/webmozart/assert/ci/composer.json b/includes/vendor/webmozart/assert/ci/composer.json new file mode 100644 index 00000000..14a099d5 --- /dev/null +++ b/includes/vendor/webmozart/assert/ci/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "vimeo/psalm": "^3.6" + } +} diff --git a/includes/vendor/webmozart/assert/composer.json b/includes/vendor/webmozart/assert/composer.json index b6002ef3..34350b29 100644 --- a/includes/vendor/webmozart/assert/composer.json +++ b/includes/vendor/webmozart/assert/composer.json @@ -18,13 +18,10 @@ "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.6.0" }, "autoload": { "psr-4": { diff --git a/includes/vendor/webmozart/assert/psalm.xml b/includes/vendor/webmozart/assert/psalm.xml new file mode 100644 index 00000000..44d37aab --- /dev/null +++ b/includes/vendor/webmozart/assert/psalm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/includes/vendor/webmozart/assert/src/Assert.php b/includes/vendor/webmozart/assert/src/Assert.php index db04bfbe..dd9ec92a 100644 --- a/includes/vendor/webmozart/assert/src/Assert.php +++ b/includes/vendor/webmozart/assert/src/Assert.php @@ -17,6 +17,8 @@ use Countable; use Exception; use InvalidArgumentException; +use ResourceBundle; +use SimpleXMLElement; use Throwable; use Traversable; @@ -50,14 +52,16 @@ * @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 nullOrEmail($value, $message = '') + * @method static void nullOrUniqueValues($values, $message = '') + * @method static void nullOrEq($value, $expect, $message = '') + * @method static void nullOrNotEq($value, $expect, $message = '') + * @method static void nullOrSame($value, $expect, $message = '') + * @method static void nullOrNotSame($value, $expect, $message = '') + * @method static void nullOrGreaterThan($value, $limit, $message = '') + * @method static void nullOrGreaterThanEq($value, $limit, $message = '') + * @method static void nullOrLessThan($value, $limit, $message = '') + * @method static void nullOrLessThanEq($value, $limit, $message = '') * @method static void nullOrRange($value, $min, $max, $message = '') * @method static void nullOrOneOf($value, $values, $message = '') * @method static void nullOrContains($value, $subString, $message = '') @@ -68,6 +72,7 @@ * @method static void nullOrEndsWith($value, $suffix, $message = '') * @method static void nullOrRegex($value, $pattern, $message = '') * @method static void nullOrNotRegex($value, $pattern, $message = '') + * @method static void nullOrUnicodeLetters($value, $message = '') * @method static void nullOrAlpha($value, $message = '') * @method static void nullOrDigits($value, $message = '') * @method static void nullOrAlnum($value, $message = '') @@ -92,11 +97,14 @@ * @method static void nullOrMethodNotExists($value, $method, $message = '') * @method static void nullOrKeyExists($value, $key, $message = '') * @method static void nullOrKeyNotExists($value, $key, $message = '') + * @method static void nullOrValidArrayKey($value, $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 nullOrIsNonEmptyList($value, $message = '') * @method static void nullOrIsMap($value, $message = '') + * @method static void nullOrIsNonEmptyMap($value, $message = '') * @method static void nullOrCountBetween($value, $min, $max, $message = '') * @method static void nullOrUuid($values, $message = '') * @method static void nullOrThrows($expression, $class = 'Exception', $message = '') @@ -129,14 +137,16 @@ * @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 allEmail($values, $message = '') + * @method static void allUniqueValues($values, $message = '') + * @method static void allEq($values, $expect, $message = '') + * @method static void allNotEq($values, $expect, $message = '') + * @method static void allSame($values, $expect, $message = '') + * @method static void allNotSame($values, $expect, $message = '') + * @method static void allGreaterThan($values, $limit, $message = '') + * @method static void allGreaterThanEq($values, $limit, $message = '') + * @method static void allLessThan($values, $limit, $message = '') + * @method static void allLessThanEq($values, $limit, $message = '') * @method static void allRange($values, $min, $max, $message = '') * @method static void allOneOf($values, $values, $message = '') * @method static void allContains($values, $subString, $message = '') @@ -147,6 +157,7 @@ * @method static void allEndsWith($values, $suffix, $message = '') * @method static void allRegex($values, $pattern, $message = '') * @method static void allNotRegex($values, $pattern, $message = '') + * @method static void allUnicodeLetters($values, $message = '') * @method static void allAlpha($values, $message = '') * @method static void allDigits($values, $message = '') * @method static void allAlnum($values, $message = '') @@ -171,12 +182,15 @@ * @method static void allMethodNotExists($values, $method, $message = '') * @method static void allKeyExists($values, $key, $message = '') * @method static void allKeyNotExists($values, $key, $message = '') + * @method static void allValidArrayKey($values, $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 allIsNonEmptyList($values, $message = '') * @method static void allIsMap($values, $message = '') + * @method static void allIsNonEmptyMap($values, $message = '') * @method static void allUuid($values, $message = '') * @method static void allThrows($expressions, $class = 'Exception', $message = '') * @@ -186,113 +200,200 @@ */ class Assert { + /** + * @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) )); } } + /** + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function stringNotEmpty($value, $message = '') { static::string($value, $message); static::notEq($value, '', $message); } + /** + * @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-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-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-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-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( + if (!\is_int($value) || $value < 0) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected a non-negative integer. Got %s', static::valueToString($value) )); } } + /** + * @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-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-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-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 +401,142 @@ public static function resource($value, $type = null, $message = '') } } + /** + * @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-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-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) )); } } + /** + * @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-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-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-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 +544,21 @@ public static function isInstanceOf($value, $class, $message = '') } } + /** + * @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 +566,13 @@ public static function notInstanceOf($value, $class, $message = '') } } + /** + * @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 +581,75 @@ 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-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-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-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-assert !null $value + * + * @param mixed $value + * @param string $message + * + * @throws InvalidArgumentException + */ public static function notNull($value, $message = '') { if (null === $value) { @@ -444,102 +659,211 @@ public static function notNull($value, $message = '') } } + /** + * @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-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) )); } } + /** + * @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( + 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 (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 ($value2 != $value) { - static::reportInvalidArgument(sprintf( + 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 = '') + /** + * @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 = '') + /** + * @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) )); } } + /** + * @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 +871,17 @@ public static function greaterThan($value, $limit, $message = '') } } + /** + * @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 +889,17 @@ public static function greaterThanEq($value, $limit, $message = '') } } + /** + * @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 +907,17 @@ public static function lessThan($value, $limit, $message = '') } } + /** + * @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 +925,20 @@ public static function lessThanEq($value, $limit, $message = '') } } + /** + * Inclusive range, so Assert::(3, 3, 5) passes. + * + * @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 +947,37 @@ public static function range($value, $min, $max, $message = '') } } + /** + * Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion. + * + * @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( + 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)) )); } } + /** + * @param mixed $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 +985,17 @@ public static function contains($value, $subString, $message = '') } } + /** + * @param mixed $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 +1003,33 @@ public static function notContains($value, $subString, $message = '') } } + /** + * @param mixed $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) )); } } + /** + * @param mixed $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 +1037,44 @@ public static function startsWith($value, $prefix, $message = '') } } + /** + * @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) )); } } + /** + * @param mixed $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 +1082,34 @@ public static function endsWith($value, $suffix, $message = '') } } + /** + * @param mixed $value + * @param mixed $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) )); } } + /** + * @param mixed $value + * @param mixed $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 +1118,142 @@ public static function notRegex($value, $pattern, $message = '') } } + /** + * @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) + )); + } + } + + /** + * @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) )); } } + /** + * @param mixed $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) )); } } + /** + * @param mixed $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) )); } } + /** + * @param mixed $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) )); } } + /** + * @param mixed $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) )); } } + /** + * @param mixed $value + * @param mixed $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 +1261,19 @@ public static function length($value, $length, $message = '') } } + /** + * Inclusive min. + * + * @param mixed $value + * @param mixed $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 +1281,19 @@ public static function minLength($value, $min, $message = '') } } + /** + * Inclusive max. + * + * @param mixed $value + * @param mixed $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 +1301,22 @@ public static function maxLength($value, $max, $message = '') } } + /** + * Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion. + * + * @param mixed $value + * @param mixed $min + * @param mixed $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 +1325,123 @@ 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 mixed $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 mixed $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) )); } } + /** + * @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 +1449,35 @@ 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) )); } } + /** + * @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 +1485,202 @@ public static function implementsInterface($value, $interface, $message = '') } } + /** + * @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) )); } } + /** + * @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) )); } } + /** + * @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 (!\method_exists($classOrObject, $method)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the method %s to exist.', static::valueToString($method) )); } } + /** + * @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 (\method_exists($classOrObject, $method)) { + static::reportInvalidArgument(\sprintf( $message ?: 'Expected the method %s to not exist.', static::valueToString($method) )); } } + /** + * @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) )); } } + /** + * @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-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 mixed $array + * @param mixed $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)) + $message ?: \sprintf('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 mixed $array + * @param mixed $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 mixed $array + * @param mixed $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 mixed $array + * @param mixed $min + * @param mixed $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 +1689,48 @@ public static function countBetween($array, $min, $max, $message = '') } } + /** + * @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-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); + } + + /** + * @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 +1738,27 @@ public static function isMap($array, $message = '') } } + /** + * @param mixed $array + * @param string $message + * + * @throws InvalidArgumentException + */ + public static function isNonEmptyMap($array, $message = '') + { + static::isMap($array, $message); + static::notEmpty($array, $message); + } + + /** + * @param mixed $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 +1766,21 @@ 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) )); } } + /** + * @param Closure $expression + * @param string|object $class + * @param string $message + * + * @throws InvalidArgumentException + */ public static function throws(Closure $expression, $class = 'Exception', $message = '') { static::string($class); @@ -1074,45 +1790,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 +1840,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 +1859,57 @@ 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()); } - 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 + */ protected static function reportInvalidArgument($message) { throw new InvalidArgumentException($message);