Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misclassification of PHP syntax tokens #210

Open
ghost opened this issue Jul 13, 2023 · 3 comments
Open

Misclassification of PHP syntax tokens #210

ghost opened this issue Jul 13, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 13, 2023

Type: Bug

VSCode assigns the wrong TextMate scope to several built-in PHP functions. The following functions are classified as entity.name.function.php instead of their corresponding support.function scope.

hrtime(); //should be support.function.datetime.php
stream_context_set_options(); //should be support.function.streamsfuncs.php
mysqli_connect_error(); //should be support.function.mysqli.php
mysqli_connect_errno(); //should be support.function.mysqli.php
mysqli_affected_rows(); //should be support.function.mysqli.php
mysqli_stmt_error(); //should be support.function.mysqli.php
mysqli_error(); //should be support.function.mysqli.php
mysqli_errno(); //should be support.function.mysqli.php

The issue is that entity.name.function.php means that a function is user defined and might have a different color than support.function.* which is a built-in function. If we indeed use a different color and add similar built-in functions the issue becomes more apparent:

stream_context_set_params(); //correct
stream_context_get_params(); //correct
stream_context_set_options(); //incorrect
stream_context_get_options(); //correct

time(); //correct
microtime(); //correct
hrtime(); //incorrect
sleep(); //correct
usleep(); //correct

mysqli_report(); //correct
mysqli_connect(); //correct
mysqli_query(); //correct
mysqli_fetch_row(); //correct
mysqli_fetch_assoc(); //correct
mysqli_affected_rows(); //incorrect
mysqli_stmt_error(); //incorrect
mysqli_error(); //incorrect
mysqli_errno(); //incorrect
mysqli_stmt_close(); //correct
mysqli_close(); //correct

Screenshot 2023-07-13 at 12 14 09

It seems possible that there are further built-in functions that are misclassified, these are merely the ones that I encountered.

VS Code version: Code 1.80.0 (Universal) (660393deaaa6d1996740ff4880f1bad43768c814, 2023-07-04T13:39:33.766Z)
OS version: Darwin arm64 22.5.0
Modes:

System Info
Item Value
CPUs Apple M2 Pro (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 1, 1, 2
Memory (System) 16.00GB (0.36GB free)
Process Argv --crash-reporter-id 1f82bd8c-3d7a-4311-b217-05e34a61785c
Screen Reader no
VM 0%
Extensions (1)
Extension Author (truncated) Version
vscode-eslint dba 2.4.2

(1 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263cf:30784848
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
282f8724:30602487
pyind779:30671433
f6dab269:30613381
pythonsymbol12:30671437
showlangstatbar:30737416
vsctsb:30748421
pythonms35:30701012
03d35959:30757346
57b77579:30736110
pythonfmttext:30731395
pythoncmvfstrcf:30756944
fixshowwlkth:30771522
showindicator:30785052
pythongtdpath:30769146
i26e3531:30780429
pythonnosmt12:30779714
pythonidxpt:30784022
pythonnocebcf:30776496
e537b577:30786199

@RedCMD
Copy link

RedCMD commented Jul 13, 2023

sadly the PHP repo has been archived
https://github.com/atom/language-php

@ghost
Copy link
Author

ghost commented Jul 13, 2023

I am not sure I understand what you mean by that. Isn't Atom supposed to be a different code editor than VSCode? Is VSCode using this archived repo to recognize tokens in PHP files? Does this mean that from now on VSCode will not be able to correctly recognize PHP syntax tokens?

@jeff-hykin
Copy link

jeff-hykin commented Jul 13, 2023

Is VSCode using this archived repo to recognize tokens in PHP files?

Precisely haha

now on VSCode will not be able to correctly recognize PHP syntax tokens?

No, since that implies it used to be able to correctly recognize PHP syntax tokens. But also you can get extensions that override the grammar, and you can revive the archived repo by making your own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants