devang_281999
devang_281999

Reputation: 65

Getting error that actually not an error in vscode while using intelephense

Getting unexpected error (Expected 1 arguments. Found 0) in vscode while using intelephense extension. When I uninstall the intelephense extesion from vscode at that time this error not showing but i dont want to uninstall the extension. how can i solve this issue??

enter image description here

Error starts showing when i write __construct method in (2.php) file.

enter image description here

Error:

enter image description here

Upvotes: 0

Views: 950

Answers (1)

JORDANO
JORDANO

Reputation: 724

Use namespaces as Brombeer suggests in the comment he made to your question, he deserves credit for this.

I define it based off of the class that the file contains, so I have a class named Animal, and keep the namespace within the Animal class:

<?php

namespace Animal;

class Animal ...

The error exists because the IDE thinks the class you're extending exists as it's using the global namespace

why it's in the global namespace: https://www.php.net/manual/en/language.namespaces.global.php

namespaces: https://www.php.net/manual/en/language.namespaces.definition.php

edit: forgetting to add code blocks to comment...

Upvotes: 0

Related Questions