[], 'js' => []]; protected function init(): bool { $this->setProperties([ 'id' => 'dcdeprecated', 'name' => __('Dotclear deprecated'), 'description' => __('Search for use of deprecated Dotclear functions'), 'priority' => 520, 'types' => ['plugin', 'theme'], ]); $this->loadDeprecatedDefinition(); return true; } private function loadDeprecatedDefinition() { $path = path::real(__DIR__ . '/dcdeprecated'); if (!$path) { return []; } if (!is_dir($path) || !is_readable($path)) { return []; } $files = files::scandir($path); foreach ($files as $file) { if (substr($file, 0, 1) == '.') { continue; } $tmp = require $path . '/' . $file; if (is_array($tmp) && isset($tmp['php'])) { $this->deprecated['php'] = array_merge($this->deprecated['php'], $tmp['php']); } if (is_array($tmp) && isset($tmp['js'])) { $this->deprecated['js'] = array_merge($this->deprecated['js'], $tmp['js']); } } } public function isConfigured(): bool { return true; } public function readFile(&$content): ?bool { if (!in_array($this->path_extension, array_keys($this->deprecated))) { return null; } foreach ($this->deprecated[$this->path_extension] as $d) { if (preg_match('/' . $d[0] . '/i', $content)) { $this->setWarning(sprintf(__('Possible use of deprecated "%s", you should use "%s" instead since Dotclear %s.'), $d[1], __($d[2]), $d[3]) . (empty($d[4]) ? '' : ' ' . __('Help') . ' ')); } } return true; } }