ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

PHP Constructors

by jltorresm ST2/ST3

Sublime plugin to auto generate PHP constructors based on the class attributes

Details

Installs

  • Total 19K
  • Win 13K
  • OS X 2K
  • Linux 3K
Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12
Windows 0 8 7 4 6 4 9 6 16 9 4 9 5 13 0 6 5 2 9 7 4 9 10 6 8 6 7 10 7 6 10 4 3 10 8 11 12 8 10 10 14 18 9 12 5 7
OS X 0 1 0 0 0 1 0 1 2 1 0 0 0 1 0 0 1 1 0 1 0 1 1 1 1 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 3 0 2 1 1 0
Linux 1 9 1 1 3 0 1 2 2 3 1 1 1 2 0 0 2 0 0 1 0 3 0 2 2 2 2 3 2 2 1 0 2 2 1 2 1 2 2 1 4 3 2 2 1 1

Readme

Source
bitbucket.​org

PHP Constructors

PHP Constructors generates for you PHP Classes constructors.

Features:

  • Generate class constructor
  • Description, type and var name automatically discovered from the variable docblock.

Usage Instruction:

  1. Write your class properties inside your PHP class:
class test
{
    /**
     * @var my\long\namespace Var that holds foo
     */
    private $foo;
}
  1. Go to Tools -> PHP Constructor
  2. Constructor will be generated
class test
{
    /**
     * @var my\long\namespace Var that holds foo
     */
    private $foo;

    /**
     * Class Constructor
     * @param my\long\namespace   $foo    Var that holds foo
     */
    public function __construct($foo)
    {
        $this->foo = $foo;
    }
}

Take sometime to document your class properties with the following format:

class test
{
    /**
     * @var varType Description of the var
     */
    private $foo;
}

Commands

Commands available are:

  • Generate Constructor for Class

This option can be accessed via the contextual menu (right click) or on the command palette.

Available Settings

optional_constructor_params

type : boolean

default: false

description: If set to true generated constructor will be generated with optional parameters.