1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace TheCodingMachine\GraphQL\Controllers\Fixtures; |
5
|
|
|
|
6
|
|
|
use ArrayObject; |
7
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Logged; |
8
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Mutation; |
9
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Query; |
10
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Right; |
11
|
|
|
|
12
|
|
|
class TestController |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @Query |
16
|
|
|
* @param int $int |
17
|
|
|
* @param TestObject[] $list |
18
|
|
|
* @param bool|null $boolean |
19
|
|
|
* @param float|null $float |
20
|
|
|
* @param \DateTimeImmutable|null $dateTimeImmutable |
21
|
|
|
* @param \DateTime|\DateTimeInterface|null $dateTime |
22
|
|
|
* @param string $withDefault |
23
|
|
|
* @param null|string $string |
24
|
|
|
* @return TestObject |
25
|
|
|
*/ |
26
|
|
|
public function test(int $int, array $list, ?bool $boolean, ?float $float, ?\DateTimeImmutable $dateTimeImmutable, ?\DateTimeInterface $dateTime, string $withDefault = 'default', ?string $string = null): TestObject |
27
|
|
|
{ |
28
|
|
|
$str = ''; |
29
|
|
|
foreach ($list as $test) { |
30
|
|
|
if (!$test instanceof TestObject) { |
31
|
|
|
throw new \RuntimeException('TestObject instance expected.'); |
32
|
|
|
} |
33
|
|
|
$str .= $test->getTest(); |
34
|
|
|
} |
35
|
|
|
return new TestObject($string.$int.$str.($boolean?'true':'false').$float.$dateTimeImmutable->format('YmdHis').$dateTime->format('YmdHis').$withDefault); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @Mutation |
40
|
|
|
* @param TestObject $testObject |
41
|
|
|
* @return TestObject |
42
|
|
|
*/ |
43
|
|
|
public function mutation(TestObject $testObject): TestObject |
44
|
|
|
{ |
45
|
|
|
return $testObject; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @Query |
50
|
|
|
* @Logged |
51
|
|
|
*/ |
52
|
|
|
public function testLogged(): TestObject |
53
|
|
|
{ |
54
|
|
|
return new TestObject('foo'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Query |
59
|
|
|
* @Right(name="CAN_FOO") |
60
|
|
|
*/ |
61
|
|
|
public function testRight(): TestObject |
62
|
|
|
{ |
63
|
|
|
return new TestObject('foo'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @Query(returnType=TestType::class) |
68
|
|
|
*/ |
69
|
|
|
public function testFixReturnType(): TestObject |
70
|
|
|
{ |
71
|
|
|
return new TestObject('foo'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @Query(name="nameFromAnnotation") |
76
|
|
|
*/ |
77
|
|
|
public function testNameFromAnnotation(): TestObject |
78
|
|
|
{ |
79
|
|
|
return new TestObject('foo'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @Query(name="arrayObject") |
84
|
|
|
* @return ArrayObject|TestObject[] |
85
|
|
|
*/ |
86
|
|
|
public function testArrayObject(): ArrayObject |
87
|
|
|
{ |
88
|
|
|
return new ArrayObject([]); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @Query(name="arrayObject") |
93
|
|
|
* @return iterable|TestObject[] |
94
|
|
|
*/ |
95
|
|
|
public function testIterable(): iterable |
96
|
|
|
{ |
97
|
|
|
return array(); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.