コード例 #1
0
 /**
  * Matches the url against the given page.
  *
  * @param string $url  The URL.
  * @param Page   $page Page to match.
  *
  * @return boolean
  */
 public function match($url, Page $page)
 {
     foreach ($this->matchers as $page_url_matcher) {
         $annotation_name = '@' . $page_url_matcher->getAnnotationName();
         $annotations = $this->annotationManager->getClassAnnotations($page, $annotation_name);
         if (!$annotations) {
             continue;
         }
         $this->ensureAnnotationsAreValid($annotations, $annotation_name);
         if ($page_url_matcher->matches($url, $annotations)) {
             return true;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Property.php プロジェクト: qa-tools/qa-tools
 /**
  * Returns annotations defined at property or in class, set in `@var` annotation of a property.
  *
  * @param string $annotation_class Annotation name.
  *
  * @return IAnnotation[]
  */
 public function getAnnotationsFromPropertyOrClass($annotation_class)
 {
     $annotations = $this->getAnnotations($annotation_class);
     if (!$annotations) {
         $annotations = $this->annotationManager->getClassAnnotations($this->getDataType(), $annotation_class);
     }
     return $annotations;
 }
コード例 #3
0
ファイル: PageFactory.php プロジェクト: qa-tools/qa-tools
 /**
  * Initializes the page.
  *
  * @param Page $page Page to initialize.
  *
  * @return self
  */
 public function initPage(Page $page)
 {
     /* @var $annotations PageUrlAnnotation[] */
     $annotations = $this->annotationManager->getClassAnnotations($page, '@page-url');
     if (!$annotations || !$annotations[0] instanceof PageUrlAnnotation) {
         return $this;
     }
     $page->setUrlBuilder($this->urlFactory->getBuilder($this->urlNormalizer->normalize($annotations[0])));
     return $this;
 }
コード例 #4
0
 /**
  * Initializes the page.
  *
  * @param Page $page Page to initialize.
  *
  * @return self
  */
 public function initPage(Page $page)
 {
     /* @var $annotations PageUrlAnnotation[] */
     $annotations = $this->annotationManager->getClassAnnotations($page, '@page-url');
     if (empty($annotations)) {
         return $this;
     }
     $page->setUrlBuilder($this->urlBuilderFactory->getUrlBuilder($annotations[0]->url, $annotations[0]->params, $this->config->getOption('base_url')));
     return $this;
 }
コード例 #5
0
ファイル: Phprtest.php プロジェクト: yegortokmakov/phprtest
 protected function getLimits($testClassName, $methodName)
 {
     /** @var \Phprtest\Annotations\AssertAnnotation $annotations */
     $annotations = $this->annotations->getMethodAnnotations($testClassName, $methodName, '@assert');
     $limits = array();
     if (count($annotations)) {
         foreach ($annotations as $annotation) {
             $limits[$annotation->metric] = array('softLimit' => $annotation->softLimit, 'hardLimit' => $annotation->hardLimit);
         }
     }
     return $limits;
 }
コード例 #6
0
 protected function testOrphanedAnnotationsAreIgnored()
 {
     $manager = new AnnotationManager();
     $manager->namespace = 'mindplay\\test\\Sample';
     $manager->cache = false;
     /** @var Annotation[] $annotations */
     $annotations = $manager->getMethodAnnotations('mindplay\\test\\Sample\\OrphanedAnnotations', 'someMethod');
     $this->check(count($annotations) == 1, 'the @return annotation was found');
     $this->check($annotations[0] instanceof ReturnAnnotation, 'the @return annotation has correct type');
 }