Skip to content

Commit 7cef325

Browse files
authored
Upgrade to php 8.4 (#3)
* Added test script to composer.json #KDS-559 * Added PHP 8.4 to CI #KDS-559 * Fixed deprecation in JPEGService
1 parent 0741351 commit 7cef325

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Codeception Tests
22

3-
on: [push]
3+
on: [ push ]
44

55
jobs:
66
build:
@@ -11,18 +11,18 @@ jobs:
1111
strategy:
1212
matrix:
1313
operating-system: [ ubuntu-latest, ubuntu-22.04 ]
14-
php: [ '8.0', '8.1']
14+
php: [ '8.0', '8.1', '8.4' ]
1515

1616
steps:
1717
- uses: actions/checkout@master
1818

1919
- name: Setup PHP
20-
uses: nanasess/setup-php@master
20+
uses: shivammathur/setup-php@master
2121
with:
2222
php-version: ${{ matrix.php }}
2323

2424
- name: Install dependencies
2525
run: composer install
2626

2727
- name: Run tests
28-
run: php vendor/bin/codecept run
28+
run: composer run test

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"require-dev": {
2020
"codeception/codeception": "^5.0.1",
2121
"codeception/module-asserts": "^3.0.0"
22+
},
23+
"scripts": {
24+
"test": "codecept run"
2225
}
2326
}

src/JPEGService.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,27 @@
1313
*/
1414
class JPEGService
1515
{
16-
/**
17-
* @var string
18-
*/
19-
private $bin_path;
20-
21-
/**
22-
* @var string
23-
*/
24-
private $args;
25-
2616
/**
2717
* @param string|null $bin_path optional path to `jpeg-recompress` binary (defaults to a built-in binary)
2818
* @param string $args command-line arguments for `jpeg-recompress`, with {INPUT} and {OUTPUT} placeholders
2919
*/
30-
public function __construct(string $bin_path = null, string $args = "--min 50 {INPUT} {OUTPUT}")
31-
{
20+
public function __construct(
21+
private ?string $bin_path = null,
22+
private string $args = "--min 50 {INPUT} {OUTPUT}"
23+
) {
3224
if ($bin_path === null) {
3325
$bin_dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR;
3426

3527
if (strncasecmp(PHP_OS, "LINUX", 5) === 0) {
36-
$bin_path = $bin_dir . "linux" . DIRECTORY_SEPARATOR . "jpeg-recompress";
28+
$this->bin_path = $bin_dir . "linux" . DIRECTORY_SEPARATOR . "jpeg-recompress";
3729
} elseif (strncasecmp(PHP_OS, "DARWIN", 6) === 0) {
38-
$bin_path = $bin_dir . "mac" . DIRECTORY_SEPARATOR . "jpeg-recompress";
30+
$this->bin_path = $bin_dir . "mac" . DIRECTORY_SEPARATOR . "jpeg-recompress";
3931
} elseif (strncasecmp(PHP_OS, "WIN", 3) === 0) {
40-
$bin_path = $bin_dir . "win" . DIRECTORY_SEPARATOR . "jpeg-recompress.exe";
32+
$this->bin_path = $bin_dir . "win" . DIRECTORY_SEPARATOR . "jpeg-recompress.exe";
4133
} else {
4234
throw new RuntimeException("unsupported OS: " . PHP_OS);
4335
}
4436
}
45-
46-
$this->bin_path = $bin_path;
47-
$this->args = $args;
4837
}
4938

5039
/**
@@ -55,7 +44,7 @@ public function __construct(string $bin_path = null, string $args = "--min 50 {I
5544
*
5645
* @throws ProcessFailedException on failure to execute the command-line tool
5746
*/
58-
public function compress(string $input, string $output)
47+
public function compress(string $input, string $output): void
5948
{
6049
$command = strtr(
6150
"{$this->bin_path} {$this->args}",

0 commit comments

Comments
 (0)