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

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.