Microsoft/vscode

Syntax highlighting error in PHP function parameter when string literal contains block comment

Open

#204.065 geöffnet am 2. Feb. 2024

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (10.221 Forks)batch import
bughelp wantedlanguages-basicphp

Repository-Metriken

Stars
 (74.848 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 11h 43m) (1.000 gemergte PRs in 30 T)

Beschreibung

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version:
  • OS Version:
  • Version: 1.86.0 Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937 Date: 2024-01-31T10:29:11.933Z Electron: 27.2.3 ElectronBuildId: 26495564 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Darwin arm64 23.3.0

Steps to Reproduce:

  1. Write valid PHP code with a string literal that contains /*.
  2. Observe that the rest of the code highlighting will be broken until a new string literal containing */ is introduced. See the example below:
<?php

declare(strict_types=1);

$jsCode = '/* <![CDATA[ */ var data = {"a": 1, "b": 2} /* ]]> */;';
$jsCode = str_replace("/* <![CDATA[ */", '', $jsCode);
$jsCode = str_replace("/* ]]> */", '', $jsCode);
var_dump($jsCode);

Refer to line 6 and 7 for the error:

php-code

Contributor Guide