Skip to content

Commit 9be2b4e

Browse files
Fix nullable types for PHP 8.4 (#12)
1 parent 6bcc078 commit 9be2b4e

16 files changed

+35
-29
lines changed

.cs.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'array_syntax' => ['syntax' => 'short'],
2020
'cast_spaces' => ['space' => 'none'],
2121
'concat_space' => ['spacing' => 'one'],
22-
'compact_nullable_typehint' => true,
22+
'compact_nullable_type_declaration' => true,
2323
'declare_equal_normalize' => ['space' => 'single'],
2424
'general_phpdoc_annotation_remove' => [
2525
'annotations' => [
@@ -36,7 +36,11 @@
3636
'phpdoc_order' => true, // psr-5
3737
'phpdoc_no_useless_inheritdoc' => false,
3838
'protected_to_private' => false,
39-
'yoda_style' => false,
39+
'yoda_style' => [
40+
'equal' => false,
41+
'identical' => false,
42+
'less_and_greater' => false
43+
],
4044
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
4145
'ordered_imports' => [
4246
'sort_algorithm' => 'alpha',

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 odan
3+
Copyright (c) 2025 odan
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ the [notification pattern](https://martinfowler.com/articles/replaceThrowWithNot
2525

2626
## Requirements
2727

28-
* PHP 8.1+
28+
* PHP 8.1 - 8.4
2929

3030
## Installation
3131

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"psr15"
1212
],
1313
"require": {
14-
"php": "^8.1",
14+
"php": "8.1.* || 8.2.* || 8.3.* || 8.4.*",
1515
"ext-json": "*",
1616
"psr/http-factory": "^1.0.1",
1717
"psr/http-server-middleware": "^1.0.1"
@@ -21,7 +21,7 @@
2121
"fig/http-message-util": "^1.1",
2222
"friendsofphp/php-cs-fixer": "^3",
2323
"nyholm/psr7": "^1.4",
24-
"phpstan/phpstan": "^1",
24+
"phpstan/phpstan": "^1 || ^2",
2525
"phpunit/phpunit": "^10",
2626
"relay/relay": "^2.0",
2727
"slim/psr7": "^1",
@@ -53,13 +53,16 @@
5353
"sniffer:check": "phpcs --standard=phpcs.xml",
5454
"sniffer:fix": "phpcbf --standard=phpcs.xml",
5555
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
56-
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
56+
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --display-warnings --display-deprecations --no-coverage",
5757
"test:all": [
5858
"@cs:check",
5959
"@sniffer:check",
6060
"@stan",
6161
"@test"
6262
],
63-
"test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
63+
"test:coverage": [
64+
"@putenv XDEBUG_MODE=coverage",
65+
"phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --display-warnings --display-deprecations --coverage-clover build/coverage/clover.xml --coverage-html build/coverage --coverage-text"
66+
]
6467
}
6568
}

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
parameters:
22
level: 8
33
reportUnmatchedIgnoredErrors: false
4-
checkMissingIterableValueType: false
5-
checkGenericClassInNonGenericObjectType: false
64
paths:
75
- src
86
- tests

src/Converter/CakeValidationConverter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class CakeValidationConverter implements ValidationConverterInterface
1212
/**
1313
* Create validation result from array with errors.
1414
*
15-
* @param array $errors The validation errors
15+
* @param array<mixed> $errors The validation errors
1616
*
1717
* @return ValidationResult The result
1818
*/
@@ -29,7 +29,7 @@ public function createValidationResult($errors): ValidationResult
2929
* Add errors.
3030
*
3131
* @param ValidationResult $result The result
32-
* @param array $errors The errors
32+
* @param array<mixed> $errors The errors
3333
* @param string $path The path
3434
*
3535
* @return void
@@ -48,7 +48,7 @@ private function addErrors(ValidationResult $result, array $errors, string $path
4848
* Add sub errors.
4949
*
5050
* @param ValidationResult $result The result
51-
* @param array $error The error
51+
* @param array<mixed> $error The error
5252
* @param string $path The path
5353
*
5454
* @return void

src/Converter/ValitronValidationValidationConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class ValitronValidationValidationConverter implements ValidationConverter
1212
/**
1313
* Create validation result from array with errors.
1414
*
15-
* @param array $errors The errors
15+
* @param array<mixed> $errors The errors
1616
*
1717
* @return ValidationResult The result
1818
*/

src/Exception/ValidationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ final class ValidationException extends DomainException
2626
*/
2727
public function __construct(
2828
string $message,
29-
ValidationResult $validationResult = null,
29+
?ValidationResult $validationResult = null,
3030
int $code = 422,
31-
Throwable $previous = null
31+
?Throwable $previous = null
3232
) {
3333
parent::__construct($message, $code, $previous);
3434

src/Factory/CakeValidationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function createValidator(): Validator
2424
/**
2525
* Create validation result from array with errors.
2626
*
27-
* @param array $errors The errors
27+
* @param array<mixed> $errors The errors
2828
*
2929
* @return ValidationResult The result
3030
*/

src/Transformer/ErrorDetailsResultTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function __construct(string $detailsName = 'details')
3232
* @param ValidationResult $validationResult The validation result
3333
* @param ValidationException|null $exception The validation exception
3434
*
35-
* @return array The transformed result
35+
* @return array<mixed> The transformed result
3636
*/
37-
public function transform(ValidationResult $validationResult, ValidationException $exception = null): array
37+
public function transform(ValidationResult $validationResult, ?ValidationException $exception = null): array
3838
{
3939
$error = [];
4040

@@ -61,7 +61,7 @@ public function transform(ValidationResult $validationResult, ValidationExceptio
6161
*
6262
* @param ValidationError[] $errors The errors
6363
*
64-
* @return array The details as array
64+
* @return array<mixed> The details as array
6565
*/
6666
private function getErrorDetails(array $errors): array
6767
{

0 commit comments

Comments
 (0)