We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 3 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | private function getDIContainerMock(array $services = [], array $parameters = []) |
||
17 | { |
||
18 | $container = $this->getMock('Symfony\\Component\\DependencyInjection\\Container', ['get', 'getParameter', 'has']); |
||
|
|||
19 | |||
20 | $getMethod = $container->expects($this->any())->method('get'); |
||
21 | |||
22 | foreach ($services as $id => $service) { |
||
23 | $getMethod |
||
24 | ->with($id) |
||
25 | ->willReturn($service) |
||
26 | ; |
||
27 | } |
||
28 | |||
29 | $getParameterMethod = $container->expects($this->any())->method('getParameter'); |
||
30 | |||
31 | foreach ($parameters as $id => $parameter) { |
||
32 | $getParameterMethod |
||
33 | ->with($id) |
||
34 | ->willReturn($parameter) |
||
35 | ; |
||
36 | } |
||
37 | |||
38 | return $container; |
||
39 | } |
||
40 | } |
||
41 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.