| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| Code Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 53 | public function testBuild() |
||
| 54 | { |
||
| 55 | $container = $this->createContainerBuilderMock(); |
||
| 56 | $container |
||
|
|
|||
| 57 | ->expects($this->at(0)) |
||
| 58 | ->method('addCompilerPass') |
||
| 59 | ->with($this->isInstanceOf(RegisterResourcePass::class)) |
||
| 60 | ->will($this->returnSelf()); |
||
| 61 | |||
| 62 | $container |
||
| 63 | ->expects($this->at(1)) |
||
| 64 | ->method('addCompilerPass') |
||
| 65 | ->with($this->isInstanceOf(RegisterDriverMappingPass::class)) |
||
| 66 | ->will($this->returnSelf()); |
||
| 67 | |||
| 68 | $container |
||
| 69 | ->expects($this->at(2)) |
||
| 70 | ->method('addCompilerPass') |
||
| 71 | ->with($this->isInstanceOf(RegisterFactoryPass::class)) |
||
| 72 | ->will($this->returnSelf()); |
||
| 73 | |||
| 74 | $container |
||
| 75 | ->expects($this->at(3)) |
||
| 76 | ->method('addCompilerPass') |
||
| 77 | ->with($this->isInstanceOf(RegisterManagerTagPass::class)) |
||
| 78 | ->will($this->returnSelf()); |
||
| 79 | |||
| 80 | $container |
||
| 81 | ->expects($this->at(4)) |
||
| 82 | ->method('addCompilerPass') |
||
| 83 | ->with($this->isInstanceOf(RegisterManagerPass::class)) |
||
| 84 | ->will($this->returnSelf()); |
||
| 85 | |||
| 86 | $container |
||
| 87 | ->expects($this->at(5)) |
||
| 88 | ->method('addCompilerPass') |
||
| 89 | ->with($this->isInstanceOf(RegisterRepositoryPass::class)) |
||
| 90 | ->will($this->returnSelf()); |
||
| 91 | |||
| 92 | $container |
||
| 93 | ->expects($this->at(6)) |
||
| 94 | ->method('addCompilerPass') |
||
| 95 | ->with($this->isInstanceOf(RegisterDomainManagerPass::class)) |
||
| 96 | ->will($this->returnSelf()); |
||
| 97 | |||
| 98 | $container |
||
| 99 | ->expects($this->at(7)) |
||
| 100 | ->method('addCompilerPass') |
||
| 101 | ->with($this->isInstanceOf(ConfigureResolveTargetEntitySubscriberPass::class)) |
||
| 102 | ->will($this->returnSelf()); |
||
| 103 | |||
| 104 | $container |
||
| 105 | ->expects($this->at(8)) |
||
| 106 | ->method('addCompilerPass') |
||
| 107 | ->with($this->isInstanceOf(RegisterFlashListenerPass::class)) |
||
| 108 | ->will($this->returnSelf()); |
||
| 109 | |||
| 110 | $container |
||
| 111 | ->expects($this->at(9)) |
||
| 112 | ->method('addCompilerPass') |
||
| 113 | ->with($this->isInstanceOf(RegisterMessageListenerPass::class)) |
||
| 114 | ->will($this->returnSelf()); |
||
| 115 | |||
| 116 | $container |
||
| 117 | ->expects($this->at(10)) |
||
| 118 | ->method('addCompilerPass') |
||
| 119 | ->with($this->isInstanceOf(ReplaceBase64FileExtensionPass::class)) |
||
| 120 | ->will($this->returnSelf()); |
||
| 121 | |||
| 122 | $container |
||
| 123 | ->expects($this->at(11)) |
||
| 124 | ->method('addCompilerPass') |
||
| 125 | ->with($this->isInstanceOf(ReplaceBooleanExtensionPass::class)) |
||
| 126 | ->will($this->returnSelf()); |
||
| 127 | |||
| 128 | $this->bundle->build($container); |
||
| 129 | } |
||
| 130 | |||
| 139 |
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:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: