phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

PHP6609 error

Open Infiland opened this issue 1 year ago • 22 comments

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.

Infiland avatar Aug 18 '24 13:08 Infiland

Thank you for reporting that!

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

Wll be fixed!

jakubmisek avatar Aug 18 '24 13:08 jakubmisek

Are you on windows/linux or mac?

jakubmisek avatar Aug 18 '24 13:08 jakubmisek

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.

Infiland avatar Aug 18 '24 13:08 Infiland

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 avatar Aug 18 '24 21:08 jakubmisek

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

jakubmisek avatar Aug 20 '24 11:08 jakubmisek

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

Infiland avatar Aug 20 '24 12:08 Infiland

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 avatar Sep 30 '24 08:09 Jack-Mutsers

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)

Jack-Mutsers avatar Sep 30 '24 08:09 Jack-Mutsers

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

jakubmisek avatar Oct 07 '24 18:10 jakubmisek

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

Jack-Mutsers avatar Oct 07 '24 18:10 Jack-Mutsers

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

jakubmisek avatar Oct 07 '24 18:10 jakubmisek

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

Jack-Mutsers avatar Oct 07 '24 18:10 Jack-Mutsers

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

jakubmisek avatar Oct 07 '24 18:10 jakubmisek

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

jakubmisek avatar Oct 09 '24 14:10 jakubmisek

Is there a way to reset this or some cache I can clear? I tried renaming the file in the finder on MacOS, renaming it in VSCode, quiting VSCode, disabling the extention, then reenabling it, uninstalled/reinstalled, and this syntax highlighting persists through all of this. Screenshot 2024-12-03 at 6 10 32 PM

--edit-- NVM. I deleted the file, restarted VSCode, added the file, and we are set!!

alex-elivate avatar Dec 04 '24 01:12 alex-elivate

@alex-elivate thank you for pointing this out!

I'm aware this is still an issue in some cases; VSCode does not respect the letter casing and we falsely report an error ...

We're working on a fix.

jakubmisek avatar Dec 04 '24 13:12 jakubmisek

Hi, I have the same problem as well. However, mine only occurs when I start with a lowercase file name, delete the file, and then recreate it with an uppercase file name.

env: windows 10

rolland97 avatar Dec 09 '24 04:12 rolland97

@rolland97 I have the exact same problem right now, did you find a fix for this or a workaround?

EnesK311 avatar Dec 16 '24 10:12 EnesK311

Thank you for the steps and for reporting the issue; still working on it. I appreciate any information.

jakubmisek avatar Dec 16 '24 13:12 jakubmisek

@jakubmisek I have the problem on MacOs, I created a controller in Laravel with php artisan make:controller and I accidentally gave it the name Authcontroller instead of AuthController and now I get errors even tho I adjusted it everywhere, deleted the file remade it, renamed it in finders and renamed it in vscode aswell.

EnesK311 avatar Dec 16 '24 14:12 EnesK311

It is caused by (the misbehavior) of the VSCode API

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

We'll need to do some additional workarounds to fix that.

jakubmisek avatar Dec 16 '24 16:12 jakubmisek

We'll (temporarily) disable the case-sensitive check since there are multiple issues with letter casing in file names. Possible workaround would be noticeably inefficient.

This change will be included in the very next update.

jakubmisek avatar Dec 16 '24 17:12 jakubmisek