1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOSHttpCacheBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FOS\HttpCacheBundle\Http; |
13
|
|
|
|
14
|
|
|
use FOS\HttpCacheBundle\Http\ResponseMatcher\ResponseMatcherInterface; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
use Symfony\Component\HttpFoundation\RequestMatcherInterface; |
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Combines a RequestMatcherInterface and a ResponseMatcherInterface. |
21
|
|
|
* |
22
|
|
|
* Both must match for the RuleMatcher to match. |
23
|
|
|
* |
24
|
|
|
* @author David Buchmann <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class RuleMatcher implements RuleMatcherInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var RequestMatcherInterface |
30
|
|
|
*/ |
31
|
|
|
private $requestMatcher; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var ResponseMatcherInterface |
35
|
|
|
*/ |
36
|
|
|
private $responseMatcher; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param RequestMatcherInterface $requestMatcher|null Request matcher |
|
|
|
|
40
|
|
|
* @param ResponseMatcherInterface $responseMatcher|null Response matcher |
|
|
|
|
41
|
|
|
*/ |
42
|
34 |
|
public function __construct( |
43
|
|
|
RequestMatcherInterface $requestMatcher = null, |
44
|
|
|
ResponseMatcherInterface $responseMatcher = null |
45
|
|
|
) { |
46
|
34 |
|
$this->requestMatcher = $requestMatcher; |
47
|
34 |
|
$this->responseMatcher = $responseMatcher; |
48
|
34 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
26 |
|
public function matches(Request $request, Response $response) |
54
|
|
|
{ |
55
|
26 |
|
if ($this->requestMatcher && !$this->requestMatcher->matches($request)) { |
56
|
21 |
|
return false; |
57
|
|
|
} |
58
|
|
|
|
59
|
25 |
|
if ($this->responseMatcher && !$this->responseMatcher->matches($response)) { |
60
|
5 |
|
return false; |
61
|
|
|
} |
62
|
|
|
|
63
|
22 |
|
return true; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.