Skip to content

Commit f5b9ecb

Browse files
committed
2 parents a070409 + 7d00f39 commit f5b9ecb

File tree

5 files changed

+37
-40
lines changed

5 files changed

+37
-40
lines changed

.travis.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ php:
66
- 7.2
77
- 7.3
88

9-
env:
10-
matrix:
11-
- EXECUTOR= DEPENDENCIES=--prefer-lowest
12-
- EXECUTOR=coroutine DEPENDENCIES=--prefer-lowest
13-
- EXECUTOR=
14-
- EXECUTOR=coroutine
15-
169
cache:
1710
directories:
1811
- $HOME/.composer/cache
@@ -21,7 +14,7 @@ before_install:
2114
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
2215
- travis_retry composer self-update
2316

24-
install: travis_retry composer update --prefer-dist
17+
install: composer update
2518

2619
script: ./vendor/bin/phpunit --group default
2720

@@ -32,7 +25,7 @@ jobs:
3225
include:
3326
- stage: Test
3427
install:
35-
- travis_retry composer update --prefer-dist {$DEPENDENCIES}
28+
- composer update
3629

3730
- stage: Test
3831
env: COVERAGE
@@ -41,7 +34,6 @@ jobs:
4134
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
4235
script:
4336
- ./vendor/bin/phpunit --coverage-php /tmp/coverage/clover_executor.cov
44-
- EXECUTOR=coroutine ./vendor/bin/phpunit --coverage-php /tmp/coverage/clover_executor-coroutine.cov
4537
after_script:
4638
- ./vendor/bin/phpcov merge /tmp/coverage --clover /tmp/clover.xml
4739
- wget https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar
@@ -50,12 +42,12 @@ jobs:
5042
- stage: Code Quality
5143
php: 7.1
5244
env: CODING_STANDARD
53-
install: travis_retry composer install --prefer-dist
45+
install: composer install
5446
script:
5547
- ./vendor/bin/phpcs
5648

5749
- stage: Code Quality
5850
php: 7.1
5951
env: STATIC_ANALYSIS
60-
install: travis_retry composer install --prefer-dist
52+
install: composer install
6153
script: composer stan

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ext-mbstring": "*"
1717
},
1818
"require-dev": {
19-
"doctrine/coding-standard": "^5.0",
19+
"doctrine/coding-standard": "^6.0",
2020
"phpbench/phpbench": "^0.14.0",
2121
"phpstan/phpstan": "0.11.16",
2222
"phpstan/phpstan-phpunit": "0.11.2",

src/Type/Definition/ValidatedFieldDefinition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ protected function _validateItems($config, array $value, array $path, callable $
146146
protected function _validate(array $arg, $value, bool $isParentList = false) : array
147147
{
148148
$res = [];
149+
150+
if (is_callable($arg['type'])) {
151+
$arg['type'] = $arg['type']();
152+
}
149153

150154
$type = $arg['type'];
151155
switch ($type) {

tests/Type/ValidatedFieldDefinition/InputObjectValidationTest.php

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,33 @@ public function testInputObjectValidationOnFieldFail(): void
3535
'type' => Type::boolean(),
3636
'args' => [
3737
'bookAttributes' => [
38-
'type' => new InputObjectType([
39-
'name' => 'BookAttributes',
40-
'fields' => [
41-
'title' => [
42-
'type' => Type::string(),
43-
'description' => 'Enter a book title, no more than 10 characters in length',
44-
'validate' => static function (string $title) {
45-
if (strlen($title) > 10) {
46-
return [1, 'book title must be less than 10 chaacters'];
47-
}
48-
return 0;
49-
},
50-
],
51-
'author' => [
52-
'type' => Type::id(),
53-
'description' => 'Provide a valid author id',
54-
'validate' => function (string $authorId) {
55-
if (!isset($this->data['people'][$authorId])) {
56-
return [1, 'We have no record of that author'];
57-
}
58-
return 0;
59-
},
60-
],
61-
],
62-
]),
38+
'type' => function() { // lazy load
39+
return new InputObjectType([
40+
'name' => 'BookAttributes',
41+
'fields' => [
42+
'title' => [
43+
'type' => Type::string(),
44+
'description' => 'Enter a book title, no more than 10 characters in length',
45+
'validate' => static function (string $title) {
46+
if (strlen($title) > 10) {
47+
return [1, 'book title must be less than 10 chaacters'];
48+
}
49+
return 0;
50+
},
51+
],
52+
'author' => [
53+
'type' => Type::id(),
54+
'description' => 'Provide a valid author id',
55+
'validate' => function (string $authorId) {
56+
if (!isset($this->data['people'][$authorId])) {
57+
return [1, 'We have no record of that author'];
58+
}
59+
return 0;
60+
},
61+
],
62+
],
63+
]);
64+
},
6365
],
6466
],
6567
'resolve' => static function ($value): bool {

tests/Utils.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static function toNowDoc($str, $numSpaces=0) {
6464
}
6565
array_unshift($lines, "");
6666
$lines[] = " ";
67-
$res = implode($lines, "\n");
68-
return $res;
67+
return implode("\n", $lines);
6968
}
7069
}

0 commit comments

Comments
 (0)