DEVSENSE / phptools-docs

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

Invalid "use of unknown class" (PHP0413) errors #722

Closed tanzanite777 closed 1 week ago

tanzanite777 commented 1 week ago

Type: Bug

Issue has been present for quite a while, but i mostly just ignored it - might be something with my settup, but i got nowhere while investigating. Managed to create a minimal reproduction - that at least always exhibits the problem on my system. Here goes ...

Make a new folder and add two files - index.php and composer.json.

<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;

require 'foo/bar/autoload.php';

$chk = new PHPMailer(true); // Use of unknown class: 'PHPMailer\PHPMailer\PHPMailer' PHP(PHP0413)
$chk->SMTPDebug = SMTP::DEBUG_LOWLEVEL; // Use of unknown class: 'PHPMailer\PHPMailer\SMTP' PHP(PHP0413)
$chk->isSMTP();
{
    "config": {
        "vendor-dir": "foo/bar/"
    },
    "require": {
        "phpmailer/phpmailer": "^6.9.2"
    }
}

Then do the usual "composer update" and then create a new workspace for this folder.

Open index.php - and it cannot find any of the PHPMailer classes. Opening the relevant PHPMailer class will cause it to find the class and remove the problems and closing it restores the bogus problems.

VSCode settings of note (user): "php.problems.scope": "all" "php.problems.exclude": { "/foo/bar/" : true } -- just checking, yep, works nothing in "files.exclude"

Noticed nothing interesting in output (PHP Language Server / etc)

... i am out of ideas.

Extension version: 1.53.16338 VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 x 3600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|15.88GB (7.52GB free)| |Process Argv|--crash-reporter-id adf79977-8c83-4303-918e-a7dfc5f31bf1| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 bdiig495:31013172 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 impr_priority:31102340 nativerepl2:31139839 pythonrstrctxt:31112756 cf971741:31144450 iacca1:31171482 notype1:31157159 5fd0e150:31155592 dwcopilot:31170013 stablechunks:31184530 ```
jakubmisek commented 1 week ago

Thank you for reporting that!

The "vendor-dir" configuration breaks it, I'll try to fix this soon.

jakubmisek commented 1 week ago

It's fixed with the latest v1.53.16357 (pre-release), the same issue as https://github.com/DEVSENSE/phptools-docs/issues/684

Full release will be soon.