Skip to content

Commit eff04f3

Browse files
committed
:octocat: +backslashes for built-in functions
1 parent ec8e534 commit eff04f3

File tree

15 files changed

+99
-99
lines changed

15 files changed

+99
-99
lines changed

src/Data/AlphaNum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ protected function write(string $data):void{
5151
* @throws \chillerlan\QRCode\Data\QRCodeDataException
5252
*/
5353
protected function getCharCode(string $chr):int{
54-
$i = array_search($chr, $this::ALPHANUM_CHAR_MAP);
54+
$i = \array_search($chr, $this::ALPHANUM_CHAR_MAP);
5555

5656
if($i !== false){
5757
return $i;
5858
}
5959

60-
throw new QRCodeDataException('illegal char: "'.$chr.'" ['.ord($chr).']');
60+
throw new QRCodeDataException('illegal char: "'.$chr.'" ['.\ord($chr).']');
6161
}
6262

6363
}

src/Data/Byte.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function write(string $data):void{
3636
$i = 0;
3737

3838
while($i < $this->strlen){
39-
$this->bitBuffer->put(ord($data[$i]), 8);
39+
$this->bitBuffer->put(\ord($data[$i]), 8);
4040
$i++;
4141
}
4242

src/Data/Kanji.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Kanji extends QRDataAbstract{
3333
* @inheritdoc
3434
*/
3535
protected function getLength(string $data):int{
36-
return mb_strlen($data, 'SJIS');
36+
return \mb_strlen($data, 'SJIS');
3737
}
3838

3939
/**
@@ -43,10 +43,10 @@ protected function getLength(string $data):int{
4343
* @throws \chillerlan\QRCode\Data\QRCodeDataException
4444
*/
4545
protected function write(string $data):void{
46-
$len = strlen($data);
46+
$len = \strlen($data);
4747

4848
for($i = 0; $i + 1 < $len; $i += 2){
49-
$c = ((0xff & ord($data[$i])) << 8) | (0xff & ord($data[$i + 1]));
49+
$c = ((0xff & \ord($data[$i])) << 8) | (0xff & \ord($data[$i + 1]));
5050

5151
if(0x8140 <= $c && $c <= 0x9FFC){
5252
$c -= 0x8140;

src/Data/MaskPatternTester.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testPattern():int{
5656
$penalty = 0;
5757

5858
for($level = 1; $level <= 4; $level++){
59-
$penalty += call_user_func([$this, 'testLevel'.$level]);
59+
$penalty += \call_user_func([$this, 'testLevel'.$level]);
6060
}
6161

6262
return (int)$penalty;
@@ -212,7 +212,7 @@ protected function testLevel4():float{
212212
}
213213
}
214214

215-
return (abs(100 * $count / $this->moduleCount / $this->moduleCount - 50) / 5) * 10;
215+
return (\abs(100 * $count / $this->moduleCount / $this->moduleCount - 50) / 5) * 10;
216216
}
217217

218218
}

src/Data/Number.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ protected function write(string $data):void{
3636
$i = 0;
3737

3838
while($i + 2 < $this->strlen){
39-
$this->bitBuffer->put($this->parseInt(substr($data, $i, 3)), 10);
39+
$this->bitBuffer->put($this->parseInt(\substr($data, $i, 3)), 10);
4040
$i += 3;
4141
}
4242

4343
if($i < $this->strlen){
4444

4545
if($this->strlen - $i === 1){
46-
$this->bitBuffer->put($this->parseInt(substr($data, $i, $i + 1)), 4);
46+
$this->bitBuffer->put($this->parseInt(\substr($data, $i, $i + 1)), 4);
4747
}
4848
// @codeCoverageIgnoreStart
4949
elseif($this->strlen - $i === 2){
50-
$this->bitBuffer->put($this->parseInt(substr($data, $i, $i + 2)), 7);
50+
$this->bitBuffer->put($this->parseInt(\substr($data, $i, $i + 2)), 7);
5151
}
5252
// @codeCoverageIgnoreEnd
5353

@@ -66,13 +66,13 @@ protected function parseInt(string $string):int{
6666

6767
$len = strlen($string);
6868
for($i = 0; $i < $len; $i++){
69-
$c = ord($string[$i]);
69+
$c = \ord($string[$i]);
7070

7171
if(!in_array($string[$i], $this::NUMBER_CHAR_MAP, true)){
7272
throw new QRCodeDataException('illegal char: "'.$string[$i].'" ['.$c.']');
7373
}
7474

75-
$c = $c - ord('0');
75+
$c = $c - \ord('0');
7676

7777
$num = $num * 10 + $c;
7878
}

src/Data/QRDataAbstract.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct(SettingsContainerInterface $options, string $data =
104104
public function setData(string $data):QRDataInterface{
105105

106106
if($this->datamode === QRCode::DATA_KANJI){
107-
$data = mb_convert_encoding($data, 'SJIS', mb_detect_encoding($data));
107+
$data = \mb_convert_encoding($data, 'SJIS', \mb_detect_encoding($data));
108108
}
109109

110110
$this->strlen = $this->getLength($data);
@@ -169,7 +169,7 @@ protected function getLengthBits():int{
169169
* @return int
170170
*/
171171
protected function getLength(string $data):int{
172-
return strlen($data);
172+
return \strlen($data);
173173
}
174174

175175
/**
@@ -182,7 +182,7 @@ protected function getMinimumVersion():int{
182182
$maxlength = 0;
183183

184184
// guess the version number within the given range
185-
foreach(range($this->options->versionMin, $this->options->versionMax) as $version){
185+
foreach(\range($this->options->versionMin, $this->options->versionMax) as $version){
186186
$maxlength = $this::MAX_LENGTH[$version][QRCode::DATA_MODES[$this->datamode]][QRCode::ECC_MODES[$this->options->eccLevel]];
187187

188188
if($this->strlen <= $maxlength){
@@ -270,13 +270,13 @@ protected function writeBitBuffer(string $data):QRDataInterface{
270270
protected function maskECC():array{
271271
[$l1, $l2, $b1, $b2] = $this::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
272272

273-
$rsBlocks = array_fill(0, $l1, [$b1, $b2]);
273+
$rsBlocks = \array_fill(0, $l1, [$b1, $b2]);
274274
$rsCount = $l1 + $l2;
275-
$this->ecdata = array_fill(0, $rsCount, null);
275+
$this->ecdata = \array_fill(0, $rsCount, null);
276276
$this->dcdata = $this->ecdata;
277277

278278
if($l2 > 0){
279-
$rsBlocks = array_merge($rsBlocks, array_fill(0, $l2, [$b1 + 1, $b2 + 1]));
279+
$rsBlocks = \array_merge($rsBlocks, \array_fill(0, $l2, [$b1 + 1, $b2 + 1]));
280280
}
281281

282282
$totalCodeCount = 0;
@@ -288,9 +288,9 @@ protected function maskECC():array{
288288
[$rsBlockTotal, $dcCount] = $block;
289289

290290
$ecCount = $rsBlockTotal - $dcCount;
291-
$maxDcCount = max($maxDcCount, $dcCount);
292-
$maxEcCount = max($maxEcCount, $ecCount);
293-
$this->dcdata[$key] = array_fill(0, $dcCount, null);
291+
$maxDcCount = \max($maxDcCount, $dcCount);
292+
$maxEcCount = \max($maxEcCount, $ecCount);
293+
$this->dcdata[$key] = \array_fill(0, $dcCount, null);
294294

295295
foreach($this->dcdata[$key] as $a => $_z){
296296
$this->dcdata[$key][$a] = 0xff & $this->bitBuffer->buffer[$a + $offset];
@@ -307,13 +307,13 @@ protected function maskECC():array{
307307
$totalCodeCount += $rsBlockTotal;
308308
}
309309

310-
$data = array_fill(0, $totalCodeCount, null);
310+
$data = \array_fill(0, $totalCodeCount, null);
311311
$index = 0;
312312

313313
$mask = function($arr, $count) use (&$data, &$index, $rsCount){
314314
for($x = 0; $x < $count; $x++){
315315
for($y = 0; $y < $rsCount; $y++){
316-
if($x < count($arr[$y])){
316+
if($x < \count($arr[$y])){
317317
$data[$index] = $arr[$y][$x];
318318
$index++;
319319
}
@@ -342,19 +342,19 @@ protected function poly(int $key, int $count):array{
342342
$rsPoly->multiply($modPoly->getNum());
343343
}
344344

345-
$rsPolyCount = count($rsPoly->getNum());
345+
$rsPolyCount = \count($rsPoly->getNum());
346346

347347
$modPoly
348348
->setNum($this->dcdata[$key], $rsPolyCount - 1)
349349
->mod($rsPoly->getNum())
350350
;
351351

352-
$this->ecdata[$key] = array_fill(0, $rsPolyCount - 1, null);
352+
$this->ecdata[$key] = \array_fill(0, $rsPolyCount - 1, null);
353353
$num = $modPoly->getNum();
354354

355355
return [
356356
$num,
357-
count($num) - count($this->ecdata[$key]),
357+
\count($num) - \count($this->ecdata[$key]),
358358
];
359359
}
360360

src/Data/QRMatrix.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ class QRMatrix{
135135
*/
136136
public function __construct(int $version, int $eclevel){
137137

138-
if(!in_array($version, range(1, 40), true)){
138+
if(!\in_array($version, \range(1, 40), true)){
139139
throw new QRCodeDataException('invalid QR Code version');
140140
}
141141

142-
if(!array_key_exists($eclevel, QRCode::ECC_MODES)){
142+
if(!\array_key_exists($eclevel, QRCode::ECC_MODES)){
143143
throw new QRCodeDataException('invalid ecc level');
144144
}
145145

146146
$this->version = $version;
147147
$this->eclevel = $eclevel;
148148
$this->moduleCount = $this->version * 4 + 17;
149-
$this->matrix = array_fill(0, $this->moduleCount, array_fill(0, $this->moduleCount, $this::M_NULL));
149+
$this->matrix = \array_fill(0, $this->moduleCount, \array_fill(0, $this->moduleCount, $this::M_NULL));
150150
}
151151

152152
/**
@@ -346,7 +346,7 @@ public function setAlignmentPattern():QRMatrix{
346346
*/
347347
public function setTimingPattern():QRMatrix{
348348

349-
foreach(range(8, $this->moduleCount - 8 - 1) as $i){
349+
foreach(\range(8, $this->moduleCount - 8 - 1) as $i){
350350

351351
if($this->matrix[6][$i] !== $this::M_NULL || $this->matrix[$i][6] !== $this::M_NULL){
352352
continue;
@@ -375,7 +375,7 @@ public function setVersionNumber(bool $test = null):QRMatrix{
375375
if($bits !== false){
376376

377377
for($i = 0; $i < 18; $i++){
378-
$a = (int)floor($i / 3);
378+
$a = (int)\floor($i / 3);
379379
$b = $i % 3 + $this->moduleCount - 8 - 3;
380380
$v = !$test && (($bits >> $i) & 1) === 1;
381381

@@ -445,22 +445,22 @@ public function setQuietZone(int $size = null):QRMatrix{
445445
throw new QRCodeDataException('use only after writing data');
446446
}
447447

448-
$size = $size !== null ? max(0, min($size, floor($this->moduleCount / 2))) : 4;
448+
$size = $size !== null ? \max(0, \min($size, \floor($this->moduleCount / 2))) : 4;
449449
$t = $this::M_QUIETZONE;
450450

451451
for($y = 0; $y < $this->moduleCount; $y++){
452452
for($i = 0; $i < $size; $i++){
453-
array_unshift($this->matrix[$y], $t);
454-
array_push($this->matrix[$y], $t);
453+
\array_unshift($this->matrix[$y], $t);
454+
\array_push($this->matrix[$y], $t);
455455
}
456456
}
457457

458458
$this->moduleCount += ($size * 2);
459-
$r = array_fill(0, $this->moduleCount, $t);
459+
$r = \array_fill(0, $this->moduleCount, $t);
460460

461461
for($i = 0; $i < $size; $i++){
462-
array_unshift($this->matrix, $r);
463-
array_push($this->matrix, $r);
462+
\array_unshift($this->matrix, $r);
463+
\array_push($this->matrix, $r);
464464
}
465465

466466
return $this;
@@ -478,7 +478,7 @@ public function setQuietZone(int $size = null):QRMatrix{
478478
*/
479479
public function mapData(array $data, int $maskPattern):QRMatrix{
480480
$this->maskPattern = $maskPattern;
481-
$byteCount = count($data);
481+
$byteCount = \count($data);
482482
$size = $this->moduleCount - 1;
483483

484484
for($i = $size, $y = $size, $inc = -1, $byteIndex = 0, $bitIndex = 7; $i > 0; $i -= 2){
@@ -551,7 +551,7 @@ protected function getMask(int $x, int $y, int $maskPattern):int{
551551
$y % 2,
552552
$x % 3,
553553
$a % 3,
554-
(floor($y / 2) + floor($x / 3)) % 2,
554+
(\floor($y / 2) + \floor($x / 3)) % 2,
555555
$m % 2 + $m % 3,
556556
($m % 2 + $m % 3) % 2,
557557
($m % 3 + $a % 2) % 2

src/Helpers/BitBuffer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function put(int $num, int $length):BitBuffer{
5555
* @return \chillerlan\QRCode\Helpers\BitBuffer
5656
*/
5757
public function putBit(bool $bit):BitBuffer{
58-
$bufIndex = floor($this->length / 8);
58+
$bufIndex = \floor($this->length / 8);
5959

60-
if(count($this->buffer) <= $bufIndex){
60+
if(\count($this->buffer) <= $bufIndex){
6161
$this->buffer[] = 0;
6262
}
6363

src/Helpers/Polynomial.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ public function getNum():array{
8787
*/
8888
public function setNum(array $num, int $shift = null):Polynomial{
8989
$offset = 0;
90-
$numCount = count($num);
90+
$numCount = \count($num);
9191

9292
while($offset < $numCount && $num[$offset] === 0){
9393
$offset++;
9494
}
9595

96-
$this->num = array_fill(0, $numCount - $offset + ($shift ?? 0), 0);
96+
$this->num = \array_fill(0, $numCount - $offset + ($shift ?? 0), 0);
9797

9898
for($i = 0; $i < $numCount - $offset; $i++){
9999
$this->num[$i] = $num[$i + $offset];
@@ -108,7 +108,7 @@ public function setNum(array $num, int $shift = null):Polynomial{
108108
* @return \chillerlan\QRCode\Helpers\Polynomial
109109
*/
110110
public function multiply(array $e):Polynomial{
111-
$n = array_fill(0, count($this->num) + count($e) - 1, 0);
111+
$n = \array_fill(0, \count($this->num) + \count($e) - 1, 0);
112112

113113
foreach($this->num as $i => $vi){
114114
$vi = $this->glog($vi);
@@ -132,7 +132,7 @@ public function multiply(array $e):Polynomial{
132132
public function mod(array $e):Polynomial{
133133
$n = $this->num;
134134

135-
if(count($n) - count($e) < 0){
135+
if(\count($n) - \count($e) < 0){
136136
return $this;
137137
}
138138

0 commit comments

Comments
 (0)