Skip to content

Commit e4ed56e

Browse files
committed
:octocat: self -> $this
1 parent 3a61a75 commit e4ed56e

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/Data/AlphaNum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function write(string $data){
6060
* @throws \chillerlan\QRCode\Data\QRCodeDataException
6161
*/
6262
protected function getCharCode(string $chr):int {
63-
$i = array_search($chr, self::CHAR_MAP);
63+
$i = array_search($chr, $this::CHAR_MAP);
6464

6565
if($i !== false){
6666
return $i;

src/Data/QRDataAbstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected function getMinimumVersion():int{
188188

189189
// guess the version number within the given range
190190
foreach(range(max(1, $this->options->versionMin), min($this->options->versionMax, 40)) as $version){
191-
$maxlength = self::MAX_LENGTH[$version][QRCode::DATA_MODES[$this->datamode]][QRCode::ECC_MODES[$this->options->eccLevel]];
191+
$maxlength = $this::MAX_LENGTH[$version][QRCode::DATA_MODES[$this->datamode]][QRCode::ECC_MODES[$this->options->eccLevel]];
192192

193193
if($this->strlen <= $maxlength){
194194
return $version;
@@ -219,7 +219,7 @@ protected function writeBitBuffer(string $data):QRDataInterface {
219219
$this->bitBuffer = new BitBuffer;
220220

221221
// @todo: fixme, get real length
222-
$MAX_BITS = self::MAX_BITS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
222+
$MAX_BITS = $this::MAX_BITS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
223223

224224
$this->bitBuffer
225225
->clear()
@@ -273,7 +273,7 @@ protected function writeBitBuffer(string $data):QRDataInterface {
273273
* @return array
274274
*/
275275
protected function maskECC():array {
276-
list($l1, $l2, $b1, $b2) = self::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
276+
list($l1, $l2, $b1, $b2) = $this::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
277277

278278
$rsBlocks = array_fill(0, $l1, [$b1, $b2]);
279279
$rsCount = $l1 + $l2;

src/Data/QRMatrix.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function __construct(int $version, int $eclevel){
142142
$this->version = $version;
143143
$this->eclevel = $eclevel;
144144
$this->moduleCount = $this->version * 4 + 17;
145-
$this->matrix = array_fill(0, $this->moduleCount, array_fill(0, $this->moduleCount, self::M_NULL));
145+
$this->matrix = array_fill(0, $this->moduleCount, array_fill(0, $this->moduleCount, $this::M_NULL));
146146
}
147147

148148
/**
@@ -240,7 +240,7 @@ public function check(int $x, int $y):bool{
240240
* @return \chillerlan\QRCode\Data\QRMatrix
241241
*/
242242
public function setDarkModule():QRMatrix{
243-
$this->set(8, 4 * $this->version + 9, true, self::M_DARKMODULE);
243+
$this->set(8, 4 * $this->version + 9, true, $this::M_DARKMODULE);
244244

245245
return $this;
246246
}
@@ -265,7 +265,7 @@ public function setFinderPattern():QRMatrix{
265265
$c[0] + $y,
266266
$c[1] + $x,
267267
!(($x > 0 && $x < 6 && ($y === 1 || $y === 5)) || ($y > 0 && $y < 6 && ($x === 1 || $x === 5))),
268-
self::M_FINDER
268+
$this::M_FINDER
269269
);
270270
}
271271
}
@@ -293,7 +293,7 @@ public function setSeparators():QRMatrix{
293293
[7, $this->moduleCount - 8],
294294
];
295295

296-
$t = self::M_SEPARATOR;
296+
$t = $this::M_SEPARATOR;
297297

298298
for($c = 0; $c < 3; $c++){
299299
for($i = 0; $i < 8; $i++){
@@ -312,21 +312,21 @@ public function setSeparators():QRMatrix{
312312
* @return \chillerlan\QRCode\Data\QRMatrix
313313
*/
314314
public function setAlignmentPattern():QRMatrix{
315-
$pattern = self::alignmentPattern[$this->version];
315+
$pattern = $this::alignmentPattern[$this->version];
316316

317317
foreach($pattern as $y){
318318
foreach($pattern as $x){
319319

320320
// skip existing patterns
321-
if($this->matrix[$y][$x] !== self::M_NULL){
321+
if($this->matrix[$y][$x] !== $this::M_NULL){
322322
continue;
323323
}
324324

325325
for($ry = -2; $ry <= 2; $ry++){
326326
for($rx = -2; $rx <= 2; $rx++){
327327
$v = ($ry === 0 && $rx === 0) || $ry === 2 || $ry === -2 || $rx === 2 || $rx === -2;
328328

329-
$this->set($x + $rx, $y + $ry, $v, self::M_ALIGNMENT);
329+
$this->set($x + $rx, $y + $ry, $v, $this::M_ALIGNMENT);
330330
}
331331
}
332332

@@ -346,12 +346,12 @@ public function setTimingPattern():QRMatrix{
346346

347347
foreach(range(8, $this->moduleCount - 8 - 1) as $i){
348348

349-
if($this->matrix[6][$i] !== self::M_NULL || $this->matrix[$i][6] !== self::M_NULL){
349+
if($this->matrix[6][$i] !== $this::M_NULL || $this->matrix[$i][6] !== $this::M_NULL){
350350
continue;
351351
}
352352

353353
$v = $i % 2 === 0;
354-
$t = self::M_TIMING;
354+
$t = $this::M_TIMING;
355355

356356
$this->set($i, 6, $v, $t); // h
357357
$this->set(6, $i, $v, $t); // v
@@ -370,15 +370,15 @@ public function setTimingPattern():QRMatrix{
370370
public function setVersionNumber(bool $test = null):QRMatrix{
371371
$test = $test !== null ? $test : false;
372372

373-
$bits = self::versionPattern[$this->version] ?? false;
373+
$bits = $this::versionPattern[$this->version] ?? false;
374374

375375
if($bits !== false){
376376

377377
for($i = 0; $i < 18; $i++){
378378
$a = (int)floor($i / 3);
379379
$b = $i % 3 + $this->moduleCount - 8 - 3;
380380
$v = !$test && (($bits >> $i) & 1) === 1;
381-
$t = self::M_VERSION;
381+
$t = $this::M_VERSION;
382382

383383
$this->set($b, $a, $v, $t); // ne
384384
$this->set($a, $b, $v, $t); // sw
@@ -399,8 +399,8 @@ public function setVersionNumber(bool $test = null):QRMatrix{
399399
*/
400400
public function setFormatInfo(int $maskPattern, bool $test = null):QRMatrix{
401401
$test = $test !== null ? $test : false;
402-
$bits = self::formatPattern[QRCode::ECC_MODES[$this->eclevel]][$maskPattern] ?? 0;
403-
$t = self::M_FORMAT;
402+
$bits = $this::formatPattern[QRCode::ECC_MODES[$this->eclevel]][$maskPattern] ?? 0;
403+
$t = $this::M_FORMAT;
404404

405405
for($i = 0; $i < 15; $i++){
406406
$v = !$test && (($bits >> $i) & 1) === 1;
@@ -441,12 +441,12 @@ public function setFormatInfo(int $maskPattern, bool $test = null):QRMatrix{
441441
*/
442442
public function setQuietZone(int $size = null):QRMatrix{
443443

444-
if($this->matrix[$this->moduleCount - 1][$this->moduleCount - 1] === self::M_NULL){
444+
if($this->matrix[$this->moduleCount - 1][$this->moduleCount - 1] === $this::M_NULL){
445445
throw new QRCodeDataException('use only after writing data');
446446
}
447447

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

451451
for($y = 0; $y < $this->moduleCount; $y++){
452452
for($i = 0; $i < $size; $i++){
@@ -491,7 +491,7 @@ public function mapData(array $data, int $maskPattern):QRMatrix{
491491
for($c = 0; $c < 2; $c++){
492492
$x = $i - $c;
493493

494-
if($this->matrix[$y][$x] === self::M_NULL){
494+
if($this->matrix[$y][$x] === $this::M_NULL){
495495
$v = false;
496496

497497
if($byteIndex < $byteCount){
@@ -502,7 +502,7 @@ public function mapData(array $data, int $maskPattern):QRMatrix{
502502
$v = !$v;
503503
}
504504

505-
$this->matrix[$y][$x] = self::M_DATA << ($v ? 8 : 0);
505+
$this->matrix[$y][$x] = $this::M_DATA << ($v ? 8 : 0);
506506
$bitIndex--;
507507

508508
if($bitIndex === -1){

src/QRCode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function __construct(QROptions $options = null){
118118
*/
119119
public function setOptions(QROptions $options):QRCode{
120120

121-
if(!array_key_exists($options->eccLevel, self::ECC_MODES)){
121+
if(!array_key_exists($options->eccLevel, $this::ECC_MODES)){
122122
throw new QRCodeException('Invalid error correct level: '.$options->eccLevel);
123123
}
124124

@@ -165,7 +165,7 @@ public function getMatrix(string $data):QRMatrix {
165165

166166
$this->dataInterface = $this->initDataInterface($data);
167167

168-
$maskPattern = $this->options->maskPattern === self::MASK_PATTERN_AUTO
168+
$maskPattern = $this->options->maskPattern === $this::MASK_PATTERN_AUTO
169169
? $this->getBestMaskPattern()
170170
: max(7, min(0, (int)$this->options->maskPattern));
171171

@@ -244,7 +244,7 @@ public function initDataInterface(string $data):QRDataInterface{
244244
*/
245245
protected function initOutputInterface(string $data):QROutputInterface{
246246

247-
foreach(self::OUTPUT_MODES as $outputInterface => $modes){
247+
foreach($this::OUTPUT_MODES as $outputInterface => $modes){
248248

249249
if(in_array($this->options->outputType, $modes, true)){
250250
return $this->loadClass($outputInterface, QROutputInterface::class, $this->options, $this->getMatrix($data));

0 commit comments

Comments
 (0)