Issues (22)

RoboFile.php (2 issues)

1
<?php
2
/**
3
 * PHP Version 5.6
4
 * @category Library
5
 * @package  ChangeLog
6
 * @author   Emlyn West <[email protected]>
7
 * @license  MIT http://opensource.org/licenses/MIT
8
 * @link     https://github.com/emlynwest/changelog
9
 */
10
11
use Robo\Tasks;
12
use Symfony\Component\Finder\Finder;
13
14
class RoboFile extends Tasks
15
{
16
	public function createPhar()
17
	{
18
		$collection = $this->collection();
0 ignored issues
show
The method collection() does not exist on RoboFile. Did you maybe mean collectionBuilder()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
		/** @scrutinizer ignore-call */ 
19
  $collection = $this->collection();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
20
		$this->taskComposerInstall()
21
			->noDev()
22
			->optimizeAutoloader()
23
			->printed(false)
24
			->addToCollection($collection);
25
26
		$packer = $this->taskPackPhar('package/changelog.phar')
27
			->compress(true)
28
			->stub('package/stub.php');
29
30
		$files = Finder::create()
31
			->ignoreVCS(true)
32
			->files()
33
			->name('*.php')
34
			->path('src')
35
			->path('vendor')
36
			->in(__DIR__);
37
38
		foreach ($files as $file) {
39
			$packer->addFile($file->getRelativePathname(), $file->getRealPath());
40
		}
41
42
		@unlink('package/bin');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for unlink(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

42
		/** @scrutinizer ignore-unhandled */ @unlink('package/bin');

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
43
		@unlink('package/changelog.phar');
44
		copy('changelog', 'package/bin');
45
46
		$packer->addFile('changelog', 'package/bin')
47
			->addToCollection($collection);
48
49
		$this->taskComposerInstall()
50
			 ->printed(false)
51
			 ->addToCollection($collection);
52
53
		$collection->run();
54
	}
55
}
56