DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
84 stars 10 forks source link

PHP6609 error #635

Open Infiland opened 3 months ago

Infiland commented 3 months ago

There is an error that occurs in the extension where it reports that the class name should be lowercase, or the filename should be the same as the class. Using PHP 8.3

However, it still throws this error in the vscode IDE.

image

Autoload is defined in index.php

image

This is the composer.json file which autoloads all classes in the Src folder

image

Running index.php doesn't print any errors or exception in the browser or console. This exception seems to only appear in vscode, but only if the PHP extension is enabled.

jakubmisek commented 3 months ago

Thank you for reporting that!

It seems we got the letter casing wrong, and hence we misreport the problem.

Wll be fixed!

jakubmisek commented 3 months ago

Are you on windows/linux or mac?

Infiland commented 3 months ago

Are you on windows/linux or mac?

I am on Windows, I can list my PC Specs but I am not sure if it's relevant.

jakubmisek commented 3 months ago

For me: there are a few related issues with VSCode and LSP implementation:

https://github.com/microsoft/language-server-protocol/issues/1263 https://github.com/microsoft/vscode/issues/137256

jakubmisek commented 3 months ago

so far of what we've tested, the issue should be fixed in the upcoming update.

Infiland commented 3 months ago

so far of what we've tested, the issue should be fixed in the upcoming update.

Great! I will let you know if the issue is resolved in the next update

Jack-Mutsers commented 2 months ago

From what I could see the last update was 3 days ago, but I'm still having this problem where the filename is the exact same as the class name and if I copy the file over to another folder (from /libraries to /models for example) then there are no problems, is this a caching issue where it remembers an old version or something with the lowercase filename?

P.S. personally, I am using VSCode on MacOs, and i have verified that both the terminal and the MacOs file system also see the filename with the uppercase as it should be.

Jack-Mutsers commented 2 months ago
image

these 2 files are an exact copy of one another, but only one gives me the error: Class name Optimizer does not match PSR autoload pattern. It is expected to be optimizer, or the file name should be Optimizer.php. PHP(PHP6609)

jakubmisek commented 1 month ago

Thank you for the update; we couldn't repro the issue after the update, yet. Are there any particular steps to reproduce the issue?

Jack-Mutsers commented 1 month ago

What I did was, I copied the file from one project to another, after which I changed the filename to match the capitalisation but it would not stop giving me this error as if its looking at the original filename when it was copied over instead of the current renamed filename.

Even if its committed and everything it still remembers to give the error that i cannot get rid of without completely changing the filename which i don't understand, and as i pointed out earlier if I copy the file with the new filename to another folder then there are no issues.

Also if I delete the file and create it again in the same folder with the same name but with an empty class then it will also give me the error, that is why i was wondering if its a cache thing that is stored in git or something for that folder

jakubmisek commented 1 month ago

@Jack-Mutsers have you renamed it using VSCode Explorer or using the MacOs Finder?

Jack-Mutsers commented 1 month ago

VS studio, but it was changed on mac os and terminal as well when i went to check

jakubmisek commented 1 month ago

Right, it just seems that our extension does not get the event about the change. We'll try that on MacOs

jakubmisek commented 1 month ago

After digging through the issue, we found several related problems in VSCode itself — it simply does not respect the letter casing after the rename. Therefore the extension (our extension) is not getting the correct information. It also uses incorrect letter casing right after opening the workspace.

I'm trying to work around it ... Meanwhile, I'll report the other issues to MS.

Related issue: https://github.com/microsoft/vscode-languageserver-node/issues/1186