| Conditions | 12 | 
| Paths | 480 | 
| Total Lines | 64 | 
| Code Lines | 43 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 0 | Features | 1 | 
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 | ||
| 67 | 	public function getForm() { | ||
| 68 | 		try { | ||
| 69 | 			if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { | ||
|  | |||
| 70 | $invalidTransactionIsolationLevel = false; | ||
| 71 | 			} else { | ||
| 72 | $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED; | ||
| 73 | } | ||
| 74 | 		} catch (DBALException $e) { | ||
| 75 | // ignore | ||
| 76 | $invalidTransactionIsolationLevel = false; | ||
| 77 | } | ||
| 78 | |||
| 79 | 		$envPath = getenv('PATH'); | ||
| 80 | |||
| 81 | // warn if outdated version of a memcache module is used | ||
| 82 | $caches = [ | ||
| 83 | 			'apcu'	=> ['name' => $this->l->t('APCu'), 'version' => '4.0.6'], | ||
| 84 | 			'redis'	=> ['name' => $this->l->t('Redis'), 'version' => '2.2.5'], | ||
| 85 | ]; | ||
| 86 | $outdatedCaches = []; | ||
| 87 | 		foreach ($caches as $php_module => $data) { | ||
| 88 | $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); | ||
| 89 | 			if ($isOutdated) { | ||
| 90 | $outdatedCaches[$php_module] = $data; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | 		if ($this->lockingProvider instanceof NoopLockingProvider) { | ||
| 95 | $fileLockingType = 'none'; | ||
| 96 | 		} else if ($this->lockingProvider instanceof DBLockingProvider) { | ||
| 97 | $fileLockingType = 'db'; | ||
| 98 | 		} else { | ||
| 99 | $fileLockingType = 'cache'; | ||
| 100 | } | ||
| 101 | |||
| 102 | // If the current web root is non-empty but the web root from the config is, | ||
| 103 | // and system cron is used, the URL generator fails to build valid URLs. | ||
| 104 | 		$shouldSuggestOverwriteCliUrl = $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' | ||
| 105 | && \OC::$WEBROOT && \OC::$WEBROOT !== '/' | ||
| 106 | 			&& !$this->config->getSystemValue('overwrite.cli.url', ''); | ||
| 107 | $suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : ''; | ||
| 108 | |||
| 109 | $parameters = [ | ||
| 110 | // Diagnosis | ||
| 111 | 'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), | ||
| 112 | 'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), | ||
| 113 | 'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), | ||
| 114 | 			'checkForWorkingWellKnownSetup'    => $this->config->getSystemValue('check_for_working_wellknown_setup', true), | ||
| 115 | 'has_fileinfo' => \OC_Util::fileInfoLoaded(), | ||
| 116 | 'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel, | ||
| 117 | 'getenvServerNotWorking' => empty($envPath), | ||
| 118 | 'OutdatedCacheWarning' => $outdatedCaches, | ||
| 119 | 'fileLockingType' => $fileLockingType, | ||
| 120 | 'suggestedOverwriteCliUrl' => $suggestedOverwriteCliUrl, | ||
| 121 | |||
| 122 | // Background jobs | ||
| 123 | 			'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), | ||
| 124 | 			'cron_log'            => $this->config->getSystemValue('cron_log', true), | ||
| 125 | 			'lastcron'            => $this->config->getAppValue('core', 'lastcron', false), | ||
| 126 | 			'cronErrors'		  => $this->config->getAppValue('core', 'cronErrors'), | ||
| 127 | ]; | ||
| 128 | |||
| 129 | 		return new TemplateResponse('settings', 'admin/server', $parameters, ''); | ||
| 130 | } | ||
| 131 | |||
| 150 | 
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.