Skip to content

Commit

Permalink
Merge pull request #5 from IndexZer0/feature/laravel-11
Browse files Browse the repository at this point in the history
Laravel 11
  • Loading branch information
IndexZer0 authored Mar 12, 2024
2 parents 2f60fa0 + 4e9866a commit d39bb29
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
coverage: none

- name: Install composer dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.3, 8.2, 8.1]
laravel: [10.*]
php: [8.3, 8.2]
laravel: [11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
carbon: ^2.63

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `laravel-validation-provider` will be documented in this file.

## v3.0.0 - 2024-03-12
### Changed
- Laravel 11 support.
- Minimum PHP 8.2
- Rely on `\Illuminate\Support\Arr::mapWithKeys` instead of own implementation.

## v2.1.0 - 2024-03-08
### Added
- Ability to define validation `rules`, `messages` and `attributes` by class properties.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ $validationProvider->rules();

## Requirements

- PHP Version >= 8.1
- Laravel Version >= 10
| laravel-validation-provider | PHP Version | Laravel Version |
|-----------------------------|-------------|-----------------|
| 2.x | 8.1+ | 10.x |
| 3.x | 8.2+ | 11.x |

---

Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
}
],
"require": {
"php": "^8.1",
"illuminate/contracts": "^10.0"
"php": "^8.2",
"illuminate/contracts": "^11.0",
"illuminate/support": "^11.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.8",
"larastan/larastan": "^2.0.1",
"orchestra/testbench": "^8.8",
"pestphp/pest": "^2.20",
"pestphp/pest-plugin-arch": "^2.5",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^8.1",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
Expand Down
26 changes: 0 additions & 26 deletions src/Helpers/ArrayHelper.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/ValidationProviders/MapAttributesValidationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace IndexZer0\LaravelValidationProvider\ValidationProviders;

use Illuminate\Support\Arr;
use IndexZer0\LaravelValidationProvider\Contracts\ValidationProvider;
use IndexZer0\LaravelValidationProvider\Helpers\ArrayHelper;
use IndexZer0\LaravelValidationProvider\Traits\HasValidationProviderChild;

class MapAttributesValidationProvider extends AbstractValidationProvider
Expand Down Expand Up @@ -47,7 +47,7 @@ public function attributes(): array

private function mapRules(array $array): array
{
return ArrayHelper::mapWithKeys($array, function ($value, $key) {
return Arr::mapWithKeys($array, function ($value, $key) {
if (array_key_exists($key, $this->mapAttributes)) {
return [$this->mapAttributes[$key] => $value];
}
Expand All @@ -57,7 +57,7 @@ private function mapRules(array $array): array

private function mapMessages(): array
{
return ArrayHelper::mapWithKeys($this->validationProvider->messages(), function ($value, $key) {
return Arr::mapWithKeys($this->validationProvider->messages(), function ($value, $key) {
foreach ($this->mapAttributes as $from => $to) {
if (str_starts_with($key, $from . '.')) {
return [str_replace($from . '.', $to . '.', $key) => $value];
Expand Down
4 changes: 2 additions & 2 deletions src/ValidationProviders/NestedValidationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace IndexZer0\LaravelValidationProvider\ValidationProviders;

use Illuminate\Support\Arr;
use IndexZer0\LaravelValidationProvider\Contracts\ValidationProvider;
use IndexZer0\LaravelValidationProvider\Helpers\ArrayHelper;
use IndexZer0\LaravelValidationProvider\Traits\HasValidationProviderChild;

class NestedValidationProvider extends AbstractValidationProvider
Expand Down Expand Up @@ -53,7 +53,7 @@ protected function getNestedKeyPrefix(): string

private function mapWithKeys(array $array): array
{
return ArrayHelper::mapWithKeys($array, function ($value, $key) {
return Arr::mapWithKeys($array, function ($value, $key) {
return [join('.', [$this->getNestedKeyPrefix(), $key]) => $value];
});
}
Expand Down

0 comments on commit d39bb29

Please sign in to comment.