diff --git a/composer.json b/composer.json index 6549d5c..a808219 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ ], "require": { "php": "^7.0", - "api-clients/middleware": "^2.0", + "api-clients/middleware": "^4.0", "joshdifabio/composed": "^1.0", "ocramius/package-versions": "^1.1", "psr/http-message": "^1.0" diff --git a/composer.lock b/composer.lock index b5e74e6..d34bcec 100644 --- a/composer.lock +++ b/composer.lock @@ -4,38 +4,40 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "3b86bf4d591946265de107aee20de777", + "content-hash": "099783c259018a6dbd9cea39b28aedf4", "packages": [ { "name": "api-clients/middleware", - "version": "2.0.1", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/php-api-clients/middleware.git", - "reference": "e25852d9d4d3092cc657b7660a413f6e73ea8c4d" + "reference": "328f8e17bbf5a51107de0d1b5987c04757f66499" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-api-clients/middleware/zipball/e25852d9d4d3092cc657b7660a413f6e73ea8c4d", - "reference": "e25852d9d4d3092cc657b7660a413f6e73ea8c4d", + "url": "https://api.github.com/repos/php-api-clients/middleware/zipball/328f8e17bbf5a51107de0d1b5987c04757f66499", + "reference": "328f8e17bbf5a51107de0d1b5987c04757f66499", "shasum": "" }, "require": { + "doctrine/annotations": "^1.4", "php": "^7.0", "psr/http-message": "^1.0", - "react/promise": "^2.4" + "react/promise": "^2.4", + "wyrihaximus/doctrine-annotation-autoloader": "^1.0" }, "require-dev": { - "api-clients/test-utilities": "^3.0", - "container-interop/container-interop": "^1.1", - "guzzlehttp/psr7": "^1.3" + "api-clients/test-utilities": "^4.1", + "guzzlehttp/psr7": "^1.3", + "psr/container": "^1.0" }, "suggest": { "api-clients/middleware-cache": "Cache requests with different strategies", "api-clients/middleware-log": "Log requests and their context", "api-clients/middleware-oauth1": "Sign requests with oauth1", "api-clients/middleware-pool": "Pool the maximum concurrent requests", - "container-interop/container-interop": "Add a ContainerInterface implementation to use the ContainerLocator" + "psr/container": "Add a ContainerInterface implementation to use the ContainerLocator" }, "type": "library", "autoload": { @@ -54,7 +56,129 @@ } ], "description": "Request middleware", - "time": "2017-04-08T07:00:13+00:00" + "time": "2017-06-28T19:24:19+00:00" + }, + { + "name": "doctrine/annotations", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-02-24T16:22:25+00:00" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09T13:34:57+00:00" }, { "name": "joshdifabio/composed", @@ -248,6 +372,42 @@ "promises" ], "time": "2017-03-25T12:08:31+00:00" + }, + { + "name": "wyrihaximus/doctrine-annotation-autoloader", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-doctrine-annotation-autoloader.git", + "reference": "9670f84b7d3ca53723556988080ebc939da345af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-doctrine-annotation-autoloader/zipball/9670f84b7d3ca53723556988080ebc939da345af", + "reference": "9670f84b7d3ca53723556988080ebc939da345af", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.4" + }, + "type": "library", + "autoload": { + "files": [ + "src/bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "Request middleware", + "time": "2017-06-19T15:02:15+00:00" } ], "packages-dev": [ diff --git a/examples/benchmark.php b/examples/benchmark.php index 04c3c92..426b00c 100644 --- a/examples/benchmark.php +++ b/examples/benchmark.php @@ -18,6 +18,6 @@ $start = time(); for ($i = 0; $i < 1000000; $i++) { - $middleware->pre(clone $request, $options); + $middleware->pre(clone $request, bin2hex(random_bytes(32)), $options); } echo 'Took: ', (time() - $start), ' seconds', PHP_EOL; \ No newline at end of file diff --git a/src/UserAgentMiddleware.php b/src/UserAgentMiddleware.php index 2b9babb..a2c11d2 100644 --- a/src/UserAgentMiddleware.php +++ b/src/UserAgentMiddleware.php @@ -12,7 +12,6 @@ final class UserAgentMiddleware implements MiddlewareInterface { - use DefaultPriorityTrait; use PostTrait; use ErrorTrait; @@ -23,8 +22,11 @@ final class UserAgentMiddleware implements MiddlewareInterface * @param array $options * @return CancellablePromiseInterface */ - public function pre(RequestInterface $request, array $options = []): CancellablePromiseInterface - { + public function pre( + RequestInterface $request, + string $transactionId, + array $options = [] + ): CancellablePromiseInterface { if (!isset($options[UserAgentMiddleware::class][Options::STRATEGY])) { return resolve($request); } diff --git a/tests/UserAgentMiddlewareTest.php b/tests/UserAgentMiddlewareTest.php index f210279..20dade5 100644 --- a/tests/UserAgentMiddlewareTest.php +++ b/tests/UserAgentMiddlewareTest.php @@ -14,17 +14,6 @@ final class UserAgentMiddlewareTest extends TestCase { - /** - * Ensure we run second last so the last can be logging or so that stores information. - */ - public function testPriority() - { - self::assertSame( - Priority::DEFAULT, - (new UserAgentMiddleware())->priority() - ); - } - public function testPre() { $request = new Request('GET', 'https://example.com/'); @@ -35,6 +24,7 @@ public function testPre() await( (new UserAgentMiddleware())->pre( $request, + 'abc', [ UserAgentMiddleware::class => [ Options::STRATEGY => StringStrategy::class,