kubotak-is/php-del

Tool to remove code based on specific comments.

0.6.0 2021-12-23 15:36 UTC

This package is auto-updated.

Last update: 2021-12-23 15:37:03 UTC


README

Unit Test Latest Stable Version PHP Version Require License

Tool to remove code based on specific comments.

Install

composer require --dev kubotak-is/php-del

Configuration

Create php-del.json in the root directory of the project

{
  "dirs": [
    "src"
  ],
  "extensions": [
    "php"
  ]
}

dirs

Specify the directory to be searched for files.

extensions(Optional: Default php)

Specify the extension to be searched.

Usage

Add a comment with a flag for code like the following

public function code() {
    /** php-del start flag-a */
    $something = 1;
    /** php-del end flag-a */
}

Run php-del from composer command.

/vendor/bin/php-del

Select the flag and enter to perform the deletion.

Finding flag...
Please choice me one of the following flag: (press <Enter> to select)
  ○ flag-a (1)  

Deletion result

public function code() {
}

One Line code delete

To delete only one line.

use Hoge\Fuga\Piyo; // php-del line flag-a

Codes not covered

The ignore comment can be added to remove it from the deletion list.

public function code() {
    /** php-del start flag-a */
    $something = 1;
    /** php-del ignore start */
    $ignore = 2;
    /** php-del ignore end */
    /** php-del end flag-a */
}

Deletion result

public function code() {
    $ignore = 2;
}

File delete

Deletes the file itself by adding a file deletion comment.

<?php

/**
 * php-del file flag-a
 */
class DeleteClass {}