@@ -119,7 +119,6 @@ discard block |
||
119 | 119 | * Retrieve the value of a specific config setting |
120 | 120 | * |
121 | 121 | * @param string $setting Settings |
122 | - * @param string $setting,... Sub-settings |
|
123 | 122 | * @return mixed Value of setting, or null if not set |
124 | 123 | */ |
125 | 124 | public function getConfigSetting($setting) { |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | * Initialise the step unless it's already running (Started state). |
234 | 233 | * The step will be expected to transition from here to Finished, Failed or Aborted state. |
235 | 234 | * |
236 | - * @return boolean True if successfully started, false if error |
|
235 | + * @return boolean|null True if successfully started, false if error |
|
237 | 236 | */ |
238 | 237 | public function start() { |
239 | 238 | $this->Status = 'Started'; |
@@ -251,7 +251,7 @@ |
||
251 | 251 | */ |
252 | 252 | public function abort() { |
253 | 253 | |
254 | - if ($this->isQueued() || $this->isRunning()) { |
|
254 | + if($this->isQueued() || $this->isRunning()) { |
|
255 | 255 | $this->Status = 'Aborted'; |
256 | 256 | $this->log('Step aborted'); |
257 | 257 | $this->write(); |
@@ -89,7 +89,9 @@ discard block |
||
89 | 89 | * @return array |
90 | 90 | */ |
91 | 91 | public function getConfigData() { |
92 | - if(!$this->Config) return array(); |
|
92 | + if(!$this->Config) { |
|
93 | + return array(); |
|
94 | + } |
|
93 | 95 | |
94 | 96 | // Merge with defaults |
95 | 97 | if(!$this->mergedConfig) { |
@@ -125,7 +127,9 @@ discard block |
||
125 | 127 | public function getConfigSetting($setting) { |
126 | 128 | $source = $this->getConfigData(); |
127 | 129 | foreach(func_get_args() as $setting) { |
128 | - if(empty($source[$setting])) return null; |
|
130 | + if(empty($source[$setting])) { |
|
131 | + return null; |
|
132 | + } |
|
129 | 133 | $source = $source[$setting]; |
130 | 134 | } |
131 | 135 | return $source; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | "href" => "$href/deploy", |
39 | 39 | "type" => "application/json", |
40 | 40 | "fields" => array( |
41 | - array( "name" => "release", "type" => "text" ), |
|
41 | + array("name" => "release", "type" => "text"), |
|
42 | 42 | ), |
43 | 43 | ) |
44 | 44 | ) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $ping->write(); |
127 | 127 | $ping->start(); |
128 | 128 | |
129 | - $location = Director::absoluteBaseURL().$this->Link().'/ping/'.$ping->ID; |
|
129 | + $location = Director::absoluteBaseURL() . $this->Link() . '/ping/' . $ping->ID; |
|
130 | 130 | $output = array( |
131 | 131 | 'message' => 'Ping queued as job ' . $ping->ResqueToken, |
132 | 132 | 'href' => $location, |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $deploy->SHA = $reqBody['release']; |
181 | 181 | $deploy->write(); |
182 | 182 | $deploy->start(); |
183 | - $location = Director::absoluteBaseURL().$this->Link().'/deploy/'.$deploy->ID; |
|
183 | + $location = Director::absoluteBaseURL() . $this->Link() . '/deploy/' . $deploy->ID; |
|
184 | 184 | $output = array( |
185 | 185 | 'message' => 'Deploy queued as job ' . $deploy->ResqueToken, |
186 | 186 | 'href' => $location, |
@@ -97,7 +97,7 @@ |
||
97 | 97 | $fetch->write(); |
98 | 98 | $fetch->start(); |
99 | 99 | |
100 | - $location = Director::absoluteBaseURL().$this->Link().'/fetch/'.$fetch->ID; |
|
100 | + $location = Director::absoluteBaseURL() . $this->Link() . '/fetch/' . $fetch->ID; |
|
101 | 101 | $output = array( |
102 | 102 | 'message' => 'Ping queued as job ' . $fetch->ResqueToken, |
103 | 103 | 'href' => $location, |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function getIdentifier() { |
27 | 27 | // If the build script changes, don't re-use cached items |
28 | - return substr(sha1($this->buildScript),0,8); |
|
28 | + return substr(sha1($this->buildScript), 0, 8); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function executeProcesses($processes, DeploynautLogFile $log) { |
74 | 74 | foreach($processes as $process) { |
75 | - $process->mustRun(function ($type, $buffer) use($log) { |
|
75 | + $process->mustRun(function($type, $buffer) use($log) { |
|
76 | 76 | $log->write($buffer); |
77 | 77 | }); |
78 | 78 | } |
@@ -33,7 +33,9 @@ |
||
33 | 33 | */ |
34 | 34 | public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) { |
35 | 35 | $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); |
36 | - if(!file_exists($tempPath)) mkdir($tempPath); |
|
36 | + if(!file_exists($tempPath)) { |
|
37 | + mkdir($tempPath); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // Execute these in sequence until there's a failure |
39 | 41 | $processes = array( |
@@ -15,7 +15,7 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | public function write($message) { |
18 | - error_log('['.date('Y-m-d H:i:s').'] ' . $message .PHP_EOL, 3, $this->logFile); |
|
18 | + error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $this->logFile); |
|
19 | 19 | @chmod($this->logFile, 0666); |
20 | 20 | } |
21 | 21 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Overwrite field to save into a {@link DataArchive}, using generateFilepath(). |
|
4 | - * This mainly just works around the limitation |
|
5 | - * of FileField to set the folder path *before* uploading the file, |
|
6 | - * at which point we don't have a {@link DataTransfer} ID yet, so can't generate the path. |
|
7 | - */ |
|
3 | + * Overwrite field to save into a {@link DataArchive}, using generateFilepath(). |
|
4 | + * This mainly just works around the limitation |
|
5 | + * of FileField to set the folder path *before* uploading the file, |
|
6 | + * at which point we don't have a {@link DataTransfer} ID yet, so can't generate the path. |
|
7 | + */ |
|
8 | 8 | class DataArchiveFileField extends FileField { |
9 | 9 | |
10 | 10 | public function saveInto(DataObjectInterface $record) { |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | class DataArchiveFileField extends FileField { |
9 | 9 | |
10 | 10 | public function saveInto(DataObjectInterface $record) { |
11 | - if(!isset($_FILES[$this->name])) return false; |
|
11 | + if(!isset($_FILES[$this->name])) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | if(!($record instanceof DNDataArchive)) { |
14 | 16 | throw new LogicException('Saving into wrong type, expected DNDataArchive'); |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | $absolutePath = $dataArchive->generateFilepath($dataTransfer); |
28 | 30 | $relativePath = preg_replace('#^' . preg_quote(ASSETS_PATH) . '/#', '', $absolutePath); |
29 | 31 | $this->upload->loadIntoFile($_FILES[$this->name], $file, $relativePath); |
30 | - if($this->upload->isError()) return false; |
|
32 | + if($this->upload->isError()) { |
|
33 | + return false; |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $file = $this->upload->getFile(); |
33 | 37 | if($this->relationAutoSetting) { |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | if(file_exists($path)) { |
32 | 32 | $command = array(); |
33 | - if($user) $command[] = sprintf('sudo -u %s', $user); |
|
33 | + if($user) { |
|
34 | + $command[] = sprintf('sudo -u %s', $user); |
|
35 | + } |
|
34 | 36 | $command[] = sprintf('rm -rf %s', $path); |
35 | 37 | |
36 | 38 | fwrite($fh, sprintf('[%s] Cleaning up existing repository %s', date('Y-m-d H:i:s'), $path) . PHP_EOL); |
@@ -50,7 +52,9 @@ discard block |
||
50 | 52 | echo "[-] CloneGitRepo starting" . PHP_EOL; |
51 | 53 | |
52 | 54 | $command = array(); |
53 | - if($user) $command[] = sprintf('sudo -u %s', $user); |
|
55 | + if($user) { |
|
56 | + $command[] = sprintf('sudo -u %s', $user); |
|
57 | + } |
|
54 | 58 | $command[] = sprintf('git clone --bare -q %s %s', $repo, $path); |
55 | 59 | |
56 | 60 | fwrite($fh, sprintf('[%s] Running command: %s', date('Y-m-d H:i:s'), implode(' ', $command)) . PHP_EOL); |
@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | public function Link() { |
53 | 53 | // Use a get-var for branch so that it can handle unsafe chars better |
54 | - return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name())); |
|
54 | + return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name())); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -97,8 +97,11 @@ |
||
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 | } |
@@ -22,7 +22,6 @@ |
||
22 | 22 | ); |
23 | 23 | |
24 | 24 | /** |
25 | - * @param Gitonomy\Git\Commit $commit |
|
26 | 25 | * @param DNProject $project |
27 | 26 | * @param DNData $data |
28 | 27 | */ |
@@ -36,15 +36,22 @@ discard block |
||
36 | 36 | $firstBranch = null; |
37 | 37 | |
38 | 38 | // return an empty array if the version control isn't checked out yet |
39 | - if(!file_exists($this->project->LocalCVSPath)) return array(); |
|
39 | + if(!file_exists($this->project->LocalCVSPath)) { |
|
40 | + return array(); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | $repository = new Gitonomy\Git\Repository($this->project->LocalCVSPath); |
42 | 44 | foreach($repository->getReferences()->getBranches() as $branch) { |
43 | 45 | $obj = DNBranch::create($branch, $this->project, $this->data); |
44 | - if($branch->getName() == 'master') $firstBranch = array($branch->getName() => $obj); |
|
45 | - else $branches[$branch->getName()] = $obj; |
|
46 | + if($branch->getName() == 'master') { |
|
47 | + $firstBranch = array($branch->getName() => $obj); |
|
48 | + } else { |
|
49 | + $branches[$branch->getName()] = $obj; |
|
50 | + } |
|
51 | + } |
|
52 | + if($firstBranch) { |
|
53 | + $branches = $firstBranch + $branches; |
|
46 | 54 | } |
47 | - if($firstBranch) $branches = $firstBranch + $branches; |
|
48 | 55 | |
49 | 56 | return $branches; |
50 | 57 | } |
@@ -57,7 +64,9 @@ discard block |
||
57 | 64 | $this->getIterator(); |
58 | 65 | } |
59 | 66 | |
60 | - if(isset($this->items[$name])) return $this->items[$name]; |
|
67 | + if(isset($this->items[$name])) { |
|
68 | + return $this->items[$name]; |
|
69 | + } |
|
61 | 70 | } |
62 | 71 | |
63 | 72 | /** |
@@ -72,7 +81,9 @@ discard block |
||
72 | 81 | $this->loaded = true; |
73 | 82 | } |
74 | 83 | foreach($this->items as $i => $item) { |
75 | - if(is_array($item)) $this->items[$i] = new ArrayData($item); |
|
84 | + if(is_array($item)) { |
|
85 | + $this->items[$i] = new ArrayData($item); |
|
86 | + } |
|
76 | 87 | } |
77 | 88 | return new ArrayIterator($this->items); |
78 | 89 | } |