Questions tagged [intelephense]

This tag should be used to discuss the PHP static code analysis and language tools provided by the Intelephense vscode plugin, including questions related to improving its effectiveness or correcting issues related to its installation, configuration, or potential bugs and shortcomings.

Intelephense is a high performance PHP language server packed full of essential features for productive PHP development. It provides PHP code intelligence for the Visual Studio Code editor.

78 questions
4
votes
1 answer

How can I declare that a constant is defined in PhpDoc (for intelephense)?

TL;DR How can I document a constant that is defined in external code using PhpDoc/DocBlocks so that it will not show up as an undefined variable in static code analysis? Details: I'm trying to write a small WordPress plugin. I have some PHP code…
drwatsoncode
  • 4,721
  • 1
  • 31
  • 45
3
votes
0 answers

PHP Intelephense 'undefined method' issues

I recently switched to an IDE that supports PHP's Intelephense. There are two issues showing up that I don't know how to resolve (note, however, that the code executes correctly). #1. Undefined method 'myfunc' $myobj =…
Merricat
  • 2,583
  • 1
  • 19
  • 27
3
votes
0 answers

Visual Studio Code PHP Intelephense not hilight probably unset variables

Visual Studio Code PHP Intelephense not hilight probably unset varuables. How enable hilight probably unset varuables? PhpStorm do it. Code: foreach ($paymentCollection as $payment) { if (!$payment->isInner() &&…
3
votes
2 answers

Laravel 8: undefined method 'createToken' intelephense(1013)

I have a problem with PHP intelephense, the method createToken is undefined. i don't know how to fix it. but when I run it in postman it works. i don't know why vscode doesnt recognize it. i also add the use Laravel\Passport\HasApiTokens; and use…
3
votes
1 answer

VSCode extension Intelephense gives error "Undefined method 'xxx'. Intelephense (1013)" with polymorphism and dynamic binding

I'm developing a PHP (v7.0.33) project using VScode (v1.56). I recently installed the VSCode's extension Intelephense (v1.7.1) and started to clean my code following Intelephense suggestions. A set of classes inside my project has the following…
Ma3x
  • 516
  • 6
  • 19
3
votes
1 answer

How to define an undefined function in intelephense (in VSCode)?

Intelephense show error like "unknown type" and "unknown function", but I have no clue how to fix them. My project (a TYPO3 composer installation) has a "public" folder, which is, why I configured intelephense's intelephense.environment.documentRoot…
Robert Wildling
  • 1,014
  • 12
  • 29
3
votes
2 answers

Go To Definition for PHP extensions in VSCode

When I use Composer 'Go To Definition' works well. But it doesn't work for PHP core extensions like MySQLi. Ubuntu is my OS and I have searched for PHP files for those libraries and only find their .so files, maybe that's why I can't 'Go To…
2
votes
2 answers

Undefined method 'hasRole'.intelephense(1013)

if (auth()->check() && (auth()->user()->hasRole('Admin'))) { $people = Person::latest()->paginate(5); } else { $people = Person::where('user_id', $user->id)->latest()->paginate(5); } My editor code analysis tool is not able to detect the…
Mario
  • 21
  • 3
2
votes
0 answers

vscode + PHP intelephense named arguments from PHP 8.1 shown as errors

In code written in PHP8.1 I use named arguments in a method call: // function definition public function myFunction(string $name, string $description = "") // method call with errors ->myFunction(name: self::SOME_CONSTANT) however extension PHP…
jave.web
  • 13,880
  • 12
  • 91
  • 125
2
votes
0 answers

VSCode PHP format indentation using Intelephense

I'm currently using php intelephense (free) extension to vscode in order to format php sources. I run in the following 'strange' behaviour, could someone explain why and how to correct it? The last
Christian
  • 685
  • 1
  • 5
  • 13
2
votes
1 answer

vscode php development setup php intelephense and phpcs

I want to setup my development environment using vscode. However, I am confused on that would be the difference between intelephense and phpcs. I have the code in Github from my company and it has the .phpcs.xml.dist. I believe this file is for…
2
votes
0 answers

VS Code PHP Intelephense Extension Wrong Suggestion Path

I use vscode as my editor and php intelephense as my php formatter. It works well, but when I want to use relative file path For example : but my php intelephense always suggest me document root, so i…
Heinz
  • 21
  • 3
2
votes
1 answer

Undefined Type on Namespace using Intellisense

I got undefined type on my project when addressing classes autoloaded with composer json. this is the extract of my composer.json file "autoload": { "psr-4": { "App\\": "app/", "Shared\\": "../Shared/" }, "classmap": [ …
Emanuele
  • 21
  • 2
2
votes
1 answer

PHP Intelephense - Method is not compatible with child method

Consider the following two classes: class A { ... testMethod($param = null) { ... } } class B extends A { ... testMethod($additionalParam, $param = null) { ... do something with $additionalParam ... …
Adam Baranyai
  • 3,635
  • 3
  • 29
  • 68
1
vote
0 answers

PHP: Redis::subscribe hover has wrong information

Setup PHP 8.2 Redis 5.3.7 VSCode 1.79.0 Intelephense 1.9.5 Problem When using Redis::subscribe I get an error, because according to the hover subscribe only takes strings as parameters. But it should be (array, callable). Not sure where the root…