Conditions | 9 |
Paths | 1 |
Total Lines | 62 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
44 | public function setUp() |
||
45 | { |
||
46 | // NEXT_MAJOR: Hack for php 5.3 only, remove it when requirement of PHP is >= 5.4 |
||
47 | $that = $this; |
||
48 | |||
49 | $this->formMapper = $this->getMockBuilder('Sonata\AdminBundle\Form\FormMapper')->disableOriginalConstructor()->getMock(); |
||
50 | $this->formMapper |
||
51 | ->expects($this->any()) |
||
52 | ->method('add') |
||
53 | ->will($this->returnCallback(function ($name, $type = null) use ($that) { |
||
54 | // NEXT_MAJOR: Remove this "if" (when requirement of Symfony is >= 2.8) |
||
55 | if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { |
||
56 | if (null !== $type) { |
||
57 | $isFQCN = class_exists($type); |
||
58 | if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { |
||
59 | // 2.8 |
||
60 | @trigger_error( |
||
|
|||
61 | sprintf( |
||
62 | 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' |
||
63 | .' Use the fully-qualified type class name instead.', |
||
64 | $type |
||
65 | ), |
||
66 | E_USER_DEPRECATED) |
||
67 | ; |
||
68 | } |
||
69 | |||
70 | $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); |
||
71 | } |
||
72 | } |
||
73 | })); |
||
74 | |||
75 | $this->formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')->disableOriginalConstructor()->getMock(); |
||
76 | $this->formBuilder |
||
77 | ->expects($this->any()) |
||
78 | ->method('add') |
||
79 | ->will($this->returnCallback(function ($name, $type = null) use ($that) { |
||
80 | // NEXT_MAJOR: Remove this "if" (when requirement of Symfony is >= 2.8) |
||
81 | if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { |
||
82 | if (null !== $type) { |
||
83 | $isFQCN = class_exists($type); |
||
84 | if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { |
||
85 | // 2.8 |
||
86 | @trigger_error( |
||
87 | sprintf( |
||
88 | 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' |
||
89 | .' Use the fully-qualified type class name instead.', |
||
90 | $type |
||
91 | ), |
||
92 | E_USER_DEPRECATED) |
||
93 | ; |
||
94 | } |
||
95 | |||
96 | $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); |
||
97 | } |
||
98 | } |
||
99 | })); |
||
100 | |||
101 | |||
102 | $this->formBuilder->expects($this->any())->method('getOption')->willReturn('api'); |
||
103 | |||
104 | $this->provider = $this->getProvider(); |
||
105 | } |
||
106 | |||
127 |
If you suppress an error, we recommend checking for the error condition explicitly: