1 | <?php |
||
9 | class QueryCounter |
||
10 | { |
||
11 | /** @var int */ |
||
12 | private $defaultMaxCount; |
||
13 | |||
14 | /** @var \Doctrine\Common\Annotations\AnnotationReader */ |
||
15 | private $annotationReader; |
||
16 | |||
17 | 16 | public function __construct($defaultMaxCount, Reader $annotationReader) |
|
18 | { |
||
19 | 16 | $this->defaultMaxCount = $defaultMaxCount; |
|
20 | 16 | $this->annotationReader = $annotationReader; |
|
|
|||
21 | 16 | } |
|
22 | |||
23 | 5 | public function checkQueryCount($actualQueryCount) |
|
24 | { |
||
25 | 5 | $maxQueryCount = $this->getMaxQueryCount(); |
|
26 | |||
27 | 5 | if (null === $maxQueryCount) { |
|
28 | return; |
||
29 | } |
||
30 | |||
31 | 5 | if ($actualQueryCount > $maxQueryCount) { |
|
32 | 2 | throw new AllowedQueriesExceededException( |
|
33 | 2 | "Allowed amount of queries ($maxQueryCount) exceeded (actual: $actualQueryCount)." |
|
34 | 2 | ); |
|
35 | } |
||
36 | 3 | } |
|
37 | |||
38 | 5 | private function getMaxQueryCount() |
|
48 | |||
49 | 5 | private function getMaxQueryAnnotation() |
|
69 | } |
||
70 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.