Skip to content

Commit 388aa46

Browse files
committed
Further rectoring. Add more info to NotFoundExceptions
1 parent d893761 commit 388aa46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+582
-462
lines changed

lib/Binarizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
abstract class Binarizer
3232
{
3333
protected function __construct(private $source)
34-
{
35-
}
34+
{
35+
}
3636

3737
/**
3838
* @return LuminanceSource

lib/Common/AbstractEnum.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
final class AbstractEnum implements \Stringable
1111
{
1212
/**
13-
* Default value.
14-
*/
13+
* Default value.
14+
* @var null
15+
*/
1516
public const __default = null;
1617
/**
1718
* Current value.
@@ -24,7 +25,7 @@ final class AbstractEnum implements \Stringable
2425
*
2526
* @var array<string, mixed>|null
2627
*/
27-
private ?array $constants = null;
28+
private ?array $constants = null;
2829

2930
/**
3031
* Creates a new enum.
@@ -53,14 +54,14 @@ public function change($value)
5354
}
5455

5556
/**
56-
* Gets all constants (possible values) as an array.
57-
*
58-
* @param boolean $includeDefault
59-
*
60-
* @return array
61-
*/
62-
public function getConstList($includeDefault = true)
57+
* Gets all constants (possible values) as an array.
58+
*
59+
*
60+
* @return array
61+
*/
62+
public function getConstList(bool $includeDefault = true)
6363
{
64+
$constants = [];
6465
if ($this->constants === null) {
6566
$reflection = new ReflectionClass($this);
6667
$this->constants = $reflection->getConstants();

lib/Common/BitArray.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ final class BitArray
3535
/**
3636
* @var mixed[]|mixed|int[]|null
3737
*/
38-
private $bits;
38+
private $bits;
3939
/**
4040
* @var mixed|null
4141
*/
42-
private $size;
42+
private $size;
4343

4444

4545
public function __construct($bits = [], $size = 0)
@@ -212,7 +212,7 @@ public function clear(): void
212212
* @return true iff all bits are set or not set in range, according to value argument
213213
* @throws InvalidArgumentException if end is less than or equal to start
214214
*/
215-
public function isRange($start, $end, $value)
215+
public function isRange($start, $end, $value): bool
216216
{
217217
if ($end < $start) {
218218
throw new \InvalidArgumentException();
@@ -313,7 +313,7 @@ public function _xor($other)
313313
* @param position $offset in array to start writing
314314
* @param how $numBytes many bytes to write
315315
*/
316-
public function toBytes($bitOffset, &$array, $offset, $numBytes): void
316+
public function toBytes($bitOffset, array &$array, $offset, $numBytes): void
317317
{
318318
for ($i = 0; $i < $numBytes; $i++) {
319319
$theByte = 0;
@@ -332,7 +332,7 @@ public function toBytes($bitOffset, &$array, $offset, $numBytes): void
332332
*
333333
* @return true iff bit i is set
334334
*/
335-
public function get($i)
335+
public function get($i): bool
336336
{
337337
$key = (int)($i / 32);
338338

@@ -390,7 +390,7 @@ public function reverse(): void
390390
// $bits = $newBits;
391391
}
392392

393-
public function equals($o)
393+
public function equals($o): bool
394394
{
395395
if (!($o instanceof BitArray)) {
396396
return false;

lib/Common/BitMatrix.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class BitMatrix
1010
/**
1111
* @var mixed|int[]
1212
*/
13-
private $bits;
13+
private $bits;
1414

1515
public function __construct($width, $height = false, $rowSize = false, $bits = false)
1616
{
@@ -375,7 +375,7 @@ public function getRowSize()
375375
return $this->rowSize;
376376
}
377377

378-
public function equals($o)
378+
public function equals($o): bool
379379
{
380380
if (!($o instanceof BitMatrix)) {
381381
return false;
@@ -388,7 +388,7 @@ public function equals($o)
388388
&& $this->bits === $other->bits;
389389
}
390390

391-
//@Override
391+
392392

393393
public function hashCode()
394394
{
@@ -401,7 +401,7 @@ public function hashCode()
401401
return $hash;
402402
}
403403

404-
//@Override
404+
405405

406406
public function toString($setString = '', $unsetString = '', $lineSeparator = '')
407407
{
@@ -441,7 +441,7 @@ public function toString_($setString, $unsetString, $lineSeparator)
441441
*
442442
* @return value of given bit in matrix
443443
*/
444-
public function get($x, $y)
444+
public function get(int $x, int $y): bool
445445
{
446446
$offset = (int)($y * $this->rowSize + ($x / 32));
447447
if (!isset($this->bits[$offset])) {

lib/Common/BitSource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ final class BitSource
3636
* Bits are read within a byte from most-significant to least-significant bit.
3737
*/
3838
public function __construct(private $bytes)
39-
{
40-
}
39+
{
40+
}
4141

4242
/**
4343
* @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}.

lib/Common/CharacterSetECI.php

Lines changed: 102 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,124 @@
99
final class CharacterSetECI
1010
{
1111
/**#@+
12-
* Character set constants.
12+
* Character set constants.
13+
*/
14+
/**
15+
* @var int
1316
*/
1417
public const CP437 = 0;
18+
/**
19+
* @var int
20+
*/
1521
public const ISO8859_1 = 1;
22+
/**
23+
* @var int
24+
*/
1625
public const ISO8859_2 = 4;
26+
/**
27+
* @var int
28+
*/
1729
public const ISO8859_3 = 5;
30+
/**
31+
* @var int
32+
*/
1833
public const ISO8859_4 = 6;
34+
/**
35+
* @var int
36+
*/
1937
public const ISO8859_5 = 7;
38+
/**
39+
* @var int
40+
*/
2041
public const ISO8859_6 = 8;
42+
/**
43+
* @var int
44+
*/
2145
public const ISO8859_7 = 9;
46+
/**
47+
* @var int
48+
*/
2249
public const ISO8859_8 = 10;
50+
/**
51+
* @var int
52+
*/
2353
public const ISO8859_9 = 11;
54+
/**
55+
* @var int
56+
*/
2457
public const ISO8859_10 = 12;
58+
/**
59+
* @var int
60+
*/
2561
public const ISO8859_11 = 13;
62+
/**
63+
* @var int
64+
*/
2665
public const ISO8859_12 = 14;
66+
/**
67+
* @var int
68+
*/
2769
public const ISO8859_13 = 15;
70+
/**
71+
* @var int
72+
*/
2873
public const ISO8859_14 = 16;
74+
/**
75+
* @var int
76+
*/
2977
public const ISO8859_15 = 17;
78+
/**
79+
* @var int
80+
*/
3081
public const ISO8859_16 = 18;
82+
/**
83+
* @var int
84+
*/
3185
public const SJIS = 20;
86+
/**
87+
* @var int
88+
*/
3289
public const CP1250 = 21;
90+
/**
91+
* @var int
92+
*/
3393
public const CP1251 = 22;
94+
/**
95+
* @var int
96+
*/
3497
public const CP1252 = 23;
98+
/**
99+
* @var int
100+
*/
35101
public const CP1256 = 24;
102+
/**
103+
* @var int
104+
*/
36105
public const UNICODE_BIG_UNMARKED = 25;
106+
/**
107+
* @var int
108+
*/
37109
public const UTF8 = 26;
110+
/**
111+
* @var int
112+
*/
38113
public const ASCII = 27;
114+
/**
115+
* @var int
116+
*/
39117
public const BIG5 = 28;
118+
/**
119+
* @var int
120+
*/
40121
public const GB18030 = 29;
122+
/**
123+
* @var int
124+
*/
41125
public const EUC_KR = 30;
42126
/**
43127
* Map between character names and their ECI values.
44128
*/
45-
private static array $nameToEci = [
129+
private static array $nameToEci = [
46130
'ISO-8859-1' => self::ISO8859_1,
47131
'ISO-8859-2' => self::ISO8859_2,
48132
'ISO-8859-3' => self::ISO8859_3,
@@ -71,23 +155,22 @@ final class CharacterSetECI
71155
'EUC-KR' => self::EUC_KR,
72156
];
73157
/**#@-*/
74-
/**
75-
* Additional possible values for character sets.
76-
*/
77-
private static array $additionalValues = [
158+
/**
159+
* Additional possible values for character sets.
160+
*/
161+
private static array $additionalValues = [
78162
self::CP437 => 2,
79163
self::ASCII => 170,
80164
];
81165
private static int|string|null $name = null;
82166

83167
/**
84-
* Gets character set ECI by value.
85-
*
86-
* @param string $value
87-
*
88-
* @return CharacterSetEci|null
89-
*/
90-
public static function getCharacterSetECIByValue($value)
168+
* Gets character set ECI by value.
169+
*
170+
*
171+
* @return CharacterSetEci|null
172+
*/
173+
public static function getCharacterSetECIByValue(string $value)
91174
{
92175
if ($value < 0 || $value >= 900) {
93176
throw new \InvalidArgumentException('Value must be between 0 and 900');
@@ -136,13 +219,12 @@ public static function name()
136219
}
137220

138221
/**
139-
* Gets character set ECI by name.
140-
*
141-
* @param string $name
142-
*
143-
* @return CharacterSetEci|null
144-
*/
145-
public static function getCharacterSetECIByName($name)
222+
* Gets character set ECI by name.
223+
*
224+
*
225+
* @return CharacterSetEci|null
226+
*/
227+
public static function getCharacterSetECIByName(string $name)
146228
{
147229
$name = strtoupper($name);
148230
if (isset(self::$nameToEci[$name])) {

lib/Common/DecoderResult.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ final class DecoderResult
2929
/**
3030
* @var mixed|null
3131
*/
32-
private $errorsCorrected;
32+
private $errorsCorrected;
3333
/**
3434
* @var mixed|null
3535
*/
36-
private $erasures;
36+
private $erasures;
3737
/**
3838
* @var mixed|null
3939
*/
40-
private $other;
40+
private $other;
4141

4242

4343
public function __construct(private $rawBytes, private $text, private $byteSegments, private $ecLevel, private $structuredAppendSequenceNumber = -1, private $structuredAppendParity = -1)
44-
{
45-
}
44+
{
45+
}
4646

4747
public function getRawBytes()
4848
{
@@ -94,7 +94,7 @@ public function setOther($other): void
9494
$this->other = $other;
9595
}
9696

97-
public function hasStructuredAppend()
97+
public function hasStructuredAppend(): bool
9898
{
9999
return $this->structuredAppendParity >= 0 && $this->structuredAppendSequenceNumber >= 0;
100100
}

0 commit comments

Comments
 (0)