| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 26 | public function shouldApplyDecoratorTemplate() |
||
| 27 | { |
||
| 28 | /** @var Reference $oldReference */ |
||
| 29 | $oldReference = $this->createMock(Reference::class); |
||
| 30 | $oldReference->method('__toString')->willReturn('some-string-representation'); |
||
|
|
|||
| 31 | $oldReference->method('getInvalidBehavior')->willReturn(1); |
||
| 32 | |||
| 33 | /** @var Definition $decoratorDefinition */ |
||
| 34 | $decoratorDefinition = $this->createMock(Definition::class); |
||
| 35 | $decoratorDefinition->method('getTags')->willReturn([ |
||
| 36 | 'some.tag.name' => 'foo' |
||
| 37 | ]); |
||
| 38 | $decoratorDefinition->expects($this->once())->method('setTags')->with([ |
||
| 39 | ]); |
||
| 40 | $decoratorDefinition->method('getArguments')->willReturn([ |
||
| 41 | 'foo', |
||
| 42 | ['bar', 123, '%some_param%'], |
||
| 43 | ['abc' => ['def' => $oldReference]], |
||
| 44 | new Reference('some-decorator-service-id.inner', 1) |
||
| 45 | ]); |
||
| 46 | $decoratorDefinition->expects($this->once())->method('setArguments')->with([ |
||
| 47 | 'foo', |
||
| 48 | ['bar', 123, 'some-resolved'], |
||
| 49 | ['abc' => ['def' => new Reference('some-string-representation', 1)]], |
||
| 50 | new Reference('some-decorated-service-id.some.tag.name.some-decorator-service-id.inner', 1) |
||
| 51 | ]); |
||
| 52 | $decoratorDefinition->expects($this->once())->method('setDecoratedService')->with( |
||
| 53 | $this->equalTo('some-decorated-service-id') |
||
| 54 | ); |
||
| 55 | |||
| 56 | /** @var ContainerBuilder $container */ |
||
| 57 | $container = $this->createMock(ContainerBuilder::class); |
||
| 58 | $container->expects($this->once())->method('findTaggedServiceIds')->with( |
||
| 59 | $this->equalTo("some.tag.name") |
||
| 60 | )->willReturn([ |
||
| 61 | 'some-decorator-service-id' => [ |
||
| 62 | ['decorates' => 'some-decorated-service-id', 'some_param' => 'some-resolved'] |
||
| 63 | ] |
||
| 64 | ]); |
||
| 65 | $container->expects($this->once())->method('getDefinition')->with( |
||
| 66 | $this->equalTo('some-decorator-service-id') |
||
| 67 | )->willReturn($decoratorDefinition); |
||
| 68 | $container->expects($this->once())->method('setDefinition')->with( |
||
| 69 | $this->equalTo("some-decorated-service-id.some.tag.name.some-decorator-service-id"), |
||
| 70 | $this->equalTo($decoratorDefinition) |
||
| 71 | ); |
||
| 72 | $container->expects($this->once())->method('removeDefinition')->with( |
||
| 73 | $this->equalTo("some-decorator-service-id") |
||
| 74 | ); |
||
| 75 | |||
| 76 | $compilerPass = new DecoratorTemplateCompilerPass("some.tag.name"); |
||
| 77 | $compilerPass->process($container); |
||
| 78 | } |
||
| 79 | |||
| 131 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.