getMetadataForHierarchy() public méthode

Return the metadata for the given class FQN.
public getMetadataForHierarchy ( ReflectionHierarchy $classHierarchy ) : Benchmark
$classHierarchy PhpBench\Benchmark\Remote\ReflectionHierarchy
Résultat Benchmark
Exemple #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;
 }
Exemple #2
0
 /**
  * Return a BenchmarkMetadata 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 BenchmarkMetadata
  */
 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->validateAbstractMetadata($hierarchy, $metadata);
     foreach (array('getBeforeClassMethods' => 'before class', 'getAfterClassMethods' => 'after class') as $methodName => $context) {
         foreach ($metadata->{$methodName}() as $method) {
             $this->validateMethodExists($context, $hierarchy, $method, true);
         }
     }
     // validate the subject and load the parameter sets
     foreach ($metadata->getSubjectMetadatas() as $subjectMetadata) {
         $this->validateAbstractMetadata($hierarchy, $subjectMetadata);
         $paramProviders = $subjectMetadata->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(), $subjectMetadata->getName()));
             }
         }
         $subjectMetadata->setParameterSets($parameterSets);
     }
     return $metadata;
 }