Adds a new method to the class using an array of tokens.

@param ClassReflection $class     Class reflection
@param string          $methodTag Method tag contents

@return bool
14952
protected function injectMethod(ClassReflection $class, $methodTag)
    {
        $data = $this->parseMethod($methodTag);

        // Bail if the method format is invalid
        if (!$data) {
            return false;
        }

        $method = new MethodReflection($data['name'], $class->getLine());
        $method->setDocComment($data['description']);
        $method->setShortDesc($data['description']);

        if ($data['hint']) {
            $method->setHint(array(array($data['hint'], null)));
        }

        // Add arguments to the method
        foreach ($data['args'] as $name => $arg) {
            $param = new ParameterReflection($name, $class->getLine());
            if (!empty($arg['hint'])) {
                $param->setHint(array(array($arg['hint'], null)));
            }
            if (!empty($arg['default'])) {
                $param->setDefault($arg['default']);
            }
            $method->addParameter($param);
        }

        $class->addMethod($method);

        return true;
    }
984753
public function addElementsClass($class) {
		foreach ($this->getElements() as $element) {
			if ($element instanceof Tag) {
				$element->addClass($class);
			}
		}
		
		return $this;
	}
586399
public function setService(IPReflectionClass $class)
    {
        $this->services[$class->classname] = $class;
        $this->services[$class->classname]->getMethods(false, false);
    }
1097489
protected function reflectClass($className)
    {
        $class = new ClassReflection($className);
        $this->reflectedClassNames[$className] = time();
        foreach ($class->getTagsValues() as $tag => $values) {
            if (array_search($tag, $this->ignoredTags) === false) {
                $this->taggedClasses[$tag][] = $className;
                $this->classTagsValues[$className][$tag] = $values;
            }
        }
        foreach ($class->getProperties() as $property) {
            $propertyName = $property->getName();
            $this->classPropertyNames[$className][] = $propertyName;
            foreach ($property->getTagsValues() as $tag => $values) {
                if (array_search($tag, $this->ignoredTags) === false) {
                    $this->propertyTagsValues[$className][$propertyName][$tag] = $values;
                }
            }
        }
        foreach ($class->getMethods() as $method) {
            $methodName = $method->getName();
            foreach ($method->getTagsValues() as $tag => $values) {
                if (array_search($tag, $this->ignoredTags) === false) {
                    $this->methodTagsValues[$className][$methodName][$tag] = $values;
                }
            }
            foreach ($method->getParameters() as $parameterPosition => $parameter) {
                $this->methodParameters[$className][$methodName][$parameter->getName()] = $this->convertParameterReflectionToArray($parameter, $parameterPosition, $method);
            }
        }
        ksort($this->reflectedClassNames);
        $this->dataCacheNeedsUpdate = true;
    }
457142
protected function buildMethod(ReflectionMethod $reflectionMethod) : Node\Stmt\ClassMethod
    {
        $methodBuilder = new Method($reflectionMethod->getName());

        if ($reflectionMethod->isPublic()) {
            $methodBuilder->makePublic();
        }

        if ($reflectionMethod->isProtected()) {
            $methodBuilder->makeProtected();
        }

        if ($reflectionMethod->isPrivate()) {
            $methodBuilder->makePrivate();
        }

        if ($reflectionMethod->isStatic()) {
            $methodBuilder->makeStatic();
        }

        if ($reflectionMethod->isAbstract()) {
            $methodBuilder->makeAbstract();
        }

        if ($reflectionMethod->isFinal()) {
            $methodBuilder->makeFinal();
        }

        if ($reflectionMethod->returnsReference()) {
            $methodBuilder->makeReturnByRef();
        }

        foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
            $methodBuilder->addParam($this->buildParameter($reflectionParameter));
        }

        // @todo should parse method body if possible (skipped for now)

        return $methodBuilder->getNode();
    }
440458
private function adjustOriginalClass(
        ReflectionClass $class,
        array $advices,
        StreamMetaData $streamMetaData,
        string $newClassName
    ): void {
        $classNode = $class->getNode();
        $position  = $classNode->getAttribute('startTokenPos');
        do {
            if (isset($streamMetaData->tokenStream[$position])) {
                $token = $streamMetaData->tokenStream[$position];
                // Remove final and following whitespace from the class, child will be final instead
                if ($token[0] === T_FINAL) {
                    unset($streamMetaData->tokenStream[$position], $streamMetaData->tokenStream[$position+1]);
                }
                // First string is class/trait name
                if ($token[0] === T_STRING) {
                    $streamMetaData->tokenStream[$position][1] = $newClassName;
                    // We have finished our job, can break this loop
                    break;
                }
            }
            ++$position;
        } while (true);

        foreach ($class->getMethods(ReflectionMethod::IS_FINAL) as $finalMethod) {
            if (!$finalMethod instanceof ReflectionMethod || $finalMethod->getDeclaringClass()->name !== $class->name) {
                continue;
            }
            $hasDynamicAdvice = isset($advices[AspectContainer::METHOD_PREFIX][$finalMethod->name]);
            $hasStaticAdvice  = isset($advices[AspectContainer::STATIC_METHOD_PREFIX][$finalMethod->name]);
            if (!$hasDynamicAdvice && !$hasStaticAdvice) {
                continue;
            }
            $methodNode = $finalMethod->getNode();
            $position   = $methodNode->getAttribute('startTokenPos');
            do {
                if (isset($streamMetaData->tokenStream[$position])) {
                    $token = $streamMetaData->tokenStream[$position];
                    // Remove final and following whitespace from the method, child will be final instead
                    if ($token[0] === T_FINAL) {
                        unset($streamMetaData->tokenStream[$position], $streamMetaData->tokenStream[$position+1]);
                        break;
                    }
                }
                ++$position;
            } while (true);
        }
    }
78928
public function setTagMap(int $class, array $map)
    {
        if (isset($this->tagMap[$class])) {
            $this->tagMap[$class] = $map;
        }

        return $this;
    }
1255625
public function add($class=null)
	{
		$class = $this->get_class($class);

		if (!isset($this->reflections[$class]))
			$this->reflections[$class] = new ReflectionClass($class);
			
		return $this;
	}
920290
public function addComponents(array $class, $append_to_tag = 'class')
    {
        foreach ($class as $key => $value) {
            if (is_array($value)) {
                continue;
            }
            if ($value === true) {
                $this->template->append($append_to_tag, ' atk-'.$key);
                continue;
            }
            $this->template->append($append_to_tag, ' atk-'.$key.'-'.$value);
        }

        return $this;
    }
1242467
public function add(
        $tag,
        $controllerClass
    )
    {
        // Add shortcode support for widgets
        add_shortcode($tag, function ($tagAttributes, $tagContent = null) use ($tag, $controllerClass) {

            $attributes = array(
                'tag' => $tag,
                'parameters' => (is_array($tagAttributes) ? $tagAttributes : array()),
                'content' => $tagContent,
            );


            $this->plugin->when($controllerClass)
                ->needs('$attributes')
                ->give(function() use ($attributes){
                	return $attributes;
                });

	        ob_start();
	            $this->plugin->make($controllerClass);
            return ob_get_clean();
        });
    }
748042
public function addTag(TagInterface $tag)
    {
        if (!$this->tags->contains($tag)) {
            $this->tags->add($tag);
        }

        return $this;
    }
1232951
@SuppressWarnings("unchecked")
  public <T extends Tag<?>> List<T> getTags(Class<T> tagClass) {
    List<T> matches = new LinkedList<T>();
    Iterator<Tag<?>> tagIter = _tags.iterator();
    while (tagIter.hasNext()) {
      Tag<?> tag = tagIter.next();
      if (tagClass.isInstance(tag)) {
        matches.add((T)tag);
      }
    }
    return matches;
  }
950203
public static function withTag($tag)
    {
        $element = (new ReflectionClass(static::class))->newInstanceWithoutConstructor();

        $element->tag = $tag;
        $element->attributes = new Attributes();
        $element->children = new Collection();

        return $element;
    }
1254235
public function getAllMethods($tags = '*'): array
    {
        $a = [];
        /** @var ReflectionMethod $m */
        foreach ($this->class->getMethods() as $m) {
            $comment = $m->getDocComment();
            $a = array_merge($a, [$m->name => $this->parse($comment, $tags)]);
        }
        return $a;
    }
519772
public function isMethodPrivate($className, $methodName)
    {
        $className = $this->prepareClassReflectionForUsage($className);
        return (isset($this->classReflectionData[$className][self::DATA_CLASS_METHODS][$methodName][self::DATA_METHOD_VISIBILITY]) && $this->classReflectionData[$className][self::DATA_CLASS_METHODS][$methodName][self::DATA_METHOD_VISIBILITY] === self::VISIBILITY_PRIVATE);
    }
905359
public function addTag(Tag $tag)
    {
        // Add tag if not existing
        if (!$this->hasTag($tag)) {
            $this->tags[$tag->getTag()] = $tag;
        }

        // Increment counter if no override in the Tag entity
        if ($tag->getCounter() === null) {
            $tag->incCounter();
        }

        // Store the max counter
        if ($tag->getCounter() > $this->max) {
            $this->max = $tag->getCounter();
        }

        return $this;
    }
10275
@DefaultVisibilityForTesting
  static TagsComponent loadTagsComponent(@Nullable ClassLoader classLoader) {
    try {
      // Call Class.forName with literal string name of the class to help shading tools.
      return Provider.createInstance(
          Class.forName(
              "io.opencensus.impl.tags.TagsComponentImpl", /*initialize=*/ true, classLoader),
          TagsComponent.class);
    } catch (ClassNotFoundException e) {
      logger.log(
          Level.FINE,
          "Couldn't load full implementation for TagsComponent, now trying to load lite "
              + "implementation.",
          e);
    }
    try {
      // Call Class.forName with literal string name of the class to help shading tools.
      return Provider.createInstance(
          Class.forName(
              "io.opencensus.impllite.tags.TagsComponentImplLite",
              /*initialize=*/ true,
              classLoader),
          TagsComponent.class);
    } catch (ClassNotFoundException e) {
      logger.log(
          Level.FINE,
          "Couldn't load lite implementation for TagsComponent, now using "
              + "default implementation for TagsComponent.",
          e);
    }
    return NoopTags.newNoopTagsComponent();
  }