Skip to content

Commit

Permalink
Support PHP 8.2 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-m authored Jan 18, 2024
1 parent 10eccf1 commit 2e967dd
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 23 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
tag: << parameters.version >>
parameters:
version:
default: "7.4"
default: "8.2"
description: The `cimg/php` Docker image version tag.
type: string
install-flags:
Expand All @@ -154,7 +154,7 @@ jobs:
- when:
condition:
and:
- equal: [ "8.1", <<parameters.version>> ]
- equal: [ "8.2", <<parameters.version>> ]
- equal: [ "", <<parameters.install-flags>> ]
steps:
- run-phpunit-tests:
Expand All @@ -164,7 +164,7 @@ jobs:
condition:
not:
and:
- equal: [ "8.1", <<parameters.version>> ]
- equal: [ "8.2", <<parameters.version>> ]
- equal: [ "", <<parameters.install-flags>> ]
steps:
- run-phpunit-tests:
Expand All @@ -176,5 +176,5 @@ workflows:
- matrix-conditions:
matrix:
parameters:
version: ["7.4", "8.0", "8.1"]
version: ["7.4", "8.0", "8.1", "8.2"]
install-flags: ["", "--prefer-lowest"]
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Exclude build/test files from archive
/.circleci export-ignore
/test export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpcs.xml export-ignore
/phpunit.xml export-ignore
/rector.php export-ignore

# Configure diff output for .php and .phar files.
*.php diff=php
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"require-dev": {
"phpunit/phpunit": "^9.4",
"rector/rector": "^0.15.19",
"squizlabs/php_codesniffer": "^3.7"
"squizlabs/php_codesniffer": "^3.7",
"symfony/phpunit-bridge": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 12 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<?xml version="1.0"?>
<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">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
verbose="false">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
<directory>src</directory>
</include>
</coverage>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<php>
<!-- Don't fail for external dependencies. -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>
<testsuites>
<testsuite name="all">
<directory suffix="Test.php" phpVersion="7.2" phpVersionOperator="&gt;=">tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
33 changes: 30 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,42 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {

$rectorConfig->phpVersion(PhpVersion::PHP_74);

$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/src',
__DIR__ . '/test',
__DIR__ . '/rector.php',
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
// Please no dead code or unneeded variables.
SetList::DEAD_CODE,
// Try to figure out type hints.
SetList::TYPE_DECLARATION,
SetList::PHP_82,
]);

$rectorConfig->skip([
// Don't throw errors on JSON parse problems. Yet.
// @todo Throw errors and deal with them appropriately.
JsonThrowOnErrorRector::class,
// We like our tags.
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveUselessVarTagRector::class,
]);

$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
};
8 changes: 3 additions & 5 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ class ValidationException extends \InvalidArgumentException
{
/**
* Validation result report.
*
* @var Opis\JsonSchema\ValidationResult
*/
private $validationResult;
private ValidationResult $validationResult;

/**
* @param string $message
Expand All @@ -33,10 +31,10 @@ public function __construct(string $message, ValidationResult $validationResult)
/**
* Get the validation result object.
*
* @return Opis\JsonSchema\ValidationResult
* @return ValidationResult
* Validation result report.
*/
public function getResult()
public function getResult(): ValidationResult
{
return $this->validationResult;
}
Expand Down
14 changes: 7 additions & 7 deletions src/RootedJsonData.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
class RootedJsonData
{

private $schema;
private $data;
private ?string $schema = null;
private JsonObject $data;

/**
* Constructor method.
Expand Down Expand Up @@ -145,7 +145,7 @@ public function set(string $path, $value)
*
* @param mixed $value
*/
private function normalizeSetValue(&$value)
private function normalizeSetValue(&$value): void
{
if ($value instanceof RootedJsonData) {
$value = $value->{"$"};
Expand All @@ -164,7 +164,7 @@ private function normalizeSetValue(&$value)
*
* @return JsonObject
*/
public function __set($path, $value)
public function __set(string $path, $value)
{
return $this->set($path, $value);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public function __unset($path)
* @param mixed $field
* Field to remove.
*
* @return \JsonPath\JsonObject
* @return JsonObject
* Modified object (self).
*/
public function remove($path, $field)
Expand All @@ -226,10 +226,10 @@ public function remove($path, $field)
/**
* Get the JSON Schema as a string.
*
* @return string
* @return string|null
* The JSON Schema for this object.
*/
public function getSchema()
public function getSchema(): ?string
{
return $this->schema;
}
Expand Down

0 comments on commit 2e967dd

Please sign in to comment.