vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Incorrect highlighting of errors in the source code.

Open SilkeKohl opened this issue 1 year ago • 5 comments

Describe the bug It highlights errors where there are none; in the previous version 1.9.5, everything worked correctly. In the screenshot, a snippet of code for a project created using CodeIgniter 4 is visible.

To Reproduce Update to version v1.10.0.

Expected behavior Not highlighting errors in the source code where there are none.

Screenshots Screenshot_20231110_001347

Platform and version Manjaro Linux VS Code: 1.84.1 PHP Intelefense: v1.10.0

SilkeKohl avatar Nov 09 '23 23:11 SilkeKohl

<?php

class MyObject {
    public $arr = [];
}

function getMyObject(): MyObject {
    return new MyObject();
}

in_array('foo', getMyObject()->arr);

I tried above code, which should be equivalent to what your code is meant to do and no errors. Are you sure your code is actually working as intended? What is the actual highlighted error?

MarioKool avatar Nov 10 '23 16:11 MarioKool

Here an example, based on the CodeIgniter4 documentation: Screenshot_20231110_184017PHP Intelefense: v1.10.0

The above source code will execute correctly and display the default value (20), but PHP Intelephense indicates an error.

The same code in PHP Intelefense: 1.9.5: Screenshot_20231110_184017PHP Intelefense: v1.9.5

SilkeKohl avatar Nov 10 '23 17:11 SilkeKohl

I saw that this bug had been reported and hoped to have it fixed in an upcoming update. Unfortunately, it has not been fixed in the version: 1.10.1. Please fix it.

Maxomeister avatar Nov 13 '23 03:11 Maxomeister

I have the same problem

mullernato avatar Dec 14 '23 05:12 mullernato

same issue, nodebody using codeigniter anymore

p3x-robot avatar Apr 17 '24 17:04 p3x-robot

Please see https://github.com/bmewburn/vscode-intelephense/issues/1063#issuecomment-2199189736 for an example on how you could add a stub function to make the extension return the correct type from the config call based on the argument passed.

bmewburn avatar Jul 06 '24 00:07 bmewburn