protected function updateDocComment($doc, $properties)
    {
        $lines = explode("\n", $doc);
        $propertyPart = false;
        $propertyPosition = false;
        foreach ($lines as $i => $line) {
            $line = trim($line);
            if (strncmp($line, '* @property ', 12) === 0) {
                $propertyPart = true;
            } elseif ($propertyPart && $line == '*') {
                $propertyPosition = $i;
                $propertyPart = false;
            }
            if (strncmp($line, '* @author ', 10) === 0 && $propertyPosition === false) {
                $propertyPosition = $i - 1;
                $propertyPart = false;
            }
            if ($propertyPart) {
                unset($lines[$i]);
            }
        }

        // if no properties or other tags where present add properties at the end
        if ($propertyPosition === false) {
            $propertyPosition = \count($lines) - 2;
        }

        $finalDoc = '';
        foreach ($lines as $i => $line) {
            $finalDoc .= $line . "\n";
            if ($i == $propertyPosition) {
                $finalDoc .= $properties;
            }
        }

        return $finalDoc;
    }