Skip to content

Commit 7cb46ad

Browse files
committed
Merge pull request #217 from FriendsOfSymfony/remove-deprecations
Remove deprecations
2 parents 1a711b9 + fb2a403 commit 7cb46ad

36 files changed

+126
-265
lines changed

doc/invalidation-handlers.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ to simplify common operations.
99
Tag Handler
1010
-----------
1111

12-
.. versionadded:: 1.3
13-
The tag handler was added in FOSHttpCache 1.3. If you are using an older
14-
version of the library and can not update, you need to use
15-
``CacheInvalidator::invalidateTags``.
16-
1712
The tag handler helps you to mark responses with tags that you can later use to
1813
invalidate all cache entries with that tag. Tag invalidation works only with a
1914
``CacheInvalidator`` that supports ``CacheInvalidator::INVALIDATE``.

src/CacheInvalidator.php

Lines changed: 4 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use FOS\HttpCache\ProxyClient\Invalidation\BanInterface;
2121
use FOS\HttpCache\ProxyClient\Invalidation\PurgeInterface;
2222
use FOS\HttpCache\ProxyClient\Invalidation\RefreshInterface;
23-
use FOS\HttpCache\Handler\TagHandler;
2423
use Symfony\Component\EventDispatcher\EventDispatcher;
2524
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2625
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -58,18 +57,6 @@ class CacheInvalidator
5857
*/
5958
private $eventDispatcher;
6059

61-
/**
62-
* @deprecated This reference is only for BC and will be removed in version 2.0.
63-
*
64-
* @var TagHandler
65-
*/
66-
private $tagHandler;
67-
68-
/**
69-
* @var string
70-
*/
71-
private $tagsHeader = 'X-Cache-Tags';
72-
7360
/**
7461
* Constructor
7562
*
@@ -78,9 +65,6 @@ class CacheInvalidator
7865
public function __construct(ProxyClientInterface $cache)
7966
{
8067
$this->cache = $cache;
81-
if ($cache instanceof BanInterface) {
82-
$this->tagHandler = new TagHandler($this, $this->tagsHeader);
83-
}
8468
}
8569

8670
/**
@@ -144,52 +128,6 @@ public function getEventDispatcher()
144128
return $this->eventDispatcher;
145129
}
146130

147-
/**
148-
* Add subscriber
149-
*
150-
* @param EventSubscriberInterface $subscriber
151-
*
152-
* @return $this
153-
*
154-
* @deprecated Use getEventDispatcher()->addSubscriber($subscriber) instead.
155-
*/
156-
public function addSubscriber(EventSubscriberInterface $subscriber)
157-
{
158-
$this->getEventDispatcher()->addSubscriber($subscriber);
159-
160-
return $this;
161-
}
162-
163-
/**
164-
* Set the HTTP header name that will hold cache tags
165-
*
166-
* @param string $tagsHeader
167-
*
168-
* @return $this
169-
*
170-
* @deprecated Use constructor argument to TagHandler instead.
171-
*/
172-
public function setTagsHeader($tagsHeader)
173-
{
174-
if ($this->tagHandler && $this->tagHandler->getTagsHeaderName() !== $tagsHeader) {
175-
$this->tagHandler = new TagHandler($this, $tagsHeader);
176-
}
177-
178-
return $this;
179-
}
180-
181-
/**
182-
* Get the HTTP header name that will hold cache tags
183-
*
184-
* @return string
185-
*
186-
* @deprecated Use TagHandler::getTagsHeaderName instead.
187-
*/
188-
public function getTagsHeader()
189-
{
190-
return $this->tagHandler ? $this->tagHandler->getTagsHeaderName() : $this->tagsHeader;
191-
}
192-
193131
/**
194132
* Invalidate a path or URL
195133
*
@@ -200,7 +138,7 @@ public function getTagsHeader()
200138
*
201139
* @return $this
202140
*/
203-
public function invalidatePath($path, array $headers = array())
141+
public function invalidatePath($path, array $headers = [])
204142
{
205143
if (!$this->cache instanceof PurgeInterface) {
206144
throw UnsupportedProxyOperationException::cacheDoesNotImplement('PURGE');
@@ -223,7 +161,7 @@ public function invalidatePath($path, array $headers = array())
223161
*
224162
* @return $this
225163
*/
226-
public function refreshPath($path, array $headers = array())
164+
public function refreshPath($path, array $headers = [])
227165
{
228166
if (!$this->cache instanceof RefreshInterface) {
229167
throw UnsupportedProxyOperationException::cacheDoesNotImplement('REFRESH');
@@ -238,7 +176,7 @@ public function refreshPath($path, array $headers = array())
238176
* Invalidate all cached objects matching the provided HTTP headers.
239177
*
240178
* Each header is a a POSIX regular expression, for example
241-
* array('X-Host' => '^(www\.)?(this|that)\.com$')
179+
* ['X-Host' => '^(www\.)?(this|that)\.com$']
242180
*
243181
* @see BanInterface::ban()
244182
*
@@ -265,7 +203,7 @@ public function invalidate(array $headers)
265203
*
266204
* The hosts parameter can either be a regular expression, e.g.
267205
* '^(www\.)?(this|that)\.com$' or an array of exact host names, e.g.
268-
* array('example.com', 'other.net'). If the parameter is empty, all hosts
206+
* ['example.com', 'other.net']. If the parameter is empty, all hosts
269207
* are matched.
270208
*
271209
* @see BanInterface::banPath()
@@ -292,29 +230,6 @@ public function invalidateRegex($path, $contentType = null, $hosts = null)
292230
return $this;
293231
}
294232

295-
/**
296-
* Invalidate cache entries that contain any of the specified tags in their
297-
* tag header.
298-
*
299-
* @param array $tags Cache tags
300-
*
301-
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
302-
*
303-
* @return $this
304-
*
305-
* @deprecated Use TagHandler::invalidateTags instead.
306-
*/
307-
public function invalidateTags(array $tags)
308-
{
309-
if (!$this->tagHandler) {
310-
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
311-
}
312-
313-
$this->tagHandler->invalidateTags($tags);
314-
315-
return $this;
316-
}
317-
318233
/**
319234
* Send all pending invalidation requests.
320235
*

src/Exception/ExceptionCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818
class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface
1919
{
20-
private $exceptions = array();
21-
22-
public function __construct(array $exceptions = array())
20+
private $exceptions = [];
21+
22+
public function __construct(array $exceptions = [])
2323
{
2424
foreach ($exceptions as $exception) {
2525
$this->add($exception);

src/Handler/TagHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TagHandler
3535
/**
3636
* @var array
3737
*/
38-
private $tags = array();
38+
private $tags = [];
3939

4040
/**
4141
* Constructor
@@ -113,7 +113,7 @@ public function addTags(array $tags)
113113
public function invalidateTags(array $tags)
114114
{
115115
$tagExpression = sprintf('(%s)(,.+)?$', implode('|', array_map('preg_quote', $this->escapeTags($tags))));
116-
$headers = array($this->tagsHeader => $tagExpression);
116+
$headers = [$this->tagsHeader => $tagExpression];
117117
$this->invalidator->invalidate($headers);
118118

119119
return $this;
@@ -129,7 +129,7 @@ public function invalidateTags(array $tags)
129129
protected function escapeTags(array $tags)
130130
{
131131
array_walk($tags, function (&$tag) {
132-
$tag = str_replace(array(',', "\n"), array('_', '_'), $tag);
132+
$tag = str_replace([',', "\n"], ['_', '_'], $tag);
133133
});
134134

135135
return $tags;

src/ProxyClient/Invalidation/BanInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function ban(array $headers);
4646
*
4747
* The hosts parameter can either be a regular expression, e.g.
4848
* '^(www\.)?(this|that)\.com$' or an array of exact host names, e.g.
49-
* array('example.com', 'other.net'). If the parameter is empty, all hosts
49+
* ['example.com', 'other.net']. If the parameter is empty, all hosts
5050
* are matched.
5151
5252
* @param string $path Regular expression pattern for URI to

src/ProxyClient/Invalidation/PurgeInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ interface PurgeInterface extends ProxyClientInterface
3636
*
3737
* @return $this
3838
*/
39-
public function purge($url, array $headers = array());
39+
public function purge($url, array $headers = []);
4040
}

src/ProxyClient/Invalidation/RefreshInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ interface RefreshInterface extends ProxyClientInterface
3737
*
3838
* @return $this
3939
*/
40-
public function refresh($url, array $headers = array());
40+
public function refresh($url, array $headers = []);
4141
}

src/ProxyClient/Symfony.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function purge($url, array $headers = array())
65+
public function purge($url, array $headers = [])
6666
{
6767
$this->queueRequest($this->options['purge_method'], $url, $headers);
6868

@@ -72,9 +72,9 @@ public function purge($url, array $headers = array())
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function refresh($url, array $headers = array())
75+
public function refresh($url, array $headers = [])
7676
{
77-
$headers = array_merge($headers, array('Cache-Control' => 'no-cache'));
77+
$headers = array_merge($headers, ['Cache-Control' => 'no-cache']);
7878
$this->queueRequest(self::HTTP_METHOD_REFRESH, $url, $headers);
7979

8080
return $this;

src/SymfonyCache/CacheEvent.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,13 @@ class CacheEvent extends Event
3939
private $response;
4040

4141
/**
42-
* Make sure your $kernel implements CacheInvalidationInterface. Creating the event with other
43-
* HttpCache classes is deprecated and will no longer be supported in version 2 of this library.
42+
* Make sure your $kernel implements CacheInvalidationInterface
4443
*
45-
* @param CacheInvalidationInterface|HttpCache $kernel The kernel raising with this event.
44+
* @param CacheInvalidationInterface$kernel The kernel raising with this event.
4645
* @param Request $request The request being processed.
4746
*/
48-
public function __construct($kernel, Request $request)
47+
public function __construct(CacheInvalidationInterface $kernel, Request $request)
4948
{
50-
if (!($kernel instanceof CacheInvalidationInterface || $kernel instanceof HttpCache)) {
51-
throw new \InvalidArgumentException('Expected a CacheInvalidationInterface or HttpCache');
52-
}
5349
$this->kernel = $kernel;
5450
$this->request = $request;
5551
}

src/SymfonyCache/PurgeSubscriber.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PurgeSubscriber extends AccessControlledSubscriber
3434
*
3535
* @var array
3636
*/
37-
private $options = array();
37+
private $options = [];
3838

3939
/**
4040
* When creating this subscriber, you can configure a number of options.
@@ -49,14 +49,14 @@ class PurgeSubscriber extends AccessControlledSubscriber
4949
*
5050
* @throws \InvalidArgumentException if unknown keys are found in $options
5151
*/
52-
public function __construct(array $options = array())
52+
public function __construct(array $options = [])
5353
{
5454
$resolver = new OptionsResolver();
5555
if (method_exists($resolver, 'setDefined')) {
5656
// this was only added in symfony 2.6
57-
$resolver->setDefined(array('purge_client_matcher', 'purge_client_ips', 'purge_method'));
57+
$resolver->setDefined(['purge_client_matcher', 'purge_client_ips', 'purge_method']);
5858
} else {
59-
$resolver->setOptional(array('purge_client_matcher', 'purge_client_ips', 'purge_method'));
59+
$resolver->setOptional(['purge_client_matcher', 'purge_client_ips', 'purge_method']);
6060
}
6161
$resolver->setDefaults(array(
6262
'purge_client_matcher' => null,

src/SymfonyCache/RefreshSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class RefreshSubscriber extends AccessControlledSubscriber
4242
*
4343
* @throws \InvalidArgumentException if unknown keys are found in $options
4444
*/
45-
public function __construct(array $options = array())
45+
public function __construct(array $options = [])
4646
{
4747
$resolver = new OptionsResolver();
4848
$resolver->setDefaults(array(

src/SymfonyCache/UserContextSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class UserContextSubscriber implements EventSubscriberInterface
5656
*
5757
* @throws \InvalidArgumentException if unknown keys are found in $options
5858
*/
59-
public function __construct(array $options = array())
59+
public function __construct(array $options = [])
6060
{
6161
$resolver = new OptionsResolver();
6262
$resolver->setDefaults(array(
@@ -123,7 +123,7 @@ public function preHandle(CacheEvent $event)
123123
*/
124124
protected function cleanupHashLookupRequest(Request $hashLookupRequest, Request $originalRequest)
125125
{
126-
$sessionIds = array();
126+
$sessionIds = [];
127127
foreach ($originalRequest->cookies as $name => $value) {
128128
if ($this->isSessionName($name)) {
129129
$sessionIds[$name] = $value;
@@ -223,7 +223,7 @@ private function isSessionName($name)
223223
*/
224224
private function generateHashLookupRequest(Request $request)
225225
{
226-
$hashLookupRequest = Request::create($this->options['user_hash_uri'], $this->options['user_hash_method'], array(), array(), array(), $request->server->all());
226+
$hashLookupRequest = Request::create($this->options['user_hash_uri'], $this->options['user_hash_method'], [], [], [], $request->server->all());
227227
$hashLookupRequest->attributes->set('internalRequest', true);
228228
$hashLookupRequest->headers->set('Accept', $this->options['user_hash_accept_header']);
229229
$this->cleanupHashLookupRequest($hashLookupRequest, $request);

src/Test/NginxTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected function getProxyClient($purgeLocation = '')
128128
{
129129
if (null === $this->proxyClient) {
130130
$this->proxyClient = new Nginx(
131-
array('http://127.0.0.1:' . $this->getCachingProxyPort()),
131+
['http://127.0.0.1:' . $this->getCachingProxyPort()],
132132
$this->getHostName()
133133
);
134134

src/Test/Proxy/NginxProxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function start()
5252
public function stop()
5353
{
5454
if (file_exists($this->pid)) {
55-
$this->runCommand('kill', array(file_get_contents($this->pid)));
55+
$this->runCommand('kill', [file_get_contents($this->pid)]);
5656
}
5757
}
5858

@@ -61,7 +61,7 @@ public function stop()
6161
*/
6262
public function clear()
6363
{
64-
$this->runCommand('rm', array('-rf', $this->getCacheDir()));
64+
$this->runCommand('rm', ['-rf', $this->getCacheDir()]);
6565
$this->start();
6666
}
6767

src/Test/Proxy/VarnishProxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function stop()
6262
{
6363
if (file_exists($this->pid)) {
6464
try {
65-
$this->runCommand('kill', array('-9', file_get_contents($this->pid)));
65+
$this->runCommand('kill', ['-9', file_get_contents($this->pid)]);
6666
} catch (\RuntimeException $e) {
6767
// Ignore if command fails when Varnish wasn't running
6868
}

src/Test/SymfonyTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ protected function getProxyClient()
8484
{
8585
if (null === $this->proxyClient) {
8686
$this->proxyClient = new Symfony(
87-
array('http://127.0.0.1:' . $this->getCachingProxyPort()),
87+
['http://127.0.0.1:' . $this->getCachingProxyPort()],
8888
$this->getHostName() . ':' . $this->getCachingProxyPort(),
8989
null,
90-
array('purge_method' => 'NOTIFY')
90+
['purge_method' => 'NOTIFY']
9191
);
9292
}
9393

src/Test/VarnishTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function getProxyClient()
152152
{
153153
if (null === $this->proxyClient) {
154154
$this->proxyClient = new Varnish(
155-
array('http://127.0.0.1:' . $this->getProxy()->getPort()),
155+
['http://127.0.0.1:' . $this->getProxy()->getPort()],
156156
$this->getHostName() . ':' . $this->getProxy()->getPort()
157157
);
158158
}

0 commit comments

Comments
 (0)