PHP code example of abryb / parameter-info

1. Go to this page and download the library: Download abryb/parameter-info library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

abryb / parameter-info example snippets




use Abryb\ParameterInfo\ParameterInfoExtractorFactory;

$extractor = ParameterInfoExtractorFactory::create();

/**
 * @param object|null                          $a0 very object description. Important!
 * @param \DateInterval[]|\DateTime[]|iterable $a1
 */
$function = function ($a0, iterable $a1) {
    // ...
};

$parameters = $extractor->getMethodParameters(new \ReflectionFunction($function));

$parameters[0]->getDescription(); // very object description. Important!
$parameters[0]->getTypes()[0]->getBuiltinType(); // object
$parameters[0]->getTypes()[0]->isNullable(); // true
$parameters[0]->getTypes()[0]->getClassName(); // null
$parameters[0]->getTypes()[0]->isCollection(); // false

$parameters[1]->getTypes()[0]->getBuiltinType(); // iterable
$parameters[0]->getTypes()[0]->isCollection(); // true

$parameters[1]->getTypes()[0]->getCollectionValueType()->getClassName(); // DateTime

$parameters[1]->getTypes()[1]->getCollectionValueType()->getClassName(); // DateInterval