Skip to content

phpDocumentor throws random RuntimeExceptions (TypeResolver failing all the time, Language Server not starting) #753

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

Open
Ciantic opened this issue Sep 20, 2019 · 6 comments

Comments

@Ciantic
Copy link

Ciantic commented Sep 20, 2019

[Error - 20.38.18] Error parsing file:///c:/...: RuntimeException: A type is missing in an array expression in ...\felixfbecker.php-intellisense-2.3.12\vendor\phpdocumentor\type-resolver\src\TypeResolver.php:236
@Ciantic
Copy link
Author

Ciantic commented Sep 23, 2019

Apparently the phpDocumentor throws RuntimeException if there is typo or something in the doc block. Pretty bad but it can be fixed like this:

https://github.com/felixfbecker/php-language-server/blob/master/src/DefinitionResolver.php#L167

                return $this->docBlockFactory->create($docCommentText, $context);
            } catch (\InvalidArgumentException $e) {
                return null;
            }

to

                return $this->docBlockFactory->create($docCommentText, $context);
            } catch (\RuntimeException | \InvalidArgumentException $e) {
                return null;
            }

@Ciantic
Copy link
Author

Ciantic commented Sep 23, 2019

Here is a pull request: #756

@Ciantic Ciantic changed the title TypeResolver failing all the time, Language Server not starting phpDocumentor throws random RuntimeExceptions (TypeResolver failing all the time, Language Server not starting) Sep 23, 2019
@Ciantic
Copy link
Author

Ciantic commented Sep 23, 2019

Note, the phpDocumentor puts a message to RuntimeException:

https://github.com/phpDocumentor/TypeResolver/blob/c0d13f995a30c295fa8f63d947153383d7597db5/src/TypeResolver.php#L156

E.g.

'A type is missing before a type separator' or 'Unexpected type separator' or 'Unexpected nullable character'

Maybe this could shown to user as warning if the line number can be extracted somehow. It's not a reason however to stop the whole thing from working.

@trdmn1
Copy link

trdmn1 commented Sep 24, 2019

I have a similar thing going on with mine. They're RuntimeExceptions, but different errors from what you're showing. They're essentially parsing errors on the doc blocks. Adding RuntimeException to the catch as shown above seems to quiet things down and keep the Output console from popping up on its own, but it would be nice to show these as warnings in the Problems console instead. I'm just not sure about the implications (or perhaps even the wisdom) of combining phpDocumenter errors with PHP errors.

@Ciantic
Copy link
Author

Ciantic commented Sep 24, 2019

Warnings would be nice, but the whole phpDocumentor is done badly, it should throw own parsing exception which contains the line number and file (or list of parsing errors). Instead it's reusing generic RuntimeException, which is not a good practice.

@jcottrell
Copy link

When running
composer run-script --working-dir=.composer/vendor/felixfbecker/language-server parse-stubs
I got a similar error message:

[RuntimeException]
A type is missing before a type separator

I edited .composer/vendor/felixfbecker/language-server/src/DefinitionResolver.php as described above (adding \RuntimeException | to the catch. The original command then completed.

Based on the comments above I went looking for the problem file. It seems that .composer/vendor/jetbrains/phpstorm-stubs/http/http3.php has docblock code @deprecated that might cause the problem, again, based on the comments of others.

I'm running "PHP 7.4.11 (cli) (built: Oct 1 2020 23:30:54) ( NTS )" if that helps.

Burnedo added a commit to Burnedo/php-language-server that referenced this issue May 20, 2021
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

3 participants