Skip to content

Instantly share code, notes, and snippets.

@keevitaja
Last active March 22, 2019 17:35
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save keevitaja/94ec7edcb1322d3a44bb to your computer and use it in GitHub Desktop.
Save keevitaja/94ec7edcb1322d3a44bb to your computer and use it in GitHub Desktop.
[
{
"command": "escape"
},
{
"command": "expand_selection",
"args": {"to": "word"}
},
{
"command": "copy"
},
{
"command": "run_macro_file",
"args": {"file": "res://Packages/Default/Add Line Before.sublime-macro"}
},
{
"args": {"characters": "protected $"},
"command": "insert"
},
{
"command": "paste"
},
{
"args": {"characters": ";\n"},
"command": "insert"
},
{
"command": "move",
"args": {"by": "lines", "forward": true}
},
{
"command": "move",
"args": {"by": "lines", "forward": true}
},
{
"command": "move_to",
"args": {"to": "brackets"}
},
{
"command": "run_macro_file",
"args": {"file": "res://Packages/Default/Add Line Before.sublime-macro"}
},
{
"args": {"characters": "$this->"},
"command": "insert"
},
{
"command": "paste"
},
{
"args": {"characters": " = $"},
"command": "insert"
},
{
"command": "paste"
},
{
"args": {"characters": ";"},
"command": "insert"
},
{
"command": "move",
"args": {"by": "lines", "forward": true}
},
{
"command": "move_to",
"args": {"to": "brackets"}
},
{
"command": "move",
"args": {"by": "lines", "forward": false}
},
{
"command": "move_to",
"args": {"to": "eol", "extend": false}
},
{
"command": "move",
"args": {"by": "characters", "forward": false}
}
]
@rawaludin
Copy link

Whooaa.. I like this one.. :)

Anyway, I have 2 suggestion:

  1. What if user type-hint the parameter type like this
public function __construct(App\Meteor $meteor)

Is it possible to add a docblock comment on the resulting property? like this:

/** @var App\Meteor [description] */
protected $meteor;
  1. Is it possible to use multiple constructor parameter? Like this one:
public function __construct(App\Meteor $meteor, App\Star $star, App\Moon $moon)

In current condition, I need to press the keystroke on each parameter to create initialization. It would be very nice if I just need to press the key stroke once and generate initialization for each parameter automatically. Thanks! :)

@vitorf7
Copy link

vitorf7 commented Nov 19, 2015

Hi,
I was trying to use your macro and it works correctly on a one line constructor, but it seems to have problems if you have something like this:

    public function __construct(
        User $user,
        UserTransformer $userTransformer
    ) {

    }

Once you have that and run the macro you end up with this:

    public function __construct(
        protected $user;

        User $user,
        UserTransformer $userTransformer
        $this->user = $user;
    ) {

    }

Do you know how we could fix this? Thank you so much for your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment