__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.
示例#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 = '';
         }
     }
 }
示例#2
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'link').
  * @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)
 {
     parent::__construct($type, $content, $docblock, $location);
     $content = preg_split('/\\s+/u', $this->description, 2);
     // any output is considered a type
     $this->link = $content[0];
     $this->description = isset($content[1]) ? $content[1] : $content[0];
 }
示例#3
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'author').
  * @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)
 {
     parent::__construct($type, $content, $docblock, $location);
     if (preg_match('/^([^\\<]*)(\\<([^\\>]*)\\>)?$/', $this->description, $matches)) {
         $this->name = trim($matches[1]);
         if (isset($matches[3])) {
             $this->email = trim($matches[3]);
         }
     }
 }
示例#4
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'var').
  * @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);
     $content = preg_split('/\\s+/u', $this->description);
     if (count($content) == 0) {
         return;
     }
     // var always starts with the variable name
     $this->type = array_shift($content);
     // if the next item starts with a $ it must be the variable name
     if (count($content) > 0 && strlen($content[0]) > 0 && $content[0][0] == '$') {
         $this->variableName = array_shift($content);
     }
     $this->description = implode(' ', $content);
 }
示例#5
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'param').
  * @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);
     $content = preg_split('/(\\s+)/u', $this->description, 3, PREG_SPLIT_DELIM_CAPTURE);
     // if the first item that is encountered is not a variable; it is a type
     if (isset($content[0]) && strlen($content[0]) > 0 && $content[0][0] !== '$') {
         $this->type = array_shift($content);
         array_shift($content);
     }
     // if the next item starts with a $ it must be the variable name
     if (isset($content[0]) && strlen($content[0]) > 0 && $content[0][0] == '$') {
         $this->variableName = array_shift($content);
         array_shift($content);
     }
     $this->description = implode('', $content);
 }
示例#6
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'source').
  * @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)
 {
     parent::__construct($type, $content, $docblock, $location);
     if (preg_match('/^
             # Starting line
             ([1-9]\\d*)
             \\s*
             # Number of lines
             (?:
                 ((?1))
                 \\s+
             )?
             # Description
             (.*)
         $/sux', $this->description, $matches)) {
         $this->startingLine = (int) $matches[1];
         if (isset($matches[2]) && '' !== $matches[2]) {
             $this->lineCount = (int) $matches[2];
         }
         $this->description = $matches[3];
     }
 }
示例#7
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'method').
  * @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);
     $matches = array();
     // 1. none or more whitespace
     // 2. optionally a word with underscores followed by whitespace : as
     //    type for the return value
     // 3. then optionally a word with underscores followed by () and
     //    whitespace : as method name as used by phpDocumentor
     // 4. then a word with underscores, followed by ( and any character
     //    until a ) and whitespace : as method name with signature
     // 5. any remaining text : as description
     if (preg_match('/^
             # Return type
             (?:
                 ([\\w\\|_\\\\]+)
                 \\s+
             )?
             # Legacy method name (not captured)
             (?:
                 [\\w_]+\\(\\)\\s+
             )?
             # Method name
             ([\\w\\|_\\\\]+)
             # Arguments
             \\(([^\\)]*)\\)
             \\s*
             # Description
             (.*)
         $/sux', $this->description, $matches)) {
         list(, $this->type, $this->method_name, $this->arguments, $this->description) = $matches;
         if (!$this->type) {
             $this->type = 'void';
         }
     } else {
         echo date('c') . ' ERR (3): @method contained invalid contents: ' . $this->content . PHP_EOL;
     }
 }
示例#8
0
 /**
  * Parses a tag and populates the member variables.
  *
  * @param string   $type     Tag identifier for this tag (should be 'version').
  * @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)
 {
     parent::__construct($type, $content, $docblock, $location);
     if (preg_match('/^
             # The version vector
             ((?:
                 # Normal release vectors.
                 \\d\\S*
                 |
                 # VCS version vectors. Per PHPCS, they are expected to
                 # follow the form of the VCS name, followed by ":", followed
                 # by the version vector itself.
                 # By convention, popular VCSes like CVS, SVN and GIT use "$"
                 # around the actual version vector.
                 [^\\s\\:]+\\:\\s*\\$[^\\$]+\\$
             ))
             \\s*
             # The description
             (.+)?
         $/sux', $this->description, $matches)) {
         $this->version = $matches[1];
         $this->description = isset($matches[2]) ? $matches[2] : '';
     }
 }