Skip to content

[Bug]: Whoops\Exception\ErrorException #64

Open
@htisoares

Description

@htisoares

Extension Version

0.1.11

PHP Binary

Herd

Operating System

Linux

What happened?

Hello, I'm using herd lite on Linux with PHP 8.4.
The extension doesn't start and gives the following error:

2024-12-17 09:51:57.993 [info] Started
2024-12-17 09:51:58.448 [error] Error:
 Translation namespaces


Deprecated: vscodeCollectTranslations(): Implicitly marking parameter $namespace as nullable is deprecated, the explicit nullable type must be used instead in Command line code on line 27

Deprecated: ArchTech\Enums\Options::stringOptions(): Implicitly marking parameter $callback as nullable is deprecated, the explicit nullable type must be used instead in /home/soares/webmail/vendor/archtechx/enums/src/Options.php on line 26
__VSCODE_LARAVEL_START_OUTPUT__
   Symfony\Component\ErrorHandler\Error\FatalError 

  Uncaught Error: Undefined constant "GLOB_BRACE" in Command line code:27
Stack trace:
#0 Command line code(27): vscodeCollectTranslations('/home/soares/we...')
#1 [internal function]: {closure:Command line code:27}('/home/soares/we...', 0)
#2 /home/soares/webmail/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(609): array_map(Object(Closure), Array, Array)
#3 /home/soares/webmail/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(795): Illuminate\Support\Arr::map(Array, Object(Closure))
#4 /home/soares/webmail/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(429): Illuminate\Support\Collection->map(Object(Closure))
#5 Command line code(27): Illuminate\Support\Collection->flatMap(Object(Closure))
#6 {main}
  thrown

  at Command line code:27



   Whoops\Exception\ErrorException 

  Uncaught Error: Undefined constant "GLOB_BRACE" in Command line code:27
Stack trace:
#0 Command line code(27): vscodeCollectTranslations('/home/soares/we...')
#1 [internal function]: {closure:Command line code:27}('/home/soares/we...', 0)
#2 /home/soares/webmail/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(609): array_map(Object(Closure), Array, Array)
#3 /home/soares/webmail/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(795): Illuminate\Support\Arr::map(Array, Object(Closure))
#4 /home/soares/webmail/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(429): Illuminate\Support\Collection->map(Object(Closure))
#5 Command line code(27): Illuminate\Support\Collection->flatMap(Object(Closure))
#6 {main}
  thrown

  at Command line code:27

   Whoops\Exception\ErrorException 

  file_get_contents(Command line code): Failed to open stream: No such file or directory

  at vendor/filp/whoops/src/Whoops/Exception/Frame.php:120
    116▕                 return null;
    117▕             }
    118▕ 
    119▕             try {
  ➜ 120▕                 $this->fileContentsCache = file_get_contents($filePath);
    121▕             } catch (ErrorException $exception) {
    122▕                 // Internal file paths of PHP extensions cannot be opened
    123▕             }
    124▕         }

      �[2m+7 vendor frames �[22m

  8   [internal]:0
      Whoops\Run::handleShutdown()



      �[2m+1 vendor frames �[22m

  2   [internal]:0
      Whoops\Run::handleShutdown()


2024-12-17 09:51:58.448 [error] /home/soares/.config/herd-lite/bin/php -r "
define('LARAVEL_START', microtime(true));

require_once '/home/soares/webmail/vendor/autoload.php';
\$app = require_once '/home/soares/webmail/bootstrap/app.php';

class VsCodeLaravel extends \Illuminate\Support\ServiceProvider
{
    public function register()
    {
        //
    }

    public function boot()
    {
        if (method_exists(\$this->app['log'], 'setHandlers')) {
            \$this->app['log']->setHandlers([new \Monolog\Handler\ProcessHandler()]);
        }
    }
}

\$app->register(new VsCodeLaravel(\$app));
\$kernel = \$app->make(Illuminate\Contracts\Console\Kernel::class);
\$kernel->bootstrap();

echo '__VSCODE_LARAVEL_START_OUTPUT__';
 function vsCodeTranslationValue(\$key, \$value, \$file, \$lines): array {     \$lineNumber = 1;     \$keys = explode('.', \$key);     \$index = 0;     \$currentKey = array_shift(\$keys);      while (\$currentKey !== null && \$index < count(\$lines)) {         \$line = \$lines[\$index][1];          if (strpos(\$line, '\"' . \$currentKey . '\"', 0) !== false || strpos(\$line, \"'\" . \$currentKey . \"'\", 0) !== false) {             \$lineNumber = \$lines[\$index][0];             \$currentKey = array_shift(\$keys);         }          \$index++;     }      return [         'value' => \$value,         'path' => realpath(\$file),         'line' => \$lineNumber,         'params' => preg_match_all('/\:([A-Za-z0-9_]+)/', \$value, \$matches) ? \$matches[1] : [],     ]; }  function vscodeCollectTranslations(string \$path, string \$namespace = null) {     return collect(glob(\"{\$path}/**/*.{php,json}\", GLOB_BRACE))->map(function (\$file) use (\$path, \$namespace) {         \$key = pathinfo(\$file, PATHINFO_FILENAME);          if (\$namespace) {             \$key = \"{\$namespace}::{\$key}\";         }          \$lang = collect(explode('/', str_replace(\$path, '', \$file)))->filter()->first();          \$fileLines = explode(PHP_EOL, file_get_contents(\$file));         \$lines = [];         \$inComment = false;          foreach (\$fileLines as \$index => \$line) {             \$trimmed = trim(\$line);              if (substr(\$trimmed, 0, 2) === '/*') {                 \$inComment = true;                 continue;             }              if (\$inComment) {                 if (substr(\$trimmed, -2) !== '*/') {                     continue;                 }                  \$inComment = false;             }              if (substr(\$trimmed, 0, 2) === '//') {                 continue;             }              \$lines[] = [\$index + 1, \$trimmed];         }          return [             'key' => \$key,             'lang' => \$lang,             'values' => collect(\Illuminate\Support\Arr::dot(__(\$key, [], \$lang)))->map(function (\$value, \$key) use (\$file, \$lines) {                 if (is_array(\$value)) {                     return null;                 }                  return vsCodeTranslationValue(\$key, \$value, \$file, \$lines);             })->filter(),         ];     }); }  \$loader = app(\"translator\")->getLoader(); \$namespaces = \$loader->namespaces();  \$reflection = new ReflectionClass(\$loader); \$property = \$reflection->hasProperty(\"paths\")   ? \$reflection->getProperty(\"paths\")   : \$reflection->getProperty(\"path\"); \$property->setAccessible(true);  \$paths = \Illuminate\Support\Arr::wrap(\$property->getValue(\$loader));  \$default = collect(\$paths)->flatMap(function (\$path) {   return vscodeCollectTranslations(\$path); });  \$namespaced = collect(\$namespaces)->flatMap(function (\$path, \$namespace) {     return vscodeCollectTranslations(\$path, \$namespace); });  \$final = [];  foreach (\$default->merge(\$namespaced) as \$value) {     foreach (\$value['values'] as \$key => \$v) {         \$dotKey = \"{\$value['key']}.{\$key}\";          if (!isset(\$final[\$dotKey])) {             \$final[\$dotKey] = [];         }          \$final[\$dotKey][\$value['lang']] = \$v;          if (\$value['lang'] === \Illuminate\Support\Facades\App::currentLocale()) {             \$final[\$dotKey]['default'] = \$v;         }     } }  echo json_encode(\$final); ;
echo '__VSCODE_LARAVEL_END_OUTPUT__';

exit(0);
"
2024-12-17 09:51:58.449 [error] 
define('LARAVEL_START', microtime(true));

require_once '/home/soares/webmail/vendor/autoload.php';
$app = require_once '/home/soares/webmail/bootstrap/app.php';

class VsCodeLaravel extends \Illuminate\Support\ServiceProvider
{
    public function register()
    {
        //
    }

    public function boot()
    {
        if (method_exists($this->app['log'], 'setHandlers')) {
            $this->app['log']->setHandlers([new \Monolog\Handler\ProcessHandler()]);
        }
    }
}

$app->register(new VsCodeLaravel($app));
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

echo '__VSCODE_LARAVEL_START_OUTPUT__';
 function vsCodeTranslationValue($key, $value, $file, $lines): array {     $lineNumber = 1;     $keys = explode('.', $key);     $index = 0;     $currentKey = array_shift($keys);      while ($currentKey !== null && $index < count($lines)) {         $line = $lines[$index][1];          if (strpos($line, '"' . $currentKey . '"', 0) !== false || strpos($line, "'" . $currentKey . "'", 0) !== false) {             $lineNumber = $lines[$index][0];             $currentKey = array_shift($keys);         }          $index++;     }      return [         'value' => $value,         'path' => realpath($file),         'line' => $lineNumber,         'params' => preg_match_all('/\:([A-Za-z0-9_]+)/', $value, $matches) ? $matches[1] : [],     ]; }  function vscodeCollectTranslations(string $path, string $namespace = null) {     return collect(glob("{$path}/**/*.{php,json}", GLOB_BRACE))->map(function ($file) use ($path, $namespace) {         $key = pathinfo($file, PATHINFO_FILENAME);          if ($namespace) {             $key = "{$namespace}::{$key}";         }          $lang = collect(explode('/', str_replace($path, '', $file)))->filter()->first();          $fileLines = explode(PHP_EOL, file_get_contents($file));         $lines = [];         $inComment = false;          foreach ($fileLines as $index => $line) {             $trimmed = trim($line);              if (substr($trimmed, 0, 2) === '/*') {                 $inComment = true;                 continue;             }              if ($inComment) {                 if (substr($trimmed, -2) !== '*/') {                     continue;                 }                  $inComment = false;             }              if (substr($trimmed, 0, 2) === '//') {                 continue;             }              $lines[] = [$index + 1, $trimmed];         }          return [             'key' => $key,             'lang' => $lang,             'values' => collect(\Illuminate\Support\Arr::dot(__($key, [], $lang)))->map(function ($value, $key) use ($file, $lines) {                 if (is_array($value)) {                     return null;                 }                  return vsCodeTranslationValue($key, $value, $file, $lines);             })->filter(),         ];     }); }  $loader = app("translator")->getLoader(); $namespaces = $loader->namespaces();  $reflection = new ReflectionClass($loader); $property = $reflection->hasProperty("paths")   ? $reflection->getProperty("paths")   : $reflection->getProperty("path"); $property->setAccessible(true);  $paths = \Illuminate\Support\Arr::wrap($property->getValue($loader));  $default = collect($paths)->flatMap(function ($path) {   return vscodeCollectTranslations($path); });  $namespaced = collect($namespaces)->flatMap(function ($path, $namespace) {     return vscodeCollectTranslations($path, $namespace); });  $final = [];  foreach ($default->merge($namespaced) as $value) {     foreach ($value['values'] as $key => $v) {         $dotKey = "{$value['key']}.{$key}";          if (!isset($final[$dotKey])) {             $final[$dotKey] = [];         }          $final[$dotKey][$value['lang']] = $v;          if ($value['lang'] === \Illuminate\Support\Facades\App::currentLocale()) {             $final[$dotKey]['default'] = $v;         }     } }  echo json_encode($final); ;
echo '__VSCODE_LARAVEL_END_OUTPUT__';

exit(0);

2024-12-17 09:57:52.414 [error] /bin/sh: 1: /home/soares/.vscode-server/data/User/globalStorage/laravel.vscode-laravel/file-downloader-downloads/php-parser-0.1.6: Exec format error

2024-12-17 09:57:58.535 [error] /bin/sh: 1: /home/soares/.vscode-server/data/User/globalStorage/laravel.vscode-laravel/file-downloader-downloads/php-parser-0.1.6: Exec format error```

### Mimimal Code Sample

_No response_

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions