PHPackages                             mizbanpaytakht/comment-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mizbanpaytakht/comment-manager

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mizbanpaytakht/comment-manager
==============================

Doc Block comment parser and method validator

v1.0.1(3y ago)017GPL-3.0-or-laterPHPPHP ^8.0

Since Mar 20Pushed 3y agoCompare

[ Source](https://github.com/mizbanpaytakht/comment-manager)[ Packagist](https://packagist.org/packages/mizbanpaytakht/comment-manager)[ RSS](/packages/mizbanpaytakht-comment-manager/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (0)

### Introduction

[](#introduction)

The Comment Manager is a Php script that allows parsing method [Doc Block comments](https://en.wikipedia.org/wiki/PHPDoc). It also allows validating parameter values and return values using information in the Doc Block comments.

### Features

[](#features)

1. ##### **Method parameter validation**

    [](#method-parameter-validation)

    If you have added the following comment to a menthod:

    ```
    @param string $my_param [val1,val2,val3]
    ```

    Then the Comment Manager script can be used to check if the value given for the parameter, $my\_param is in the list val1,val2,val3.

    The script can validate range of numbers, parameter types, lists, emails, json and arrays. Method return values can also be validated based on information in DocBlock comments
2. ##### **Extracting method description**

    [](#extracting-method-description)

    The Comment Manager script can be used to extract the description text given in method Doc Bloc comments. Long and short method description can be extracted
3. ##### **Validating method context**

    [](#validating-method-context)

    The Comment Manager script can be used to check if a class method is being called from the command line, from browser, as an API function or test function etc, based on information in the [@internal tag](http://docs.phpdoc.org/references/phpdoc/tags/internal.html)
4. ##### **Custom Validation**

    [](#custom-validation)

    The Comment Manager script allows validating parameter values using custom validation functions
5. ##### **Supported tags**

    [](#supported-tags)

    Currently the Comment Manager script can be used to extract the following tags from DocBloc comments: [@param](http://docs.phpdoc.org/references/phpdoc/tags/param.html), [@version&gt;](http://docs.phpdoc.org/references/phpdoc/tags/version.html), [@internal](http://docs.phpdoc.org/references/phpdoc/tags/internal.html), [@return](http://docs.phpdoc.org/references/phpdoc/tags/return.html) and the [long and short method description](http://docs.phpdoc.org/guides/docblocks.html#description).

    The Comment Manager script can be easily extended to extract other tags from method comments
6. ##### **Use in MVC frameworks**

    [](#use-in-mvc-frameworks)

    The Comment Manager package can be used in MVC (Model View Controller) frameworks for performing automatic validation of method parameters based on information in the method Doc Block comments
7. ##### **PSR Standard**

    [](#psr-standard)

    The Comment Manager package code is compliant with the [PSR-2 coding style](https://www.php-fig.org/psr/psr-2/)

### Example Use

[](#example-use)

##### **Example 1**

[](#example-1)

The following example shows how to call a function safely with parameter and return value validation:

```

/** The safe_function_caller closure is fetched from the CommentManager class */
$safe_function_caller       = CommentManager::GetClosure();
/** The parameters for the test function */
$parameters                 = array(
                                  "number1" => 30,
                                  "number2" => 10,
                                  "number3" => 10,
                                   "data" => array(
                                                 "type" => "integer",
                                                  "random_string" => "The result of adding the three integers is: ";
                                            )
                              );

/** The function that provides custom validation for the test function parameters */
$validation_callback        = array($this, "CustomValidation");

/** The callback */
$callback                   = array(
                                  "class_name" => get_class(),
                                  "class_object" => $this,
                                  "function_name" => "AddNumbers",
                                  "parameters" => $parameters,
                                  "context" => "cli"
                              );
try {
   /** The test function is called through the safe function caller */
   $result                  = $safe_function_caller($callback, $validation_callback);
}
catch (\Error $e) {
    /** The error message is displayed and the script ends */
    die($e->getMessage());
}

/** The result of adding the numbers is displayed */
echo $result['random_string'] . $result['sum'];

```

In the above exampe, **CustomValidation** is a user defined function that performs custom validation. **AddNumbers** is the function to validate. It takes 3 numbers and a random string as parameters. It returns the random string as it is and also the sum of the three numbers. The custom validation function validates the return value by checking if the length of the random string is within range. The type and value of the parameters is checked by the Comment Manager classes. See the example file **CommentManagerTest.php** for the complete example.

##### **Example 2**

[](#example-2)

The following example shows how to extract method DocBlock comments:

```

/** The Parser class is included */
require("Parser.php");
/** An object of the parser class is created */
$parser = new Parser();
/** The method doc block comments are parsed */
$parsed_comments          = $parser->ParseMethodDocBlockComments($class_name, $function_name);
print_R($parsed_comments);

```

In the above example, $class name and $function\_name is the method to check. The following output is produced:

```

Array
(
    [description] => Array
        (
            [short] => This function adds the three numbers given as parameters.
                       It returns the sum of the numbers and a random string.
                       The random string is given as the last parameter
            [long] =>
        )

    [version] => Array
        (
            [since] =>
            [version] =>
        )

    [internal] => Array
        (
            [context] => cli
        )

    [parameters] => Array
        (
            [0] => Array
                (
                    [type] => int
                    [variable_name] => number1
                    [rule] => range
                    [description] => the first number
                    [rule_data] => 1-100
                )

            [1] => Array
                (
                    [type] => int
                    [variable_name] => number2
                    [rule] => range
                    [description] => the second number
                    [rule_data] => 1-100
                )

            [2] => Array
                (
                    [type] => int
                    [variable_name] => number3
                    [rule] => range
                    [description] => the third number
                    [rule_data] => 1-100
                )

            [3] => Array
                (
                    [type] => array
                    [variable_name] => data
                    [rule] =>
                    [description] => contains the type of the numbers and a string
                    [rule_data] =>
                    [values] => Array
                        (
                            [0] => Array
                                (
                                    [variable_name] => type
                                    [type] => string
                                    [rule] => list
                                    [rule_data] => integer,float
                                    [description] => the type of number to be added
                                )

                            [1] => Array
                                (
                                    [variable_name] => random_string
                                    [type] => string
                                    [rule] => custom
                                    [rule_data] =>
                                    [description] => a random string that is returned by the function
                                )

                        )

                )

        )

    [return_value] => Array
        (
            [type] => array
            [variable_name] => result
            [rule] =>
            [description] => the result of the function
            [rule_data] =>
            [values] => Array
                (
                    [0] => Array
                        (
                            [variable_name] => sum
                            [type] => int
                            [rule] => range
                            [rule_data] => 1-50
                            [description] => the sum of the three numbers
                        )

                    [1] => Array
                        (
                            [variable_name] => random_string
                            [type] => string
                            [rule] =>
                            [rule_data] =>
                            [description] => the random string
                        )

                )

        )

    [function_name] => AddNumbers
)

```

### List of files

[](#list-of-files)

The Comment Manager package consists of the following files:

- **CommentManager.php**. It provides a closure function for safe calling of class methods. It also provides functions for parsing and validating method parameters and return value
- **Parser.php**. It provides a single function for parsing all method DocBlock comments
- **DescriptionParser.php**. It provides functions for extracting long and short method description as well as the internal and version tags
- **ParameterParser.php**. It provides functions for parsing the **@param** tag
- **Validator.php**. It provides functions for validating method parameters and method return value using information in DocBloc comments
- **VariableValidator.php**. It provides functions for validating different types of variables. For example integer, string, boolean and arrays

### Installation

[](#installation)

1. ##### Install using composer:

    [](#install-using-composer)

    Run the command: **composer require nadirlc/comment-manager**

    **OR**
2. ##### Download from the [Comment Manager GitHub Repository](https://github.com/nadirlc/comment-manager)

    [](#download-from-the-comment-manager-github-repository)

    Run the command: **git clone **

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1488 days

Total

2

Last Release

1120d ago

PHP version history (2 changes)v1.0.0PHP ^7.2

v1.0.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/206930f1e4a086d995b1fdef9f0ce9a2bc76387e98111772d3d087bda853986e?d=identicon)[mizbanpaytakht](/maintainers/mizbanpaytakht)

---

Top Contributors

[![mizbanpaytakht](https://avatars.githubusercontent.com/u/2773653?v=4)](https://github.com/mizbanpaytakht "mizbanpaytakht (4 commits)")

---

Tags

commentsdoc blocparameter validation

### Embed Badge

![Health badge](/badges/mizbanpaytakht-comment-manager/health.svg)

```
[![Health](https://phpackages.com/badges/mizbanpaytakht-comment-manager/health.svg)](https://phpackages.com/packages/mizbanpaytakht-comment-manager)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
