@@ -84,6 +84,9 @@ discard block |
||
84 | 84 | /** @var Git_Driver_Gerrit_Template_TemplateFactory */ |
85 | 85 | private $template_factory; |
86 | 86 | |
87 | + /** |
|
88 | + * @param string $dir |
|
89 | + */ |
|
87 | 90 | public function __construct( |
88 | 91 | $dir, |
89 | 92 | Git_Driver_Gerrit_GerritDriverFactory $driver_factory, |
@@ -204,6 +207,9 @@ discard block |
||
204 | 207 | $executor->exportBranchesAndTags($gerrit_project_url); |
205 | 208 | } |
206 | 209 | |
210 | + /** |
|
211 | + * @param string $replication_group |
|
212 | + */ |
|
207 | 213 | private function pushFullTuleapAccessRightsToGerrit(GitRepository $repository, Git_RemoteServer_GerritServer $gerrit_server, array $ugroups, $replication_group, $template_id) { |
208 | 214 | foreach ($ugroups as $ugroup) { |
209 | 215 | $this->addGroupToGroupFile($gerrit_server, $repository->getProject()->getUnixName().'/'.$ugroup->getNormalizedName()); |
@@ -263,6 +269,9 @@ discard block |
||
263 | 269 | $this->addGroupDefinitionToGroupFile('global:Registered-Users', self::GROUP_REGISTERED_USERS); |
264 | 270 | } |
265 | 271 | |
272 | + /** |
|
273 | + * @param string $uuid |
|
274 | + */ |
|
266 | 275 | private function addGroupDefinitionToGroupFile($uuid, $group_name) { |
267 | 276 | file_put_contents("$this->dir/groups", "$uuid\t$group_name\n", FILE_APPEND); |
268 | 277 | } |
@@ -24,6 +24,10 @@ |
||
24 | 24 | private $std_out; |
25 | 25 | private $std_err; |
26 | 26 | |
27 | + /** |
|
28 | + * @param string $std_out |
|
29 | + * @param string $std_err |
|
30 | + */ |
|
27 | 31 | function __construct($exit_code, $std_out, $std_err) { |
28 | 32 | parent::__construct(implode(PHP_EOL, array("exit_code: $exit_code", "std_err: $std_err", "std_out: $std_out"))); |
29 | 33 | $this->exit_code = $exit_code; |
@@ -74,7 +74,7 @@ |
||
74 | 74 | /** |
75 | 75 | * @param int $group_id |
76 | 76 | * |
77 | - * @return True if this template belongs to the given project |
|
77 | + * @return boolean if this template belongs to the given project |
|
78 | 78 | */ |
79 | 79 | public function belongsToProject($group_id) { |
80 | 80 | return $this->group_id == $group_id; |
@@ -27,6 +27,9 @@ discard block |
||
27 | 27 | */ |
28 | 28 | class Git_Driver_Gerrit_Template_TemplateDao extends DataAccessObject { |
29 | 29 | |
30 | + /** |
|
31 | + * @param integer $project_id |
|
32 | + */ |
|
30 | 33 | public function getAllTemplatesOfProject($project_id) { |
31 | 34 | $project_id = $this->da->escapeInt($project_id); |
32 | 35 | |
@@ -37,6 +40,9 @@ discard block |
||
37 | 40 | return $this->retrieve($sql); |
38 | 41 | } |
39 | 42 | |
43 | + /** |
|
44 | + * @param integer $template_id |
|
45 | + */ |
|
40 | 46 | public function getTemplate($template_id) { |
41 | 47 | $template_id = $this->da->escapeInt($template_id); |
42 | 48 | |
@@ -47,6 +53,11 @@ discard block |
||
47 | 53 | return $this->retrieve($sql); |
48 | 54 | } |
49 | 55 | |
56 | + /** |
|
57 | + * @param integer $project_id |
|
58 | + * @param string $name |
|
59 | + * @param string $content |
|
60 | + */ |
|
50 | 61 | public function addTemplate($project_id, $name, $content) { |
51 | 62 | $project_id = $this->da->escapeInt($project_id); |
52 | 63 | $name = $this->da->quoteSmart($name); |
@@ -65,6 +76,11 @@ discard block |
||
65 | 76 | return $this->update($sql); |
66 | 77 | } |
67 | 78 | |
79 | + /** |
|
80 | + * @param integer $template_id |
|
81 | + * @param string $name |
|
82 | + * @param string $content |
|
83 | + */ |
|
68 | 84 | public function updateTemplate($template_id, $name, $content) { |
69 | 85 | $template_id = $this->da->escapeInt($template_id); |
70 | 86 | $name = $this->da->quoteSmart($name); |
@@ -77,6 +93,9 @@ discard block |
||
77 | 93 | return $this->update($sql); |
78 | 94 | } |
79 | 95 | |
96 | + /** |
|
97 | + * @param integer $template_id |
|
98 | + */ |
|
80 | 99 | public function deleteTemplate($template_id) { |
81 | 100 | $template_id = $this->da->escapeInt($template_id); |
82 | 101 |
@@ -128,7 +128,7 @@ |
||
128 | 128 | * Instatiate a Template from a SQL row |
129 | 129 | * |
130 | 130 | * @param array |
131 | - * @return Git_Driver_Gerrit_Template_Template[] | false -where the array is in DAR format |
|
131 | + * @return Git_Driver_Gerrit_Template_Template | false -where the array is in DAR format |
|
132 | 132 | */ |
133 | 133 | private function instantiateTemplateFromRow(array $row) { |
134 | 134 | return new Git_Driver_Gerrit_Template_Template( |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | |
74 | 74 | /** |
75 | 75 | * set the inheritance on all Project's servers |
76 | - * @param array $gerrit_servers |
|
77 | - * @param type $project_name |
|
78 | - * @param type $parent_project_name |
|
76 | + * @param Git_RemoteServer_GerritServer[] $gerrit_servers |
|
77 | + * @param type $project |
|
78 | + * @param type $parent_project |
|
79 | 79 | */ |
80 | 80 | private function setProjectInheritanceOnServers(array $gerrit_servers, Project $project, Project $parent_project) { |
81 | 81 | foreach ($gerrit_servers as $gerrit_server) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * @param array $gerrit_servers |
|
93 | + * @param Git_RemoteServer_GerritServer[] $gerrit_servers |
|
94 | 94 | * @param Project $project |
95 | 95 | */ |
96 | 96 | private function resetProjectInheritanceOnServers(array $gerrit_servers, Project $project) { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | - * @param array $gerrit_servers |
|
108 | + * @param Git_RemoteServer_GerritServer[] $gerrit_servers |
|
109 | 109 | * @param Project $project |
110 | 110 | */ |
111 | 111 | private function createProjectOnServers(array $gerrit_servers, Project $project) { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * |
129 | 129 | * @param ProjectUGroup[] $ugroups |
130 | - * @return null | ProjectUGroup |
|
130 | + * @return ProjectUGroup|null | ProjectUGroup |
|
131 | 131 | */ |
132 | 132 | private function getAdminUGroup(array $ugroups) { |
133 | 133 | foreach ($ugroups as $ugroup) { |
@@ -71,7 +71,6 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param array $original_keys |
73 | 73 | * @param array $new_keys |
74 | - * @param Git_RemoteServer_GerritServerFactory $remote_gerrit_factory |
|
75 | 74 | * @return void |
76 | 75 | * @throws Git_UserSynchronisationException |
77 | 76 | */ |
@@ -118,7 +117,6 @@ discard block |
||
118 | 117 | /** |
119 | 118 | * Makes sure there is one copy of each key on each remote server |
120 | 119 | * |
121 | - * @param Git_RemoteServer_GerritServerFactory $remote_gerrit_factory |
|
122 | 120 | * @return void |
123 | 121 | * @throws Git_UserSynchronisationException |
124 | 122 | */ |
@@ -202,7 +200,7 @@ discard block |
||
202 | 200 | * |
203 | 201 | * @param array $keys_to_add |
204 | 202 | * @param array $keys_to_remove |
205 | - * @return array |
|
203 | + * @return boolean |
|
206 | 204 | */ |
207 | 205 | private function areThereKeysToUpdate(Array $keys_to_add, Array $keys_to_remove) { |
208 | 206 | return $keys_to_add || $keys_to_remove; |
@@ -36,7 +36,7 @@ |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | - /** @return bool */ |
|
39 | + /** @return boolean|null */ |
|
40 | 40 | public function areRegisteredUsersAllowedTo($permission_type, GitRepository $repository) { |
41 | 41 | if ($permission_type == Git::SPECIAL_PERM_ADMIN) { |
42 | 42 | return false; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param Git_RemoteServer_GerritServer $server |
93 | 93 | * @param string $project_name |
94 | - * @return true if the gerrit project exists, else return false |
|
94 | + * @return boolean if the gerrit project exists, else return false |
|
95 | 95 | */ |
96 | 96 | public function doesTheParentProjectExist(Git_RemoteServer_GerritServer $server, $project_name) { |
97 | 97 | return in_array($project_name, $this->listParentProjects($server)); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * @param Git_RemoteServer_GerritServer $server |
102 | 102 | * @param string $project_name |
103 | - * @return true if the gerrit project exists, else return false |
|
103 | + * @return boolean if the gerrit project exists, else return false |
|
104 | 104 | * |
105 | 105 | * @throws Git_Driver_Gerrit_Exception |
106 | 106 | */ |
@@ -163,6 +163,9 @@ discard block |
||
163 | 163 | $this->logger->info("Gerrit: Group $group_name successfully created"); |
164 | 164 | } |
165 | 165 | |
166 | + /** |
|
167 | + * @param string $group_full_name |
|
168 | + */ |
|
166 | 169 | public function getGroupUUID(Git_RemoteServer_GerritServer $server, $group_full_name) { |
167 | 170 | $json_result = $this->getAccountGroupsInfo($server, $group_full_name); |
168 | 171 | if (isset($json_result->columns->group_uuid)) { |
@@ -176,7 +179,7 @@ discard block |
||
176 | 179 | * Can throw Git_Driver_Gerrit_RemoteSSHCommandFailure exception |
177 | 180 | * |
178 | 181 | * @param Git_RemoteServer_GerritServer $server |
179 | - * @param type $group_full_name |
|
182 | + * @param string $group_full_name |
|
180 | 183 | * |
181 | 184 | * @return type |
182 | 185 | */ |
@@ -193,6 +196,9 @@ discard block |
||
193 | 196 | return json_decode(array_shift(explode("\n", $command_result))); |
194 | 197 | } |
195 | 198 | |
199 | + /** |
|
200 | + * @param string $group_name |
|
201 | + */ |
|
196 | 202 | public function doesTheGroupExist(Git_RemoteServer_GerritServer $server, $group_name) { |
197 | 203 | return in_array($group_name, $this->listGroups($server)); |
198 | 204 | } |
@@ -223,15 +229,24 @@ discard block |
||
223 | 229 | return $group_info; |
224 | 230 | } |
225 | 231 | |
232 | + /** |
|
233 | + * @param string $command |
|
234 | + */ |
|
226 | 235 | private function computeException(Git_Driver_Gerrit_RemoteSSHCommandFailure $e, $command) { |
227 | 236 | return $this->isGerritFailure($e) ? $this->gerritDriverException($e, $command) : $e; |
228 | 237 | |
229 | 238 | } |
230 | 239 | |
240 | + /** |
|
241 | + * @param Git_Driver_Gerrit_RemoteSSHCommandFailure $e |
|
242 | + */ |
|
231 | 243 | private function isGerritFailure($e) { |
232 | 244 | return $e->getExitCode() === self::EXIT_CODE; |
233 | 245 | } |
234 | 246 | |
247 | + /** |
|
248 | + * @param Git_Driver_Gerrit_RemoteSSHCommandFailure $e |
|
249 | + */ |
|
235 | 250 | private function gerritDriverException($e, $command) { |
236 | 251 | return new Git_Driver_Gerrit_Exception("Command: $command".PHP_EOL."Error: ".$e->getStdErr()); |
237 | 252 | } |
@@ -254,7 +269,7 @@ discard block |
||
254 | 269 | * Can throw Git_Driver_Gerrit_RemoteSSHCommandFailure exception |
255 | 270 | * |
256 | 271 | * @param Git_RemoteServer_GerritServer $server |
257 | - * @param PFUser $user |
|
272 | + * @param Git_Driver_Gerrit_User $user |
|
258 | 273 | * @param String $group_name |
259 | 274 | */ |
260 | 275 | public function addUserToGroup(Git_RemoteServer_GerritServer $server, Git_Driver_Gerrit_User $user, $group_name) { |
@@ -272,7 +287,7 @@ discard block |
||
272 | 287 | * Can throw Git_Driver_Gerrit_RemoteSSHCommandFailure exception |
273 | 288 | * |
274 | 289 | * @param Git_RemoteServer_GerritServer $server |
275 | - * @param PFUser $user |
|
290 | + * @param Git_Driver_Gerrit_User $user |
|
276 | 291 | * @param String $group_name |
277 | 292 | */ |
278 | 293 | public function removeUserFromGroup(Git_RemoteServer_GerritServer $server, Git_Driver_Gerrit_User $user, $group_name) { |
@@ -310,6 +325,10 @@ discard block |
||
310 | 325 | $this->flushGerritCacheGroupsInclude($server); |
311 | 326 | } |
312 | 327 | |
328 | + /** |
|
329 | + * @param string $group_name |
|
330 | + * @param string $included_group_name |
|
331 | + */ |
|
313 | 332 | private function insertAccountGroupIncludes(Git_RemoteServer_GerritServer $server, $group_name, $included_group_name) { |
314 | 333 | $sql_query = "INSERT INTO account_group_includes (group_id, include_id) SELECT G.group_id, I.group_id FROM account_groups G, account_groups I WHERE G.name='".$group_name."' AND I.name='".$included_group_name."'"; |
315 | 334 | $this->executeQuery($server, $sql_query); |
@@ -333,14 +352,23 @@ discard block |
||
333 | 352 | $this->executeQuery($server, $sql_query); |
334 | 353 | } |
335 | 354 | |
355 | + /** |
|
356 | + * @param Git_RemoteServer_GerritServer $server |
|
357 | + */ |
|
336 | 358 | public function flushGerritCacheAccounts($server) { |
337 | 359 | $this->flushGerritCaches($server, self::CACHE_ACCOUNTS); |
338 | 360 | } |
339 | 361 | |
362 | + /** |
|
363 | + * @param Git_RemoteServer_GerritServer $server |
|
364 | + */ |
|
340 | 365 | private function flushGerritCacheGroupsInclude($server) { |
341 | 366 | $this->flushGerritCaches($server, self::CACHE_GROUPS_INCLUDES); |
342 | 367 | } |
343 | 368 | |
369 | + /** |
|
370 | + * @param string $cache |
|
371 | + */ |
|
344 | 372 | private function flushGerritCaches($server, $cache=null) { |
345 | 373 | $query = self::COMMAND .' flush-caches'; |
346 | 374 | if ($cache) { |
@@ -349,6 +377,9 @@ discard block |
||
349 | 377 | $this->ssh->execute($server, $query); |
350 | 378 | } |
351 | 379 | |
380 | + /** |
|
381 | + * @param string $string |
|
382 | + */ |
|
352 | 383 | private function escapeSQLQuery($string) { |
353 | 384 | $escaped_string = str_replace(' ', '\ ', $string); |
354 | 385 | $escaped_string = str_replace("'", "\\'", $escaped_string); |
@@ -434,6 +465,9 @@ discard block |
||
434 | 465 | return preg_match("/\s$plugin\s+[^\s]+\s+$is_enabled/", $plugins_list); |
435 | 466 | } |
436 | 467 | |
468 | + /** |
|
469 | + * @param string $plugins_list |
|
470 | + */ |
|
437 | 471 | private function isDeletePluginInstalled($plugins_list) { |
438 | 472 | return strstr($plugins_list, self::DELETEPROJECT_PLUGIN_NAME); |
439 | 473 | } |
@@ -476,7 +510,6 @@ discard block |
||
476 | 510 | |
477 | 511 | /** |
478 | 512 | * @param Git_RemoteServer_GerritServer $server |
479 | - * @param PFUser $gerrit_users_to_suspend |
|
480 | 513 | * |
481 | 514 | * @throws Git_Driver_Gerrit_Exception |
482 | 515 | */ |