Download the PHP package mizbanpaytakht/comment-manager without Composer

On this page you can find all versions of the php package mizbanpaytakht/comment-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package comment-manager

Introduction

The Comment Manager is a Php script that allows parsing method Doc Block comments. It also allows validating parameter values and return values using information in the Doc Block comments.

Features

  1. 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

    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

    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

  4. Custom Validation

    The Comment Manager script allows validating parameter values using custom validation functions

  5. Supported tags

    Currently the Comment Manager script can be used to extract the following tags from DocBloc comments: @param, @version>, @internal, @return and the long and short method description.

    The Comment Manager script can be easily extended to extract other tags from method comments

  6. 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

    The Comment Manager package code is compliant with the PSR-2 coding style

Example Use

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

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

The Comment Manager package consists of the following files:

Installation

  1. Install using composer:

    Run the command: composer require nadirlc/comment-manager

    OR

  2. Download from the Comment Manager GitHub Repository

    Run the command: git clone https://github.com/nadirlc/comment-manager.git


All versions of comment-manager with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mizbanpaytakht/comment-manager contains the following files

Loading the files please wait ....