setProperties([ 'id' => 'endoffile', 'name' => __('End of files'), 'description' => __('Remove php tag and empty lines from end of files'), 'priority' => 860, 'configurator' => true, 'types' => ['plugin', 'theme'], ]); return true; } public function isConfigured(): bool { return true; } public function configure($url): ?string { if (!empty($_POST['save'])) { $this->setSettings('psr2', !empty($_POST['endoffile_psr2'])); $this->redirect($url); } return '
' . __('PSR2 must have a blank line, whereas PSR12 must not.') . '
'; } public function readFile(&$content): ?bool { if (!in_array($this->path_extension, ['php', 'md'])) { return null; } $clean = preg_replace( ['/(\s*)(\?>\s*)$/', '/\n+$/'], '', $content ) . ($this->getSetting('psr2') ? "\n" : ''); if ($content != $clean) { $this->setSuccess(__('Replace end of file')); $content = $clean; } return true; } }