Skip to content

Fix phpstan errors #345

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/cache/sfAPCuCache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public function clean($mode = sfCache::ALL)
if (sfCache::ALL === $mode) {
return apcu_clear_cache();
}

return true;
}

/**
Expand Down Expand Up @@ -139,24 +141,26 @@ public function removePattern($pattern)

$infos = apcu_cache_info();
if (!is_array($infos['cache_list'])) {
return;
return true;
}

$regexp = self::patternToRegexp($this->getOption('prefix').$pattern);
$regexp = $this->patternToRegexp($this->getOption('prefix').$pattern);

foreach ($infos['cache_list'] as $info) {
if (preg_match($regexp, $info['info'])) {
apcu_delete($info['info']);
}
}

return true;
}

/**
* Gets the cache info.
*
* @param string $key The cache key
*
* @return string
* @return string|false|array
*/
protected function getCacheInfo($key)
{
Expand All @@ -177,6 +181,13 @@ protected function getCacheInfo($key)
return null;
}

/**
* @param string $key
*
* @param-out bool $success
*
* @return false|mixed
*/
private function fetch($key, &$success)
{
$has = null;
Expand Down
2 changes: 2 additions & 0 deletions lib/cache/sfFileCache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public function removePattern($pattern)
@unlink($path);
}
}

return true;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/cache/sfMemcacheCache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public function clean($mode = sfCache::ALL)
if (sfCache::ALL === $mode) {
return $this->memcache->flush();
}

return true;
}

/**
Expand Down Expand Up @@ -188,6 +190,8 @@ public function removePattern($pattern)
$this->remove(substr($key, strlen($this->getOption('prefix'))));
}
}

return true;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/task/app/sfAppRoutesTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ protected function execute($arguments = [], $options = [])

// display
$arguments['name'] ? $this->outputRoute($arguments['application'], $arguments['name']) : $this->outputRoutes($arguments['application']);

return 0;
}

protected function outputRoutes($application)
Expand Down
2 changes: 2 additions & 0 deletions lib/task/cache/sfCacheClearTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ protected function execute($arguments = [], $options = [])
if (null === $options['app'] && 'all' == $options['type']) {
$this->getFilesystem()->remove(sfFinder::type('file')->discard('.*')->in(sfConfig::get('sf_cache_dir')));
}

return 0;
}

protected function getClearCacheMethod($type)
Expand Down
2 changes: 2 additions & 0 deletions lib/task/configure/sfConfigureAuthorTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ protected function execute($arguments = [], $options = [])
}

file_put_contents($file, $ini);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/generator/sfGenerateAppTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,7 @@ protected function execute($arguments = [], $options = [])

// Create test dir
$this->getFilesystem()->mkdirs(sfConfig::get('sf_test_dir').'/functional/'.$app);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/generator/sfGenerateModuleTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@ protected function execute($arguments = [], $options = [])
// customize php and yml files
$finder = sfFinder::type('file')->name('*.php', '*.yml');
$this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $constants);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/generator/sfGenerateProjectTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ protected function execute($arguments = [], $options = [])
$fixPerms->run();

$this->replaceTokens();

return 0;
}

protected function canRunInstaller($installer)
Expand Down
2 changes: 2 additions & 0 deletions lib/task/generator/sfGenerateTaskTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,7 @@ protected function execute(\$arguments = array(), \$options = array())

$this->logSection('task', sprintf('Creating "%s" task file', $taskFile));
file_put_contents($taskFile, $content);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/help/sfHelpTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ protected function execute($arguments = [], $options = [])
} else {
$this->outputAsText($task);
}

return 0;
}

protected function outputAsText(sfTask $task)
Expand Down
2 changes: 2 additions & 0 deletions lib/task/help/sfListTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ protected function execute($arguments = [], $options = [])
} else {
$this->outputAsText($arguments['namespace'], $tasks);
}

return 0;
}

protected function outputAsText($namespace, $tasks)
Expand Down
2 changes: 2 additions & 0 deletions lib/task/i18n/sfI18nExtractTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function execute($arguments = [], $options = [])

$extract->deleteOldMessages();
}

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/task/i18n/sfI18nFindTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public function execute($arguments = [], $options = [])
$this->log(" {$message}\n");
}
}

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/task/log/sfLogClearTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ protected function execute($arguments = [], $options = [])
{
$logs = sfFinder::type('file')->in(sfConfig::get('sf_log_dir'));
$this->getFilesystem()->remove($logs);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/log/sfLogRotateTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ protected function configure()
protected function execute($arguments = [], $options = [])
{
$this->rotate($arguments['application'], $arguments['env'], $options['period'], $options['history'], true);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/plugin/sfPluginAddChannelTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ protected function execute($arguments = [], $options = [])
$this->logSection('plugin', sprintf('add channel "%s"', $arguments['name']));

$this->getPluginManager()->getEnvironment()->registerChannel($arguments['name']);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/plugin/sfPluginInstallTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@ protected function execute($arguments = [], $options = [])
}

$this->getPluginManager()->installPlugin($arguments['name'], $options);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/plugin/sfPluginListTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ protected function execute($arguments = [], $options = [])
$alias = $this->getPluginManager()->getEnvironment()->getRegistry()->getChannel($package->getChannel())->getAlias();
$this->log(sprintf(' %-40s %10s-%-6s %s', $this->formatter->format($package->getPackage(), 'INFO'), $package->getVersion(), $package->getState() ?: null, $this->formatter->format(sprintf('# %s (%s)', $package->getChannel(), $alias), 'COMMENT')));
}

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/plugin/sfPluginPublishAssetsTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ protected function execute($arguments = [], $options = [])
$this->logSection('plugin', 'Configuring plugin - '.$plugin);
$this->installPluginAssets($plugin, $pluginConfiguration->getRootDir(), $options['relative']);
}

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/task/plugin/sfPluginUninstallTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ protected function execute($arguments = [], $options = [])
$this->logSection('plugin', sprintf('uninstalling plugin "%s"', $arguments['name']));

$this->getPluginManager()->uninstallPlugin($arguments['name'], $options['channel']);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/plugin/sfPluginUpgradeTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ protected function execute($arguments = [], $options = [])
$this->logSection('plugin', sprintf('upgrading plugin "%s"', $arguments['name']));

$this->getPluginManager()->installPlugin($arguments['name'], $options);

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectClearControllersTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ protected function execute($arguments = [], $options = [])
}
}
}

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectDeployTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ protected function execute($arguments = [], $options = [])
$this->getFilesystem()->execute($command, $options['trace'] ? [$this, 'logOutput'] : null, [$this, 'logErrors']);

$this->clearBuffers();

return 0;
}

protected function clearBuffers()
Expand Down
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectDisableTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ protected function execute($arguments = [], $options = [])
$this->logSection('enable', sprintf('%s [%s] has been DISABLED', $app, $env));
}
}

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectEnableTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ protected function execute($arguments = [], $options = [])
$this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
}
}

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectOptimizeTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ protected function execute($arguments = [], $options = [])
file_put_contents($target, '<?php return '.var_export($data, true).';');

umask($current_umask);

return 0;
}

protected function optimizeGetControllerDirs($modules)
Expand Down
4 changes: 4 additions & 0 deletions lib/task/project/sfProjectPermissionsTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ protected function execute($arguments = [], $options = [])
['Permissions on the following file(s) could not be fixed:', ''],
array_map(function ($f) { return ' - '.sfDebug::shortenFilePath($f); }, $this->failed)
), 'ERROR_LARGE');

return 1;
}

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectSendEmailsTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ protected function execute($arguments = [], $options = [])
$sent = $this->getMailer()->flushQueue();

$this->logSection('project', sprintf('sent %s emails', $sent));

return 0;
}
}
2 changes: 2 additions & 0 deletions lib/task/project/sfProjectValidateTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ protected function execute($arguments = [], $options = [])

$this->log($v->getExplanation());
}

return 0;
}

protected function formatFile($file)
Expand Down
6 changes: 6 additions & 0 deletions lib/task/sfBaseTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function checkProjectExists()
if (!file_exists('symfony')) {
throw new sfException('You must be in a symfony project directory.');
}

return true;
}

/**
Expand All @@ -75,6 +77,8 @@ public function checkAppExists($app)
if (!is_dir(sfConfig::get('sf_apps_dir').'/'.$app)) {
throw new sfException(sprintf('Application "%s" does not exist', $app));
}

return true;
}

/**
Expand All @@ -92,6 +96,8 @@ public function checkModuleExists($app, $module)
if (!is_dir(sfConfig::get('sf_apps_dir').'/'.$app.'/modules/'.$module)) {
throw new sfException(sprintf('Module "%s/%s" does not exist.', $app, $module));
}

return true;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/task/test/sfTestCoverageTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ protected function execute($arguments = [], $options = [])

$coveredFiles = $this->getFiles(sfConfig::get('sf_root_dir').'/'.$arguments['lib_name']);
$coverage->output($coveredFiles);

return 0;
}

protected function getTestHarness($harnessOptions = [])
Expand Down
2 changes: 2 additions & 0 deletions lib/task/test/sfTestFunctionalTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ protected function execute($arguments = [], $options = [])
}
} else {
$this->logSection('functional', 'no controller found', null, 'ERROR');

return 1;
}
} else {
require_once __DIR__.'/sfLimeHarness.class.php';
Expand Down
2 changes: 1 addition & 1 deletion lib/task/test/sfTestPluginTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ protected function execute($arguments = [], $options = [])
$finder = sfFinder::type('file')->follow_link()->name('*Test.php');
$h->register($finder->in($h->base_dir));

$h->run();
return $h->run();
}
}