Skip to content

Commit 51144d8

Browse files
committed
Make plugin classes final, related #18
1 parent 52b23ee commit 51144d8

14 files changed

+15
-57
lines changed

src/Plugin/AddHostPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
* Add schema and host to a request. Can be set to overwrite the schema and host if desired.
1212
*
1313
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
14-
*
15-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1614
*/
17-
/*final*/ class AddHostPlugin implements Plugin
15+
final class AddHostPlugin implements Plugin
1816
{
1917
/**
2018
* @var UriInterface

src/Plugin/AuthenticationPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* Send an authenticated request.
1111
*
1212
* @author Joel Wurtz <joel.wurtz@gmail.com>
13-
*
14-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1513
*/
16-
/*final*/ class AuthenticationPlugin implements Plugin
14+
final class AuthenticationPlugin implements Plugin
1715
{
1816
/**
1917
* @var Authentication An authentication system

src/Plugin/ContentLengthPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* Allow to set the correct content length header on the request or to transfer it as a chunk if not possible.
1111
*
1212
* @author Joel Wurtz <joel.wurtz@gmail.com>
13-
*
14-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1513
*/
16-
/*final*/ class ContentLengthPlugin implements Plugin
14+
final class ContentLengthPlugin implements Plugin
1715
{
1816
/**
1917
* {@inheritdoc}

src/Plugin/CookiePlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
* Handle request cookies.
1313
*
1414
* @author Joel Wurtz <joel.wurtz@gmail.com>
15-
*
16-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1715
*/
18-
/*final*/ class CookiePlugin implements Plugin
16+
final class CookiePlugin implements Plugin
1917
{
2018
/**
2119
* Cookie storage.

src/Plugin/DecoderPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
* If Content-Encoding is not disabled, the plugin will add an Accept-Encoding header for the encoding methods it supports.
1818
*
1919
* @author Joel Wurtz <joel.wurtz@gmail.com>
20-
*
21-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
2220
*/
23-
/*final*/ class DecoderPlugin implements Plugin
21+
final class DecoderPlugin implements Plugin
2422
{
2523
/**
2624
* @var bool Whether this plugin decode stream with value in the Content-Encoding header (default to true).

src/Plugin/ErrorPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
* By default an exception will be thrown for all status codes from 400 to 599.
1515
*
1616
* @author Joel Wurtz <joel.wurtz@gmail.com>
17-
*
18-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1917
*/
20-
/*final*/ class ErrorPlugin implements Plugin
18+
final class ErrorPlugin implements Plugin
2119
{
2220
/**
2321
* {@inheritdoc}

src/Plugin/HeaderAppendPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
* @link https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
1515
*
1616
* @author Soufiane Ghzal <sghzal@gmail.com>
17-
*
18-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1917
*/
20-
/*final*/ class HeaderAppendPlugin implements Plugin
18+
final class HeaderAppendPlugin implements Plugin
2119
{
2220
/**
2321
* @var array

src/Plugin/HeaderDefaultsPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* If a given header already exists the value wont be replaced and the request wont be changed.
1111
*
1212
* @author Soufiane Ghzal <sghzal@gmail.com>
13-
*
14-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1513
*/
16-
/*final*/ class HeaderDefaultsPlugin implements Plugin
14+
final class HeaderDefaultsPlugin implements Plugin
1715
{
1816
/**
1917
* @var array

src/Plugin/HeaderRemovePlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
* Removes headers from the request.
1010
*
1111
* @author Soufiane Ghzal <sghzal@gmail.com>
12-
*
13-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1412
*/
15-
/*final*/ class HeaderRemovePlugin implements Plugin
13+
final class HeaderRemovePlugin implements Plugin
1614
{
1715
/**
1816
* @var array

src/Plugin/HeaderSetPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* If the header does not exist it wil be set, if the header already exists it will be replaced.
1111
*
1212
* @author Soufiane Ghzal <sghzal@gmail.com>
13-
*
14-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1513
*/
16-
/*final*/ class HeaderSetPlugin implements Plugin
14+
final class HeaderSetPlugin implements Plugin
1715
{
1816
/**
1917
* @var array

src/Plugin/HistoryPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
* Record HTTP calls.
1212
*
1313
* @author Joel Wurtz <joel.wurtz@gmail.com>
14-
*
15-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1614
*/
17-
/*final*/ class HistoryPlugin implements Plugin
15+
final class HistoryPlugin implements Plugin
1816
{
1917
/**
2018
* Journal use to store request / responses / exception.

src/Plugin/RedirectPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
* Follow redirections.
1717
*
1818
* @author Joel Wurtz <joel.wurtz@gmail.com>
19-
*
20-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
2119
*/
22-
/*final*/ class RedirectPlugin implements Plugin
20+
class RedirectPlugin implements Plugin
2321
{
2422
/**
2523
* Rule on how to redirect, change method for the new request.

src/Plugin/RetryPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
* By default will retry only one time.
1515
*
1616
* @author Joel Wurtz <joel.wurtz@gmail.com>
17-
*
18-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
1917
*/
20-
/*final*/ class RetryPlugin implements Plugin
18+
final class RetryPlugin implements Plugin
2119
{
2220
/**
2321
* Number of retry before sending an exception.

src/PluginClient.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
* The client managing plugins and providing a decorator around HTTP Clients.
1616
*
1717
* @author Joel Wurtz <joel.wurtz@gmail.com>
18-
*
19-
* TODO: make class final in version 2.0, once plugins does not extend it anymore.
2018
*/
21-
/*final*/ class PluginClient implements HttpClient, HttpAsyncClient
19+
final class PluginClient implements HttpClient, HttpAsyncClient
2220
{
2321
/**
2422
* An HTTP async client.
@@ -140,7 +138,7 @@ private function createPluginChain($pluginList, callable $clientCallable)
140138
$firstCalls = 0;
141139
$firstCallable = function (RequestInterface $request) use ($lastCallable, &$firstCalls) {
142140
if ($firstCalls > $this->options['max_restarts']) {
143-
throw $this->createLoopException($request);
141+
return new LoopException('Too many restarts in plugin client', $request);
144142
}
145143

146144
++$firstCalls;
@@ -150,18 +148,4 @@ private function createPluginChain($pluginList, callable $clientCallable)
150148

151149
return $firstCallable;
152150
}
153-
154-
/**
155-
* Creates a new loop exception.
156-
*
157-
* @param RequestInterface $request
158-
*
159-
* @return LoopException
160-
*
161-
* TODO: Remove once plugin client is removed from plugins.
162-
*/
163-
protected function createLoopException(RequestInterface $request)
164-
{
165-
return new LoopException('Too many restarts in plugin client', $request);
166-
}
167151
}

0 commit comments

Comments
 (0)