1 | <?php |
||
9 | class QueryCounter |
||
10 | { |
||
11 | /** @var int */ |
||
12 | private $defaultMaxCount; |
||
13 | |||
14 | /** @var \Doctrine\Common\Annotations\AnnotationReader */ |
||
15 | private $annotationReader; |
||
16 | |||
17 | public function __construct($defaultMaxCount, Reader $annotationReader) |
||
18 | { |
||
19 | $this->defaultMaxCount = $defaultMaxCount; |
||
20 | $this->annotationReader = $annotationReader; |
||
|
|||
21 | } |
||
22 | |||
23 | public function checkQueryCount($actualQueryCount) |
||
24 | { |
||
25 | $maxQueryCount = $this->getMaxQueryCount(); |
||
26 | |||
27 | if (null === $maxQueryCount) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | if ($actualQueryCount > $maxQueryCount) { |
||
32 | throw new AllowedQueriesExceededException( |
||
33 | "Allowed amount of queries ($maxQueryCount) exceeded (actual: $actualQueryCount)." |
||
34 | ); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | private function getMaxQueryCount() |
||
39 | { |
||
40 | $maxQueryCount = $this->getMaxQueryAnnotation(); |
||
41 | |||
42 | if (false !== $maxQueryCount) { |
||
43 | return $maxQueryCount; |
||
44 | } |
||
45 | |||
46 | return $this->defaultMaxCount; |
||
47 | } |
||
48 | |||
49 | 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.