Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jianjye opened this issue Nov 3, 2021 · 0 comments
Open

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

jianjye opened this issue Nov 3, 2021 · 0 comments

Comments

@jianjye
Copy link

jianjye commented Nov 3, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant