yii\apidoc\models\Context::handlePropertyFeature PHP Method

handlePropertyFeature() protected method

Add properties for getters and setters if class is subclass of Object.
protected handlePropertyFeature ( yii\apidoc\models\ClassDoc $class )
$class yii\apidoc\models\ClassDoc
    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]);
                }
            }
        }
    }