From 963724dcbf027f65a9c254e3eae5b4b5e6c85926 Mon Sep 17 00:00:00 2001 From: tharindarodrigo Date: Fri, 26 Jan 2024 00:33:38 -0700 Subject: [PATCH] Update Permission.php namespace detection edge case resolved --- src/Commands/Permission.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Commands/Permission.php b/src/Commands/Permission.php index 8fc5c33..905ce37 100644 --- a/src/Commands/Permission.php +++ b/src/Commands/Permission.php @@ -239,10 +239,8 @@ private function extractNamespace($file) $handle = fopen($file, 'r'); if ($handle) { while (($line = fgets($handle)) !== false) { - $line = str($line)->remove('remove('trim(); - if (str_starts_with($line, 'namespace')) { - $parts = explode(' ', $line); - $ns = rtrim(trim($parts[1]), ';'); + if (preg_match('/^namespace\s+([a-zA-Z0-9\\_]+);/', $line, $matches)) { + $namespace = $matches[1]; break; } }