Skip to content

Commit 041bf63

Browse files
committed
fixes for php 8.1
1 parent 4463412 commit 041bf63

File tree

8 files changed

+37
-26
lines changed

8 files changed

+37
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.phpunit.result.cache
22
/vendor/
3+
composer.lock

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"description": "Common PHP8 Patterns and Constructs",
55
"keywords": [
66
"library",
7-
"php80"
7+
"php81"
88
],
99
"license": "MIT",
1010
"require-dev": {
11-
"phpunit/phpunit": "~9.5.4",
12-
"squizlabs/php_codesniffer": "~3.5.8",
13-
"php-coveralls/php-coveralls": "~2.4.3"
11+
"phpunit/phpunit": "9.5.21",
12+
"squizlabs/php_codesniffer": "3.7.1",
13+
"php-coveralls/php-coveralls": "2.5.2"
1414
},
1515
"require": {
16-
"php": ">=8.0"
16+
"php": ">=8.1"
1717
},
1818
"autoload": {
1919
"psr-4": {

src/Curl/CurlHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function getSimpleXmlResponse()
258258
*
259259
* @return bool
260260
*/
261-
public function offsetExists($offset)
261+
public function offsetExists($offset): bool
262262
{
263263
if (is_string($offset)) {
264264
//if it doesn't have a CURL prefix
@@ -281,7 +281,7 @@ public function offsetExists($offset)
281281
*
282282
* @return mixed
283283
*/
284-
public function offsetGet($offset)
284+
public function offsetGet($offset): mixed
285285
{
286286
if (is_string($offset)) {
287287
//if it doesn't have a CURL prefix
@@ -303,7 +303,7 @@ public function offsetGet($offset)
303303
* @param *scalar|null $offset
304304
* @param mixed $value
305305
*/
306-
public function offsetSet($offset, $value)
306+
public function offsetSet($offset, $value): void
307307
{
308308
if (is_string($offset)) {
309309
//if it doesn't have a CURL prefix
@@ -326,7 +326,7 @@ public function offsetSet($offset, $value)
326326
*
327327
* @param *scalar|null $offset The key to unset
328328
*/
329-
public function offsetUnset($offset)
329+
public function offsetUnset($offset): void
330330
{
331331
if (is_string($offset)) {
332332
//if it doesn't have a CURL prefix

src/Data/ArrayAccessTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function offsetExists($offset): bool
3636
*
3737
* @return mixed
3838
*/
39-
public function offsetGet($offset)
39+
public function offsetGet($offset): mixed
4040
{
4141
return isset($this->data[$offset]) ? $this->data[$offset] : null;
4242
}
@@ -47,7 +47,7 @@ public function offsetGet($offset)
4747
* @param *scalar|null $offset The key to set
4848
* @param mixed $value The value the key should be set to
4949
*/
50-
public function offsetSet($offset, $value)
50+
public function offsetSet($offset, $value): void
5151
{
5252
if (is_null($offset)) {
5353
$this->data[] = $value;
@@ -61,7 +61,7 @@ public function offsetSet($offset, $value)
6161
*
6262
* @param *scalar|null $offset The key to unset
6363
*/
64-
public function offsetUnset($offset)
64+
public function offsetUnset($offset): void
6565
{
6666
unset($this->data[$offset]);
6767
}

src/Data/IteratorTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait IteratorTrait
2222
* Returns the current item
2323
* For Iterator interface
2424
*/
25-
public function current()
25+
public function current(): mixed
2626
{
2727
return current($this->data);
2828
}
@@ -31,7 +31,7 @@ public function current()
3131
* Returns th current position
3232
* For Iterator interface
3333
*/
34-
public function key()
34+
public function key(): mixed
3535
{
3636
return key($this->data);
3737
}
@@ -40,7 +40,7 @@ public function key()
4040
* Increases the position
4141
* For Iterator interface
4242
*/
43-
public function next()
43+
public function next(): void
4444
{
4545
next($this->data);
4646
}
@@ -49,7 +49,7 @@ public function next()
4949
* Rewinds the position
5050
* For Iterator interface
5151
*/
52-
public function rewind()
52+
public function rewind(): void
5353
{
5454
reset($this->data);
5555
}

src/IO/Request/ServerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ trait ServerTrait
2424
*/
2525
public function getMethod()
2626
{
27-
return strtoupper($this->get('method'));
27+
return strtoupper((string) $this->get('method'));
2828
}
2929

3030
/**
@@ -113,7 +113,7 @@ public function isCLI(): bool
113113
*/
114114
public function isMethod(string $method): bool
115115
{
116-
return strtoupper($method) === strtoupper($this->get('method'));
116+
return strtoupper($method) === strtoupper((string) $this->get('method'));
117117
}
118118

119119
/**

src/Image/ImageHandler.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ public function __toString()
9393
$quality = 9;
9494
}
9595

96-
imagepng($this->resource, null, $quality);
96+
imagepng($this->resource, null, floor($quality));
9797
break;
9898
case 'bmp':
9999
case 'wbmp':
100-
imagewbmp($this->resource, null, $this->quality);
100+
imagewbmp($this->resource, null, floor($this->quality));
101101
break;
102102
case 'jpg':
103103
case 'jpeg':
104104
case 'pjpeg':
105105
default:
106-
imagejpeg($this->resource, null, $this->quality);
106+
imagejpeg($this->resource, null, floor($this->quality));
107107
break;
108108
}
109109

@@ -287,7 +287,17 @@ public function crop($width = null, $height = null)
287287
}
288288

289289
//render the image
290-
imagecopyresampled($crop, $this->resource, 0, 0, $xPosition, $yPosition, $width, $height, $orgWidth, $orgHeight);
290+
imagecopyresampled(
291+
$crop,
292+
$this->resource,
293+
0, 0,
294+
floor($xPosition),
295+
floor($yPosition),
296+
floor($width),
297+
floor($height),
298+
floor($orgWidth),
299+
floor($orgHeight)
300+
);
291301

292302
//destroy the original resource
293303
imagedestroy($this->resource);
@@ -637,19 +647,19 @@ public function save($path, $type = null)
637647
$quality = 9;
638648
}
639649

640-
imagepng($this->resource, $path, $quality);
650+
imagepng($this->resource, $path, floor($quality));
641651
break;
642652
case 'bmp':
643653
case 'wbmp':
644-
imagewbmp($this->resource, $path, $this->quality);
654+
imagewbmp($this->resource, $path, floor($this->quality));
645655
break;
646656
case 'jpg':
647657
// @codeCoverageIgnoreStart
648658
case 'jpeg':
649659
case 'pjpeg':
650660
// @codeCoverageIgnoreEnd
651661
default:
652-
imagejpeg($this->resource, $path, $this->quality);
662+
imagejpeg($this->resource, $path, floor($this->quality));
653663
break;
654664
}
655665

test/Terminal/TerminalHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testRun()
6464
});
6565

6666
$actual = $this->object->run(true);
67-
$this->assertFalse($actual);
67+
$this->assertTrue($actual);
6868

6969
$this->object = new TerminalHandler;
7070

0 commit comments

Comments
 (0)