Skip to content

Commit 6d248da

Browse files
authored
22 datetime error (#24)
* [#22] Add PHP 7.4 for testing environment * [#22] Add better type hints
1 parent 528c054 commit 6d248da

25 files changed

+63
-112
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
vendor
33
composer.lock
4+
.phpunit.result.cache

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ language: php
33

44
matrix:
55
include:
6-
- php: 7.1
7-
- php: 7.2
8-
- php: 7.3
6+
- php: 7.4
97
allow_failures:
108
- php: nightly
119
fast_finish: true
1210

13-
before_install:
14-
1511
install:
1612
- composer install
1713

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cubicl/php-structure-check",
3-
"description": "Structural check of arrays for PHP 7.1+",
3+
"description": "Structural check of arrays for PHP 7.3+",
44
"keywords": ["array", "structure", "types"],
55
"homepage": "https://github.com/cubicldev/php-structure-check",
66
"type": "library",
@@ -19,9 +19,9 @@
1919
"tests-spec": "phpspec run --no-interaction"
2020
},
2121
"require-dev": {
22-
"phpspec/phpspec": "^5.1.0",
23-
"phpunit/phpunit": "^7",
24-
"phpstan/phpstan": "^0.11.4"
22+
"phpspec/phpspec": "^6.2",
23+
"phpunit/phpunit": "^9.3",
24+
"phpstan/phpstan": "^0.12"
2525
},
2626
"autoload": {
2727
"psr-4": {

spec/CheckerSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CheckerSpec extends ObjectBehavior
1111
{
12-
function it_is_initializable()
12+
function it_is_initializable(): void
1313
{
1414
$this->shouldHaveType(Checker::class);
1515
}

spec/Type/DatetimeTypeSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
class DatetimeTypeSpec extends ObjectBehavior
1010
{
11-
function it_is_initializable()
11+
public function it_is_initializable(): void
1212
{
1313
$this->beConstructedWith('d-m-Y h:m:s', 'UTC');
1414
$this->shouldHaveType(DatetimeType::class);
1515
}
1616

17-
function it_should_return_valid_for_correct_values()
17+
public function it_should_return_valid_for_correct_values(): void
1818
{
1919
$this->beConstructedWith('d-m-Y h:m:s', 'Europe/Berlin');
2020

2121
$this->check('', '12-12-2012 12:12:10')->isValid()->shouldBe(true);
2222
}
2323

24-
function it_should_return_invalid_for_others()
24+
public function it_should_return_invalid_for_others(): void
2525
{
2626
$this->beConstructedWith('d-m-Y h:m:s', 'Europe/Berlin');
2727

spec/Type/OptionalTypeSpec.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
class OptionalTypeSpec extends ObjectBehavior
1111
{
12-
function it_is_initializable(TypeInterface $childType)
12+
function it_is_initializable(TypeInterface $childType): void
1313
{
1414
$this->beConstructedWith($childType);
1515
$this->shouldHaveType(OptionalType::class);
1616
}
1717

18-
function it_should_return_the_value_from_the_child(TypeInterface $childType) {
18+
function it_should_return_the_value_from_the_child(TypeInterface $childType): void
19+
{
1920
$this->beConstructedWith($childType);
2021
$childType->check('', false)->willReturn(new Result(false, []));
2122
$this->check('', false)->isValid()->shouldBe(false);

spec/Type/RegexTypeSpec.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@
88
class RegexTypeSpec extends ObjectBehavior
99
{
1010

11-
function it_is_initializable()
11+
function it_is_initializable(): void
1212
{
1313
$this->beConstructedWith('/^def/');
1414

1515
$this->shouldHaveType(RegexType::class);
1616
}
1717

18-
function it_should_return_valid_for_matching_strings()
18+
function it_should_return_valid_for_matching_strings(): void
1919
{
2020
$this->beConstructedWith('/^def/');
2121

2222
$this->check('', 'definitive')->isValid()->shouldBe(true);
2323
}
2424

25-
function it_should_return_invalid_for_not_matching_strings()
25+
function it_should_return_invalid_for_not_matching_strings(): void
2626
{
2727
$this->beConstructedWith('/^def/');
2828

2929
$this->check('', 'developers')->isValid()->shouldBe(false);
3030
}
3131

32-
function it_should_return_invalid_for_others()
32+
function it_should_return_invalid_for_others(): void
3333
{
3434
$this->beConstructedWith('/^def/');
3535

spec/Type/StringTypeSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
class StringTypeSpec extends ObjectBehavior
1010
{
11-
function it_is_initializable()
11+
function it_is_initializable(): void
1212
{
1313
$this->shouldHaveType(StringType::class);
1414
}
1515

16-
function it_should_return_valid_for_strings()
16+
function it_should_return_valid_for_strings(): void
1717
{
1818
$this->check('', '')->isValid()->shouldBe(true);
1919
$this->check('', 'fooo')->isValid()->shouldBe(true);
2020
$this->check('', 'adadsad asd a')->isValid()->shouldBe(true);
2121
}
2222

23-
function it_should_return_invalid_for_others()
23+
function it_should_return_invalid_for_others(): void
2424
{
2525
$this->check('', null)->isValid()->shouldBe(false);
2626
$this->check('', 12.3)->isValid()->shouldBe(false);

src/Check/CountCheck.php

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,13 @@
1010

1111
class CountCheck implements TypeInterface
1212
{
13-
/**
14-
* @var string
15-
*/
16-
private static $countErrorMessage = 'The given countable %s has not the expected count %d.';
17-
18-
/**
19-
* @var string
20-
*/
21-
private static $countableErrorMessage = 'The given value %s is not a countable';
22-
23-
/**
24-
* @var TypeInterface
25-
*/
26-
private $child;
27-
28-
/**
29-
* @var int
30-
*/
31-
private $count;
13+
private static string $countErrorMessage = 'The given countable %s has not the expected count %d.';
14+
15+
private static string $countableErrorMessage = 'The given value %s is not a countable';
16+
17+
private TypeInterface $child;
18+
19+
private int $count;
3220

3321
public function __construct(TypeInterface $child, int $count)
3422
{

src/Error.php

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

55
class Error implements ErrorInterface
66
{
7-
private $key;
7+
private string $key;
88

9-
private $message;
9+
private string $message;
1010

1111
public function __construct(string $key, string $message)
1212
{

0 commit comments

Comments
 (0)