From ce0a287403e7b49f9dd5594a9d03aa5f736491d0 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Wed, 3 Jun 2026 20:13:58 -0700 Subject: [PATCH] getDefinedFunctionsInFile() should remove heredocs --- Sources/Actions/Admin/Maintenance.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/Actions/Admin/Maintenance.php b/Sources/Actions/Admin/Maintenance.php index 4175a67f33..50550dfcec 100644 --- a/Sources/Actions/Admin/Maintenance.php +++ b/Sources/Actions/Admin/Maintenance.php @@ -2274,15 +2274,22 @@ protected static function parseIntegrationHook(string $hook, string $rawData): a protected static function getDefinedFunctionsInFile(string $file): array { + static $patterns = [ + // Remove multiline comments so regex does not + // match fake functions/classes inside them. + '~//[^\h]+|/\*.*?\*/~s', + + // Also must remove those pesky heredocs. + '/<<<[\'"]?(\w+)[\'"]?[\r\n]+[\s\S]*?[\r\n]+\1;/', + ]; + $source = file_get_contents($file); if (!str_contains($source, 'function')) { return []; } - // Remove multiline comments so regex does not - // match fake functions/classes inside them. - $source = preg_replace('~//[^\h]+|/\*.*?\*/~s', '', $source); + $source = preg_replace($patterns, '', $source); $functions = []; $namespace = ''; $class = '';