thecodingmachine /
graphql-controllers
| 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 | use TheCodingMachine\GraphQL\Controllers\Types\ID; |
||
| 12 | |||
| 13 | class TestController |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @Query |
||
| 17 | * @param int $int |
||
| 18 | * @param TestObject[] $list |
||
| 19 | * @param bool|null $boolean |
||
| 20 | * @param float|null $float |
||
| 21 | * @param \DateTimeImmutable|null $dateTimeImmutable |
||
| 22 | * @param \DateTime|\DateTimeInterface|null $dateTime |
||
| 23 | * @param string $withDefault |
||
| 24 | * @param null|string $string |
||
| 25 | * @param ID|null $id |
||
| 26 | * @return TestObject |
||
| 27 | */ |
||
| 28 | public function test(int $int, array $list, ?bool $boolean, ?float $float, ?\DateTimeImmutable $dateTimeImmutable, ?\DateTimeInterface $dateTime, string $withDefault = 'default', ?string $string = null, ID $id = null): TestObject |
||
| 29 | { |
||
| 30 | $str = ''; |
||
| 31 | foreach ($list as $test) { |
||
| 32 | if (!$test instanceof TestObject) { |
||
| 33 | throw new \RuntimeException('TestObject instance expected.'); |
||
| 34 | } |
||
| 35 | $str .= $test->getTest(); |
||
| 36 | } |
||
| 37 | return new TestObject($string.$int.$str.($boolean?'true':'false').$float.$dateTimeImmutable->format('YmdHis').$dateTime->format('YmdHis').$withDefault.($id !== null ? $id->val() : '')); |
||
|
0 ignored issues
–
show
|
|||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @Mutation |
||
| 42 | * @param TestObject $testObject |
||
| 43 | * @return TestObject |
||
| 44 | */ |
||
| 45 | public function mutation(TestObject $testObject): TestObject |
||
| 46 | { |
||
| 47 | return $testObject; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @Query |
||
| 52 | * @Logged |
||
| 53 | */ |
||
| 54 | public function testLogged(): TestObject |
||
| 55 | { |
||
| 56 | return new TestObject('foo'); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @Query |
||
| 61 | * @Right(name="CAN_FOO") |
||
| 62 | */ |
||
| 63 | public function testRight(): TestObject |
||
| 64 | { |
||
| 65 | return new TestObject('foo'); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @Query(outputType="ID") |
||
| 70 | */ |
||
| 71 | public function testFixReturnType(): TestObject |
||
| 72 | { |
||
| 73 | return new TestObject('foo'); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @Query(name="nameFromAnnotation") |
||
| 78 | */ |
||
| 79 | public function testNameFromAnnotation(): TestObject |
||
| 80 | { |
||
| 81 | return new TestObject('foo'); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @Query(name="arrayObject") |
||
| 86 | * @return ArrayObject|TestObject[] |
||
| 87 | */ |
||
| 88 | public function testArrayObject(): ArrayObject |
||
| 89 | { |
||
| 90 | return new ArrayObject([]); |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @Query(name="arrayObject") |
||
| 95 | * @return iterable|TestObject[] |
||
| 96 | */ |
||
| 97 | public function testIterable(): iterable |
||
| 98 | { |
||
| 99 | return array(); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @Query(name="union") |
||
| 104 | * @return TestObject|TestObject2 |
||
| 105 | */ |
||
| 106 | public function testUnion() |
||
| 107 | { |
||
| 108 | return new TestObject2('foo'); |
||
| 109 | } |
||
| 110 | } |
||
| 111 |
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.