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

RuntimeException: PHP Error: Undefined property: stdClass::$range #10353

Closed
jgmdev opened this issue Nov 7, 2023 · 5 comments · Fixed by #10614
Closed

RuntimeException: PHP Error: Undefined property: stdClass::$range #10353

jgmdev opened this issue Nov 7, 2023 · 5 comments · Fixed by #10614

Comments

@jgmdev
Copy link

jgmdev commented Nov 7, 2023

PHP Version: 8.2.12

Was testing the language server component of this project with Pragtical text editor + LSP plugin and sending the document changed event triggered the following error:

[psalm-language-server] RuntimeException: PHP Error: Undefined property: stdClass::$range in vendor/vimeo/psalm/src/Psalm/Internal/LanguageServer/Server/TextDocument.php:122 for command with CLI args "vendor/bin/psalm-language-server --config psalm.xml" in vendor/vimeo/psalm/src/Psalm/Internal/ErrorHandler.php:77

Fixed it locally with the following change, but not sure if it is the proper solution:

vendor/vimeo/psalm/src/Psalm/Internal/LanguageServer/Server/TextDocument.php

-        if (count($contentChanges) === 1 && isset($contentChanges[0]) && $contentChanges[0]->range === null) {
+        if (count($contentChanges) === 1 && isset($contentChanges[0]) && (!property_exists($contentChanges[0], "range") || $contentChanges[0]->range === null)) {
Copy link

Hey @jgmdev, can you reproduce the issue on https://psalm.dev ?

@weirdan
Copy link
Collaborator

weirdan commented Jan 30, 2024

Is there any chance you're running PHP with opcache.save_comments=0?

@jgmdev
Copy link
Author

jgmdev commented Jan 30, 2024

Is there any chance you're running PHP with opcache.save_comments=0?

You are correct that is the case on my php opcache config. If not supported by psalm should this issue get closed?

@weirdan
Copy link
Collaborator

weirdan commented Jan 30, 2024

No, we should detect this configuration and warn about / correct it.

@weirdan
Copy link
Collaborator

weirdan commented Jan 30, 2024

Fixed in 5.x-dev (composer require --dev vimeo/psalm:5.x-dev)

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

Successfully merging a pull request may close this issue.

2 participants