From f31c713610107f21527fa6d480597552046e9ce4 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 17 Aug 2017 13:40:22 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/CacheInvalidator.php | 30 +++++++++---------- src/Exception/InvalidUrlException.php | 2 +- src/Exception/MissingHostException.php | 2 +- src/Exception/ProxyResponseException.php | 10 +++---- src/Exception/ProxyUnreachableException.php | 8 ++--- .../UnsupportedProxyOperationException.php | 2 +- src/Handler/TagHandler.php | 14 ++++----- src/ProxyClient/AbstractProxyClient.php | 6 ++-- src/ProxyClient/Invalidation/BanInterface.php | 15 +++++----- .../Invalidation/PurgeInterface.php | 2 +- .../Invalidation/RefreshInterface.php | 2 +- src/ProxyClient/Nginx.php | 2 +- src/ProxyClient/ProxyClientInterface.php | 4 +-- src/ProxyClient/Symfony.php | 2 +- src/ProxyClient/Varnish.php | 4 +-- .../AccessControlledSubscriber.php | 10 +++---- src/SymfonyCache/CacheEvent.php | 6 ++-- src/SymfonyCache/UserContextSubscriber.php | 2 +- src/Test/NginxTestCase.php | 2 +- src/Test/VarnishTestCase.php | 2 +- src/UserContext/HashGenerator.php | 2 +- .../Varnish/UserContextTestCase.php | 2 +- tests/Unit/CacheInvalidatorTest.php | 5 ++++ .../ProxyClient/AbstractProxyClientTest.php | 5 ++-- 24 files changed, 74 insertions(+), 67 deletions(-) diff --git a/src/CacheInvalidator.php b/src/CacheInvalidator.php index 89969c77..9a9e40c6 100644 --- a/src/CacheInvalidator.php +++ b/src/CacheInvalidator.php @@ -96,7 +96,7 @@ public function __construct(ProxyClientInterface $cache) * refreshPath works and INVALIDATE is about all other invalidation * methods. * - * @param string $operation one of the class constants. + * @param string $operation one of the class constants * * @return bool * @@ -123,7 +123,7 @@ public function supports($operation) * * @return $this * - * @throws \Exception When trying to override the event dispatcher. + * @throws \Exception when trying to override the event dispatcher */ public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) { @@ -156,7 +156,7 @@ public function getEventDispatcher() * * @return $this * - * @deprecated Use getEventDispatcher()->addSubscriber($subscriber) instead. + * @deprecated use getEventDispatcher()->addSubscriber($subscriber) instead */ public function addSubscriber(EventSubscriberInterface $subscriber) { @@ -172,7 +172,7 @@ public function addSubscriber(EventSubscriberInterface $subscriber) * * @return $this * - * @deprecated Use constructor argument to TagHandler instead. + * @deprecated use constructor argument to TagHandler instead */ public function setTagsHeader($tagsHeader) { @@ -188,7 +188,7 @@ public function setTagsHeader($tagsHeader) * * @return string * - * @deprecated Use TagHandler::getTagsHeaderName instead. + * @deprecated use TagHandler::getTagsHeaderName instead */ public function getTagsHeader() { @@ -247,7 +247,7 @@ public function refreshPath($path, array $headers = array()) * * @see BanInterface::ban() * - * @param array $headers HTTP headers that path must match to be banned. + * @param array $headers HTTP headers that path must match to be banned * * @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests * @@ -275,12 +275,12 @@ public function invalidate(array $headers) * * @see BanInterface::banPath() * - * @param string $path Regular expression pattern for URI to - * invalidate. - * @param string $contentType Regular expression pattern for the content - * type to limit banning, for instance 'text'. - * @param array|string $hosts Regular expression of a host name or list of - * exact host names to limit banning. + * @param string $path regular expression pattern for URI to + * invalidate + * @param string $contentType regular expression pattern for the content + * type to limit banning, for instance 'text' + * @param array|string $hosts regular expression of a host name or list of + * exact host names to limit banning * * @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests * @@ -307,7 +307,7 @@ public function invalidateRegex($path, $contentType = null, $hosts = null) * * @return $this * - * @deprecated Use TagHandler::invalidateTags instead. + * @deprecated use TagHandler::invalidateTags instead */ public function invalidateTags(array $tags) { @@ -323,9 +323,9 @@ public function invalidateTags(array $tags) /** * Send all pending invalidation requests. * - * @return int The number of cache invalidations performed per caching server. + * @return int the number of cache invalidations performed per caching server * - * @throws ExceptionCollection If any errors occurred during flush. + * @throws ExceptionCollection if any errors occurred during flush */ public function flush() { diff --git a/src/Exception/InvalidUrlException.php b/src/Exception/InvalidUrlException.php index ad49258c..fec85323 100644 --- a/src/Exception/InvalidUrlException.php +++ b/src/Exception/InvalidUrlException.php @@ -17,7 +17,7 @@ class InvalidUrlException extends InvalidArgumentException implements HttpCacheExceptionInterface { /** - * @param string $url The invalid URL. + * @param string $url the invalid URL * @param string $reason Further explanation why the URL was invalid (optional) * * @return InvalidUrlException diff --git a/src/Exception/MissingHostException.php b/src/Exception/MissingHostException.php index d1695bb3..9fb32338 100644 --- a/src/Exception/MissingHostException.php +++ b/src/Exception/MissingHostException.php @@ -18,7 +18,7 @@ class MissingHostException extends \RuntimeException implements HttpCacheExceptionInterface { /** - * @param string $path The path that was asked to be invalidated. + * @param string $path the path that was asked to be invalidated * * @return MissingHostException */ diff --git a/src/Exception/ProxyResponseException.php b/src/Exception/ProxyResponseException.php index 445ac7db..c809129d 100644 --- a/src/Exception/ProxyResponseException.php +++ b/src/Exception/ProxyResponseException.php @@ -17,11 +17,11 @@ class ProxyResponseException extends \RuntimeException implements HttpCacheExceptionInterface { /** - * @param string $host The host name that was contacted. - * @param string $statusCode The status code of the reply. - * @param string $statusMessage The error message. - * @param string $details Further details about the request that caused the error. - * @param \Exception $previous The exception from the HTTP client. + * @param string $host the host name that was contacted + * @param string $statusCode the status code of the reply + * @param string $statusMessage the error message + * @param string $details further details about the request that caused the error + * @param \Exception $previous the exception from the HTTP client * * @return ProxyUnreachableException */ diff --git a/src/Exception/ProxyUnreachableException.php b/src/Exception/ProxyUnreachableException.php index 3f1f94c5..54035a66 100644 --- a/src/Exception/ProxyUnreachableException.php +++ b/src/Exception/ProxyUnreachableException.php @@ -18,10 +18,10 @@ class ProxyUnreachableException extends \RuntimeException implements HttpCacheExceptionInterface { /** - * @param string $host The host name that was contacted. - * @param string $message The error message from the HTTP client. - * @param string $details Further details about the request that caused the error. - * @param \Exception $previous The exception from the HTTP client. + * @param string $host the host name that was contacted + * @param string $message the error message from the HTTP client + * @param string $details further details about the request that caused the error + * @param \Exception $previous the exception from the HTTP client * * @return ProxyUnreachableException */ diff --git a/src/Exception/UnsupportedProxyOperationException.php b/src/Exception/UnsupportedProxyOperationException.php index 4970c83d..526377ec 100644 --- a/src/Exception/UnsupportedProxyOperationException.php +++ b/src/Exception/UnsupportedProxyOperationException.php @@ -18,7 +18,7 @@ class UnsupportedProxyOperationException extends \RuntimeException implements HttpCacheExceptionInterface { /** - * @param string $method Name of the HTTP method that would be required. + * @param string $method name of the HTTP method that would be required * * @return UnsupportedProxyOperationException */ diff --git a/src/Handler/TagHandler.php b/src/Handler/TagHandler.php index 47566b7e..b7f8c928 100644 --- a/src/Handler/TagHandler.php +++ b/src/Handler/TagHandler.php @@ -45,9 +45,9 @@ class TagHandler /** * Constructor. * - * @param CacheInvalidator $invalidator The invalidator instance. - * @param string $tagsHeader Header to use for tags, defaults to X-Cache-Tags. - * @param int $headerLength Maximum header size in bytes, defaults to 7500. + * @param CacheInvalidator $invalidator the invalidator instance + * @param string $tagsHeader header to use for tags, defaults to X-Cache-Tags + * @param int $headerLength maximum header size in bytes, defaults to 7500 * * @throws UnsupportedProxyOperationException If CacheInvalidator does not support invalidate requests */ @@ -96,7 +96,7 @@ public function getTagsHeaderValue() /** * Check whether the tag handler has any tags to set on the response. * - * @return bool True if this handler will set at least one tag. + * @return bool true if this handler will set at least one tag */ public function hasTags() { @@ -108,7 +108,7 @@ public function hasTags() * * This must be called before any HTTP response is sent to the client. * - * @param array $tags List of tags to add. + * @param array $tags list of tags to add * * @return $this */ @@ -154,9 +154,9 @@ public function invalidateTags(array $tags) /** * Make sure that the tags are valid. * - * @param array $tags The tags to escape. + * @param array $tags the tags to escape * - * @return array Sane tags. + * @return array sane tags */ protected function escapeTags(array $tags) { diff --git a/src/ProxyClient/AbstractProxyClient.php b/src/ProxyClient/AbstractProxyClient.php index 957ca425..1fd596c8 100644 --- a/src/ProxyClient/AbstractProxyClient.php +++ b/src/ProxyClient/AbstractProxyClient.php @@ -153,7 +153,7 @@ protected function queueRequest($method, $url, array $headers = array()) * @param string $url URL * @param array $headers HTTP headers * - * @return string A hash value for this request. + * @return string a hash value for this request */ private function getSignature($method, $url, array $headers) { @@ -261,8 +261,8 @@ protected function handleException(GuzzleExceptionCollection $exceptions) * @param string $url * @param string[] $allowedParts Array of allowed URL parts (optional) * - * @throws InvalidUrlException If URL is invalid, the scheme is not http or - * contains parts that are not expected. + * @throws InvalidUrlException if URL is invalid, the scheme is not http or + * contains parts that are not expected * * @return string The URL (with default scheme if there was no scheme) */ diff --git a/src/ProxyClient/Invalidation/BanInterface.php b/src/ProxyClient/Invalidation/BanInterface.php index 58c472e9..e64ba41d 100644 --- a/src/ProxyClient/Invalidation/BanInterface.php +++ b/src/ProxyClient/Invalidation/BanInterface.php @@ -34,7 +34,7 @@ interface BanInterface extends ProxyClientInterface * host name, configure your proxy to copy the host to a custom HTTP header * such as X-Host. * - * @param array $headers HTTP headers that path must match to be banned. + * @param array $headers HTTP headers that path must match to be banned * * @return $this */ @@ -49,12 +49,13 @@ public function ban(array $headers); * array('example.com', 'other.net'). If the parameter is empty, all hosts * are matched. - * @param string $path Regular expression pattern for URI to - * invalidate. - * @param string $contentType Regular expression pattern for the content - * type to limit banning, for instance 'text'. - * @param array|string $hosts Regular expression of a host name or list - * of exact host names to limit banning. + * + * @param string $path regular expression pattern for URI to + * invalidate + * @param string $contentType regular expression pattern for the content + * type to limit banning, for instance 'text' + * @param array|string $hosts regular expression of a host name or list + * of exact host names to limit banning * * @return $this */ diff --git a/src/ProxyClient/Invalidation/PurgeInterface.php b/src/ProxyClient/Invalidation/PurgeInterface.php index be714ba0..3075b010 100644 --- a/src/ProxyClient/Invalidation/PurgeInterface.php +++ b/src/ProxyClient/Invalidation/PurgeInterface.php @@ -30,7 +30,7 @@ interface PurgeInterface extends ProxyClientInterface * If the $url is just a path, the proxy client class will add a default * host name. * - * @param string $url Path or URL to purge. + * @param string $url path or URL to purge * @param array $headers Extra HTTP headers to send to the caching proxy * (optional) * diff --git a/src/ProxyClient/Invalidation/RefreshInterface.php b/src/ProxyClient/Invalidation/RefreshInterface.php index 7c4e6b7f..de7fb1b6 100644 --- a/src/ProxyClient/Invalidation/RefreshInterface.php +++ b/src/ProxyClient/Invalidation/RefreshInterface.php @@ -31,7 +31,7 @@ interface RefreshInterface extends ProxyClientInterface * If the $url is just a path, the proxy client class will add a default * host name. * - * @param string $url Path or URL to refresh. + * @param string $url path or URL to refresh * @param array $headers Extra HTTP headers to send to the caching proxy * (optional) * diff --git a/src/ProxyClient/Nginx.php b/src/ProxyClient/Nginx.php index ec17db55..49780f2a 100644 --- a/src/ProxyClient/Nginx.php +++ b/src/ProxyClient/Nginx.php @@ -45,7 +45,7 @@ class Nginx extends AbstractProxyClient implements PurgeInterface, RefreshInterf * requests (optional). This is required * if you purge relative URLs and the domain * is not part of your `proxy_cache_key` - * @param string $purgeLocation Path that triggers purge (optional). + * @param string $purgeLocation path that triggers purge (optional) * @param ClientInterface $client HTTP client (optional). If no HTTP client * is supplied, a default one will be * created. diff --git a/src/ProxyClient/ProxyClientInterface.php b/src/ProxyClient/ProxyClientInterface.php index b193f590..73f48e14 100644 --- a/src/ProxyClient/ProxyClientInterface.php +++ b/src/ProxyClient/ProxyClientInterface.php @@ -23,9 +23,9 @@ interface ProxyClientInterface /** * Send all pending invalidation requests. * - * @return int The number of cache invalidations performed per caching server. + * @return int the number of cache invalidations performed per caching server * - * @throws ExceptionCollection If any errors occurred during flush. + * @throws ExceptionCollection if any errors occurred during flush */ public function flush(); } diff --git a/src/ProxyClient/Symfony.php b/src/ProxyClient/Symfony.php index f7bdfe16..b2957b3b 100644 --- a/src/ProxyClient/Symfony.php +++ b/src/ProxyClient/Symfony.php @@ -41,7 +41,7 @@ class Symfony extends AbstractProxyClient implements PurgeInterface, RefreshInte * * - purge_method: HTTP method that identifies purge requests. * - * @param array $options The purge_method that should be used. + * @param array $options the purge_method that should be used */ public function __construct(array $servers, $baseUrl = null, ClientInterface $client = null, array $options = array()) { diff --git a/src/ProxyClient/Varnish.php b/src/ProxyClient/Varnish.php index f98d2720..68b7da4a 100644 --- a/src/ProxyClient/Varnish.php +++ b/src/ProxyClient/Varnish.php @@ -45,8 +45,8 @@ class Varnish extends AbstractProxyClient implements BanInterface, PurgeInterfac /** * Set the default headers that get merged with the provided headers in self::ban(). * - * @param array $headers Hashmap with keys being the header names, values - * the header values. + * @param array $headers hashmap with keys being the header names, values + * the header values */ public function setDefaultBanHeaders(array $headers) { diff --git a/src/SymfonyCache/AccessControlledSubscriber.php b/src/SymfonyCache/AccessControlledSubscriber.php index 95c787b0..7d7139cd 100644 --- a/src/SymfonyCache/AccessControlledSubscriber.php +++ b/src/SymfonyCache/AccessControlledSubscriber.php @@ -39,10 +39,10 @@ abstract class AccessControlledSubscriber implements EventSubscriberInterface * * If neither parameter is set, the filter is IP 127.0.0.1 * - * @param RequestMatcher|null $requestMatcher Request matcher configured to only match allowed requests. - * @param string|string[]|null $ips IP or list of IPs that are allowed to send requests. + * @param RequestMatcher|null $requestMatcher request matcher configured to only match allowed requests + * @param string|string[]|null $ips IP or list of IPs that are allowed to send requests * - * @throws \InvalidArgumentException If both $requestMatcher and $ips are set. + * @throws \InvalidArgumentException if both $requestMatcher and $ips are set */ public function __construct(RequestMatcher $requestMatcher = null, $ips = null) { @@ -59,9 +59,9 @@ public function __construct(RequestMatcher $requestMatcher = null, $ips = null) /** * Check whether the request is allowed. * - * @param Request $request The request to check. + * @param Request $request the request to check * - * @return bool Whether access is granted. + * @return bool whether access is granted */ protected function isRequestAllowed(Request $request) { diff --git a/src/SymfonyCache/CacheEvent.php b/src/SymfonyCache/CacheEvent.php index 80e1b716..810ae6df 100644 --- a/src/SymfonyCache/CacheEvent.php +++ b/src/SymfonyCache/CacheEvent.php @@ -42,8 +42,8 @@ class CacheEvent extends Event * Make sure your $kernel implements CacheInvalidationInterface. Creating the event with other * HttpCache classes is deprecated and will no longer be supported in version 2 of this library. * - * @param CacheInvalidationInterface|HttpCache $kernel The kernel raising with this event. - * @param Request $request The request being processed. + * @param CacheInvalidationInterface|HttpCache $kernel the kernel raising with this event + * @param Request $request the request being processed */ public function __construct($kernel, Request $request) { @@ -75,7 +75,7 @@ public function getRequest() } /** - * @return Response|null The response if one was set. + * @return Response|null the response if one was set */ public function getResponse() { diff --git a/src/SymfonyCache/UserContextSubscriber.php b/src/SymfonyCache/UserContextSubscriber.php index db7687e6..97f57111 100644 --- a/src/SymfonyCache/UserContextSubscriber.php +++ b/src/SymfonyCache/UserContextSubscriber.php @@ -219,7 +219,7 @@ private function isSessionName($name) * * @param Request $request * - * @return Request The request that will return the user context hash value. + * @return Request the request that will return the user context hash value */ private function generateHashLookupRequest(Request $request) { diff --git a/src/Test/NginxTestCase.php b/src/Test/NginxTestCase.php index a7f2054b..70e1a3fb 100644 --- a/src/Test/NginxTestCase.php +++ b/src/Test/NginxTestCase.php @@ -55,7 +55,7 @@ abstract class NginxTestCase extends ProxyTestCase * * @throws \Exception * - * @return string the path to the NGINX server configuration file to use with this test. + * @return string the path to the NGINX server configuration file to use with this test */ protected function getConfigFile() { diff --git a/src/Test/VarnishTestCase.php b/src/Test/VarnishTestCase.php index 21eabce3..ee981c24 100644 --- a/src/Test/VarnishTestCase.php +++ b/src/Test/VarnishTestCase.php @@ -55,7 +55,7 @@ abstract class VarnishTestCase extends ProxyTestCase * * @throws \Exception * - * @return string the path to the varnish server configuration file to use with this test. + * @return string the path to the varnish server configuration file to use with this test */ protected function getConfigFile() { diff --git a/src/UserContext/HashGenerator.php b/src/UserContext/HashGenerator.php index 97a0fc56..b9c8d622 100644 --- a/src/UserContext/HashGenerator.php +++ b/src/UserContext/HashGenerator.php @@ -65,7 +65,7 @@ public function generateHash() /** * Register a provider to be called for updating a UserContext before generating the Hash. * - * @param ContextProviderInterface $provider A context provider to be called to get context information about the current request. + * @param ContextProviderInterface $provider a context provider to be called to get context information about the current request */ private function registerProvider(ContextProviderInterface $provider) { diff --git a/tests/Functional/Varnish/UserContextTestCase.php b/tests/Functional/Varnish/UserContextTestCase.php index 4097e83e..0a4a943a 100644 --- a/tests/Functional/Varnish/UserContextTestCase.php +++ b/tests/Functional/Varnish/UserContextTestCase.php @@ -23,7 +23,7 @@ abstract class UserContextTestCase extends VarnishTestCase /** * Assert that the context cache status is as expected. * - * @param string $hashCache The cache status of the context request. + * @param string $hashCache the cache status of the context request */ abstract protected function assertContextCache($hashCache); diff --git a/tests/Unit/CacheInvalidatorTest.php b/tests/Unit/CacheInvalidatorTest.php index 67037286..73828368 100644 --- a/tests/Unit/CacheInvalidatorTest.php +++ b/tests/Unit/CacheInvalidatorTest.php @@ -146,30 +146,35 @@ public function testMethodException() { $proxyClient = \Mockery::mock('\FOS\HttpCache\ProxyClient\ProxyClientInterface'); $cacheInvalidator = new CacheInvalidator($proxyClient); + try { $cacheInvalidator->invalidatePath('/'); $this->fail('Expected exception'); } catch (UnsupportedProxyOperationException $e) { // success } + try { $cacheInvalidator->refreshPath('/'); $this->fail('Expected exception'); } catch (UnsupportedProxyOperationException $e) { // success } + try { $cacheInvalidator->invalidate(array()); $this->fail('Expected exception'); } catch (UnsupportedProxyOperationException $e) { // success } + try { $cacheInvalidator->invalidateRegex('/'); $this->fail('Expected exception'); } catch (UnsupportedProxyOperationException $e) { // success } + try { $cacheInvalidator->invalidateTags(array()); $this->fail('Expected exception'); diff --git a/tests/Unit/ProxyClient/AbstractProxyClientTest.php b/tests/Unit/ProxyClient/AbstractProxyClientTest.php index 6d1bfe91..1cf33c26 100644 --- a/tests/Unit/ProxyClient/AbstractProxyClientTest.php +++ b/tests/Unit/ProxyClient/AbstractProxyClientTest.php @@ -76,8 +76,8 @@ public function curlExceptionProvider() /** * @dataProvider curlExceptionProvider * - * @param \Exception $exception The exception that curl should throw. - * @param string $type The returned exception class to be expected. + * @param \Exception $exception the exception that curl should throw + * @param string $type the returned exception class to be expected */ public function testExceptions(\Exception $exception, $type) { @@ -98,6 +98,7 @@ public function testExceptions(\Exception $exception, $type) $varnish = new Varnish(array('127.0.0.1:123'), 'my_hostname.dev', $client); $varnish->ban(array()); + try { $varnish->flush(); $this->fail('Should have aborted with an exception');