| Conditions | 6 |
| Paths | 11 |
| Total Lines | 51 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 112 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 113 | { |
||
| 114 | if (version_compare($this->installed, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<')) { |
||
| 115 | $output->writeln($this->translator->trans('The currently installed version of Zikula (%currentVersion%) is too old. You must upgrade to version %minimumVersion% before you can use this upgrade.', ['%currentVersion%' => $this->installed, '%minimumVersion%' => UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION])); |
||
| 116 | |||
| 117 | return 1; |
||
| 118 | } |
||
| 119 | |||
| 120 | $io = new SymfonyStyle($input, $output); |
||
| 121 | if ($input->isInteractive()) { |
||
| 122 | $io->title($this->translator->trans('Zikula Upgrader Script')); |
||
| 123 | $io->section($this->translator->trans('*** UPGRADING TO ZIKULA CORE %version% ***', ['%version%' => ZikulaKernel::VERSION])); |
||
| 124 | $io->text($this->translator->trans('Upgrading Zikula in %env% environment.', ['%env%' => $this->kernel->getEnvironment()])); |
||
| 125 | } |
||
| 126 | |||
| 127 | $iniWarnings = $this->phpHelper->setUp(); |
||
| 128 | if (!empty($iniWarnings)) { |
||
| 129 | $this->printWarnings($output, $iniWarnings); |
||
| 130 | |||
| 131 | return 2; |
||
| 132 | } |
||
| 133 | |||
| 134 | $yamlManager = new YamlDumper($this->kernel->getProjectDir() . '/config', 'services_custom.yaml'); |
||
| 135 | $yamlManager->setParameter('upgrading', true); // tell the core that we are upgrading |
||
| 136 | |||
| 137 | $this->migrateUsers($input, $output, $io); |
||
| 138 | |||
| 139 | // get the settings from user input |
||
| 140 | $settings = $this->doLocale($input, $output, $io); |
||
| 141 | $settings = array_merge($settings, $this->doAdminLogin($input, $output, $io)); |
||
| 142 | if (false === $mailSettings = $this->doMailer($input, $output, $io)) { |
||
| 143 | $io->error($this->translator->trans('Cannot write mailer DSN to %file% file.', ['%file%' => '/.env.local'])); |
||
| 144 | } else { |
||
| 145 | $settings = array_merge($settings, $mailSettings); |
||
| 146 | } |
||
| 147 | $settings = array_merge($settings, $this->doRequestContext($input, $output, $io)); |
||
| 148 | |||
| 149 | if ($input->isInteractive()) { |
||
| 150 | $this->printSettings($settings, $io); |
||
| 151 | $io->newLine(); |
||
| 152 | } |
||
| 153 | |||
| 154 | $params = array_merge($yamlManager->getParameters(), $settings); |
||
| 155 | $yamlManager->setParameters($params); |
||
| 156 | |||
| 157 | // upgrade! |
||
| 158 | $this->stageHelper->handleAjaxStage($this->ajaxUpgraderStage, $io); |
||
| 159 | |||
| 160 | $io->success($this->translator->trans('UPGRADE SUCCESSFUL!')); |
||
| 161 | |||
| 162 | return 0; |
||
| 163 | } |
||
| 213 |
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.