PhpBench\Benchmark\Remote\Reflector::getParameterSets PHP Method

getParameterSets() public method

Return the parameter sets for the benchmark container in the given file.
public getParameterSets ( string $file, string[] $paramProviders ) : array
$file string
$paramProviders string[]
return array
    public function getParameterSets($file, $paramProviders)
    {
        $parameterSets = $this->launcher->payload(__DIR__ . '/template/parameter_set_extractor.template', ['file' => $file, 'class' => $this->getClassNameFromFile($file), 'paramProviders' => var_export($paramProviders, true)])->launch();
        // validate parameters
        $parameters = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($parameterSets));
        iterator_apply($parameters, function (\Iterator $iterator) {
            $parameter = $iterator->current();
            if (!is_scalar($parameter)) {
                throw new \InvalidArgumentException(sprintf('Parameter values must be scalar. Got "%s"', is_object($parameter) ? get_class($parameter) : gettype($parameter)));
            }
        }, [$parameters]);
        return $parameterSets;
    }

Usage Example

Example #1
0
 /**
  * Return a Benchmark instance for the given file or NULL if the
  * given file contains no classes, or the class in the given file is
  * abstract.
  *
  * @param string $file
  *
  * @return Benchmark
  */
 public function getMetadataForFile($file)
 {
     $hierarchy = $this->reflector->reflect($file);
     if ($hierarchy->isEmpty()) {
         return;
     }
     if ($hierarchy->getTop() && true === $hierarchy->getTop()->abstract) {
         return;
     }
     $metadata = $this->driver->getMetadataForHierarchy($hierarchy);
     $this->validateBenchmark($hierarchy, $metadata);
     // validate the subject and load the parameter sets
     foreach ($metadata->getSubjects() as $subject) {
         $this->validateSubject($hierarchy, $subject);
         $paramProviders = $subject->getParamProviders();
         $parameterSets = $this->reflector->getParameterSets($metadata->getPath(), $paramProviders);
         foreach ($parameterSets as $parameterSet) {
             if (!is_array($parameterSet)) {
                 throw new \InvalidArgumentException(sprintf('Each parameter set must be an array, got "%s" for %s::%s', gettype($parameterSet), $metadata->getClass(), $subject->getName()));
             }
         }
         $subject->setParameterSets($parameterSets);
     }
     return $metadata;
 }
All Usage Examples Of PhpBench\Benchmark\Remote\Reflector::getParameterSets