yuseflockwood/phpdoc-stripper

A CLI tool to remove PHPDoc comments from PHP files recursively.

dev-main 2025-02-17 19:19 UTC

This package is auto-updated.

Last update: 2025-06-17 19:57:19 UTC


README

A simple CLI tool to recursively remove PHPDoc comments from PHP files.

👥 Installation

Global Installation (Recommended)

To install the tool globally using Composer:

composer global require yuseflockwood/phpdoc-stripper

Project-Based Installation

If you want to use it within a specific project:

composer require yuseflockwood/phpdoc-stripper --dev

🚀 Usage

Run the Tool on a Directory

To remove all PHPDoc comments in a specific directory, run:

phpdoc-stripper -d /path/to/project

If no directory is specified, it defaults to the current working directory.

Example:

phpdoc-stripper

(This will run in the directory where the command is executed.)

⚙️ How It Works

  • The script recursively scans all PHP files in the given directory.
  • It removes PHPDoc comments (/** ... */) while leaving normal code and comments (// or /* ... */) intact.
  • Modifies files in place, so ensure you have backups before running!

📝 Example

Before running phpdoc-stripper:

<?php

/**
 * This function adds two numbers.
 *
 * @param int $a The first number.
 * @param int $b The second number.
 * @return int The sum of both numbers.
 */
function add($a, $b) {
  return $a + $b;
}

After running phpdoc-stripper:

<?php

function add($a, $b) {
  return $a + $b;
}

⚠️ Warning: Use with Caution

  • This tool permanently modifies files by stripping PHPDoc comments.
  • Backup your project before running, or use version control.

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.