This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Robo; |
||
3 | |||
4 | use PHPUnit\Framework\TestCase; |
||
5 | use Robo\Traits\TestTasksTrait; |
||
6 | |||
7 | class CopyDirTest extends TestCase |
||
8 | { |
||
9 | use TestTasksTrait; |
||
10 | use Task\Filesystem\loadTasks; |
||
11 | |||
12 | protected $fixtures; |
||
13 | |||
14 | public function setUp() |
||
15 | { |
||
16 | $this->fixtures = new Fixtures(); |
||
17 | $this->initTestTasksTrait(); |
||
18 | } |
||
19 | |||
20 | public function tearDown() |
||
21 | { |
||
22 | $this->fixtures->cleanup(); |
||
23 | } |
||
24 | |||
25 | public function testCopyDir() |
||
26 | { |
||
27 | $this->fixtures->createAndCdToSandbox(); |
||
28 | |||
29 | $result = $this->taskCopyDir(['box' => 'bin']) |
||
30 | ->run(); |
||
31 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
32 | $this->assertFileExists('bin'); |
||
33 | $this->assertFileExists('bin/robo.txt'); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Data provider for overwrite test |
||
38 | */ |
||
39 | public function copyDirWithOverwriteData() |
||
40 | { |
||
41 | return [ |
||
42 | [ |
||
43 | true, |
||
44 | 'some existing file', |
||
45 | ], |
||
46 | [ |
||
47 | false, |
||
48 | 'newer data', |
||
49 | ], |
||
50 | ]; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @dataProvider copyDirWithOverwriteData |
||
55 | */ |
||
56 | public function testCopyDirWithOverwrite($overwriteValue, $expected) |
||
57 | { |
||
58 | $this->fixtures->createAndCdToSandbox(); |
||
59 | |||
60 | @mkdir('some_destination'); |
||
61 | @mkdir('some_destination/deeply'); |
||
62 | file_put_contents('some_destination/deeply/existing_file', 'newer data'); |
||
63 | |||
64 | $this->assertFileExists('some'); |
||
65 | $this->assertFileExists('some/deeply/existing_file'); |
||
66 | $result = $this->taskCopyDir(['some' => 'some_destination']) |
||
0 ignored issues
–
show
|
|||
67 | ->overwrite($overwriteValue) |
||
68 | ->run(); |
||
69 | $this->assertTrue($result->wasSuccessful()); |
||
70 | |||
71 | $this->assertFileExists('some_destination'); |
||
72 | $this->assertFileExists('some_destination/deeply/existing_file'); |
||
73 | |||
74 | $actual = trim(file_get_contents('some_destination/deeply/existing_file')); |
||
75 | $this->assertEquals($expected, $actual); |
||
76 | } |
||
77 | |||
78 | View Code Duplication | public function testCopyRecursive() |
|
0 ignored issues
–
show
This method seems to be duplicated in 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...
|
|||
79 | { |
||
80 | $this->fixtures->createAndCdToSandbox(); |
||
81 | |||
82 | $this->assertFileExists('some/deeply/nested'); |
||
83 | $this->assertFileExists('some/deeply/nested/structu.re'); |
||
84 | $result = $this->taskCopyDir(['some/deeply' => 'some_destination/deeply']) |
||
85 | ->run(); |
||
86 | $this->assertTrue($result->wasSuccessful()); |
||
87 | $this->assertFileExists('some_destination/deeply/nested'); |
||
88 | $this->assertFileExists('some_destination/deeply/nested/structu.re'); |
||
89 | |||
90 | } |
||
91 | |||
92 | public function testCopyRecursiveWithExcludedFile() |
||
93 | { |
||
94 | $this->fixtures->createAndCdToSandbox(); |
||
95 | |||
96 | $this->assertFileExists('some/deeply/nested'); |
||
97 | $this->assertFileExists('some/deeply/nested2'); |
||
98 | $this->assertFileExists('some/deeply/nested3'); |
||
99 | $this->assertFileExists('some/deeply/nested3/nested31'); |
||
100 | $this->assertFileExists('some/deeply/nested4'); |
||
101 | $this->assertFileExists('some/deeply/nested4/nested41'); |
||
102 | $this->assertFileExists('some/deeply/nested/structu.re'); |
||
103 | $this->assertFileExists('some/deeply/nested/structu1.re'); |
||
104 | $this->assertFileExists('some/deeply/nested/structu2.re'); |
||
105 | $this->assertFileExists('some/deeply/nested/structu3.re'); |
||
106 | $this->assertFileExists('some/deeply/nested2/structu21.re'); |
||
107 | $this->assertFileExists('some/deeply/nested3/structu31.re'); |
||
108 | $this->assertFileExists('some/deeply/nested3/structu32.re'); |
||
109 | $this->assertFileExists('some/deeply/nested3/nested31/structu311.re'); |
||
110 | $this->assertFileExists('some/deeply/nested4/nested41/structu411.re'); |
||
111 | $this->assertFileExists('some/deeply/nested4/nested41/structu412.re'); |
||
112 | |||
113 | $result = $this->taskCopyDir(['some/deeply' => 'some_destination/deeply']) |
||
0 ignored issues
–
show
The method
exclude does only exist in Robo\Task\Filesystem\CopyDir , but not in Robo\Collection\CollectionBuilder .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
114 | ->exclude([ |
||
115 | // Basename exclusion. |
||
116 | 'structu1.re', |
||
117 | // File in subdir exclusion. |
||
118 | 'some/deeply/nested/structu3.re', |
||
119 | // Dir exclusion. |
||
120 | 'nested2', |
||
121 | // Subdir exclusion. |
||
122 | 'some/deeply/nested3/nested31', |
||
123 | // Subpath within source exclusion. |
||
124 | 'nested3/structu31.re', |
||
125 | // File in deeper subpath within source exclusion. |
||
126 | 'nested4/nested41/structu411.re', |
||
127 | ]) |
||
128 | ->run(); |
||
129 | $this->assertTrue($result->wasSuccessful()); |
||
130 | |||
131 | $this->assertFileExists('some_destination/deeply/nested'); |
||
132 | $this->assertFileNotExists('some_destination/deeply/nested2'); |
||
133 | $this->assertFileExists('some_destination/deeply/nested3'); |
||
134 | $this->assertFileNotExists('some_destination/deeply/nested3/nested31'); |
||
135 | $this->assertFileExists('some_destination/deeply/nested4'); |
||
136 | $this->assertFileExists('some_destination/deeply/nested4/nested41'); |
||
137 | $this->assertFileExists('some_destination/deeply/nested/structu.re'); |
||
138 | $this->assertFileNotExists('some_destination/deeply/nested/structu1.re'); |
||
139 | $this->assertFileExists('some_destination/deeply/nested/structu2.re'); |
||
140 | $this->assertFileNotExists('some_destination/deeply/nested/structu3.re'); |
||
141 | $this->assertFileNotExists('some_destination/deeply/nested2/structu21.re'); |
||
142 | $this->assertFileNotExists('some_destination/deeply/nested3/structu31.re'); |
||
143 | $this->assertFileExists('some_destination/deeply/nested3/structu32.re'); |
||
144 | $this->assertFileNotExists('some_destination/deeply/nested3/nested31/structu311.re'); |
||
145 | $this->assertFileNotExists('some_destination/deeply/nested4/nested41/structu411.re'); |
||
146 | $this->assertFileExists('some_destination/deeply/nested4/nested41/structu412.re'); |
||
147 | } |
||
148 | } |
||
149 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: