Vscode-intelephense: Errors in VSCode when using MongoDB extension/driver

Created on 17 Apr 2020  路  1Comment  路  Source: bmewburn/vscode-intelephense

Describe the bug
Intelephense keeps telling be I'm using undefined classes when using the MongoDB extension/driver.
I keep getting Undefined type 'MongoDB\Driver\Cursor and Undefined type 'MongoDB\BSON\ObjectId.
Basically, when ever I refer to some object that exists in the extension, it throws those errors in VSCode. The code works though so PHP do have access to them.

To Reproduce
Install and enable the MongoDB extension/driver and do:

var_dump(new \MongoDB\BSON\ObjectId());

Intelephense should tell you that the class ObjectId is undefined but if you run the code, it should dump an object of that type

Expected behavior
Not to tell me it's undefined if it isn't.

Screenshots

Platform and version

  • OS: Ubuntu 18.04
  • Intelephense version: 1.3.11 with valid license*
  • MongoDB extension: 1.7.4 (built through PECL)

Comments
As I understand it, there must be stubs for the extension/driver for Intelephense to know about it. I can also see that there aren't any for the mongodb extension/driver
However, I have no idea how to create those stubs. There probably is a guide somewhere but I can't find it?

It's kind of frustrating having the IDE showing errors that aren't real errors.

Most helpful comment

@magnus-eriksson please add mongodb to intelephense.stubs setting. Names are the same as folders in this repository: https://github.com/JetBrains/phpstorm-stubs

>All comments

@magnus-eriksson please add mongodb to intelephense.stubs setting. Names are the same as folders in this repository: https://github.com/JetBrains/phpstorm-stubs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steven7mwesigwa picture steven7mwesigwa  路  4Comments

zlianon picture zlianon  路  4Comments

zlianon picture zlianon  路  3Comments

umpirsky picture umpirsky  路  4Comments

swashata picture swashata  路  3Comments