sublimelsp / LSP-intelephense

PHP support for Sublime's LSP plugin provided through intelephense.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Template format

pacoVela opened this issue · comments

Using LSP-json I obtain a default template for function phpdoc:

    "intelephense.phpdoc.functionTemplate": {
          "summary": "${1:$SYMBOL_NAME}",
	         "tags": [
		        "@param ${1:$SYMBOL_TYPE} $SYMBOL_NAME $2",
			"@return ${1:$SYMBOL_TYPE} $2",
			"@throws ${1:$SYMBOL_TYPE} $2"
		]
	}

But I obtain this:

    /**
     * @param   
     * @return  
     */
    private function getPagePoolFeaturesAsArrayOfSlugs(array $page)

I've tried both "text" and "snippet" in the "intelephense.phpdoc.textFormat" option.

But if i delete my config it works like that:

    /**
     * @param array $page 
     * @return array 
     */
    private function getPagePoolFeaturesAsArrayOfSlugs(array $page)

So I think that the problem is the format of the template. How could I get the correct format to use?

That's what is listed in the server's doc... https://github.com/bmewburn/vscode-intelephense/blob/dbb22977f6c1804a87291999e6d3d0eba18acd15/package.json#L763-L792

Doesn't seem to work indeed. Since the server is not open source, I guess you can only ask the author on https://github.com/bmewburn/vscode-intelephense/issues


My Personal Taste

Just to share, I prefer using https://packagecontrol.io/packages/DoxyDoxygen for generating doc strings for various languages. It works well for PHP too. And I don't really care about those whitespaces in the docstring since eventually they will be normalized by php-cs-fixer.

I haven't coded in PHP for a while though.

I wonder if it's a matter of having to escape the dollar signs.

I wonder if it's a matter of having to escape the dollar signs.

I can confirm escaping $ works.

"intelephense.phpdoc.functionTemplate": {
    "summary": "\\${1:\\$SYMBOL_NAME}",
    "tags": [
        "@param \\${1:\\$SYMBOL_TYPE} \\$SYMBOL_NAME \\$2",
        "@return \\${1:\\$SYMBOL_TYPE} \\$2",
        "@throws \\${1:\\$SYMBOL_TYPE} \\$2"
    ]
},

Probably they are replaced with empty string by LSP before sending to the server. This is because LSP uses the same way to interpret variables ($variable notation).

Thank you, it works!

We should update the package schema so that the default example is properly escaped.