Conditions | 1 |
Paths | 1 |
Total Lines | 67 |
Code Lines | 47 |
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 |
||
135 | public function testWillTryAutoGeneration() : void |
||
136 | { |
||
137 | $instance = new stdClass(); |
||
138 | $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); |
||
139 | $generator = $this->createMock(GeneratorStrategyInterface::class); |
||
140 | $autoloader = $this->createMock(AutoloaderInterface::class); |
||
141 | |||
142 | $this->config->expects(self::any())->method('getGeneratorStrategy')->will(self::returnValue($generator)); |
||
|
|||
143 | $this->config->expects(self::any())->method('getProxyAutoloader')->will(self::returnValue($autoloader)); |
||
144 | |||
145 | $generator |
||
146 | ->expects(self::once()) |
||
147 | ->method('generate') |
||
148 | ->with( |
||
149 | self::callback( |
||
150 | function (ClassGenerator $targetClass) use ($proxyClassName) : bool { |
||
151 | return $targetClass->getName() === $proxyClassName; |
||
152 | } |
||
153 | ) |
||
154 | ); |
||
155 | |||
156 | // simulate autoloading |
||
157 | $autoloader |
||
158 | ->expects(self::once()) |
||
159 | ->method('__invoke') |
||
160 | ->with($proxyClassName) |
||
161 | ->willReturnCallback(function () use ($proxyClassName) : bool { |
||
162 | eval( |
||
163 | 'class ' . $proxyClassName |
||
164 | . ' extends \\ProxyManagerTestAsset\\AccessInterceptorValueHolderMock {}' |
||
165 | ); |
||
166 | |||
167 | return true; |
||
168 | }); |
||
169 | |||
170 | $this |
||
171 | ->inflector |
||
172 | ->expects(self::once()) |
||
173 | ->method('getProxyClassName') |
||
174 | ->with('stdClass') |
||
175 | ->will(self::returnValue($proxyClassName)); |
||
176 | |||
177 | $this |
||
178 | ->inflector |
||
179 | ->expects(self::once()) |
||
180 | ->method('getUserClassName') |
||
181 | ->with('stdClass') |
||
182 | ->will(self::returnValue(EmptyClass::class)); |
||
183 | |||
184 | $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); |
||
185 | $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); |
||
186 | |||
187 | $factory = new AccessInterceptorValueHolderFactory($this->config); |
||
188 | $prefixInterceptors = [function () { |
||
189 | self::fail('Not supposed to be called'); |
||
190 | }]; |
||
191 | $suffixInterceptors = [function () { |
||
192 | self::fail('Not supposed to be called'); |
||
193 | }]; |
||
194 | /* @var $proxy AccessInterceptorValueHolderMock */ |
||
195 | $proxy = $factory->createProxy($instance, $prefixInterceptors, $suffixInterceptors); |
||
196 | |||
197 | self::assertInstanceOf($proxyClassName, $proxy); |
||
198 | self::assertSame($instance, $proxy->instance); |
||
199 | self::assertSame($prefixInterceptors, $proxy->prefixInterceptors); |
||
200 | self::assertSame($suffixInterceptors, $proxy->suffixInterceptors); |
||
201 | } |
||
202 | } |
||
203 |
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.