Describe the bug
After programming for a few minutes, intelephense thinks that there are all kinds of syntax errors. I'm programming in a Laravel project on VS Code version 1.41.1 (Windows) and the actual files, PHP and the webserver are on a remote system (see: https://code.visualstudio.com/docs/remote/ssh)
The issue also appears on my Linux (Manjaro) laptop. These issues starded about one day ago. I also had the same issue as GitHub issue #942. Laravel uses some Symfony packages, so these two issues might be related.
When I close the class and re-open it, the issues are gone, until I start making changes again.
To Reproduce
Screenshots
-- Example one --
Error: https://cdnsilver.ownshot.eu/file/ownshot-cdn/screenshots/7DGpMcVZStIAb9fZCd8U/hXWXYkGk98.png
private function calculateWidgetSignature($params, $secret)
{
$signVersion = $params['sign_version'];
unset($params['sig']);
ksort($params);
$baseString = '';
foreach ($params as $key => $value) {
$baseString .= $key . '=' . $value;
}
$baseString .= $secret;
if ($signVersion === 2) {
return md5($baseString);
} elseif ($signVersion === 3) {
return hash('sha256', $baseString);
}
return null;
}
-- Example Two --
Says it returns void; https://cdnsilver.ownshot.eu/file/ownshot-cdn/screenshots/7DGpMcVZStIAb9fZCd8U/VT4MOR9bBM.png
It does not, it's an array: https://cdnsilver.ownshot.eu/file/ownshot-cdn/screenshots/7DGpMcVZStIAb9fZCd8U/Jjdp91XM8A.png
public function processPaymentMethodOverrides(array $data): array
{
$overrides = $this->paymentMethodOverrides;
foreach ($overrides as $key => $override) {
$data[$key] = $override;
}
return $data;
}
It also thinks that both $data and $overrides are unused.
-- Example Three --
Error: https://cdnsilver.ownshot.eu/file/ownshot-cdn/screenshots/7DGpMcVZStIAb9fZCd8U/6vGZCTsJix.png
/**
* @var GatewayCredentialMapper
*/
protected $gatewayCredentialsMapper;
public function __construct(GatewayCredentialMapper $gatewayCredentialsMapper)
{
$this->gatewayCredentialsMapper = $gatewayCredentialsMapper;
}
Platform and version
Windows 10 / Manjaro Linux
VS Code version 1.41.1
Intelephense version 1.3.7 (also tested on 1.3.6, same issue)
Thanks in advance, and thanks for the great extension! It saves a lot of time.
This looks the same #939 . It seems as though the intelephense version of the document gets out of sync with the vscode version and misses or wrongly applies edits.
Unfortunately I haven't been able to reproduce this yet. Would you be able to share your extension list here and settings?
Sure thing, I have these installed at this moment;
Extensions (remote):
Extensions (local)
Settings.json
{
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"workbench.startupEditor": "newUntitledFile",
"git.autofetch": true,
"git.enableSmartCommit": true,
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"extensions.ignoreRecommendations": false,
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"extensions.autoUpdate": false,
}
Thanks, there was a comment on the other thread about vscode-blade-spacer. Does disabling this improve things at all?
Disabeling that extension seems to resolve the issue for me. And when I re-enable it, the issue is back.
As I can switch between the working and "broken" senario; Do you need extra information or logs, if so, how can I enable and share these?
A magic fix that only works for some, and that is not reproducable is the worst kind of fix.
When I downgrade blade spacer (https://github.com/austenc/vscode-blade-spacer/commits/master) to v1 instead of v2 (released when I started having the issue) the problem is solved as well.
If you could enable the broken scenario and switch intelephense.trace.server to verbose in settings, then start coding you should see a bunch of edits being sent to the server in the output tab. If you could post the before and after code and the output tab edits in between then that may help figure out exactly what's happening. There could be a lot of data, but just need enough to see the first false error show.
When opening the file: https://hastebin.com/rofihapenu.bash
When editing: https://hastebin.com/raguvarumi.bash
Start
<?php
namespace App\Http\Controllers;
class TestController
{
protected $test;
public function __construct($test)
{
$this->test = $test;
}
}
Changed it to;
<?php
namespace App\Http\Controllers;
class TestController
{
protected $test;
public function __construct(string $test, string $test2)
{
$this->test = $test;
}
}
Nothing went wrong, but when I hit undo, it "broke". I can e-mail the full "after" log if you'd need it, it was too big for hastebin.
If I could get the undo log that would be great
I've e-mailed the full log. I can also re-produce the issue on my local VS Code (not remote) on Windows.
Thanks, I've opened https://github.com/microsoft/vscode/issues/88310 as I think it's due to blade spacer reversing order of text document changes and causing other extension's documents to get out of sync.
I don't think it's a bug in intelephense but will keep this open for now.
I was having the same issue and can confirm that disabling Blade Spacer fixed it.
I was having the same issue and can confirm that disabling Laravel Blade Spacer fixed it.
I can confirm that downgrading Laravel Blade Spacer to version 1.* solves issue.
Also I posted this issue to Laravel Blade Spacer repo.
https://github.com/austenc/vscode-blade-spacer/issues/8
Yikes! Sorry everyone -- I'll get this fixed ASAP. @bmewburn if you've got any ideas I would love to hear them. Thanks :)
@austenc vscode team has fixed it in next version
Released an update for austenc/vscode-blade-spacer that should fix the problem in the interim also. Sorry to everyone for the headache!
Thanks @austenc
Closing, fixed in vscode and vscode-blade-spacer
Most helpful comment
Released an update for austenc/vscode-blade-spacer that should fix the problem in the interim also. Sorry to everyone for the headache!