Skip to content

Extension fails if showTypeOnHover is enabled #144

@lkrms

Description

@lkrms

Possibly related to #142.

When I enable phpstan.showTypeOnHover, the extension fails in multiple ways; when I leave it disabled, everything appears to work.

Output when working (after restarting extensions):

[04/12/2025, 17:05:50] [client] Starting extension with configuration: {
	"phpstan.singleFileMode": false,
	"phpstan.binPath": "vendor/bin/phpstan",
	"phpstan.binCommand": [],
	"phpstan.configFile": "phpstan.neon,phpstan.neon.dist,phpstan.dist.neon",
	"phpstan.paths": {},
	"phpstan.dockerContainerName": "",
	"phpstan.rootDir": "",
	"phpstan.options": [],
	"phpstan.enableStatusBar": true,
	"phpstan.memoryLimit": "1G",
	"phpstan.enabled": true,
	"phpstan.projectTimeout": 300000,
	"phpstan.timeout": 300000,
	"phpstan.suppressTimeoutMessage": true,
	"phpstan.showProgress": true,
	"phpstan.showTypeOnHover": false,
	"phpstan.enableLanguageServer": false,
	"phpstan.ignoreErrors": [
		"Xdebug: .*"
	],
	"phpstan.suppressWorkspaceMessage": true,
	"phpstan.pro": false,
	"phpstan.tmpDir": "",
	"phpstan.checkValidity": false
}
[04/12/2025, 17:05:50] [client] Initializing done
[04/12/2025, 17:05:50] [client] Showing one-time messages (if needed)
[04/12/2025, 5:05:50 pm] [server] Language server ready
[04/12/2025, 17:05:50] [server] Language server started
[04/12/2025, 5:05:50 pm] [neon] Error while parsing .neon file "/Users/lina/Code/lk/pretty-php/phpstan.neon": Unexpected '$parameters' on line 3, column 1.
[04/12/2025, 5:05:50 pm] [neon] Error while parsing .neon file "/Users/lina/Code/lk/pretty-php/phpstan.neon.dist": Unexpected '$parameters' on line 3, column 1.
[04/12/2025, 5:05:55 pm] [file-watcher] Checking: Initial check
[04/12/2025, 5:05:55 pm] [check:1] Check started for project
[04/12/2025, 17:05:55] [status-bar] notification:' {"opId":0,"type":"new","tooltip":"Checking project"}
[04/12/2025, 17:05:55] [status-bar] Showing status bar
[04/12/2025, 5:05:55 pm] [check:1] Spawning PHPStan with the following configuration:  {"binStr":"/Users/lina/Code/lk/pretty-php/vendor/bin/phpstan","args":["analyse","-c","/Users/lina/Code/lk/pretty-php/phpstan.neon","--error-format=json","--no-interaction","--memory-limit=1G"]}
[04/12/2025, 5:05:55 pm] [check:1] Spawning PHPStan, command:  /Users/lina/Code/lk/pretty-php/vendor/bin/phpstan "analyse" "-c" "/Users/lina/Code/lk/pretty-php/phpstan.neon" "--error-format=json" "--no-interaction" "--memory-limit=1G"
[04/12/2025, 17:05:55] [process-spawner] Spawning process 55334 with timeout 900000
[04/12/2025, 17:05:56] [status-bar] notification:' {"progress":{"done":0,"total":143,"percentage":0},"opId":0,"type":"progress","tooltip":"Checking project - 0/143 (0%)"}
[04/12/2025, 17:05:56] [status-bar] notification:' {"progress":{"done":143,"total":143,"percentage":100},"opId":0,"type":"progress","tooltip":"Checking project - 143/143 (100%)"}
[04/12/2025, 5:05:56 pm] [check:1] PHPStan process exited succesfully
[04/12/2025, 17:05:56] [status-bar] notification:' {"opId":0,"result":"Success","type":"done"}
[04/12/2025, 17:05:56] [status-bar] Hiding status bar, last operation result = Success
[04/12/2025, 5:05:56 pm] [check:1] Check completed for project, errors= {"fileSpecificErrors":{"file:///Users/lina/Code/lk/pretty-php/scripts/get-rules.php":["Offset 'method' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory?: bool, is_default?: bool, pass?: int, method?: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'rule' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory?: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'is_mandatory' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory?: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'is_default' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'pass' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'priority' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'rule' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens: non-empty-array<int, bool|string>, ...}.","Offset 'declarations' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'php_doc' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc?: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'rule' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: 'callback', priority?: int, php_doc: null, tokens?: array<int, bool|string>|null, ...}.","Offset 'rule' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: 'callback', priority?: int, php_doc: null, tokens?: array<int, bool|string>|null, ...}.","Offset 'is_default' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: false, is_default?: bool, pass?: int, method: string, priority?: int, php_doc: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}.","Offset 'priority' might not exist on array{rule?: class-string<Lkrms\\PrettyPHP\\Contract\\Rule>, is_mandatory: bool, is_default?: bool, pass?: int, method: string, priority?: int, php_doc: Salient\\PHPDoc\\PHPDoc|null, tokens?: array<int, bool|string>|null, ...}."],"file:///Users/lina/Code/lk/pretty-php/src/Rule/NormaliseStrings.php":["Offset string|null might not exist on array{a: 7, b: 8}."]},"notFileSpecificErrors":[]}

After enabling, the following output appears (below the above) and "PHPStan checking..." appears in the toolbar, spinning forever.

[04/12/2025, 5:09:01 pm] [neon] Error while parsing .neon file "/Users/lina/Code/lk/pretty-php/phpstan.neon": Unexpected '$parameters' on line 3, column 1.
[04/12/2025, 5:09:01 pm] [neon] Error while parsing .neon file "/Users/lina/Code/lk/pretty-php/phpstan.neon.dist": Unexpected '$parameters' on line 3, column 1.
[04/12/2025, 5:09:01 pm] [file-watcher] Checking: Manual all-projects scan
[04/12/2025, 5:09:01 pm] [check:2] Check started for project
[04/12/2025, 17:09:01] [status-bar] notification:' {"opId":1,"type":"new","tooltip":"Checking project"}
[04/12/2025, 17:09:01] [status-bar] Showing status bar

And if I restart extensions:

[04/12/2025, 17:10:44] [client] Starting extension with configuration: {
	"phpstan.singleFileMode": false,
	"phpstan.binPath": "vendor/bin/phpstan",
	"phpstan.binCommand": [],
	"phpstan.configFile": "phpstan.neon,phpstan.neon.dist,phpstan.dist.neon",
	"phpstan.paths": {},
	"phpstan.dockerContainerName": "",
	"phpstan.rootDir": "",
	"phpstan.options": [],
	"phpstan.enableStatusBar": true,
	"phpstan.memoryLimit": "1G",
	"phpstan.enabled": true,
	"phpstan.projectTimeout": 300000,
	"phpstan.timeout": 300000,
	"phpstan.suppressTimeoutMessage": true,
	"phpstan.showProgress": true,
	"phpstan.showTypeOnHover": true,
	"phpstan.enableLanguageServer": false,
	"phpstan.ignoreErrors": [
		"Xdebug: .*"
	],
	"phpstan.suppressWorkspaceMessage": true,
	"phpstan.pro": false,
	"phpstan.tmpDir": "",
	"phpstan.checkValidity": false
}
[04/12/2025, 17:10:44] [client] Initializing done
[04/12/2025, 17:10:44] [client] Showing one-time messages (if needed)
[04/12/2025, 5:10:44 pm] [server] Language server ready
[04/12/2025, 17:10:44] [server] Language server started
[04/12/2025, 5:10:45 pm] [neon] Error while parsing .neon file "/Users/lina/Code/lk/pretty-php/phpstan.neon": Unexpected '$parameters' on line 3, column 1.
[04/12/2025, 5:10:45 pm] [neon] Error while parsing .neon file "/Users/lina/Code/lk/pretty-php/phpstan.neon.dist": Unexpected '$parameters' on line 3, column 1.
[04/12/2025, 5:10:47 pm] [file-watcher] Checking: New document active
[04/12/2025, 5:10:47 pm] [check:1] Check started for project
[04/12/2025, 17:10:47] [status-bar] notification:' {"opId":0,"type":"new","tooltip":"Checking project"}
[04/12/2025, 17:10:47] [status-bar] Showing status bar

Configuration files are:

phpstan.neon:

includes:
  - phpstan.neon.dist

parameters:
  editorUrl: "vscode://file/%%file%%:%%line%%"
  editorUrlTitle: "%%relFile%%:%%line%%"

  parallel:
    maximumNumberOfProcesses: 6

phpstan.neon.dist:

includes:
  - tests/phpstan-conditional.php
  - phpstan-baseline.neon

parameters:
  level: 9
  paths:
    - bin/pretty-php
    - scripts
    - src
    - tests/integration
    - tests/unit
    - tests/phpstan-conditional.php
    - bootstrap.php
  excludePaths:
    analyseAndScan:
      - tests/integration/Bootstrap/invalid-single-character-tokens.php
      - tests/integration/Bootstrap/invalid-tokens.php
      - tests/integration/Bootstrap/tokens-with-same-id.php

I get the same result if I comment out the only "tricky" inclusion, i.e. tests/phpstan-conditional.php, so it doesn't seem to be related to the PHP version-specific settings in there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions