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

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.