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 | use Robo\Robo; |
||
4 | |||
5 | class ApiGenTest extends \Codeception\TestCase\Test |
||
6 | { |
||
7 | protected $container; |
||
8 | |||
9 | /** |
||
10 | * @var \AspectMock\Proxy\ClassProxy |
||
11 | */ |
||
12 | protected $apigen; |
||
13 | |||
14 | protected function _before() |
||
15 | { |
||
16 | $this->apigen = test::double('Robo\Task\ApiGen\ApiGen', [ |
||
17 | 'executeCommand' => null, |
||
18 | 'output' => new \Symfony\Component\Console\Output\NullOutput(), |
||
19 | 'logger' => new \Psr\Log\NullLogger(), |
||
20 | ]); |
||
21 | |||
22 | $this->container = Robo::getContainer(); |
||
23 | } |
||
24 | |||
25 | // tests |
||
26 | public function testPHPUnitCommand() |
||
27 | { |
||
28 | // need an explicit Traversable |
||
29 | $skippedPaths = new \SplDoublyLinkedList(); |
||
30 | $skippedPaths->push('a'); |
||
31 | $skippedPaths->push('b'); |
||
32 | |||
33 | // going for 'bang for the buck' here re: test converage |
||
34 | $task = (new \Robo\Task\ApiGen\ApiGen('apigen')) |
||
35 | ->config('./apigen.neon') |
||
36 | ->source('src') // single string value of Traversable |
||
37 | ->extensions('php') // single string value of List |
||
38 | ->exclude(array('test', 'tmp')) // array value of Traversable |
||
39 | ->skipDocPath($skippedPaths) // multi-value of Traversable |
||
40 | ->charset(array('utf8','iso88591')) // array of List |
||
41 | ->internal('no') // boolean as supported "no" |
||
42 | ->php(true) // boolean as boolean |
||
43 | ->tree('Y') // boolean as string |
||
44 | ->debug('n'); |
||
45 | |||
46 | $linuxCmd = 'apigen generate --config ./apigen.neon --source src --extensions php --exclude test --exclude tmp --skip-doc-path a --skip-doc-path b --charset \'utf8,iso88591\' --internal no --php yes --tree yes --debug no'; |
||
47 | |||
48 | $winCmd = 'apigen generate --config ./apigen.neon --source src --extensions php --exclude test --exclude tmp --skip-doc-path a --skip-doc-path b --charset "utf8,iso88591" --internal no --php yes --tree yes --debug no'; |
||
49 | |||
50 | $cmd = stripos(PHP_OS, 'WIN') === 0 ? $winCmd : $linuxCmd; |
||
51 | |||
52 | verify($task->getCommand())->equals($cmd); |
||
53 | |||
54 | $task->run(); |
||
55 | $this->apigen->verifyInvoked('executeCommand', [$cmd]); |
||
56 | } |
||
57 | } |
||
58 |
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: