Completed
Pull Request — 1.1 (#490)
by Mateusz
23:25
created
code/api/DeploynautAPI.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	/**
42 42
 	 *
43 43
 	 * @param SS_HTTPRequest $request
44
-	 * @return string
44
+	 * @return SS_HTTPResponse
45 45
 	 */
46 46
 	public function listProjects(SS_HTTPRequest $request) {
47 47
 		$response = array(
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@
 block discarded – undo
49 49
 			'projects' => array(),
50 50
 		);
51 51
 
52
-		if($request->httpMethod() != 'GET') return $this->message('API not found', 404);;
52
+		if($request->httpMethod() != 'GET') {
53
+			return $this->message('API not found', 404);
54
+		}
55
+		;
53 56
 
54 57
 		foreach(DNProject::get() as $item) {
55 58
 			if($item->canView($this->getMember())) {
Please login to merge, or discard this patch.
code/backends/CapistranoDeploymentBackend.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -300,6 +300,7 @@
 block discarded – undo
300 300
 	/**
301 301
 	 * Utility function for triggering the db rebuild and flush.
302 302
 	 * Also cleans up and generates new error pages.
303
+	 * @param DeploynautLogFile $log
303 304
 	 */
304 305
 	public function rebuild(DNEnvironment $environment, $log) {
305 306
 		$name = $environment->getFullName();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,9 @@
 block discarded – undo
176 176
 		$name = $environment->getFullName();
177 177
 		$env = $environment->Project()->getProcessEnv();
178 178
 
179
-		if(!$args) $args = array();
179
+		if(!$args) {
180
+			$args = array();
181
+		}
180 182
 		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/');
181 183
 
182 184
 		// Inject env string directly into the command.
Please login to merge, or discard this patch.
code/backends/DeploymentBackend.php 1 patch
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -10,6 +10,7 @@  discard block
 block discarded – undo
10 10
 	 * @param DeploynautLogFile $log
11 11
 	 * @param DNProject $project
12 12
 	 * @param type $leaveMaintenancePage
13
+	 * @return void
13 14
 	 */
14 15
 	public function deploy(DNEnvironment $environment, $sha, DeploynautLogFile $log, DNProject $project, $leaveMaintenancePage = false);
15 16
 
@@ -19,6 +20,7 @@  discard block
 block discarded – undo
19 20
 	 *
20 21
 	 * @param DNDataTransfer $dataTransfer
21 22
 	 * @param DeploynautLogFile $log
23
+	 * @return void
22 24
 	 */
23 25
 	public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log);
24 26
 
@@ -28,6 +30,7 @@  discard block
 block discarded – undo
28 30
 	 * @param DNEnvironment $environment
29 31
 	 * @param DeploynautLogFile $log
30 32
 	 * @param DNProject $project
33
+	 * @return void
31 34
 	 */
32 35
 	public function enableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project);
33 36
 
@@ -37,6 +40,7 @@  discard block
 block discarded – undo
37 40
 	 * @param DNEnvironment $environment
38 41
 	 * @param DeploynautLogFile $log
39 42
 	 * @param DNProject $project
43
+	 * @return void
40 44
 	 */
41 45
 	public function disableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project);
42 46
 
@@ -46,6 +50,7 @@  discard block
 block discarded – undo
46 50
 	 * @param DNEnvironment $environment
47 51
 	 * @param DeploynautLogFile $log
48 52
 	 * @param DNProject $project
53
+	 * @return void
49 54
 	 */
50 55
 	public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project);
51 56
 
Please login to merge, or discard this patch.
code/backends/PackageGenerator.php 1 patch
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@
 block discarded – undo
13 13
 	/**
14 14
 	 * Generate the package file, saving to the given location
15 15
 	 *
16
-	 * @param $baseDir string The base directory of the project, checked out from git.
16
+	 * @param string $baseDir string The base directory of the project, checked out from git.
17 17
 	 * @param $outputFilename string The filename to write to.
18
+	 * @param string $sha
18 19
 	 *
19 20
 	 * @return boolean True on success
20 21
 	 */
Please login to merge, or discard this patch.
code/backends/SizeRestrictedPackageCache.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
 	/**
73 73
 	 * Take the identifier an make it safe to use as a directory name.
74 74
 	 *
75
-	 * @param string $identfiier The unsanitised directory name.
75
+	 * @param string $identifier The unsanitised directory name.
76 76
 	 */
77 77
 	protected function sanitiseDirName($identifier) {
78 78
 		$safe = preg_replace('/[^A-Za-z0-9_-]/', '', $identifier);
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,16 +41,22 @@  discard block
 block discarded – undo
41 41
 	 * @param DeploynautLogFile $log The log to write status output to, including package-generation commands
42 42
 	 */
43 43
 	public function getPackageFilename(PackageGenerator $generator, $identifier, $sha, $repositoryDir, DeploynautLogFile $log) {
44
-		if(!$this->baseDir) throw new \LogicException("Can't use PackageCache without setting BaseDir");
44
+		if(!$this->baseDir) {
45
+			throw new \LogicException("Can't use PackageCache without setting BaseDir");
46
+		}
45 47
 
46 48
 		$buildPath = $this->baseDir . '/' . $this->sanitiseDirName($identifier);
47 49
 		$filename = "$buildPath/$sha.tar.gz";
48 50
 
49 51
 		if(!file_exists($this->baseDir)) {
50
-			if(!mkdir($this->baseDir)) throw new \LogicException("Can't create base dir {$this->baseDir}");
52
+			if(!mkdir($this->baseDir)) {
53
+				throw new \LogicException("Can't create base dir {$this->baseDir}");
54
+			}
51 55
 		}
52 56
 		if(!file_exists($buildPath)) {
53
-			if(!mkdir($buildPath)) throw new \LogicException("Can't create build path $buildPath");
57
+			if(!mkdir($buildPath)) {
58
+				throw new \LogicException("Can't create build path $buildPath");
59
+			}
54 60
 		}
55 61
 
56 62
 		if(file_exists($filename)) {
@@ -61,7 +67,9 @@  discard block
 block discarded – undo
61 67
 			return $filename;
62 68
 
63 69
 		} else {
64
-			if($this->cacheSize) $this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log);
70
+			if($this->cacheSize) {
71
+				$this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log);
72
+			}
65 73
 
66 74
 			if($generator->generatePackage($sha, $repositoryDir, $filename, $log)) {
67 75
 				return $filename;
Please login to merge, or discard this patch.
code/control/DeployForm.php 1 patch
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,6 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * Validate a commit sha
19 19
 	 *
20 20
 	 * @param string $sha
21
+	 * @param string $field
21 22
 	 * @return boolean
22 23
 	 */
23 24
 	protected function validateCommit($sha, $field) {
@@ -100,6 +101,10 @@  discard block
 block discarded – undo
100 101
  */
101 102
 class DeployForm extends Form {
102 103
 
104
+	/**
105
+	 * @param DNRoot $controller
106
+	 * @param string $name
107
+	 */
103 108
 	public function __construct($controller, $name, DNEnvironment $environment, DNProject $project) {
104 109
 		if($environment->HasPipelineSupport()) {
105 110
 			// Determine if commits are filtered
@@ -261,7 +266,6 @@  discard block
 block discarded – undo
261 266
 	/**
262 267
 	 * Generate fields necessary to select from a filtered commit list
263 268
 	 *
264
-	 * @param DNEnvironment $environment
265 269
 	 * @param DataList $commits List of commits
266 270
 	 * @return FormField
267 271
 	 */
Please login to merge, or discard this patch.
code/control/DNRoot.php 2 patches
Doc Comments   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	/**
162 162
 	 * Action
163 163
 	 *
164
-	 * @return string - HTML
164
+	 * @return HTMLText - HTML
165 165
 	 */
166 166
 	public function projects(SS_HTTPRequest $request) {
167 167
 		// Performs canView permission check by limiting visible projects in DNProjectsList() call.
@@ -854,6 +854,7 @@  discard block
 block discarded – undo
854 854
 	}
855 855
 
856 856
 	/**
857
+	 * @param SS_HTTPRequest $request
857 858
 	 * @return Form
858 859
 	 */
859 860
 	public function getDataTransferForm($request) {
@@ -1189,6 +1190,8 @@  discard block
 block discarded – undo
1189 1190
 
1190 1191
 	/**
1191 1192
 	 * Build snapshot move form.
1193
+	 * @param SS_HTTPRequest $request
1194
+	 * @param DataObject $dataArchive
1192 1195
 	 */
1193 1196
 	public function getMoveForm($request, $dataArchive = null) {
1194 1197
 		$dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID'));
@@ -1330,7 +1333,7 @@  discard block
 block discarded – undo
1330 1333
 	 * TODO To be replaced with a method that just returns the list of archives this {@link Member} has access to.
1331 1334
 	 *
1332 1335
 	 * @param Member $member The {@link Member} to check (or null to check the currently logged in Member)
1333
-	 * @return boolean true if $member has access to upload or download to at least one {@link DNEnvironment}.
1336
+	 * @return boolean|null true if $member has access to upload or download to at least one {@link DNEnvironment}.
1334 1337
 	 */
1335 1338
 	public function CanViewArchives(Member $member = null) {
1336 1339
 		if(!$member) $member = Member::currentUser();
@@ -1357,7 +1360,7 @@  discard block
 block discarded – undo
1357 1360
 	}
1358 1361
 
1359 1362
 	/**
1360
-	 * @return ArrayList The list of all archive files that can be accessed by the currently logged-in {@link Member}
1363
+	 * @return PaginatedList The list of all archive files that can be accessed by the currently logged-in {@link Member}
1361 1364
 	 */
1362 1365
 	public function CompleteDataArchives() {
1363 1366
 		$project = $this->getCurrentProject();
@@ -1375,7 +1378,7 @@  discard block
 block discarded – undo
1375 1378
 	}
1376 1379
 
1377 1380
 	/**
1378
-	 * @return ArrayList The list of "pending" data archives which are waiting for a file
1381
+	 * @return PaginatedList The list of "pending" data archives which are waiting for a file
1379 1382
 	 * to be delivered offline by post, and manually uploaded into the system.
1380 1383
 	 */
1381 1384
 	public function PendingDataArchives() {
Please login to merge, or discard this patch.
Braces   +75 added lines, -25 removed lines patch added patch discarded remove patch
@@ -107,11 +107,15 @@  discard block
 block discarded – undo
107 107
 	 * @return boolean
108 108
 	 */
109 109
 	public static function FlagSnapshotsEnabled() {
110
-		if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) return true;
110
+		if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) {
111
+			return true;
112
+		}
111 113
 		if (defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) {
112 114
 			$allowedMembers = explode(';', FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS);
113 115
 			$member = Member::currentUser();
114
-			if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) return true;
116
+			if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) {
117
+				return true;
118
+			}
115 119
 		}
116 120
 		return false;
117 121
 	}
@@ -655,14 +659,22 @@  discard block
 block discarded – undo
655 659
 		$params = $request->params();
656 660
 		$pipeline = Pipeline::get()->byID($params['Identifier']);
657 661
 
658
-		if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) throw new SS_HTTPResponse_Exception('Pipeline not found', 404);
659
-		if(!$pipeline->Environment()->canView()) return Security::permissionFailure();
662
+		if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) {
663
+			throw new SS_HTTPResponse_Exception('Pipeline not found', 404);
664
+		}
665
+		if(!$pipeline->Environment()->canView()) {
666
+			return Security::permissionFailure();
667
+		}
660 668
 
661 669
 		$environment = $pipeline->Environment();
662 670
 		$project = $pipeline->Environment()->Project();
663 671
 
664
-		if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this pipeline");
665
-		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this pipeline");
672
+		if($environment->Name != $params['Environment']) {
673
+			throw new LogicException("Environment in URL doesn't match this pipeline");
674
+		}
675
+		if($project->Name != $params['Project']) {
676
+			throw new LogicException("Project in URL doesn't match this pipeline");
677
+		}
666 678
 
667 679
 		// Delegate to sub-requesthandler
668 680
 		return PipelineController::create($this, $pipeline);
@@ -795,14 +807,22 @@  discard block
 block discarded – undo
795 807
 		$params = $request->params();
796 808
 		$deployment = DNDeployment::get()->byId($params['Identifier']);
797 809
 
798
-		if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404);
799
-		if(!$deployment->canView()) return Security::permissionFailure();
810
+		if(!$deployment || !$deployment->ID) {
811
+			throw new SS_HTTPResponse_Exception('Deployment not found', 404);
812
+		}
813
+		if(!$deployment->canView()) {
814
+			return Security::permissionFailure();
815
+		}
800 816
 
801 817
 		$environment = $deployment->Environment();
802 818
 		$project = $environment->Project();
803 819
 
804
-		if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy");
805
-		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy");
820
+		if($environment->Name != $params['Environment']) {
821
+			throw new LogicException("Environment in URL doesn't match this deploy");
822
+		}
823
+		if($project->Name != $params['Project']) {
824
+			throw new LogicException("Project in URL doesn't match this deploy");
825
+		}
806 826
 
807 827
 		return $this->customise(new ArrayData(array(
808 828
 			'Deployment' => $deployment,
@@ -818,14 +838,22 @@  discard block
 block discarded – undo
818 838
 		$params = $request->params();
819 839
 		$deployment = DNDeployment::get()->byId($params['Identifier']);
820 840
 
821
-		if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404);
822
-		if(!$deployment->canView()) return Security::permissionFailure();
841
+		if(!$deployment || !$deployment->ID) {
842
+			throw new SS_HTTPResponse_Exception('Deployment not found', 404);
843
+		}
844
+		if(!$deployment->canView()) {
845
+			return Security::permissionFailure();
846
+		}
823 847
 
824 848
 		$environment = $deployment->Environment();
825 849
 		$project = $environment->Project();
826 850
 
827
-		if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy");
828
-		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy");
851
+		if($environment->Name != $params['Environment']) {
852
+			throw new LogicException("Environment in URL doesn't match this deploy");
853
+		}
854
+		if($project->Name != $params['Project']) {
855
+			throw new LogicException("Project in URL doesn't match this deploy");
856
+		}
829 857
 
830 858
 		$log = $deployment->log();
831 859
 		if($log->exists()) {
@@ -950,13 +978,19 @@  discard block
 block discarded – undo
950 978
 		$params = $request->params();
951 979
 		$transfer = DNDataTransfer::get()->byId($params['Identifier']);
952 980
 
953
-		if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404);
954
-		if(!$transfer->canView()) return Security::permissionFailure();
981
+		if(!$transfer || !$transfer->ID) {
982
+			throw new SS_HTTPResponse_Exception('Transfer not found', 404);
983
+		}
984
+		if(!$transfer->canView()) {
985
+			return Security::permissionFailure();
986
+		}
955 987
 
956 988
 		$environment = $transfer->Environment();
957 989
 		$project = $environment->Project();
958 990
 
959
-		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy");
991
+		if($project->Name != $params['Project']) {
992
+			throw new LogicException("Project in URL doesn't match this deploy");
993
+		}
960 994
 
961 995
 		return $this->customise(new ArrayData(array(
962 996
 			'Transfer' => $transfer,
@@ -973,13 +1007,19 @@  discard block
 block discarded – undo
973 1007
 		$params = $request->params();
974 1008
 		$transfer = DNDataTransfer::get()->byId($params['Identifier']);
975 1009
 
976
-		if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404);
977
-		if(!$transfer->canView()) return Security::permissionFailure();
1010
+		if(!$transfer || !$transfer->ID) {
1011
+			throw new SS_HTTPResponse_Exception('Transfer not found', 404);
1012
+		}
1013
+		if(!$transfer->canView()) {
1014
+			return Security::permissionFailure();
1015
+		}
978 1016
 
979 1017
 		$environment = $transfer->Environment();
980 1018
 		$project = $environment->Project();
981 1019
 
982
-		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy");
1020
+		if($project->Name != $params['Project']) {
1021
+			throw new LogicException("Project in URL doesn't match this deploy");
1022
+		}
983 1023
 
984 1024
 		$log = $transfer->log();
985 1025
 		if($log->exists()) {
@@ -1318,7 +1358,9 @@  discard block
 block discarded – undo
1318 1358
 	 * @return DNEnvironment
1319 1359
 	 */
1320 1360
 	protected function getCurrentEnvironment($project = null) {
1321
-		if(!$project) $project = $this->getCurrentProject();
1361
+		if(!$project) {
1362
+			$project = $this->getCurrentProject();
1363
+		}
1322 1364
 		return $project->DNEnvironmentList()->filter('Name', $this->getRequest()->latestParam('Environment'))->First();
1323 1365
 	}
1324 1366
 
@@ -1333,12 +1375,18 @@  discard block
 block discarded – undo
1333 1375
 	 * @return boolean true if $member has access to upload or download to at least one {@link DNEnvironment}.
1334 1376
 	 */
1335 1377
 	public function CanViewArchives(Member $member = null) {
1336
-		if(!$member) $member = Member::currentUser();
1378
+		if(!$member) {
1379
+			$member = Member::currentUser();
1380
+		}
1337 1381
 
1338
-		if(Permission::checkMember($member, 'ADMIN')) return true;
1382
+		if(Permission::checkMember($member, 'ADMIN')) {
1383
+			return true;
1384
+		}
1339 1385
 
1340 1386
 		$allProjects = $this->DNProjectList();
1341
-		if(!$allProjects) return false;
1387
+		if(!$allProjects) {
1388
+			return false;
1389
+		}
1342 1390
 
1343 1391
 		foreach($allProjects as $project) {
1344 1392
 			if($project->Environments()) {
@@ -1383,7 +1431,9 @@  discard block
 block discarded – undo
1383 1431
 		$archives = new ArrayList();
1384 1432
 		foreach($project->DNEnvironmentList() as $env) {
1385 1433
 			foreach($env->DataArchives() as $archive) {
1386
-				if($archive->canView() && $archive->isPending()) $archives->push($archive);
1434
+				if($archive->canView() && $archive->isPending()) {
1435
+					$archives->push($archive);
1436
+				}
1387 1437
 			}
1388 1438
 		}
1389 1439
 		return new PaginatedList($archives->sort("Created", "DESC"), $this->request);
Please login to merge, or discard this patch.
code/control/EmailMessagingService.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 *
85 85
 	 * @param PipelineStep $source Client step
86 86
 	 * @param string $from
87
-	 * @param string|Member $to
87
+	 * @param string $to
88 88
 	 * @param string $subject
89 89
 	 * @param string $body
90 90
 	 */
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@
 block discarded – undo
75 75
 	 * @param string $body
76 76
 	 */
77 77
 	protected function sendMessageTo($source, $from, $to, $subject, $body) {
78
-		if($to instanceof Member) $to = $to->Email;
78
+		if($to instanceof Member) {
79
+			$to = $to->Email;
80
+		}
79 81
 		$this->sendViaEmail($source, $from, $to, $subject, $body);
80 82
 	}
81 83
 
Please login to merge, or discard this patch.
code/model/DNBranch.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,6 @@
 block discarded – undo
27 27
 
28 28
 	/**
29 29
 	 *
30
-	 * @param Gitonomy\Git\Commit $commit
31 30
 	 * @param DNProject $project
32 31
 	 * @param DNData $data
33 32
 	 */
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,8 +97,11 @@
 block discarded – undo
97 97
 	 * @return string
98 98
 	 */
99 99
 	public function IsOpenByDefault() {
100
-		if($this->Name() == 'master') return " open";
101
-		else return "";
100
+		if($this->Name() == 'master') {
101
+			return " open";
102
+		} else {
103
+			return "";
104
+		}
102 105
 	}
103 106
 
104 107
 }
Please login to merge, or discard this patch.