Add PHPStan and other quality checks

Similar to FreshRSS core
Contributes to https://github.com/FreshRSS/Extensions/issues/184
This commit is contained in:
Alexandre Alapetite 2023-11-23 22:41:09 +01:00
parent a86467db48
commit b49596818c
No known key found for this signature in database
GPG key ID: A24378C38E812B23
59 changed files with 1173 additions and 404 deletions

View file

@ -3,11 +3,14 @@
declare(strict_types=1);
class CustomCSSExtension extends Minz_Extension {
public function init() {
public string $css_rules;
public string $permission_problem = '';
public function init(): void {
$this->registerTranslates();
$current_user = Minz_Session::paramString('currentUser');
$filename = 'style.' . $current_user . '.css';
$filename = 'style.' . $current_user . '.css';
$filepath = join_path($this->getPath(), 'static', $filename);
if (file_exists($filepath)) {
@ -15,28 +18,28 @@ class CustomCSSExtension extends Minz_Extension {
}
}
public function handleConfigureAction() {
public function handleConfigureAction(): void {
$this->registerTranslates();
$current_user = Minz_Session::paramString('currentUser');
$filename = 'style.' . $current_user . '.css';
$filename = 'style.' . $current_user . '.css';
$staticPath = join_path($this->getPath(), 'static');
$filepath = join_path($staticPath, $filename);
if (!file_exists($filepath) && !is_writable($staticPath)) {
$tmpPath = explode(EXTENSIONS_PATH . '/', $staticPath);
$this->permission_problem = $tmpPath[1] . '/';
} else if (file_exists($filepath) && !is_writable($filepath)) {
} elseif (file_exists($filepath) && !is_writable($filepath)) {
$tmpPath = explode(EXTENSIONS_PATH . '/', $filepath);
$this->permission_problem = $tmpPath[1];
} else if (Minz_Request::isPost()) {
} elseif (Minz_Request::isPost()) {
$css_rules = html_entity_decode(Minz_Request::paramString('css-rules'));
file_put_contents($filepath, $css_rules);
}
$this->css_rules = '';
if (file_exists($filepath)) {
$this->css_rules = htmlentities(file_get_contents($filepath));
$this->css_rules = htmlentities(file_get_contents($filepath) ?: '');
}
}
}