Skip to content

Commit 41e4ac5

Browse files
committed
Update PHPUnit and adopt Pint
1 parent 0d1a302 commit 41e4ac5

16 files changed

Lines changed: 190 additions & 198 deletions

.github/workflows/run-tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
12-
php: [8.1, 8.2]
13-
laravel: [9.*, 10.*]
12+
php: [8.2, 8.3, 8.4, 8.5]
13+
laravel: [11.*, 12.*, 13.*]
1414
stability: [prefer-lowest, prefer-stable]
1515
include:
16-
- laravel: 9.*
1716
- laravel: 10.*
17+
- laravel: 11.*
18+
- laravel: 13.*
1819

1920
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2021

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
},
2424
"require-dev": {
2525
"mockery/mockery": "^1.4.4",
26-
"phpunit/phpunit": "~9.0"
26+
"phpunit/phpunit": "~12.0",
27+
"laravel/pint": "^1.29"
2728
},
2829
"autoload": {
2930
"psr-4": {

src/Injectors/UniqueInjector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait UniqueInjector
99
* if required.
1010
*
1111
* @param array $parameters
12-
* @param string $field
12+
* @param string $field
1313
* @return string
1414
*/
1515
protected function prepareUniqueRule($parameters, $field)
@@ -51,6 +51,6 @@ protected function prepareUniqueRule($parameters, $field)
5151
}
5252
}
5353

54-
return 'unique:' . implode(',', $parameters);
54+
return 'unique:'.implode(',', $parameters);
5555
}
5656
}

src/Injectors/UniqueWithInjector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trait UniqueWithInjector
88
* Prepare a unique_with rule, adding the model identifier if required.
99
*
1010
* @param array $parameters
11-
* @param string $field
11+
* @param string $field
1212
* @return string
1313
*/
1414
protected function prepareUniqueWithRule($parameters, $field)
@@ -22,6 +22,6 @@ protected function prepareUniqueWithRule($parameters, $field)
2222
}
2323
}
2424

25-
return 'unique_with:' . implode(',', $parameters);
25+
return 'unique_with:'.implode(',', $parameters);
2626
}
2727
}

src/ValidatingInterface.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Watson\Validating;
44

5-
use Illuminate\Support\MessageBag;
6-
use Illuminate\Support\Facades\Input;
5+
use Illuminate\Database\Eloquent\Model;
76
use Illuminate\Support\Facades\Validator;
7+
use Illuminate\Support\MessageBag;
88
use Illuminate\Validation\Factory;
99

1010
interface ValidatingInterface
@@ -17,10 +17,10 @@ interface ValidatingInterface
1717
*/
1818
public function getValidating();
1919

20-
/**
20+
/**
2121
* Set whether the model should attempt validation on saving.
2222
*
23-
* @param bool $value
23+
* @param bool $value
2424
* @return void
2525
*/
2626
public function setValidating($value);
@@ -37,8 +37,9 @@ public function getThrowValidationExceptions();
3737
* Set whether the model should raise an exception or
3838
* return a boolean on a failed validation.
3939
*
40-
* @param bool $value
40+
* @param bool $value
4141
* @return void
42+
*
4243
* @throws InvalidArgumentException
4344
*/
4445
public function setThrowValidationExceptions($value);
@@ -55,16 +56,17 @@ public function getInjectUniqueIdentifier();
5556
* Set the model to add unique identifier to rules when performing
5657
* validation.
5758
*
58-
* @param bool $value
59+
* @param bool $value
5960
* @return void
61+
*
6062
* @throws InvalidArgumentException
6163
*/
6264
public function setInjectUniqueIdentifier($value);
6365

6466
/**
6567
* Get the model.
6668
*
67-
* @return \Illuminate\Database\Eloquent\Model
69+
* @return Model
6870
*/
6971
public function getModel();
7072

@@ -85,22 +87,20 @@ public function getRules();
8587
/**
8688
* Set the global validation rules.
8789
*
88-
* @param array $rules
8990
* @return void
9091
*/
9192
public function setRules(?array $rules = null);
9293

9394
/**
9495
* Get the validation error messages from the model.
9596
*
96-
* @return \Illuminate\Support\MessageBag
97+
* @return MessageBag
9798
*/
9899
public function getErrors();
99100

100101
/**
101102
* Set the error messages.
102103
*
103-
* @param \Illuminate\Support\MessageBag $validationErrors
104104
* @return void
105105
*/
106106
public function setErrors(MessageBag $validationErrors);
@@ -116,7 +116,8 @@ public function isValid();
116116
* Returns if the model is valid, otherwise throws an exception.
117117
*
118118
* @return bool
119-
* @throws \Watson\Validating\ValidationException
119+
*
120+
* @throws ValidationException
120121
*/
121122
public function isValidOrFail();
122123

@@ -139,7 +140,8 @@ public function forceSave();
139140
* instead of returning a boolean (which is the default behaviour).
140141
*
141142
* @return void
142-
* @throws \Watson\Validating\ValidatingException
143+
*
144+
* @throws ValidatingException
143145
*/
144146
public function saveOrFail();
145147

@@ -154,22 +156,20 @@ public function saveOrReturn();
154156
/**
155157
* Get the Validator instance
156158
*
157-
* @return \Illuminate\Validation\Factory
159+
* @return Factory
158160
*/
159161
public function getValidator();
160162

161163
/**
162164
* Set the Validator instance
163-
*
164-
* @param \Illuminate\Validation\Factory $validator
165165
*/
166166
public function setValidator(Factory $validator);
167167

168168
/**
169169
* Throw a validation exception.
170170
*
171-
* @throws \Watson\Validating\ValidationException
172-
*/
171+
* @throws ValidationException
172+
*/
173173
public function throwValidationException();
174174

175175
/**

src/ValidatingModel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
namespace Watson\Validating;
44

5-
use Illuminate\Database\Eloquent\Model as Eloquent;
65
use Illuminate\Contracts\Support\MessageProvider;
6+
use Illuminate\Database\Eloquent\Model as Eloquent;
7+
use Illuminate\Support\MessageBag;
78

89
abstract class ValidatingModel extends Eloquent implements MessageProvider, ValidatingInterface
910
{
1011
/**
1112
* Make model validate attributes.
1213
*
13-
* @see \Watson\Validating\ValidatingTrait
14+
* @see ValidatingTrait
1415
*/
1516
use ValidatingTrait;
1617

@@ -24,7 +25,7 @@ abstract class ValidatingModel extends Eloquent implements MessageProvider, Vali
2425
/**
2526
* Get the messages for the instance.
2627
*
27-
* @return \Illuminate\Support\MessageBag
28+
* @return MessageBag
2829
*/
2930
public function getMessageBag()
3031
{

src/ValidatingObserver.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Support\Facades\Event;
7-
use Watson\Validating\ValidationException;
87

98
class ValidatingObserver
109
{
1110
/**
1211
* Register the validation event for saving the model. Saving validation
1312
* should only occur if creating and updating validation does not.
1413
*
15-
* @param \Illuminate\Database\Eloquent\Model $model
16-
* @return boolean
14+
* @return bool
1715
*/
1816
public function saving(Model $model)
1917
{
@@ -23,8 +21,7 @@ public function saving(Model $model)
2321
/**
2422
* Register the validation event for restoring the model.
2523
*
26-
* @param \Illuminate\Database\Eloquent\Model $model
27-
* @return boolean
24+
* @return bool
2825
*/
2926
public function restoring(Model $model)
3027
{
@@ -34,9 +31,8 @@ public function restoring(Model $model)
3431
/**
3532
* Perform validation with the specified ruleset.
3633
*
37-
* @param \Illuminate\Database\Eloquent\Model $model
38-
* @param string $event
39-
* @return boolean
34+
* @param string $event
35+
* @return bool
4036
*/
4137
protected function performValidation(Model $model, $event)
4238
{
@@ -68,24 +64,22 @@ protected function performValidation(Model $model, $event)
6864
/**
6965
* Fire the namespaced validating event.
7066
*
71-
* @param \Illuminate\Database\Eloquent\Model $model
72-
* @param string $event
67+
* @param string $event
7368
* @return mixed
7469
*/
7570
protected function fireValidatingEvent(Model $model, $event)
7671
{
77-
return Event::until("eloquent.validating: ".get_class($model), [$model, $event]);
72+
return Event::until('eloquent.validating: '.get_class($model), [$model, $event]);
7873
}
7974

8075
/**
8176
* Fire the namespaced post-validation event.
8277
*
83-
* @param \Illuminate\Database\Eloquent\Model $model
84-
* @param string $status
78+
* @param string $status
8579
* @return void
8680
*/
8781
protected function fireValidatedEvent(Model $model, $status)
8882
{
89-
Event::dispatch("eloquent.validated: ".get_class($model), [$model, $status]);
83+
Event::dispatch('eloquent.validated: '.get_class($model), [$model, $status]);
9084
}
9185
}

0 commit comments

Comments
 (0)