Skip to content

Commit

Permalink
Merge pull request #11 from POPSuL/multiversion
Browse files Browse the repository at this point in the history
Implemented support for all of php versions between 7.4 and 8.3
  • Loading branch information
franzose authored Apr 23, 2024
2 parents 21a355f + 38513d5 commit 9a8dc57
Show file tree
Hide file tree
Showing 10 changed files with 829 additions and 554 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require-dev": {
"phpunit/phpunit": "~6.0"
"phpunit/phpunit": "^9.3.0"
},
"autoload": {
"psr-4": {
Expand Down
1,346 changes: 815 additions & 531 deletions composer.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Error/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function has($attribute)
return array_key_exists($attribute, $this->errors);
}

#[\ReturnTypeWillChange]
public function count()
{
return count($this->errors);
Expand Down
4 changes: 4 additions & 0 deletions src/Rules/Core/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function isValid($input = null)
PhpDateTime::createFromFormat(static::FORMAT, $input);
$errors = PhpDateTime::getLastErrors();

if ($errors === false) {
return true;
}

if ($errors['error_count'] > 0) {
$this->violations[] = 'format';

Expand Down
4 changes: 1 addition & 3 deletions tests/Rules/CallableRuleWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

class CallableRuleWrapperTest extends TestCase
{
/**
* @expectedException \UnexpectedValueException
*/
public function testConstructorThrowsOnValidationAbsence()
{
$this->expectException(\UnexpectedValueException::class);
new CallableRuleWrapper(['name' => 'foo']);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/Core/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public function testMxAndHostValidation()

static::assertFalse($valid);
static::assertCount(2, $violations);
static::assertArraySubset(['mx', 'host'], $violations);
static::assertEquals(['mx', 'host'], $violations);
}
}
8 changes: 2 additions & 6 deletions tests/Rules/Core/LengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@

class LengthTest extends TestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testThrowsWhenMinAndMaxAreNull()
{
$this->expectException(\InvalidArgumentException::class);
new Length;
}

/**
* @expectedException \LogicException
*/
public function testThrowsWhenMaxIsLessThanMin()
{
$this->expectException(\LogicException::class);
new Length(5, 0);
}

Expand Down
8 changes: 2 additions & 6 deletions tests/Rules/Core/RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@

class RangeTest extends TestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testThrowsWhenMinAndMaxAreNull()
{
$this->expectException(\InvalidArgumentException::class);
new Range;
}

/**
* @expectedException \LogicException
*/
public function testThrowsWhenMaxIsLessThanMin()
{
$this->expectException(\LogicException::class);
new Range(5, 0);
}

Expand Down
4 changes: 1 addition & 3 deletions tests/Rules/Core/RegexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

class RegexTest extends TestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testShouldOnlyAcceptPatternAsString()
{
$this->expectException(\InvalidArgumentException::class);
new Regex(234);
}

Expand Down
4 changes: 1 addition & 3 deletions tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ public function testConstructor()
static::assertEquals($messages, $validator->getMessages());
}

/**
* @expectedException \UnexpectedValueException
*/
public function testThrowsOnUnknownRule()
{
$this->expectException(\UnexpectedValueException::class);
$this->validate(['foo' => 'bar'], ['foo' => 'uknown_rule'], ['foo' => 'error!']);
}

Expand Down

0 comments on commit 9a8dc57

Please sign in to comment.