33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-27 23:36:38 +00:00

skip nonexecutable files [starting with die() or exit()] in GPL rule

This commit is contained in:
Denis Ryabov 2021-05-11 14:43:39 +03:00
parent 40135deac7
commit f7d9cad01a

View File

@ -186,14 +186,15 @@ class JedcheckerRulesGpl extends JEDcheckerRule
*/
protected function find($file)
{
// Check the file is empty (i.e. comments-only)
$content = php_strip_whitespace($file);
if (preg_match('#^<\?php\s+$#', $content))
// Check the file is empty, comments-only, or nonexecutable
if (empty($content) || preg_match('#^<\?php\s+(?:$|(?:die|exit)(?:\(\))?;)#', $content))
{
return true;
}
// Reload file to preserve comments and line numbers
$content = file_get_contents($file);
// Remove leading "*" characters from phpDoc-like comments