extractFirstSentence() 공개 정적인 메소드

Extracts first sentence out of text
public static extractFirstSentence ( string $text ) : string
$text string
리턴 string
예제 #1
0
 /**
  * @param \phpDocumentor\Reflection\ClassReflector\PropertyReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($reflector, $context, $config);
     if ($reflector === null) {
         return;
     }
     $this->visibility = $reflector->getVisibility();
     $this->isStatic = $reflector->isStatic();
     // bypass $reflector->getDefault() for short array syntax
     if ($reflector->getNode()->default) {
         $this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default);
     }
     $hasInheritdoc = false;
     foreach ($this->tags as $tag) {
         if ($tag->getName() === 'inheritdoc') {
             $hasInheritdoc = true;
         }
         if ($tag instanceof VarTag) {
             $this->type = $tag->getType();
             $this->types = $tag->getTypes();
             $this->description = ucfirst($tag->getDescription());
             $this->shortDescription = BaseDoc::extractFirstSentence($this->description);
         }
     }
     if (empty($this->shortDescription) && $context !== null && !$hasInheritdoc) {
         $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for element '{$this->name}'"];
     }
 }
예제 #2
0
 /**
  * @param \phpDocumentor\Reflection\ClassReflector\ConstantReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($reflector, $context, $config);
     if ($reflector === null) {
         return;
     }
     foreach ($this->tags as $i => $tag) {
         if ($tag->getName() == 'event') {
             $eventTag = new ReturnTag('event', $tag->getContent(), $tag->getDocBlock(), $tag->getLocation());
             $this->type = $eventTag->getType();
             $this->types = $eventTag->getTypes();
             $this->description = ucfirst($eventTag->getDescription());
             $this->shortDescription = BaseDoc::extractFirstSentence($this->description);
             unset($this->tags[$i]);
         }
     }
 }
예제 #3
0
파일: Context.php 프로젝트: howq/yii2
 /**
  * Add properties for getters and setters if class is subclass of [[\yii\base\Object]].
  * @param ClassDoc $class
  */
 protected function handlePropertyFeature($class)
 {
     if (!$this->isSubclassOf($class, 'yii\\base\\Object')) {
         return;
     }
     foreach ($class->getPublicMethods() as $name => $method) {
         if ($method->isStatic) {
             continue;
         }
         if (!strncmp($name, 'get', 3) && strlen($name) > 3 && $this->hasNonOptionalParams($method)) {
             $propertyName = '$' . lcfirst(substr($method->name, 3));
             if (isset($class->properties[$propertyName])) {
                 $property = $class->properties[$propertyName];
                 if ($property->getter === null && $property->setter === null) {
                     $this->errors[] = ['line' => $property->startLine, 'file' => $class->sourceFile, 'message' => "Property {$propertyName} conflicts with a defined getter {$method->name} in {$class->name}."];
                 }
                 $property->getter = $method;
             } else {
                 $class->properties[$propertyName] = new PropertyDoc(null, $this, ['name' => $propertyName, 'definedBy' => $method->definedBy, 'sourceFile' => $class->sourceFile, 'visibility' => 'public', 'isStatic' => false, 'type' => $method->returnType, 'types' => $method->returnTypes, 'shortDescription' => BaseDoc::extractFirstSentence($method->return), 'description' => $method->return, 'getter' => $method]);
             }
         }
         if (!strncmp($name, 'set', 3) && strlen($name) > 3 && $this->hasNonOptionalParams($method, 1)) {
             $propertyName = '$' . lcfirst(substr($method->name, 3));
             if (isset($class->properties[$propertyName])) {
                 $property = $class->properties[$propertyName];
                 if ($property->getter === null && $property->setter === null) {
                     $this->errors[] = ['line' => $property->startLine, 'file' => $class->sourceFile, 'message' => "Property {$propertyName} conflicts with a defined setter {$method->name} in {$class->name}."];
                 }
                 $property->setter = $method;
             } else {
                 $param = $this->getFirstNotOptionalParameter($method);
                 $class->properties[$propertyName] = new PropertyDoc(null, $this, ['name' => $propertyName, 'definedBy' => $method->definedBy, 'sourceFile' => $class->sourceFile, 'visibility' => 'public', 'isStatic' => false, 'type' => $param->type, 'types' => $param->types, 'shortDescription' => BaseDoc::extractFirstSentence($param->description), 'description' => $param->description, 'setter' => $method]);
             }
         }
     }
 }