| Conditions | 9 |
| Paths | 50 |
| Total Lines | 59 |
| Code Lines | 34 |
| 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 |
||
| 81 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 82 | { |
||
| 83 | $io = new SymfonyStyle($input, $output); |
||
| 84 | $io->title($this->translator->trans('Zikula Installer Script')); |
||
| 85 | |||
| 86 | if (true === $this->installed) { |
||
| 87 | $io->error($this->translator->trans('Zikula already appears to be installed.')); |
||
| 88 | |||
| 89 | return 1; |
||
| 90 | } |
||
| 91 | |||
| 92 | $iniWarnings = $this->phpHelper->setUp(); |
||
| 93 | if (!empty($iniWarnings)) { |
||
| 94 | $this->printWarnings($output, $iniWarnings); |
||
| 95 | |||
| 96 | return 2; |
||
| 97 | } |
||
| 98 | |||
| 99 | if ($input->isInteractive()) { |
||
| 100 | $io->comment($this->translator->trans('Configuring Zikula installation in %env% environment.', ['%env%' => $this->kernel->getEnvironment()])); |
||
| 101 | $io->comment($this->translator->trans('Please follow the instructions to install Zikula %version%.', ['%version%' => ZikulaKernel::VERSION])); |
||
| 102 | } |
||
| 103 | |||
| 104 | // get the settings from user input |
||
| 105 | $settings = $this->doLocale($input, $output, $io); |
||
| 106 | $settings = array_merge($settings, $this->doRequestContext($input, $output, $io)); |
||
| 107 | if (!$this->doDBCreds($input, $output, $io)) { |
||
| 108 | $io->error($this->translator->trans('Cannot write database DSN to %file% file.', ['%file%' => '/.env.local'])); |
||
| 109 | } |
||
| 110 | if (false === $mailSettings = $this->doMailer($input, $output, $io)) { |
||
| 111 | $io->error($this->translator->trans('Cannot write mailer DSN to %file% file.', ['%file%' => '/.env.local'])); |
||
| 112 | } else { |
||
| 113 | $settings = array_merge($settings, $mailSettings); |
||
| 114 | } |
||
| 115 | $settings = array_merge($settings, $this->doAdminCreate($input, $output, $io)); |
||
| 116 | |||
| 117 | if ($input->isInteractive()) { |
||
| 118 | $io->success($this->translator->trans('Configuration successful. Please verify your parameters below:')); |
||
| 119 | $io->comment($this->translator->trans('(Admin credentials have been encoded to make them json-safe.)')); |
||
| 120 | } |
||
| 121 | |||
| 122 | if ($input->isInteractive()) { |
||
| 123 | $this->printSettings($settings, $io); |
||
| 124 | $io->newLine(); |
||
| 125 | $confirmation = $io->confirm($this->translator->trans('Start installation?'), true); |
||
| 126 | |||
| 127 | if (!$confirmation) { |
||
| 128 | $io->error($this->translator->trans('Installation aborted')); |
||
| 129 | |||
| 130 | return 3; |
||
| 131 | } |
||
| 132 | } |
||
| 133 | |||
| 134 | // write parameters into config/services_custom.yaml and env vars into .env.local |
||
| 135 | $this->parameterHelper->initializeParameters($settings); |
||
| 136 | |||
| 137 | $io->success($this->translator->trans('First stage of installation complete. Run `php bin/console zikula:install:finish` to complete the installation.')); |
||
| 138 | |||
| 139 | return 0; |
||
| 140 | } |
||
| 165 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.