1 | <?php |
||
19 | class LoggingHelper { |
||
20 | |||
21 | /** |
||
22 | * @var IBufferingStatsdDataFactory |
||
23 | */ |
||
24 | private $dataFactory; |
||
25 | |||
26 | /** |
||
27 | * @var LoggerInterface |
||
28 | */ |
||
29 | private $logger; |
||
30 | |||
31 | /** |
||
32 | * @var float[] |
||
33 | */ |
||
34 | private $constraintCheckDurationLimits; |
||
35 | |||
36 | /** |
||
37 | * @var float[] |
||
38 | */ |
||
39 | private $constraintCheckOnEntityDurationLimits; |
||
40 | |||
41 | /** |
||
42 | * @param IBufferingStatsdDataFactory $dataFactory, |
||
|
|||
43 | * @param LoggerInterface $logger |
||
44 | * @param Config $config |
||
45 | */ |
||
46 | public function __construct( |
||
62 | |||
63 | /** |
||
64 | * Find the longest limit in $limits which the $durationSeconds exceeds, |
||
65 | * and return it along with the associated log level. |
||
66 | * |
||
67 | * @param float $durationSeconds |
||
68 | * @return array [ $limitSeconds, $logLevel ] |
||
69 | */ |
||
70 | private function findLimit( $limits, $durationSeconds ) { |
||
88 | |||
89 | /** |
||
90 | * Log a single constraint check. |
||
91 | * The constraint check is tracked on the statsd data factory, |
||
92 | * and also logged with the logger interface if it took longer than a certain time. |
||
93 | * Multiple limits corresponding to different log levels can be specified in the configuration; |
||
94 | * checks that exceed a higher limit are logged at a more severe level. |
||
95 | * |
||
96 | * @param Context $context |
||
97 | * @param Constraint $constraint |
||
98 | * @param CheckResult $result |
||
99 | * @param string $constraintCheckerClass |
||
100 | * @param float $durationSeconds |
||
101 | * @param string $method Use __METHOD__. |
||
102 | */ |
||
103 | public function logConstraintCheck( |
||
165 | |||
166 | /** |
||
167 | * Log a full constraint check on an entity. |
||
168 | * The constraint check is tracked on the statsd data factory, |
||
169 | * and also logged with the logger interface if it took longer than a certain time. |
||
170 | * Multiple limits corresponding to different log levels can be specified in the configuration; |
||
171 | * checks that exceed a higher limit are logged at a more severe level. |
||
172 | * |
||
173 | * |
||
174 | * @param EntityId $entityId |
||
175 | * @param CheckResult[] $checkResults |
||
176 | * @param float $durationSeconds |
||
177 | */ |
||
178 | public function logConstraintCheckOnEntity( |
||
213 | |||
214 | /** |
||
215 | * Log a cache hit for a complete constraint check result for the given entity ID. |
||
216 | * |
||
217 | * @param EntityId $entityId |
||
218 | */ |
||
219 | public function logCheckConstraintsCacheHit( EntityId $entityId ) { |
||
224 | |||
225 | /** |
||
226 | * Log cache misses for a complete constraint check result for the given entity IDs. |
||
227 | * |
||
228 | * @param EntityId[] $entityIds |
||
229 | */ |
||
230 | public function logCheckConstraintsCacheMisses( array $entityIds ) { |
||
236 | |||
237 | /** |
||
238 | * Log that the dependency metadata for a check result had an empty set of entity IDs. |
||
239 | * This should never happen – at least the entity being checked should always be contained. |
||
240 | */ |
||
241 | public function logEmptyDependencyMetadata() { |
||
253 | |||
254 | /** |
||
255 | * Log that the dependency metadata for a check result has a very large set of entity IDs. |
||
256 | * |
||
257 | * @param EntityId[] $entityIds |
||
258 | * @param int $maxRevisionIds |
||
259 | */ |
||
260 | public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) { |
||
280 | |||
281 | } |
||
282 |
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.