Skip to content

Commit aa5f044

Browse files
committed
:octocat: phan happy (this might be a false positive?)
1 parent 6349562 commit aa5f044

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/Detector/FinderPatternFinder.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ final class FinderPatternFinder{
2929
private const MIN_SKIP = 2;
3030
private const MAX_MODULES = 177; // 1 pixel/module times 3 modules/center
3131
private const CENTER_QUORUM = 2; // support up to version 10 for mobile clients
32+
/** @var int[] */
33+
private const crossCheckStateCount = [0, 0, 0, 0, 0];
3234
private BitMatrix $matrix;
3335
/** @var \chillerlan\QRCode\Detector\FinderPattern[] */
3436
private array $possibleCenters;
@@ -65,7 +67,7 @@ public function find():array{
6567

6668
for($i = ($iSkip - 1); ($i < $dimension) && !$done; $i += $iSkip){
6769
// Get a row of black/white values
68-
$stateCount = $this->getCrossCheckStateCount();
70+
$stateCount = self::crossCheckStateCount;
6971
$currentState = 0;
7072

7173
for($j = 0; $j < $dimension; $j++){
@@ -122,7 +124,7 @@ public function find():array{
122124
}
123125
// Clear state to start looking again
124126
$currentState = 0;
125-
$stateCount = $this->getCrossCheckStateCount();
127+
$stateCount = self::crossCheckStateCount;
126128
}
127129
// No, shift counts back by two
128130
else{
@@ -158,13 +160,6 @@ public function find():array{
158160
return $this->orderBestPatterns($this->selectBestPatterns());
159161
}
160162

161-
/**
162-
* @return int[]
163-
*/
164-
private function getCrossCheckStateCount():array{
165-
return [0, 0, 0, 0, 0];
166-
}
167-
168163
/**
169164
* @param int[] $stateCount
170165
*
@@ -251,7 +246,7 @@ private function foundPatternVariance(array $stateCount, float $variance):bool{
251246
* @return bool true if proportions are withing expected limits
252247
*/
253248
private function crossCheckDiagonal(int $centerI, int $centerJ):bool{
254-
$stateCount = $this->getCrossCheckStateCount();
249+
$stateCount = self::crossCheckStateCount;
255250

256251
// Start counting up, left from center finding black center mass
257252
$i = 0;
@@ -335,7 +330,7 @@ private function crossCheckDiagonal(int $centerI, int $centerJ):bool{
335330
*/
336331
private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):float|null{
337332
$maxI = $this->matrix->getSize();
338-
$stateCount = $this->getCrossCheckStateCount();
333+
$stateCount = self::crossCheckStateCount;
339334

340335
// Start counting up from center
341336
$i = $startI;
@@ -419,7 +414,7 @@ private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, in
419414
*/
420415
private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal):float|null{
421416
$maxJ = $this->matrix->getSize();
422-
$stateCount = $this->getCrossCheckStateCount();
417+
$stateCount = self::crossCheckStateCount;
423418

424419
$j = $startJ;
425420
while($j >= 0 && $this->matrix->check($j, $centerI)){

0 commit comments

Comments
 (0)