Skip to content

Commit 2e967dd

Browse files
authored
Support PHP 8.2 (#16)
1 parent 10eccf1 commit 2e967dd

File tree

7 files changed

+70
-23
lines changed

7 files changed

+70
-23
lines changed

.circleci/config.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
tag: << parameters.version >>
144144
parameters:
145145
version:
146-
default: "7.4"
146+
default: "8.2"
147147
description: The `cimg/php` Docker image version tag.
148148
type: string
149149
install-flags:
@@ -154,7 +154,7 @@ jobs:
154154
- when:
155155
condition:
156156
and:
157-
- equal: [ "8.1", <<parameters.version>> ]
157+
- equal: [ "8.2", <<parameters.version>> ]
158158
- equal: [ "", <<parameters.install-flags>> ]
159159
steps:
160160
- run-phpunit-tests:
@@ -164,7 +164,7 @@ jobs:
164164
condition:
165165
not:
166166
and:
167-
- equal: [ "8.1", <<parameters.version>> ]
167+
- equal: [ "8.2", <<parameters.version>> ]
168168
- equal: [ "", <<parameters.install-flags>> ]
169169
steps:
170170
- run-phpunit-tests:
@@ -176,5 +176,5 @@ workflows:
176176
- matrix-conditions:
177177
matrix:
178178
parameters:
179-
version: ["7.4", "8.0", "8.1"]
179+
version: ["7.4", "8.0", "8.1", "8.2"]
180180
install-flags: ["", "--prefer-lowest"]

.gitattributes

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Exclude build/test files from archive
2+
/.circleci export-ignore
3+
/test export-ignore
4+
/.editorconfig export-ignore
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/phpcs.xml export-ignore
8+
/phpunit.xml export-ignore
9+
/rector.php export-ignore
10+
11+
# Configure diff output for .php and .phar files.
12+
*.php diff=php

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"require-dev": {
2222
"phpunit/phpunit": "^9.4",
2323
"rector/rector": "^0.15.19",
24-
"squizlabs/php_codesniffer": "^3.7"
24+
"squizlabs/php_codesniffer": "^3.7",
25+
"symfony/phpunit-bridge": "^7.0"
2526
},
2627
"autoload": {
2728
"psr-4": {

phpunit.xml

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" stopOnFailure="false" stopOnError="false" verbose="true">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
verbose="false">
35
<coverage processUncoveredFiles="true">
46
<include>
5-
<directory suffix=".php">src</directory>
7+
<directory>src</directory>
68
</include>
79
</coverage>
10+
<listeners>
11+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
12+
</listeners>
13+
<php>
14+
<!-- Don't fail for external dependencies. -->
15+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
16+
</php>
817
<testsuites>
918
<testsuite name="all">
10-
<directory suffix="Test.php" phpVersion="7.2" phpVersionOperator="&gt;=">tests</directory>
19+
<directory>tests</directory>
1120
</testsuite>
1221
</testsuites>
1322
</phpunit>

rector.php

+30-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,42 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6+
use Rector\Core\ValueObject\PhpVersion;
7+
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
8+
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
9+
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
10+
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
611
use Rector\Set\ValueObject\LevelSetList;
12+
use Rector\Set\ValueObject\SetList;
713

814
return static function (RectorConfig $rectorConfig): void {
15+
16+
$rectorConfig->phpVersion(PhpVersion::PHP_74);
17+
918
$rectorConfig->paths([
10-
__DIR__ . '/src',
11-
__DIR__ . '/tests',
19+
__DIR__ . '/src',
20+
__DIR__ . '/test',
21+
__DIR__ . '/rector.php',
1222
]);
1323

1424
$rectorConfig->sets([
15-
LevelSetList::UP_TO_PHP_74,
25+
// Please no dead code or unneeded variables.
26+
SetList::DEAD_CODE,
27+
// Try to figure out type hints.
28+
SetList::TYPE_DECLARATION,
29+
SetList::PHP_82,
1630
]);
31+
32+
$rectorConfig->skip([
33+
// Don't throw errors on JSON parse problems. Yet.
34+
// @todo Throw errors and deal with them appropriately.
35+
JsonThrowOnErrorRector::class,
36+
// We like our tags.
37+
RemoveUselessParamTagRector::class,
38+
RemoveUselessReturnTagRector::class,
39+
RemoveUselessVarTagRector::class,
40+
]);
41+
42+
$rectorConfig->importNames();
43+
$rectorConfig->importShortClasses(false);
1744
};

src/Exception/ValidationException.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ class ValidationException extends \InvalidArgumentException
1313
{
1414
/**
1515
* Validation result report.
16-
*
17-
* @var Opis\JsonSchema\ValidationResult
1816
*/
19-
private $validationResult;
17+
private ValidationResult $validationResult;
2018

2119
/**
2220
* @param string $message
@@ -33,10 +31,10 @@ public function __construct(string $message, ValidationResult $validationResult)
3331
/**
3432
* Get the validation result object.
3533
*
36-
* @return Opis\JsonSchema\ValidationResult
34+
* @return ValidationResult
3735
* Validation result report.
3836
*/
39-
public function getResult()
37+
public function getResult(): ValidationResult
4038
{
4139
return $this->validationResult;
4240
}

src/RootedJsonData.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
class RootedJsonData
1818
{
1919

20-
private $schema;
21-
private $data;
20+
private ?string $schema = null;
21+
private JsonObject $data;
2222

2323
/**
2424
* Constructor method.
@@ -145,7 +145,7 @@ public function set(string $path, $value)
145145
*
146146
* @param mixed $value
147147
*/
148-
private function normalizeSetValue(&$value)
148+
private function normalizeSetValue(&$value): void
149149
{
150150
if ($value instanceof RootedJsonData) {
151151
$value = $value->{"$"};
@@ -164,7 +164,7 @@ private function normalizeSetValue(&$value)
164164
*
165165
* @return JsonObject
166166
*/
167-
public function __set($path, $value)
167+
public function __set(string $path, $value)
168168
{
169169
return $this->set($path, $value);
170170
}
@@ -205,7 +205,7 @@ public function __unset($path)
205205
* @param mixed $field
206206
* Field to remove.
207207
*
208-
* @return \JsonPath\JsonObject
208+
* @return JsonObject
209209
* Modified object (self).
210210
*/
211211
public function remove($path, $field)
@@ -226,10 +226,10 @@ public function remove($path, $field)
226226
/**
227227
* Get the JSON Schema as a string.
228228
*
229-
* @return string
229+
* @return string|null
230230
* The JSON Schema for this object.
231231
*/
232-
public function getSchema()
232+
public function getSchema(): ?string
233233
{
234234
return $this->schema;
235235
}

0 commit comments

Comments
 (0)