protected function updateDocComment($doc, $properties, $coveredProperties, $ref)
    {
        $lines = explode("\n", trim($doc));
        $propertyPart = false;
        $propertyPosition = false;
        foreach ($lines as $i => $line) {
            if (substr(trim($line), 0, 12) == '* @property ') {
                $propertyPart = true;
            } elseif ($propertyPart && trim($line) == '*') {
                $propertyPosition = $i;
                $propertyPart = false;
            }
            if (substr(trim($line), 0, 10) == '* @author ' && $propertyPosition === false) {
                $propertyPosition = $i - 1;
                $propertyPart = false;
            }
            if ($propertyPart && !$ref->isSubclassOf('yii\base\Model')) {
                unset($lines[$i]);
            } elseif ($ref->isSubclassOf('yii\db\ActiveRecord')
                && preg_match('/^\* This is the model class for table/', trim($line)) === 1) {
                unset($lines[$i]);
            } else {
                foreach ($coveredProperties as $property) {
                    if (preg_match('/^\* \@property[^\w]' . $property . '/', trim($line)) === 1) {
                        unset($lines[$i]);
                        break;
                    }
                }
            }
        }
        $finalDoc = '';
        foreach ($lines as $i => $line) {
            $finalDoc .= $line . "\n";
            if ($i == $propertyPosition) {
                $finalDoc .= $properties;
            }
        }

        return $finalDoc;
    }