Skip to content

Commit

Permalink
Require PHP 8.1
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
dave-redfern committed Mar 2, 2024
1 parent 6afdbcc commit 06af1b5
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ on:
jobs:
testsuite:
name: Unittests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.1', '8.2']
php-version: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json, pdo
extensions: json, mbstring
tools: pecl

- name: Validate composer.json
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ Network Trash Folder
Temporary Items
.apdisk
/.phpunit.result.cache
/.phpunit.cache
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log
==========

2024-03-02
----------

* required PHP 8.1+
* update dependencies
* fix missing return types

2023-10-05
----------

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.5",
"doctrine/dbal": "^3.1.0",
"ramsey/uuid": "^4.3",
"symfony/var-dumper": "^6.0"
Expand Down
20 changes: 10 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>tests</directory>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="256M"/>
Expand All @@ -19,4 +11,12 @@
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>tests</directory>
</exclude>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __invoke(string $rule, ...$args): Rule
return $this->rule($rule)->fillParameters($args);
}

protected function registerDefaultRules()
protected function registerDefaultRules(): void
{
$rules = [
'accepted' => new Rules\Accepted,
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Present.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function check(mixed $value): bool
return $this->validation->input()->has($this->attribute->key());
}

protected function setAttributeAsRequired()
protected function setAttributeAsRequired(): void
{
$this->attribute?->makeRequired();
}
Expand Down
9 changes: 6 additions & 3 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ public function testNonExistentValidationRule()
public function testNewValidationRuleCanBeAdded()
{
$this->validator->addRule('even', new Even());
$this->validator->messages()->add('en', [
'rule.even' => 'The :attribute must be even',
]);

$data = [4, 6, 8, 10 ];
$data = ['s' => 4];

$validation = $this->validator->make($data, ['s' => 'even'], []);
$validation = $this->validator->make($data, ['s' => 'even']);

$validation->validate();

Expand Down Expand Up @@ -312,7 +315,7 @@ public function testRootAsteriskValidation(array $data, array $rules, $errors =
}
}

public function rootAsteriskProvider(): array
public static function rootAsteriskProvider(): array
{
return [
'control sample success' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Even.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Even extends Rule
{
protected string $message = "The :attribute must be even";
protected string $message = 'rule.even';

public function check($value): bool
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Rules/AfterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AfterTest extends TestCase
{

/**
* @var \Somnambulist\Components\Validation\Rules\After
* @var After
*/
protected $validator;

Expand Down Expand Up @@ -48,7 +48,7 @@ public function testUserProvidedParamCannotBeValidatedBecauseItIsInvalid()
$this->validator->fillParameters(["to,morrow"])->check("now");
}

public function getInvalidDates()
public static function getInvalidDates(): array
{
$now = new DateTime();

Expand All @@ -62,7 +62,7 @@ public function getInvalidDates()
];
}

public function getValidDates()
public static function getValidDates(): array
{
$now = new DateTime();

Expand Down
4 changes: 2 additions & 2 deletions tests/Rules/BeforeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testOnlyAWellFormedDateCanBeValidated($date)
);
}

public function getValidDates()
public static function getValidDates(): array
{
$now = new DateTime();

Expand All @@ -54,7 +54,7 @@ public function testANonWellFormedDateCannotBeValidated($date)
$this->validator->fillParameters(["tomorrow"])->check($date);
}

public function getInvalidDates()
public static function getInvalidDates(): array
{
$now = new DateTime();

Expand Down
4 changes: 2 additions & 2 deletions tests/Rules/BooleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function setUp(): void

public function testValids()
{
$this->assertTrue($this->rule->check(\true));
$this->assertTrue($this->rule->check(\false));
$this->assertTrue($this->rule->check(true));
$this->assertTrue($this->rule->check(false));
$this->assertTrue($this->rule->check(1));
$this->assertTrue($this->rule->check(0));
$this->assertTrue($this->rule->check('1'));
Expand Down
2 changes: 1 addition & 1 deletion tests/UploadedFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testMissingKeyUploadedFile($uploadedFile)
$this->assertNotNull($errors->first('file:required'));
}

public function getSamplesMissingKeyFromUploadedFileValue()
public static function getSamplesMissingKeyFromUploadedFileValue(): array
{
$validUploadedFile = [
'name' => 'foo',
Expand Down
2 changes: 1 addition & 1 deletion tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testParseRule($rules, $expectedResult)
$this->assertSame($expectedResult, $result);
}

public function parseRuleProvider(): array
public static function parseRuleProvider(): array
{
return [
[
Expand Down

0 comments on commit 06af1b5

Please sign in to comment.