kubotak-is / php-del
Tool to remove code based on specific comments.
Installs: 19 680
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 3
Forks: 0
Open Issues: 4
Requires
- php: >=8.0
- ext-mbstring: *
- league/climate: ^3.7
Requires (Dev)
- phpunit/phpunit: ^9.6
README
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 {}