Passed
Push — master ( 0e9290...52a373 )
by Josh
02:21
created
src/Exceptions/EncodingException.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 class EncodingException extends InvalidArgumentException
13 13
 {
14 14
 	/**
15
-	* @var mixed Value that caused this exception to be thrown
16
-	*/
15
+	 * @var mixed Value that caused this exception to be thrown
16
+	 */
17 17
 	protected $value;
18 18
 
19 19
 	public function __construct(string $message, $value)
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	/**
26
-	* Return the value that caused this exception to be thrown
27
-	*
28
-	* @return mixed
29
-	*/
26
+	 * Return the value that caused this exception to be thrown
27
+	 *
28
+	 * @return mixed
29
+	 */
30 30
 	public function getValue()
31 31
 	{
32 32
 		return $this->value;
Please login to merge, or discard this patch.
tests/Test.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	/**
23
-	* @group memory
24
-	*/
23
+	 * @group memory
24
+	 */
25 25
 	public function testMemoryList()
26 26
 	{
27 27
 		$len = 10000;
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	}
52 52
 
53 53
 	/**
54
-	* @group memory
55
-	*/
54
+	 * @group memory
55
+	 */
56 56
 	public function testMemoryString()
57 57
 	{
58 58
 		$reference = memory_get_peak_usage();
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	/**
85
-	* @dataProvider getEncodeTests
86
-	*/
85
+	 * @dataProvider getEncodeTests
86
+	 */
87 87
 	public function testEncode($bencoded, $value)
88 88
 	{
89 89
 		$this->assertSame($bencoded, Bencode::encode($value));
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 
169 169
 	/**
170
-	* @dataProvider getEncodeInvalidTests
171
-	*/
170
+	 * @dataProvider getEncodeInvalidTests
171
+	 */
172 172
 	public function testEncodeInvalid($input)
173 173
 	{
174 174
 		$this->expectException(EncodingException::class);
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	}
200 200
 
201 201
 	/**
202
-	* @dataProvider getDecodeTests
203
-	*/
202
+	 * @dataProvider getDecodeTests
203
+	 */
204 204
 	public function testDecode($bencoded, $value)
205 205
 	{
206 206
 		$this->assertEquals($value, Bencode::decode($bencoded));
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	}
285 285
 
286 286
 	/**
287
-	* @dataProvider getDecodeInvalidTests
288
-	*/
287
+	 * @dataProvider getDecodeInvalidTests
288
+	 */
289 289
 	public function testDecodeInvalid($input, $expected)
290 290
 	{
291 291
 		$this->expectException(get_class($expected));
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		fclose($fp);
193 193
 
194 194
 		return [
195
-			[function(){}],
195
+			[function () {}],
196 196
 			[1.2],
197 197
 			[$fp],
198 198
 		];
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$dict = Bencode::decode('d3:bar4:spam3:fooi42ee');
494 494
 
495 495
 		$this->assertSame('spam', $dict->bar);
496
-		$this->assertSame(42,     $dict['foo']);
496
+		$this->assertSame(42, $dict['foo']);
497 497
 
498 498
 		$actual = [];
499 499
 		foreach ($dict as $k => $v)
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -192,7 +192,9 @@
 block discarded – undo
192 192
 		fclose($fp);
193 193
 
194 194
 		return [
195
-			[function(){}],
195
+			[function()
196
+			{
197
+}],
196 198
 			[1.2],
197 199
 			[$fp],
198 200
 		];
Please login to merge, or discard this patch.
src/Encoder.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,8 @@
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	/**
85
-	* Encode a PHP array into either a list of a dictionary
86
-	*/
85
+	 * Encode a PHP array into either a list of a dictionary
86
+	 */
87 87
 	protected static function encodeArray(array $value): string
88 88
 	{
89 89
 		return self::arrayIsList($value)
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 		throw new EncodingException('Unsupported value', $value);
68 68
 	}
69 69
 
70
-	protected static function coerceUnsupportedValue($value): array|int|string
70
+	protected static function coerceUnsupportedValue($value): array | int | string
71 71
 	{
72 72
 		if (is_float($value))
73 73
 		{
Please login to merge, or discard this patch.
src/Decoder.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@  discard block
 block discarded – undo
15 15
 class Decoder
16 16
 {
17 17
 	/**
18
-	* @var string Bencoded string being decoded
19
-	*/
18
+	 * @var string Bencoded string being decoded
19
+	 */
20 20
 	protected string $bencoded;
21 21
 
22 22
 	/**
23
-	* @var int Length of the bencoded string
24
-	*/
23
+	 * @var int Length of the bencoded string
24
+	 */
25 25
 	protected int $len;
26 26
 
27 27
 	/**
28
-	* @var int Safe rightmost boundary
29
-	*/
28
+	 * @var int Safe rightmost boundary
29
+	 */
30 30
 	protected int $max;
31 31
 
32 32
 	/**
33
-	* @var int Position of the cursor while decoding
34
-	*/
33
+	 * @var int Position of the cursor while decoding
34
+	 */
35 35
 	protected int $offset = 0;
36 36
 
37 37
 	public static function decode(string $bencoded): ArrayObject|array|int|string
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	}
70 70
 
71 71
 	/**
72
-	* Check the cursor's position after decoding is done
73
-	*/
72
+	 * Check the cursor's position after decoding is done
73
+	 */
74 74
 	protected function checkCursorPosition(): void
75 75
 	{
76 76
 		if ($this->offset !== $this->len)
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	/**
103
-	* Adjust the rightmost boundary to the last safe character that can start a value
104
-	*
105
-	* Will rewind the boundary to skip the rightmost digits, optionally preceded by "i" or "i-"
106
-	*/
103
+	 * Adjust the rightmost boundary to the last safe character that can start a value
104
+	 *
105
+	 * Will rewind the boundary to skip the rightmost digits, optionally preceded by "i" or "i-"
106
+	 */
107 107
 	protected function computeSafeBoundary(): void
108 108
 	{
109 109
 		$boundary = $this->len - 1;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	*/
35 35
 	protected int $offset = 0;
36 36
 
37
-	public static function decode(string $bencoded): ArrayObject|array|int|string
37
+	public static function decode(string $bencoded): ArrayObject | array | int | string
38 38
 	{
39 39
 		$decoder = new static($bencoded);
40 40
 		$value   = $decoder->decodeAnything();
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 		if ($this->max < 1)
62 62
 		{
63
-			throw match ($this->bencoded[0])
63
+			throw match($this->bencoded[0])
64 64
 			{
65 65
 				'-', 'e' => new DecodingException('Illegal character', 0),
66 66
 				default  => new DecodingException('Premature end of data', $this->len - 1)
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 		while (str_contains('0123456789', $c) && --$boundary >= 0);
115 115
 
116
-		$this->max = match ($c)
116
+		$this->max = match($c)
117 117
 		{
118 118
 			'-'     => $boundary - 2,
119 119
 			'i'     => $boundary - 1,
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 		$this->checkBoundary();
123 123
 	}
124 124
 
125
-	protected function decodeAnything(): ArrayObject|array|int|string
125
+	protected function decodeAnything(): ArrayObject | array | int | string
126 126
 	{
127
-		return match ($this->bencoded[$this->offset])
127
+		return match($this->bencoded[$this->offset])
128 128
 		{
129 129
 			'd'     => $this->decodeDictionary(),
130 130
 			'i'     => $this->decodeInteger(),
Please login to merge, or discard this patch.