These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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(); |
||
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
|
|||
43 | @unlink('package/changelog.phar'); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
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.');
}
![]() |
|||
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 |
If you suppress an error, we recommend checking for the error condition explicitly: