| Conditions | 1 |
| Paths | 1 |
| Total Lines | 117 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 2 | Features | 0 |
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 |
||
| 58 | public function canCreateServiceConfigProvider() |
||
| 59 | { |
||
| 60 | return [ |
||
| 61 | [ |
||
| 62 | [], |
||
| 63 | 'anything', |
||
| 64 | false, |
||
| 65 | ], |
||
| 66 | [ |
||
| 67 | [ 'thorr_persistence_dmm' => [] ], |
||
| 68 | 'anything', |
||
| 69 | false, |
||
| 70 | ], |
||
| 71 | [ |
||
| 72 | [ |
||
| 73 | 'thorr_persistence_dmm' => [ |
||
| 74 | 'doctrine' => [], |
||
| 75 | ], |
||
| 76 | ], |
||
| 77 | 'anything', |
||
| 78 | false, |
||
| 79 | ], |
||
| 80 | [ |
||
| 81 | [ |
||
| 82 | 'thorr_persistence_dmm' => [ |
||
| 83 | 'doctrine' => [ |
||
| 84 | 'adapters' => [], |
||
| 85 | ], |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | 'anything', |
||
| 89 | false, |
||
| 90 | ], |
||
| 91 | [ |
||
| 92 | [ |
||
| 93 | 'thorr_persistence_dmm' => [ |
||
| 94 | 'doctrine' => [ |
||
| 95 | 'adapters' => [ |
||
| 96 | 'SomeDataMapperServiceName' => 123, |
||
| 97 | ], |
||
| 98 | ], |
||
| 99 | ], |
||
| 100 | ], |
||
| 101 | 'SomeDataMapperServiceName', |
||
| 102 | false, |
||
| 103 | ], |
||
| 104 | [ |
||
| 105 | [ |
||
| 106 | 'thorr_persistence_dmm' => [ |
||
| 107 | 'doctrine' => [ |
||
| 108 | 'adapters' => [ |
||
| 109 | 'SomeDataMapperServiceName' => DoctrineAdapter::class, |
||
| 110 | ], |
||
| 111 | ], |
||
| 112 | ], |
||
| 113 | ], |
||
| 114 | 'SomeDataMapperServiceName', |
||
| 115 | true, |
||
| 116 | ], |
||
| 117 | [ |
||
| 118 | [ |
||
| 119 | 'thorr_persistence_dmm' => [ |
||
| 120 | 'doctrine' => [ |
||
| 121 | 'adapters' => [ |
||
| 122 | 'SomeDataMapperServiceName' => 'not-a-class', |
||
| 123 | ], |
||
| 124 | ], |
||
| 125 | ], |
||
| 126 | ], |
||
| 127 | 'SomeDataMapperServiceName', |
||
| 128 | false, |
||
| 129 | ], |
||
| 130 | [ |
||
| 131 | [ |
||
| 132 | 'thorr_persistence_dmm' => [ |
||
| 133 | 'doctrine' => [ |
||
| 134 | 'adapters' => [ |
||
| 135 | 'SomeDataMapperServiceName' => [ |
||
| 136 | 'class' => DoctrineAdapter::class, |
||
| 137 | ], |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | ], |
||
| 141 | ], |
||
| 142 | 'SomeDataMapperServiceName', |
||
| 143 | true, |
||
| 144 | ], |
||
| 145 | [ |
||
| 146 | [ |
||
| 147 | 'thorr_persistence_dmm' => [ |
||
| 148 | 'doctrine' => [ |
||
| 149 | 'adapters' => [ |
||
| 150 | 'SomeDataMapperServiceName' => [], |
||
| 151 | ], |
||
| 152 | ], |
||
| 153 | ], |
||
| 154 | ], |
||
| 155 | 'SomeDataMapperServiceName', |
||
| 156 | false, |
||
| 157 | ], |
||
| 158 | [ |
||
| 159 | [ |
||
| 160 | 'thorr_persistence_dmm' => [ |
||
| 161 | 'doctrine' => [ |
||
| 162 | 'adapters' => [ |
||
| 163 | 'SomeDataMapperServiceName' => [ |
||
| 164 | 'class' => 'not-a-class', |
||
| 165 | ], |
||
| 166 | ], |
||
| 167 | ], |
||
| 168 | ], |
||
| 169 | ], |
||
| 170 | 'SomeDataMapperServiceName', |
||
| 171 | false, |
||
| 172 | ], |
||
| 173 | ]; |
||
| 174 | } |
||
| 175 | |||
| 332 |
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: