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

PHP Constructors

by jltorresm ST2/ST3 Trending

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

Details

Installs

  • Total 14K
  • Win 10K
  • OS X 1K
  • Linux 3K
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 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5
Windows 12 11 25 10 17 18 19 7 7 13 14 7 10 7 8 6 12 9 14 8 9 5 9 8 10 11 18 13 7 6 15 7 16 18 15 10 8 12 10 14 15 14 6 9 16 11
OS X 0 1 5 1 0 3 1 1 0 3 2 2 2 2 0 1 1 1 0 3 0 1 0 1 1 0 4 2 0 0 2 2 0 2 2 0 0 2 0 1 0 0 0 2 3 0
Linux 1 3 4 2 1 5 4 3 1 5 3 4 3 3 3 3 3 2 0 1 6 0 2 3 5 6 4 2 0 3 5 2 3 1 5 0 2 0 6 1 0 1 1 3 4 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.