Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error
Intelephense 1.3 added undefined type, function, constant, class constant, method, and property diagnostics, where previously in 1.2 there was only undefined variable diagnostics.
Some frameworks are written in a way that provide convenient shortcuts for the user but make it difficult for static analysis engines to discover symbols that are available at runtime.
Stub generators like https://github.com/barryvdh/laravel-ide-helper help fill the gap here and using this with Laravel will take care of many of the false diagnostics by providing concrete definitions of symbols that can be easily discovered.
Still, PHP is a very flexible language and there may be other instances of false undefined symbols depending on how code is written. For this reason, since 1.3.3, intelephense has config options to enable/disable each category of undefined symbol to suit the workspace and coding style.
These options are:intelephense.diagnostics.undefinedTypes
intelephense.diagnostics.undefinedFunctions
intelephense.diagnostics.undefinedConstants
intelephense.diagnostics.undefinedClassConstants
intelephense.diagnostics.undefinedMethods
intelephense.diagnostics.undefinedProperties
intelephense.diagnostics.undefinedVariables
Setting all of these to false except intelephense.diagnostics.undefinedVariables
will give version 1.2 behaviour. See the VSCode settings UI and search for intelephense
.
VSCode PHP Intelephense show error when using Memcached
You can disable the undefined type in intelephense vscode setting. To open the setting you can type ctrl + ,
Visual Studio Code PHP Intelephense gets errors which aren't
Solved by uninstalling and reinstalling Visual Studio Code extensions.
PHP : VS code + Intelephense detect an error on references passed in foreach (and in functions)
That was not a problem Intelephense, but with PHP IntelliSense :
https://github.com/felixfbecker/vscode-php-intellisense
Disabling it remove the errors i had.
I did not post an issue on intellisense Github.
Visual studio code keep showing unecesarry error
The Auth::user()
return type is not the User
model instance. And that's why it's shown as error. You can use comment to define the variable as an instance of the User
model like,
/** @var User $ketua */
$ketua = Auth::user();
VSCode show error after use PHP Intelephense
You are using the $_POST in a wrong way.
The Intelephense think that $_POST should always use like this:
$_POST['something']
Related Topics
PHP Glob - Scan in Subfolders For a File
How to Get JavaScript Function Data into a PHP Variable
Best Way to Completely Destroy a Session - Even If the Browser Is Not Closed
Preserve Key Order (Stable Sort) When Sorting With PHP'S Uasort
Import CSV File Directly into MySQL
PHP Is Confused When Adding and Concatenating
How to Access Dynamic Variable Names in Twig
Initializing PHP Class Property Declarations With Simple Expressions Yields Syntax Error
Access Controller Method from Another Controller in Laravel 5
PHP Curl Not Working - Wamp on Windows 7 64 Bit
How to Read Last Lines (I.E. "Tail") from a File Using PHP
Read Each Line of Txt File to New Array Element
Convert Timestamp to Readable Date/Time PHP