Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'array_syntax' => ['syntax' => 'short'],
'cast_spaces' => ['space' => 'none'],
'concat_space' => ['spacing' => 'one'],
'compact_nullable_typehint' => true,
'compact_nullable_type_declaration' => true,
'declare_equal_normalize' => ['space' => 'single'],
'general_phpdoc_annotation_remove' => [
'annotations' => [
Expand All @@ -36,7 +36,11 @@
'phpdoc_order' => true, // psr-5
'phpdoc_no_useless_inheritdoc' => false,
'protected_to_private' => false,
'yoda_style' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false
],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 odan
Copyright (c) 2025 odan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ the [notification pattern](https://martinfowler.com/articles/replaceThrowWithNot

## Requirements

* PHP 8.1+
* PHP 8.1 - 8.4

## Installation

Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"psr15"
],
"require": {
"php": "^8.1",
"php": "8.1.* || 8.2.* || 8.3.* || 8.4.*",
"ext-json": "*",
"psr/http-factory": "^1.0.1",
"psr/http-server-middleware": "^1.0.1"
Expand All @@ -21,7 +21,7 @@
"fig/http-message-util": "^1.1",
"friendsofphp/php-cs-fixer": "^3",
"nyholm/psr7": "^1.4",
"phpstan/phpstan": "^1",
"phpstan/phpstan": "^1 || ^2",
"phpunit/phpunit": "^10",
"relay/relay": "^2.0",
"slim/psr7": "^1",
Expand Down Expand Up @@ -53,13 +53,16 @@
"sniffer:check": "phpcs --standard=phpcs.xml",
"sniffer:fix": "phpcbf --standard=phpcs.xml",
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --display-warnings --display-deprecations --no-coverage",
"test:all": [
"@cs:check",
"@sniffer:check",
"@stan",
"@test"
],
"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"
"test:coverage": [
"@putenv XDEBUG_MODE=coverage",
"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"
]
}
}
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
parameters:
level: 8
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
paths:
- src
- tests
Expand Down
6 changes: 3 additions & 3 deletions src/Converter/CakeValidationConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class CakeValidationConverter implements ValidationConverterInterface
/**
* Create validation result from array with errors.
*
* @param array $errors The validation errors
* @param array<mixed> $errors The validation errors
*
* @return ValidationResult The result
*/
Expand All @@ -29,7 +29,7 @@ public function createValidationResult($errors): ValidationResult
* Add errors.
*
* @param ValidationResult $result The result
* @param array $errors The errors
* @param array<mixed> $errors The errors
* @param string $path The path
*
* @return void
Expand All @@ -48,7 +48,7 @@ private function addErrors(ValidationResult $result, array $errors, string $path
* Add sub errors.
*
* @param ValidationResult $result The result
* @param array $error The error
* @param array<mixed> $error The error
* @param string $path The path
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/ValitronValidationValidationConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ValitronValidationValidationConverter implements ValidationConverter
/**
* Create validation result from array with errors.
*
* @param array $errors The errors
* @param array<mixed> $errors The errors
*
* @return ValidationResult The result
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ final class ValidationException extends DomainException
*/
public function __construct(
string $message,
ValidationResult $validationResult = null,
?ValidationResult $validationResult = null,
int $code = 422,
Throwable $previous = null
?Throwable $previous = null
) {
parent::__construct($message, $code, $previous);

Expand Down
2 changes: 1 addition & 1 deletion src/Factory/CakeValidationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function createValidator(): Validator
/**
* Create validation result from array with errors.
*
* @param array $errors The errors
* @param array<mixed> $errors The errors
*
* @return ValidationResult The result
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Transformer/ErrorDetailsResultTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function __construct(string $detailsName = 'details')
* @param ValidationResult $validationResult The validation result
* @param ValidationException|null $exception The validation exception
*
* @return array The transformed result
* @return array<mixed> The transformed result
*/
public function transform(ValidationResult $validationResult, ValidationException $exception = null): array
public function transform(ValidationResult $validationResult, ?ValidationException $exception = null): array
{
$error = [];

Expand All @@ -61,7 +61,7 @@ public function transform(ValidationResult $validationResult, ValidationExceptio
*
* @param ValidationError[] $errors The errors
*
* @return array The details as array
* @return array<mixed> The details as array
*/
private function getErrorDetails(array $errors): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Transformer/ResultTransformerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ResultTransformerInterface
* @param ValidationResult $validationResult The validation result
* @param ValidationException|null $exception The validation exception
*
* @return array The transformed result
* @return array<string> The transformed result
*/
public function transform(ValidationResult $validationResult, ValidationException $exception = null): array;
public function transform(ValidationResult $validationResult, ?ValidationException $exception = null): array;
}
2 changes: 1 addition & 1 deletion src/ValidationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function clear(): void
* The message SHOULD be limited to a concise single sentence
* @param string|null $code A numeric or alphanumeric value that indicates the error type that occurred. (optional)
*/
public function addError(string $field, string $message, string $code = null): void
public function addError(string $field, string $message, ?string $code = null): void
{
$error = new ValidationError($message);
$error->setField($field)->setCode($code);
Expand Down
2 changes: 1 addition & 1 deletion tests/Converter/CakeValidationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CakeValidationFactoryTest extends TestCase
*
* @param ValidationResult $validationResult The result
*
* @return array The array
* @return array<string> The array
*/
private function getValidationResultAsArray(ValidationResult $validationResult): array
{
Expand Down
7 changes: 4 additions & 3 deletions tests/Factory/CakeValidationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Selective\Validation\Test\Factory;

use Cake\Validation\Validator;
use PHPUnit\Framework\TestCase;
use Selective\Validation\Factory\CakeValidationFactory;
use Selective\Validation\ValidationError;
Expand All @@ -18,9 +19,9 @@ class CakeValidationFactoryTest extends TestCase
*/
public function testCreateValidator()
{
(new CakeValidationFactory())->createValidator();
$validator = (new CakeValidationFactory())->createValidator();

$this->assertTrue(true);
$this->assertInstanceOf(Validator::class, $validator);
}

/**
Expand Down Expand Up @@ -111,7 +112,7 @@ public function testCreateResultFromErrorsSimple()
*
* @param ValidationError $error The error
*
* @return array Data
* @return array<string> Data
*/
private function toArray(ValidationError $error): array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/MiddlewareTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait MiddlewareTestTrait
/**
* Run middleware stack.
*
* @param array $queue The queue
* @param array<mixed> $queue The queue
*
* @return ResponseInterface The response
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/TestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestService
*
* @throws ValidationException
*
* @return array Result data
* @return array<mixed> Result data
*/
public function process(int $id): array
{
Expand Down
Loading