These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | use AspectMock\Test as test; |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | use Robo\Traits\Common\AdjustQuotes; |
||
5 | |||
6 | class GulpTest extends \Codeception\TestCase\Test |
||
7 | { |
||
8 | use AdjustQuotes; |
||
9 | |||
10 | /** |
||
11 | * @var \AspectMock\Proxy\ClassProxy |
||
12 | */ |
||
13 | protected $baseGulp; |
||
14 | |||
15 | protected function _before() |
||
16 | { |
||
17 | $this->baseGulp = test::double('Robo\Task\Gulp\Base', [ |
||
0 ignored issues
–
show
It seems like
\AspectMock\Test::double...e\Output\NullOutput())) can also be of type object<AspectMock\Proxy\InstanceProxy> . However, the property $baseGulp is declared as type object<AspectMock\Proxy\ClassProxy> . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
18 | 'output' => new \Symfony\Component\Console\Output\NullOutput() |
||
19 | ]); |
||
20 | } |
||
21 | |||
22 | // tests |
||
23 | public function testGulpGetCommand() |
||
24 | { |
||
25 | verify( |
||
26 | (new \Robo\Task\Gulp\Run('default','gulp'))->getCommand() |
||
27 | )->equals($this->adjustQuotes("gulp 'default'")); |
||
28 | |||
29 | verify( |
||
30 | (new \Robo\Task\Gulp\Run('another','gulp'))->getCommand() |
||
31 | )->equals($this->adjustQuotes("gulp 'another'")); |
||
32 | |||
33 | verify( |
||
34 | (new \Robo\Task\Gulp\Run('default','gulp'))->silent()->getCommand() |
||
35 | )->equals($this->adjustQuotes("gulp 'default' --silent")); |
||
36 | |||
37 | verify( |
||
38 | (new \Robo\Task\Gulp\Run('default','gulp'))->noColor()->getCommand() |
||
39 | )->equals($this->adjustQuotes("gulp 'default' --no-color")); |
||
40 | |||
41 | verify( |
||
42 | (new \Robo\Task\Gulp\Run('default','gulp'))->color()->getCommand() |
||
43 | )->equals($this->adjustQuotes("gulp 'default' --color")); |
||
44 | |||
45 | verify( |
||
46 | (new \Robo\Task\Gulp\Run('default','gulp'))->simple()->getCommand() |
||
47 | )->equals($this->adjustQuotes("gulp 'default' --tasks-simple")); |
||
48 | } |
||
49 | |||
50 | View Code Duplication | public function testGulpRun() |
|
51 | { |
||
52 | $gulp = test::double('Robo\Task\Gulp\Run', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
53 | |||
54 | $task = (new \Robo\Task\Gulp\Run('default','gulp'))->simple(); |
||
55 | verify($task->getCommand())->equals($this->adjustQuotes("gulp 'default' --tasks-simple")); |
||
56 | $task->run(); |
||
57 | $gulp->verifyInvoked('executeCommand', [$this->adjustQuotes("gulp 'default' --tasks-simple")]); |
||
58 | } |
||
59 | |||
60 | public function testGulpUnusualChars() |
||
61 | { |
||
62 | $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); |
||
63 | |||
64 | if ($isWindows) { |
||
65 | |||
66 | verify( |
||
67 | (new \Robo\Task\Gulp\Run('anotherWith weired!("\') Chars','gulp'))->getCommand() |
||
68 | )->equals('gulp "anotherWith weired!(\"\') Chars"'); |
||
69 | |||
70 | } else { |
||
71 | |||
72 | verify( |
||
73 | (new \Robo\Task\Gulp\Run('anotherWith weired!("\') Chars','gulp'))->getCommand() |
||
74 | )->equals("gulp 'anotherWith weired!(\"'\\'') Chars'"); |
||
75 | |||
76 | } |
||
77 | } |
||
78 | } |
||
79 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: