Skip to content

Commit 69a19bb

Browse files
authored
Merge branch 'master' into copilot/migrate-from-coveralls-to-codecov
2 parents d8908d4 + dd79b22 commit 69a19bb

33 files changed

Lines changed: 1102 additions & 1596 deletions

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
php-version:
19-
- "7.3"
20-
- "7.4"
21-
- "8.0"
22-
- "8.1"
2319
- "8.2"
2420
- "8.3"
21+
- "8.4"
22+
- "8.5"
2523

2624
steps:
2725
- name: Checkout
@@ -49,3 +47,10 @@ jobs:
4947
env:
5048
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5149
if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}
50+
51+
coding-standard:
52+
name: Coding Standard
53+
uses: brick/coding-standard/.github/workflows/coding-standard.yml@v4
54+
with:
55+
php-version: "8.2"
56+
working-directory: "tools/ecs"

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/vendor
22
/composer.lock
3-
/.phpunit.result.cache
3+
/.phpunit.cache
4+
5+
/tools/*
6+
!/tools/ecs/composer.json
7+
!/tools/ecs/ecs.php

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ composer require brick/std
4343
Requirements
4444
------------
4545

46-
This library requires PHP 7.2 or later.
46+
This library requires PHP 8.2 or later.
4747

4848
Overview
4949
--------

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
],
99
"license": "MIT",
1010
"require": {
11-
"php": "^7.3 || ^8.0"
11+
"php": "^8.2"
1212
},
1313
"require-dev": {
1414
"ext-curl": "*",
1515
"ext-json": "*",
16-
"phpunit/phpunit": "^9.0"
16+
"phpunit/phpunit": "^11.5"
1717
},
1818
"suggest": {
1919
"ext-json": "Required to use JsonEncoder and JsonDecoder"

phpunit.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
33
<testsuites>
44
<testsuite name="Std tests">
55
<directory>tests</directory>
66
</testsuite>
77
</testsuites>
8-
<coverage processUncoveredFiles="true">
8+
<source>
99
<include>
1010
<directory suffix=".php">src</directory>
1111
</include>
12-
</coverage>
12+
</source>
1313
</phpunit>

src/Curl/Curl.php

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44

55
namespace Brick\Std\Curl;
66

7+
use function curl_copy_handle;
8+
use function curl_error;
9+
use function curl_exec;
10+
use function curl_getinfo;
11+
use function curl_init;
12+
use function curl_setopt;
13+
use function curl_setopt_array;
14+
use function curl_version;
15+
16+
use const CURLOPT_RETURNTRANSFER;
17+
718
/**
819
* An object wrapper for cURL.
920
*/
10-
class Curl
21+
final class Curl
1122
{
1223
/**
1324
* The cURL handle.
@@ -18,38 +29,16 @@ class Curl
1829

1930
/**
2031
* Class constructor.
21-
*
22-
* @param string|null $url
2332
*/
2433
public function __construct(?string $url = null)
2534
{
2635
$this->curl = ($url === null) ? curl_init() : curl_init($url);
2736
}
2837

2938
/**
30-
* Class destructor.
31-
*/
32-
public function __destruct()
33-
{
34-
curl_close($this->curl);
35-
}
36-
37-
/**
38-
* Clone handler.
39-
*
40-
* @return void
41-
*/
42-
public function __clone()
43-
{
44-
$this->curl = curl_copy_handle($this->curl);
45-
}
46-
47-
/**
48-
* @return string
49-
*
5039
* @throws CurlException
5140
*/
52-
public function execute() : string
41+
public function execute(): string
5342
{
5443
// This option must always be set.
5544
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
@@ -70,10 +59,8 @@ public function execute() : string
7059
* Otherwise, an associative array of values is returned.
7160
*
7261
* @param int|null $opt One of the CURLINFO_* constants, or null to return all.
73-
*
74-
* @return mixed
7562
*/
76-
public function getInfo(?int $opt = null)
63+
public function getInfo(?int $opt = null): mixed
7764
{
7865
if ($opt === null) {
7966
return curl_getinfo($this->curl);
@@ -82,32 +69,26 @@ public function getInfo(?int $opt = null)
8269
return curl_getinfo($this->curl, $opt);
8370
}
8471

85-
/**
86-
* @param int $option
87-
* @param mixed $value
88-
*
89-
* @return void
90-
*/
91-
public function setOption(int $option, $value) : void
72+
public function setOption(int $option, mixed $value): void
9273
{
9374
curl_setopt($this->curl, $option, $value);
9475
}
9576

96-
/**
97-
* @param array $options
98-
*
99-
* @return void
100-
*/
101-
public function setOptions(array $options) : void
77+
public function setOptions(array $options): void
10278
{
10379
curl_setopt_array($this->curl, $options);
10480
}
10581

82+
public static function getVersion(): array
83+
{
84+
return curl_version();
85+
}
86+
10687
/**
107-
* @return array
88+
* Clone handler.
10889
*/
109-
public static function getVersion() : array
90+
public function __clone()
11091
{
111-
return curl_version();
92+
$this->curl = curl_copy_handle($this->curl);
11293
}
11394
}

src/Curl/CurlException.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
namespace Brick\Std\Curl;
66

7+
use RuntimeException;
8+
9+
use function sprintf;
10+
711
/**
812
* Exception thrown when a Curl request fails.
913
*/
10-
class CurlException extends \RuntimeException
14+
final class CurlException extends RuntimeException
1115
{
12-
/**
13-
* @param string $error
14-
*
15-
* @return CurlException
16-
*/
17-
public static function error(string $error) : CurlException
16+
public static function error(string $error): CurlException
1817
{
1918
return new self(sprintf('cURL request failed: %s.', $error));
2019
}

0 commit comments

Comments
 (0)