Hi everyone,

I'm encountering an issue which seems to be problem with recognition of WordPress methods when I work on files via FTP. My setup works just fine locally, however this problem occurs when I use the FTP Simple VSCode extension, and interestingly, it persists even when connecting via FTP without this extension. Additionally, I use CodeSniffer, which functions without any issues.

My setup is as follows:

  • VS Code version: 1.84.2
  • PHP DEVSENSE plugin: v1.41.14263
  • Ubuntu 22.04 LTS

I would greatly appreciate any guidance or suggestions to help resolve this issue. Thank you in advance!

    JJdv Hi, and thank you for the issue.

    The editor (PHP extension) does not see the files on the remote file system (FTP). It would have to download the entire folder from FTP to know what's there.

    The workaround, for now, would be:

    In the future, we'll include wordpress stubs by default, and recognize them in the editor.

    Thank you for the answer, wordpress stubs helped me with fixing the issue :)

    JJdv awesome, thank you for the update.

    We'll try to make this more straightforward in future updates!

      11 days later

      JakubMisek
      Thank you ! Those squiggly lines under every WP function were driving me crazy,
      I didnt want to ignore the problem like your 1st recommendation, and I i didnt want to open entire wp directory like your 2nd a.) suggestion so I went ahead and downlaoded and opened the single wp-stubs.php file.

      But I d really like if the stubs were included in the near future. Or make it opitonal like intelephense does: https://stackoverflow.com/a/65275602

        13 days later

        JakubMisek
        Glad to see its added already. I have another issue but didnt wanna create a new topic for it.
        The extension also throws some false-positives for some known functions like json_decode or preg_match

          SergeyAntonov I think the problem would be the "php.stubs" setting. It needs to contain all the standard stubs as well (which is shortneed for "*"):

              "php.stubs": [
                  "*",
                  "wordpress"
              ]

          More details can be found in the recent blog post: https://blog.devsense.com/2023/wordpress-intellisense-linting-vscode#heading-2

            23 days later

            Thank you for your reply, but the error is still there after adding * to php.stubs and I think I have selected every available stub in intelephnese.stubs
            You can see below that another intellisense extension is detecting preg_match, json_decode etc, but intelephense is not.



            semi OT: may I also suggest woocommerce stubs to be added ? One available here : https://github.com/php-stubs/woocommerce-stubs

              This can only be caused by a wrong "php.stubs" setting - have you checked both User and Workspace settings?

              You can try "Workspace Stubs" command (F1 (Command Pallete) -> PHP: Workspace Stubs -> Check there is pcre enabled):

                6 days later

                Thanks that worked. How about adding WooCommerce stubs for the future ? is it too much ?

                The pcre was not checked, only wordpress was checked. So my guess is the "*" was not selecting all. So I selected everything from the select all checkbox
                https://imgur.com/a/AJe0tNq

                  SergeyAntonov It looks like you may have another settings.json (in the workspace folder?).

                  The "*" should work. Also, you can just delete your "php.stubs" setting (make sure to delete it in both User and Workspace settings) and then add wordpress through the checkbox.

                  SergeyAntonov Good idea, adding WooCommerce to our to-do list.

                    Write a Reply...