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

Sublime Text 4 - PHP : phpactor does not recognize standards PHP functions and classes #2584

Open
srbetasign opened this issue Jan 3, 2025 · 0 comments

Comments

@srbetasign
Copy link

srbetasign commented Jan 3, 2025

Hello,

Happy new year !!!

First, thank you for this amazing plugin which has turned my Sublime Text into a real and impressive IDE !


Bug description

I have an issue on a Symfony 7 project, about standard functions like implode() or array_column()and standard classes like \RuntimeException or \DateTimeImmutable: they are marked as "not found".

This error is triggered if I use \DateTimeImmutable or if I add the use statement use DateTimeImmutable;.


Configuration & settings

I am using the latest version of Sublime Text 4 (Build 4189) and the latest version of Phpactor:

$ /path/to/phpactor.phar status
Version: 2024.11.28.1
Filesystems: git, simple, composer
Working directory: /home/dev/www/sf7

Config files (missing is not bad):

  ✘ /home/dev/.config/phpactor/phpactor.json
  ✘ /home/dev/.config/phpactor/phpactor.yml
  ✔ /home/dev/www/sf7/.phpactor.json
  ✘ /home/dev/www/sf7/.phpactor.yml

Diagnostics:

  ✔ Composer detected - Phpactor could work faster without an index
  ✔ Git detected - enables faster refactorings in your repository scope!
  ✔ XDebug is disabled. XDebug has a negative effect on performance.

I have installed the LSP plugin for Sublime Text with the following settings:

{
  "clients": {
    "phpactor": {
      "command": [
        "/home/dev/bin/phpactor.phar",
        "language-server"
      ],
      "enabled": true,
      "priority_selector": "source.php",
      "selector": "source.php | embedding.php",
      "syntaxes": [
        "Packages/PHP/PHP.sublime-syntax"
      ]
    }
  }
}

And here is the .phpactor.json configuration file:

{
    "$schema": "/phpactor.schema.json",
    "language_server_phpstan.enabled": true,
    "language_server_php_cs_fixer.enabled": false,
    "behat.enabled": true,
    "behat.symfony.di_xml_path": "var/cache/test/App_KernelTestDebugContainer.xml",
    "symfony.enabled": true,
    "indexer.exclude_patterns": [
        "/vendor/**/Tests/**/*",
        "/vendor/**/tests/**/*",
        "/var/cache/**/*",
        "/vendor/composer/**/*"
    ]
}

Troubleshooting: phpactor

Version

  • LSP: 2.3.0
  • Sublime Text: 4189

Server Test Run

  • exit code: 0
  • output
Starting language server, use -vvv for verbose output

Server Configuration

  • command
[
  "/home/dev/bin/phpactor.phar",
  "language-server"
]
  • shell command
/home/dev/bin/phpactor.phar language-server
  • selector
source.php | embedding.php
  • priority_selector
source.php
  • init_options
{}
  • settings
{}
  • env
{}

Active view

  • File name
/home/dev/www/sf7/src/Factory/DataFactory.php
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
  "lsp_active": true,
  "syntax": "Packages/PHP/PHP.sublime-syntax"
}
  • base scope
embedding.php

Project / Workspace

  • folders
[
  "/home/dev/www/sf7"
]
  • is project: False

LSP configuration

{
  "clients": {
    "phpactor": {
      "command": [
        "/home/dev/bin/phpactor.phar",
        "language-server"
      ],
      "enabled": true,
      "priority_selector": "source.php",
      "selector": "source.php | embedding.php",
      "syntaxes": [
        "Packages/PHP/PHP.sublime-syntax"
      ]
    }
  }
}

Log Panel

:: [11:59:35.641] --> phpactor initialize (1): {'processId': 29282, 'clientInfo': {'name': 'Sublime Text LSP', 'version': '2.3.0'}, 'rootUri': 'file:///home/dev/www/sf7', 'rootPath': '/home/dev/www/sf7', 'workspaceFolders': [{'name': 'sf7', 'uri': 'file:///home/dev/www/sf7'}], 'capabilities': {'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}}, 'textDocument': {'synchronization': {'dynamicRegistration': True, 'didSave': True, 'willSave': True, 'willSaveWaitUntil': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'completion': {'dynamicRegistration': True, 'completionItem': {'snippetSupport': True, 'deprecatedSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'tagSupport': {'valueSet': [1]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertReplaceSupport': True, 'insertTextModeSupport': {'valueSet': [2]}, 'labelDetailsSupport': True}, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'insertTextMode': 2, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}}, 'signatureHelp': {'dynamicRegistration': True, 'contextSupport': True, 'signatureInformation': {'activeParameterSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}}}, 'references': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'tagSupport': {'valueSet': [1]}}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True, 'rangesSupport': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'codeAction': {'dynamicRegistration': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}, 'dataSupport': True, 'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True, 'prepareSupportDefaultBehavior': 1}, 'colorProvider': {'dynamicRegistration': True}, 'publishDiagnostics': {'relatedInformation': True, 'tagSupport': {'valueSet': [1, 2]}, 'versionSupport': True, 'codeDescriptionSupport': True, 'dataSupport': True}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'foldingRange': {'dynamicRegistration': True, 'foldingRangeKind': {'valueSet': ['comment', 'imports', 'region']}}, 'codeLens': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'semanticTokens': {'dynamicRegistration': True, 'requests': {'range': True, 'full': {'delta': True}}, 'tokenTypes': ['namespace', 'type', 'class', 'enum', 'interface', 'struct', 'typeParameter', 'parameter', 'variable', 'property', 'enumMember', 'event', 'function', 'method', 'macro', 'keyword', 'modifier', 'comment', 'string', 'number', 'regexp', 'operator', 'decorator', 'label'], 'tokenModifiers': ['declaration', 'definition', 'readonly', 'static', 'deprecated', 'abstract', 'async', 'modification', 'documentation', 'defaultLibrary'], 'formats': ['relative'], 'overlappingTokenSupport': False, 'multilineTokenSupport': True, 'augmentsSyntaxTokens': True}, 'callHierarchy': {'dynamicRegistration': True}, 'typeHierarchy': {'dynamicRegistration': True}}, 'workspace': {'applyEdit': True, 'didChangeConfiguration': {'dynamicRegistration': True}, 'executeCommand': {}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'workspaceFolders': True, 'symbol': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['location.range']}, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'tagSupport': {'valueSet': [1]}}, 'configuration': True, 'codeLens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'diagnostics': {'refreshSupport': True}}, 'window': {'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'workDoneProgress': True}}, 'initializationOptions': {}}
phpactor: Starting language server, use -vvv for verbose output
:: [11:59:35.808] <<< phpactor (1) (duration: 167ms): {'capabilities': {'completionProvider': {'triggerCharacters': [':', '>', '$', '[', '@', '(', "'", '"', '\\'], 'resolveProvider': True}, 'hoverProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(', ',', '@']}, 'definitionProvider': True, 'typeDefinitionProvider': True, 'implementationProvider': True, 'referencesProvider': True, 'documentHighlightProvider': True, 'documentSymbolProvider': True, 'codeActionProvider': {'codeActionKinds': ['refactor.class.simplify', 'quickfix.import_class', 'quickfix.override_method', 'quickfix.promote_constructor', 'quickfix.promote_constructor_public', 'quickfix.complete_constructor', 'quickfix.complete_constructor_public', 'quickfix.add_missing_class_generic', 'quickfix.create_class', 'quickfix.create_unresolable_class', 'quickfix.correct_variable_name', 'quickfix.add_missing_properties', 'quickfix.implement_contracts', 'quickfix.fix_namespace_class_name', 'quickfix.add_missing_docblocks_return', 'quickfix.add_missing_params', 'quickfix.add_missing_return_types', 'quickfix.remove_unused_imports', 'quickfix.generate_member', 'refactor.extract.method', 'refactor.extract.constant', 'quickfix.generate_accessors', 'quickfix.generate_mutators', 'refactor.extract.expression', 'quickfix.fill.object', 'quickfix.fill.matchArms', 'refactor', 'quickfix.generate_decorator']}, 'workspaceSymbolProvider': True, 'renameProvider': {'prepareProvider': True}, 'selectionRangeProvider': True, 'executeCommandProvider': {'commands': ['name_import', 'transform', 'create_class', 'generate_member', 'extract_method', 'replace_qualifier_with_import', 'extract_constant', 'generate_accessors', 'generate_mutators', 'import_all_unresolved_names', 'extract_expression', 'generate_decorator', 'override_method']}, 'workspace': {'fileOperations': {'willRename': {'filters': [{'pattern': {'glob': '**/*.php'}}]}}}, 'textDocumentSync': {'didOpen': {}, 'save': {}, 'didClose': {}, 'change': {'syncKind': 1}}}, 'serverInfo': {'name': 'phpactor/phpactor', 'version': '2024.11.28.1'}}
:: [11:59:35.809]  -> phpactor initialized: {}
:: [11:59:35.832]  -> phpactor textDocument/didOpen: <params with 10245 characters>
:: [11:59:36.335] <-- phpactor window/workDoneProgress/create (313c2a4a-de8a-49a8-8d56-2d49af544c26): {'token': '8b2029a9-2d28-4dfb-b29e-bbcd78062cd3'}
:: [11:59:36.335] >>> phpactor (313c2a4a-de8a-49a8-8d56-2d49af544c26) (duration: 0ms): None
:: [11:59:36.347] <-  phpactor $/progress: {'token': '8b2029a9-2d28-4dfb-b29e-bbcd78062cd3', 'value': {'kind': 'begin', 'title': 'Indexing workspace', 'message': '0 PHP files', 'percentage': 0}}
:: [11:59:36.350] <-  phpactor $/progress: {'token': '8b2029a9-2d28-4dfb-b29e-bbcd78062cd3', 'value': {'kind': 'end', 'message': 'Done indexing (0.00s, 34/∞ mb), watching with pattern matching buffered inotify'}}
:: [11:59:37.339] <-  phpactor textDocument/publishDiagnostics: {'uri': 'file:///home/dev/www/sf7/src/Factory/SalesforceDataFactory.php', 'version': 0, 'diagnostics': []}
:: [11:59:37.733] <-  phpactor textDocument/publishDiagnostics: {'uri': 'file:///home/dev/www/sf7/src/Factory/SalesforceDataFactory.php', 'version': 0, 'diagnostics': [{'range': {'start': {'line': 72, 'character': 72}, 'end': {'line': 72, 'character': 85}}, 'severity': 1, 'code': 'worse.unresolved_name', 'source': 'phpactor', 'message': 'Class "DateInterval" not found', 'tags': []}, {'range': {'start': {'line': 92, 'character': 40}, 'end': {'line': 92, 'character': 47}}, 'severity': 1, 'code': 'worse.unresolved_name', 'source': 'phpactor', 'message': 'Function "implode" not found', 'tags': []}, {'range': {'start': {'line': 207, 'character': 23}, 'end': {'line': 207, 'character': 30}}, 'severity': 1, 'code': 'worse.unresolved_name', 'source': 'phpactor', 'message': 'Function "implode" not found', 'tags': []}, {'range': {'start': {'line': 207, 'character': 37}, 'end': {'line': 207, 'character': 49}}, 'severity': 1, 'code': 'worse.unresolved_name', 'source': 'phpactor', 'message': 'Function "array_column" not found', 'tags': []}]}
...
:: [12:05:47.231] <<< phpactor (24) (duration: 100ms): {'contents': {'kind': 'markdown', 'value': 'Unable to locate class "DateInterval"'}, 'range': {'start': {'line': 72, 'character': 72}, 'end': {'line': 72, 'character': 85}}}

Log console

LSP: enabled configs: phpactor
LSP: disabled configs: erlang-ls, ocaml, polymer-ide, ruby, sorbet
LSP: starting ['/home/dev/bin/phpactor.phar', 'language-server'] in /home/dev/www/sf7
LSP: phpactor: Supported execute commands: ['name_import', 'transform', 'create_class', 'generate_member', 'extract_method', 'replace_qualifier_with_import', 'extract_constant', 'generate_accessors', 'generate_mutators', 'import_all_unresolved_names', 'extract_expression', 'generate_decorator', 'override_method']
LSP: phpactor: supported code action kinds: ['refactor.class.simplify', 'quickfix.import_class', 'quickfix.override_method', 'quickfix.promote_constructor', 'quickfix.promote_constructor_public', 'quickfix.complete_constructor', 'quickfix.complete_constructor_public', 'quickfix.add_missing_class_generic', 'quickfix.create_class', 'quickfix.create_unresolable_class', 'quickfix.correct_variable_name', 'quickfix.add_missing_properties', 'quickfix.implement_contracts', 'quickfix.fix_namespace_class_name', 'quickfix.add_missing_docblocks_return', 'quickfix.add_missing_params', 'quickfix.add_missing_return_types', 'quickfix.remove_unused_imports', 'quickfix.generate_member', 'refactor.extract.method', 'refactor.extract.constant', 'quickfix.generate_accessors', 'quickfix.generate_mutators', 'refactor.extract.expression', 'quickfix.fill.object', 'quickfix.fill.matchArms', 'refactor', 'quickfix.generate_decorator']
Package Control: Skipping automatic upgrade, last run at 2025-01-03 09:21:35, next run at 2025-01-03 17:21:35 or after

Test Phpactor in command line

When, i run Phpactor in command line on a PHP file with the "Not found" errors, no one is displayed:

$ /path/to/phpactor.phar worse:analyse src/Classes/MyPhpClass.php 
Analysing files...

    0 [->--------------------------]

0 problems in 0.0126 seconds with 21,682,448b memory

This is the expected behavior.


Partial conclusion

As Phpactor runs as expected in command line, it leads to think the issue should be in the configuration/settings files.

I am aware for any advice or solution.

Thank you.

Best regards.

Sam.

@srbetasign srbetasign changed the title Sublime Text 4 : phpactor does not recognize standards PHP functions and classes Sublime Text 4 - PHP : phpactor does not recognize standards PHP functions and classes Jan 3, 2025
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

1 participant