Returns the needed indentation whitespace for fhe fixing of the uses.

@param int $usePos

@return string
514213
private function getIndentationForFix(int $usePos): string
    {
        $file = $this->getFile()->getBaseFile();
        $indentation = '';
        $currentPointer = $usePos - 1;
        $tokens = $file->getTokens();

        while ($tokens[$currentPointer]['code'] === T_WHITESPACE &&
            $tokens[$currentPointer]['content'] !== $file->eolChar) {
            $indentation .= $tokens[$currentPointer]['content'];
            $currentPointer--;
        }

        return $indentation;
    }
700645
public function identifyMode($pos)
    {
        if ($pos >= strlen($this->dataStr))
            return Constants::QR_MODE_NUL;

        $c = $this->dataStr[$pos];

        if(self::isdigitat($this->dataStr, $pos)) {
            return Constants::QR_MODE_NUM;
        } else if(self::isalnumat($this->dataStr, $pos)) {
            return Constants::QR_MODE_AN;
        } else if($this->modeHint == Constants::QR_MODE_KANJI) {

            if ($pos+1 < strlen($this->dataStr))
            {
                $d = $this->dataStr[$pos+1];
                $word = (ord($c) << 8) | ord($d);
                if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) {
                    return Constants::QR_MODE_KANJI;
                }
            }
        }

        return Constants::QR_MODE_8;
    }
712975
private function parseNamespace($tokens)
    {
        $namespace = null;
        $tokenCount = count($tokens);
        for ($offset=0; $offset < $tokenCount; $offset++) {
            if (!is_array($tokens[$offset])) {
                continue;
            }

            if (T_NAMESPACE === $tokens[$offset][0]) {
                $offset++; // the next token is a whitespace

                return $this->parseNamespaceString($tokens, $offset);
            }
        }

        return $namespace;
    }
655425
protected function prependGroupUses($uses)
    {
        $group = last($this->groupStack);
        
        return isset($group['namespace']) && strpos($uses, '\\') !== 0 ? $group['namespace'] . '\\' . $uses : $uses;
    }
347312
private function formatUsedClasses($baseNamespace, $usedClasses)
    {
        $result = [];
        foreach ($usedClasses as $usedClass) {
            // Do not import classes from same namespace
            $namespacePattern = str_replace('\\', '\\\\', "/{$baseNamespace}\\[a-zA-Z0-9_]*/");
            if (! preg_match($namespacePattern, $usedClass)) {
                $result[] = "use {$usedClass};";
            }
        }

        sort($result);

        return implode("\n", $result);
    }
234597
public function getIndentationPrefix($times = 1)
    {
        if (!is_integer($times)) {
            throw new \InvalidArgumentException('The times parameter has to be an integer');
        }

        $indentation = '';

        for ($i = 0; $i < $times; $i++) {
            $indentation .= $this->getTemplate()->getIndentation();
        }

        return $indentation;
    }
700318
public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = '   ' ) : string
   {

      // Concatenate the base error message from usable elements
      $msg = \sprintf(
         '%s%s in %s[%d]. %s',
         \str_repeat( $indentSpaces, $subExceptionLevel ),
         \get_class( $this ),
         $this->file,
         $this->line,
         \str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
      );

      // getting a may defined previous exception
      $previous = $this->getPrevious();

      // if no previous exception is defined return the current generated message
      if ( null === $previous || ! ( $previous instanceof \Throwable ) )
      {
         return $msg;
      }

      // If previous message is a framework internal exception
      if ( $previous instanceof NiirrtyException )
      {
         // Simple cast the exception to a string and append it with rewrite the indention
         $msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
         // And return the message
         return $msg;
      }

      // Else its a normal PHP exception
      // Concatenate the previous error message from usable elements
      $msg .= \sprintf(
         "\n%s%s %s in %s[%d]\n    %s",
         \str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
         \get_class( $previous ),
         static::GetCodeName( $previous->getCode() ),
         $previous->file,
         $previous->line,
         \str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
      );

      // And return the message
      return $msg;

   }
595403
public function getLineIndentation()
    {
        $first = $this->getFirstTokenOnLine();
        if ( ! $first->matches(T_WHITESPACE)) {
            return '';
        }

        return $first->getContentUntil($first->findNextToken('NO_WHITESPACE')->get());
    }
874113
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getSlug();
                break;
            case 2:
                return $this->getHasAttributeAvValue();
                break;
            case 3:
                return $this->getIsMultilingualAttributeAvValue();
                break;
            case 4:
                return $this->getPattern();
                break;
            case 5:
                return $this->getCssClass();
                break;
            case 6:
                return $this->getInputType();
                break;
            case 7:
                return $this->getMax();
                break;
            case 8:
                return $this->getMin();
                break;
            case 9:
                return $this->getStep();
                break;
            case 10:
                return $this->getImageMaxWidth();
                break;
            case 11:
                return $this->getImageMaxHeight();
                break;
            case 12:
                return $this->getImageRatio();
                break;
            case 13:
                return $this->getCreatedAt();
                break;
            case 14:
                return $this->getUpdatedAt();
                break;
            default:
                return null;
                break;
        } // switch()
    }
1359643
function fixSpaces($spaces='')
	{
		$count = strlen($spaces);
		if($count == 0) {
			return '';
		}

		$div = floor($count / 2);
		$mod = $count % 2;
		return str_repeat('&nbsp; ', $div).str_repeat('&nbsp;', $mod);
	}
505409
private function getNamespaceUseDeclarations(Tokens $tokens, array $useIndexes)
    {
        $uses = array();

        foreach ($useIndexes as $index) {
            $declarationEndIndex = $tokens->getNextTokenOfKind($index, array(';'));
            $declarationContent = $tokens->generatePartialCode($index + 1, $declarationEndIndex - 1);

            // ignore multiple use statements like: `use BarB, BarC as C, BarD;`
            // that should be split into few separate statements
            if (false !== strpos($declarationContent, ',')) {
                continue;
            }

            $declarationParts = preg_split('/\s+as\s+/i', $declarationContent);

            if (1 === count($declarationParts)) {
                $fullName = $declarationContent;
                $declarationParts = explode('\\', $fullName);
                $shortName = end($declarationParts);
                $aliased = false;
            } else {
                $fullName = $declarationParts[0];
                $shortName = $declarationParts[1];
                $declarationParts = explode('\\', $fullName);
                $aliased = $shortName !== end($declarationParts);
            }

            $shortName = trim($shortName);

            $uses[$shortName] = array(
                'aliased' => $aliased,
                'end' => $declarationEndIndex,
                'fullName' => trim($fullName),
                'shortName' => $shortName,
                'start' => $index,
            );
        }

        return $uses;
    }
1221480
private function getUsesDeclarations()
    {
        asort( $this->usesDeclarations );
        $output = [];
        foreach( $this->usesDeclarations as $namespace ) {
            $output[] = sprintf( 'use %s;', $namespace );
        }
        return new Format( $output );
    }
348741
private function getRealLinesBeforeFirstUse(int $firstUsePos, int $posBeforeFirstUse): int
    {
        $file = $this->getFile();
        $whitespaceBeforeFirstUse = '';

        if ($posBeforeFirstUse + 1 !== $firstUsePos) {
            $whitespaceBeforeFirstUse .= TokenHelper::getContent(
                $file,
                $posBeforeFirstUse + 1,
                $firstUsePos - 1
            );
        }

        return substr_count($whitespaceBeforeFirstUse, $file->eolChar) - 1;
    }
861712
static function processWhitespaceNewlines($text) {

		// remove excess spaces around tabs
		$text = preg_replace("/ *\t */im", "\t", $text);

		// remove leading whitespace
		$text = ltrim($text);

		// remove leading spaces on each line
		$text = preg_replace("/\n[ \t]*/im", "\n", $text);

		// convert non-breaking spaces to regular spaces to prevent output issues,
		// do it here so they do NOT get removed with other leading spaces, as they
		// are sometimes used for indentation
		$text = static::renderText($text);

		// remove trailing whitespace
		$text = rtrim($text);

		// remove trailing spaces on each line
		$text = preg_replace("/[ \t]*\n/im", "\n", $text);

		// unarmor pre blocks
		$text = static::fixNewLines($text);

		// remove unnecessary empty lines
		$text = preg_replace("/\n\n\n*/im", "\n\n", $text);

		return $text;
	}
382641
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getFile();
                break;
            case 2:
                return $this->getPersonId();
                break;
            case 3:
                return $this->getVisible();
                break;
            case 4:
                return $this->getPosition();
                break;
            case 5:
                return $this->getCreatedAt();
                break;
            case 6:
                return $this->getUpdatedAt();
                break;
            case 7:
                return $this->getVersion();
                break;
            case 8:
                return $this->getVersionCreatedAt();
                break;
            case 9:
                return $this->getVersionCreatedBy();
                break;
            case 10:
                return $this->getPersonIdVersion();
                break;
            default:
                return null;
                break;
        } // switch()
    }
201994
protected function resolvePosition($positions)
    {
        $str = '';
        foreach ($positions as $pos => $val) {
            $str .= "{$pos}: {$val}px; ";
        }

        return rtrim($str);
    }
354488
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getContactId();
                break;
            case 2:
                return $this->getContactType();
                break;
            case 3:
                return $this->getCreatedAt();
                break;
            case 4:
                return $this->getUpdatedAt();
                break;
            case 5:
                return $this->getVersion();
                break;
            case 6:
                return $this->getVersionCreatedAt();
                break;
            case 7:
                return $this->getVersionCreatedBy();
                break;
            case 8:
                return $this->getContactIdVersion();
                break;
            default:
                return null;
                break;
        } // switch()
    }