npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yaegassy/coc-intelephense

v0.30.4

Published

intelephense (php language server) extension for coc.nvim

Downloads

287

Readme

coc-intelephense

fork from a bmewburn/vscode-intelephense | PHP Intelephense and more feature.

intelephense (PHP language server) extension for coc.nvim. intelephense's various LSP features and this extension's additional features are available.

Install

CocInstall:

:CocInstall @yaegassy/coc-intelephense

scoped packages

vim-plug:

Plug 'yaegassy/coc-intelephense', {'do': 'yarn install --frozen-lockfile'}

Enabling the PREMIUM feature

Prepare a licence.txt file containing the licence key and place it in a designated location.

$ node -e "console.log(os.homedir() + '/intelephense/licence.txt')"
/Users/username/intelephense/licence.txt

[DEPRECATED]: Or set intelephense.licenceKey in "coc-settings.json"

{
  // ...snip
  "intelephense.licenceKey": "LICENCEKEYSAMPLE",
  // ...snip
}

For more information, please check this link.

[RECOMMENDED] Additional installation of "watchman"

In the intelephense used by coc-intelephense, it utilizes the workspace/didChangeWatchedFiles notification to watch files within the project.

In coc.nvim, it is recommended to install watchman in order to utilize this feature.

If you have difficulty installing watchman, you can use coc-intelephense without watchman, but you may not be able to immediately use intelephense's IntelliSense with the newly added files.

In this case, please execute the command to restart the language server.

  • :CocRestart

workspaceFolders

Depending on the project like mono repo or how Vim/Neovim is started, workspaceFolders may not be recognized correctly.

To make coc.nvim recognize workspaceFolders correctly, you can set b:coc_root_patterns in .vimrc/init.vim

Example:

  au FileType php let b:coc_root_patterns = ['.git', '.env', 'composer.json', 'artisan']

For more information, check this coc.nvim's wiki.

Configuration options

For additional feature of coc-intelephese:

  • intelephense.enable: Enable coc-intelephense extension, default true
  • intelephense.path: Path to intelephense module. ~ and $HOME, etc. can also be used. If there is no setting, the built-in module will be used. e.g. /path/to/node_modules/intelephense. default: ""
  • intelephense.client.diagnosticsIgnoreErrorFeature: Whether to enable the PHPDoc tag (// @intelephense-ignore-line, /** @intelephense-ignore-next-line */) feature and ignore errors, default: false | DEMO
  • intelephense.client.autoCloseDocCommentDoSuggest: When /** is entered, */ is automatically inserted (/**| */). Then, automatically display the completion menu of PHPDoc comments, default: true | DEMO
  • intelephense.client.disableScaffoldCompletion: Disable scaffold completion (client). Typing class_scaffold, interface_scaffold, trait_scaffold, enum_scaffold or test_scaffold will output completion suggestions. This completion feature will only work on the first line of the file, default: false | DEMO
  • intelephense.client.disableSnippetsCompletion: Disable snippets completion only (client), default: false
  • intelephense.client.snippetsCompletionExclude: Exclude specific prefix in snippet completion, e.g. ["class", "fun"], default: []
  • intelephense.client.disableCodeLens: Disable code lens only (client), default: false
  • intelephense.client.codelensProvider: Provider for CodeLens. Possible options include phpunit and pest, default: "phpunit"
  • intelephense.client.disableInlayHints: Disable inlay hints only (client), default: true
  • intelephense.client.disableAddIskeyword: Disable the feature of the extension to add iskeyword, default: false
  • intelephense.server.disableCompletion: Disable completion only (server), default: false
  • intelephense.server.disableDefinition: Disable definition only (server), default: false
  • intelephense.composer.path: Path to composer command. default: composer
  • intelephense.composer.runCommandList: Set the subcommand of the composer you want to execute, default: ["dump-autoload", "clear-cache", "install", "update"]
  • intelephense.composer.runCommandPlusList: Set the subcommand of the composer you want to execute. Additional strings can be entered and executed in the subcommand. default: ["require", "require --dev", "remove", "remove --dev", "update"]
  • intelephense.composer.enableSplitRight: Use vertical belowright for composer terminal window, default: false
  • intelephense.artisan.withoutArgumentsCommandList: List of commands to quickly execute intelephense.artisan.runCommand or intelephense.sailArtisan.runCommand without prompting for arguments or options, e.g. ["route:list", "clear-compiled"], default: []
  • intelephense.artisan.enableSplitRight: Use vertical belowright for artisan terminal window, default: false
  • intelephense.symfony.withoutArgumentsCommandList: List of commands to quickly execute intelephense.symfony.runCommand without prompting for arguments or options, default: []
  • intelephense.symfony.enableSplitRight: Use vertical belowright for symfony terminal window, default: false
  • intelephense.phpunit.path: Path to phpunit command. If there is no setting, the vendor/bin/phpunit will be used, default: ""
  • intelephense.phpunit.colors: Use colors in output (--colors), default: false
  • intelephense.phpunit.debug: Display debugging information (--debug), default: false
  • intelephense.phpunit.useSail: To run sail phpunit instead of phpunit, default: false
  • intelephense.phpunit.codeLensTitle: CodeLens title. Can be changed to any display, default: ">> [Run PHPUnit]"
  • intelephense.phpunit.enableSplitRight: Use vertical belowright for phpunit terminal window, default: false
  • intelephense.pest.path: Path to Pest command. If there is no setting, the vendor/bin/pest will be used, default: ""
  • intelephense.pest.doNotCacheResult: Do not write test results to cache file (--do-not-cache-result), default: true
  • intelephense.pest.useSail: To run sail pest instead of pest, default: false
  • intelephense.pest.codeLensTitle: CodeLens title. Can be changed to any display, default: ">> [Run Pest]"
  • intelephense.pest.enableSplitRight: Use vertical belowright for pest terminal window, default: false
  • intelephense.inlineParameters.showDollarSign: Show the $ character before PHP parameter names, default: false
  • intelephense.progress.enable: Enable progress window for indexing, If false, display with echo messages, default: true | DEMO

Same configuration as vscode-intelephense:

  • intelephense.compatibility.correctForBaseClassStaticUnionTypes: Resolves 'BaseClass|static' union types to 'static' instead of 'BaseClass', default: true
  • intelephense.compatibility.correctForArrayAccessArrayAndTraversableArrayUnionTypes: Resolves 'ArrayAccess' and 'Traversable' implementations that are unioned with a typed array to generic syntax. eg 'ArrayAccessOrTraversable|ElementType[]' => 'ArrayAccessOrTraversable<mixed, ElementType>', default: true
  • intelephense.compatibility.preferPsalmPhpstanPrefixedAnnotations: Prefer @psalm- and @phpstan- prefixed @return, @var, @param tags when determining symbol types, default: false
  • intelephense.files.maxSize: Maximum file size in bytes, default: 5000000
  • intelephense.files.associations: Configure glob patterns to make files available for language server features. Inherits from files.associations, default: ["*.php", "*.phtml"]
  • intelephense.files.exclude: Configure glob patterns to exclude certain files and folders from all language server features. Inherits from files.exclude, default: ["**/.git/**", "**/.svn/**", "**/.hg/**", "**/CVS/**", "**/.DS_Store/**", "**/node_modules/**", "**/bower_components/**", "**/vendor/**/{Tests,tests}/**", "**/.history/**", "**/vendor/**/vendor/**"]
  • intelephense.stubs: Configure stub files for built in symbols and common extensions. The default setting includes PHP core and all bundled extensions, default: Omitted due to the large number of settings..., See configuration in package.json
  • intelephense.completion.insertUseDeclaration: Use declarations will be automatically inserted for namespaced classes, traits, interfaces, functions, and constants, default: true
  • intelephense.completion.fullyQualifyGlobalConstantsAndFunctions: Global namespace constants and functions will be fully qualified (prefixed with a backslash), default: false
  • intelephense.completion.triggerParameterHints: Method and function completions will include parentheses and trigger parameter hints, default: true
  • intelephense.completion.maxItems: The maximum number of completion items returned per request, default: 100
  • intelephense.completion.suggestObjectOperatorStaticMethods: PHP permits the calling of static methods using the object operator eg $obj->myStaticMethod();. If you would prefer not to have static methods suggested in this context then set this value to false, default: true
  • intelephense.format.enable: Enables formatting, default: true
  • intelephense.format.braces: Controls formatting style of braces, valid option "per", "allman", "k&r", default: per
  • intelephense.environment.documentRoot: The directory of the entry point to the application (directory of index.php). Can be absolute or relative to the workspace folder. Used for resolving script inclusion and path suggestions, default: null
  • intelephense.environment.includePaths: include paths (as individual path items) as defined in the include_path ini setting or paths to external libraries. Can be absolute or relative to the workspace folder. Used for resolving script inclusion and/or adding external symbols to folder, default: null
  • intelephense.environment.phpVersion: A semver compatible string that represents the target PHP version. Used for providing version appropriate suggestions and diagnostics. PHP 5.3.0 and greater supported, default: "8.3.0"
  • intelephense.environment.shortOpenTag: When enabled <? will be parsed as a PHP open tag. Defaults to true, default: true
  • intelephense.diagnostics.enable: Enables diagnostics, default: true
  • intelephense.diagnostics.run: Controls when diagnostics are run, valid option "onType", "onSave", default: "onType"
  • intelephense.diagnostics.embeddedLanguages: Enables diagnostics in embedded languages, default: true
  • intelephense.diagnostics.undefinedSymbols: DEPRECATED. Use the setting for each symbol category, default: true
  • intelephense.diagnostics.undefinedVariables: Enables undefined variable diagnostics, default: true
  • intelephense.diagnostics.undefinedTypes: Enables undefined class, interface and trait diagnostics, default: true
  • intelephense.diagnostics.undefinedFunctions: Enables undefined function diagnostics, default: true
  • intelephense.diagnostics.undefinedConstants: Enables undefined constant diagnostics, default: true
  • intelephense.diagnostics.undefinedClassConstants: Enables undefined class constant diagnostics, default: true
  • intelephense.diagnostics.undefinedMethods: Enables undefined method diagnostics, default: true
  • intelephense.diagnostics.undefinedProperties: Enables undefined property diagnostics, default: true
  • intelephense.diagnostics.unusedSymbols: Enables unused variable, private member, and import diagnostics, default: true
  • intelephense.diagnostics.unexpectedTokens: Enables unexpected token diagnostics, default: true
  • intelephense.diagnostics.duplicateSymbols: Enables duplicate symbol diagnostics, default: true
  • intelephense.diagnostics.argumentCount: Enables argument count diagnostics, default: true
  • intelephense.diagnostics.typeErrors: Enables diagnostics on type compatibility of arguments, property assignments, and return statements where types have been declared, default: true
  • intelephense.diagnostics.deprecated: Enables deprecated diagnostics, default: true
  • intelephense.diagnostics.languageConstraints: Enables reporting of various language constraint errors, default: true
  • intelephense.diagnostics.implementationErrors: Enables reporting of problems associated with method and class implementations. For example, unimplemented methods or method signature incompatibilities, default: true
  • intelephense.diagnostics.relaxedTypeCheck: This setting makes type checking less thorough by allowing contravariant (wider) types to also satisfy a type constraint. This is useful for projects that may have incomplete or innacurate typings. Set to false for more thorough type checks. When this setting is true, the noMixedTypeCheck setting is ignored, default: true
  • intelephense.diagnostics.noMixedTypeCheck: This setting turns off type checking for the mixed type. This is useful for projects that may have incomplete or innacurate typings. Set to false to make type checking more thorough by not allowing mixed to satisy any type constraint. This setting has no effect when relaxedTypeCheck is true, default: true
  • intelephense.runtime: Path to a Node.js executable. Use this if you wish to use a different version of Node.js, default: null
  • intelephense.maxMemory: Maximum memory (in MB) that the server should use. On some systems this may only have effect when runtime has been set. Minimum 256, default: null
  • intelephense.licenceKey: DEPRECATED. Don't use this, default: ""
  • intelephense.telemetry.enabled: Anonymous usage and crash data will be sent to Azure Application Insights, default: null
  • intelephense.rename.exclude: Glob patterns to exclude files and folders from having symbols renamed. Rename operation will fail if references and/or definitions are found in excluded files/folders, default: ["**/vendor/**"]
  • intelephense.rename.namespaceMode: Controls the scope of a namespace rename operation, valid option "single", "all", default: "single"
  • intelephense.references.exclude: Glob patterns matching files and folders that should be excluded from references search, default: ["**/vendor/**"]
  • intelephense.phpdoc.returnVoid: Adds @return void to auto generated phpdoc for definitions that do not return a value, default: true
  • intelephense.phpdoc.textFormat: Auto generated phpdoc is returned in {snippet, plain text}, valid option "snippet", "text", default: "snippet"
  • intelephense.phpdoc.classTemplate: An object that describes the format of generated class/interface/trait phpdoc. The following snippet variables are available: SYMBOL_NAME; SYMBOL_KIND; SYMBOL_TYPE; SYMBOL_NAMESPACE, default: See configuration in package.json
  • intelephense.phpdoc.propertyTemplate: An object that describes the format of generated property phpdoc. The following snippet variables are available: SYMBOL_NAME; SYMBOL_KIND; SYMBOL_TYPE; SYMBOL_NAMESPACE, default: See configuration in package.json
  • intelephense.phpdoc.functionTemplate: An object that describes the format of generated function/method phpdoc. The following snippet variables are available: SYMBOL_NAME; SYMBOL_KIND; SYMBOL_TYPE; SYMBOL_NAMESPACE, default: See configuration in package.json
  • intelephense.phpdoc.useFullyQualifiedNames: Fully qualified names will be used for types when true. When false short type names will be used and imported where appropriate. Overrides intelephense.completion.insertUseDeclaration, default: true
  • intelephense.codeLens.references.enable: Enable a code lens that shows a reference count and command to peek locations, default: false.
  • intelephense.codeLens.implementations.enable: Enable a code lens that shows an abstract and interface implementations count and command to peek locations, default: false
  • intelephense.codeLens.usages.enable: Enable a code lens that shows a trait usages count and command to peek locations, default: false
  • intelephense.codeLens.overrides.enable: Enable a code lens that shows method override count and command to peek locations, default: false
  • intelephense.codeLens.parent.enable: Enable a code lens that indicates if a method has a parent implementation and command to peek location, default: false
  • intelephense.trace.server: Traces the communication between VSCode and the intelephense language server, valid option "off", "messages", "verbose", default: "off"

Commands

Command List:

:CocCommand [CommandName]

e.g. :CocCommand intelephense.phpunit.projectTest

  • intelephense.index.workspace: Index workspace
  • intelephense.cancel.indexing: Cancel indexing
  • intelephense.composer.runCommand: Run selected composer command
  • intelephense.composer.runCommandPlus: Enter and run additional strings to the selected composer commands
  • intelephense.composer.runScriptsCommand: Run selected composer script
    • Select and run the script defined in the "scripts section" of composer.json. The pre-... and post-... event scripts are excluded from the list.
    • DEMO
  • intelephense.artisan.runCommand: Run Artisan command | DEMO
  • intelephense.sailArtisan.runCommand: Run Sail Artisan command
  • intelephense.symfony.runCommand: Run Symfony command
  • intelephense.phpunit.projectTest: Run PHPUnit for current project
  • intelephense.phpunit.fileTest: Run PHPUnit for current file
  • intelephense.phpunit.singleTest: Run PHPUnit for single (nearest) test
  • intelephense.pest.projectTest: Run Pest for current project
  • intelephense.pest.fileTest: Run Pest for current file
  • intelephense.pest.singleTest: Run Pest for single (nearest) test
  • intelephense.fixClassName: Fix class name based on file name | DEMO
  • intelephense.fixNamespace: Fix namespace based on the composer configuration | DEMO
  • intelephense.completeConstructor: Complete the assignments and add properties for an incomplete constructor | DEMO

Example of Vim command and key mapping:

Vim commands can be defined and executed or key mappings can be set and used.

" Quickly view a list of all coc.nvim commands
nnoremap <silent> <C-p> :<C-u>CocCommand<CR>

" Run PHPUnit for current project
command! -nargs=0 PHPUnit :call CocAction('runCommand', 'intelephense.phpunit.projectTest')

" Run PHPUnit for current file
command! -nargs=0 PHPUnitCurrent :call CocAction('runCommand', 'intelephense.phpunit.fileTest', ['%'])

" Run PHPUnit for single (nearest) test
nnoremap <leader>te :call CocAction('runCommand', 'intelephense.phpunit.singleTest')<CR>

CodeLens

Feature:

Test file for "PHPUnit" or "Pest", allowing execution of a single test method. CodeLens appears at the top of the test method.

coc-settings.json:

By default, codeLens.enable is set to false, which disables it.

Change the setting to true to enable it.

{
  "codeLens.enable": true
}

If you want to use "Pest", change the intelephense.client.codelensProvider setting to pest (default: phpunit).

{
  "intelephense.client.codelensProvider": "pest"
}

Example key mapping (CodeLens related):

nmap <silent> gl <Plug>(coc-codelens-action)

Code Actions

Example key mapping (Code Action related):

nmap <silent> ga <Plug>(coc-codeaction-line)
xmap <silent> ga <Plug>(coc-codeaction-selected)
nmap <silent> <leader>a <Plug>(coc-codeaction-cursor)
nmap <silent> gA <Plug>(coc-codeaction)

Code Actions (Client side):

  • Open 'php.net' for 'xxxx' | DEMO
  • Add @intelephense-ignore-line | DEMO
  • Add @intelephense-ignore-next-line | DEMO
  • Insert PHP Getter | DEMO
  • Insert PHP Setter | DEMO
  • Insert PHP Getter & Setter | DEMO
  • Change Visibility | DEMO
  • Remove all unused imports for "use" statetment | DEMO

Code Actions (Server side):

  • use NAMESPACE\...\CLASS
  • Implement all abstract methods for '...'
  • Add PHPDoc for '...'
  • and more...
    • Other code actions provided by the intelephehse language server

Inlay Hints (Client Base)

  • inlineParametersInlayHintsFeature | DEMO
    • By default, this feature is disabled
    • Set "intelephense.client.disableInlayHints" to false to use the feature.

Thanks

License

MIT


This extension is built with create-coc-extension