phpDocumentor\Reflection\DocBlock\Tag::__construct PHP Method

__construct() public method

Parses a tag and populates the member variables.
public __construct ( string $name, string $content, DocBlock $docblock = null, phpDocumentor\Reflection\DocBlock\Location $location = null )
$name string Name of the tag.
$content string The contents of the given tag.
$docblock phpDocumentor\Reflection\DocBlock The DocBlock which this tag belongs to.
$location phpDocumentor\Reflection\DocBlock\Location Location of the tag.
    public function __construct($name, $content, DocBlock $docblock = null, Location $location = null)
    {
        $this->setName($name)->setContent($content)->setDocBlock($docblock)->setLocation($location);
    }

Usage Example

Example #1
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'example').
  * @param string   $content  Contents for this tag.
  * @param DocBlock $docblock The DocBlock which this tag belongs to.
  * @param Location $location Location of the tag.
  */
 public function __construct($type, $content, DocBlock $docblock = null, Location $location = null)
 {
     Tag::__construct($type, $content, $docblock, $location);
     if (preg_match('/^
             (?:
                 # File path in quotes
                 \\"([^\\"]+)\\"
                 |
                 # File URI
                 (\\S+)
             )
             # Remaining content (parsed by SourceTag)
             (?:\\s+(.*))?
         $/sux', $this->description, $matches)) {
         if ('' !== $matches[1]) {
             //Quoted file path.
             $this->filePath = trim($matches[1]);
         } elseif (false === strpos($matches[2], ':')) {
             //Relative URL or a file path with no spaces in it.
             $this->filePath = rawurldecode(str_replace(array('/', '\\'), '%2F', $matches[2]));
         } else {
             //Absolute URL or URI.
             $this->filePath = $matches[2];
         }
         if (isset($matches[3])) {
             parent::__construct($type, $matches[3]);
             $this->content = $content;
         } else {
             $this->description = '';
         }
     }
 }
All Usage Examples Of phpDocumentor\Reflection\DocBlock\Tag::__construct