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 17K
  • Win 12K
  • OS X 2K
  • Linux 3K
Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30
Windows 2 19 12 10 15 7 11 9 5 8 10 6 6 12 11 9 11 20 12 12 6 13 7 17 9 13 9 5 9 12 13 8 12 8 9 12 12 7 6 11 6 10 11 19 10 18
OS X 0 0 1 2 1 1 0 3 0 1 1 2 2 2 0 1 0 0 1 1 2 0 0 1 0 1 1 0 1 1 0 2 1 1 1 1 3 2 1 1 1 2 2 3 1 1
Linux 0 3 2 6 2 2 1 1 0 1 1 1 3 1 1 1 2 1 1 1 2 0 2 4 2 2 3 0 2 3 2 4 0 3 5 3 3 0 2 4 0 0 4 5 4 3

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.