You are here

class ExampleTag in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag/ExampleTag.php \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag

Reflection class for a @example tag in a Docblock.

@author Vasil Rangelov <boen.robot@gmail.com> @license http://www.opensource.org/licenses/mit-license.php MIT @link http://phpdoc.org

Hierarchy

  • class \phpDocumentor\Reflection\DocBlock\Tag implements \phpDocumentor\Reflection\DocBlock\Reflector
    • class \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
      • class \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag

Expanded class hierarchy of ExampleTag

File

vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag/ExampleTag.php, line 24

Namespace

phpDocumentor\Reflection\DocBlock\Tag
View source
class ExampleTag extends SourceTag {

  /**
   * @var string Path to a file to use as an example.
   *     May also be an absolute URI.
   */
  protected $filePath = '';

  /**
   * @var bool Whether the file path component represents an URI.
   *     This determines how the file portion appears at {@link getContent()}.
   */
  protected $isURI = false;

  /**
   * {@inheritdoc}
   */
  public function getContent() {
    if (null === $this->content) {
      $filePath = '';
      if ($this->isURI) {
        if (false === strpos($this->filePath, ':')) {
          $filePath = str_replace('%2F', '/', rawurlencode($this->filePath));
        }
        else {
          $filePath = $this->filePath;
        }
      }
      else {
        $filePath = '"' . $this->filePath . '"';
      }
      $this->content = $filePath . ' ' . parent::getContent();
    }
    return $this->content;
  }

  /**
   * {@inheritdoc}
   */
  public function setContent($content) {
    Tag::setContent($content);
    if (preg_match('/^
                # File component
                (?:
                    # File path in quotes
                    \\"([^\\"]+)\\"
                    |
                    # File URI
                    (\\S+)
                )
                # Remaining content (parsed by SourceTag)
                (?:\\s+(.*))?
            $/sux', $this->description, $matches)) {
      if ('' !== $matches[1]) {
        $this
          ->setFilePath($matches[1]);
      }
      else {
        $this
          ->setFileURI($matches[2]);
      }
      if (isset($matches[3])) {
        parent::setContent($matches[3]);
      }
      else {
        $this
          ->setDescription('');
      }
      $this->content = $content;
    }
    return $this;
  }

  /**
   * Returns the file path.
   *
   * @return string Path to a file to use as an example.
   *     May also be an absolute URI.
   */
  public function getFilePath() {
    return $this->filePath;
  }

  /**
   * Sets the file path.
   *
   * @param string $filePath The new file path to use for the example.
   *
   * @return $this
   */
  public function setFilePath($filePath) {
    $this->isURI = false;
    $this->filePath = trim($filePath);
    $this->content = null;
    return $this;
  }

  /**
   * Sets the file path as an URI.
   *
   * This function is equivalent to {@link setFilePath()}, except that it
   * convers an URI to a file path before that.
   *
   * There is no getFileURI(), as {@link getFilePath()} is compatible.
   *
   * @param type $uri The new file URI to use as an example.
   */
  public function setFileURI($uri) {
    $this->isURI = true;
    if (false === strpos($uri, ':')) {

      //Relative URL
      $this->filePath = rawurldecode(str_replace(array(
        '/',
        '\\',
      ), '%2F', $uri));
    }
    else {

      //Absolute URL or URI.
      $this->filePath = $uri;
    }
    $this->content = null;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExampleTag::$filePath protected property May also be an absolute URI.
ExampleTag::$isURI protected property This determines how the file portion appears at {@link getContent()}.
ExampleTag::getContent public function Gets the content of this tag. Overrides SourceTag::getContent
ExampleTag::getFilePath public function Returns the file path.
ExampleTag::setContent public function Sets the content of this tag. Overrides SourceTag::setContent
ExampleTag::setFilePath public function Sets the file path.
ExampleTag::setFileURI public function Sets the file path as an URI.
SourceTag::$lineCount protected property means "to the end".
SourceTag::$startingLine protected property location.
SourceTag::getLineCount public function Returns the number of lines.
SourceTag::getStartingLine public function Gets the starting line.
SourceTag::setLineCount public function Sets the number of lines.
SourceTag::setStartingLine public function Sets the starting line.
Tag::$content protected property When set to NULL, it means it needs to be regenerated.
Tag::$description protected property @var string Description of the content of this tag
Tag::$docblock protected property @var DocBlock The DocBlock which this tag belongs to.
Tag::$location protected property @var Location Location of the tag.
Tag::$parsedDescription protected property When set to NULL, it means it needs to be regenerated.
Tag::$tag protected property @var string Name of the tag
Tag::$tagHandlerMappings private static property handles it as an array value. The class is expected to inherit this class.
Tag::createInstance final public static function Factory method responsible for instantiating the correct sub type.
Tag::export public static function Builds a string representation of this object.
Tag::getDescription public function Gets the description component of this tag.
Tag::getDocBlock public function Gets the docblock this tag belongs to.
Tag::getLocation public function Gets the location of the tag.
Tag::getName public function Gets the name of this tag.
Tag::getParsedDescription public function Gets the parsed text of this description.
Tag::REGEX_TAGNAME constant PCRE regular expression matching a tag name.
Tag::registerTagHandler final public static function Registers a handler for tags.
Tag::setDescription public function Sets the description component of this tag.
Tag::setDocBlock public function Sets the docblock this tag belongs to.
Tag::setLocation public function Sets the location of the tag.
Tag::setName public function Sets the name of this tag.
Tag::__construct public function Parses a tag and populates the member variables.
Tag::__toString public function Returns the tag as a serialized string