| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 124 | public function testComposer() |
||
| 125 | { |
||
| 126 | $this->markTestSkipped('Currently not working'); |
||
| 127 | |||
| 128 | vfsStream::setup('root'); |
||
| 129 | vfsStream::create( |
||
| 130 | array( |
||
| 131 | 'htdocs' => array( |
||
| 132 | 'app' => array( |
||
| 133 | 'Mage.php' => '' |
||
| 134 | ) |
||
| 135 | ), |
||
| 136 | 'vendor' => array( |
||
| 137 | 'acme' => array( |
||
| 138 | 'magerun-test-module' => array( |
||
| 139 | 'n98-magerun2.yaml' => file_get_contents(__DIR__ . '/_ApplicationTestComposer/n98-magerun2.yaml'), |
||
| 140 | 'src' => array( |
||
| 141 | 'Acme' => array( |
||
| 142 | 'FooCommand.php' => file_get_contents(__DIR__ . '/_ApplicationTestComposer/FooCommand.php'), |
||
| 143 | ) |
||
| 144 | ) |
||
| 145 | ) |
||
| 146 | ), |
||
| 147 | 'n98' => array( |
||
| 148 | 'magerun' => array( |
||
| 149 | 'src' => array( |
||
| 150 | 'N98' => array( |
||
| 151 | 'Magento' => array( |
||
| 152 | 'Command' => array( |
||
| 153 | 'ConfigurationLoader.php' => '', |
||
| 154 | ), |
||
| 155 | ), |
||
| 156 | ), |
||
| 157 | ), |
||
| 158 | ), |
||
| 159 | ), |
||
| 160 | ), |
||
| 161 | ) |
||
| 162 | ); |
||
| 163 | |||
| 164 | $configurationLoader = $this->getMock( |
||
| 165 | '\N98\Magento\Command\ConfigurationLoader', |
||
| 166 | array('getConfigurationLoaderDir'), |
||
| 167 | array(array(), false, new NullOutput()) |
||
| 168 | ); |
||
| 169 | $configurationLoader |
||
| 170 | ->expects($this->any()) |
||
| 171 | ->method('getConfigurationLoaderDir') |
||
| 172 | ->will($this->returnValue(vfsStream::url('root/vendor/n98/magerun/src/N98/Magento/Command'))); |
||
| 173 | |||
| 174 | /* @var $application Application */ |
||
| 175 | $application = require __DIR__ . '/../../../src/bootstrap.php'; |
||
| 176 | $application->setMagentoRootFolder(vfsStream::url('root/htdocs')); |
||
| 177 | $application->setConfigurationLoader($configurationLoader); |
||
| 178 | $application->init(); |
||
| 179 | |||
| 180 | // Check for module command |
||
| 181 | $this->assertInstanceOf('Acme\FooCommand', $application->find('acme:foo')); |
||
| 182 | } |
||
| 183 | } |
||
| 184 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.