public static function php_check_file_syntax($file, &$error = null)
{
// Prepend and append PHP opening tags to prevent eval() failures.
$plugin_code = file_get_contents($file);
$replacements = array('#^<\\?(php)?\\s#A' => '', '#\\?>$#' => '', '#(?<!\\w)namespace [^;]+;#' => 'namespace HabariSandBox\\Plugin;');
foreach ($replacements as $search => $replacement) {
if (preg_match($search, $plugin_code)) {
$plugin_code = trim(preg_replace($search, $replacement, $plugin_code));
}
}
return self::php_check_syntax($plugin_code, $error);
}