phpactor / vscode-phpactor

Phpactor VS Code Extension
MIT License
124 stars 8 forks source link

Request textDocument/definition failed on php build-in function stubs #116

Open PianistaMichal opened 7 months ago

PianistaMichal commented 7 months ago

I installed library from markeplace on vscode and I have trouble with this extension. Vscode version: Version: 1.86.0, vscode-phpactor version: 1.3.0 I am getting this error when hovering on some build-in php functions. For example on hovering on:

var_dump('test'):

Will throw this error:

[Error - 13:45:40] Request textDocument/definition failed.
  Message: Exception [Phpactor\TextDocument\Exception\TextDocumentNotFound] Text document "file:///Users/user_name/.vscode/extensions/phpactor.vscode-phpactor-1.3.0/phpactor.phar/vendor/jetbrains/phpstorm-stubs/standard/standard_4.php" not found at phar:///Users/user_name/.vscode/extensions/phpactor.vscode-phpactor-1.3.0/phpactor.phar/lib/TextDocument/Exception/TextDocumentNotFound.php#12
  Code: -32603 

Hovering on exception in this code: class InvalidDataException extends Exception will throw this exception:

[Error - 13:48:45] Request textDocument/definition failed.
  Message: Exception [Phpactor\TextDocument\Exception\TextDocumentNotFound] Text document "file:///Users/user_name/.vscode/extensions/phpactor.vscode-phpactor-1.3.0/phpactor.phar/vendor/jetbrains/phpstorm-stubs/Core/Core_c.php" not found at phar:///Users/user_name/.vscode/extensions/phpactor.vscode-phpactor-1.3.0/phpactor.phar/lib/TextDocument/Exception/TextDocumentNotFound.php#12
  Code: -32603

On dumping configuration I see this:

    "container.extension_classes": [
        "Phpactor\\Extension\\Core\\CoreExtension",
        "Phpactor\\Extension\\ClassToFileExtra\\ClassToFileExtraExtension",
        "Phpactor\\Extension\\ClassToFile\\ClassToFileExtension",
        "Phpactor\\Extension\\ClassMover\\ClassMoverExtension",
        "Phpactor\\ClassMover\\Extension\\ClassMoverExtension",
        "Phpactor\\Extension\\CodeTransform\\CodeTransformExtension",
        "Phpactor\\Extension\\CodeTransformExtra\\CodeTransformExtraExtension",
        "Phpactor\\Extension\\CompletionExtra\\CompletionExtraExtension",
        "Phpactor\\Extension\\CompletionWorse\\CompletionWorseExtension",
        "Phpactor\\Extension\\Completion\\CompletionExtension",
        "Phpactor\\Extension\\CompletionRpc\\CompletionRpcExtension",
        "Phpactor\\Extension\\Navigation\\NavigationExtension",
        "Phpactor\\Extension\\ContextMenu\\ContextMenuExtension",
        "Phpactor\\Extension\\Rpc\\RpcExtension",
        "Phpactor\\Extension\\SourceCodeFilesystemExtra\\SourceCodeFilesystemExtraExtension",
        "Phpactor\\Extension\\SourceCodeFilesystem\\SourceCodeFilesystemExtension",
        "Phpactor\\Extension\\WorseReflection\\WorseReflectionExtension",
        "Phpactor\\Extension\\WorseReflectionExtra\\WorseReflectionExtraExtension",
        "Phpactor\\Extension\\WorseReflectionAnalyse\\WorseReflectionAnalyseExtension",
        "Phpactor\\Extension\\FilePathResolver\\FilePathResolverExtension",
        "Phpactor\\Extension\\Logger\\LoggingExtension",
        "Phpactor\\Extension\\ComposerAutoloader\\ComposerAutoloaderExtension",
        "Phpactor\\Extension\\Console\\ConsoleExtension",
        "Phpactor\\Extension\\WorseReferenceFinder\\WorseReferenceFinderExtension",
        "Phpactor\\Extension\\ReferenceFinderRpc\\ReferenceFinderRpcExtension",
        "Phpactor\\Extension\\ReferenceFinder\\ReferenceFinderExtension",
        "Phpactor\\Extension\\Php\\PhpExtension",
        "Phpactor\\Extension\\Configuration\\ConfigurationExtension",
        "Phpactor\\Extension\\ComposerInspector\\ComposerInspectorExtension",
        "Phpactor\\Extension\\LanguageServer\\LanguageServerExtension",
        "Phpactor\\Extension\\LanguageServerCompletion\\LanguageServerCompletionExtension",
        "Phpactor\\Extension\\LanguageServerReferenceFinder\\LanguageServerReferenceFinderExtension",
        "Phpactor\\Extension\\LanguageServerWorseReflection\\LanguageServerWorseReflectionExtension",
        "Phpactor\\Extension\\LanguageServerIndexer\\LanguageServerIndexerExtension",
        "Phpactor\\Extension\\LanguageServerHover\\LanguageServerHoverExtension",
        "Phpactor\\Extension\\LanguageServerBridge\\LanguageServerBridgeExtension",
        "Phpactor\\Extension\\LanguageServerCodeTransform\\LanguageServerCodeTransformExtension",
        "Phpactor\\Extension\\LanguageServerSymbolProvider\\LanguageServerSymbolProviderExtension",
        "Phpactor\\Extension\\LanguageServerSelectionRange\\LanguageServerSelectionRangeExtension",
        "Phpactor\\Extension\\LanguageServer\\LanguageServerExtraExtension",
        "Phpactor\\Extension\\LanguageServerDiagnostics\\LanguageServerDiagnosticsExtension",
        "Phpactor\\Extension\\LanguageServerRename\\LanguageServerRenameExtension",
        "Phpactor\\Extension\\LanguageServerRename\\LanguageServerRenameWorseExtension",
        "Phpactor\\Extension\\LanguageServerConfiguration\\LanguageServerConfigurationExtension",
        "Phpactor\\Indexer\\Extension\\IndexerExtension",
        "Phpactor\\Extension\\ObjectRenderer\\ObjectRendererExtension",
        "Phpactor\\Extension\\LanguageServerPhpstan\\LanguageServerPhpstanExtension",
        "Phpactor\\Extension\\LanguageServerPhpstan\\LanguageServerPhpstanSuggestExtension",
        "Phpactor\\Extension\\LanguageServerPsalm\\LanguageServerPsalmExtension",
        "Phpactor\\Extension\\LanguageServerPsalm\\LanguageServerPsalmSuggestExtension",
        "Phpactor\\Extension\\LanguageServerPhpCsFixer\\LanguageServerPhpCsFixerExtension",
        "Phpactor\\Extension\\LanguageServerPhpCsFixer\\LanguageServerPhpCsFixerSuggestExtension",
        "Phpactor\\Extension\\PhpCodeSniffer\\PhpCodeSnifferExtension",
        "Phpactor\\Extension\\PhpCodeSniffer\\PhpCodeSnifferSuggestExtension",
        "Phpactor\\Extension\\LanguageServerBlackfire\\LanguageServerBlackfireExtension",
        "Phpactor\\Extension\\Prophecy\\ProphecyExtension",
        "Phpactor\\Extension\\Prophecy\\ProphecySuggestExtension",
        "Phpactor\\Extension\\Behat\\BehatExtension",
        "Phpactor\\Extension\\Behat\\BehatSuggestExtension",
        "Phpactor\\Extension\\Symfony\\SymfonyExtension",
        "Phpactor\\Extension\\Symfony\\SymfonySuggestExtension",
        "Phpactor\\Extension\\PHPUnit\\PHPUnitExtension",
        "Phpactor\\Extension\\Debug\\DebugExtension"
    ],
    "console_dumper_default": "indented",
    "xdebug_disable": true,
    "command": "language-server",
    "core.warn_on_develop": true,
    "core.min_memory_limit": 1610612736,
    "$schema": "\/phpactor.schema.json",
    "class_to_file.project_root": "%project_root%",
    "class_to_file.brute_force_conversion": false,
    "code_transform.class_new.variants": [],
    "code_transform.template_paths": [
        "%project_config%\/templates",
        "%config%\/templates"
    ],
    "code_transform.indentation": "    ",
    "code_transform.refactor.generate_accessor.prefix": "",
    "code_transform.refactor.generate_accessor.upper_case_first": false,
    "code_transform.refactor.generate_mutator.prefix": "set",
    "code_transform.refactor.generate_mutator.upper_case_first": true,
    "code_transform.refactor.generate_mutator.fluent": false,
    "code_transform.import_globals": false,
    "code_transform.refactor.object_fill.hint": true,
    "code_transform.refactor.object_fill.named_parameters": true,
    "completion_worse.completor.doctrine_annotation.enabled": true,
    "completion_worse.completor.imported_names.enabled": true,
    "completion_worse.completor.worse_parameter.enabled": true,
    "completion_worse.completor.named_parameter.enabled": true,
    "completion_worse.completor.constructor.enabled": true,
    "completion_worse.completor.class_member.enabled": true,
    "completion_worse.completor.scf_class.enabled": false,
    "completion_worse.completor.local_variable.enabled": true,
    "completion_worse.completor.subscript.enabled": true,
    "completion_worse.completor.declared_function.enabled": false,
    "completion_worse.completor.declared_constant.enabled": false,
    "completion_worse.completor.declared_class.enabled": false,
    "completion_worse.completor.expression_name_search.enabled": true,
    "completion_worse.completor.use.enabled": true,
    "completion_worse.completor.attribute.enabled": true,
    "completion_worse.completor.class_like.enabled": true,
    "completion_worse.completor.type.enabled": true,
    "completion_worse.completor.keyword.enabled": true,
    "completion_worse.completor.docblock.enabled": true,
    "completion_worse.completor.constant.enabled": false,
    "completion_worse.completor.class.limit": 100,
    "completion_worse.name_completion_priority": "proximity",
    "completion_worse.snippets": true,
    "completion_worse.experimantal": false,
    "completion_worse.debug": false,
    "completion.dedupe": true,
    "completion.dedupe_match_fqn": true,
    "completion.limit": null,
    "completion.label_formatter": "helpful",
    "navigator.destinations": [],
    "navigator.autocreate": [],
    "rpc.store_replay": false,
    "rpc.replay_path": "%cache%\/replay.json",
    "source_code_filesystem.project_root": "%project_root%",
    "language_server_code_transform.import_globals": false,
    "worse_reflection.enable_cache": true,
    "worse_reflection.cache_lifetime": 1,
    "worse_reflection.enable_context_location": false,
    "worse_reflection.cache_dir": "%cache%\/worse-reflection",
    "worse_reflection.stub_dir": "%application_root%\/vendor\/jetbrains\/phpstorm-stubs",
    "worse_reflection.diagnostics.undefined_variable.suggestion_levenshtein_disatance": 4,
    "file_path_resolver.project_root": "\/Users\/user_name\/projects\/app-wallet-api",
    "file_path_resolver.app_name": "phpactor",
    "file_path_resolver.application_root": "phar:\/\/\/Users\/user_name\/.vscode\/extensions\/phpactor.vscode-phpactor-1.3.0\/phpactor.phar",
    "file_path_resolver.enable_cache": true,
    "file_path_resolver.enable_logging": true,
    "logging.enabled": false,
    "logging.fingers_crossed": false,
    "logging.path": "application.log",
    "logging.level": "warning",
    "logger.name": "logger",
    "logging.formatter": null,
    "composer.enable": true,
    "composer.autoloader_path": "%project_root%\/vendor\/autoload.php",
    "composer.autoload_deregister": true,
    "composer.class_maps_only": true,
    "console.verbosity": 32,
    "console.decorated": null,
    "php.version": null,
    "language_server.catch_errors": true,
    "language_server.enable_workspace": true,
    "language_server.session_parameters": {
        "language_server.method_alias_map": {
            "indexer\/reindex": "phpactor\/indexer\/reindex",
            "session\/dumpConfig": "phpactor\/debug\/config",
            "service\/running": "phpactor\/service\/running",
            "system\/status": "phpactor\/stats"
        },
        "worse_reflection.enable_context_location": false,
        "class_to_file.brute_force_conversion": false,
        "completion_worse.completor.scf_class.enabled": false,
        "completion_worse.completor.declared_class.enabled": false,
        "completion_worse.completor.declared_constant.enabled": false,
        "completion_worse.completor.declared_function.enabled": false
    },
    "language_server.method_alias_map": {
        "indexer\/reindex": "phpactor\/indexer\/reindex",
        "session\/dumpConfig": "phpactor\/debug\/config",
        "service\/running": "phpactor\/service\/running",
        "system\/status": "phpactor\/stats"
    },
    "language_server.diagnostic_sleep_time": 1000,
    "language_server.diagnostics_on_update": true,
    "language_server.diagnostics_on_save": true,
    "language_server.diagnostics_on_open": true,
    "language_server.diagnostic_providers": null,
    "language_server.diagnostic_outsource": true,
    "language_server.file_events": true,
    "language_server.file_event_globs": [
        "**\/*.php"
    ],
    "language_server.profile": false,
    "language_server.trace": false,
    "language_server.shutdown_grace_period": 200,
    "language_server.phpactor_bin": "\/Users\/user_name\/.vscode\/extensions\/phpactor.vscode-phpactor-1.3.0\/phpactor.phar",
    "language_server.self_destruct_timeout": 2500,
    "language_server.diagnostic_outsource_timeout": 5,
    "language_server_completion.trim_leading_dollar": false,
    "language_server_reference_reference_finder.reference_timeout": 60,
    "language_server_worse_reflection.workspace_index.update_interval": 100,
    "language_server_worse_reflection.inlay_hints.enable": false,
    "language_server_worse_reflection.inlay_hints.types": false,
    "language_server_worse_reflection.inlay_hints.params": true,
    "language_server_worse_reflection.diagnostics.enable": true,
    "language_server_indexer.workspace_symbol_search_limit": 250,
    "language_server_indexer.reindex_timeout": 300,
    "language_server_code_transform.import_name.report_non_existing_names": true,
    "language_server_configuration.auto_config": true,
    "indexer.enabled_watchers": [
        "lsp",
        "inotify",
        "find",
        "php"
    ],
    "indexer.index_path": "%cache%\/index\/%project_id%",
    "indexer.include_patterns": [
        "\/**\/*.php"
    ],
    "indexer.exclude_patterns": [
        "\/vendor\/**\/Tests\/**\/*",
        "\/vendor\/**\/tests\/**\/*",
        "\/vendor\/composer\/**\/*"
    ],
    "indexer.stub_paths": [
        "phar:\/\/\/Users\/user_name\/.vscode\/extensions\/phpactor.vscode-phpactor-1.3.0\/phpactor.phar\/vendor\/jetbrains\/phpstorm-stubs"
    ],
    "indexer.poll_time": 5000,
    "indexer.buffer_time": 500,
    "indexer.follow_symlinks": false,
    "indexer.project_root": "%project_root%",
    "indexer.reference_finder.deep": true,
    "indexer.implementation_finder.deep": true,
    "indexer.supported_extensions": [
        "php"
    ],
    "object_renderer.template_paths.markdown": [
        "%project_config%\/templates\/markdown",
        "%config%\/templates\/markdown"
    ],
    "language_server_phpstan.enabled": true,
    "language_server_phpstan.bin": "%project_root%\/vendor\/bin\/phpstan",
    "language_server_phpstan.level": null,
    "language_server_phpstan.config": null,
    "language_server_phpstan.mem_limit": null,
    "language_server_psalm.enabled": false,
    "language_server_psalm.bin": "%project_root%\/vendor\/bin\/psalm",
    "language_server_psalm.show_info": true,
    "language_server_psalm.use_cache": true,
    "language_server_psalm.error_level": null,
    "language_server_psalm.threads": 1,
    "language_server_psalm.timeout": 15,
    "language_server_php_cs_fixer.enabled": false,
    "language_server_php_cs_fixer.bin": "%project_root%\/vendor\/bin\/php-cs-fixer",
    "language_server_php_cs_fixer.env": {
        "XDEBUG_MODE": "off",
        "PHP_CS_FIXER_IGNORE_ENV": true
    },
    "language_server_php_cs_fixer.show_diagnostics": true,
    "language_server_php_cs_fixer.config": null,
    "php_code_sniffer.enabled": false,
    "php_code_sniffer.bin": "%project_root%\/vendor\/bin\/phpcs",
    "php_code_sniffer.env": {
        "XDEBUG_MODE": "off"
    },
    "php_code_sniffer.show_diagnostics": true,
    "blackfire.enabled": false,
    "prophecy.enabled": true,
    "behat.enabled": false,
    "behat.config_path": "%project_root%\/behat.yml",
    "behat.symfony.di_xml_path": null,
    "symfony.enabled": false,
    "symfony.xml_path": "%project_root%\/var\/cache\/dev\/App_KernelDevDebugContainer.xml",
    "completion_worse.completor.symfony.enabled": true,
    "public_services_only": false,
    "phpunit.enabled": false
}

How to fix this?

PianistaMichal commented 1 month ago

In case anyone would have similar issue. I found solution. Just install globally or locally. Whatever You prefer this package:

composer global require JetBrains/phpstorm-stubs

And then in .phpactor.json add:

"worse_reflection.stub_dir": "~/.composer/vendor/jetbrains/phpstorm-stubs",
dantleech commented 1 month ago

I guess this is a general issue with the phar, I guess using the phar:// scheme with the original file path would also work