Completed
Push — master ( a101ca...aeb0d9 )
by Daniel
10s
created
src/Executor.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	function createLocal($command, $options) {
37 37
 		$options = array_merge($this->defaultOptions, $options);
38
-		if(is_array($command)) $command = $this->commandArrayToString($command);
38
+		if (is_array($command)) $command = $this->commandArrayToString($command);
39 39
 
40 40
 		return new Process($command, $options);
41 41
 	}
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function commandArrayToString($command) {
55 55
 		$string = escapeshellcmd(array_shift($command));
56
-		foreach($command as $arg) {
57
-			$string .= ' ' . escapeshellarg($arg);
56
+		foreach ($command as $arg) {
57
+			$string .= ' '.escapeshellarg($arg);
58 58
 		}
59 59
 		return $string;
60 60
 	}
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 		$options = array_merge($this->options, $options);
81 81
 
82 82
 		// Modify command for remote execution, if necessary.
83
-		if($this->remoteServer) {
84
-			if(!empty($options['outputFile']) || !empty($options['outputStream'])) $ssh = "ssh -T ";
83
+		if ($this->remoteServer) {
84
+			if (!empty($options['outputFile']) || !empty($options['outputStream'])) $ssh = "ssh -T ";
85 85
 			else $ssh = "ssh -t ";
86 86
 			if (!empty($options['identity'])) {
87
-				$ssh .= '-i ' . escapeshellarg($options['identity']) . ' ';
87
+				$ssh .= '-i '.escapeshellarg($options['identity']).' ';
88 88
 			}
89
-			$command = $ssh . escapeshellarg($this->remoteServer) . ' ' . escapeshellarg($this->command);
89
+			$command = $ssh.escapeshellarg($this->remoteServer).' '.escapeshellarg($this->command);
90 90
 		} else {
91 91
 			$command = $this->command;
92 92
 		}
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 		);
100 100
 
101 101
 		// Alternatives
102
-		if($options['inputContent'] || $options['inputStream']) $pipeSpec[0] = array('pipe', 'r');
102
+		if ($options['inputContent'] || $options['inputStream']) $pipeSpec[0] = array('pipe', 'r');
103 103
 
104
-		if($options['outputFile']) {
104
+		if ($options['outputFile']) {
105 105
 			$pipeSpec[1] = array('file',
106 106
 				$options['outputFile'],
107 107
 				$options['outputFileAppend'] ? 'a' : 'w');
@@ -109,24 +109,24 @@  discard block
 block discarded – undo
109 109
 
110 110
 		$process = proc_open($command, $pipeSpec, $pipes);
111 111
 
112
-		if($options['inputContent']) {
112
+		if ($options['inputContent']) {
113 113
 			fwrite($pipes[0], $options['inputContent']);
114 114
 
115
-		} else if($options['inputStream']) {
116
-			while($content = fread($options['inputStream'], 8192)) {
115
+		} else if ($options['inputStream']) {
116
+			while ($content = fread($options['inputStream'], 8192)) {
117 117
 				fwrite($pipes[0], $content);
118 118
 			}
119 119
 		}
120
-		if(isset($pipes[0])) fclose($pipes[0]);
120
+		if (isset($pipes[0])) fclose($pipes[0]);
121 121
 
122 122
 		$result = array();
123 123
 
124
-		if(isset($pipes[1])) {
124
+		if (isset($pipes[1])) {
125 125
 			// If a stream was provided, then pipe all the content
126 126
 			// Doing it this way rather than passing outputStream to $pipeSpec
127 127
 			// Means that streams as well as simple FDs can be used
128
-			if($options['outputStream']) {
129
-				while($content = fread($pipes[1], 8192)) {
128
+			if ($options['outputStream']) {
129
+				while ($content = fread($pipes[1], 8192)) {
130 130
 					fwrite($options['outputStream'], $content);
131 131
 				}
132 132
 
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 			}
137 137
 			fclose($pipes[1]);
138 138
 		}
139
-		if(isset($pipes[2])) {
139
+		if (isset($pipes[2])) {
140 140
 			$result['error'] = stream_get_contents($pipes[2]);
141 141
 			fclose($pipes[2]);
142 142
 		}
143 143
 
144 144
 		$result['return'] = proc_close($process);
145 145
 
146
-		if($options['throwException'] && $result['return'] != 0)	{
146
+		if ($options['throwException'] && $result['return'] != 0) {
147 147
 			throw new Exception("Command: $command\nExecution failed: returned {$result['return']}.\n"
148 148
 				. (empty($result['output']) ? "" : "Output:\n{$result['output']}"));
149 149
 		}
Please login to merge, or discard this patch.
src/FilesystemEntity.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 	function __construct($path, $executor) {
13 13
 		$this->executor = $executor;
14 14
 
15
-		if(strpos($path,':') !== false) {
16
-			list($this->server,$this->path) = explode(':', $path, 2);
15
+		if (strpos($path, ':') !== false) {
16
+			list($this->server, $this->path) = explode(':', $path, 2);
17 17
 		} else {
18 18
 			$this->server = null;
19 19
 			$this->path = $path;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @return Process
48 48
 	 */
49 49
 	function createProcess($command, $options = array()) {
50
-		if($this->server) {
50
+		if ($this->server) {
51 51
 			if ($this->identity && !isset($options['identity'])) {
52 52
 				$options['identity'] = $this->identity;
53 53
 			}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param string $dest The remote filename/dir to upload to
64 64
 	 */
65 65
 	function upload($source, $dest) {
66
-		if($this->server) {
66
+		if ($this->server) {
67 67
 			$this->executor->execLocal(array("scp", $source, "$this->server:$dest"));
68 68
 		} else {
69 69
 			$this->executor->execLocal(array("cp", $source, $dest));
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $dest The remote filename/dir to upload to
77 77
 	 */
78 78
 	function uploadContent($content, $dest) {
79
-		$this->exec("echo " . escapeshellarg($content) . " > " . escapeshellarg($dest));
79
+		$this->exec("echo ".escapeshellarg($content)." > ".escapeshellarg($dest));
80 80
 	}
81 81
 
82 82
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @param string $dest The local filename/dir to download to
86 86
 	 */
87 87
 	function download($source, $dest) {
88
-		if($this->server) {
88
+		if ($this->server) {
89 89
 			$this->executor->execLocal(array("scp", "$this->server:$source", $dest));
90 90
 		} else {
91 91
 			$this->executor->execLocal(array("cp", $file, $dest));
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 * @return boolean
99 99
 	 */
100 100
 	function exists($file = null) {
101
-		if(!$file) $file = $this->path;
102
-		if($file == '@self') return true;
101
+		if (!$file) $file = $this->path;
102
+		if ($file == '@self') return true;
103 103
 
104
-		if($this->server) {
105
-			$result = $this->exec("if [ -e " . escapeshellarg($file) . " ]; then echo yes; fi");
104
+		if ($this->server) {
105
+			$result = $this->exec("if [ -e ".escapeshellarg($file)." ]; then echo yes; fi");
106 106
 			return (trim($result['output']) == 'yes');
107 107
 
108 108
 		} else {
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * Create the given file with the given content
115 115
 	 */
116 116
 	function writeFile($file, $content) {
117
-		if($this->server) {
118
-			$this->exec("echo " . escapeshellarg($content) . " > " . escapeshellarg($file));
117
+		if ($this->server) {
118
+			$this->exec("echo ".escapeshellarg($content)." > ".escapeshellarg($file));
119 119
 
120 120
 		} else {
121 121
 			file_put_contents($file, $content);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $file The file to remove
129 129
 	 */
130 130
 	function unlink($file) {
131
-		if(!$file || $file == '/' || $file == '.') throw new Exception("Can't unlink file '$file'");
131
+		if (!$file || $file == '/' || $file == '.') throw new Exception("Can't unlink file '$file'");
132 132
 		$this->exec(array('rm', '-rf', $file));
133 133
 		return true;
134 134
 	}
Please login to merge, or discard this patch.
src/Args.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	function __construct($args) {
12 12
 		array_shift($args);
13 13
 
14
-		foreach($args as $arg) {
15
-			if(preg_match('/^--([^=]+)=(.*)$/', $arg, $matches)) {
14
+		foreach ($args as $arg) {
15
+			if (preg_match('/^--([^=]+)=(.*)$/', $arg, $matches)) {
16 16
 				$this->namedArgs[$matches[1]] = $matches[2];
17
-			} else if(preg_match('/^--([^=]+)$/', $arg, $matches)) {
17
+			} else if (preg_match('/^--([^=]+)$/', $arg, $matches)) {
18 18
 				$this->namedArgs[$matches[1]] = true;
19 19
 			} else {
20 20
 				$this->unnamedArgs[] = $arg;
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * Return the sudo argument, preferring a more specific one with the given optional prefix
52 52
 	 */
53 53
 	function sudo($optionalPrefix) {
54
-		if(!empty($this->namedArgs[$optionalPrefix . '-sudo'])) return $this->namedArgs[$optionalPrefix . '-sudo'];
55
-		else if(!empty($this->namedArgs['sudo'])) return $this->namedArgs['sudo'];
54
+		if (!empty($this->namedArgs[$optionalPrefix.'-sudo'])) return $this->namedArgs[$optionalPrefix.'-sudo'];
55
+		else if (!empty($this->namedArgs['sudo'])) return $this->namedArgs['sudo'];
56 56
 		else return null;
57 57
 	}
58 58
 
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
 	function pakParts() {
63 63
 		// Look up which parts of the sspak are going to be saved
64 64
 		$pakParks = array();
65
-		foreach(array('assets','db','git-remote') as $part) {
65
+		foreach (array('assets', 'db', 'git-remote') as $part) {
66 66
 			$pakParts[$part] = !empty($this->namedArgs[$part]);
67 67
 		}
68 68
 
69 69
 		// Default to db and assets
70
-		if(!array_filter($pakParts)) $pakParts = array('db' => true, 'assets' => true, 'git-remote' => true);
70
+		if (!array_filter($pakParts)) $pakParts = array('db' => true, 'assets' => true, 'git-remote' => true);
71 71
 		return $pakParts;
72 72
 	}
73 73
 
74 74
 	function requireUnnamed($items) {
75
-		if(sizeof($this->unnamedArgs) < sizeof($items)) {
76
-			echo "Usage: {$_SERVER['argv'][0]} " . $this->action . " (";
75
+		if (sizeof($this->unnamedArgs) < sizeof($items)) {
76
+			echo "Usage: {$_SERVER['argv'][0]} ".$this->action." (";
77 77
 			echo implode(") (", $items);
78 78
 			echo ")\n";
79 79
 			throw new Exception('Arguments missing.');
Please login to merge, or discard this patch.
src/DataExtractor/CsvTableWriter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 
34 34
 	private function mapFromColumns($record) {
35 35
 		$row = [];
36
-		foreach($this->columns as $i => $column)
36
+		foreach ($this->columns as $i => $column)
37 37
 		{
38 38
 			$row[$i] = isset($record[$column]) ? $record[$column] : null;
39 39
 		}
Please login to merge, or discard this patch.
src/DataExtractor/DatabaseConnector.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
 		$this->isConnected = true;
27 27
 
28 28
 		// Necessary for SilverStripe's _ss_environment.php loader to work
29
-		$_SERVER['SCRIPT_FILENAME'] = $this->basePath . '/dummy.php';
29
+		$_SERVER['SCRIPT_FILENAME'] = $this->basePath.'/dummy.php';
30 30
 
31 31
 		global $databaseConfig;
32 32
 
33 33
 		// require composers autoloader
34
-		if (file_exists($this->basePath . '/vendor/autoload.php')) {
35
-			require_once $this->basePath . '/vendor/autoload.php';
34
+		if (file_exists($this->basePath.'/vendor/autoload.php')) {
35
+			require_once $this->basePath.'/vendor/autoload.php';
36 36
 		}
37 37
 
38
-		if (file_exists($this->basePath . '/framework/core/Core.php')) {
39
-			require_once($this->basePath . '/framework/core/Core.php');
40
-		} elseif (file_exists($this->basePath . '/sapphire/core/Core.php')) {
41
-			require_once($this->basePath . '/sapphire/core/Core.php');
38
+		if (file_exists($this->basePath.'/framework/core/Core.php')) {
39
+			require_once($this->basePath.'/framework/core/Core.php');
40
+		} elseif (file_exists($this->basePath.'/sapphire/core/Core.php')) {
41
+			require_once($this->basePath.'/sapphire/core/Core.php');
42 42
 		} else {
43 43
 			throw new \LogicException("No framework/core/Core.php or sapphire/core/Core.php included in project.  Perhaps $this->basePath is not a SilverStripe project?");
44 44
 		}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	function getDatabase() {
57 57
 		$this->connect();
58 58
 
59
-		if(method_exists('DB', 'get_conn')) {
59
+		if (method_exists('DB', 'get_conn')) {
60 60
 			return DB::get_conn();
61 61
 		} else {
62 62
 			return DB::getConn();
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	function getTables() {
70 70
 		$this->connect();
71 71
 
72
-		if(method_exists('DB', 'table_list')) {
72
+		if (method_exists('DB', 'table_list')) {
73 73
 			return DB::table_list();
74 74
 		} else {
75 75
 			return DB::tableList();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	function getFieldsForTable($tableName) {
83 83
 		$this->connect();
84 84
 
85
-		if(method_exists('DB', 'field_list')) {
85
+		if (method_exists('DB', 'field_list')) {
86 86
 			return DB::field_list($tableName);
87 87
 		} else {
88 88
 			return DB::fieldList($tableName);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$fields = $this->getFieldsForTable($tableName);
112 112
 
113
-		foreach($reader as $record) {
113
+		foreach ($reader as $record) {
114 114
 			foreach ($record as $k => $v) {
115 115
 				if (!isset($fields[$k])) {
116 116
 					unset($record[$k]);
Please login to merge, or discard this patch.
src/DataExtractor/CsvTableReader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		$this->columns = null;
25 25
 		$this->initColumns();
26 26
 
27
-		while(($row = $this->getRow()) !== false) {
27
+		while (($row = $this->getRow()) !== false) {
28 28
 			yield $this->mapToColumns($row);
29 29
 		}
30 30
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 
34 34
 	private function mapToColumns($row) {
35 35
 		$record = [];
36
-		foreach($row as $i => $value)
36
+		foreach ($row as $i => $value)
37 37
 		{
38
-			if(isset($this->columns[$i])) {
38
+			if (isset($this->columns[$i])) {
39 39
 				$record[$this->columns[$i]] = $value;
40 40
 			} else {
41
-				throw new \LogicException("Row contains invalid column #$i\n" . var_export($row, true));
41
+				throw new \LogicException("Row contains invalid column #$i\n".var_export($row, true));
42 42
 			}
43 43
 		}
44 44
 		return $record;
Please login to merge, or discard this patch.
tests/DataExtractor/CsvTableReaderTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
 {
7 7
 	function testCsvReading() {
8 8
 
9
-		$csv = new CsvTableReader(__DIR__ . '/fixture/input.csv');
9
+		$csv = new CsvTableReader(__DIR__.'/fixture/input.csv');
10 10
 		$this->assertEquals(['Col1', 'Col2', 'Col3'], $csv->getColumns());
11 11
 
12 12
 		$extractedData = [];
13
-		foreach($csv as $record) {
13
+		foreach ($csv as $record) {
14 14
 			$extractedData[] = $record;
15 15
 		}
16 16
 
17 17
 		$this->assertEquals(
18 18
 			[
19
-				[ 'Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three' ],
20
-				[ 'Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?" ]
19
+				['Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three'],
20
+				['Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?"]
21 21
 			],
22 22
 			$extractedData
23 23
 		);
Please login to merge, or discard this patch.
tests/DataExtractor/CsvTableWriterTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 		$csv = new CsvTableWriter('/tmp/output.csv');
14 14
 
15 15
 		$csv->start(['Col1', 'Col2', 'Col3']);
16
-		$csv->writeRecord([ 'Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three' ]);
17
-		$csv->writeRecord([ 'Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?" ]);
16
+		$csv->writeRecord(['Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three']);
17
+		$csv->writeRecord(['Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?"]);
18 18
 		$csv->finish();
19 19
 
20 20
 		$csvContent = file_get_contents('/tmp/output.csv');
21 21
 		unlink('/tmp/output.csv');
22 22
 
23
-		$fixture = file_get_contents(__DIR__ . '/fixture/input.csv');
23
+		$fixture = file_get_contents(__DIR__.'/fixture/input.csv');
24 24
 
25 25
 		$this->assertEquals($fixture, $csvContent);
26 26
 	}
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 
34 34
 		$csv = new CsvTableWriter('/tmp/output.csv');
35 35
 
36
-		$csv->writeRecord([ 'Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three' ]);
37
-		$csv->writeRecord([ 'Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?" ]);
36
+		$csv->writeRecord(['Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three']);
37
+		$csv->writeRecord(['Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?"]);
38 38
 		$csv->finish();
39 39
 
40 40
 		$csvContent = file_get_contents('/tmp/output.csv');
41 41
 		unlink('/tmp/output.csv');
42 42
 
43
-		$fixture = file_get_contents(__DIR__ . '/fixture/input.csv');
43
+		$fixture = file_get_contents(__DIR__.'/fixture/input.csv');
44 44
 
45 45
 		$this->assertEquals($fixture, $csvContent);
46 46
 	}
Please login to merge, or discard this patch.
tests/SmokeTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('PACKAGE_ROOT' , dirname(__DIR__).'/');
4
-require_once(PACKAGE_ROOT . 'src/SSPak.php');
3
+define('PACKAGE_ROOT', dirname(__DIR__).'/');
4
+require_once(PACKAGE_ROOT.'src/SSPak.php');
5 5
 
6 6
 /**
7 7
  * Confirm that the compile binary executes
Please login to merge, or discard this patch.