| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| 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 |
||
| 60 | public function register(IRegistrationContext $context): void { |
||
| 61 | $this->registerNavigationEntry(); |
||
| 62 | // $this->registerPersonalPage(); |
||
| 63 | |||
| 64 | $context->registerEventListener( |
||
| 65 | BeforeUserDeletedEvent::class, |
||
| 66 | UserDeletedListener::class |
||
| 67 | ); |
||
| 68 | |||
| 69 | $context->registerSearchProvider(Provider::class); |
||
| 70 | |||
| 71 | $context->registerService(View::class, function () { |
||
| 72 | return new View(''); |
||
| 73 | }, false); |
||
| 74 | |||
| 75 | $context->registerService('isCLI', function () { |
||
| 76 | return \OC::$CLI; |
||
| 77 | }); |
||
| 78 | |||
| 79 | $context->registerMiddleware(ShareMiddleware::class); |
||
| 80 | $context->registerMiddleware(APIMiddleware::class); |
||
| 81 | |||
| 82 | $context->registerService('ShareController', function (ContainerInterface $c) { |
||
| 83 | $server = $this->getContainer()->getServer(); |
||
| 84 | return new ShareController( |
||
| 85 | $c->get('AppName'), |
||
| 86 | $c->get('Request'), |
||
| 87 | $server->getUserSession()->getUser(), |
||
| 88 | $server->getGroupManager(), |
||
| 89 | $server->getUserManager(), |
||
| 90 | $c->get(ActivityService::class), |
||
| 91 | $c->get(VaultService::class), |
||
| 92 | $c->get(ShareService::class), |
||
| 93 | $c->get(CredentialService::class), |
||
| 94 | $c->get(NotificationService::class), |
||
| 95 | $c->get(FileService::class), |
||
| 96 | $c->get(SettingsService::class) |
||
| 97 | ); |
||
| 98 | }); |
||
| 99 | |||
| 100 | |||
| 101 | $context->registerService('CronService', function (ContainerInterface $c) { |
||
| 102 | return new CronService( |
||
| 103 | $c->get(CredentialService::class), |
||
| 104 | $c->get(ILogger::class), |
||
| 105 | $c->get(Utils::class), |
||
| 106 | $c->get(NotificationService::class), |
||
| 107 | $c->get(ActivityService::class), |
||
| 108 | $c->get(IDBConnection::class) |
||
| 109 | ); |
||
| 110 | }); |
||
| 111 | |||
| 112 | $context->registerService('Logger', function (ContainerInterface $c) { |
||
| 113 | return $c->get(ServerContainer::class)->getLogger(); |
||
| 114 | }); |
||
| 115 | } |
||
| 116 | |||
| 153 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.