1 | <?php |
||
34 | class ComposerJsonController extends AbstractController |
||
35 | { |
||
36 | /** |
||
37 | * Retrieve the composer.json. |
||
38 | * |
||
39 | * @return Response |
||
40 | * |
||
41 | * @ApiDoc( |
||
42 | * section="files", |
||
43 | * statusCodes = { |
||
44 | * 200 = "When everything worked out ok" |
||
45 | * }, |
||
46 | * authentication = true, |
||
47 | * authenticationRoles = { |
||
48 | * "ROLE_EDIT_COMPOSER_JSON" |
||
49 | * } |
||
50 | * ) |
||
51 | */ |
||
52 | public function getComposerJsonAction() |
||
56 | |||
57 | /** |
||
58 | * Update the composer.json with the given data if it is valid. |
||
59 | * |
||
60 | * The whole submitted data is used as file. |
||
61 | * |
||
62 | * @param Request $request The request to process. |
||
63 | * |
||
64 | * @return JsonResponse |
||
65 | * |
||
66 | * @ApiDoc( |
||
67 | * section="files", |
||
68 | * statusCodes = { |
||
69 | * 200 = "When everything worked out ok" |
||
70 | * }, |
||
71 | * authentication = true, |
||
72 | * authenticationRoles = { |
||
73 | * "ROLE_EDIT_COMPOSER_JSON" |
||
74 | * } |
||
75 | * ) |
||
76 | * @ApiDescription( |
||
77 | * response={ |
||
78 | * "status" = { |
||
79 | * "dataType" = "string", |
||
80 | * "description" = "Either OK or ERROR" |
||
81 | * }, |
||
82 | * "errors" = { |
||
83 | * "description" = "List of contained errors", |
||
84 | * "subType" = "object", |
||
85 | * "actualType" = "collection", |
||
86 | * "children" = { |
||
87 | * "line" = { |
||
88 | * "dataType" = "string", |
||
89 | * "description" = "The line number containing the error", |
||
90 | * "required" = true |
||
91 | * }, |
||
92 | * "msg" = { |
||
93 | * "dataType" = "string", |
||
94 | * "description" = "The error message", |
||
95 | * "required" = true |
||
96 | * } |
||
97 | * } |
||
98 | * }, |
||
99 | * "warnings" = { |
||
100 | * "description" = "List of contained warnings", |
||
101 | * "subType" = "object", |
||
102 | * "actualType" = "collection", |
||
103 | * "children" = { |
||
104 | * "line" = { |
||
105 | * "dataType" = "string", |
||
106 | * "description" = "The line number containing the warning", |
||
107 | * "required" = true |
||
108 | * }, |
||
109 | * "msg" = { |
||
110 | * "dataType" = "string", |
||
111 | * "description" = "The error message", |
||
112 | * "required" = true |
||
113 | * } |
||
114 | * } |
||
115 | * } |
||
116 | * } |
||
117 | * ) |
||
118 | */ |
||
119 | public function putComposerJsonAction(Request $request) |
||
143 | |||
144 | /** |
||
145 | * Check the json contents and return the error array. |
||
146 | * |
||
147 | * @param string $content The Json content. |
||
148 | * |
||
149 | * @return array<string,string[]> |
||
150 | */ |
||
151 | private function checkComposerJson($content) |
||
178 | } |
||
179 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.