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 WriteFileTest extends TestCase |
||
8 | { |
||
9 | use TestTasksTrait; |
||
10 | use Task\File\loadTasks; |
||
11 | |||
12 | protected $fixtures; |
||
13 | |||
14 | public function setUp() |
||
15 | { |
||
16 | $this->fixtures = new Fixtures(); |
||
17 | $this->initTestTasksTrait(); |
||
18 | $this->fixtures->createAndCdToSandbox(); |
||
19 | } |
||
20 | |||
21 | public function tearDown() |
||
22 | { |
||
23 | $this->fixtures->cleanup(); |
||
24 | } |
||
25 | |||
26 | View Code Duplication | public function writeFewLines() |
|
0 ignored issues
–
show
|
|||
27 | { |
||
28 | // write lines with WriteToFile task |
||
29 | $result = $this->taskWriteToFile('blogpost.md') |
||
0 ignored issues
–
show
The method
line does only exist in Robo\Task\File\Write , 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...
|
|||
30 | ->line('****') |
||
31 | ->line('hello world') |
||
32 | ->line('****') |
||
33 | ->run(); |
||
34 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
35 | $this->assertFileExists('blogpost.md'); |
||
36 | $contents = file_get_contents('blogpost.md'); |
||
37 | $expreded = <<<HERE |
||
0 ignored issues
–
show
$expreded 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
Loading history...
|
|||
38 | **** |
||
39 | hello world |
||
40 | **** |
||
41 | |||
42 | HERE; |
||
43 | $this->assertContains($expected, $contents); |
||
0 ignored issues
–
show
|
|||
44 | } |
||
45 | |||
46 | public function appendToFile() |
||
47 | { |
||
48 | $result = $this->taskWriteToFile('a.txt') |
||
0 ignored issues
–
show
The method
append does only exist in Robo\Task\File\Write , 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...
|
|||
49 | ->append() |
||
50 | ->line('hello world') |
||
51 | ->run(); |
||
52 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
53 | $this->assertFileExists('a.txt'); |
||
54 | $contents = file_get_contents('a.txt'); |
||
55 | $expected = <<<HERE |
||
56 | Ahello world |
||
57 | |||
58 | HERE; |
||
59 | $this->assertContains($expected, $contents); |
||
60 | } |
||
61 | |||
62 | public function testWouldChange() |
||
63 | { |
||
64 | $writeTask = $this->taskWriteToFile('a.txt') |
||
0 ignored issues
–
show
The method
append does only exist in Robo\Task\File\Write , 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...
|
|||
65 | ->append(); |
||
66 | $this->assertEquals(false, $writeTask->wouldChange(), "No changes to test file."); |
||
67 | $writeTask->line('hello world'); |
||
68 | $this->assertEquals(true, $writeTask->wouldChange(), "Test file would change."); |
||
69 | } |
||
70 | |||
71 | View Code Duplication | public function insertFile() |
|
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...
|
|||
72 | { |
||
73 | $result = $this->taskWriteToFile('a.txt') |
||
0 ignored issues
–
show
The method
line does only exist in Robo\Task\File\Write , 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...
|
|||
74 | ->line('****') |
||
75 | ->textFromFile('b.txt') |
||
76 | ->line("C") |
||
77 | ->run(); |
||
78 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
79 | $this->assertFileExists('a.txt'); |
||
80 | $contents = file_get_contents('a.txt'); |
||
81 | $expected = <<<HERE |
||
82 | **** |
||
83 | BC |
||
84 | |||
85 | HERE; |
||
86 | $this->assertContains($expected, $contents); |
||
87 | } |
||
88 | |||
89 | public function appendIfMatch() |
||
90 | { |
||
91 | // append lines with WriteToFile task, but only if pattern does not match |
||
92 | $result = $this->taskWriteToFile('blogpost.md') |
||
0 ignored issues
–
show
The method
line does only exist in Robo\Task\File\Write , 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...
|
|||
93 | ->line('****') |
||
94 | ->line('hello world') |
||
95 | ->line('****') |
||
96 | ->appendUnlessMatches('/hello/', 'Should not add this') |
||
97 | ->appendUnlessMatches('/goodbye/', 'Should add this') |
||
98 | ->appendIfMatches('/hello/', ' and should also add this') |
||
99 | ->appendIfMatches('/goodbye/', ' but should not add this') |
||
100 | ->appendIfMatches('/should/', '!') |
||
101 | ->run(); |
||
102 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
103 | $this->assertFileExists('blogpost.md'); |
||
104 | $contents = file_get_contents('blogpost.md'); |
||
105 | $expected = <<<HERE |
||
106 | **** |
||
107 | hello world |
||
108 | **** |
||
109 | Should add this and should also add this! |
||
110 | HERE; |
||
111 | $this->assertContains($expected, $contents); |
||
112 | } |
||
113 | |||
114 | public function replaceInFile() |
||
115 | { |
||
116 | $result = $this->taskReplaceInFile('a.txt') |
||
0 ignored issues
–
show
The method
from does only exist in Robo\Task\File\Replace , 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...
|
|||
117 | ->from('A') |
||
118 | ->to('B') |
||
119 | ->run(); |
||
120 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
121 | $this->assertFileExists('a.txt'); |
||
122 | $contents = file_get_contents('a.txt'); |
||
123 | $this->assertContains('B', $contents); |
||
124 | |||
125 | } |
||
126 | |||
127 | public function replaceMultipleInFile() |
||
128 | { |
||
129 | $result = $this->taskReplaceInFile('box/robo.txt') |
||
0 ignored issues
–
show
The method
from does only exist in Robo\Task\File\Replace , 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...
|
|||
130 | ->from(array('HELLO', 'ROBO')) |
||
131 | ->to(array('Hello ', 'robo.li!')) |
||
132 | ->run(); |
||
133 | $this->assertTrue($result->wasSuccessful(), $result->getMessage()); |
||
134 | $this->assertFileExists('box/robo.txt'); |
||
135 | $contents = file_get_contents('box/robo.txt'); |
||
136 | $this->assertContains('Hello robo.li!', $contents); |
||
137 | } |
||
138 | } |
||
139 | |||
140 |
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.