Tool to remove code based on specific comments.
composer require --dev kubotak-is/php-del
Create php-del.json in the root directory of the project
{
"dirs": [
"src"
],
"extensions": [
"php"
]
}
Specify the directory to be searched for files.
Specify the extension to be searched.
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() {
}
To delete only one line.
use Hoge\Fuga\Piyo; // php-del line flag-a
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;
}
Deletes the file itself by adding a file deletion comment.
<?php
/**
* php-del file flag-a
*/
class DeleteClass {}