diff --git a/composer.json b/composer.json index f9c1dd4c..14c86bbd 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ "embed/embed": "^4.3", "laminas/laminas-diactoros": "^2.8", "grandel/include-directory": "^0.2.2", - "knplabs/github-api": "3.0", - "guzzlehttp/guzzle": "7.0.1", - "http-interop/http-factory-guzzle": "1.0" + "knplabs/github-api": "^3.0", + "guzzlehttp/guzzle": "^7.0.1", + "http-interop/http-factory-guzzle": "^1.0" } } diff --git a/composer.lock b/composer.lock index 926b36fb..893794b3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "941d586d93b4ccab82b6d25acb5e1a10", + "content-hash": "c370a196fb020d63e645d8ea571d04ac", "packages": [ { "name": "clue/stream-filter", @@ -265,34 +265,35 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.0.1", + "version": "7.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2" + "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/2d9d3c186a6637a43193e66b097c50e4451eaab2", - "reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79", + "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": "^7.2.5", - "psr/http-client": "^1.0" + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.8.3 || ^2.1", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "provide": { "psr/http-client-implementation": "1.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.0", + "bamarni/composer-bin-plugin": "^1.4.1", "ext-curl": "*", - "php-http/client-integration-tests": "dev-phpunit8", - "phpunit/phpunit": "^8.5.5", - "psr/log": "^1.1" + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", @@ -302,7 +303,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -318,19 +319,43 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", "keywords": [ "client", "curl", @@ -344,9 +369,23 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.0" + "source": "https://github.com/guzzle/guzzle/tree/7.4.1" }, - "time": "2020-06-27T10:33:25+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2021-12-06T18:43:05+00:00" }, { "name": "guzzlehttp/promises", @@ -434,29 +473,32 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.8.3", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "1afdd860a2566ed3c2b0b4a3de6e23434a79ec85" + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/1afdd860a2566ed3c2b0b4a3de6e23434a79ec85", - "reference": "1afdd860a2566ed3c2b0b4a3de6e23434a79ec85", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", "shasum": "" }, "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" }, "provide": { + "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -464,16 +506,13 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "2.1-dev" } }, "autoload": { "psr-4": { "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -509,6 +548,11 @@ "name": "Tobias Schultze", "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "description": "PSR-7 message implementation that also provides common utility methods", @@ -524,7 +568,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.8.3" + "source": "https://github.com/guzzle/psr7/tree/2.1.0" }, "funding": [ { @@ -540,32 +584,36 @@ "type": "tidelift" } ], - "time": "2021-10-05T13:56:00+00:00" + "time": "2021-10-06T17:43:30+00:00" }, { "name": "http-interop/http-factory-guzzle", - "version": "1.0.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/http-interop/http-factory-guzzle.git", - "reference": "34861658efb9899a6618cef03de46e2a52c80fc0" + "reference": "8f06e92b95405216b237521cc64c804dd44c4a81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/http-interop/http-factory-guzzle/zipball/34861658efb9899a6618cef03de46e2a52c80fc0", - "reference": "34861658efb9899a6618cef03de46e2a52c80fc0", + "url": "https://api.github.com/repos/http-interop/http-factory-guzzle/zipball/8f06e92b95405216b237521cc64c804dd44c4a81", + "reference": "8f06e92b95405216b237521cc64c804dd44c4a81", "shasum": "" }, "require": { - "guzzlehttp/psr7": "^1.4.2", + "guzzlehttp/psr7": "^1.7||^2.0", + "php": ">=7.3", "psr/http-factory": "^1.0" }, "provide": { "psr/http-factory-implementation": "^1.0" }, "require-dev": { - "http-interop/http-factory-tests": "^0.5", - "phpunit/phpunit": "^6.5" + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^9.5" + }, + "suggest": { + "guzzlehttp/psr7": "Includes an HTTP factory starting in version 2.0" }, "type": "library", "autoload": { @@ -592,22 +640,22 @@ ], "support": { "issues": "https://github.com/http-interop/http-factory-guzzle/issues", - "source": "https://github.com/http-interop/http-factory-guzzle/tree/master" + "source": "https://github.com/http-interop/http-factory-guzzle/tree/1.2.0" }, - "time": "2018-07-31T19:32:56+00:00" + "time": "2021-07-21T13:50:14+00:00" }, { "name": "knplabs/github-api", - "version": "v3.0.0", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/KnpLabs/php-github-api.git", - "reference": "adf4ecaafc96e2c7a43370e229b58d722f2ad97a" + "reference": "9906308d0c0e0b551e5fd461e026592de66fe311" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/adf4ecaafc96e2c7a43370e229b58d722f2ad97a", - "reference": "adf4ecaafc96e2c7a43370e229b58d722f2ad97a", + "url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/9906308d0c0e0b551e5fd461e026592de66fe311", + "reference": "9906308d0c0e0b551e5fd461e026592de66fe311", "shasum": "" }, "require": { @@ -618,10 +666,11 @@ "php-http/discovery": "^1.12", "php-http/httplug": "^2.2", "php-http/multipart-stream-builder": "^1.1.2", - "psr/cache": "^1.0", + "psr/cache": "^1.0|^2.0|^3.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", "psr/http-message": "^1.0", + "symfony/deprecation-contracts": "^2.2|^3.0", "symfony/polyfill-php80": "^1.17" }, "require-dev": { @@ -633,13 +682,14 @@ "phpstan/phpstan": "^0.12.57", "phpstan/phpstan-deprecation-rules": "^0.12.5", "phpunit/phpunit": "^8.5 || ^9.4", - "symfony/cache": "^5.1.8" + "symfony/cache": "^5.1.8", + "symfony/phpunit-bridge": "^5.2" }, "type": "library", "extra": { "branch-alias": { - "dev-2.x": "2.19.x-dev", - "dev-master": "3.0.x-dev" + "dev-2.x": "2.20.x-dev", + "dev-master": "3.4.x-dev" } }, "autoload": { @@ -672,7 +722,7 @@ ], "support": { "issues": "https://github.com/KnpLabs/php-github-api/issues", - "source": "https://github.com/KnpLabs/php-github-api/tree/v3.0.0" + "source": "https://github.com/KnpLabs/php-github-api/tree/v3.5.0" }, "funding": [ { @@ -680,7 +730,7 @@ "type": "github" } ], - "time": "2020-12-21T18:38:02+00:00" + "time": "2022-01-23T11:32:47+00:00" }, { "name": "laminas/laminas-diactoros", @@ -1451,20 +1501,20 @@ }, { "name": "psr/cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { @@ -1484,7 +1534,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for caching libraries", @@ -1494,9 +1544,9 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/master" + "source": "https://github.com/php-fig/cache/tree/3.0.0" }, - "time": "2016-08-06T20:24:11+00:00" + "time": "2021-02-03T23:26:27+00:00" }, { "name": "psr/http-client", diff --git a/vendor/guzzlehttp/guzzle/CHANGELOG.md b/vendor/guzzlehttp/guzzle/CHANGELOG.md index 8edecd4a..b278efca 100644 --- a/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ b/vendor/guzzlehttp/guzzle/CHANGELOG.md @@ -2,7 +2,100 @@ Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version. -## UNRELEASED +## 7.4.1 - 2021-12-06 + +### Changed + +- Replaced implicit URI to string coercion [#2946](https://github.com/guzzle/guzzle/pull/2946) +- Allow `symfony/deprecation-contracts` version 3 [#2961](https://github.com/guzzle/guzzle/pull/2961) + +### Fixed + +- Only close curl handle if it's done [#2950](https://github.com/guzzle/guzzle/pull/2950) + +## 7.4.0 - 2021-10-18 + +### Added + +- Support PHP 8.1 [#2929](https://github.com/guzzle/guzzle/pull/2929), [#2939](https://github.com/guzzle/guzzle/pull/2939) +- Support `psr/log` version 2 and 3 [#2943](https://github.com/guzzle/guzzle/pull/2943) + +### Fixed + +- Make sure we always call `restore_error_handler()` [#2915](https://github.com/guzzle/guzzle/pull/2915) +- Fix progress parameter type compatibility between the cURL and stream handlers [#2936](https://github.com/guzzle/guzzle/pull/2936) +- Throw `InvalidArgumentException` when an incorrect `headers` array is provided [#2916](https://github.com/guzzle/guzzle/pull/2916), [#2942](https://github.com/guzzle/guzzle/pull/2942) + +### Changed + +- Be more strict with types [#2914](https://github.com/guzzle/guzzle/pull/2914), [#2917](https://github.com/guzzle/guzzle/pull/2917), [#2919](https://github.com/guzzle/guzzle/pull/2919), [#2945](https://github.com/guzzle/guzzle/pull/2945) + +## 7.3.0 - 2021-03-23 + +### Added + +- Support for DER and P12 certificates [#2413](https://github.com/guzzle/guzzle/pull/2413) +- Support the cURL (http://) scheme for StreamHandler proxies [#2850](https://github.com/guzzle/guzzle/pull/2850) +- Support for `guzzlehttp/psr7:^2.0` [#2878](https://github.com/guzzle/guzzle/pull/2878) + +### Fixed + +- Handle exceptions on invalid header consistently between PHP versions and handlers [#2872](https://github.com/guzzle/guzzle/pull/2872) + +## 7.2.0 - 2020-10-10 + +### Added + +- Support for PHP 8 [#2712](https://github.com/guzzle/guzzle/pull/2712), [#2715](https://github.com/guzzle/guzzle/pull/2715), [#2789](https://github.com/guzzle/guzzle/pull/2789) +- Support passing a body summarizer to the http errors middleware [#2795](https://github.com/guzzle/guzzle/pull/2795) + +### Fixed + +- Handle exceptions during response creation [#2591](https://github.com/guzzle/guzzle/pull/2591) +- Fix CURLOPT_ENCODING not to be overwritten [#2595](https://github.com/guzzle/guzzle/pull/2595) +- Make sure the Request always has a body object [#2804](https://github.com/guzzle/guzzle/pull/2804) + +### Changed + +- The `TooManyRedirectsException` has a response [#2660](https://github.com/guzzle/guzzle/pull/2660) +- Avoid "functions" from dependencies [#2712](https://github.com/guzzle/guzzle/pull/2712) + +### Deprecated + +- Using environment variable GUZZLE_CURL_SELECT_TIMEOUT [#2786](https://github.com/guzzle/guzzle/pull/2786) + +## 7.1.1 - 2020-09-30 + +### Fixed + +- Incorrect EOF detection for response body streams on Windows. + +### Changed + +- We dont connect curl `sink` on HEAD requests. +- Removed some PHP 5 workarounds + +## 7.1.0 - 2020-09-22 + +### Added + +- `GuzzleHttp\MessageFormatterInterface` + +### Fixed + +- Fixed issue that caused cookies with no value not to be stored. +- On redirects, we allow all safe methods like GET, HEAD and OPTIONS. +- Fixed logging on empty responses. +- Make sure MessageFormatter::format returns string + +### Deprecated + +- All functions in `GuzzleHttp` has been deprecated. Use static methods on `Utils` instead. +- `ClientInterface::getConfig()` +- `Client::getConfig()` +- `Client::__call()` +- `Utils::defaultCaBundle()` +- `CurlFactory::LOW_CURL_VERSION_NUMBER` ## 7.0.1 - 2020-06-27 diff --git a/vendor/guzzlehttp/guzzle/LICENSE b/vendor/guzzlehttp/guzzle/LICENSE index d51aa698..fd2375d8 100644 --- a/vendor/guzzlehttp/guzzle/LICENSE +++ b/vendor/guzzlehttp/guzzle/LICENSE @@ -1,4 +1,12 @@ -Copyright (c) 2011 Michael Dowling, https://github.com/mtdowling +The MIT License (MIT) + +Copyright (c) 2011 Michael Dowling +Copyright (c) 2012 Jeremy Lindblom +Copyright (c) 2014 Graham Campbell +Copyright (c) 2015 Márk Sági-Kazár +Copyright (c) 2015 Tobias Schultze +Copyright (c) 2016 Tobias Nyholm +Copyright (c) 2016 George Mponos 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/vendor/guzzlehttp/guzzle/README.md b/vendor/guzzlehttp/guzzle/README.md index 72371701..0025aa7a 100644 --- a/vendor/guzzlehttp/guzzle/README.md +++ b/vendor/guzzlehttp/guzzle/README.md @@ -65,7 +65,7 @@ composer require guzzlehttp/guzzle | 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 | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | -| 6.x | Bugfixes | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 | +| 6.x | Security fixes | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 | | 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >= 7.2 | [guzzle-3-repo]: https://github.com/guzzle/guzzle3 @@ -77,3 +77,18 @@ composer require guzzlehttp/guzzle [guzzle-5-docs]: http://docs.guzzlephp.org/en/5.3/ [guzzle-6-docs]: http://docs.guzzlephp.org/en/6.5/ [guzzle-7-docs]: http://docs.guzzlephp.org/en/latest/ + + +## Security + +If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/guzzle/security/policy) for more information. + +## License + +Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information. + +## For Enterprise + +Available as part of the Tidelift Subscription + +The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-guzzle?utm_source=packagist-guzzlehttp-guzzle&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/vendor/guzzlehttp/guzzle/composer.json b/vendor/guzzlehttp/guzzle/composer.json index 5cf87fda..2549f78b 100644 --- a/vendor/guzzlehttp/guzzle/composer.json +++ b/vendor/guzzlehttp/guzzle/composer.json @@ -1,6 +1,5 @@ { "name": "guzzlehttp/guzzle", - "type": "library", "description": "Guzzle is a PHP HTTP client library", "keywords": [ "framework", @@ -13,36 +12,61 @@ "PSR-7", "PSR-18" ], - "homepage": "http://guzzlephp.org/", "license": "MIT", "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "require": { - "php": "^7.2.5", + "php": "^7.2.5 || ^8.0", "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "psr/http-client": "^1.0" + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.8.3 || ^2.1", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "provide": { "psr/http-client-implementation": "1.0" }, "require-dev": { "ext-curl": "*", - "ergebnis/composer-normalize": "^2.0", - "php-http/client-integration-tests": "dev-phpunit8", - "phpunit/phpunit": "^8.5.5", - "psr/log": "^1.1" + "bamarni/composer-bin-plugin": "^1.4.1", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", @@ -50,11 +74,12 @@ "psr/log": "Required for using the Log middleware" }, "config": { + "preferred-install": "dist", "sort-packages": true }, "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "7.4-dev" } }, "autoload": { diff --git a/vendor/guzzlehttp/guzzle/src/BodySummarizer.php b/vendor/guzzlehttp/guzzle/src/BodySummarizer.php new file mode 100644 index 00000000..6eca94ef --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/BodySummarizer.php @@ -0,0 +1,28 @@ +truncateAt = $truncateAt; + } + + /** + * Returns a summarized message body. + */ + public function summarize(MessageInterface $message): ?string + { + return $this->truncateAt === null + ? \GuzzleHttp\Psr7\Message::bodySummary($message) + : \GuzzleHttp\Psr7\Message::bodySummary($message, $this->truncateAt); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php b/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php new file mode 100644 index 00000000..3e02e036 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php @@ -0,0 +1,13 @@ +configureDefaults($config); @@ -71,6 +75,8 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface * @param array $args * * @return PromiseInterface|ResponseInterface + * + * @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0. */ public function __call($method, $args) { @@ -151,7 +157,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $body = $options['body'] ?? null; $version = $options['version'] ?? '1.1'; // Merge the URI into the base URI. - $uri = $this->buildUri(Psr7\uri_for($uri), $options); + $uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options); if (\is_array($body)) { throw $this->invalidBody(); } @@ -191,18 +197,20 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface * @param string|null $option The config option to retrieve. * * @return mixed + * + * @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0. */ public function getConfig(?string $option = null) { return $option === null ? $this->config - : (isset($this->config[$option]) ? $this->config[$option] : null); + : ($this->config[$option] ?? null); } private function buildUri(UriInterface $uri, array $config): UriInterface { if (isset($config['base_uri'])) { - $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri); + $uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri); } if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) { @@ -320,9 +328,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $handler = $options['handler']; try { - return Promise\promise_for($handler($request, $options)); + return P\Create::promiseFor($handler($request, $options)); } catch (\Exception $e) { - return Promise\rejection_for($e); + return P\Create::rejectionFor($e); } } @@ -336,6 +344,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface ]; if (isset($options['headers'])) { + if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) { + throw new InvalidArgumentException('The headers array must have header name as keys.'); + } $modify['set_headers'] = $options['headers']; unset($options['headers']); } @@ -351,7 +362,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $options['body'] = \http_build_query($options['form_params'], '', '&'); unset($options['form_params']); // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded'; } @@ -364,7 +375,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $options['body'] = Utils::jsonEncode($options['json']); unset($options['json']); // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); $options['_conditional']['Content-Type'] = 'application/json'; } @@ -372,7 +383,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface && $options['decode_content'] !== true ) { // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']); $modify['set_headers']['Accept-Encoding'] = $options['decode_content']; } @@ -380,7 +391,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface if (\is_array($options['body'])) { throw $this->invalidBody(); } - $modify['body'] = Psr7\stream_for($options['body']); + $modify['body'] = Psr7\Utils::streamFor($options['body']); unset($options['body']); } @@ -390,7 +401,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface switch ($type) { case 'basic': // Ensure that we don't have the header in different case and set the new value. - $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']); + $modify['set_headers'] = Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']); $modify['set_headers']['Authorization'] = 'Basic ' . \base64_encode("$value[0]:$value[1]"); break; @@ -409,7 +420,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface if (isset($options['query'])) { $value = $options['query']; if (\is_array($value)) { - $value = \http_build_query($value, null, '&', \PHP_QUERY_RFC3986); + $value = \http_build_query($value, '', '&', \PHP_QUERY_RFC3986); } if (!\is_string($value)) { throw new InvalidArgumentException('query must be a string or array'); @@ -426,11 +437,11 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface } } - $request = Psr7\modify_request($request, $modify); + $request = Psr7\Utils::modifyRequest($request, $modify); if ($request->getBody() instanceof Psr7\MultipartStream) { // Use a multipart/form-data POST if a Content-Type is not set. // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' . $request->getBody()->getBoundary(); } @@ -444,7 +455,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $modify['set_headers'][$k] = $v; } } - $request = Psr7\modify_request($request, $modify); + $request = Psr7\Utils::modifyRequest($request, $modify); // Don't pass this internal value along to middleware/handlers. unset($options['_conditional']); } diff --git a/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/vendor/guzzlehttp/guzzle/src/ClientInterface.php index bc0fe73d..6aaee61a 100644 --- a/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ b/vendor/guzzlehttp/guzzle/src/ClientInterface.php @@ -16,7 +16,7 @@ interface ClientInterface /** * The Guzzle major version. */ - const MAJOR_VERSION = 7; + public const MAJOR_VERSION = 7; /** * Send an HTTP request. @@ -77,6 +77,8 @@ interface ClientInterface * @param string|null $option The config option to retrieve. * * @return mixed + * + * @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0. */ public function getConfig(?string $option = null); } diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php index fa6d6600..7df374b5 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php @@ -36,10 +36,7 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate * @param RequestInterface $request Request that was sent * @param ResponseInterface $response Response that was received */ - public function extractCookies( - RequestInterface $request, - ResponseInterface $response - ): void; + public function extractCookies(RequestInterface $request, ResponseInterface $response): void; /** * Sets a cookie in the cookie jar. diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php index cf278cb6..7c04034d 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php @@ -28,7 +28,7 @@ class SetCookie private $data; /** - * Create a new SetCookie object from a string + * Create a new SetCookie object from a string. * * @param string $cookie Set-Cookie header string */ @@ -39,7 +39,7 @@ class SetCookie // Explode the cookie string using a series of semicolons $pieces = \array_filter(\array_map('trim', \explode(';', $cookie))); // The name of the cookie (first kvp) must exist and include an equal sign. - if (empty($pieces[0]) || !\strpos($pieces[0], '=')) { + if (!isset($pieces[0]) || \strpos($pieces[0], '=') === false) { return new self($data); } @@ -52,7 +52,7 @@ class SetCookie : true; // Only check for non-cookies when cookies have been found - if (empty($data['Name'])) { + if (!isset($data['Name'])) { $data['Name'] = $key; $data['Value'] = $value; } else { @@ -92,7 +92,7 @@ class SetCookie public function __toString() { - $str = $this->data['Name'] . '=' . $this->data['Value'] . '; '; + $str = $this->data['Name'] . '=' . ($this->data['Value'] ?? '') . '; '; foreach ($this->data as $k => $v) { if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) { if ($k === 'Expires') { @@ -112,7 +112,7 @@ class SetCookie } /** - * Get the cookie name + * Get the cookie name. * * @return string */ @@ -122,17 +122,21 @@ class SetCookie } /** - * Set the cookie name + * Set the cookie name. * * @param string $name Cookie name */ public function setName($name): void { - $this->data['Name'] = $name; + if (!is_string($name)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Name'] = (string) $name; } /** - * Get the cookie value + * Get the cookie value. * * @return string|null */ @@ -142,17 +146,21 @@ class SetCookie } /** - * Set the cookie value + * Set the cookie value. * * @param string $value Cookie value */ public function setValue($value): void { - $this->data['Value'] = $value; + if (!is_string($value)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Value'] = (string) $value; } /** - * Get the domain + * Get the domain. * * @return string|null */ @@ -162,17 +170,21 @@ class SetCookie } /** - * Set the domain of the cookie + * Set the domain of the cookie. * - * @param string $domain + * @param string|null $domain */ public function setDomain($domain): void { - $this->data['Domain'] = $domain; + if (!is_string($domain) && null !== $domain) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Domain'] = null === $domain ? null : (string) $domain; } /** - * Get the path + * Get the path. * * @return string */ @@ -182,37 +194,45 @@ class SetCookie } /** - * Set the path of the cookie + * Set the path of the cookie. * * @param string $path Path of the cookie */ public function setPath($path): void { - $this->data['Path'] = $path; + if (!is_string($path)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Path'] = (string) $path; } /** - * Maximum lifetime of the cookie in seconds + * Maximum lifetime of the cookie in seconds. * * @return int|null */ public function getMaxAge() { - return $this->data['Max-Age']; + return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age']; } /** - * Set the max-age of the cookie + * Set the max-age of the cookie. * - * @param int $maxAge Max age of the cookie in seconds + * @param int|null $maxAge Max age of the cookie in seconds */ public function setMaxAge($maxAge): void { - $this->data['Max-Age'] = $maxAge; + if (!is_int($maxAge) && null !== $maxAge) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Max-Age'] = $maxAge === null ? null : (int) $maxAge; } /** - * The UNIX timestamp when the cookie Expires + * The UNIX timestamp when the cookie Expires. * * @return string|int|null */ @@ -222,21 +242,23 @@ class SetCookie } /** - * Set the unix timestamp for which the cookie will expire + * Set the unix timestamp for which the cookie will expire. * - * @param int|string $timestamp Unix timestamp or any English textual datetime description. + * @param int|string|null $timestamp Unix timestamp or any English textual datetime description. */ public function setExpires($timestamp): void { - $this->data['Expires'] = \is_numeric($timestamp) - ? (int) $timestamp - : \strtotime($timestamp); + if (!is_int($timestamp) && !is_string($timestamp) && null !== $timestamp) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int, string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Expires'] = null === $timestamp ? null : (\is_numeric($timestamp) ? (int) $timestamp : \strtotime((string) $timestamp)); } /** - * Get whether or not this is a secure cookie + * Get whether or not this is a secure cookie. * - * @return bool|null + * @return bool */ public function getSecure() { @@ -244,17 +266,21 @@ class SetCookie } /** - * Set whether or not the cookie is secure + * Set whether or not the cookie is secure. * * @param bool $secure Set to true or false if secure */ public function setSecure($secure): void { - $this->data['Secure'] = $secure; + if (!is_bool($secure)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Secure'] = (bool) $secure; } /** - * Get whether or not this is a session cookie + * Get whether or not this is a session cookie. * * @return bool|null */ @@ -264,17 +290,21 @@ class SetCookie } /** - * Set whether or not this is a session cookie + * Set whether or not this is a session cookie. * * @param bool $discard Set to true or false if this is a session cookie */ public function setDiscard($discard): void { - $this->data['Discard'] = $discard; + if (!is_bool($discard)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Discard'] = (bool) $discard; } /** - * Get whether or not this is an HTTP only cookie + * Get whether or not this is an HTTP only cookie. * * @return bool */ @@ -284,13 +314,17 @@ class SetCookie } /** - * Set whether or not this is an HTTP only cookie + * Set whether or not this is an HTTP only cookie. * * @param bool $httpOnly Set to true or false if this is HTTP only */ public function setHttpOnly($httpOnly): void { - $this->data['HttpOnly'] = $httpOnly; + if (!is_bool($httpOnly)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['HttpOnly'] = (bool) $httpOnly; } /** @@ -332,7 +366,7 @@ class SetCookie } /** - * Check if the cookie matches a domain value + * Check if the cookie matches a domain value. * * @param string $domain Domain to check against */ @@ -362,7 +396,7 @@ class SetCookie } /** - * Check if the cookie is expired + * Check if the cookie is expired. */ public function isExpired(): bool { @@ -370,15 +404,14 @@ class SetCookie } /** - * Check if the cookie is valid according to RFC 6265 + * Check if the cookie is valid according to RFC 6265. * * @return bool|string Returns true if valid or an error message if invalid */ public function validate() { - // Names must not be empty, but can be 0 $name = $this->getName(); - if (empty($name) && !\is_numeric($name)) { + if ($name === '') { return 'The cookie name must not be empty'; } @@ -392,17 +425,17 @@ class SetCookie . 'following characters: ()<>@,;:\"/?={}'; } - // Value must not be empty, but can be 0 + // Value must not be null. 0 and empty string are valid. Empty strings + // are technically against RFC 6265, but known to happen in the wild. $value = $this->getValue(); - if (empty($value) && !\is_numeric($value)) { + if ($value === null) { return 'The cookie value must not be empty'; } - // Domains must not be empty, but can be 0 - // A "0" is not a valid internet domain, but may be used as server name - // in a private network. + // Domains must not be empty, but can be 0. "0" is not a valid internet + // domain, but may be used as server name in a private network. $domain = $this->getDomain(); - if (empty($domain) && !\is_numeric($domain)) { + if ($domain === null || $domain === '') { return 'The cookie domain must not be empty'; } diff --git a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php index 315fa378..c2d0a9cc 100644 --- a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +++ b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php @@ -2,6 +2,8 @@ namespace GuzzleHttp\Exception; +use GuzzleHttp\BodySummarizer; +use GuzzleHttp\BodySummarizerInterface; use Psr\Http\Client\RequestExceptionInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -47,24 +49,24 @@ class RequestException extends TransferException implements RequestExceptionInte */ public static function wrapException(RequestInterface $request, \Throwable $e): RequestException { - return $e instanceof RequestException - ? $e - : new RequestException($e->getMessage(), $request, null, $e); + return $e instanceof RequestException ? $e : new RequestException($e->getMessage(), $request, null, $e); } /** * Factory method to create a new exception with a normalized error message * - * @param RequestInterface $request Request - * @param ResponseInterface $response Response received - * @param \Throwable $previous Previous exception - * @param array $ctx Optional handler context. + * @param RequestInterface $request Request sent + * @param ResponseInterface $response Response received + * @param \Throwable|null $previous Previous exception + * @param array $handlerContext Optional handler context + * @param BodySummarizerInterface|null $bodySummarizer Optional body summarizer */ public static function create( RequestInterface $request, ResponseInterface $response = null, \Throwable $previous = null, - array $ctx = [] + array $handlerContext = [], + BodySummarizerInterface $bodySummarizer = null ): self { if (!$response) { return new self( @@ -72,7 +74,7 @@ class RequestException extends TransferException implements RequestExceptionInte $request, null, $previous, - $ctx + $handlerContext ); } @@ -97,18 +99,18 @@ class RequestException extends TransferException implements RequestExceptionInte '%s: `%s %s` resulted in a `%s %s` response', $label, $request->getMethod(), - $uri, + $uri->__toString(), $response->getStatusCode(), $response->getReasonPhrase() ); - $summary = \GuzzleHttp\Psr7\get_message_body_summary($response); + $summary = ($bodySummarizer ?? new BodySummarizer())->summarize($response); if ($summary !== null) { $message .= ":\n{$summary}\n"; } - return new $className($message, $request, $response, $previous, $ctx); + return new $className($message, $request, $response, $previous, $handlerContext); } /** diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php index d236865d..0c45089f 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php @@ -4,9 +4,9 @@ namespace GuzzleHttp\Handler; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\LazyOpenStream; use GuzzleHttp\TransferStats; use GuzzleHttp\Utils; @@ -14,14 +14,20 @@ use Psr\Http\Message\RequestInterface; /** * Creates curl resources from a request + * + * @final */ class CurlFactory implements CurlFactoryInterface { public const CURL_VERSION_STR = 'curl_version'; + + /** + * @deprecated + */ public const LOW_CURL_VERSION_NUMBER = '7.21.2'; /** - * @var resource[] + * @var resource[]|\CurlHandle[] */ private $handles = []; @@ -60,9 +66,7 @@ class CurlFactory implements CurlFactoryInterface } $conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy); - $easy->handle = $this->handles - ? \array_pop($this->handles) - : \curl_init(); + $easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init(); curl_setopt_array($easy->handle, $conf); return $easy; @@ -96,11 +100,8 @@ class CurlFactory implements CurlFactoryInterface * @param callable(RequestInterface, array): PromiseInterface $handler * @param CurlFactoryInterface $factory Dictates how the handle is released */ - public static function finish( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ): PromiseInterface { + public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface + { if (isset($easy->options['on_stats'])) { self::invokeStats($easy); } @@ -132,17 +133,14 @@ class CurlFactory implements CurlFactoryInterface $easy->errno, $curlStats ); - \call_user_func($easy->options['on_stats'], $stats); + ($easy->options['on_stats'])($stats); } /** * @param callable(RequestInterface, array): PromiseInterface $handler */ - private static function finishError( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ): PromiseInterface { + private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface + { // Get error information and release the handle to the factory. $ctx = [ 'errno' => $easy->errno, @@ -153,9 +151,7 @@ class CurlFactory implements CurlFactoryInterface $factory->release($easy); // Retry when nothing is present or when curl failed to rewind. - if (empty($easy->options['_err_message']) - && (!$easy->errno || $easy->errno == 65) - ) { + if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) { return self::retryFailedRewind($handler, $easy, $ctx); } @@ -172,10 +168,22 @@ class CurlFactory implements CurlFactoryInterface \CURLE_GOT_NOTHING => true, ]; + if ($easy->createResponseException) { + return P\Create::rejectionFor( + new RequestException( + 'An error was encountered while creating the response', + $easy->request, + $easy->response, + $easy->createResponseException, + $ctx + ) + ); + } + // If an exception was encountered during the onHeaders event, then // return a rejected promise that wraps that exception. if ($easy->onHeadersException) { - return \GuzzleHttp\Promise\rejection_for( + return P\Create::rejectionFor( new RequestException( 'An error was encountered during the on_headers event', $easy->request, @@ -185,21 +193,16 @@ class CurlFactory implements CurlFactoryInterface ) ); } - 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() - ); + + $message = \sprintf( + 'cURL error %s: %s (%s)', + $ctx['errno'], + $ctx['error'], + 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html' + ); + $uriString = (string) $easy->request->getUri(); + if ($uriString !== '' && false === \strpos($ctx['error'], $uriString)) { + $message .= \sprintf(' for %s', $uriString); } // Create a connection exception if it was a specific error code. @@ -207,7 +210,7 @@ class CurlFactory implements CurlFactoryInterface ? new ConnectException($message, $easy->request, null, $ctx) : new RequestException($message, $easy->request, $easy->response, null, $ctx); - return \GuzzleHttp\Promise\rejection_for($error); + return P\Create::rejectionFor($error); } /** @@ -275,9 +278,7 @@ class CurlFactory implements CurlFactoryInterface // Send the body as a string if the size is less than 1MB OR if the // [curl][body_as_string] request value is set. - if (($size !== null && $size < 1000000) || - !empty($options['_body_as_string']) - ) { + if (($size !== null && $size < 1000000) || !empty($options['_body_as_string'])) { $conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody(); // Don't duplicate the Content-Length header $this->removeHeader('Content-Length', $conf); @@ -359,9 +360,7 @@ class CurlFactory implements CurlFactoryInterface if (\is_string($options['verify'])) { // Throw an error if the file/folder/link path is not valid or doesn't exist. if (!\file_exists($options['verify'])) { - throw new \InvalidArgumentException( - "SSL CA bundle not found: {$options['verify']}" - ); + throw new \InvalidArgumentException("SSL CA bundle not found: {$options['verify']}"); } // If it's a directory or a link to a directory use CURLOPT_CAPATH. // If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO. @@ -381,40 +380,38 @@ class CurlFactory implements CurlFactoryInterface } } - if (!empty($options['decode_content'])) { + if (!isset($options['curl'][\CURLOPT_ENCODING]) && !empty($options['decode_content'])) { $accept = $easy->request->getHeaderLine('Accept-Encoding'); if ($accept) { $conf[\CURLOPT_ENCODING] = $accept; } else { + // The empty string enables all available decoders and implicitly + // sets a matching 'Accept-Encoding' header. $conf[\CURLOPT_ENCODING] = ''; - // Don't let curl send the header over the wire + // But as the user did not specify any acceptable encodings we need + // to overwrite this implicit header with an empty one. $conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:'; } } - if (isset($options['sink'])) { - $sink = $options['sink']; - if (!\is_string($sink)) { - $sink = \GuzzleHttp\Psr7\stream_for($sink); - } elseif (!\is_dir(\dirname($sink))) { - // Ensure that the directory exists before failing in curl. - throw new \RuntimeException(\sprintf( - 'Directory %s does not exist for sink value of %s', - \dirname($sink), - $sink - )); - } else { - $sink = new LazyOpenStream($sink, 'w+'); - } - $easy->sink = $sink; - $conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int { - return $sink->write($write); - }; - } else { + if (!isset($options['sink'])) { // Use a default temp stream if no sink was set. - $conf[\CURLOPT_FILE] = \fopen('php://temp', 'w+'); - $easy->sink = Psr7\stream_for($conf[\CURLOPT_FILE]); + $options['sink'] = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+'); } + $sink = $options['sink']; + if (!\is_string($sink)) { + $sink = \GuzzleHttp\Psr7\Utils::streamFor($sink); + } elseif (!\is_dir(\dirname($sink))) { + // Ensure that the directory exists before failing in curl. + throw new \RuntimeException(\sprintf('Directory %s does not exist for sink value of %s', \dirname($sink), $sink)); + } else { + $sink = new LazyOpenStream($sink, 'w+'); + } + $easy->sink = $sink; + $conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int { + return $sink->write($write); + }; + $timeoutRequiresNoSignal = false; if (isset($options['timeout'])) { $timeoutRequiresNoSignal |= $options['timeout'] < 1; @@ -446,9 +443,7 @@ class CurlFactory implements CurlFactoryInterface $scheme = $easy->request->getUri()->getScheme(); if (isset($options['proxy'][$scheme])) { $host = $easy->request->getUri()->getHost(); - if (!isset($options['proxy']['no']) || - !Utils::isHostInNoProxy($host, $options['proxy']['no']) - ) { + if (!isset($options['proxy']['no']) || !Utils::isHostInNoProxy($host, $options['proxy']['no'])) { $conf[\CURLOPT_PROXY] = $options['proxy'][$scheme]; } } @@ -462,9 +457,13 @@ class CurlFactory implements CurlFactoryInterface $cert = $cert[0]; } if (!\file_exists($cert)) { - throw new \InvalidArgumentException( - "SSL certificate not found: {$cert}" - ); + throw new \InvalidArgumentException("SSL certificate not found: {$cert}"); + } + # OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files. + # see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html + $ext = pathinfo($cert, \PATHINFO_EXTENSION); + if (preg_match('#^(der|p12)$#i', $ext)) { + $conf[\CURLOPT_SSLCERTTYPE] = strtoupper($ext); } $conf[\CURLOPT_SSLCERT] = $cert; } @@ -481,9 +480,7 @@ class CurlFactory implements CurlFactoryInterface $sslKey = $sslKey ?? $options['ssl_key']; if (!\file_exists($sslKey)) { - throw new \InvalidArgumentException( - "SSL private key not found: {$sslKey}" - ); + throw new \InvalidArgumentException("SSL private key not found: {$sslKey}"); } $conf[\CURLOPT_SSLKEY] = $sslKey; } @@ -491,18 +488,11 @@ class CurlFactory implements CurlFactoryInterface if (isset($options['progress'])) { $progress = $options['progress']; if (!\is_callable($progress)) { - throw new \InvalidArgumentException( - 'progress client option must be callable' - ); + throw new \InvalidArgumentException('progress client option must be callable'); } $conf[\CURLOPT_NOPROGRESS] = false; - $conf[\CURLOPT_PROGRESSFUNCTION] = static function () use ($progress) { - $args = \func_get_args(); - // PHP 5.5 pushed the handle onto the start of the args - if (\is_resource($args[0])) { - \array_shift($args); - } - \call_user_func_array($progress, $args); + $conf[\CURLOPT_PROGRESSFUNCTION] = static function ($resource, int $downloadSize, int $downloaded, int $uploadSize, int $uploaded) use ($progress) { + $progress($downloadSize, $downloaded, $uploadSize, $uploaded); }; } @@ -523,11 +513,8 @@ class CurlFactory implements CurlFactoryInterface * * @param callable(RequestInterface, array): PromiseInterface $handler */ - private static function retryFailedRewind( - callable $handler, - EasyHandle $easy, - array $ctx - ): PromiseInterface { + private static function retryFailedRewind(callable $handler, EasyHandle $easy, array $ctx): PromiseInterface + { try { // Only rewind if the body has been read from. $body = $easy->request->getBody(); @@ -580,7 +567,12 @@ class CurlFactory implements CurlFactoryInterface $value = \trim($h); if ($value === '') { $startingResponse = true; - $easy->createResponse(); + try { + $easy->createResponse(); + } catch (\Exception $e) { + $easy->createResponseException = $e; + return -1; + } if ($onHeaders !== null) { try { $onHeaders($easy->response); diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php index 55bba705..9ad10a9b 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php @@ -11,6 +11,8 @@ use Psr\Http\Message\RequestInterface; * When using the CurlHandler, custom curl options can be specified as an * associative array of curl option constants mapping to values in the * **curl** key of the "client" key of the request. + * + * @final */ class CurlHandler { @@ -22,9 +24,9 @@ class CurlHandler /** * Accepts an associative array of options: * - * - factory: Optional curl factory used to create cURL handles. + * - handle_factory: Optional curl factory used to create cURL handles. * - * @param array $options Array of options to use with the handler + * @param array{handle_factory?: ?CurlFactoryInterface} $options Array of options to use with the handler */ public function __construct(array $options = []) { diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php index a996d70f..9e2e4703 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php @@ -15,7 +15,9 @@ use Psr\Http\Message\RequestInterface; * associative array of curl option constants mapping to values in the * **curl** key of the provided request options. * - * @property resource $_mh Internal use only. Lazy loaded multi-handle. + * @property resource|\CurlMultiHandle $_mh Internal use only. Lazy loaded multi-handle. + * + * @final */ class CurlMultiHandler { @@ -30,7 +32,7 @@ class CurlMultiHandler private $selectTimeout; /** - * @var resource|null the currently executing resource in `curl_multi_exec`. + * @var resource|\CurlMultiHandle|null the currently executing resource in `curl_multi_exec`. */ private $active; @@ -69,6 +71,7 @@ class CurlMultiHandler if (isset($options['select_timeout'])) { $this->selectTimeout = $options['select_timeout']; } elseif ($selectTimeout = Utils::getenv('GUZZLE_CURL_SELECT_TIMEOUT')) { + @trigger_error('Since guzzlehttp/guzzle 7.2.0: Using environment variable GUZZLE_CURL_SELECT_TIMEOUT is deprecated. Use option "select_timeout" instead.', \E_USER_DEPRECATED); $this->selectTimeout = (int) $selectTimeout; } else { $this->selectTimeout = 1; @@ -80,7 +83,7 @@ class CurlMultiHandler /** * @param string $name * - * @return resource + * @return resource|\CurlMultiHandle * * @throws \BadMethodCallException when another field as `_mh` will be gotten * @throws \RuntimeException when curl can not initialize a multi handle @@ -152,11 +155,9 @@ class CurlMultiHandler } // Step through the task queue which may add additional requests. - P\queue()->run(); + P\Utils::queue()->run(); - if ($this->active && - \curl_multi_select($this->_mh, $this->selectTimeout) === -1 - ) { + if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) { // Perform a usleep if a select returns -1. // See: https://bugs.php.net/bug.php?id=61141 \usleep(250); @@ -172,7 +173,7 @@ class CurlMultiHandler */ public function execute(): void { - $queue = P\queue(); + $queue = P\Utils::queue(); while ($this->handles || !$queue->isEmpty()) { // If there are no transfers, then sleep for the next delay @@ -204,6 +205,10 @@ class CurlMultiHandler */ private function cancel($id): bool { + if (!is_int($id)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + // Cannot cancel if it has been processed. if (!isset($this->handles[$id])) { return false; @@ -220,6 +225,10 @@ class CurlMultiHandler private function processMessages(): void { while ($done = \curl_multi_info_read($this->_mh)) { + if ($done['msg'] !== \CURLMSG_DONE) { + // if it's not done, then it would be premature to remove the handle. ref https://github.com/guzzle/guzzle/pull/2892#issuecomment-945150216 + continue; + } $id = (int) $done['handle']; \curl_multi_remove_handle($this->_mh, $done['handle']); @@ -232,11 +241,7 @@ class CurlMultiHandler unset($this->handles[$id], $this->delays[$id]); $entry['easy']->errno = $done['result']; $entry['deferred']->resolve( - CurlFactory::finish( - $this, - $entry['easy'], - $this->factory - ) + CurlFactory::finish($this, $entry['easy'], $this->factory) ); } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php index 183476e9..224344d7 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php @@ -16,7 +16,7 @@ use Psr\Http\Message\StreamInterface; final class EasyHandle { /** - * @var resource cURL resource + * @var resource|\CurlHandle cURL resource */ public $handle; @@ -55,31 +55,28 @@ final class EasyHandle */ public $onHeadersException; + /** + * @var \Exception|null Exception during createResponse (if any) + */ + public $createResponseException; + /** * Attach a response to the easy handle based on the received headers. * - * @throws \RuntimeException if no headers have been received. + * @throws \RuntimeException if no headers have been received or the first + * header line is invalid. */ public function createResponse(): void { - if (empty($this->headers)) { - throw new \RuntimeException('No headers have been received'); - } + [$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($this->headers); - // HTTP-version SP status-code SP reason-phrase - $startLine = \explode(' ', \array_shift($this->headers), 3); - $headers = Utils::headersFromLines($this->headers); $normalizedKeys = Utils::normalizeHeaderKeys($headers); - if (!empty($this->options['decode_content']) - && isset($normalizedKeys['content-encoding']) - ) { - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; + if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) { + $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']]; unset($headers[$normalizedKeys['content-encoding']]); if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; + $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']]; $bodyLength = (int) $this->sink->getSize(); if ($bodyLength) { @@ -90,15 +87,13 @@ final class EasyHandle } } - $statusCode = (int) $startLine[1]; - // Attach a response to the easy handle with the parsed headers. $this->response = new Response( - $statusCode, + $status, $headers, $this->sink, - \substr($startLine[0], 5), - isset($startLine[2]) ? (string) $startLine[2] : null + $ver, + $reason ); } @@ -111,9 +106,7 @@ final class EasyHandle */ public function __get($name) { - $msg = $name === 'handle' - ? 'The EasyHandle has been released' - : 'Invalid property: ' . $name; + $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name; throw new \BadMethodCallException($msg); } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php b/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php new file mode 100644 index 00000000..a0988845 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php @@ -0,0 +1,42 @@ +onFulfilled = $onFulfilled; $this->onRejected = $onRejected; if ($queue) { - \call_user_func_array([$this, 'append'], $queue); + // array_values included for BC + $this->append(...array_values($queue)); } } @@ -86,7 +84,7 @@ class MockHandler implements \Countable } if (isset($options['delay']) && \is_numeric($options['delay'])) { - \usleep($options['delay'] * 1000); + \usleep((int) $options['delay'] * 1000); } $this->lastRequest = $request; @@ -106,18 +104,18 @@ class MockHandler implements \Countable } if (\is_callable($response)) { - $response = \call_user_func($response, $request, $options); + $response = $response($request, $options); } $response = $response instanceof \Throwable - ? \GuzzleHttp\Promise\rejection_for($response) - : \GuzzleHttp\Promise\promise_for($response); + ? P\Create::rejectionFor($response) + : P\Create::promiseFor($response); return $response->then( function (?ResponseInterface $value) use ($request, $options) { $this->invokeStats($request, $options, $value); if ($this->onFulfilled) { - \call_user_func($this->onFulfilled, $value); + ($this->onFulfilled)($value); } if ($value !== null && isset($options['sink'])) { @@ -138,9 +136,9 @@ class MockHandler implements \Countable function ($reason) use ($request, $options) { $this->invokeStats($request, $options, null, $reason); if ($this->onRejected) { - \call_user_func($this->onRejected, $reason); + ($this->onRejected)($reason); } - return \GuzzleHttp\Promise\rejection_for($reason); + return P\Create::rejectionFor($reason); } ); } @@ -207,7 +205,7 @@ class MockHandler implements \Countable if (isset($options['on_stats'])) { $transferTime = $options['transfer_time'] ?? 0; $stats = new TransferStats($request, $response, $transferTime, $reason); - \call_user_func($options['on_stats'], $stats); + ($options['on_stats'])($stats); } } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php index c027b7f7..f045b526 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php @@ -8,6 +8,8 @@ use Psr\Http\Message\RequestInterface; /** * Provides basic proxies for handlers. + * + * @final */ class Proxy { @@ -20,14 +22,10 @@ class Proxy * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler. */ - public static function wrapSync( - callable $default, - callable $sync - ): callable { + public static function wrapSync(callable $default, callable $sync): callable + { return static function (RequestInterface $request, array $options) use ($default, $sync): PromiseInterface { - return empty($options[RequestOptions::SYNCHRONOUS]) - ? $default($request, $options) - : $sync($request, $options); + return empty($options[RequestOptions::SYNCHRONOUS]) ? $default($request, $options) : $sync($request, $options); }; } @@ -44,14 +42,10 @@ class Proxy * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler. */ - public static function wrapStreaming( - callable $default, - callable $streaming - ): callable { + public static function wrapStreaming(callable $default, callable $streaming): callable + { return static function (RequestInterface $request, array $options) use ($default, $streaming): PromiseInterface { - return empty($options['stream']) - ? $default($request, $options) - : $streaming($request, $options); + return empty($options['stream']) ? $default($request, $options) : $streaming($request, $options); }; } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php index 9d45b626..70c646be 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php @@ -4,6 +4,7 @@ namespace GuzzleHttp\Handler; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7; @@ -16,6 +17,8 @@ use Psr\Http\Message\UriInterface; /** * HTTP handler that uses PHP's HTTP stream wrapper. + * + * @final */ class StreamHandler { @@ -72,7 +75,7 @@ class StreamHandler } $this->invokeStats($options, $request, $startTime, null, $e); - return \GuzzleHttp\Promise\rejection_for($e); + return P\Create::rejectionFor($e); } } @@ -84,61 +87,57 @@ class StreamHandler \Throwable $error = null ): void { if (isset($options['on_stats'])) { - $stats = new TransferStats( - $request, - $response, - Utils::currentTime() - $startTime, - $error, - [] - ); - \call_user_func($options['on_stats'], $stats); + $stats = new TransferStats($request, $response, Utils::currentTime() - $startTime, $error, []); + ($options['on_stats'])($stats); } } /** * @param resource $stream */ - private function createResponse( - RequestInterface $request, - array $options, - $stream, - ?float $startTime - ): PromiseInterface { + private function createResponse(RequestInterface $request, array $options, $stream, ?float $startTime): PromiseInterface + { $hdrs = $this->lastHeaders; $this->lastHeaders = []; - $parts = \explode(' ', \array_shift($hdrs), 3); - $ver = \explode('/', $parts[0])[1]; - $status = (int) $parts[1]; - $reason = $parts[2] ?? null; - $headers = Utils::headersFromLines($hdrs); + + try { + [$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($hdrs); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered while creating the response', $request, null, $e) + ); + } + [$stream, $headers] = $this->checkDecode($options, $headers, $stream); - $stream = Psr7\stream_for($stream); + $stream = Psr7\Utils::streamFor($stream); $sink = $stream; if (\strcasecmp('HEAD', $request->getMethod())) { $sink = $this->createSink($stream, $options); } - $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); + try { + $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered while creating the response', $request, null, $e) + ); + } if (isset($options['on_headers'])) { try { $options['on_headers']($response); } catch (\Exception $e) { - $msg = 'An error was encountered during the on_headers event'; - $ex = new RequestException($msg, $request, $response, $e); - return \GuzzleHttp\Promise\rejection_for($ex); + return P\Create::rejectionFor( + new RequestException('An error was encountered during the on_headers event', $request, $response, $e) + ); } } // Do not drain when the request is a HEAD request because they have // no body. if ($sink !== $stream) { - $this->drain( - $stream, - $sink, - $response->getHeaderLine('Content-Length') - ); + $this->drain($stream, $sink, $response->getHeaderLine('Content-Length')); } $this->invokeStats($options, $request, $startTime, $response, null); @@ -152,12 +151,9 @@ class StreamHandler return $stream; } - $sink = $options['sink'] - ?? \fopen('php://temp', 'r+'); + $sink = $options['sink'] ?? Psr7\Utils::tryFopen('php://temp', 'r+'); - return \is_string($sink) - ? new Psr7\LazyOpenStream($sink, 'w+') - : Psr7\stream_for($sink); + return \is_string($sink) ? new Psr7\LazyOpenStream($sink, 'w+') : Psr7\Utils::streamFor($sink); } /** @@ -171,18 +167,15 @@ class StreamHandler if (isset($normalizedKeys['content-encoding'])) { $encoding = $headers[$normalizedKeys['content-encoding']]; if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') { - $stream = new Psr7\InflateStream( - Psr7\stream_for($stream) - ); - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; + $stream = new Psr7\InflateStream(Psr7\Utils::streamFor($stream)); + $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']]; + // Remove content-encoding header unset($headers[$normalizedKeys['content-encoding']]); + // Fix content-length header if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; - + $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']]; $length = (int) $stream->getSize(); if ($length === 0) { unset($headers[$normalizedKeys['content-length']]); @@ -205,16 +198,13 @@ class StreamHandler * * @throws \RuntimeException when the sink option is invalid. */ - private function drain( - StreamInterface $source, - StreamInterface $sink, - string $contentLength - ): StreamInterface { + private function drain(StreamInterface $source, StreamInterface $sink, string $contentLength): StreamInterface + { // If a content-length header is provided, then stop reading once // that number of bytes has been read. This can prevent infinitely // reading from a stream when dealing with servers that do not honor // Connection: Close headers. - Psr7\copy_to_stream( + Psr7\Utils::copyToStream( $source, $sink, (\strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1 @@ -247,8 +237,11 @@ class StreamHandler return true; }); - $resource = $callback(); - \restore_error_handler(); + try { + $resource = $callback(); + } finally { + \restore_error_handler(); + } if (!$resource) { $message = 'Error creating resource: '; @@ -306,10 +299,7 @@ class StreamHandler if (!\is_array($options['stream_context'])) { throw new \InvalidArgumentException('stream_context must be an array'); } - $context = \array_replace_recursive( - $context, - $options['stream_context'] - ); + $context = \array_replace_recursive($context, $options['stream_context']); } // Microsoft NTLM authentication only supported with curl handler @@ -327,16 +317,11 @@ class StreamHandler return $this->createResource( function () use ($uri, &$http_response_header, $contextResource, $context, $options, $request) { - $resource = \fopen((string) $uri, 'r', false, $contextResource); + $resource = @\fopen((string) $uri, 'r', false, $contextResource); $this->lastHeaders = $http_response_header; if (false === $resource) { - throw new ConnectException( - sprintf('Connection refused for URI %s', $uri), - $request, - null, - $context - ); + throw new ConnectException(sprintf('Connection refused for URI %s', $uri), $request, null, $context); } if (isset($options['read_timeout'])) { @@ -359,26 +344,14 @@ class StreamHandler if ('v4' === $options['force_ip_resolve']) { $records = \dns_get_record($uri->getHost(), \DNS_A); if (false === $records || !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); } return $uri->withHost($records[0]['ip']); } if ('v6' === $options['force_ip_resolve']) { $records = \dns_get_record($uri->getHost(), \DNS_AAAA); if (false === $records || !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); } return $uri->withHost('[' . $records[0]['ipv6'] . ']'); } @@ -426,21 +399,60 @@ class StreamHandler */ private function add_proxy(RequestInterface $request, array &$options, $value, array &$params): void { + $uri = null; + if (!\is_array($value)) { - $options['http']['proxy'] = $value; + $uri = $value; } else { $scheme = $request->getUri()->getScheme(); if (isset($value[$scheme])) { - if (!isset($value['no']) - || !Utils::isHostInNoProxy( - $request->getUri()->getHost(), - $value['no'] - ) - ) { - $options['http']['proxy'] = $value[$scheme]; + if (!isset($value['no']) || !Utils::isHostInNoProxy($request->getUri()->getHost(), $value['no'])) { + $uri = $value[$scheme]; } } } + + if (!$uri) { + return; + } + + $parsed = $this->parse_proxy($uri); + $options['http']['proxy'] = $parsed['proxy']; + + if ($parsed['auth']) { + if (!isset($options['http']['header'])) { + $options['http']['header'] = []; + } + $options['http']['header'] .= "\r\nProxy-Authorization: {$parsed['auth']}"; + } + } + + /** + * Parses the given proxy URL to make it compatible with the format PHP's stream context expects. + */ + private function parse_proxy(string $url): array + { + $parsed = \parse_url($url); + + if ($parsed !== false && isset($parsed['scheme']) && $parsed['scheme'] === 'http') { + if (isset($parsed['host']) && isset($parsed['port'])) { + $auth = null; + if (isset($parsed['user']) && isset($parsed['pass'])) { + $auth = \base64_encode("{$parsed['user']}:{$parsed['pass']}"); + } + + return [ + 'proxy' => "tcp://{$parsed['host']}:{$parsed['port']}", + 'auth' => $auth ? "Basic {$auth}" : null, + ]; + } + } + + // Return proxy as-is. + return [ + 'proxy' => $url, + 'auth' => null, + ]; } /** @@ -501,11 +513,13 @@ class StreamHandler */ private function add_progress(RequestInterface $request, array &$options, $value, array &$params): void { - $this->addNotification( + self::addNotification( $params, static function ($code, $a, $b, $c, $transferred, $total) use ($value) { if ($code == \STREAM_NOTIFY_PROGRESS) { - $value($total, $transferred, null, null); + // The upload progress cannot be determined. Use 0 for cURL compatibility: + // https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html + $value($total, $transferred, 0, 0); } } ); @@ -532,16 +546,13 @@ class StreamHandler \STREAM_NOTIFY_COMPLETED => 'COMPLETED', \STREAM_NOTIFY_RESOLVE => 'RESOLVE', ]; - static $args = ['severity', 'message', 'message_code', - 'bytes_transferred', 'bytes_max']; + static $args = ['severity', 'message', 'message_code', 'bytes_transferred', 'bytes_max']; $value = Utils::debugResource($value); $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment(''); - $this->addNotification( + self::addNotification( $params, - static function () use ($ident, $value, $map, $args): void { - $passed = \func_get_args(); - $code = \array_shift($passed); + static function (int $code, ...$passed) use ($ident, $value, $map, $args): void { \fprintf($value, '<%s> [%s] ', $ident, $map[$code]); foreach (\array_filter($passed) as $i => $v) { \fwrite($value, $args[$i] . ': "' . $v . '" '); @@ -551,25 +562,24 @@ class StreamHandler ); } - private function addNotification(array &$params, callable $notify): void + private static function addNotification(array &$params, callable $notify): void { // Wrap the existing function if needed. if (!isset($params['notification'])) { $params['notification'] = $notify; } else { - $params['notification'] = $this->callArray([ + $params['notification'] = self::callArray([ $params['notification'], $notify ]); } } - private function callArray(array $functions): callable + private static function callArray(array $functions): callable { - return static function () use ($functions) { - $args = \func_get_args(); + return static function (...$args) use ($functions) { foreach ($functions as $fn) { - \call_user_func_array($fn, $args); + $fn(...$args); } }; } diff --git a/vendor/guzzlehttp/guzzle/src/HandlerStack.php b/vendor/guzzlehttp/guzzle/src/HandlerStack.php index 13a3fa0d..e0a1d119 100644 --- a/vendor/guzzlehttp/guzzle/src/HandlerStack.php +++ b/vendor/guzzlehttp/guzzle/src/HandlerStack.php @@ -9,11 +9,13 @@ use Psr\Http\Message\ResponseInterface; /** * Creates a composed Guzzle handler function by stacking middlewares on top of * an HTTP handler function. + * + * @final */ class HandlerStack { /** - * @var null|callable(RequestInterface, array): PromiseInterface + * @var (callable(RequestInterface, array): PromiseInterface)|null */ private $handler; @@ -23,7 +25,7 @@ class HandlerStack private $stack = []; /** - * @var null|callable(RequestInterface, array): PromiseInterface + * @var (callable(RequestInterface, array): PromiseInterface)|null */ private $cached; @@ -38,9 +40,9 @@ class HandlerStack * The returned handler stack can be passed to a client in the "handler" * option. * - * @param null|callable(RequestInterface, array): PromiseInterface $handler HTTP handler function to use with the stack. If no - * handler is provided, the best handler for your - * system will be utilized. + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler HTTP handler function to use with the stack. If no + * handler is provided, the best handler for your + * system will be utilized. */ public static function create(?callable $handler = null): self { @@ -54,7 +56,7 @@ class HandlerStack } /** - * @param null|callable(RequestInterface, array): PromiseInterface $handler Underlying HTTP handler. + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler Underlying HTTP handler. */ public function __construct(callable $handler = null) { @@ -178,6 +180,10 @@ class HandlerStack */ public function remove($remove): void { + if (!is_string($remove) && !is_callable($remove)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a callable or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->cached = null; $idx = \is_callable($remove) ? 0 : 1; $this->stack = \array_values(\array_filter( @@ -249,7 +255,7 @@ class HandlerStack /** * Provides a debug string for a given callable. * - * @param callable $fn Function to write as a string. + * @param callable|string $fn Function to write as a string. */ private function debugCallable($fn): string { diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php index 36e3a9c4..da499547 100644 --- a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +++ b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php @@ -32,8 +32,10 @@ use Psr\Http\Message\ResponseInterface; * - {res_headers}: Response headers * - {req_body}: Request body * - {res_body}: Response body + * + * @final */ -class MessageFormatter +class MessageFormatter implements MessageFormatterInterface { /** * Apache Common Log Format. @@ -66,11 +68,8 @@ class MessageFormatter * @param ResponseInterface|null $response Response that was received * @param \Throwable|null $error Exception that was received */ - public function format( - RequestInterface $request, - ?ResponseInterface $response = null, - ?\Throwable $error = null - ): string { + public function format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null): string + { $cache = []; /** @var string */ @@ -84,10 +83,10 @@ class MessageFormatter $result = ''; switch ($matches[1]) { case 'request': - $result = Psr7\str($request); + $result = Psr7\Message::toString($request); break; case 'response': - $result = $response ? Psr7\str($response) : ''; + $result = $response ? Psr7\Message::toString($response) : ''; break; case 'req_headers': $result = \trim($request->getMethod() @@ -106,10 +105,22 @@ class MessageFormatter : 'NULL'; break; case 'req_body': - $result = $request->getBody(); + $result = $request->getBody()->__toString(); break; case 'res_body': - $result = $response ? $response->getBody() : 'NULL'; + if (!$response instanceof ResponseInterface) { + $result = 'NULL'; + break; + } + + $body = $response->getBody(); + + if (!$body->isSeekable()) { + $result = 'RESPONSE_NOT_LOGGEABLE'; + break; + } + + $result = $response->getBody()->__toString(); break; case 'ts': case 'date_iso_8601': @@ -126,7 +137,7 @@ class MessageFormatter break; case 'uri': case 'url': - $result = $request->getUri(); + $result = $request->getUri()->__toString(); break; case 'target': $result = $request->getRequestTarget(); diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php b/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php new file mode 100644 index 00000000..a39ac248 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php @@ -0,0 +1,18 @@ +then( - static function (ResponseInterface $response) use ($request) { + static function (ResponseInterface $response) use ($request, $bodySummarizer) { $code = $response->getStatusCode(); if ($code < 400) { return $response; } - throw RequestException::create($request, $response); + throw RequestException::create($request, $response, null, [], $bodySummarizer); } ); }; @@ -104,7 +107,7 @@ final class Middleware 'error' => $reason, 'options' => $options ]; - return \GuzzleHttp\Promise\rejection_for($reason); + return P\Create::rejectionFor($reason); } ); }; @@ -180,14 +183,19 @@ final class Middleware * * @phpstan-param \Psr\Log\LogLevel::* $logLevel Level at which to log requests. * - * @param LoggerInterface $logger Logs messages. - * @param MessageFormatter $formatter Formatter used to create message strings. - * @param string $logLevel Level at which to log requests. + * @param LoggerInterface $logger Logs messages. + * @param MessageFormatterInterface|MessageFormatter $formatter Formatter used to create message strings. + * @param string $logLevel Level at which to log requests. * * @return callable Returns a function that accepts the next handler. */ - public static function log(LoggerInterface $logger, MessageFormatter $formatter, string $logLevel = 'info'): callable + public static function log(LoggerInterface $logger, $formatter, string $logLevel = 'info'): callable { + // To be compatible with Guzzle 7.1.x we need to allow users to pass a MessageFormatter + if (!$formatter instanceof MessageFormatter && !$formatter instanceof MessageFormatterInterface) { + throw new \LogicException(sprintf('Argument 2 to %s::log() must be of type %s', self::class, MessageFormatterInterface::class)); + } + return static function (callable $handler) use ($logger, $formatter, $logLevel): callable { return static function (RequestInterface $request, array $options = []) use ($handler, $logger, $formatter, $logLevel) { return $handler($request, $options)->then( @@ -197,12 +205,10 @@ final class Middleware return $response; }, static function ($reason) use ($logger, $request, $formatter): PromiseInterface { - $response = $reason instanceof RequestException - ? $reason->getResponse() - : null; - $message = $formatter->format($request, $response, \GuzzleHttp\Promise\exception_for($reason)); + $response = $reason instanceof RequestException ? $reason->getResponse() : null; + $message = $formatter->format($request, $response, P\Create::exceptionFor($reason)); $logger->error($message); - return \GuzzleHttp\Promise\rejection_for($reason); + return P\Create::rejectionFor($reason); } ); }; diff --git a/vendor/guzzlehttp/guzzle/src/Pool.php b/vendor/guzzlehttp/guzzle/src/Pool.php index 66fe0292..6277c61f 100644 --- a/vendor/guzzlehttp/guzzle/src/Pool.php +++ b/vendor/guzzlehttp/guzzle/src/Pool.php @@ -2,6 +2,7 @@ namespace GuzzleHttp; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\EachPromise; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\PromisorInterface; @@ -17,6 +18,8 @@ use Psr\Http\Message\RequestInterface; * When a function is yielded by the iterator, the function is provided the * "request_options" array that should be merged on top of any existing * options, and the function MUST then return a wait-able promise. + * + * @final */ class Pool implements PromisorInterface { @@ -35,11 +38,8 @@ class Pool implements PromisorInterface * - fulfilled: (callable) Function to invoke when a request completes. * - rejected: (callable) Function to invoke when a request is rejected. */ - public function __construct( - ClientInterface $client, - $requests, - array $config = [] - ) { + public function __construct(ClientInterface $client, $requests, array $config = []) + { if (!isset($config['concurrency'])) { $config['concurrency'] = 25; } @@ -51,7 +51,7 @@ class Pool implements PromisorInterface $opts = []; } - $iterable = \GuzzleHttp\Promise\iter_for($requests); + $iterable = P\Create::iterFor($requests); $requests = static function () use ($iterable, $client, $opts) { foreach ($iterable as $key => $rfn) { if ($rfn instanceof RequestInterface) { @@ -59,10 +59,7 @@ class Pool implements PromisorInterface } elseif (\is_callable($rfn)) { yield $key => $rfn($opts); } else { - throw new \InvalidArgumentException('Each value yielded by ' - . 'the iterator must be a Psr7\Http\Message\RequestInterface ' - . 'or a callable that returns a promise that fulfills ' - . 'with a Psr7\Message\Http\ResponseInterface object.'); + throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7\Http\Message\RequestInterface or a callable that returns a promise that fulfills with a Psr7\Message\Http\ResponseInterface object.'); } } }; @@ -96,11 +93,8 @@ class Pool implements PromisorInterface * * @throws \InvalidArgumentException if the event format is incorrect. */ - public static function batch( - ClientInterface $client, - $requests, - array $options = [] - ): array { + public static function batch(ClientInterface $client, $requests, array $options = []): array + { $res = []; self::cmpCallback($options, 'fulfilled', $res); self::cmpCallback($options, 'rejected', $res); diff --git a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php index 28331a0e..7ca62833 100644 --- a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php @@ -8,6 +8,8 @@ use Psr\Http\Message\RequestInterface; /** * Prepares requests that contain a body, adding the Content-Length, * Content-Type, and Expect headers. + * + * @final */ class PrepareBodyMiddleware { @@ -38,7 +40,7 @@ class PrepareBodyMiddleware // Add a default content-type if possible. if (!$request->hasHeader('Content-Type')) { if ($uri = $request->getBody()->getMetadata('uri')) { - if ($type = Psr7\mimetype_from_filename($uri)) { + if (is_string($uri) && $type = Psr7\MimeType::fromFilename($uri)) { $modify['set_headers']['Content-Type'] = $type; } } @@ -59,17 +61,14 @@ class PrepareBodyMiddleware // Add the expect header if needed. $this->addExpectHeader($request, $options, $modify); - return $fn(Psr7\modify_request($request, $modify), $options); + return $fn(Psr7\Utils::modifyRequest($request, $modify), $options); } /** * Add expect header */ - private function addExpectHeader( - RequestInterface $request, - array $options, - array &$modify - ): void { + private function addExpectHeader(RequestInterface $request, array $options, array &$modify): void + { // Determine if the Expect header should be used if ($request->hasHeader('Expect')) { return; diff --git a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php index 09dc7efa..1dd38614 100644 --- a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php @@ -14,6 +14,8 @@ use Psr\Http\Message\UriInterface; * * Apply this middleware like other middleware using * {@see \GuzzleHttp\Middleware::redirect()}. + * + * @final */ class RedirectMiddleware { @@ -75,23 +77,19 @@ class RedirectMiddleware /** * @return ResponseInterface|PromiseInterface */ - public function checkRedirect( - RequestInterface $request, - array $options, - ResponseInterface $response - ) { + public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response) + { if (\strpos((string) $response->getStatusCode(), '3') !== 0 || !$response->hasHeader('Location') ) { return $response; } - $this->guardMax($request, $options); + $this->guardMax($request, $response, $options); $nextRequest = $this->modifyRequest($request, $options, $response); if (isset($options['allow_redirects']['on_redirect'])) { - \call_user_func( - $options['allow_redirects']['on_redirect'], + ($options['allow_redirects']['on_redirect'])( $request, $response, $nextRequest->getUri() @@ -138,7 +136,7 @@ class RedirectMiddleware * * @throws TooManyRedirectsException Too many redirects. */ - private function guardMax(RequestInterface $request, array &$options): void + private function guardMax(RequestInterface $request, ResponseInterface $response, array &$options): void { $current = $options['__redirect_count'] ?? 0; @@ -146,18 +144,12 @@ class RedirectMiddleware $max = $options['allow_redirects']['max']; if ($options['__redirect_count'] > $max) { - throw new TooManyRedirectsException( - "Will not follow more than {$max} redirects", - $request - ); + throw new TooManyRedirectsException("Will not follow more than {$max} redirects", $request, $response); } } - public function modifyRequest( - RequestInterface $request, - array $options, - ResponseInterface $response - ): RequestInterface { + public function modifyRequest(RequestInterface $request, array $options, ResponseInterface $response): RequestInterface + { // Request modifications to apply. $modify = []; $protocols = $options['allow_redirects']['protocols']; @@ -169,7 +161,10 @@ class RedirectMiddleware if ($statusCode == 303 || ($statusCode <= 302 && !$options['allow_redirects']['strict']) ) { - $modify['method'] = 'GET'; + $safeMethods = ['GET', 'HEAD', 'OPTIONS']; + $requestMethod = $request->getMethod(); + + $modify['method'] = in_array($requestMethod, $safeMethods) ? $requestMethod : 'GET'; $modify['body'] = ''; } @@ -180,7 +175,7 @@ class RedirectMiddleware } $modify['uri'] = $uri; - Psr7\rewind_body($request); + Psr7\Message::rewindBody($request); // Add the Referer header if it is told to do so and only // add the header if we are not redirecting from https to http. @@ -198,17 +193,14 @@ class RedirectMiddleware $modify['remove_headers'][] = 'Authorization'; } - return Psr7\modify_request($request, $modify); + return Psr7\Utils::modifyRequest($request, $modify); } /** * Set the appropriate URL on the request based on the location header */ - private function redirectUri( - RequestInterface $request, - ResponseInterface $response, - array $protocols - ): UriInterface { + private function redirectUri(RequestInterface $request, ResponseInterface $response, array $protocols): UriInterface + { $location = Psr7\UriResolver::resolve( $request->getUri(), new Psr7\Uri($response->getHeaderLine('Location')) @@ -216,15 +208,7 @@ class RedirectMiddleware // Ensure that the redirect URI is allowed based on the protocols. if (!\in_array($location->getScheme(), $protocols)) { - throw new BadResponseException( - \sprintf( - 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s', - $location, - \implode(', ', $protocols) - ), - $request, - $response - ); + throw new BadResponseException(\sprintf('Redirect URI, %s, does not use one of the allowed redirect protocols: %s', $location, \implode(', ', $protocols)), $request, $response); } return $location; diff --git a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php index 187eca64..c210fc47 100644 --- a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php @@ -2,6 +2,7 @@ namespace GuzzleHttp; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\PromiseInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -9,6 +10,8 @@ use Psr\Http\Message\ResponseInterface; /** * Middleware that retries requests based on the boolean result of * invoking the provided "decider" function. + * + * @final */ class RetryMiddleware { @@ -33,15 +36,12 @@ class RetryMiddleware * returns true if the request is to be * retried. * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke. - * @param null|callable(int): int $delay Function that accepts the number of retries + * @param (callable(int): int)|null $delay Function that accepts the number of retries * and returns the number of * milliseconds to delay. */ - public function __construct( - callable $decider, - callable $nextHandler, - callable $delay = null - ) { + public function __construct(callable $decider, callable $nextHandler, callable $delay = null) + { $this->decider = $decider; $this->nextHandler = $nextHandler; $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; @@ -77,8 +77,7 @@ class RetryMiddleware private function onFulfilled(RequestInterface $request, array $options): callable { return function ($value) use ($request, $options) { - if (!\call_user_func( - $this->decider, + if (!($this->decider)( $options['retries'], $request, $value, @@ -96,14 +95,13 @@ class RetryMiddleware private function onRejected(RequestInterface $req, array $options): callable { return function ($reason) use ($req, $options) { - if (!\call_user_func( - $this->decider, + if (!($this->decider)( $options['retries'], $req, null, $reason )) { - return \GuzzleHttp\Promise\rejection_for($reason); + return P\Create::rejectionFor($reason); } return $this->doRetry($req, $options); }; @@ -111,7 +109,7 @@ class RetryMiddleware private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null): PromiseInterface { - $options['delay'] = \call_user_func($this->delay, ++$options['retries'], $response); + $options['delay'] = ($this->delay)(++$options['retries'], $response); return $this($request, $options); } diff --git a/vendor/guzzlehttp/guzzle/src/TransferStats.php b/vendor/guzzlehttp/guzzle/src/TransferStats.php index f15e816b..93fa334c 100644 --- a/vendor/guzzlehttp/guzzle/src/TransferStats.php +++ b/vendor/guzzlehttp/guzzle/src/TransferStats.php @@ -128,8 +128,6 @@ final class TransferStats */ public function getHandlerStat(string $stat) { - return isset($this->handlerStats[$stat]) - ? $this->handlerStats[$stat] - : null; + return $this->handlerStats[$stat] ?? null; } } diff --git a/vendor/guzzlehttp/guzzle/src/Utils.php b/vendor/guzzlehttp/guzzle/src/Utils.php index 5a0f8a81..91591da2 100644 --- a/vendor/guzzlehttp/guzzle/src/Utils.php +++ b/vendor/guzzlehttp/guzzle/src/Utils.php @@ -49,9 +49,7 @@ final class Utils foreach ($lines as $line) { $parts = \explode(':', $line, 2); - $headers[\trim($parts[0])][] = isset($parts[1]) - ? \trim($parts[1]) - : null; + $headers[\trim($parts[0])][] = isset($parts[1]) ? \trim($parts[1]) : null; } return $headers; @@ -73,12 +71,7 @@ final class Utils return \STDOUT; } - $resource = \fopen('php://output', 'w'); - if (false === $resource) { - throw new \RuntimeException('Can not open php output for writing to debug the resource.'); - } - - return $resource; + return \GuzzleHttp\Psr7\Utils::tryFopen('php://output', 'w'); } /** @@ -106,8 +99,7 @@ final class Utils ? Proxy::wrapStreaming($handler, new StreamHandler()) : new StreamHandler(); } elseif (!$handler) { - throw new \RuntimeException('GuzzleHttp requires cURL, the ' - . 'allow_url_fopen ini setting, or a custom HTTP handler.'); + throw new \RuntimeException('GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.'); } return $handler; @@ -133,6 +125,8 @@ final class Utils * Note: the result of this function is cached for subsequent calls. * * @throws \RuntimeException if no bundle can be found. + * + * @deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+. */ public static function defaultCaBundle(): string { @@ -231,20 +225,20 @@ EOT } // Strip port if present. - if (\strpos($host, ':')) { - /** @var string[] $hostParts will never be false because of the checks above */ - $hostParts = \explode($host, ':', 2); - $host = $hostParts[0]; - } + [$host] = \explode(':', $host, 2); foreach ($noProxyArray as $area) { // Always match on wildcards. if ($area === '*') { return true; - } elseif (empty($area)) { + } + + if (empty($area)) { // Don't match on empty values. continue; - } elseif ($area === $host) { + } + + if ($area === $host) { // Exact matches. return true; } @@ -278,9 +272,7 @@ EOT { $data = \json_decode($json, $assoc, $depth, $options); if (\JSON_ERROR_NONE !== \json_last_error()) { - throw new InvalidArgumentException( - 'json_decode error: ' . \json_last_error_msg() - ); + throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg()); } return $data; @@ -301,9 +293,7 @@ EOT { $json = \json_encode($value, $options, $depth); if (\JSON_ERROR_NONE !== \json_last_error()) { - throw new InvalidArgumentException( - 'json_encode error: ' . \json_last_error_msg() - ); + throw new InvalidArgumentException('json_encode error: ' . \json_last_error_msg()); } /** @var string */ @@ -335,7 +325,7 @@ EOT if ($asciiHost === false) { $errorBitSet = $info['errors'] ?? 0; - $errorConstants = array_filter(array_keys(get_defined_constants()), static function ($name) { + $errorConstants = array_filter(array_keys(get_defined_constants()), static function (string $name): bool { return substr($name, 0, 11) === 'IDNA_ERROR_'; }); diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php index 74e3bd26..a70d2cbf 100644 --- a/vendor/guzzlehttp/guzzle/src/functions.php +++ b/vendor/guzzlehttp/guzzle/src/functions.php @@ -10,6 +10,8 @@ namespace GuzzleHttp; * * @return string Returns a string containing the type of the variable and * if a class is provided, the class name. + * + * @deprecated describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead. */ function describe_type($input): string { @@ -21,6 +23,8 @@ function describe_type($input): string * * @param iterable $lines Header lines array of strings in the following * format: "Name: Value" + * + * @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead. */ function headers_from_lines(iterable $lines): array { @@ -33,6 +37,8 @@ function headers_from_lines(iterable $lines): array * @param mixed $value Optional value * * @return resource + * + * @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead. */ function debug_resource($value = null) { @@ -47,6 +53,8 @@ function debug_resource($value = null) * @throws \RuntimeException if no viable Handler is available. * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. + * + * @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead. */ function choose_handler(): callable { @@ -55,6 +63,8 @@ function choose_handler(): callable /** * Get the default User-Agent string to use with Guzzle. + * + * @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead. */ function default_user_agent(): string { @@ -73,6 +83,8 @@ function default_user_agent(): string * Note: the result of this function is cached for subsequent calls. * * @throws \RuntimeException if no bundle can be found. + * + * @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+. */ function default_ca_bundle(): string { @@ -82,6 +94,8 @@ function default_ca_bundle(): string /** * Creates an associative array of lowercase header names to the actual * header casing. + * + * @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead. */ function normalize_header_keys(array $headers): array { @@ -106,6 +120,8 @@ function normalize_header_keys(array $headers): array * @param string[] $noProxyArray An array of host patterns. * * @throws Exception\InvalidArgumentException + * + * @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead. */ function is_host_in_noproxy(string $host, array $noProxyArray): bool { @@ -126,6 +142,7 @@ function is_host_in_noproxy(string $host, array $noProxyArray): bool * @throws Exception\InvalidArgumentException if the JSON cannot be decoded. * * @link https://www.php.net/manual/en/function.json-decode.php + * @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead. */ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0) { @@ -142,6 +159,7 @@ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $o * @throws Exception\InvalidArgumentException if the JSON cannot be encoded. * * @link https://www.php.net/manual/en/function.json-encode.php + * @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead. */ function json_encode($value, int $options = 0, int $depth = 512): string { diff --git a/vendor/guzzlehttp/psr7/.github/FUNDING.yml b/vendor/guzzlehttp/psr7/.github/FUNDING.yml deleted file mode 100644 index 7d222c58..00000000 --- a/vendor/guzzlehttp/psr7/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: [Nyholm, GrahamCampbell] -tidelift: "packagist/guzzlehttp/psr7" diff --git a/vendor/guzzlehttp/psr7/.github/stale.yml b/vendor/guzzlehttp/psr7/.github/stale.yml deleted file mode 100644 index 53faa71b..00000000 --- a/vendor/guzzlehttp/psr7/.github/stale.yml +++ /dev/null @@ -1,14 +0,0 @@ -daysUntilStale: 120 -daysUntilClose: 14 -exemptLabels: - - lifecycle/keep-open - - lifecycle/ready-for-merge -# Label to use when marking an issue as stale -staleLabel: lifecycle/stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/vendor/guzzlehttp/psr7/.github/workflows/ci.yml b/vendor/guzzlehttp/psr7/.github/workflows/ci.yml deleted file mode 100644 index eda7dceb..00000000 --- a/vendor/guzzlehttp/psr7/.github/workflows/ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CI - -on: - pull_request: - -jobs: - build: - name: Build - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - matrix: - php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: 'none' - extensions: mbstring - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Mimic PHP 8.0 - run: composer config platform.php 8.0.999 - if: matrix.php > 8 - - - name: Install dependencies - run: composer update --no-interaction --no-progress - - - name: Run tests - run: make test diff --git a/vendor/guzzlehttp/psr7/.github/workflows/integration.yml b/vendor/guzzlehttp/psr7/.github/workflows/integration.yml deleted file mode 100644 index 3c31f9ef..00000000 --- a/vendor/guzzlehttp/psr7/.github/workflows/integration.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Integration - -on: - pull_request: - -jobs: - - build: - name: Test - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - matrix: - php: ['7.2', '7.3', '7.4', '8.0'] - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Download dependencies - uses: ramsey/composer-install@v1 - with: - composer-options: --no-interaction --optimize-autoloader - - - name: Start server - run: php -S 127.0.0.1:10002 tests/Integration/server.php & - - - name: Run tests - env: - TEST_SERVER: 127.0.0.1:10002 - run: ./vendor/bin/phpunit --testsuite Integration diff --git a/vendor/guzzlehttp/psr7/.github/workflows/static.yml b/vendor/guzzlehttp/psr7/.github/workflows/static.yml deleted file mode 100644 index ab4d68ba..00000000 --- a/vendor/guzzlehttp/psr7/.github/workflows/static.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Static analysis - -on: - pull_request: - -jobs: - php-cs-fixer: - name: PHP-CS-Fixer - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - extensions: mbstring - - - name: Download dependencies - run: composer update --no-interaction --no-progress - - - name: Download PHP CS Fixer - run: composer require "friendsofphp/php-cs-fixer:2.18.4" - - - name: Execute PHP CS Fixer - run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run diff --git a/vendor/guzzlehttp/psr7/.php_cs.dist b/vendor/guzzlehttp/psr7/.php_cs.dist deleted file mode 100644 index e4f0bd53..00000000 --- a/vendor/guzzlehttp/psr7/.php_cs.dist +++ /dev/null @@ -1,56 +0,0 @@ -setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'concat_space' => ['spacing' => 'one'], - 'declare_strict_types' => false, - 'final_static_access' => true, - 'fully_qualified_strict_types' => true, - 'header_comment' => false, - 'is_null' => ['use_yoda_style' => true], - 'list_syntax' => ['syntax' => 'long'], - 'lowercase_cast' => true, - 'magic_method_casing' => true, - 'modernize_types_casting' => true, - 'multiline_comment_opening_closing' => true, - 'no_alias_functions' => true, - 'no_alternative_syntax' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_blank_lines' => true, - 'no_leading_import_slash' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unset_cast' => true, - 'no_unused_imports' => true, - 'no_whitespace_in_blank_line' => true, - 'ordered_imports' => true, - 'php_unit_ordered_covers' => true, - 'php_unit_test_annotation' => ['style' => 'prefix'], - 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], - 'phpdoc_align' => ['align' => 'vertical'], - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_trim' => true, - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'phpdoc_types' => true, - 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], - 'phpdoc_var_without_name' => true, - 'single_trait_insert_per_statement' => true, - 'standardize_not_equals' => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__.'/src') - ->in(__DIR__.'/tests') - ->name('*.php') - ) -; - -return $config; diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md index f40736c4..740b2877 100644 --- a/vendor/guzzlehttp/psr7/CHANGELOG.md +++ b/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -1,26 +1,52 @@ # Change Log - All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased -## 1.8.3 - 2021-10-05 +## 2.1.0 - 2021-10-06 + +### Changed + +- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic + `InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former + for backwards compatibility. Callers relying on the exception being thrown to detect invalid + URIs should catch the new exception. ### Fixed - Return `null` in caching stream size if remote size is `null` -## 1.8.2 - 2021-04-26 +## 2.0.0 - 2021-06-30 + +Identical to the RC release. + +## 2.0.0@RC-1 - 2021-04-29 ### Fixed - Handle possibly unset `url` in `stream_get_meta_data` +## 2.0.0@beta-1 - 2021-03-21 + +### Added + +- PSR-17 factories +- Made classes final +- PHP7 type hints + +### Changed + +- When building a query string, booleans are represented as 1 and 0. + +### Removed + +- PHP < 7.2 support +- All functions in the Guzzle\Psr7 namespace + ## 1.8.1 - 2021-03-21 ### Fixed diff --git a/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md index 464cae4f..ed81c927 100644 --- a/vendor/guzzlehttp/psr7/README.md +++ b/vendor/guzzlehttp/psr7/README.md @@ -4,8 +4,8 @@ This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/) message implementation, several stream decorators, and some helpful functionality like query string parsing. - -[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7) +![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg) +![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg) # Stream implementation @@ -130,10 +130,9 @@ $fnStream->rewind(); `GuzzleHttp\Psr7\InflateStream` -Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. +Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content. -This stream decorator skips the first 10 bytes of the given stream to remove -the gzip header, converts the provided stream to a PHP stream resource, +This stream decorator converts the provided stream to a PHP stream resource, then appends the zlib.inflate filter. The stream is then converted back to a Guzzle stream resource to be used as a Guzzle stream. @@ -555,7 +554,7 @@ Maps a file extensions to a mimetype. ## Upgrading from Function API -The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience: +The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience: | Original Function | Replacement Method | |----------------|----------------| diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json index bfa7cfdc..885aa1da 100644 --- a/vendor/guzzlehttp/psr7/composer.json +++ b/vendor/guzzlehttp/psr7/composer.json @@ -1,7 +1,16 @@ { "name": "guzzlehttp/psr7", "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"], + "keywords": [ + "request", + "response", + "message", + "stream", + "http", + "uri", + "url", + "psr-7" + ], "license": "MIT", "authors": [ { @@ -33,28 +42,35 @@ "name": "Tobias Schultze", "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10", - "ext-zlib": "*" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" }, "provide": { + "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" + }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "autoload": { "psr-4": { "GuzzleHttp\\Psr7\\": "src/" - }, - "files": ["src/functions_include.php"] + } }, "autoload-dev": { "psr-4": { @@ -63,7 +79,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "2.1-dev" } }, "config": { diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php index fa9153d7..967925f3 100644 --- a/vendor/guzzlehttp/psr7/src/AppendStream.php +++ b/vendor/guzzlehttp/psr7/src/AppendStream.php @@ -1,5 +1,7 @@ rewind(); return $this->getContents(); - } catch (\Exception $e) { + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } @@ -48,7 +57,7 @@ class AppendStream implements StreamInterface * * @throws \InvalidArgumentException if the stream is not readable */ - public function addStream(StreamInterface $stream) + public function addStream(StreamInterface $stream): void { if (!$stream->isReadable()) { throw new \InvalidArgumentException('Each stream must be readable'); @@ -62,17 +71,15 @@ class AppendStream implements StreamInterface $this->streams[] = $stream; } - public function getContents() + public function getContents(): string { return Utils::copyToString($this); } /** * Closes each attached stream. - * - * {@inheritdoc} */ - public function close() + public function close(): void { $this->pos = $this->current = 0; $this->seekable = true; @@ -88,8 +95,6 @@ class AppendStream implements StreamInterface * Detaches each attached stream. * * Returns null as it's not clear which underlying stream resource to return. - * - * {@inheritdoc} */ public function detach() { @@ -105,7 +110,7 @@ class AppendStream implements StreamInterface return null; } - public function tell() + public function tell(): int { return $this->pos; } @@ -115,10 +120,8 @@ class AppendStream implements StreamInterface * * If any of the streams do not return a valid number, then the size of the * append stream cannot be determined and null is returned. - * - * {@inheritdoc} */ - public function getSize() + public function getSize(): ?int { $size = 0; @@ -133,24 +136,22 @@ class AppendStream implements StreamInterface return $size; } - public function eof() + public function eof(): bool { return !$this->streams || ($this->current >= count($this->streams) - 1 && $this->streams[$this->current]->eof()); } - public function rewind() + public function rewind(): void { $this->seek(0); } /** * Attempts to seek to the given position. Only supports SEEK_SET. - * - * {@inheritdoc} */ - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { if (!$this->seekable) { throw new \RuntimeException('This AppendStream is not seekable'); @@ -181,10 +182,8 @@ class AppendStream implements StreamInterface /** * Reads from all of the appended streams until the length is met or EOF. - * - * {@inheritdoc} */ - public function read($length) + public function read($length): string { $buffer = ''; $total = count($this->streams) - 1; @@ -204,8 +203,7 @@ class AppendStream implements StreamInterface $result = $this->streams[$this->current]->read($remaining); - // Using a loose comparison here to match on '', false, and null - if ($result == null) { + if ($result === '') { $progressToNext = true; continue; } @@ -219,26 +217,31 @@ class AppendStream implements StreamInterface return $buffer; } - public function isReadable() + public function isReadable(): bool { return true; } - public function isWritable() + public function isWritable(): bool { return false; } - public function isSeekable() + public function isSeekable(): bool { return $this->seekable; } - public function write($string) + public function write($string): int { throw new \RuntimeException('Cannot write to an AppendStream'); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { return $key ? null : []; diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php index 783859c1..21be8c0a 100644 --- a/vendor/guzzlehttp/psr7/src/BufferStream.php +++ b/vendor/guzzlehttp/psr7/src/BufferStream.php @@ -1,5 +1,7 @@ hwm = $hwm; } - public function __toString() + public function __toString(): string { return $this->getContents(); } - public function getContents() + public function getContents(): string { $buffer = $this->buffer; $this->buffer = ''; @@ -44,7 +47,7 @@ class BufferStream implements StreamInterface return $buffer; } - public function close() + public function close(): void { $this->buffer = ''; } @@ -56,42 +59,42 @@ class BufferStream implements StreamInterface return null; } - public function getSize() + public function getSize(): ?int { return strlen($this->buffer); } - public function isReadable() + public function isReadable(): bool { return true; } - public function isWritable() + public function isWritable(): bool { return true; } - public function isSeekable() + public function isSeekable(): bool { return false; } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { throw new \RuntimeException('Cannot seek a BufferStream'); } - public function eof() + public function eof(): bool { return strlen($this->buffer) === 0; } - public function tell() + public function tell(): int { throw new \RuntimeException('Cannot determine the position of a BufferStream'); } @@ -99,7 +102,7 @@ class BufferStream implements StreamInterface /** * Reads data from the buffer. */ - public function read($length) + public function read($length): string { $currentLength = strlen($this->buffer); @@ -119,21 +122,25 @@ class BufferStream implements StreamInterface /** * Writes data to the buffer. */ - public function write($string) + public function write($string): int { $this->buffer .= $string; - // TODO: What should happen here? if (strlen($this->buffer) >= $this->hwm) { - return false; + return 0; } return strlen($string); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { - if ($key == 'hwm') { + if ($key === 'hwm') { return $this->hwm; } diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php index febade9f..7a70ee94 100644 --- a/vendor/guzzlehttp/psr7/src/CachingStream.php +++ b/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -1,5 +1,7 @@ stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+')); } - public function getSize() + public function getSize(): ?int { $remoteSize = $this->remoteStream->getSize(); @@ -45,18 +45,18 @@ class CachingStream implements StreamInterface return max($this->stream->getSize(), $remoteSize); } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { - if ($whence == SEEK_SET) { + if ($whence === SEEK_SET) { $byte = $offset; - } elseif ($whence == SEEK_CUR) { + } elseif ($whence === SEEK_CUR) { $byte = $offset + $this->tell(); - } elseif ($whence == SEEK_END) { + } elseif ($whence === SEEK_END) { $size = $this->remoteStream->getSize(); if ($size === null) { $size = $this->cacheEntireStream(); @@ -81,7 +81,7 @@ class CachingStream implements StreamInterface } } - public function read($length) + public function read($length): string { // Perform a regular read on any previously read data from the buffer $data = $this->stream->read($length); @@ -110,7 +110,7 @@ class CachingStream implements StreamInterface return $data; } - public function write($string) + public function write($string): int { // When appending to the end of the currently read stream, you'll want // to skip bytes from being read from the remote stream to emulate @@ -124,7 +124,7 @@ class CachingStream implements StreamInterface return $this->stream->write($string); } - public function eof() + public function eof(): bool { return $this->stream->eof() && $this->remoteStream->eof(); } @@ -132,12 +132,13 @@ class CachingStream implements StreamInterface /** * Close both the remote stream and buffer stream */ - public function close() + public function close(): void { - $this->remoteStream->close() && $this->stream->close(); + $this->remoteStream->close(); + $this->stream->close(); } - private function cacheEntireStream() + private function cacheEntireStream(): int { $target = new FnStream(['write' => 'strlen']); Utils::copyToStream($this, $target); diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php index 9f7420c4..d78070ae 100644 --- a/vendor/guzzlehttp/psr7/src/DroppingStream.php +++ b/vendor/guzzlehttp/psr7/src/DroppingStream.php @@ -1,5 +1,7 @@ stream = $stream; $this->maxLength = $maxLength; } - public function write($string) + public function write($string): int { $diff = $this->maxLength - $this->stream->getSize(); diff --git a/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php new file mode 100644 index 00000000..3a084779 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php @@ -0,0 +1,14 @@ + */ private $methods; - /** @var array Methods that must be implemented in the given array */ - private static $slots = ['__toString', 'close', 'detach', 'rewind', - 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', - 'isReadable', 'read', 'getContents', 'getMetadata']; - /** - * @param array $methods Hash of method name to a callable. + * @param array $methods Hash of method name to a callable. */ public function __construct(array $methods) { @@ -40,7 +41,7 @@ class FnStream implements StreamInterface * * @throws \BadMethodCallException */ - public function __get($name) + public function __get(string $name): void { throw new \BadMethodCallException(str_replace('_fn_', '', $name) . '() is not implemented in the FnStream'); @@ -61,7 +62,7 @@ class FnStream implements StreamInterface * * @throws \LogicException */ - public function __wakeup() + public function __wakeup(): void { throw new \LogicException('FnStream should never be unserialized'); } @@ -70,8 +71,8 @@ class FnStream implements StreamInterface * Adds custom functionality to an underlying stream by intercepting * specific method calls. * - * @param StreamInterface $stream Stream to decorate - * @param array $methods Hash of method name to a closure + * @param StreamInterface $stream Stream to decorate + * @param array $methods Hash of method name to a closure * * @return FnStream */ @@ -79,21 +80,31 @@ class FnStream implements StreamInterface { // If any of the required methods were not provided, then simply // proxy to the decorated stream. - foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { - $methods[$diff] = [$stream, $diff]; + foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) { + /** @var callable $callable */ + $callable = [$stream, $diff]; + $methods[$diff] = $callable; } return new self($methods); } - public function __toString() + public function __toString(): string { - return call_user_func($this->_fn___toString); + try { + return call_user_func($this->_fn___toString); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + return ''; + } } - public function close() + public function close(): void { - return call_user_func($this->_fn_close); + call_user_func($this->_fn_close); } public function detach() @@ -101,61 +112,66 @@ class FnStream implements StreamInterface return call_user_func($this->_fn_detach); } - public function getSize() + public function getSize(): ?int { return call_user_func($this->_fn_getSize); } - public function tell() + public function tell(): int { return call_user_func($this->_fn_tell); } - public function eof() + public function eof(): bool { return call_user_func($this->_fn_eof); } - public function isSeekable() + public function isSeekable(): bool { return call_user_func($this->_fn_isSeekable); } - public function rewind() + public function rewind(): void { call_user_func($this->_fn_rewind); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { call_user_func($this->_fn_seek, $offset, $whence); } - public function isWritable() + public function isWritable(): bool { return call_user_func($this->_fn_isWritable); } - public function write($string) + public function write($string): int { return call_user_func($this->_fn_write, $string); } - public function isReadable() + public function isReadable(): bool { return call_user_func($this->_fn_isReadable); } - public function read($length) + public function read($length): string { return call_user_func($this->_fn_read, $length); } - public function getContents() + public function getContents(): string { return call_user_func($this->_fn_getContents); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { return call_user_func($this->_fn_getMetadata, $key); diff --git a/vendor/guzzlehttp/psr7/src/Header.php b/vendor/guzzlehttp/psr7/src/Header.php index 865d7421..0e79a71a 100644 --- a/vendor/guzzlehttp/psr7/src/Header.php +++ b/vendor/guzzlehttp/psr7/src/Header.php @@ -1,5 +1,7 @@ getSize(); + } + + return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType); + } + + public function createStream(string $content = ''): StreamInterface + { + return Utils::streamFor($content); + } + + public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface + { + try { + $resource = Utils::tryFopen($file, $mode); + } catch (\RuntimeException $e) { + if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) { + throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e); + } + + throw $e; + } + + return Utils::streamFor($resource); + } + + public function createStreamFromResource($resource): StreamInterface + { + return Utils::streamFor($resource); + } + + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface + { + if (empty($method)) { + if (!empty($serverParams['REQUEST_METHOD'])) { + $method = $serverParams['REQUEST_METHOD']; + } else { + throw new \InvalidArgumentException('Cannot determine HTTP method'); + } + } + + return new ServerRequest($method, $uri, [], null, '1.1', $serverParams); + } + + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { + return new Response($code, [], null, '1.1', $reasonPhrase); + } + + public function createRequest(string $method, $uri): RequestInterface + { + return new Request($method, $uri); + } + + public function createUri(string $uri = ''): UriInterface + { + return new Uri($uri); + } +} diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php index 0cbd2cce..8e3cf171 100644 --- a/vendor/guzzlehttp/psr7/src/InflateStream.php +++ b/vendor/guzzlehttp/psr7/src/InflateStream.php @@ -1,56 +1,34 @@ read(10); - $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header); - // Skip the header, that is 10 + length of filename + 1 (nil) bytes - $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength); $resource = StreamWrapper::getResource($stream); - stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); + // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data + // See http://www.zlib.net/manual.html#Advanced definition of inflateInit2 + // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection" + // Default window size is 15. + stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]); $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); } - - /** - * @param StreamInterface $stream - * @param $header - * - * @return int - */ - private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) - { - $filename_header_length = 0; - - if (substr(bin2hex($header), 6, 2) === '08') { - // we have a filename, read until nil - $filename_header_length = 1; - while ($stream->read(1) !== chr(0)) { - $filename_header_length++; - } - } - - return $filename_header_length; - } } diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php index 911e127d..6b604296 100644 --- a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +++ b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php @@ -1,5 +1,7 @@ filename = $filename; $this->mode = $mode; @@ -32,10 +32,8 @@ class LazyOpenStream implements StreamInterface /** * Creates the underlying stream lazily when required. - * - * @return StreamInterface */ - protected function createStream() + protected function createStream(): StreamInterface { return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode)); } diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php index 1173ec40..9762d38a 100644 --- a/vendor/guzzlehttp/psr7/src/LimitStream.php +++ b/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -1,15 +1,15 @@ stream = $stream; $this->setLimit($limit); $this->setOffset($offset); } - public function eof() + public function eof(): bool { // Always return true if the underlying stream is EOF if ($this->stream->eof()) { @@ -44,7 +44,7 @@ class LimitStream implements StreamInterface } // No limit and the underlying stream is not at EOF - if ($this->limit == -1) { + if ($this->limit === -1) { return false; } @@ -53,13 +53,12 @@ class LimitStream implements StreamInterface /** * Returns the size of the limited subset of data - * {@inheritdoc} */ - public function getSize() + public function getSize(): ?int { if (null === ($length = $this->stream->getSize())) { return null; - } elseif ($this->limit == -1) { + } elseif ($this->limit === -1) { return $length - $this->offset; } else { return min($this->limit, $length - $this->offset); @@ -68,9 +67,8 @@ class LimitStream implements StreamInterface /** * Allow for a bounded seek on the read limited stream - * {@inheritdoc} */ - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { if ($whence !== SEEK_SET || $offset < 0) { throw new \RuntimeException(sprintf( @@ -93,9 +91,8 @@ class LimitStream implements StreamInterface /** * Give a relative tell() - * {@inheritdoc} */ - public function tell() + public function tell(): int { return $this->stream->tell() - $this->offset; } @@ -107,7 +104,7 @@ class LimitStream implements StreamInterface * * @throws \RuntimeException if the stream cannot be seeked. */ - public function setOffset($offset) + public function setOffset(int $offset): void { $current = $this->stream->tell(); @@ -132,14 +129,14 @@ class LimitStream implements StreamInterface * @param int $limit Number of bytes to allow to be read from the stream. * Use -1 for no limit. */ - public function setLimit($limit) + public function setLimit(int $limit): void { $this->limit = $limit; } - public function read($length) + public function read($length): string { - if ($this->limit == -1) { + if ($this->limit === -1) { return $this->stream->read($length); } diff --git a/vendor/guzzlehttp/psr7/src/Message.php b/vendor/guzzlehttp/psr7/src/Message.php index 516d1cb8..9b825b30 100644 --- a/vendor/guzzlehttp/psr7/src/Message.php +++ b/vendor/guzzlehttp/psr7/src/Message.php @@ -1,5 +1,7 @@ getMethod() . ' ' @@ -52,10 +52,8 @@ final class Message * * @param MessageInterface $message The message to get the body summary * @param int $truncateAt The maximum allowed size of the summary - * - * @return string|null */ - public static function bodySummary(MessageInterface $message, $truncateAt = 120) + public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string { $body = $message->getBody(); @@ -95,7 +93,7 @@ final class Message * * @throws \RuntimeException */ - public static function rewindBody(MessageInterface $message) + public static function rewindBody(MessageInterface $message): void { $body = $message->getBody(); @@ -112,10 +110,8 @@ final class Message * array values, and a "body" key containing the body of the message. * * @param string $message HTTP request or response to parse. - * - * @return array */ - public static function parseMessage($message) + public static function parseMessage(string $message): array { if (!$message) { throw new \InvalidArgumentException('Invalid message'); @@ -129,7 +125,7 @@ final class Message throw new \InvalidArgumentException('Invalid message: Missing header delimiter'); } - list($rawHeaders, $body) = $messageParts; + [$rawHeaders, $body] = $messageParts; $rawHeaders .= "\r\n"; // Put back the delimiter we split previously $headerParts = preg_split("/\r?\n/", $rawHeaders, 2); @@ -137,7 +133,7 @@ final class Message throw new \InvalidArgumentException('Invalid message: Missing status line'); } - list($startLine, $rawHeaders) = $headerParts; + [$startLine, $rawHeaders] = $headerParts; if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') { // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0 @@ -175,10 +171,8 @@ final class Message * * @param string $path Path from the start-line * @param array $headers Array of headers (each value an array). - * - * @return string */ - public static function parseRequestUri($path, array $headers) + public static function parseRequestUri(string $path, array $headers): string { $hostKey = array_filter(array_keys($headers), function ($k) { return strtolower($k) === 'host'; @@ -199,10 +193,8 @@ final class Message * Parses a request message string into a request object. * * @param string $message Request message string. - * - * @return Request */ - public static function parseRequest($message) + public static function parseRequest(string $message): RequestInterface { $data = self::parseMessage($message); $matches = []; @@ -227,10 +219,8 @@ final class Message * Parses a response message string into a response object. * * @param string $message Response message string. - * - * @return Response */ - public static function parseResponse($message) + public static function parseResponse(string $message): ResponseInterface { $data = self::parseMessage($message); // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space @@ -246,7 +236,7 @@ final class Message $data['headers'], $data['body'], explode('/', $parts[0])[1], - isset($parts[2]) ? $parts[2] : null + $parts[2] ?? null ); } } diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php index 99203bb4..503c280b 100644 --- a/vendor/guzzlehttp/psr7/src/MessageTrait.php +++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -1,7 +1,10 @@ array of values */ + /** @var array Map of all registered headers, as original name => array of values */ private $headers = []; - /** @var array Map of lowercase header name => original name at registration */ + /** @var array Map of lowercase header name => original name at registration */ private $headerNames = []; /** @var string */ @@ -21,12 +24,12 @@ trait MessageTrait /** @var StreamInterface|null */ private $stream; - public function getProtocolVersion() + public function getProtocolVersion(): string { return $this->protocol; } - public function withProtocolVersion($version) + public function withProtocolVersion($version): MessageInterface { if ($this->protocol === $version) { return $this; @@ -37,17 +40,17 @@ trait MessageTrait return $new; } - public function getHeaders() + public function getHeaders(): array { return $this->headers; } - public function hasHeader($header) + public function hasHeader($header): bool { return isset($this->headerNames[strtolower($header)]); } - public function getHeader($header) + public function getHeader($header): array { $header = strtolower($header); @@ -60,12 +63,12 @@ trait MessageTrait return $this->headers[$header]; } - public function getHeaderLine($header) + public function getHeaderLine($header): string { return implode(', ', $this->getHeader($header)); } - public function withHeader($header, $value) + public function withHeader($header, $value): MessageInterface { $this->assertHeader($header); $value = $this->normalizeHeaderValue($value); @@ -81,7 +84,7 @@ trait MessageTrait return $new; } - public function withAddedHeader($header, $value) + public function withAddedHeader($header, $value): MessageInterface { $this->assertHeader($header); $value = $this->normalizeHeaderValue($value); @@ -99,7 +102,7 @@ trait MessageTrait return $new; } - public function withoutHeader($header) + public function withoutHeader($header): MessageInterface { $normalized = strtolower($header); @@ -115,7 +118,7 @@ trait MessageTrait return $new; } - public function getBody() + public function getBody(): StreamInterface { if (!$this->stream) { $this->stream = Utils::streamFor(''); @@ -124,7 +127,7 @@ trait MessageTrait return $this->stream; } - public function withBody(StreamInterface $body) + public function withBody(StreamInterface $body): MessageInterface { if ($body === $this->stream) { return $this; @@ -135,7 +138,10 @@ trait MessageTrait return $new; } - private function setHeaders(array $headers) + /** + * @param array $headers + */ + private function setHeaders(array $headers): void { $this->headerNames = $this->headers = []; foreach ($headers as $header => $value) { @@ -157,7 +163,12 @@ trait MessageTrait } } - private function normalizeHeaderValue($value) + /** + * @param mixed $value + * + * @return string[] + */ + private function normalizeHeaderValue($value): array { if (!is_array($value)) { return $this->trimHeaderValues([$value]); @@ -178,13 +189,13 @@ trait MessageTrait * header-field = field-name ":" OWS field-value OWS * OWS = *( SP / HTAB ) * - * @param string[] $values Header values + * @param mixed[] $values Header values * * @return string[] Trimmed header values * * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 */ - private function trimHeaderValues(array $values) + private function trimHeaderValues(array $values): array { return array_map(function ($value) { if (!is_scalar($value) && null !== $value) { @@ -198,7 +209,12 @@ trait MessageTrait }, array_values($values)); } - private function assertHeader($header) + /** + * @see https://tools.ietf.org/html/rfc7230#section-3.2 + * + * @param mixed $header + */ + private function assertHeader($header): void { if (!is_string($header)) { throw new \InvalidArgumentException(sprintf( @@ -207,8 +223,13 @@ trait MessageTrait )); } - if ($header === '') { - throw new \InvalidArgumentException('Header name can not be empty.'); + if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $header)) { + throw new \InvalidArgumentException( + sprintf( + '"%s" is not valid header name', + $header + ) + ); } } } diff --git a/vendor/guzzlehttp/psr7/src/MimeType.php b/vendor/guzzlehttp/psr7/src/MimeType.php index 205c7b1f..dfa94251 100644 --- a/vendor/guzzlehttp/psr7/src/MimeType.php +++ b/vendor/guzzlehttp/psr7/src/MimeType.php @@ -1,17 +1,119 @@ 'video/3gpp', + '7z' => 'application/x-7z-compressed', + 'aac' => 'audio/x-aac', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'asc' => 'text/plain', + 'asf' => 'video/x-ms-asf', + 'atom' => 'application/atom+xml', + 'avi' => 'video/x-msvideo', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bzip2', + 'cer' => 'application/pkix-cert', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'css' => 'text/css', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'deb' => 'application/x-debian-package', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dvi' => 'application/x-dvi', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'etx' => 'text/x-setext', + 'flac' => 'audio/flac', + 'flv' => 'video/x-flv', + 'gif' => 'image/gif', + 'gz' => 'application/gzip', + 'htm' => 'text/html', + 'html' => 'text/html', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ini' => 'text/plain', + 'iso' => 'application/x-iso9660-image', + 'jar' => 'application/java-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'js' => 'text/javascript', + 'json' => 'application/json', + 'latex' => 'application/x-latex', + 'log' => 'text/plain', + 'm4a' => 'audio/mp4', + 'm4v' => 'video/mp4', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mkv' => 'video/x-matroska', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4v' => 'video/mp4', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'pbm' => 'image/x-portable-bitmap', + 'pdf' => 'application/pdf', + 'pgm' => 'image/x-portable-graymap', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'ppm' => 'image/x-portable-pixmap', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'qt' => 'video/quicktime', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'svg' => 'image/svg+xml', + 'swf' => 'application/x-shockwave-flash', + 'tar' => 'application/x-tar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'torrent' => 'application/x-bittorrent', + 'ttf' => 'application/x-font-ttf', + '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', + 'wsdl' => 'application/wsdl+xml', + 'xbm' => 'image/x-xbitmap', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + 'xpm' => 'image/x-xpixmap', + 'xwd' => 'image/x-xwindowdump', + 'yaml' => 'text/yaml', + 'yml' => 'text/yaml', + 'zip' => 'application/zip', + ]; + /** * Determines the mimetype of a file by looking at its extension. - * - * @param string $filename - * - * @return string|null */ - public static function fromFilename($filename) + public static function fromFilename(string $filename): ?string { return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION)); } @@ -19,122 +121,10 @@ final class MimeType /** * Maps a file extensions to a mimetype. * - * @param string $extension string The file extension. - * - * @return string|null - * * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types */ - public static function fromExtension($extension) + public static function fromExtension(string $extension): ?string { - static $mimetypes = [ - '3gp' => 'video/3gpp', - '7z' => 'application/x-7z-compressed', - 'aac' => 'audio/x-aac', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'asc' => 'text/plain', - 'asf' => 'video/x-ms-asf', - 'atom' => 'application/atom+xml', - 'avi' => 'video/x-msvideo', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bzip2', - 'cer' => 'application/pkix-cert', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'css' => 'text/css', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'deb' => 'application/x-debian-package', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dvi' => 'application/x-dvi', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'etx' => 'text/x-setext', - 'flac' => 'audio/flac', - 'flv' => 'video/x-flv', - 'gif' => 'image/gif', - 'gz' => 'application/gzip', - 'htm' => 'text/html', - 'html' => 'text/html', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ini' => 'text/plain', - 'iso' => 'application/x-iso9660-image', - 'jar' => 'application/java-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'js' => 'text/javascript', - 'json' => 'application/json', - 'latex' => 'application/x-latex', - 'log' => 'text/plain', - 'm4a' => 'audio/mp4', - 'm4v' => 'video/mp4', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mkv' => 'video/x-matroska', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4v' => 'video/mp4', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'pbm' => 'image/x-portable-bitmap', - 'pdf' => 'application/pdf', - 'pgm' => 'image/x-portable-graymap', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'ppm' => 'image/x-portable-pixmap', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'qt' => 'video/quicktime', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'svg' => 'image/svg+xml', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'torrent' => 'application/x-bittorrent', - 'ttf' => 'application/x-font-ttf', - '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', - 'wsdl' => 'application/wsdl+xml', - 'xbm' => 'image/x-xbitmap', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - 'xpm' => 'image/x-xpixmap', - 'xwd' => 'image/x-xwindowdump', - 'yaml' => 'text/yaml', - 'yml' => 'text/yaml', - 'zip' => 'application/zip', - ]; - - $extension = strtolower($extension); - - return isset($mimetypes[$extension]) - ? $mimetypes[$extension] - : null; + return self::MIME_TYPES[strtolower($extension)] ?? null; } } diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php index 5a6079a8..f76d7c61 100644 --- a/vendor/guzzlehttp/psr7/src/MultipartStream.php +++ b/vendor/guzzlehttp/psr7/src/MultipartStream.php @@ -1,5 +1,7 @@ boundary = $boundary ?: sha1(uniqid('', true)); $this->stream = $this->createStream($elements); } - /** - * Get the boundary - * - * @return string - */ - public function getBoundary() + public function getBoundary(): string { return $this->boundary; } - public function isWritable() + public function isWritable(): bool { return false; } /** * Get the headers needed before transferring the content of a POST file + * + * @param array $headers */ - private function getHeaders(array $headers) + private function getHeaders(array $headers): string { $str = ''; foreach ($headers as $key => $value) { @@ -65,7 +63,7 @@ class MultipartStream implements StreamInterface /** * Create the aggregate stream that will be used to upload the POST data */ - protected function createStream(array $elements) + protected function createStream(array $elements = []): StreamInterface { $stream = new AppendStream(); @@ -79,7 +77,7 @@ class MultipartStream implements StreamInterface return $stream; } - private function addElement(AppendStream $stream, array $element) + private function addElement(AppendStream $stream, array $element): void { foreach (['contents', 'name'] as $key) { if (!array_key_exists($key, $element)) { @@ -96,11 +94,11 @@ class MultipartStream implements StreamInterface } } - list($body, $headers) = $this->createElement( + [$body, $headers] = $this->createElement( $element['name'], $element['contents'], - isset($element['filename']) ? $element['filename'] : null, - isset($element['headers']) ? $element['headers'] : [] + $element['filename'] ?? null, + $element['headers'] ?? [] ); $stream->addStream(Utils::streamFor($this->getHeaders($headers))); @@ -108,10 +106,7 @@ class MultipartStream implements StreamInterface $stream->addStream(Utils::streamFor("\r\n")); } - /** - * @return array - */ - private function createElement($name, StreamInterface $stream, $filename, array $headers) + private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array { // Set a default content-disposition header if one was no provided $disposition = $this->getHeader($headers, 'content-disposition'); @@ -144,7 +139,7 @@ class MultipartStream implements StreamInterface return [$stream, $headers]; } - private function getHeader(array $headers, $key) + private function getHeader(array $headers, string $key) { $lowercaseHeader = strtolower($key); foreach ($headers as $k => $v) { diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php index d66bdde4..99e25b9e 100644 --- a/vendor/guzzlehttp/psr7/src/NoSeekStream.php +++ b/vendor/guzzlehttp/psr7/src/NoSeekStream.php @@ -1,24 +1,24 @@ source = $source; - $this->size = isset($options['size']) ? $options['size'] : null; - $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; + $this->size = $options['size'] ?? null; + $this->metadata = $options['metadata'] ?? []; $this->buffer = new BufferStream(); } - public function __toString() + public function __toString(): string { try { return Utils::copyToString($this); - } catch (\Exception $e) { + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } - public function close() + public function close(): void { $this->detach(); } public function detach() { - $this->tellPos = false; + $this->tellPos = 0; $this->source = null; return null; } - public function getSize() + public function getSize(): ?int { return $this->size; } - public function tell() + public function tell(): int { return $this->tellPos; } - public function eof() + public function eof(): bool { - return !$this->source; + return $this->source === null; } - public function isSeekable() + public function isSeekable(): bool { return false; } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { throw new \RuntimeException('Cannot seek a PumpStream'); } - public function isWritable() + public function isWritable(): bool { return false; } - public function write($string) + public function write($string): int { throw new \RuntimeException('Cannot write to a PumpStream'); } - public function isReadable() + public function isReadable(): bool { return true; } - public function read($length) + public function read($length): string { $data = $this->buffer->read($length); $readLen = strlen($data); @@ -134,7 +138,7 @@ class PumpStream implements StreamInterface return $data; } - public function getContents() + public function getContents(): string { $result = ''; while (!$this->eof()) { @@ -144,16 +148,21 @@ class PumpStream implements StreamInterface return $result; } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { if (!$key) { return $this->metadata; } - return isset($this->metadata[$key]) ? $this->metadata[$key] : null; + return $this->metadata[$key] ?? null; } - private function pump($length) + private function pump(int $length): void { if ($this->source) { do { diff --git a/vendor/guzzlehttp/psr7/src/Query.php b/vendor/guzzlehttp/psr7/src/Query.php index 5a7cc035..4fd0ca96 100644 --- a/vendor/guzzlehttp/psr7/src/Query.php +++ b/vendor/guzzlehttp/psr7/src/Query.php @@ -1,5 +1,7 @@ $v) { - $k = $encoder($k); + $k = $encoder((string) $k); if (!is_array($v)) { $qs .= $k; + $v = is_bool($v) ? (int) $v : $v; if ($v !== null) { - $qs .= '=' . $encoder($v); + $qs .= '=' . $encoder((string) $v); } $qs .= '&'; } else { foreach ($v as $vv) { $qs .= $k; + $vv = is_bool($vv) ? (int) $vv : $vv; if ($vv !== null) { - $qs .= '=' . $encoder($vv); + $qs .= '=' . $encoder((string) $vv); } $qs .= '&'; } diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php index c1cdaebf..b17af66a 100644 --- a/vendor/guzzlehttp/psr7/src/Request.php +++ b/vendor/guzzlehttp/psr7/src/Request.php @@ -1,5 +1,7 @@ $headers Request headers * @param string|resource|StreamInterface|null $body Request body * @param string $version Protocol version */ public function __construct( - $method, + string $method, $uri, array $headers = [], $body = null, - $version = '1.1' + string $version = '1.1' ) { $this->assertMethod($method); if (!($uri instanceof UriInterface)) { @@ -56,14 +58,14 @@ class Request implements RequestInterface } } - public function getRequestTarget() + public function getRequestTarget(): string { if ($this->requestTarget !== null) { return $this->requestTarget; } $target = $this->uri->getPath(); - if ($target == '') { + if ($target === '') { $target = '/'; } if ($this->uri->getQuery() != '') { @@ -73,7 +75,7 @@ class Request implements RequestInterface return $target; } - public function withRequestTarget($requestTarget) + public function withRequestTarget($requestTarget): RequestInterface { if (preg_match('#\s#', $requestTarget)) { throw new InvalidArgumentException( @@ -86,12 +88,12 @@ class Request implements RequestInterface return $new; } - public function getMethod() + public function getMethod(): string { return $this->method; } - public function withMethod($method) + public function withMethod($method): RequestInterface { $this->assertMethod($method); $new = clone $this; @@ -99,12 +101,12 @@ class Request implements RequestInterface return $new; } - public function getUri() + public function getUri(): UriInterface { return $this->uri; } - public function withUri(UriInterface $uri, $preserveHost = false) + public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface { if ($uri === $this->uri) { return $this; @@ -120,7 +122,7 @@ class Request implements RequestInterface return $new; } - private function updateHostFromUri() + private function updateHostFromUri(): void { $host = $this->uri->getHost(); @@ -143,10 +145,13 @@ class Request implements RequestInterface $this->headers = [$header => [$host]] + $this->headers; } - private function assertMethod($method) + /** + * @param mixed $method + */ + private function assertMethod($method): void { if (!is_string($method) || $method === '') { - throw new \InvalidArgumentException('Method must be a non-empty string.'); + throw new InvalidArgumentException('Method must be a non-empty string.'); } } } diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php index 8c01a0f5..4c6ee6f0 100644 --- a/vendor/guzzlehttp/psr7/src/Response.php +++ b/vendor/guzzlehttp/psr7/src/Response.php @@ -1,5 +1,7 @@ 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', @@ -34,6 +36,7 @@ class Response implements ResponseInterface 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', + 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', @@ -71,31 +74,30 @@ class Response implements ResponseInterface 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', + 510 => 'Not Extended', 511 => 'Network Authentication Required', ]; /** @var string */ - private $reasonPhrase = ''; + private $reasonPhrase; /** @var int */ - private $statusCode = 200; + private $statusCode; /** * @param int $status Status code - * @param array $headers Response headers + * @param array $headers Response headers * @param string|resource|StreamInterface|null $body Response body * @param string $version Protocol version * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) */ public function __construct( - $status = 200, + int $status = 200, array $headers = [], $body = null, - $version = '1.1', - $reason = null + string $version = '1.1', + string $reason = null ) { - $this->assertStatusCodeIsInteger($status); - $status = (int) $status; $this->assertStatusCodeRange($status); $this->statusCode = $status; @@ -105,8 +107,8 @@ class Response implements ResponseInterface } $this->setHeaders($headers); - if ($reason == '' && isset(self::$phrases[$this->statusCode])) { - $this->reasonPhrase = self::$phrases[$this->statusCode]; + if ($reason == '' && isset(self::PHRASES[$this->statusCode])) { + $this->reasonPhrase = self::PHRASES[$this->statusCode]; } else { $this->reasonPhrase = (string) $reason; } @@ -114,17 +116,17 @@ class Response implements ResponseInterface $this->protocol = $version; } - public function getStatusCode() + public function getStatusCode(): int { return $this->statusCode; } - public function getReasonPhrase() + public function getReasonPhrase(): string { return $this->reasonPhrase; } - public function withStatus($code, $reasonPhrase = '') + public function withStatus($code, $reasonPhrase = ''): ResponseInterface { $this->assertStatusCodeIsInteger($code); $code = (int) $code; @@ -132,21 +134,24 @@ class Response implements ResponseInterface $new = clone $this; $new->statusCode = $code; - if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { - $reasonPhrase = self::$phrases[$new->statusCode]; + if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) { + $reasonPhrase = self::PHRASES[$new->statusCode]; } $new->reasonPhrase = (string) $reasonPhrase; return $new; } - private function assertStatusCodeIsInteger($statusCode) + /** + * @param mixed $statusCode + */ + private function assertStatusCodeIsInteger($statusCode): void { if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) { throw new \InvalidArgumentException('Status code must be an integer value.'); } } - private function assertStatusCodeRange($statusCode) + private function assertStatusCodeRange(int $statusCode): void { if ($statusCode < 100 || $statusCode >= 600) { throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.'); diff --git a/vendor/guzzlehttp/psr7/src/Rfc7230.php b/vendor/guzzlehttp/psr7/src/Rfc7230.php index 51b571f2..30224018 100644 --- a/vendor/guzzlehttp/psr7/src/Rfc7230.php +++ b/vendor/guzzlehttp/psr7/src/Rfc7230.php @@ -1,12 +1,16 @@ @,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m"; - const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)"; + public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m"; + public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)"; } diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php index e6d26f5f..6ae3f9be 100644 --- a/vendor/guzzlehttp/psr7/src/ServerRequest.php +++ b/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -1,5 +1,7 @@ $headers Request headers * @param string|resource|StreamInterface|null $body Request body * @param string $version Protocol version * @param array $serverParams Typically the $_SERVER superglobal */ public function __construct( - $method, + string $method, $uri, array $headers = [], $body = null, - $version = '1.1', + string $version = '1.1', array $serverParams = [] ) { $this->serverParams = $serverParams; @@ -80,11 +82,9 @@ class ServerRequest extends Request implements ServerRequestInterface * * @param array $files A array which respect $_FILES structure * - * @return array - * * @throws InvalidArgumentException for unrecognized values */ - public static function normalizeFiles(array $files) + public static function normalizeFiles(array $files): array { $normalized = []; @@ -112,7 +112,7 @@ class ServerRequest extends Request implements ServerRequestInterface * * @param array $value $_FILES struct * - * @return array|UploadedFileInterface + * @return UploadedFileInterface|UploadedFileInterface[] */ private static function createUploadedFileFromSpec(array $value) { @@ -135,11 +135,9 @@ class ServerRequest extends Request implements ServerRequestInterface * Loops through all nested files and returns a normalized array of * UploadedFileInterface instances. * - * @param array $files - * * @return UploadedFileInterface[] */ - private static function normalizeNestedFileSpec(array $files = []) + private static function normalizeNestedFileSpec(array $files = []): array { $normalizedFiles = []; @@ -164,12 +162,10 @@ class ServerRequest extends Request implements ServerRequestInterface * $_COOKIE * $_FILES * $_SERVER - * - * @return ServerRequestInterface */ - public static function fromGlobals() + public static function fromGlobals(): ServerRequestInterface { - $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; + $method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $headers = getallheaders(); $uri = self::getUriFromGlobals(); $body = new CachingStream(new LazyOpenStream('php://input', 'r+')); @@ -184,7 +180,7 @@ class ServerRequest extends Request implements ServerRequestInterface ->withUploadedFiles(self::normalizeFiles($_FILES)); } - private static function extractHostAndPortFromAuthority($authority) + private static function extractHostAndPortFromAuthority(string $authority): array { $uri = 'http://' . $authority; $parts = parse_url($uri); @@ -192,18 +188,16 @@ class ServerRequest extends Request implements ServerRequestInterface return [null, null]; } - $host = isset($parts['host']) ? $parts['host'] : null; - $port = isset($parts['port']) ? $parts['port'] : null; + $host = $parts['host'] ?? null; + $port = $parts['port'] ?? null; return [$host, $port]; } /** * Get a Uri populated with values from $_SERVER. - * - * @return UriInterface */ - public static function getUriFromGlobals() + public static function getUriFromGlobals(): UriInterface { $uri = new Uri(''); @@ -211,7 +205,7 @@ class ServerRequest extends Request implements ServerRequestInterface $hasPort = false; if (isset($_SERVER['HTTP_HOST'])) { - list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']); + [$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']); if ($host !== null) { $uri = $uri->withHost($host); } @@ -247,26 +241,17 @@ class ServerRequest extends Request implements ServerRequestInterface return $uri; } - /** - * {@inheritdoc} - */ - public function getServerParams() + public function getServerParams(): array { return $this->serverParams; } - /** - * {@inheritdoc} - */ - public function getUploadedFiles() + public function getUploadedFiles(): array { return $this->uploadedFiles; } - /** - * {@inheritdoc} - */ - public function withUploadedFiles(array $uploadedFiles) + public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface { $new = clone $this; $new->uploadedFiles = $uploadedFiles; @@ -274,18 +259,12 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function getCookieParams() + public function getCookieParams(): array { return $this->cookieParams; } - /** - * {@inheritdoc} - */ - public function withCookieParams(array $cookies) + public function withCookieParams(array $cookies): ServerRequestInterface { $new = clone $this; $new->cookieParams = $cookies; @@ -293,18 +272,12 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function getQueryParams() + public function getQueryParams(): array { return $this->queryParams; } - /** - * {@inheritdoc} - */ - public function withQueryParams(array $query) + public function withQueryParams(array $query): ServerRequestInterface { $new = clone $this; $new->queryParams = $query; @@ -314,16 +287,15 @@ class ServerRequest extends Request implements ServerRequestInterface /** * {@inheritdoc} + * + * @return array|object|null */ public function getParsedBody() { return $this->parsedBody; } - /** - * {@inheritdoc} - */ - public function withParsedBody($data) + public function withParsedBody($data): ServerRequestInterface { $new = clone $this; $new->parsedBody = $data; @@ -331,16 +303,15 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function getAttributes() + public function getAttributes(): array { return $this->attributes; } /** * {@inheritdoc} + * + * @return mixed */ public function getAttribute($attribute, $default = null) { @@ -351,10 +322,7 @@ class ServerRequest extends Request implements ServerRequestInterface return $this->attributes[$attribute]; } - /** - * {@inheritdoc} - */ - public function withAttribute($attribute, $value) + public function withAttribute($attribute, $value): ServerRequestInterface { $new = clone $this; $new->attributes[$attribute] = $value; @@ -362,10 +330,7 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function withoutAttribute($attribute) + public function withoutAttribute($attribute): ServerRequestInterface { if (false === array_key_exists($attribute, $this->attributes)) { return $this; diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php index 3865d6d6..d389427c 100644 --- a/vendor/guzzlehttp/psr7/src/Stream.php +++ b/vendor/guzzlehttp/psr7/src/Stream.php @@ -1,33 +1,36 @@ size = $options['size']; } - $this->customMetadata = isset($options['metadata']) - ? $options['metadata'] - : []; - + $this->customMetadata = $options['metadata'] ?? []; $this->stream = $stream; $meta = stream_get_meta_data($this->stream); $this->seekable = $meta['seekable']; @@ -74,19 +74,23 @@ class Stream implements StreamInterface $this->close(); } - public function __toString() + public function __toString(): string { try { if ($this->isSeekable()) { $this->seek(0); } return $this->getContents(); - } catch (\Exception $e) { + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } - public function getContents() + public function getContents(): string { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -101,7 +105,7 @@ class Stream implements StreamInterface return $contents; } - public function close() + public function close(): void { if (isset($this->stream)) { if (is_resource($this->stream)) { @@ -125,7 +129,7 @@ class Stream implements StreamInterface return $result; } - public function getSize() + public function getSize(): ?int { if ($this->size !== null) { return $this->size; @@ -141,7 +145,7 @@ class Stream implements StreamInterface } $stats = fstat($this->stream); - if (isset($stats['size'])) { + if (is_array($stats) && isset($stats['size'])) { $this->size = $stats['size']; return $this->size; } @@ -149,22 +153,22 @@ class Stream implements StreamInterface return null; } - public function isReadable() + public function isReadable(): bool { return $this->readable; } - public function isWritable() + public function isWritable(): bool { return $this->writable; } - public function isSeekable() + public function isSeekable(): bool { return $this->seekable; } - public function eof() + public function eof(): bool { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -173,7 +177,7 @@ class Stream implements StreamInterface return feof($this->stream); } - public function tell() + public function tell(): int { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -188,12 +192,12 @@ class Stream implements StreamInterface return $result; } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { $whence = (int) $whence; @@ -209,7 +213,7 @@ class Stream implements StreamInterface } } - public function read($length) + public function read($length): string { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -233,7 +237,7 @@ class Stream implements StreamInterface return $string; } - public function write($string) + public function write($string): int { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -253,6 +257,11 @@ class Stream implements StreamInterface return $result; } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { if (!isset($this->stream)) { @@ -265,6 +274,6 @@ class Stream implements StreamInterface $meta = stream_get_meta_data($this->stream); - return isset($meta[$key]) ? $meta[$key] : null; + return $meta[$key] ?? null; } } diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php index 5025dd67..56d4104d 100644 --- a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +++ b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php @@ -1,5 +1,7 @@ stream = $this->createStream(); return $this->stream; } @@ -37,22 +37,23 @@ trait StreamDecoratorTrait throw new \UnexpectedValueException("$name not found on class"); } - public function __toString() + public function __toString(): string { try { if ($this->isSeekable()) { $this->seek(0); } return $this->getContents(); - } catch (\Exception $e) { - // Really, PHP? https://bugs.php.net/bug.php?id=53648 - trigger_error('StreamDecorator::__toString exception: ' - . (string) $e, E_USER_ERROR); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } - public function getContents() + public function getContents(): string { return Utils::copyToString($this); } @@ -60,24 +61,28 @@ trait StreamDecoratorTrait /** * Allow decorators to implement custom methods * - * @param string $method Missing method name - * @param array $args Method arguments - * * @return mixed */ - public function __call($method, array $args) + public function __call(string $method, array $args) { - $result = call_user_func_array([$this->stream, $method], $args); + /** @var callable $callable */ + $callable = [$this->stream, $method]; + $result = call_user_func_array($callable, $args); // Always return the wrapped object if the result is a return $this return $result === $this->stream ? $this : $result; } - public function close() + public function close(): void { $this->stream->close(); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { return $this->stream->getMetadata($key); @@ -88,52 +93,52 @@ trait StreamDecoratorTrait return $this->stream->detach(); } - public function getSize() + public function getSize(): ?int { return $this->stream->getSize(); } - public function eof() + public function eof(): bool { return $this->stream->eof(); } - public function tell() + public function tell(): int { return $this->stream->tell(); } - public function isReadable() + public function isReadable(): bool { return $this->stream->isReadable(); } - public function isWritable() + public function isWritable(): bool { return $this->stream->isWritable(); } - public function isSeekable() + public function isSeekable(): bool { return $this->stream->isSeekable(); } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { $this->stream->seek($offset, $whence); } - public function read($length) + public function read($length): string { return $this->stream->read($length); } - public function write($string) + public function write($string): int { return $this->stream->write($string); } @@ -141,11 +146,9 @@ trait StreamDecoratorTrait /** * Implement in subclasses to dynamically create streams when requested. * - * @return StreamInterface - * * @throws \BadMethodCallException */ - protected function createStream() + protected function createStream(): StreamInterface { throw new \BadMethodCallException('Not implemented'); } diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php index fc7cb969..2a934640 100644 --- a/vendor/guzzlehttp/psr7/src/StreamWrapper.php +++ b/vendor/guzzlehttp/psr7/src/StreamWrapper.php @@ -1,5 +1,7 @@ context); @@ -83,41 +83,48 @@ class StreamWrapper return true; } - public function stream_read($count) + public function stream_read(int $count): string { return $this->stream->read($count); } - public function stream_write($data) + public function stream_write(string $data): int { - return (int) $this->stream->write($data); + return $this->stream->write($data); } - public function stream_tell() + public function stream_tell(): int { return $this->stream->tell(); } - public function stream_eof() + public function stream_eof(): bool { return $this->stream->eof(); } - public function stream_seek($offset, $whence) + public function stream_seek(int $offset, int $whence): bool { $this->stream->seek($offset, $whence); return true; } - public function stream_cast($cast_as) + /** + * @return resource|false + */ + public function stream_cast(int $cast_as) { $stream = clone($this->stream); + $resource = $stream->detach(); - return $stream->detach(); + return $resource ?? false; } - public function stream_stat() + /** + * @return array + */ + public function stream_stat(): array { static $modeMap = [ 'r' => 33060, @@ -144,7 +151,10 @@ class StreamWrapper ]; } - public function url_stat($path, $flags) + /** + * @return array + */ + public function url_stat(string $path, int $flags): array { return [ 'dev' => 0, diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php index bf342c4d..b1521bcf 100644 --- a/vendor/guzzlehttp/psr7/src/UploadedFile.php +++ b/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -1,5 +1,7 @@ setError($errorStatus); - $this->setSize($size); - $this->setClientFilename($clientFilename); - $this->setClientMediaType($clientMediaType); + $this->size = $size; + $this->clientFilename = $clientFilename; + $this->clientMediaType = $clientMediaType; if ($this->isOk()) { $this->setStreamOrFile($streamOrFile); @@ -85,11 +80,11 @@ class UploadedFile implements UploadedFileInterface /** * Depending on the value set file or stream variable * - * @param mixed $streamOrFile + * @param StreamInterface|string|resource $streamOrFile * * @throws InvalidArgumentException */ - private function setStreamOrFile($streamOrFile) + private function setStreamOrFile($streamOrFile): void { if (is_string($streamOrFile)) { $this->file = $streamOrFile; @@ -105,19 +100,11 @@ class UploadedFile implements UploadedFileInterface } /** - * @param int $error - * * @throws InvalidArgumentException */ - private function setError($error) + private function setError(int $error): void { - if (false === is_int($error)) { - throw new InvalidArgumentException( - 'Upload file error status must be an integer' - ); - } - - if (false === in_array($error, UploadedFile::$errors)) { + if (false === in_array($error, UploadedFile::ERRORS, true)) { throw new InvalidArgumentException( 'Invalid error status for UploadedFile' ); @@ -126,88 +113,20 @@ class UploadedFile implements UploadedFileInterface $this->error = $error; } - /** - * @param int $size - * - * @throws InvalidArgumentException - */ - private function setSize($size) - { - if (false === is_int($size)) { - throw new InvalidArgumentException( - 'Upload file size must be an integer' - ); - } - - $this->size = $size; - } - - /** - * @param mixed $param - * - * @return bool - */ - private function isStringOrNull($param) - { - return in_array(gettype($param), ['string', 'NULL']); - } - - /** - * @param mixed $param - * - * @return bool - */ - private function isStringNotEmpty($param) + private function isStringNotEmpty($param): bool { return is_string($param) && false === empty($param); } - /** - * @param string|null $clientFilename - * - * @throws InvalidArgumentException - */ - private function setClientFilename($clientFilename) - { - if (false === $this->isStringOrNull($clientFilename)) { - throw new InvalidArgumentException( - 'Upload file client filename must be a string or null' - ); - } - - $this->clientFilename = $clientFilename; - } - - /** - * @param string|null $clientMediaType - * - * @throws InvalidArgumentException - */ - private function setClientMediaType($clientMediaType) - { - if (false === $this->isStringOrNull($clientMediaType)) { - throw new InvalidArgumentException( - 'Upload file client media type must be a string or null' - ); - } - - $this->clientMediaType = $clientMediaType; - } - /** * Return true if there is no upload error - * - * @return bool */ - private function isOk() + private function isOk(): bool { return $this->error === UPLOAD_ERR_OK; } - /** - * @return bool - */ - public function isMoved() + public function isMoved(): bool { return $this->moved; } @@ -215,7 +134,7 @@ class UploadedFile implements UploadedFileInterface /** * @throws RuntimeException if is moved or not ok */ - private function validateActive() + private function validateActive(): void { if (false === $this->isOk()) { throw new RuntimeException('Cannot retrieve stream due to upload error'); @@ -226,12 +145,7 @@ class UploadedFile implements UploadedFileInterface } } - /** - * {@inheritdoc} - * - * @throws RuntimeException if the upload was not successful. - */ - public function getStream() + public function getStream(): StreamInterface { $this->validateActive(); @@ -239,23 +153,13 @@ class UploadedFile implements UploadedFileInterface return $this->stream; } - return new LazyOpenStream($this->file, 'r+'); + /** @var string $file */ + $file = $this->file; + + return new LazyOpenStream($file, 'r+'); } - /** - * {@inheritdoc} - * - * @see http://php.net/is_uploaded_file - * @see http://php.net/move_uploaded_file - * - * @param string $targetPath Path to which to move the uploaded file. - * - * @throws RuntimeException if the upload was not successful. - * @throws InvalidArgumentException if the $path specified is invalid. - * @throws RuntimeException on any error during the move operation, or on - * the second or subsequent call to the method. - */ - public function moveTo($targetPath) + public function moveTo($targetPath): void { $this->validateActive(); @@ -266,7 +170,7 @@ class UploadedFile implements UploadedFileInterface } if ($this->file) { - $this->moved = php_sapi_name() == 'cli' + $this->moved = PHP_SAPI === 'cli' ? rename($this->file, $targetPath) : move_uploaded_file($this->file, $targetPath); } else { @@ -285,43 +189,22 @@ class UploadedFile implements UploadedFileInterface } } - /** - * {@inheritdoc} - * - * @return int|null The file size in bytes or null if unknown. - */ - public function getSize() + public function getSize(): ?int { return $this->size; } - /** - * {@inheritdoc} - * - * @see http://php.net/manual/en/features.file-upload.errors.php - * - * @return int One of PHP's UPLOAD_ERR_XXX constants. - */ - public function getError() + public function getError(): int { return $this->error; } - /** - * {@inheritdoc} - * - * @return string|null The filename sent by the client or null if none - * was provided. - */ - public function getClientFilename() + public function getClientFilename(): ?string { return $this->clientFilename; } - /** - * {@inheritdoc} - */ - public function getClientMediaType() + public function getClientMediaType(): ?string { return $this->clientMediaType; } diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php index 0f9f020d..3898f783 100644 --- a/vendor/guzzlehttp/psr7/src/Uri.php +++ b/vendor/guzzlehttp/psr7/src/Uri.php @@ -1,7 +1,10 @@ 80, 'https' => 443, 'ftp' => 21, @@ -35,9 +38,20 @@ class Uri implements UriInterface 'ldap' => 389, ]; - private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; - private static $charSubDelims = '!\$&\'\(\)\*\+,;='; - private static $replaceQuery = ['=' => '%3D', '&' => '%26']; + /** + * Unreserved characters for use in a regex. + * + * @link https://tools.ietf.org/html/rfc3986#section-2.3 + */ + private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~'; + + /** + * Sub-delims for use in a regex. + * + * @link https://tools.ietf.org/html/rfc3986#section-2.2 + */ + private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;='; + private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26']; /** @var string Uri scheme. */ private $scheme = ''; @@ -60,21 +74,19 @@ class Uri implements UriInterface /** @var string Uri fragment. */ private $fragment = ''; - /** - * @param string $uri URI to parse - */ - public function __construct($uri = '') + /** @var string|null String representation */ + private $composedComponents; + + public function __construct(string $uri = '') { - // weak type check to also accept null until we can add scalar type hints - if ($uri != '') { + if ($uri !== '') { $parts = self::parse($uri); if ($parts === false) { - throw new \InvalidArgumentException("Unable to parse URI: $uri"); + throw new MalformedUriException("Unable to parse URI: $uri"); } $this->applyParts($parts); } } - /** * UTF-8 aware \parse_url() replacement. * @@ -88,19 +100,19 @@ class Uri implements UriInterface * @see https://www.php.net/manual/en/function.parse-url.php#114817 * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING * - * @param string $url - * * @return array|false */ - private static function parse($url) + private static function parse(string $url) { // If IPv6 $prefix = ''; if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) { + /** @var array{0:string, 1:string, 2:string} $matches */ $prefix = $matches[1]; $url = $matches[2]; } + /** @var string */ $encodedUrl = preg_replace_callback( '%[^:/@?&=#]+%usD', static function ($matches) { @@ -118,15 +130,19 @@ class Uri implements UriInterface return array_map('urldecode', $result); } - public function __toString() + public function __toString(): string { - return self::composeComponents( - $this->scheme, - $this->getAuthority(), - $this->path, - $this->query, - $this->fragment - ); + if ($this->composedComponents === null) { + $this->composedComponents = self::composeComponents( + $this->scheme, + $this->getAuthority(), + $this->path, + $this->query, + $this->fragment + ); + } + + return $this->composedComponents; } /** @@ -145,17 +161,9 @@ class Uri implements UriInterface * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to * that format). * - * @param string $scheme - * @param string $authority - * @param string $path - * @param string $query - * @param string $fragment - * - * @return string - * * @link https://tools.ietf.org/html/rfc3986#section-5.3 */ - public static function composeComponents($scheme, $authority, $path, $query, $fragment) + public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string { $uri = ''; @@ -186,15 +194,11 @@ class Uri implements UriInterface * * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used * independently of the implementation. - * - * @param UriInterface $uri - * - * @return bool */ - public static function isDefaultPort(UriInterface $uri) + public static function isDefaultPort(UriInterface $uri): bool { return $uri->getPort() === null - || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]); + || (isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]); } /** @@ -207,16 +211,12 @@ class Uri implements UriInterface * - absolute-path references, e.g. '/path' * - relative-path references, e.g. 'subpath' * - * @param UriInterface $uri - * - * @return bool - * * @see Uri::isNetworkPathReference * @see Uri::isAbsolutePathReference * @see Uri::isRelativePathReference * @link https://tools.ietf.org/html/rfc3986#section-4 */ - public static function isAbsolute(UriInterface $uri) + public static function isAbsolute(UriInterface $uri): bool { return $uri->getScheme() !== ''; } @@ -226,13 +226,9 @@ class Uri implements UriInterface * * A relative reference that begins with two slash characters is termed an network-path reference. * - * @param UriInterface $uri - * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.2 */ - public static function isNetworkPathReference(UriInterface $uri) + public static function isNetworkPathReference(UriInterface $uri): bool { return $uri->getScheme() === '' && $uri->getAuthority() !== ''; } @@ -242,13 +238,9 @@ class Uri implements UriInterface * * A relative reference that begins with a single slash character is termed an absolute-path reference. * - * @param UriInterface $uri - * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.2 */ - public static function isAbsolutePathReference(UriInterface $uri) + public static function isAbsolutePathReference(UriInterface $uri): bool { return $uri->getScheme() === '' && $uri->getAuthority() === '' @@ -261,13 +253,9 @@ class Uri implements UriInterface * * A relative reference that does not begin with a slash character is termed a relative-path reference. * - * @param UriInterface $uri - * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.2 */ - public static function isRelativePathReference(UriInterface $uri) + public static function isRelativePathReference(UriInterface $uri): bool { return $uri->getScheme() === '' && $uri->getAuthority() === '' @@ -284,11 +272,9 @@ class Uri implements UriInterface * @param UriInterface $uri The URI to check * @param UriInterface|null $base An optional base URI to compare against * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.4 */ - public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null) + public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool { if ($base !== null) { $uri = UriResolver::resolve($base, $uri); @@ -302,41 +288,6 @@ class Uri implements UriInterface return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; } - /** - * Removes dot segments from a path and returns the new path. - * - * @param string $path - * - * @return string - * - * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead. - * @see UriResolver::removeDotSegments - */ - public static function removeDotSegments($path) - { - return UriResolver::removeDotSegments($path); - } - - /** - * Converts the relative URI into a new URI that is resolved against the base URI. - * - * @param UriInterface $base Base URI - * @param string|UriInterface $rel Relative URI - * - * @return UriInterface - * - * @deprecated since version 1.4. Use UriResolver::resolve instead. - * @see UriResolver::resolve - */ - public static function resolve(UriInterface $base, $rel) - { - if (!($rel instanceof UriInterface)) { - $rel = new self($rel); - } - - return UriResolver::resolve($base, $rel); - } - /** * Creates a new URI with a specific query string value removed. * @@ -345,10 +296,8 @@ class Uri implements UriInterface * * @param UriInterface $uri URI to use as a base. * @param string $key Query string key to remove. - * - * @return UriInterface */ - public static function withoutQueryValue(UriInterface $uri, $key) + public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface { $result = self::getFilteredQueryString($uri, [$key]); @@ -367,10 +316,8 @@ class Uri implements UriInterface * @param UriInterface $uri URI to use as a base. * @param string $key Key to set. * @param string|null $value Value to set - * - * @return UriInterface */ - public static function withQueryValue(UriInterface $uri, $key, $value) + public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface { $result = self::getFilteredQueryString($uri, [$key]); @@ -384,17 +331,15 @@ class Uri implements UriInterface * * It has the same behavior as withQueryValue() but for an associative array of key => value. * - * @param UriInterface $uri URI to use as a base. - * @param array $keyValueArray Associative array of key and values - * - * @return UriInterface + * @param UriInterface $uri URI to use as a base. + * @param array $keyValueArray Associative array of key and values */ - public static function withQueryValues(UriInterface $uri, array $keyValueArray) + public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface { $result = self::getFilteredQueryString($uri, array_keys($keyValueArray)); foreach ($keyValueArray as $key => $value) { - $result[] = self::generateQueryString($key, $value); + $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); } return $uri->withQuery(implode('&', $result)); @@ -403,15 +348,11 @@ class Uri implements UriInterface /** * Creates a URI from a hash of `parse_url` components. * - * @param array $parts - * - * @return UriInterface - * * @link http://php.net/manual/en/function.parse-url.php * - * @throws \InvalidArgumentException If the components do not form a valid URI. + * @throws MalformedUriException If the components do not form a valid URI. */ - public static function fromParts(array $parts) + public static function fromParts(array $parts): UriInterface { $uri = new self(); $uri->applyParts($parts); @@ -420,12 +361,12 @@ class Uri implements UriInterface return $uri; } - public function getScheme() + public function getScheme(): string { return $this->scheme; } - public function getAuthority() + public function getAuthority(): string { $authority = $this->host; if ($this->userInfo !== '') { @@ -439,37 +380,37 @@ class Uri implements UriInterface return $authority; } - public function getUserInfo() + public function getUserInfo(): string { return $this->userInfo; } - public function getHost() + public function getHost(): string { return $this->host; } - public function getPort() + public function getPort(): ?int { return $this->port; } - public function getPath() + public function getPath(): string { return $this->path; } - public function getQuery() + public function getQuery(): string { return $this->query; } - public function getFragment() + public function getFragment(): string { return $this->fragment; } - public function withScheme($scheme) + public function withScheme($scheme): UriInterface { $scheme = $this->filterScheme($scheme); @@ -479,13 +420,14 @@ class Uri implements UriInterface $new = clone $this; $new->scheme = $scheme; + $new->composedComponents = null; $new->removeDefaultPort(); $new->validateState(); return $new; } - public function withUserInfo($user, $password = null) + public function withUserInfo($user, $password = null): UriInterface { $info = $this->filterUserInfoComponent($user); if ($password !== null) { @@ -498,12 +440,13 @@ class Uri implements UriInterface $new = clone $this; $new->userInfo = $info; + $new->composedComponents = null; $new->validateState(); return $new; } - public function withHost($host) + public function withHost($host): UriInterface { $host = $this->filterHost($host); @@ -513,12 +456,13 @@ class Uri implements UriInterface $new = clone $this; $new->host = $host; + $new->composedComponents = null; $new->validateState(); return $new; } - public function withPort($port) + public function withPort($port): UriInterface { $port = $this->filterPort($port); @@ -528,13 +472,14 @@ class Uri implements UriInterface $new = clone $this; $new->port = $port; + $new->composedComponents = null; $new->removeDefaultPort(); $new->validateState(); return $new; } - public function withPath($path) + public function withPath($path): UriInterface { $path = $this->filterPath($path); @@ -544,12 +489,13 @@ class Uri implements UriInterface $new = clone $this; $new->path = $path; + $new->composedComponents = null; $new->validateState(); return $new; } - public function withQuery($query) + public function withQuery($query): UriInterface { $query = $this->filterQueryAndFragment($query); @@ -559,11 +505,12 @@ class Uri implements UriInterface $new = clone $this; $new->query = $query; + $new->composedComponents = null; return $new; } - public function withFragment($fragment) + public function withFragment($fragment): UriInterface { $fragment = $this->filterQueryAndFragment($fragment); @@ -573,6 +520,7 @@ class Uri implements UriInterface $new = clone $this; $new->fragment = $fragment; + $new->composedComponents = null; return $new; } @@ -582,7 +530,7 @@ class Uri implements UriInterface * * @param array $parts Array of parse_url parts to apply. */ - private function applyParts(array $parts) + private function applyParts(array $parts): void { $this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) @@ -613,13 +561,11 @@ class Uri implements UriInterface } /** - * @param string $scheme - * - * @return string + * @param mixed $scheme * * @throws \InvalidArgumentException If the scheme is invalid. */ - private function filterScheme($scheme) + private function filterScheme($scheme): string { if (!is_string($scheme)) { throw new \InvalidArgumentException('Scheme must be a string'); @@ -629,33 +575,29 @@ class Uri implements UriInterface } /** - * @param string $component - * - * @return string + * @param mixed $component * * @throws \InvalidArgumentException If the user info is invalid. */ - private function filterUserInfoComponent($component) + private function filterUserInfoComponent($component): string { 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}))/', + '/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component ); } /** - * @param string $host - * - * @return string + * @param mixed $host * * @throws \InvalidArgumentException If the host is invalid. */ - private function filterHost($host) + private function filterHost($host): string { if (!is_string($host)) { throw new \InvalidArgumentException('Host must be a string'); @@ -665,13 +607,11 @@ class Uri implements UriInterface } /** - * @param int|null $port - * - * @return int|null + * @param mixed $port * * @throws \InvalidArgumentException If the port is invalid. */ - private function filterPort($port) + private function filterPort($port): ?int { if ($port === null) { return null; @@ -688,12 +628,11 @@ class Uri implements UriInterface } /** - * @param UriInterface $uri - * @param array $keys + * @param string[] $keys * - * @return array + * @return string[] */ - private static function getFilteredQueryString(UriInterface $uri, array $keys) + private static function getFilteredQueryString(UriInterface $uri, array $keys): array { $current = $uri->getQuery(); @@ -708,27 +647,21 @@ class Uri implements UriInterface }); } - /** - * @param string $key - * @param string|null $value - * - * @return string - */ - private static function generateQueryString($key, $value) + private static function generateQueryString(string $key, ?string $value): string { // Query string separators ("=", "&") within the key or value need to be encoded // (while preventing double-encoding) before setting the query string. All other // chars that need percent-encoding will be encoded by withQuery(). - $queryString = strtr($key, self::$replaceQuery); + $queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); if ($value !== null) { - $queryString .= '=' . strtr($value, self::$replaceQuery); + $queryString .= '=' . strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); } return $queryString; } - private function removeDefaultPort() + private function removeDefaultPort(): void { if ($this->port !== null && self::isDefaultPort($this)) { $this->port = null; @@ -738,20 +671,18 @@ class Uri implements UriInterface /** * Filters the path of a URI * - * @param string $path - * - * @return string + * @param mixed $path * * @throws \InvalidArgumentException If the path is invalid. */ - private function filterPath($path) + private function filterPath($path): string { if (!is_string($path)) { throw new \InvalidArgumentException('Path must be a string'); } return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', + '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path ); @@ -760,31 +691,29 @@ class Uri implements UriInterface /** * Filters the query string or fragment of a URI. * - * @param string $str - * - * @return string + * @param mixed $str * * @throws \InvalidArgumentException If the query or fragment is invalid. */ - private function filterQueryAndFragment($str) + private function filterQueryAndFragment($str): string { if (!is_string($str)) { throw new \InvalidArgumentException('Query and fragment must be a string'); } return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', + '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str ); } - private function rawurlencodeMatchZero(array $match) + private function rawurlencodeMatchZero(array $match): string { return rawurlencode($match[0]); } - private function validateState() + private function validateState(): void { if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { $this->host = self::HTTP_DEFAULT_HOST; @@ -792,19 +721,13 @@ class Uri implements UriInterface if ($this->getAuthority() === '') { if (0 === strpos($this->path, '//')) { - throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"'); + throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"'); } if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { - throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon'); + throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon'); } } elseif (isset($this->path[0]) && $this->path[0] !== '/') { - @trigger_error( - 'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' . - 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.', - E_USER_DEPRECATED - ); - $this->path = '/' . $this->path; - //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty'); + throw new MalformedUriException('The path of a URI with an authority must start with a slash "/" or be empty'); } } } diff --git a/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/vendor/guzzlehttp/psr7/src/UriNormalizer.php index 81419ead..e12971ed 100644 --- a/vendor/guzzlehttp/psr7/src/UriNormalizer.php +++ b/vendor/guzzlehttp/psr7/src/UriNormalizer.php @@ -1,5 +1,7 @@ getScheme() !== '' && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') @@ -174,6 +162,7 @@ final class UriResolver // inherit the base query component when resolving. if ($target->getQuery() === '') { $segments = explode('/', $target->getPath()); + /** @var string $lastSegment */ $lastSegment = end($segments); return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); @@ -182,7 +171,7 @@ final class UriResolver return $emptyPathUri; } - private static function getRelativePath(UriInterface $base, UriInterface $target) + private static function getRelativePath(UriInterface $base, UriInterface $target): string { $sourceSegments = explode('/', $base->getPath()); $targetSegments = explode('/', $target->getPath()); diff --git a/vendor/guzzlehttp/psr7/src/Utils.php b/vendor/guzzlehttp/psr7/src/Utils.php index 6b6c8cce..6cc04ee4 100644 --- a/vendor/guzzlehttp/psr7/src/Utils.php +++ b/vendor/guzzlehttp/psr7/src/Utils.php @@ -1,5 +1,7 @@ $keys - * - * @return array + * @param string[] $keys */ - public static function caselessRemove($keys, array $data) + public static function caselessRemove(array $keys, array $data): array { $result = []; @@ -25,7 +25,7 @@ final class Utils } foreach ($data as $k => $v) { - if (!in_array(strtolower($k), $keys)) { + if (!is_string($k) || !in_array(strtolower($k), $keys)) { $result[$k] = $v; } } @@ -44,7 +44,7 @@ final class Utils * * @throws \RuntimeException on error. */ - public static function copyToStream(StreamInterface $source, StreamInterface $dest, $maxLen = -1) + public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void { $bufferSize = 8192; @@ -76,19 +76,16 @@ final class Utils * @param int $maxLen Maximum number of bytes to read. Pass -1 * to read the entire stream. * - * @return string - * * @throws \RuntimeException on error. */ - public static function copyToString(StreamInterface $stream, $maxLen = -1) + public static function copyToString(StreamInterface $stream, int $maxLen = -1): string { $buffer = ''; if ($maxLen === -1) { while (!$stream->eof()) { $buf = $stream->read(1048576); - // Using a loose equality here to match on '' and false. - if ($buf == null) { + if ($buf === '') { break; } $buffer .= $buf; @@ -99,8 +96,7 @@ final class Utils $len = 0; while (!$stream->eof() && $len < $maxLen) { $buf = $stream->read($maxLen - $len); - // Using a loose equality here to match on '' and false. - if ($buf == null) { + if ($buf === '') { break; } $buffer .= $buf; @@ -120,11 +116,9 @@ final class Utils * @param string $algo Hash algorithm (e.g. md5, crc32, etc) * @param bool $rawOutput Whether or not to use raw output * - * @return string Returns the hash of the stream - * * @throws \RuntimeException on error. */ - public static function hash(StreamInterface $stream, $algo, $rawOutput = false) + public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string { $pos = $stream->tell(); @@ -160,10 +154,8 @@ final class Utils * * @param RequestInterface $request Request to clone and modify. * @param array $changes Changes to apply. - * - * @return RequestInterface */ - public static function modifyRequest(RequestInterface $request, array $changes) + public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface { if (!$changes) { return $request; @@ -204,13 +196,11 @@ final class Utils if ($request instanceof ServerRequestInterface) { $new = (new ServerRequest( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $changes['method'] ?? $request->getMethod(), $uri, $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion(), + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion(), $request->getServerParams() )) ->withParsedBody($request->getParsedBody()) @@ -226,13 +216,11 @@ final class Utils } return new Request( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $changes['method'] ?? $request->getMethod(), $uri, $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion() + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion() ); } @@ -241,17 +229,14 @@ final class Utils * * @param StreamInterface $stream Stream to read from * @param int|null $maxLength Maximum buffer length - * - * @return string */ - public static function readLine(StreamInterface $stream, $maxLength = null) + public static function readLine(StreamInterface $stream, ?int $maxLength = null): string { $buffer = ''; $size = 0; while (!$stream->eof()) { - // Using a loose equality here to match on '' and false. - if (null == ($byte = $stream->read(1))) { + if ('' === ($byte = $stream->read(1))) { return $buffer; } $buffer .= $byte; @@ -294,18 +279,16 @@ final class Utils * buffered and used in subsequent reads. * * @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data - * @param array $options Additional options - * - * @return StreamInterface + * @param array{size?: int, metadata?: array} $options Additional options * * @throws \InvalidArgumentException if the $resource arg is not valid. */ - public static function streamFor($resource = '', array $options = []) + public static function streamFor($resource = '', array $options = []): StreamInterface { if (is_scalar($resource)) { $stream = self::tryFopen('php://temp', 'r+'); if ($resource !== '') { - fwrite($stream, $resource); + fwrite($stream, (string) $resource); fseek($stream, 0); } return new Stream($stream, $options); @@ -317,8 +300,9 @@ final class Utils * The 'php://input' is a special stream with quirks and inconsistencies. * We avoid using that stream by reading it into php://temp */ - $metaData = \stream_get_meta_data($resource); - if (isset($metaData['uri']) && $metaData['uri'] === 'php://input') { + + /** @var resource $resource */ + if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') { $stream = self::tryFopen('php://temp', 'w+'); fwrite($stream, stream_get_contents($resource)); fseek($stream, 0); @@ -326,6 +310,7 @@ final class Utils } return new Stream($resource, $options); case 'object': + /** @var object $resource */ if ($resource instanceof StreamInterface) { return $resource; } elseif ($resource instanceof \Iterator) { @@ -338,7 +323,7 @@ final class Utils return $result; }, $options); } elseif (method_exists($resource, '__toString')) { - return Utils::streamFor((string) $resource, $options); + return self::streamFor((string) $resource, $options); } break; case 'NULL': @@ -365,21 +350,22 @@ final class Utils * * @throws \RuntimeException if the file cannot be opened */ - public static function tryFopen($filename, $mode) + public static function tryFopen(string $filename, string $mode) { $ex = null; - set_error_handler(function () use ($filename, $mode, &$ex) { + set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool { $ex = new \RuntimeException(sprintf( 'Unable to open "%s" using mode "%s": %s', $filename, $mode, - func_get_args()[1] + $errstr )); return true; }); try { + /** @var resource $handle */ $handle = fopen($filename, $mode); } catch (\Throwable $e) { $ex = new \RuntimeException(sprintf( @@ -409,11 +395,9 @@ final class Utils * * @param string|UriInterface $uri * - * @return UriInterface - * * @throws \InvalidArgumentException */ - public static function uriFor($uri) + public static function uriFor($uri): UriInterface { if ($uri instanceof UriInterface) { return $uri; diff --git a/vendor/guzzlehttp/psr7/src/functions.php b/vendor/guzzlehttp/psr7/src/functions.php deleted file mode 100644 index b0901fad..00000000 --- a/vendor/guzzlehttp/psr7/src/functions.php +++ /dev/null @@ -1,422 +0,0 @@ - '1', 'foo[b]' => '2'])`. - * - * @param string $str Query string to parse - * @param int|bool $urlEncoding How the query string is encoded - * - * @return array - * - * @deprecated parse_query will be removed in guzzlehttp/psr7:2.0. Use Query::parse instead. - */ -function parse_query($str, $urlEncoding = true) -{ - return Query::parse($str, $urlEncoding); -} - -/** - * Build a query string from an array of key value pairs. - * - * This function can use the return value of `parse_query()` to build a query - * string. This function does not modify the provided keys when an array is - * encountered (like `http_build_query()` would). - * - * @param array $params Query string parameters. - * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 - * to encode using RFC3986, or PHP_QUERY_RFC1738 - * to encode using RFC1738. - * - * @return string - * - * @deprecated build_query will be removed in guzzlehttp/psr7:2.0. Use Query::build instead. - */ -function build_query(array $params, $encoding = PHP_QUERY_RFC3986) -{ - return Query::build($params, $encoding); -} - -/** - * Determines the mimetype of a file by looking at its extension. - * - * @param string $filename - * - * @return string|null - * - * @deprecated mimetype_from_filename will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromFilename instead. - */ -function mimetype_from_filename($filename) -{ - return MimeType::fromFilename($filename); -} - -/** - * Maps a file extensions to a mimetype. - * - * @param $extension string The file extension. - * - * @return string|null - * - * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types - * @deprecated mimetype_from_extension will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromExtension instead. - */ -function mimetype_from_extension($extension) -{ - return MimeType::fromExtension($extension); -} - -/** - * Parses an HTTP message into an associative array. - * - * The array contains the "start-line" key containing the start line of - * the message, "headers" key containing an associative array of header - * array values, and a "body" key containing the body of the message. - * - * @param string $message HTTP request or response to parse. - * - * @return array - * - * @internal - * - * @deprecated _parse_message will be removed in guzzlehttp/psr7:2.0. Use Message::parseMessage instead. - */ -function _parse_message($message) -{ - return Message::parseMessage($message); -} - -/** - * Constructs a URI for an HTTP request message. - * - * @param string $path Path from the start-line - * @param array $headers Array of headers (each value an array). - * - * @return string - * - * @internal - * - * @deprecated _parse_request_uri will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequestUri instead. - */ -function _parse_request_uri($path, array $headers) -{ - return Message::parseRequestUri($path, $headers); -} - -/** - * Get a short summary of the message body. - * - * Will return `null` if the response is not printable. - * - * @param MessageInterface $message The message to get the body summary - * @param int $truncateAt The maximum allowed size of the summary - * - * @return string|null - * - * @deprecated get_message_body_summary will be removed in guzzlehttp/psr7:2.0. Use Message::bodySummary instead. - */ -function get_message_body_summary(MessageInterface $message, $truncateAt = 120) -{ - return Message::bodySummary($message, $truncateAt); -} - -/** - * Remove the items given by the keys, case insensitively from the data. - * - * @param iterable $keys - * - * @return array - * - * @internal - * - * @deprecated _caseless_remove will be removed in guzzlehttp/psr7:2.0. Use Utils::caselessRemove instead. - */ -function _caseless_remove($keys, array $data) -{ - return Utils::caselessRemove($keys, $data); -} diff --git a/vendor/guzzlehttp/psr7/src/functions_include.php b/vendor/guzzlehttp/psr7/src/functions_include.php deleted file mode 100644 index 96a4a83a..00000000 --- a/vendor/guzzlehttp/psr7/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ -=7.3", "psr/http-factory": "^1.0", - "guzzlehttp/psr7": "^1.4.2" + "guzzlehttp/psr7": "^1.7||^2.0" }, "require-dev": { - "http-interop/http-factory-tests": "^0.5", - "phpunit/phpunit": "^6.5" + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { "Http\\Factory\\Guzzle\\": "src/" } + }, + "suggest": { + "guzzlehttp/psr7": "Includes an HTTP factory starting in version 2.0" } } diff --git a/vendor/http-interop/http-factory-guzzle/phpunit.xml.dist b/vendor/http-interop/http-factory-guzzle/phpunit.xml.dist deleted file mode 100644 index 356f4824..00000000 --- a/vendor/http-interop/http-factory-guzzle/phpunit.xml.dist +++ /dev/null @@ -1,25 +0,0 @@ - - - - vendor/http-interop/http-factory-tests/test - - - - - - - - - - - - - ./src/ - - - - - - - - diff --git a/vendor/http-interop/http-factory-guzzle/src/StreamFactory.php b/vendor/http-interop/http-factory-guzzle/src/StreamFactory.php index 23aee9fa..6fe772e7 100644 --- a/vendor/http-interop/http-factory-guzzle/src/StreamFactory.php +++ b/vendor/http-interop/http-factory-guzzle/src/StreamFactory.php @@ -2,6 +2,8 @@ namespace Http\Factory\Guzzle; +use GuzzleHttp\Psr7\Stream; +use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; @@ -9,18 +11,16 @@ class StreamFactory implements StreamFactoryInterface { public function createStream(string $content = ''): StreamInterface { - return \GuzzleHttp\Psr7\stream_for($content); + return Utils::streamFor($content); } public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface { - $resource = \GuzzleHttp\Psr7\try_fopen($file, $mode); - - return \GuzzleHttp\Psr7\stream_for($resource); + return $this->createStreamFromResource(Utils::tryFopen($file, $mode)); } public function createStreamFromResource($resource): StreamInterface { - return \GuzzleHttp\Psr7\stream_for($resource); + return new Stream($resource); } } diff --git a/vendor/knplabs/github-api/CHANGELOG-3.X.md b/vendor/knplabs/github-api/CHANGELOG-3.X.md new file mode 100644 index 00000000..30dcb73d --- /dev/null +++ b/vendor/knplabs/github-api/CHANGELOG-3.X.md @@ -0,0 +1,109 @@ +# Changelog + +## 3.5.0 + +### Added +- added support for psr\cache 3.0 ([rconfig](https://github.com/rconfig)) [#1046](https://github.com/KnpLabs/php-github-api/issues/1046) +- Symfony: allow deprecation-contracts version 3 ([glaubinix](https://github.com/glaubinix)) [#1049](https://github.com/KnpLabs/php-github-api/issues/1049) + +### Changed +- Fix internal doc link ([staudenmeir](https://github.com/staudenmeir)) [#1044](https://github.com/KnpLabs/php-github-api/issues/1044) + +### Fixed +- Fix Client URL Prepending For GraphQL Endpoint on Enterprise ([asher-goldberg](https://github.com/asher-goldberg), [acrobat](https://github.com/acrobat)) [#1048](https://github.com/KnpLabs/php-github-api/issues/1048) + +## 3.4.0 + +### Added +- Add create a repository using a template endpoint ([martinbean](https://github.com/martinbean)) [#994](https://github.com/KnpLabs/php-github-api/issues/994) +- Allow fetching repo readme for a specific ref ([bery](https://github.com/bery)) [#1019](https://github.com/KnpLabs/php-github-api/issues/1019) +- allow assigning role to organisation members ([luceos](https://github.com/luceos)) [#1018](https://github.com/KnpLabs/php-github-api/issues/1018) +- Branch lists . ( ? query per_page) ([pitonic](https://github.com/pitonic)) [#1020](https://github.com/KnpLabs/php-github-api/issues/1020) +- Php8.1 support ([acrobat](https://github.com/acrobat)) [#1025](https://github.com/KnpLabs/php-github-api/issues/1025) +- Allow psr/cache 2.0 as well as 1.0 ([johnnoel](https://github.com/johnnoel)) [#1029](https://github.com/KnpLabs/php-github-api/issues/1029) +- adding code_with_match (#1024) ([QuentinRa](https://github.com/QuentinRa)) [#1031](https://github.com/KnpLabs/php-github-api/issues/1031) +- Added dir parameter for Repo readme ([AlexandrePavy](https://github.com/AlexandrePavy)) [#1032](https://github.com/KnpLabs/php-github-api/issues/1032) +- refs #955: deprecate Client::AUTH_* constants and replace them with AuthMethod::AUTH_* const ([ipalo](https://github.com/ipalo)) [#1036](https://github.com/KnpLabs/php-github-api/issues/1036) +- feat: Add `visibility` option to repo create ([gerdemann](https://github.com/gerdemann)) [#1038](https://github.com/KnpLabs/php-github-api/issues/1038) +- Feature get authenticated app ([kdaniel95](https://github.com/kdaniel95)) [#1041](https://github.com/KnpLabs/php-github-api/issues/1041) + +### Changed +- Fix up typos ([dereuromark](https://github.com/dereuromark)) [#1011](https://github.com/KnpLabs/php-github-api/issues/1011) +- Update integration authentication documentation for usage with lcobucci/jwt ^4 ([glaubinix](https://github.com/glaubinix)) [#1017](https://github.com/KnpLabs/php-github-api/issues/1017) +- Update result_pager.md ([tomsowerby](https://github.com/tomsowerby)) [#1023](https://github.com/KnpLabs/php-github-api/issues/1023) +- fix(doc): links to doc in CurrentUser class ([Nek-](https://github.com/Nek-)) [#1026](https://github.com/KnpLabs/php-github-api/issues/1026) +- Fix incorrect phpdoc ([gemal](https://github.com/gemal)) [#1034](https://github.com/KnpLabs/php-github-api/issues/1034) + +### Fixed +- Add accept header for creating repo from template ([davidpeach](https://github.com/davidpeach)) [#1030](https://github.com/KnpLabs/php-github-api/issues/1030) + +## 3.3.0 + +### Added +- Allow costume accept headers for GraphQL Endpoint. ([Necmttn](https://github.com/Necmttn)) [#1001](https://github.com/KnpLabs/php-github-api/issues/1001) +- Add endpoint for approve workflow run ([Nyholm](https://github.com/Nyholm)) [#1006](https://github.com/KnpLabs/php-github-api/issues/1006) + +### Changed +- Update readme and add example for different http client usage ([acrobat](https://github.com/acrobat)) [#1002](https://github.com/KnpLabs/php-github-api/issues/1002) +- Bumped branch alias after new feature merged ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1004](https://github.com/KnpLabs/php-github-api/issues/1004) +- Add comment on AbstractApi::$perPage() ([Nyholm](https://github.com/Nyholm)) [#1007](https://github.com/KnpLabs/php-github-api/issues/1007) + +### Fixed +- Fix publicKey ([Yurunsoft](https://github.com/Yurunsoft)) [#1005](https://github.com/KnpLabs/php-github-api/issues/1005) + +## 3.2.0 + +### Added +- Deprecate ResultPager::postFetch method ([acrobat](https://github.com/acrobat)) [#986](https://github.com/KnpLabs/php-github-api/issues/986) +- Add deprecations to the PR review methods to allow cleanup ([acrobat](https://github.com/acrobat)) [#984](https://github.com/KnpLabs/php-github-api/issues/984) +- Allow binary content downloads of assets ([acrobat](https://github.com/acrobat)) [#990](https://github.com/KnpLabs/php-github-api/issues/990) +- Deployments: added missing 'delete deployment' endpoint ([clxmstaab](https://github.com/clxmstaab)) [#991](https://github.com/KnpLabs/php-github-api/issues/991) +- Events list per authenticated user for all repos ([richard015ar](https://github.com/richard015ar)) [#1000](https://github.com/KnpLabs/php-github-api/issues/1000) + +### Changed +- Fixed branch alias ([GrahamCampbell](https://github.com/GrahamCampbell)) [#975](https://github.com/KnpLabs/php-github-api/issues/975) +- fix typo ([staabm](https://github.com/staabm)) [#977](https://github.com/KnpLabs/php-github-api/issues/977) +- Improved bc check ([acrobat](https://github.com/acrobat)) [#982](https://github.com/KnpLabs/php-github-api/issues/982) +- Correctly link to github actions docs and fix backlinks ([acrobat](https://github.com/acrobat)) [#983](https://github.com/KnpLabs/php-github-api/issues/983) +- Add missing repo hooks documentation ([acrobat](https://github.com/acrobat)) [#987](https://github.com/KnpLabs/php-github-api/issues/987) +- Fix incorrect public key documentation ([acrobat](https://github.com/acrobat)) [#988](https://github.com/KnpLabs/php-github-api/issues/988) +- Fixed incorrect parameters in apps docs ([acrobat](https://github.com/acrobat)) [#989](https://github.com/KnpLabs/php-github-api/issues/989) +- phpdoc: fix typo ([clxmstaab](https://github.com/clxmstaab)) [#993](https://github.com/KnpLabs/php-github-api/issues/993) +- Fix upmerged usage of deprecated phpunit assert ([acrobat](https://github.com/acrobat)) [#995](https://github.com/KnpLabs/php-github-api/issues/995) +- Fix typo ([romainneutron](https://github.com/romainneutron)) [#997](https://github.com/KnpLabs/php-github-api/issues/997) + +### Fixed +- Deployments: use proper media-type for in_progress/queued, inactive state ([staabm](https://github.com/staabm)) [#979](https://github.com/KnpLabs/php-github-api/issues/979) +- [952] doc - Specify lcobucci/jwt version, fix deprecation ([amacrobert-meq](https://github.com/amacrobert-meq), [acrobat](https://github.com/acrobat)) [#953](https://github.com/KnpLabs/php-github-api/issues/953) +- Replace deprecated organization team repository add/remove urls ([acrobat](https://github.com/acrobat)) [#985](https://github.com/KnpLabs/php-github-api/issues/985) +- fixed php warning in GithubExceptionThrower ([clxmstaab](https://github.com/clxmstaab), [acrobat](https://github.com/acrobat)) [#992](https://github.com/KnpLabs/php-github-api/issues/992) + +## 3.1.0 + +### Added +- Add workflow dispatch and allow workflow names. ([fodinabor](https://github.com/fodinabor)) [#969](https://github.com/KnpLabs/php-github-api/issues/969) + +### Changed +- Re-enable roave bc check for 3.x ([acrobat](https://github.com/acrobat)) [#958](https://github.com/KnpLabs/php-github-api/issues/958) +- Cleanup 3.0.0 changelog ([acrobat](https://github.com/acrobat)) [#957](https://github.com/KnpLabs/php-github-api/issues/957) +- Update new GitHub doc links in repo. ([fodinabor](https://github.com/fodinabor)) [#974](https://github.com/KnpLabs/php-github-api/issues/974) + +### Fixed +- Add accept header for the checks API ([Agares](https://github.com/Agares)) [#968](https://github.com/KnpLabs/php-github-api/issues/968) +- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959) + +## 3.0.0 + +### Added +- Switch to PSR18 client implementation and bump httplug minimum version to ^2.0 ([GrahamCampbell](https://github.com/GrahamCampbell)) [#885](https://github.com/KnpLabs/php-github-api/issues/885) +- Switch to PSR-17 and remove deprecated code ([GrahamCampbell](https://github.com/GrahamCampbell)) [#888](https://github.com/KnpLabs/php-github-api/issues/888) +- Allow PHP8 ([acrobat](https://github.com/acrobat)) [#934](https://github.com/KnpLabs/php-github-api/issues/934) +- [3.x] Make PHP 7.2.5 the minimum version ([GrahamCampbell](https://github.com/GrahamCampbell)) [#942](https://github.com/KnpLabs/php-github-api/issues/942) +- [3.x] Re-worked pagination to not mutate the api classes ([GrahamCampbell](https://github.com/GrahamCampbell)) [#907](https://github.com/KnpLabs/php-github-api/issues/907) & ([acrobat](https://github.com/acrobat)) [#956](https://github.com/KnpLabs/php-github-api/issues/956) +- Prepare 3.0 release and remove remaining deprecated code ([acrobat](https://github.com/acrobat)) [#948](https://github.com/KnpLabs/php-github-api/issues/948) + +### Changed +- Remove BC check on 3.x ([GrahamCampbell](https://github.com/GrahamCampbell)) [#900](https://github.com/KnpLabs/php-github-api/issues/900) +- [3.x] Fix the HTTP methods client ([GrahamCampbell](https://github.com/GrahamCampbell)) [#910](https://github.com/KnpLabs/php-github-api/issues/910) +- fix typo ([michielkempen](https://github.com/michielkempen)) [#920](https://github.com/KnpLabs/php-github-api/issues/920) +- [3.x] Added some additional scalar types and return types ([GrahamCampbell](https://github.com/GrahamCampbell)) [#949](https://github.com/KnpLabs/php-github-api/issues/949) diff --git a/vendor/knplabs/github-api/CHANGELOG.md b/vendor/knplabs/github-api/CHANGELOG.md index a5728ab2..47980eff 100644 --- a/vendor/knplabs/github-api/CHANGELOG.md +++ b/vendor/knplabs/github-api/CHANGELOG.md @@ -1,5 +1,36 @@ # Changelog +## 2.20.0 + +### Added +- Deployments: added missing 'delete deployment' endpoint ([clxmstaab](https://github.com/clxmstaab)) [#991](https://github.com/KnpLabs/php-github-api/issues/991) + +### Changed +- phpdoc: fix typo ([clxmstaab](https://github.com/clxmstaab)) [#993](https://github.com/KnpLabs/php-github-api/issues/993) + +### Fixed +- fixed php warning in GithubExceptionThrower ([clxmstaab](https://github.com/clxmstaab), [acrobat](https://github.com/acrobat)) [#992](https://github.com/KnpLabs/php-github-api/issues/992) + +## 2.19.2 + +### Changed +- Improved bc check ([acrobat](https://github.com/acrobat)) [#982](https://github.com/KnpLabs/php-github-api/issues/982) +- Correctly link to github actions docs and fix backlinks ([acrobat](https://github.com/acrobat)) [#983](https://github.com/KnpLabs/php-github-api/issues/983) +- Add missing repo hooks documentation ([acrobat](https://github.com/acrobat)) [#987](https://github.com/KnpLabs/php-github-api/issues/987) +- Fix incorrect public key documentation ([acrobat](https://github.com/acrobat)) [#988](https://github.com/KnpLabs/php-github-api/issues/988) +- Fixed incorrect parameters in apps docs ([acrobat](https://github.com/acrobat)) [#989](https://github.com/KnpLabs/php-github-api/issues/989) + +### Fixed +- Deployments: use proper media-type for in_progress/queued, inactive state ([staabm](https://github.com/staabm)) [#979](https://github.com/KnpLabs/php-github-api/issues/979) +- backported #979 into 2.x ([staabm](https://github.com/staabm)) [#981](https://github.com/KnpLabs/php-github-api/issues/981) +- [952] doc - Specify lcobucci/jwt version, fix deprecation ([amacrobert-meq](https://github.com/amacrobert-meq), [acrobat](https://github.com/acrobat)) [#953](https://github.com/KnpLabs/php-github-api/issues/953) +- Replace deprecated organization team repository add/remove urls ([acrobat](https://github.com/acrobat)) [#985](https://github.com/KnpLabs/php-github-api/issues/985) + +## 2.19.1 + +### Fixed +- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959) + ## 2.19.0 ### Added diff --git a/vendor/knplabs/github-api/README.md b/vendor/knplabs/github-api/README.md index 6c360917..de79112b 100644 --- a/vendor/knplabs/github-api/README.md +++ b/vendor/knplabs/github-api/README.md @@ -1,10 +1,9 @@ # PHP GitHub API -[![Build Status](https://travis-ci.org/KnpLabs/php-github-api.svg?branch=master)](https://travis-ci.org/KnpLabs/php-github-api) +![Build Status](https://github.com/KnpLabs/php-github-api/actions/workflows/ci.yml/badge.svg) [![StyleCI](https://styleci.io/repos/3948501/shield?style=flat)](https://styleci.io/repos/3948501) [![Latest Stable Version](https://poser.pugx.org/knplabs/github-api/v/stable)](https://packagist.org/packages/knplabs/github-api) [![Total Downloads](https://poser.pugx.org/knplabs/github-api/downloads)](https://packagist.org/packages/knplabs/github-api) -[![Latest Unstable Version](https://poser.pugx.org/knplabs/github-api/v/unstable)](https://packagist.org/packages/knplabs/github-api) [![Monthly Downloads](https://poser.pugx.org/knplabs/github-api/d/monthly)](https://packagist.org/packages/knplabs/github-api) [![Daily Downloads](https://poser.pugx.org/knplabs/github-api/d/daily)](https://packagist.org/packages/knplabs/github-api) @@ -19,34 +18,46 @@ Uses [GitHub API v3](http://developer.github.com/v3/) & supports [GitHub API v4] ## Requirements -* PHP >= 7.1 +* PHP >= 7.2 * A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation) * A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation) -## Install +## Quick install Via [Composer](https://getcomposer.org). -### PHP 7.1+: - -```bash -composer require knplabs/github-api:^3.0 php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0 -``` - -### PHP 7.2+: +This command will get you up and running quickly with a Guzzle HTTP client. ```bash composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0 ``` -### Laravel 6+: +## Advanced install + +We are decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io). + +### Using a different http client ```bash -composer require graham-campbell/github:^10.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0 +composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7 ``` -We are decoupled from any HTTP messaging client with help by [HTTPlug](http://httplug.io). Read about clients in our [docs](doc/customize.md). [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub) is by [Graham Campbell](https://github.com/GrahamCampbell). +To set up the Github client with this HTTP client +```php +use Github\Client; +use Symfony\Component\HttpClient\HttplugClient; + +$client = Client::createWithHttpClient(new HttplugClient()); +``` + +Read more about [using different clients in our docs](doc/customize.md). + +## Framework integrations + +### Laravel + +To integrate this library in laravel [Graham Campbell](https://github.com/GrahamCampbell) created [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub). See the [installation instructions](https://github.com/GrahamCampbell/Laravel-GitHub#installation) to get started in laravel. ## Basic usage of `php-github-api` client @@ -60,7 +71,7 @@ $client = new \Github\Client(); $repositories = $client->api('user')->repositories('ornicar'); ``` -From `$client` object, you can access to all GitHub. +From `$client` object, you have access to all available GitHub api endpoints. ## Cache usage @@ -105,18 +116,18 @@ See the [`doc` directory](doc/) for more detailed documentation. Please read [this post](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance) first. This library is maintained by the following people (alphabetically sorted) : -- @acrobat -- @Nyholm +- [@acrobat](https://github.com/acrobat) +- [@Nyholm](https://github.com/Nyholm) ## Contributors -- Thanks to [Thibault Duplessis aka. ornicar](http://github.com/ornicar) for his first version of this library. -- Thanks to [Joseph Bielawski aka. stloyd](http://github.com/stloyd) for his contributions and support. -- Thanks to [noloh](http://github.com/noloh) for his contribution on the Object API. -- Thanks to [bshaffer](http://github.com/bshaffer) for his contribution on the Repo API. -- Thanks to [Rolf van de Krol](http://github.com/rolfvandekrol) for his countless contributions. -- Thanks to [Nicolas Pastorino](http://github.com/jeanvoye) for his contribution on the Pull Request API. -- Thanks to [Edoardo Rivello](http://github.com/erivello) for his contribution on the Gists API. +- Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for his first version of this library. +- Thanks to [Joseph Bielawski aka. stloyd](https://github.com/stloyd) for his contributions and support. +- Thanks to [noloh](https://github.com/noloh) for his contribution on the Object API. +- Thanks to [bshaffer](https://github.com/bshaffer) for his contribution on the Repo API. +- Thanks to [Rolf van de Krol](https://github.com/rolfvandekrol) for his countless contributions. +- Thanks to [Nicolas Pastorino](https://github.com/jeanvoye) for his contribution on the Pull Request API. +- Thanks to [Edoardo Rivello](https://github.com/erivello) for his contribution on the Gists API. - Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API. - Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API. diff --git a/vendor/knplabs/github-api/UPGRADE-3.0.md b/vendor/knplabs/github-api/UPGRADE-3.0.md index 8e0e3f5f..738343d6 100644 --- a/vendor/knplabs/github-api/UPGRADE-3.0.md +++ b/vendor/knplabs/github-api/UPGRADE-3.0.md @@ -13,7 +13,7 @@ * `Github\HttpClient\Plugin\History` * `Github\HttpClient\Plugin\PathPrepend` -### Authetication methods +### Authentication methods * `Github\Client::AUTH_URL_TOKEN` use `Github\Client::AUTH_ACCESS_TOKEN` instead. * `Github\Client::AUTH_URL_CLIENT_ID` use `Github\Client::AUTH_CLIENT_ID` instead. diff --git a/vendor/knplabs/github-api/UPGRADE-4.0.md b/vendor/knplabs/github-api/UPGRADE-4.0.md new file mode 100644 index 00000000..6ede78de --- /dev/null +++ b/vendor/knplabs/github-api/UPGRADE-4.0.md @@ -0,0 +1,11 @@ +## UPGRADE from 3.x to 4.0 + +### ResultPager + +* `\Github\ResultPagerInterface::postFetch` is deprecated, and the method will be removed from the ResultPager interface/class. + +### Authentication methods + +* `Github\Client::AUTH_CLIENT_ID` is deprecated, use `Github\AuthMethod::CLIENT_ID` instead. +* `Github\Client::AUTH_ACCESS_TOKEN` is deprecated, use `Github\AuthMethod::ACCESS_TOKEN` instead. +* `Github\Client::AUTH_JWT` is deprecated, use `Github\AuthMethod::JWT` instead. diff --git a/vendor/knplabs/github-api/composer.json b/vendor/knplabs/github-api/composer.json index c6e2a7a4..b54537bd 100644 --- a/vendor/knplabs/github-api/composer.json +++ b/vendor/knplabs/github-api/composer.json @@ -24,11 +24,12 @@ "php-http/discovery": "^1.12", "php-http/httplug": "^2.2", "php-http/multipart-stream-builder": "^1.1.2", - "psr/cache": "^1.0", + "psr/cache": "^1.0|^2.0|^3.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", "psr/http-message": "^1.0", - "symfony/polyfill-php80": "^1.17" + "symfony/polyfill-php80": "^1.17", + "symfony/deprecation-contracts": "^2.2|^3.0" }, "require-dev": { "symfony/cache": "^5.1.8", @@ -39,7 +40,8 @@ "phpstan/phpstan": "^0.12.57", "phpstan/extension-installer": "^1.0.5", "phpstan/phpstan-deprecation-rules": "^0.12.5", - "phpunit/phpunit": "^8.5 || ^9.4" + "phpunit/phpunit": "^8.5 || ^9.4", + "symfony/phpunit-bridge": "^5.2" }, "autoload": { "psr-4": { "Github\\": "lib/Github/" } @@ -49,8 +51,13 @@ }, "extra": { "branch-alias": { - "dev-2.x": "2.19.x-dev", - "dev-master": "3.0.x-dev" + "dev-2.x": "2.20.x-dev", + "dev-master": "3.4.x-dev" + } + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true } } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/AbstractApi.php b/vendor/knplabs/github-api/lib/Github/Api/AbstractApi.php index ce70bbe2..71f71cce 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/AbstractApi.php +++ b/vendor/knplabs/github-api/lib/Github/Api/AbstractApi.php @@ -20,7 +20,7 @@ abstract class AbstractApi private $client; /** - * The per page parameter. + * The per page parameter. It is used by the ResultPager. * * @var int|null */ diff --git a/vendor/knplabs/github-api/lib/Github/Api/Apps.php b/vendor/knplabs/github-api/lib/Github/Api/Apps.php index bb2a2c46..9e9a4b6a 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Apps.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Apps.php @@ -186,4 +186,16 @@ class Apps extends AbstractApi return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId); } + + /** + * Get the currently authenticated app. + * + * @link https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app + * + * @return array + */ + public function getAuthenticatedApp() + { + return $this->get('/app'); + } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/CurrentUser.php b/vendor/knplabs/github-api/lib/Github/Api/CurrentUser.php index 70600a85..b5cbc89a 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/CurrentUser.php +++ b/vendor/knplabs/github-api/lib/Github/Api/CurrentUser.php @@ -54,7 +54,7 @@ class CurrentUser extends AbstractApi } /** - * @link http://developer.github.com/v3/issues/#list-issues + * @link https://docs.github.com/en/rest/reference/issues#list-user-account-issues-assigned-to-the-authenticated-user * * @param array $params * @param bool $includeOrgIssues @@ -91,7 +91,7 @@ class CurrentUser extends AbstractApi } /** - * @link http://developer.github.com/v3/orgs/#list-user-organizations + * @link https://docs.github.com/en/rest/reference/orgs#list-organizations-for-the-authenticated-user * * @return array */ @@ -111,7 +111,7 @@ class CurrentUser extends AbstractApi } /** - * @link http://developer.github.com/v3/repos/#list-your-repositories + * @link https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user * * @param string $type role in the repository * @param string $sort sort by @@ -159,7 +159,7 @@ class CurrentUser extends AbstractApi } /** - * @link https://developer.github.com/v3/activity/watching/#list-repositories-being-watched + * @link https://docs.github.com/en/rest/reference/activity#list-repositories-watched-by-the-authenticated-user */ public function subscriptions() { @@ -167,7 +167,7 @@ class CurrentUser extends AbstractApi } /** - * @link https://developer.github.com/v3/apps/installations/#list-app-installations-accessible-to-the-user-access-token + * @link https://docs.github.com/en/rest/reference/apps#list-app-installations-accessible-to-the-user-access-token * * @param array $params */ diff --git a/vendor/knplabs/github-api/lib/Github/Api/Deployment.php b/vendor/knplabs/github-api/lib/Github/Api/Deployment.php index 6fa8700a..f6127357 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Deployment.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Deployment.php @@ -11,6 +11,8 @@ use Github\Exception\MissingArgumentException; */ class Deployment extends AbstractApi { + use AcceptHeaderTrait; + /** * List deployments for a particular repository. * @@ -66,6 +68,21 @@ class Deployment extends AbstractApi return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params); } + /** + * Delete a deployment for the given username and repo. + * + * @link https://docs.github.com/en/rest/reference/repos#delete-a-deployment + * + * Important: Deployments can only be deleted when in inactive state + * @see updateStatus + * + * @return mixed null on success, array on error with 'message' + */ + public function remove(string $username, string $repository, int $id) + { + return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id); + } + /** * Updates a deployment by creating a new status update. * @@ -76,7 +93,7 @@ class Deployment extends AbstractApi * @param int $id the deployment number * @param array $params The information about the deployment update. * Must include a "state" field of pending, success, error, or failure. - * May also be given a target_url and description, ßee link for more details. + * May also be given a target_url and description, see link for more details. * * @throws MissingArgumentException * @@ -88,6 +105,15 @@ class Deployment extends AbstractApi throw new MissingArgumentException(['state']); } + // adjust media-type per github docs + // https://docs.github.com/en/rest/reference/repos#create-a-deployment-status + if ($params['state'] === 'inactive') { + $this->acceptHeaderValue = 'application/vnd.github.ant-man-preview+json'; + } + if ($params['state'] === 'in_progress' || $params['state'] === 'queued') { + $this->acceptHeaderValue = 'application/vnd.github.flash-preview+json'; + } + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params); } diff --git a/vendor/knplabs/github-api/lib/Github/Api/GraphQL.php b/vendor/knplabs/github-api/lib/Github/Api/GraphQL.php index 9d66b512..02499ad8 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/GraphQL.php +++ b/vendor/knplabs/github-api/lib/Github/Api/GraphQL.php @@ -18,12 +18,13 @@ class GraphQL extends AbstractApi /** * @param string $query * @param array $variables + * @param string $acceptHeaderValue * * @return array */ - public function execute($query, array $variables = []) + public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github.v4+json') { - $this->acceptHeaderValue = 'application/vnd.github.v4+json'; + $this->acceptHeaderValue = $acceptHeaderValue; $params = [ 'query' => $query, ]; diff --git a/vendor/knplabs/github-api/lib/Github/Api/Organization/Actions/Secrets.php b/vendor/knplabs/github-api/lib/Github/Api/Organization/Actions/Secrets.php index 7a082129..819e2c46 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Organization/Actions/Secrets.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Organization/Actions/Secrets.php @@ -5,12 +5,12 @@ namespace Github\Api\Organization\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#secrets + * @link https://docs.github.com/en/rest/reference/actions#secrets */ class Secrets extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-organization-secrets + * @link https://docs.github.com/en/rest/reference/actions#list-organization-secrets * * @param string $organization * @@ -22,7 +22,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#get-an-organization-secret * * @param string $organization * @param string $secretName @@ -35,7 +35,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret * * @param string $organization * @param string $secretName @@ -49,7 +49,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret * * @param string $organization * @param string $secretName @@ -63,7 +63,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret * * @param string $organization * @param string $secretName @@ -76,7 +76,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-selected-repositories-for-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret * * @param string $organization * @param string $secretName @@ -89,7 +89,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#set-selected-repositories-for-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret * * @param string $organization * @param string $secretName @@ -103,7 +103,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#add-selected-repository-to-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret * * @param string $organization * @param string $repositoryId @@ -117,7 +117,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#remove-selected-repository-from-an-organization-secret + * @link https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret * * @param string $organization * @param string $repositoryId @@ -131,7 +131,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-public-key + * @link https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key * * @param string $organization * @@ -139,6 +139,6 @@ class Secrets extends AbstractApi */ public function publicKey(string $organization) { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/secret-key'); + return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/public-key'); } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Organization/Members.php b/vendor/knplabs/github-api/lib/Github/Api/Organization/Members.php index 3639e3ba..023e3f8d 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Organization/Members.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Organization/Members.php @@ -58,9 +58,9 @@ class Members extends AbstractApi /* * Add user to organization */ - public function add($organization, $username) + public function add($organization, $username, array $params = []) { - return $this->put('/orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username)); + return $this->put('/orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username), $params); } public function addMember($organization, $username) diff --git a/vendor/knplabs/github-api/lib/Github/Api/Organization/Teams.php b/vendor/knplabs/github-api/lib/Github/Api/Organization/Teams.php index 00b57758..3af63b73 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Organization/Teams.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Organization/Teams.php @@ -107,15 +107,15 @@ class Teams extends AbstractApi public function addRepository($team, $organization, $repository, $params = []) { - if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) { + if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin', 'maintain', 'triage'])) { $params['permission'] = 'pull'; } - return $this->put('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params); + return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params); } public function removeRepository($team, $organization, $repository) { - return $this->delete('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); + return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/PullRequest/Review.php b/vendor/knplabs/github-api/lib/Github/Api/PullRequest/Review.php index 249477f0..ed586ddf 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/PullRequest/Review.php +++ b/vendor/knplabs/github-api/lib/Github/Api/PullRequest/Review.php @@ -20,6 +20,8 @@ class Review extends AbstractApi public function configure() { + trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" is deprecated and will be removed.', __METHOD__); + return $this; } @@ -37,6 +39,10 @@ class Review extends AbstractApi */ public function all($username, $repository, $pullRequest, array $params = []) { + if (!empty($params)) { + trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "$params" parameter is deprecated, to paginate the results use the "ResultPager" instead.'); + } + $parameters = array_merge([ 'page' => 1, 'per_page' => 30, diff --git a/vendor/knplabs/github-api/lib/Github/Api/PullRequest/ReviewRequest.php b/vendor/knplabs/github-api/lib/Github/Api/PullRequest/ReviewRequest.php index 54030755..d95913cc 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/PullRequest/ReviewRequest.php +++ b/vendor/knplabs/github-api/lib/Github/Api/PullRequest/ReviewRequest.php @@ -14,6 +14,8 @@ class ReviewRequest extends AbstractApi public function configure() { + trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" is deprecated and will be removed.', __METHOD__); + return $this; } @@ -29,6 +31,10 @@ class ReviewRequest extends AbstractApi */ public function all($username, $repository, $pullRequest, array $params = []) { + if (!empty($params)) { + trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "$params" parameter is deprecated, to paginate the results use the "ResultPager" instead.'); + } + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', $params); } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repo.php b/vendor/knplabs/github-api/lib/Github/Api/Repo.php index 4698ebbc..4d8c012f 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repo.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repo.php @@ -181,6 +181,7 @@ class Repo extends AbstractApi * @param int $teamId The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization. * @param bool $autoInit `true` to create an initial commit with empty README, `false` for no initial commit * @param bool $hasProjects `true` to enable projects for this repository or false to disable them. + * @param string|null $visibility * * @return array returns repository data */ @@ -195,7 +196,8 @@ class Repo extends AbstractApi $hasDownloads = false, $teamId = null, $autoInit = false, - $hasProjects = true + $hasProjects = true, + $visibility = null ) { $path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos'; @@ -203,7 +205,7 @@ class Repo extends AbstractApi 'name' => $name, 'description' => $description, 'homepage' => $homepage, - 'private' => !$public, + 'visibility' => $visibility ?? ($public ? 'public' : 'private'), 'has_issues' => $hasIssues, 'has_wiki' => $hasWiki, 'has_downloads' => $hasDownloads, @@ -257,12 +259,20 @@ class Repo extends AbstractApi * @param string $username the user who owns the repository * @param string $repository the name of the repository * @param string $format one of formats: "raw", "html", or "v3+json" + * @param string $dir The alternate path to look for a README file + * @param array $params additional query params like "ref" to fetch readme for branch/tag * * @return string|array the readme content */ - public function readme($username, $repository, $format = 'raw') + public function readme($username, $repository, $format = 'raw', $dir = null, $params = []) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme', [], [ + $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme'; + + if (null !== $dir) { + $path .= '/'.rawurlencode($dir); + } + + return $this->get($path, $params, [ 'Accept' => "application/vnd.github.$format", ]); } @@ -323,7 +333,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#check-runs + * @link https://docs.github.com/en/rest/reference/checks#check-runs */ public function checkRuns(): CheckRuns { @@ -331,7 +341,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#check-suites + * @link https://docs.github.com/en/rest/reference/checks#check-suites */ public function checkSuites(): CheckSuites { @@ -347,7 +357,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflows + * @link https://docs.github.com/en/rest/reference/actions#workflows */ public function workflows(): Workflows { @@ -355,7 +365,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-runs + * @link https://docs.github.com/en/rest/reference/actions#workflow-runs */ public function workflowRuns(): WorkflowRuns { @@ -363,7 +373,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-jobs + * @link https://docs.github.com/en/rest/reference/actions#workflow-jobs */ public function workflowJobs(): WorkflowJobs { @@ -371,7 +381,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners + * @link https://docs.github.com/en/rest/reference/actions#self-hosted-runners */ public function selfHostedRunners(): SelfHostedRunners { @@ -379,7 +389,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#secrets + * @link https://docs.github.com/en/rest/reference/actions#secrets */ public function secrets(): Secrets { @@ -502,17 +512,18 @@ class Repo extends AbstractApi * @param string $username the username * @param string $repository the name of the repository * @param string $branch the name of the branch + * @param array $parameters parameters for the query string * * @return array list of the repository branches */ - public function branches($username, $repository, $branch = null) + public function branches($username, $repository, $branch = null, array $parameters = []) { $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches'; if (null !== $branch) { $url .= '/'.rawurlencode($branch); } - return $this->get($url); + return $this->get($url, $parameters); } /** @@ -617,7 +628,7 @@ class Repo extends AbstractApi * @param string $head The head to merge. This can be a branch name or a commit SHA1. * @param string $message Commit message to use for the merge commit. If omitted, a default message will be used. * - * @return array|null + * @return array|string */ public function merge($username, $repository, $base, $head, $message = null) { @@ -646,7 +657,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#enable-automated-security-fixes + * @link https://docs.github.com/en/rest/reference/repos#enable-automated-security-fixes * * @param string $username * @param string $repository @@ -661,7 +672,7 @@ class Repo extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#disable-automated-security-fixes + * @link https://docs.github.com/en/rest/reference/repos#disable-automated-security-fixes * * @param string $username * @param string $repository @@ -793,4 +804,19 @@ class Repo extends AbstractApi { return $this->post('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/transfer', ['new_owner' => $newOwner, 'team_id' => $teamId]); } + + /** + * Create a repository using a template. + * + * @link https://developer.github.com/v3/repos/#create-a-repository-using-a-template + * + * @return array + */ + public function createFromTemplate(string $templateOwner, string $templateRepo, array $parameters = []) + { + //This api is in preview mode, so set the correct accept-header + $this->acceptHeaderValue = 'application/vnd.github.baptiste-preview+json'; + + return $this->post('/repos/'.rawurldecode($templateOwner).'/'.rawurldecode($templateRepo).'/generate', $parameters); + } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Artifacts.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Artifacts.php index b81d560b..84f3b060 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Artifacts.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Artifacts.php @@ -5,12 +5,12 @@ namespace Github\Api\Repository\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#artifacts + * @link https://docs.github.com/en/rest/reference/actions#artifacts */ class Artifacts extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-artifacts-for-a-repository + * @link https://docs.github.com/en/rest/reference/actions#list-artifacts-for-a-repository * * @param string $username * @param string $repository @@ -24,7 +24,7 @@ class Artifacts extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-run-artifacts + * @link https://docs.github.com/en/rest/reference/actions#list-workflow-run-artifacts * * @param string $username * @param string $repository @@ -38,7 +38,7 @@ class Artifacts extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-artifact + * @link https://docs.github.com/en/rest/reference/actions#get-an-artifact * * @param string $username * @param string $repository @@ -52,7 +52,7 @@ class Artifacts extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-artifact + * @link https://docs.github.com/en/rest/reference/actions#delete-an-artifact * * @param string $username * @param string $repository @@ -66,7 +66,7 @@ class Artifacts extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact + * @link https://docs.github.com/en/rest/reference/actions#download-an-artifact * * @param string $username * @param string $repository diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Secrets.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Secrets.php index 4c38de20..2085a133 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Secrets.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Secrets.php @@ -5,12 +5,12 @@ namespace Github\Api\Repository\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#secrets + * @link https://docs.github.com/en/rest/reference/actions#secrets */ class Secrets extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-repository-secrets + * @link https://docs.github.com/en/rest/reference/actions#list-repository-secrets * * @param string $username * @param string $repository @@ -23,7 +23,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-repository-secret + * @link https://docs.github.com/en/rest/reference/actions#get-a-repository-secret * * @param string $username * @param string $repository @@ -37,7 +37,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-a-repository-secret + * @link https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret * * @param string $username * @param string $repository @@ -52,7 +52,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-a-repository-secret + * @link https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret * * @param string $username * @param string $repository @@ -67,7 +67,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-repository-secret + * @link https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret * * @param string $username * @param string $repository @@ -81,7 +81,7 @@ class Secrets extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-repository-public-key + * @link https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key * * @param string $username * @param string $repository @@ -90,6 +90,6 @@ class Secrets extends AbstractApi */ public function publicKey(string $username, string $repository) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/secret-key'); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/public-key'); } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/SelfHostedRunners.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/SelfHostedRunners.php index 4a20b116..7eb1a9d4 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/SelfHostedRunners.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/SelfHostedRunners.php @@ -5,12 +5,12 @@ namespace Github\Api\Repository\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners + * @link https://docs.github.com/en/rest/reference/actions#self-hosted-runners */ class SelfHostedRunners extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-self-hosted-runners-for-a-repository + * @link https://docs.github.com/en/rest/reference/actions#list-self-hosted-runners-for-a-repository * * @param string $username * @param string $repository @@ -23,7 +23,7 @@ class SelfHostedRunners extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-self-hosted-runner-for-a-repository + * @link https://docs.github.com/en/rest/reference/actions#get-a-self-hosted-runner-for-a-repository * * @param string $username * @param string $repository @@ -37,7 +37,7 @@ class SelfHostedRunners extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-self-hosted-runner-from-a-repository + * @link https://docs.github.com/en/rest/reference/actions#delete-a-self-hosted-runner-from-a-repository * * @param string $username * @param string $repository @@ -51,7 +51,7 @@ class SelfHostedRunners extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-runner-applications-for-a-repository + * @link https://docs.github.com/en/rest/reference/actions#list-runner-applications-for-a-repository * * @param string $username * @param string $repository diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowJobs.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowJobs.php index edcb806e..3167d3db 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowJobs.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowJobs.php @@ -5,12 +5,12 @@ namespace Github\Api\Repository\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-jobs + * @link https://docs.github.com/en/rest/reference/actions#workflow-jobs */ class WorkflowJobs extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-jobs-for-a-workflow-run + * @link https://docs.github.com/en/rest/reference/actions#list-jobs-for-a-workflow-run * * @param string $username * @param string $repository @@ -25,7 +25,7 @@ class WorkflowJobs extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-job-for-a-workflow-run + * @link https://docs.github.com/en/rest/reference/actions#get-a-job-for-a-workflow-run * * @param string $username * @param string $repository @@ -39,7 +39,7 @@ class WorkflowJobs extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-job-logs-for-a-workflow-run + * @link https://docs.github.com/en/rest/reference/actions#download-job-logs-for-a-workflow-run * * @param string $username * @param string $repository diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowRuns.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowRuns.php index 27213826..d6f95f1e 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowRuns.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/WorkflowRuns.php @@ -5,12 +5,12 @@ namespace Github\Api\Repository\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-runs + * @link https://docs.github.com/en/rest/reference/actions#workflow-runs */ class WorkflowRuns extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs-for-a-repository + * @link https://docs.github.com/en/rest/reference/actions#list-workflow-runs-for-a-repository * * @param string $username * @param string $repository @@ -24,22 +24,22 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs + * @link https://docs.github.com/en/rest/reference/actions#list-workflow-runs * * @param string $username * @param string $repository - * @param string $workflowId + * @param string $workflow * @param array $parameters * * @return array */ - public function listRuns(string $username, string $repository, string $workflowId, array $parameters = []) + public function listRuns(string $username, string $repository, string $workflow, array $parameters = []) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflowId.'/runs', $parameters); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.rawurlencode($workflow).'/runs', $parameters); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow-run + * @link https://docs.github.com/en/rest/reference/actions#get-a-workflow-run * * @param string $username * @param string $repository @@ -54,7 +54,7 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-workflow-run + * @link https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run * * @param string $username * @param string $repository @@ -68,7 +68,7 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#re-run-a-workflow + * @link https://docs.github.com/en/rest/reference/actions#re-run-a-workflow * * @param string $username * @param string $repository @@ -82,7 +82,7 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#cancel-a-workflow-run + * @link https://docs.github.com/en/rest/reference/actions#cancel-a-workflow-run * * @param string $username * @param string $repository @@ -96,7 +96,7 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-run-usage + * @link https://docs.github.com/en/rest/reference/actions#get-workflow-run-usage * * @param string $username * @param string $repository @@ -110,7 +110,7 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-workflow-run-logs + * @link https://docs.github.com/en/rest/reference/actions#download-workflow-run-logs * * @param string $username * @param string $repository @@ -124,7 +124,7 @@ class WorkflowRuns extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-workflow-run-logs + * @link https://docs.github.com/en/rest/reference/actions#delete-workflow-run-logs * * @param string $username * @param string $repository @@ -136,4 +136,20 @@ class WorkflowRuns extends AbstractApi { return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs'); } + + /** + * @link https://docs.github.com/en/rest/reference/actions#approve-a-workflow-run-for-a-fork-pull-request + * + * @param string $username + * @param string $repository + * @param int $runId + * + * @return array|string + * + * @experimental This endpoint is currently in beta. + */ + public function approve(string $username, string $repository, int $runId) + { + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/approve'); + } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Workflows.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Workflows.php index 3843c59a..e425f9d2 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Workflows.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Actions/Workflows.php @@ -5,12 +5,12 @@ namespace Github\Api\Repository\Actions; use Github\Api\AbstractApi; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflows + * @link https://docs.github.com/en/rest/reference/actions#workflows */ class Workflows extends AbstractApi { /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-repository-workflows + * @link https://docs.github.com/en/rest/reference/actions#list-repository-workflows * * @param string $username * @param string $repository @@ -24,30 +24,59 @@ class Workflows extends AbstractApi } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow + * @link https://docs.github.com/en/rest/reference/actions#get-a-workflow * - * @param string $username - * @param string $repository - * @param int $workflowId + * @param string $username + * @param string $repository + * @param string|int $workflow * * @return array */ - public function show(string $username, string $repository, int $workflowId) + public function show(string $username, string $repository, $workflow) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflowId); + if (is_string($workflow)) { + $workflow = rawurlencode($workflow); + } + + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-usage + * @link https://docs.github.com/en/rest/reference/actions#get-workflow-usage * - * @param string $username - * @param string $repository - * @param int $workflowId + * @param string $username + * @param string $repository + * @param string|int $workflow * * @return array|string */ - public function usage(string $username, string $repository, int $workflowId) + public function usage(string $username, string $repository, $workflow) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflowId.'/timing'); + if (is_string($workflow)) { + $workflow = rawurlencode($workflow); + } + + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow.'/timing'); + } + + /** + * @link https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event + * + * @param string $username + * @param string $repository + * @param string|int $workflow + * @param string $ref + * @param array $inputs + * + * @return array|string empty + */ + public function dispatches(string $username, string $repository, $workflow, string $ref, array $inputs = null) + { + if (is_string($workflow)) { + $workflow = rawurlencode($workflow); + } + $parameters = array_filter(['ref' => $ref, 'inputs' => $inputs]); + + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow.'/dispatches', $parameters); } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Assets.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Assets.php index 39cdc5da..043016e7 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Assets.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Assets.php @@ -3,6 +3,7 @@ namespace Github\Api\Repository; use Github\Api\AbstractApi; +use Github\Api\AcceptHeaderTrait; use Github\Exception\ErrorException; use Github\Exception\MissingArgumentException; @@ -13,6 +14,8 @@ use Github\Exception\MissingArgumentException; */ class Assets extends AbstractApi { + use AcceptHeaderTrait; + /** * Get all release's assets in selected repository * GET /repos/:owner/:repo/releases/:id/assets. @@ -36,10 +39,14 @@ class Assets extends AbstractApi * @param string $repository the name of the repo * @param int $id the id of the asset * - * @return array + * @return array|string */ - public function show($username, $repository, $id) + public function show($username, $repository, $id, bool $returnBinaryContent = false) { + if ($returnBinaryContent) { + $this->acceptHeaderValue = 'application/octet-stream'; + } + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id); } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckRuns.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckRuns.php index 6f91997e..37968a01 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckRuns.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckRuns.php @@ -3,69 +3,84 @@ namespace Github\Api\Repository\Checks; use Github\Api\AbstractApi; +use Github\Api\AcceptHeaderTrait; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks + * @link https://docs.github.com/en/rest/reference/checks */ class CheckRuns extends AbstractApi { + use AcceptHeaderTrait; + /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-run + * @link https://docs.github.com/en/rest/reference/checks#create-a-check-run * * @return array */ public function create(string $username, string $repository, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs', $params); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#get-a-check-run + * @link https://docs.github.com/en/rest/reference/checks#get-a-check-run * * @return array */ public function show(string $username, string $repository, int $checkRunId) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#update-a-check-run + * @link https://docs.github.com/en/rest/reference/checks#update-a-check-run * * @return array */ public function update(string $username, string $repository, int $checkRunId, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId, $params); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#list-check-run-annotations + * @link https://docs.github.com/en/rest/reference/checks#list-check-run-annotations * * @return array */ public function annotations(string $username, string $repository, int $checkRunId) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId.'/annotations'); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#list-check-runs-in-a-check-suite + * @link https://docs.github.com/en/rest/reference/checks#list-check-runs-in-a-check-suite * * @return array */ public function allForCheckSuite(string $username, string $repository, int $checkSuiteId, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/check-runs', $params); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#list-check-runs-for-a-git-reference + * @link https://docs.github.com/en/rest/reference/checks#list-check-runs-for-a-git-reference * * @return array */ public function allForReference(string $username, string $repository, string $ref, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params); } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckSuites.php b/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckSuites.php index d597fed5..40c83a56 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckSuites.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Repository/Checks/CheckSuites.php @@ -3,59 +3,72 @@ namespace Github\Api\Repository\Checks; use Github\Api\AbstractApi; +use Github\Api\AcceptHeaderTrait; /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks + * @link https://docs.github.com/en/rest/reference/checks */ class CheckSuites extends AbstractApi { + use AcceptHeaderTrait; + /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-suite + * @link https://docs.github.com/en/rest/reference/checks#create-a-check-suite * * @return array */ public function create(string $username, string $repository, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites', $params); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#update-repository-preferences-for-check-suites + * @link https://docs.github.com/en/rest/reference/checks#update-repository-preferences-for-check-suites * * @return array */ public function updatePreferences(string $username, string $repository, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/preferences', $params); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#get-a-check-suite + * @link https://docs.github.com/en/rest/reference/checks#get-a-check-suite * * @return array */ public function getCheckSuite(string $username, string $repository, int $checkSuiteId) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#rerequest-a-check-suite + * @link https://docs.github.com/en/rest/reference/checks#rerequest-a-check-suite * * @return array */ public function rerequest(string $username, string $repository, int $checkSuiteId) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/rerequest'); } /** - * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#list-check-suites-for-a-git-reference + * @link https://docs.github.com/en/rest/reference/checks#list-check-suites-for-a-git-reference * * @return array */ public function allForReference(string $username, string $repository, string $ref, array $params = []) { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-suites', $params); } } diff --git a/vendor/knplabs/github-api/lib/Github/Api/Search.php b/vendor/knplabs/github-api/lib/Github/Api/Search.php index 24bd59bb..96a51ea6 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/Search.php +++ b/vendor/knplabs/github-api/lib/Github/Api/Search.php @@ -61,6 +61,21 @@ class Search extends AbstractApi return $this->get('/search/code', ['q' => $q, 'sort' => $sort, 'order' => $order]); } + /** + * Search code by filter (q), but will return additional data to highlight + * the matched results. + * + * @link https://docs.github.com/en/rest/reference/search#text-match-metadata + * + * @return array list of code found + */ + public function codeWithMatch(string $q, string $sort = 'updated', string $order = 'desc'): array + { + $this->acceptHeaderValue = 'application/vnd.github.v3.text-match+json'; + + return $this->code($q, $sort, $order); + } + /** * Search users by filter (q). * diff --git a/vendor/knplabs/github-api/lib/Github/Api/User.php b/vendor/knplabs/github-api/lib/Github/Api/User.php index b36ae471..c1ccc89e 100644 --- a/vendor/knplabs/github-api/lib/Github/Api/User.php +++ b/vendor/knplabs/github-api/lib/Github/Api/User.php @@ -234,4 +234,16 @@ class User extends AbstractApi { return $this->get('/users/'.rawurlencode($username).'/events/public'); } + + /** + * List events performed by an authenticated user. + * + * @link https://docs.github.com/en/rest/reference/activity#list-events-for-the-authenticated-user + * + * @return array + */ + public function events(string $username) + { + return $this->get('/users/'.rawurlencode($username).'/events'); + } } diff --git a/vendor/knplabs/github-api/lib/Github/AuthMethod.php b/vendor/knplabs/github-api/lib/Github/AuthMethod.php new file mode 100644 index 00000000..4a390699 --- /dev/null +++ b/vendor/knplabs/github-api/lib/Github/AuthMethod.php @@ -0,0 +1,30 @@ +responseHistory = new History(); $this->httpClientBuilder = $builder = $httpClientBuilder ?? new Builder(); + $this->apiVersion = $apiVersion ?: 'v3'; $builder->addPlugin(new GithubExceptionThrower()); $builder->addPlugin(new Plugin\HistoryPlugin($this->responseHistory)); @@ -126,11 +133,9 @@ class Client $builder->addPlugin(new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('https://api.github.com'))); $builder->addPlugin(new Plugin\HeaderDefaultsPlugin([ 'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)', + 'Accept' => sprintf('application/vnd.github.%s+json', $this->apiVersion), ])); - $this->apiVersion = $apiVersion ?: 'v3'; - $builder->addHeaderValue('Accept', sprintf('application/vnd.github.%s+json', $this->apiVersion)); - if ($enterpriseUrl) { $this->setEnterpriseUrl($enterpriseUrl); } @@ -314,7 +319,7 @@ class Client */ public function authenticate($tokenOrLogin, $password = null, $authMethod = null): void { - if (null === $authMethod && (self::AUTH_JWT === $password || self::AUTH_ACCESS_TOKEN === $password)) { + if (null === $authMethod && (AuthMethod::JWT === $password || AuthMethod::ACCESS_TOKEN === $password)) { $authMethod = $password; $password = null; } @@ -341,7 +346,14 @@ class Client $builder->removePlugin(PathPrepend::class); $builder->addPlugin(new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri($enterpriseUrl))); - $builder->addPlugin(new PathPrepend(sprintf('/api/%s', $this->getApiVersion()))); + + // For GHE, v4 API endpoint is at `api/graphql` so we don't want to add the version number + // For earlier versions add the version number after /api + if ($this->getApiVersion() === 'v4') { + $builder->addPlugin(new PathPrepend('/api')); + } else { + $builder->addPlugin(new PathPrepend(sprintf('/api/%s', $this->getApiVersion()))); + } } /** diff --git a/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/Authentication.php b/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/Authentication.php index 2b533436..91ed9caa 100644 --- a/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/Authentication.php +++ b/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/Authentication.php @@ -2,7 +2,7 @@ namespace Github\HttpClient\Plugin; -use Github\Client; +use Github\AuthMethod; use Github\Exception\RuntimeException; use Http\Client\Common\Plugin; use Http\Promise\Promise; @@ -58,11 +58,11 @@ final class Authentication implements Plugin private function getAuthorizationHeader(): string { switch ($this->method) { - case Client::AUTH_CLIENT_ID: + case AuthMethod::CLIENT_ID: return sprintf('Basic %s', base64_encode($this->tokenOrLogin.':'.$this->password)); - case Client::AUTH_ACCESS_TOKEN: + case AuthMethod::ACCESS_TOKEN: return sprintf('token %s', $this->tokenOrLogin); - case Client::AUTH_JWT: + case AuthMethod::JWT: return sprintf('Bearer %s', $this->tokenOrLogin); default: throw new RuntimeException(sprintf('%s not yet implemented', $this->method)); diff --git a/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php b/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php index e4adb6a5..4603f629 100644 --- a/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php +++ b/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php @@ -34,7 +34,7 @@ final class GithubExceptionThrower implements Plugin // If error: $remaining = ResponseMediator::getHeader($response, 'X-RateLimit-Remaining'); - if (null !== $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) { + if ((429 === $response->getStatusCode()) && null !== $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) { $limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit'); $reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset'); @@ -56,7 +56,7 @@ final class GithubExceptionThrower implements Plugin if (422 === $response->getStatusCode() && isset($content['errors'])) { $errors = []; foreach ($content['errors'] as $error) { - switch ($error['code']) { + switch ($error['code'] ?? null) { case 'missing': $errors[] = sprintf('The %s %s does not exist, for resource "%s"', $error['field'], $error['value'], $error['resource']); break; @@ -78,6 +78,12 @@ final class GithubExceptionThrower implements Plugin break; default: + if (is_string($error)) { + $errors[] = $error; + + break; + } + if (isset($error['message'])) { $errors[] = $error['message']; } diff --git a/vendor/knplabs/github-api/lib/Github/ResultPager.php b/vendor/knplabs/github-api/lib/Github/ResultPager.php index 5f9c40d0..cfd1d605 100644 --- a/vendor/knplabs/github-api/lib/Github/ResultPager.php +++ b/vendor/knplabs/github-api/lib/Github/ResultPager.php @@ -86,7 +86,7 @@ class ResultPager implements ResultPagerInterface $api = $closure($api); $result = $api->$method(...$parameters); - $this->postFetch(); + $this->postFetch(true); return $result; } @@ -130,9 +130,13 @@ class ResultPager implements ResultPagerInterface /** * {@inheritdoc} */ - public function postFetch(): void + public function postFetch(/* $skipDeprecation = false */): void { - $this->pagination = ResponseMediator::getPagination($this->client->getLastResponse()); + if (func_num_args() === 0 || (func_num_args() > 0 && false === func_get_arg(0))) { + trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" method is deprecated and will be removed.', __METHOD__); + } + + $this->setPagination(); } /** @@ -196,8 +200,13 @@ class ResultPager implements ResultPagerInterface $result = $this->client->getHttpClient()->get($this->pagination[$key]); - $this->postFetch(); + $this->postFetch(true); return ResponseMediator::getContent($result); } + + private function setPagination(): void + { + $this->pagination = ResponseMediator::getPagination($this->client->getLastResponse()); + } } diff --git a/vendor/knplabs/github-api/lib/Github/ResultPagerInterface.php b/vendor/knplabs/github-api/lib/Github/ResultPagerInterface.php index 350f8453..bf7618ee 100644 --- a/vendor/knplabs/github-api/lib/Github/ResultPagerInterface.php +++ b/vendor/knplabs/github-api/lib/Github/ResultPagerInterface.php @@ -54,6 +54,8 @@ interface ResultPagerInterface /** * Method that performs the actual work to refresh the pagination property. * + * @deprecated since 3.2 and will be removed in 4.0. + * * @return void */ public function postFetch(): void; diff --git a/vendor/psr/cache/README.md b/vendor/psr/cache/README.md index c8706cee..9855a318 100644 --- a/vendor/psr/cache/README.md +++ b/vendor/psr/cache/README.md @@ -1,9 +1,12 @@ -PSR Cache -========= +Caching Interface +============== -This repository holds all interfaces defined by -[PSR-6](http://www.php-fig.org/psr/psr-6/). +This repository holds all interfaces related to [PSR-6 (Caching Interface)][psr-url]. -Note that this is not a Cache implementation of its own. It is merely an -interface that describes a Cache implementation. See the specification for more -details. +Note that this is not a Caching implementation of its own. It is merely interfaces that describe the components of a Caching mechanism. + +The installable [package][package-url] and [implementations][implementation-url] are listed on Packagist. + +[psr-url]: https://www.php-fig.org/psr/psr-6/ +[package-url]: https://packagist.org/packages/psr/cache +[implementation-url]: https://packagist.org/providers/psr/cache-implementation diff --git a/vendor/psr/cache/composer.json b/vendor/psr/cache/composer.json index e828fec9..4b687971 100644 --- a/vendor/psr/cache/composer.json +++ b/vendor/psr/cache/composer.json @@ -6,11 +6,11 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "autoload": { "psr-4": { diff --git a/vendor/psr/cache/src/CacheException.php b/vendor/psr/cache/src/CacheException.php index e27f22f8..bb785f46 100644 --- a/vendor/psr/cache/src/CacheException.php +++ b/vendor/psr/cache/src/CacheException.php @@ -5,6 +5,6 @@ namespace Psr\Cache; /** * Exception interface for all exceptions thrown by an Implementing Library. */ -interface CacheException +interface CacheException extends \Throwable { } diff --git a/vendor/psr/cache/src/CacheItemInterface.php b/vendor/psr/cache/src/CacheItemInterface.php index 63d05dd1..2b2e4bb8 100644 --- a/vendor/psr/cache/src/CacheItemInterface.php +++ b/vendor/psr/cache/src/CacheItemInterface.php @@ -32,7 +32,7 @@ interface CacheItemInterface * @return string * The key string for this cache item. */ - public function getKey(); + public function getKey(): string; /** * Retrieves the value of the item from the cache associated with this object's key. @@ -46,7 +46,7 @@ interface CacheItemInterface * @return mixed * The value corresponding to this cache item's key, or null if not found. */ - public function get(); + public function get(): mixed; /** * Confirms if the cache item lookup resulted in a cache hit. @@ -57,7 +57,7 @@ interface CacheItemInterface * @return bool * True if the request resulted in a cache hit. False otherwise. */ - public function isHit(); + public function isHit(): bool; /** * Sets the value represented by this cache item. @@ -72,12 +72,12 @@ interface CacheItemInterface * @return static * The invoked object. */ - public function set($value); + public function set(mixed $value): static; /** * Sets the expiration time for this cache item. * - * @param \DateTimeInterface|null $expiration + * @param ?\DateTimeInterface $expiration * The point in time after which the item MUST be considered expired. * If null is passed explicitly, a default value MAY be used. If none is set, * the value should be stored permanently or for as long as the @@ -86,7 +86,7 @@ interface CacheItemInterface * @return static * The called object. */ - public function expiresAt($expiration); + public function expiresAt(?\DateTimeInterface $expiration): static; /** * Sets the expiration time for this cache item. @@ -101,5 +101,5 @@ interface CacheItemInterface * @return static * The called object. */ - public function expiresAfter($time); + public function expiresAfter(int|\DateInterval|null $time): static; } diff --git a/vendor/psr/cache/src/CacheItemPoolInterface.php b/vendor/psr/cache/src/CacheItemPoolInterface.php index 03514196..4b3017c7 100644 --- a/vendor/psr/cache/src/CacheItemPoolInterface.php +++ b/vendor/psr/cache/src/CacheItemPoolInterface.php @@ -29,7 +29,7 @@ interface CacheItemPoolInterface * @return CacheItemInterface * The corresponding Cache Item. */ - public function getItem($key); + public function getItem(string $key): CacheItemInterface; /** * Returns a traversable set of cache items. @@ -41,13 +41,13 @@ interface CacheItemPoolInterface * If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException * MUST be thrown. * - * @return array|\Traversable - * A traversable collection of Cache Items keyed by the cache keys of + * @return iterable + * An iterable collection of Cache Items keyed by the cache keys of * each item. A Cache item will be returned for each key, even if that * key is not found. However, if no keys are specified then an empty * traversable MUST be returned instead. */ - public function getItems(array $keys = array()); + public function getItems(array $keys = []): iterable; /** * Confirms if the cache contains specified cache item. @@ -66,7 +66,7 @@ interface CacheItemPoolInterface * @return bool * True if item exists in the cache, false otherwise. */ - public function hasItem($key); + public function hasItem(string $key): bool; /** * Deletes all items in the pool. @@ -74,7 +74,7 @@ interface CacheItemPoolInterface * @return bool * True if the pool was successfully cleared. False if there was an error. */ - public function clear(); + public function clear(): bool; /** * Removes the item from the pool. @@ -89,14 +89,14 @@ interface CacheItemPoolInterface * @return bool * True if the item was successfully removed. False if there was an error. */ - public function deleteItem($key); + public function deleteItem(string $key): bool; /** * Removes multiple items from the pool. * * @param string[] $keys * An array of keys that should be removed from the pool. - + * * @throws InvalidArgumentException * If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException * MUST be thrown. @@ -104,7 +104,7 @@ interface CacheItemPoolInterface * @return bool * True if the items were successfully removed. False if there was an error. */ - public function deleteItems(array $keys); + public function deleteItems(array $keys): bool; /** * Persists a cache item immediately. @@ -115,7 +115,7 @@ interface CacheItemPoolInterface * @return bool * True if the item was successfully persisted. False if there was an error. */ - public function save(CacheItemInterface $item); + public function save(CacheItemInterface $item): bool; /** * Sets a cache item to be persisted later. @@ -126,7 +126,7 @@ interface CacheItemPoolInterface * @return bool * False if the item could not be queued or if a commit was attempted and failed. True otherwise. */ - public function saveDeferred(CacheItemInterface $item); + public function saveDeferred(CacheItemInterface $item): bool; /** * Persists any deferred cache items. @@ -134,5 +134,5 @@ interface CacheItemPoolInterface * @return bool * True if all not-yet-saved items were successfully saved or there were none. False otherwise. */ - public function commit(); + public function commit(): bool; }