1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace TheCodingMachine\GraphQL\Controllers\Fixtures; |
5
|
|
|
|
6
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Logged; |
7
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Mutation; |
8
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Query; |
9
|
|
|
use TheCodingMachine\GraphQL\Controllers\Annotations\Right; |
10
|
|
|
|
11
|
|
|
class TestController |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @Query |
15
|
|
|
* @param int $int |
16
|
|
|
* @param TestObject[] $list |
17
|
|
|
* @param bool|null $boolean |
18
|
|
|
* @param float|null $float |
19
|
|
|
* @param \DateTimeImmutable|null $dateTimeImmutable |
20
|
|
|
* @param \DateTime|\DateTimeInterface|null $dateTime |
21
|
|
|
* @param string $withDefault |
22
|
|
|
* @param null|string $string |
23
|
|
|
* @return TestObject |
24
|
|
|
*/ |
25
|
|
|
public function test(int $int, array $list, ?bool $boolean, ?float $float, ?\DateTimeImmutable $dateTimeImmutable, ?\DateTimeInterface $dateTime, string $withDefault = 'default', ?string $string = null): TestObject |
26
|
|
|
{ |
27
|
|
|
$str = ''; |
28
|
|
|
foreach ($list as $test) { |
29
|
|
|
if (!$test instanceof TestObject) { |
30
|
|
|
throw new \RuntimeException('TestObject instance expected.'); |
31
|
|
|
} |
32
|
|
|
$str .= $test->getTest(); |
33
|
|
|
} |
34
|
|
|
return new TestObject($string.$int.$str.($boolean?'true':'false').$float.$dateTimeImmutable->format('YmdHis').$dateTime->format('YmdHis').$withDefault); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @Mutation |
39
|
|
|
* @param TestObject $testObject |
40
|
|
|
* @return TestObject |
41
|
|
|
*/ |
42
|
|
|
public function mutation(TestObject $testObject): TestObject |
43
|
|
|
{ |
44
|
|
|
return $testObject; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @Query |
49
|
|
|
* @Logged |
50
|
|
|
*/ |
51
|
|
|
public function testLogged(): TestObject |
52
|
|
|
{ |
53
|
|
|
return new TestObject('foo'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Query |
58
|
|
|
* @Right(name="CAN_FOO") |
59
|
|
|
*/ |
60
|
|
|
public function testRight(): TestObject |
61
|
|
|
{ |
62
|
|
|
return new TestObject('foo'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @Query(returnType=TestType::class) |
67
|
|
|
*/ |
68
|
|
|
public function testFixReturnType(): TestObject |
69
|
|
|
{ |
70
|
|
|
return new TestObject('foo'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @Query(name="nameFromAnnotation") |
75
|
|
|
*/ |
76
|
|
|
public function testNameFromAnnotation(): TestObject |
77
|
|
|
{ |
78
|
|
|
return new TestObject('foo'); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
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.