31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-09-23 10:39:12 +00:00

Allow declare/namespace/use statements before the JEXEC guard

This commit is contained in:
Denis Ryabov 2021-03-09 23:39:05 +03:00
parent 1a201318c6
commit edf06dc135

View File

@ -122,6 +122,9 @@ class JedcheckerRulesJexec extends JEDcheckerRule
$this->regex
= '#^' // at the beginning of the file
. '<\?php\s+' // there is an opening php tag
. '(?:declare ?\(strict_types ?= ?1 ?\) ?; ?)?' // optionally followed by declare(strict_types=1) directive
. '(?:namespace [0-9A-Za-z_\\\\]+ ?; ?)?' // optionally followed by namespace directive
. '(?:use [0-9A-Za-z_\\\\]+ ?(?:as [0-9A-Za-z_]+ ?)?; ?)*' // optionally followed by use directives
. 'defined ?\( ?' // followed by defined test
. '([\'"])(?:' . implode('|', $defines) . ')\1' // of any of given constant
. ' ?\) ?(?:or |\|\| ?)(?:die|exit)\b' // or exit