public function addMethodSelector(MethodSelector $selector) { if (empty($this->join['m'])) { $this->join['m'] = sprintf('INNER JOIN "meta_method" AS m ON (m."type" = e."ancestor" AND (e."length" = 0 OR (m."modifiers" & %u) = 0))', MetaInfo::IS_PRIVATE); $this->where[] = sprintf('(m."modifiers" & %u) = 0', MetaInfo::IS_STATIC); } $this->where[] = $selector->getMatcher()->applyMatcher('m."method"', $this->context); $vis = $selector->getVisibility(); if ($vis !== NULL) { $this->where[] = sprintf('m."modifiers" & %u', $vis); } $anno = $selector->getAnnotations(); if (!empty($anno)) { foreach ($anno as $a) { $alias = 'ma' . count($this->join); $this->join[$alias] = 'INNER JOIN "meta_method_annotation" AS ' . $alias; $this->join[$alias] .= ' ON (' . $alias . '."type" = m."type"'; $this->join[$alias] .= ' AND ' . $alias . '."method" = m."method")'; $matchers = $a->getMatchers(); $first = array_shift($matchers); $where = '(' . $first->applyMatcher($alias . '."annotation"', $this->context); foreach ($matchers as $matcher) { $where .= ' OR ' . $matcher->applyMatcher($alias . '."annotation"', $this->context); } $where .= ')'; $this->where[] = $where; } } }
public function buildQuery(QueryContext $context) { $selector = new MethodSelector($this->buildMatcher($this->namePattern)); if ($this->visibility != 0) { $selector->setVisibility($this->visibility); } foreach ($this->annotationFilters as $filter) { $matchers = []; foreach ($filter->getAnnotations() as $anno) { $matchers[] = $this->buildMatcher($anno); } $selector->addAnnotationSelector(new AnnotationSelector($matchers)); } $query = new Query($context); $query->addMethodSelector($selector); if ($this->typeMatcher !== NULL) { $query->addTypeSelector($this->typeMatcher->buildTypeSelector($context)); } return $query; }