1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of CaptainHook |
||
5 | * |
||
6 | * (c) Sebastian Feldmann <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace CaptainHook\App; |
||
13 | |||
14 | use CaptainHook\App\Console\Runtime\Resolver; |
||
15 | use PHPUnit\Framework\MockObject\MockBuilder; |
||
0 ignored issues
–
show
|
|||
16 | use SebastianFeldmann\Git\Operator\Diff; |
||
17 | use SebastianFeldmann\Git\Operator\Index; |
||
18 | use SebastianFeldmann\Git\Operator\Config; |
||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
CaptainHook\App\Config . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||
19 | use SebastianFeldmann\Git\Operator\Info; |
||
20 | use SebastianFeldmann\Git\Operator\Log; |
||
21 | use SebastianFeldmann\Git\Operator\Remote; |
||
22 | use SebastianFeldmann\Git\Repository; |
||
23 | |||
24 | trait Mockery |
||
25 | { |
||
26 | /** |
||
27 | * Create resolver mock |
||
28 | * |
||
29 | * @param string $executable |
||
30 | * @param bool $isPhar |
||
31 | * @return \CaptainHook\App\Console\Runtime\Resolver&\PHPUnit\Framework\MockObject\MockObject |
||
32 | */ |
||
33 | public function createResolverMock(string $executable = 'vendor/bin/captainhook', bool $isPhar = false): Resolver |
||
34 | { |
||
35 | $repo = $this->getMockBuilder(Resolver::class) |
||
36 | ->disableOriginalConstructor() |
||
37 | ->getMock(); |
||
38 | |||
39 | $repo->method('getExecutable')->willReturn($executable); |
||
40 | $repo->method('isPharRelease')->willReturn($isPhar); |
||
41 | |||
42 | return $repo; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Create repository mock |
||
47 | * |
||
48 | * @param string $root |
||
49 | * @return \SebastianFeldmann\Git\Repository&\PHPUnit\Framework\MockObject\MockObject |
||
50 | */ |
||
51 | public function createRepositoryMock(string $root = '', string $hooksDir = ''): Repository |
||
52 | { |
||
53 | |||
54 | $repo = $this->getMockBuilder(Repository::class) |
||
55 | ->disableOriginalConstructor() |
||
56 | ->getMock(); |
||
57 | |||
58 | $repo->method('getRoot')->willReturn($root); |
||
59 | $repo->method('getHooksDir')->willReturn(empty($hooksDir) ? $root . '/.git/hooks' : $hooksDir); |
||
60 | |||
61 | return $repo; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Create info operator mock |
||
66 | * |
||
67 | * @param string $tag |
||
68 | * @param string $branch |
||
69 | * @return \SebastianFeldmann\Git\Operator\Info&\PHPUnit\Framework\MockObject\MockObject |
||
70 | */ |
||
71 | public function createGitInfoOperator(string $tag = 'v1.0.0', string $branch = 'master'): Info |
||
72 | { |
||
73 | $operator = $this->getMockBuilder(Info::class) |
||
74 | ->disableOriginalConstructor() |
||
75 | ->getMock(); |
||
76 | |||
77 | $operator->method('getCurrentTag')->willReturn($tag); |
||
78 | $operator->method('getCurrentBranch')->willReturn($branch); |
||
79 | |||
80 | return $operator; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Create diff operator mock |
||
85 | * |
||
86 | * @param array $changedFiles |
||
87 | * @return \SebastianFeldmann\Git\Operator\Diff&\PHPUnit\Framework\MockObject\MockObject |
||
88 | */ |
||
89 | public function createGitDiffOperator(array $changedFiles = []): Diff |
||
90 | { |
||
91 | $operator = $this->getMockBuilder(Diff::class) |
||
92 | ->disableOriginalConstructor() |
||
93 | ->getMock(); |
||
94 | |||
95 | $operator->method('getChangedFiles')->willReturn($changedFiles); |
||
96 | |||
97 | return $operator; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Create remote operator mock |
||
102 | * |
||
103 | * @return \SebastianFeldmann\Git\Operator\Remote&\PHPUnit\Framework\MockObject\MockObject |
||
104 | */ |
||
105 | public function createGitRemoteOperator(): Remote |
||
106 | { |
||
107 | return $this->getMockBuilder(Remote::class) |
||
108 | ->disableOriginalConstructor() |
||
109 | ->getMock(); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * Create log operator mock |
||
114 | * |
||
115 | * @return \SebastianFeldmann\Git\Operator\Log&\PHPUnit\Framework\MockObject\MockObject |
||
116 | */ |
||
117 | public function createGitLogOperator(): Log |
||
118 | { |
||
119 | $operator = $this->getMockBuilder(Log::class) |
||
120 | ->disableOriginalConstructor() |
||
121 | ->getMock(); |
||
122 | |||
123 | return $operator; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Create index operator mock |
||
128 | * |
||
129 | * @param array $stagedFiles |
||
130 | * @return \SebastianFeldmann\Git\Operator\Index&\PHPUnit\Framework\MockObject\MockObject |
||
131 | */ |
||
132 | public function createGitIndexOperator(array $stagedFiles = []): Index |
||
133 | { |
||
134 | $operator = $this->getMockBuilder(Index::class) |
||
135 | ->disableOriginalConstructor() |
||
136 | ->getMock(); |
||
137 | |||
138 | $operator->method('getStagedFiles')->willReturn($stagedFiles); |
||
139 | |||
140 | return $operator; |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Create config operator mock |
||
145 | * |
||
146 | * @return \SebastianFeldmann\Git\Operator\Config&\PHPUnit\Framework\MockObject\MockObject |
||
147 | */ |
||
148 | public function createGitConfigOperator(): Config |
||
149 | { |
||
150 | return $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @param $type |
||
155 | * @return \PHPUnit\Framework\MockObject\MockBuilder |
||
156 | */ |
||
157 | abstract public function getMockBuilder(string $type): MockBuilder; |
||
158 | } |
||
159 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths