Completed
Push — master ( 90fc03...4b579b )
by Daniel
02:38
created

SSPak   C

Complexity

Total Complexity 55

Size/Duplication

Total Lines 402
Duplicated Lines 3.23 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 16
Bugs 6 Features 2
Metric Value
wmc 55
c 16
b 6
f 2
lcom 1
cbo 4
dl 13
loc 402
rs 6.8

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getActions() 0 49 1
B help() 0 16 8
B saveexisting() 0 27 3
A extract() 0 16 3
C save() 3 61 9
A getdb_MySQLPDODatabase() 0 3 1
B getdb_MySQLDatabase() 10 24 4
A getdb_PostgreSQLDatabase() 0 11 1
A getassets() 0 7 1
B getgitremote() 0 35 5
C load() 0 32 8
C install() 0 38 8
B bundle() 0 32 1
A transfer() 0 3 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like SSPak often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use SSPak, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * SSPak handler
5
 */
6
class SSPak {
7
	protected $executor;
8
9
	/**
10
	 * Create a new handler
11
	 * @param Executor $executor The Executor object to handle command execution
12
	 */
13
	function __construct($executor) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
		$this->executor = $executor;
15
	}
16
17
	function getActions() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
		return array(
19
			"help" => array(
20
				"description" => "Show this help message.",
21
				"method" => "help",
22
			),
23
			"save" => array(
24
				"description" => "Save an .sspak file from a SilverStripe site.",
25
				"unnamedArgs" => array("webroot", "sspak file"),
26
				"namedArgs" => array("identity"),
27
				"method" => "save",
28
			),
29
			"load" => array(
30
				"description" => "Load an .sspak file into a SilverStripe site. Does not backup - be careful!",
31
				"unnamedArgs" => array("sspak file", "[webroot]"),
32
				"namedArgs" => array("identity"),
33
				"namedFlags" => array("drop-db"),
34
				"method" => "load",
35
			),
36
			"saveexisting" => array(
37
				"description" => "Create an .sspak file from database SQL dump and/or assets. Does not require a SilverStripe site.",
38
				"unnamedArgs" => array("sspak file"),
39
				"namedArgs" => array("db", "assets"),
40
				"method" => "saveexisting"
41
			),
42
			"extract" => array(
43
				"description" => "Extract an .sspak file into the current working directory. Does not require a SilverStripe site.",
44
				"unnamedArgs" => array("sspak file", "destination path"),
45
				"method" => "extract"
46
			),
47
			/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
			"install" => array(
49
				"description" => "Install a .sspak file into a new environment.",
50
				"unnamedArgs" => array("sspak file", "new webroot"),
51
				"method" => "install",
52
			),
53
			"bundle" => array(
54
				"description" => "Bundle a .sspak file into a self-extracting executable .sspak.phar installer.",
55
				"unnamedArgs" => array("sspak file", "executable"),
56
				"method" => "bundle",
57
			),
58
			"transfer" => array(
59
				"description" => "Transfer db & assets from one site to another (not implemented yet).",
60
				"unnamedArgs" => array("src webroot", "dest webroot"),
61
				"method" => "transfer",
62
			),
63
			*/
64
		);
65
	}
66
67
	function help($args) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
68
		echo "SSPak: manage SilverStripe .sspak archives.\n\nUsage:\n";
69
		foreach($this->getActions() as $action => $info) {
70
			echo "sspak $action";
71
			if(!empty($info['unnamedArgs'])) {
72
				foreach($info['unnamedArgs'] as $arg) echo " ($arg)";
73
			}
74
			if(!empty($info['namedFlags'])) {
75
				foreach($info['namedFlags'] as $arg) echo " (--$arg)";
76
			}
77
			if(!empty($info['namedArgs'])) {
78
				foreach($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\"";
79
			}
80
			echo "\n  {$info['description']}\n\n";
81
		}
82
	}
83
84
	/**
85
	 * Save an existing database and/or assets into an .sspak.phar file.
86
	 * Does the same as {@link save()} but doesn't require an existing site.
87
	 */
88
	function saveexisting($args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
89
		$executor = $this->executor;
90
91
		$args->requireUnnamed(array('sspak file'));
92
		$unnamedArgs = $args->getUnnamedArgs();
93
		$namedArgs = $args->getNamedArgs();
94
95
		$sspak = new SSPakFile($unnamedArgs[0], $executor);
96
97
		// Look up which parts of the sspak are going to be saved
98
		$pakParts = $args->pakParts();
99
100
		$filesystem = new FilesystemEntity(null, $executor);
101
102
		if($pakParts['db']) {
103
			$dbPath = escapeshellarg($namedArgs['db']);
104
			$process = $filesystem->createProcess("cat $dbPath | gzip -c");
105
			$sspak->writeFileFromProcess('database.sql.gz', $process);
106
		}
107
108
		if($pakParts['assets']) {
109
			$assetsParentArg = escapeshellarg(dirname($namedArgs['assets']));
110
			$assetsBaseArg = escapeshellarg(basename($namedArgs['assets']));
111
			$process = $filesystem->createProcess("cd $assetsParentArg && tar cfh - $assetsBaseArg | gzip -c");
112
			$sspak->writeFileFromProcess('assets.tar.gz', $process);
113
		}
114
	}
115
116
	/**
117
	 * Extracts an existing database and/or assets from a sspak into the given directory,
118
	 * defaulting the current working directory if the destination is not given.
119
	 */
120
	function extract($args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
121
		$executor = $this->executor;
122
123
		$args->requireUnnamed(array('source sspak file'));
124
		$unnamedArgs = $args->getUnnamedArgs();
125
		$file = $unnamedArgs[0];
126
		$dest = !empty($unnamedArgs[1]) ? $unnamedArgs[1] : getcwd();
127
128
		$sspak = new SSPakFile($file, $executor);
129
130
		// Validation
131
		if(!$sspak->exists()) throw new Exception("File '$file' doesn't exist.");
132
133
		$phar = $sspak->getPhar();
134
		$phar->extractTo($dest);
135
	}
136
137
	/**
138
	 * Save a .sspak.phar file
139
	 */
140
	function save($args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
141
		$executor = $this->executor;
142
143
		$args->requireUnnamed(array('source webroot', 'dest sspak file'));
144
145
		$unnamedArgs = $args->getUnnamedArgs();
146
		$namedArgs = $args->getNamedArgs();
147
148
		$webroot = new Webroot($unnamedArgs[0], $executor);
149
		$file = $unnamedArgs[1];
150
		if(file_exists($file)) throw new Exception( "File '$file' already exists.");
151
152
		$sspak = new SSPakFile($file, $executor);
153
154
		if(!empty($namedArgs['identity'])) {
155
			// SSH private key
156
			$webroot->setSSHItentityFile($namedArgs['identity']);
157
		}
158
		if(!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']);
159
		else if(!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']);
160
161
		// Look up which parts of the sspak are going to be saved
162
		$pakParts = $args->pakParts();
163
164
		// Get the environment details
165
		$details = $webroot->sniff();
166
167
		// Create a build folder for the sspak file
168
		$buildFolder = "/tmp/sspak-" . rand(100000,999999);
169
		$webroot->exec(array('mkdir', $buildFolder));
0 ignored issues
show
Documentation introduced by
array('mkdir', $buildFolder) is of type array<integer,string,{"0":"string","1":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
170
171
		$dbFile = "$buildFolder/database.sql.gz";
172
		$assetsFile = "$buildFolder/assets.tar.gz";
173
		$gitRemoteFile = "$buildFolder/git-remote";
174
175
		// Files to include in the .sspak.phar file
176
		$fileList = array();
0 ignored issues
show
Unused Code introduced by
$fileList is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
177
178
		// Save DB
179
		if($pakParts['db']) {
180
			// Check the database type
181
			$dbFunction = 'getdb_'.$details['db_type'];
182 View Code Duplication
			if(!method_exists($this,$dbFunction)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
183
				throw new Exception("Can't process database type '" . $details['db_type'] . "'");
184
			}
185
			$this->$dbFunction($webroot, $details, $sspak, basename($dbFile));
186
		}
187
188
		// Save Assets
189
		if($pakParts['assets']) {
190
			$this->getassets($webroot, $details['assets_path'], $sspak, basename($assetsFile));
191
		}
192
193
		// Save git-remote
194
		if($pakParts['git-remote']) {
195
			$this->getgitremote($webroot, $sspak, basename($gitRemoteFile));
196
		}
197
198
		// Remove the build folder
199
		$webroot->unlink($buildFolder);
200
	}
201
202
	function getdb_MySQLPDODatabase($webroot, $conf, $sspak, $filename) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
203
		return $this->getdb_MySQLDatabase($webroot, $conf, $sspak, $filename);
204
	}
205
206
	function getdb_MySQLDatabase($webroot, $conf, $sspak, $filename) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
207
		$usernameArg = escapeshellarg("--user=".$conf['db_username']);
208
		$passwordArg = escapeshellarg("--password=".$conf['db_password']);
209
		$databaseArg = escapeshellarg($conf['db_database']);
210
211
		$hostArg = '';
212
		$portArg = '';
213 View Code Duplication
		if (!empty($conf['db_server']) && $conf['db_server'] != 'localhost') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
214
			if (strpos($conf['db_server'], ':')!==false) {
215
				// Handle "server:port" format.
216
				$server = explode(':', $conf['db_server'], 2);
217
				$hostArg = escapeshellarg("--host=".$server[0]);
218
				$portArg = escapeshellarg("--port=".$server[1]);
219
			} else {
220
				$hostArg = escapeshellarg("--host=".$conf['db_server']);
221
			}
222
		}
223
224
		$filenameArg = escapeshellarg($filename);
0 ignored issues
show
Unused Code introduced by
$filenameArg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
225
226
		$process = $webroot->createProcess("mysqldump --skip-opt --add-drop-table --extended-insert --create-options --quick  --set-charset --default-character-set=utf8 $usernameArg $passwordArg $hostArg $portArg $databaseArg | gzip -c");
227
		$sspak->writeFileFromProcess($filename, $process);
228
		return true;
229
	}
230
231
	function getdb_PostgreSQLDatabase($webroot, $conf, $sspak, $filename) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
232
		$usernameArg = escapeshellarg("--username=".$conf['db_username']);
233
		$passwordArg = "PGPASSWORD=".escapeshellarg($conf['db_password']);
234
		$databaseArg = escapeshellarg($conf['db_database']);
235
		$hostArg = escapeshellarg("--host=".$conf['db_server']);
236
		$filenameArg = escapeshellarg($filename);
0 ignored issues
show
Unused Code introduced by
$filenameArg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
237
238
		$process = $webroot->createProcess("$passwordArg pg_dump --clean --no-owner --no-tablespaces $usernameArg $hostArg $databaseArg | gzip -c");
239
		$sspak->writeFileFromProcess($filename, $process);
240
		return true;
241
	}
242
243
	function getassets($webroot, $assetsPath, $sspak, $filename) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
244
		$assetsParentArg = escapeshellarg(dirname($assetsPath));
245
		$assetsBaseArg = escapeshellarg(basename($assetsPath));
246
247
		$process = $webroot->createProcess("cd $assetsParentArg && tar cfh - $assetsBaseArg | gzip -c");
248
		$sspak->writeFileFromProcess($filename, $process);
249
	}
250
251
	function getgitremote($webroot, $sspak, $gitRemoteFile) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
252
		// Only do anything if we're copying from a git checkout
253
		$gitRepo = $webroot->getPath() .'/.git';
254
		if($webroot->exists($gitRepo)) {
255
			// Identify current branch
256
			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'branch'));
257
			if(preg_match("/\* ([^ \n]*)/", $output['output'], $matches) && strpos("(no branch)", $matches[1])===false) {
258
				// If there is a current branch, use that branch's remove
259
				$currentBranch = trim($matches[1]);
260
				$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"branch.$currentBranch.remote"));
261
				$remoteName = trim($output['output']);
262
				if(!$remoteName) $remoteName = 'origin';
263
264
			// Default to origin
265
			} else {
266
				$currentBranch = null;
267
				$remoteName = 'origin';
268
			}
269
270
			// Determine the URL of that remote
271
			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"remote.$remoteName.url"));
272
			$remoteURL = trim($output['output']);
273
274
			// Determine the current SHA
275
			$output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'log','-1','--format=%H'));
276
			$sha = trim($output['output']);
277
278
			$content = "remote = $remoteURL\nbranch = $currentBranch\nsha = $sha\n";
279
280
			$sspak->writeFile($gitRemoteFile, $content);
281
282
			return true;
283
		}
284
		return false;
285
	}
286
287
	/**
288
	 * Load an .sspak into an environment.
289
	 * Does not backup - be careful! */
290
	function load($args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
291
		$executor = $this->executor;
292
293
		$args->requireUnnamed(array('source sspak file'));
294
295
		// Set-up
296
		$file = $args->unnamed(0);
297
		$sspak = new SSPakFile($file, $executor);
298
		$webroot = new Webroot(($args->unnamed(1) ?: '.'), $executor);
299
		$webroot->setSudo($args->sudo('to'));
300
		$pakParts = $args->pakParts();
301
302
		$namedArgs = $args->getNamedArgs();
303
		if(!empty($namedArgs['identity'])) {
304
			// SSH private key
305
			$webroot->setSSHItentityFile($namedArgs['identity']);
306
		}
307
308
		// Validation
309
		if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist.");
310
311
		// Push database, if necessary
312
		$namedArgs = $args->getNamedArgs();
313
		if($pakParts['db'] && $sspak->contains('database.sql.gz')) {
314
			$webroot->putdb($sspak, isset($namedArgs['drop-db']));
315
		}
316
317
		// Push assets, if neccessary
318
		if($pakParts['assets'] && $sspak->contains('assets.tar.gz')) {
319
			$webroot->putassets($sspak);
320
		}
321
	}
322
323
	/**
324
	 * Install an .sspak into a new environment.
325
	 */
326
	function install($args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
327
		$executor = $this->executor;
328
329
		$args->requireUnnamed(array('source sspak file', 'dest new webroot'));
330
331
		// Set-up
332
		$file = $args->unnamed(0);
333
		$webrootDir = $args->unnamed(1);
334
		$sspak = new SSPakFile($file, $executor);
335
		$webroot = new Webroot($webrootDir, $executor);
336
		$webroot->setSudo($args->sudo('to'));
337
		$pakParts = $args->pakParts();
338
339
		// Validation
340
		if($webroot->exists($webroot->getPath())) throw new Exception( "Webroot '$webrootDir' already exists.");
341
		if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist.");
342
343
		// Create new dir
344
		$webroot->exec(array('mkdir', $webroot->getPath()));
0 ignored issues
show
Documentation introduced by
array('mkdir', $webroot->getPath()) is of type array<integer,?,{"0":"string","1":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
345
346
		if($sspak->contains('git-remote')) {
347
			$details = $sspak->gitRemoteDetails();
348
			$webroot->putgit($details);
349
		}
350
351
		// TODO: composer install needed.
352
353
		// Push database, if necessary
354
		$namedArgs = $args->getNamedArgs();
355
		if($pakParts['db'] && $sspak->contains('database.sql.gz')) {
356
			$webroot->putdb($sspak, isset($namedArgs['drop-db']));
357
		}
358
359
		// Push assets, if neccessary
360
		if($pakParts['assets'] && $sspak->contains('assets.tar.gz')) {
361
			$webroot->putassets($sspak);
362
		}
363
	}
364
365
	/**
366
	 * Bundle a .sspak into a self-extracting executable installer.
367
	 */
368
	function bundle($args) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
369
		// TODO: throws require_once errors, fix before re-enabling.
370
371
		$executor = $this->executor;
372
373
		$args->requireUnnamed(array('source sspak file', 'dest executable file'));
374
375
		// Set-up
376
		$sourceFile = $args->unnamed(0);
377
		$destFile = $args->unnamed(1);
378
379
		$sspakScript = file_get_contents($_SERVER['argv'][0]);
380
		// Broken up to not get detected by our sed command
381
		$sspakScript .= "\n__halt_compiler();\n"."//"." TAR START?>\n";
382
383
		// Mark as self-extracting
384
		$sspakScript = str_replace('$isSelfExtracting = false;', '$isSelfExtracting = true;', $sspakScript);
385
386
		// Load the sniffer file
387
		$snifferFile = dirname(__FILE__) . '/sspak-sniffer.php';
388
		$sspakScript = str_replace("\$snifferFileContent = '';\n",
389
			"\$snifferFileContent = '"
390
			. str_replace(array("\\","'"),array("\\\\", "\\'"), file_get_contents($snifferFile)) . "';\n", $sspakScript);
391
392
		file_put_contents($destFile, $sspakScript);
393
		chmod($destFile, 0775);
394
395
		$executor->execLocal(array('cat', $sourceFile), array(
0 ignored issues
show
Documentation introduced by
array('cat', $sourceFile) is of type array<integer,?,{"0":"string","1":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
396
			'outputFile' => $destFile,
397
			'outputFileAppend' => true
398
		));
399
	}
400
401
	/**
402
	 * Transfer between environments without creating an sspak file
403
	 */
404
	function transfer($args) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
405
		echo "Not implemented yet.\n";
406
	}
407
}
408