bmewburn / intelephense-docs

Documentation for the Intelephense PHP language server
https://intelephense.com
Other
184 stars 17 forks source link

PHP 8 "match" Errors in Sublime Text 4 #47

Open jianjye opened 2 years ago

jianjye commented 2 years ago

Hi, in my Sublime Text 4 Intelephense seems to be throwing errors on all my match codes even though they work perfectly fine.

Here's a working snippet from a Laravel project:

line 80:        return match($this->investorable_type) {
line 81:            'App\Models\Person' => "/people/{$this->id}",
line 82:            'App\Models\Organization' => "/companies/{$this->id}",
line 83:        };

And I would get these errors despite the fully functional codes:

80:16  info    Array or string offset access with curly braces deprecated in PHP 7.4. Targeting PHP 8.0.10. ​
80:16  error   Undefined function 'App\Models\match'. ​intelephense:1010intelephense:1034
81:32  error   Unexpected '=>'. Expected '}'. ​intelephense:1001
81:57  error   Unexpected ','. ​intelephense:1001
82:43  error   Unexpected 'EncapsulatedAndWhitespace'. Expected ';'. ​intelephense:1001
82:65  error   Unexpected '"'. ​intelephense:1001

Are there any settings that I may be missing that could be causing match to be flagged as errors?

Here's a copy of my LSP-intelephense.sublime-settings:

// Settings in here override those in "LSP-json/LSP-json.sublime-settings"

{
    "enabled": true,
    "command": [
        "intelephense",
        "--stdio",
    ],
    "scopes": ["source.php", "embedding.php"],
    "syntaxes": ["Packages/PHP/PHP.sublime-syntax"],
    "languageId": "php",
    "initializationOptions": {
        "clearCache": true,
        "licenceKey": "xxxxx",
    },
    "settings": {
        "intelephense":
        {
            "environment":
            {
                "phpVersion": "8.0.10"
            },
            "diagnostics":
            {
                "undefinedTypes": false,
                // "undefinedConstants": false,
                // "undefinedFunctions": false,
                // "undefinedSymbols": false
            },
            "files":
            {
                "associations": [
                    "*.php",
                    "*.phtml",
                    "*.inc"
                ],
                "exclude": [
                    "**/.git/**",
                    "**/.svn/**",
                    "**/.hg/**",
                    "**/CVS/**",
                    "**/.DS_Store/**",
                    "**/node_modules/**",
                    "**/bower_components/**",
                    "**/vendor/**/{Tests,tests}/**",
                    "/var/**",
                    "/framework/**",
                     "**/vendor/**/{Example,example,Examples,examples}/**"
                ]
            },
            "trace":
            {
                "server": "off"
            }
        }
    },
}

Thanks.