Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit f4ab187

Browse files
authored
Merge pull request #17 from WoltLab/php-8.2
Add support for PHP 8.2 to composer.json
2 parents d91b199 + d301f41 commit f4ab187

File tree

7 files changed

+37
-86
lines changed

7 files changed

+37
-86
lines changed

.laminas-ci.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignore_php_platform_requirements": {
3+
"8.2": true
4+
}
5+
}

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
"sort-packages": true
2020
},
2121
"require": {
22-
"php": "~8.0.0 || ~8.1.0",
22+
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
2323
"laminas/laminas-stdlib": "^3.2.1"
2424
},
2525
"require-dev": {
2626
"laminas/laminas-coding-standard": "~1.0.0",
27-
"laminas/laminas-json": "^3.3",
2827
"laminas/laminas-session": "^2.13",
2928
"phpunit/phpunit": "^9.5.25"
3029
},
3130
"suggest": {
32-
"laminas/laminas-json": "Laminas\\Json component",
3331
"laminas/laminas-session": "To support progressbar persistent"
3432
},
3533
"autoload": {

composer.lock

Lines changed: 15 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Adapter/JsPull.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Laminas\ProgressBar\Adapter;
44

5-
use Laminas\Json\Json;
5+
use function json_encode;
6+
7+
use const JSON_THROW_ON_ERROR;
68

79
/**
810
* Laminas\ProgressBar\Adapter\JsPull offers a simple method for updating a
@@ -51,7 +53,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
5153
'finished' => false
5254
];
5355

54-
$data = Json::encode($arguments);
56+
$data = json_encode($arguments, JSON_THROW_ON_ERROR);
5557

5658
// Output the data
5759
$this->_outputData($data);
@@ -64,7 +66,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
6466
*/
6567
public function finish()
6668
{
67-
$data = Json::encode(['finished' => true]);
69+
$data = json_encode(['finished' => true], JSON_THROW_ON_ERROR);
6870

6971
$this->_outputData($data);
7072
}

src/Adapter/JsPush.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Laminas\ProgressBar\Adapter;
44

5-
use Laminas\Json\Json;
5+
use function json_encode;
6+
7+
use const JSON_THROW_ON_ERROR;
68

79
/**
810
* Laminas\ProgressBar\Adapter\JsPush offers a simple method for updating a
@@ -73,7 +75,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
7375
];
7476

7577
$data = '<script type="text/javascript">'
76-
. 'parent.' . $this->updateMethodName . '(' . Json::encode($arguments) . ');'
78+
. 'parent.' . $this->updateMethodName . '(' . json_encode($arguments, JSON_THROW_ON_ERROR) . ');'
7779
. '</script>';
7880

7981
// Output the data

test/Adapter/JsPullTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use LaminasTest\ProgressBar\TestAsset\JsPullStub;
66
use PHPUnit\Framework\TestCase;
77

8+
use const JSON_THROW_ON_ERROR;
9+
810
class JsPullTest extends TestCase
911
{
1012
public function testJson()
@@ -13,7 +15,7 @@ public function testJson()
1315
$adapter->notify(0, 2, 0.5, 1, 1, 'status');
1416
$output = $adapter->getLastOutput();
1517

16-
$data = json_decode($output, true);
18+
$data = json_decode($output, true, JSON_THROW_ON_ERROR);
1719

1820
$this->assertEquals(0, $data['current']);
1921
$this->assertEquals(2, $data['max']);
@@ -26,7 +28,7 @@ public function testJson()
2628
$adapter->finish();
2729
$output = $adapter->getLastOutput();
2830

29-
$data = json_decode($output, true);
31+
$data = json_decode($output, true, JSON_THROW_ON_ERROR);
3032

3133
$this->assertTrue($data['finished']);
3234
}

test/Adapter/JsPushTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use LaminasTest\ProgressBar\TestAsset\JsPushStub;
66
use PHPUnit\Framework\TestCase;
77

8+
use const JSON_THROW_ON_ERROR;
9+
810
class JsPushTest extends TestCase
911
{
1012
public function testJson()
@@ -19,7 +21,7 @@ public function testJson()
1921
. preg_quote('Laminas\\ProgressBar\\ProgressBar\\Update') . '\((.*?)\);</script>#', $output, $result);
2022
$this->assertEquals(1, $matches);
2123

22-
$data = json_decode($result[1], true);
24+
$data = json_decode($result[1], true, JSON_THROW_ON_ERROR);
2325

2426
$this->assertEquals(0, $data['current']);
2527
$this->assertEquals(2, $data['max']);

0 commit comments

Comments
 (0)