Skip to content

pcyman/phptools.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

PhpTools

Useful lua functions for php development. Mostly for personal use.

Requirements

  • neovim 0.6+
  • treesitter with php grammar installed

Installation

Install the plugin using your favorite package manager. Packer example:

  use {'pcyman/phptools.nvim', ft = 'php'}

Run somewhere in your config:

require('phptools').setup()

Functions

Getter and setter generation

Generates getters and setters for property under cursor or for multiple properties (in visual mode)

Lua:

require'phptools.getset'.generate_getset() -- under cursor
require'phptools.getset'.generate_getset('v') --visual mode

Vim commands:

PhpToolsGetSet
PhpToolsGetSetVisual

Assumes properties have visibility and type specified:

    private string $name;

Empty unit test with mocks generation

Creates a unit test for currently open class with classes in constructor mocked.

Lua:

lua require'phptools.unitgen'.generate_test()

Vim commands:

PhpToolsGenTest

Assumptions:

  • assumes prophecy for mocking
  • assumes class is somewhere in the src directory in the project
  • assumes tests are somewhere in the tests directory in the project
  • assumes composer.json is located in the root of the working directory
  • assumes namespaces for the /src and /tests dirs are defined in composer.json

About

A set of helpful php tools for neovim

Topics

Resources

License

Stars

Watchers

Forks

Languages