Alex
Alex

Reputation: 47

Is there an easy way (in PhpStorm) to wrap snippet of PHP code in PHPDoc?

Is there a way to copy some code and insert in into PHPDoc comment so that formatting remains the same?

I need to insert this snippet of code into phpcs for the function.

         [
            [
                '_is_forecast'  => true,
                '_is_fake_item'     => false,
                'humidity'          => 1.24,
                // ... other parameters
                'rain_intensity'    => 3,
                'timestamp'         => '2019-12-20 11:20 UTC',
            ],
            [
                '_is_forecast'  => true,
                '_is_fake_item'     => false,
                'humidity'          => 24.5,
                // ... other parameters
                'rain_intensity'    => 23,
                'timestamp'         => '2019-12-20 11:40 UTC',
            ],
        ];

so it then should look like this:

/**
 *
 *        [
 *            [
 *                '_is_forecast'  => true,
 *                '_is_fake_item'     => false,
 *                'humidity'          => 1.24,
 *                / ... other parameters
 *                'rain_intensity'    => 3,
 *                'timestamp'         => '2019-12-20 11:20 UTC',
 *            ],
 *            [
 *                '_is_forecast'  => true,
 *                '_is_fake_item'     => false,
 *                'humidity'          => 24.5,
 *                / ... other parameters
 *                'rain_intensity'    => 23,
 *                'timestamp'         => '2019-12-20 11:40 UTC',
 *            ],
 *        ];
 *
 * @return array
 */
public function groupByParams()
{
   return [];
}

Upvotes: 2

Views: 264

Answers (3)

Mike Doe
Mike Doe

Reputation: 17624

Usually I select the block of the text I want to comment and press CTRL + / or CTRL + SHIFT + / depending upon the comment type I want to get.

PHPStorm will apply the comment based on the type of the file you are currently editing.

You un-comment the block using the same keystroke combination.

enter image description here

Upvotes: 2

Olawale
Olawale

Reputation: 751

You can use the Comment with Block Comment from the Code menu, in the menu bar

Upvotes: 0

Sunny Danu
Sunny Danu

Reputation: 77

You can use live template of PHPStrom ctr+alt+s open setting. search live template. and create your template. and set small abbreviations for that then you can easily access anywhere that template. or in your case commented code. in file. by just using. ctr+j select your abbreviation.

Upvotes: 0

Related Questions