src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
private function createReturnType(): string
    {
        $returnTypeHint = '';
        $typeCount = count($this->typesForFix);

        foreach ($this->typesForFix as $type) {
            // We add the default value if only null is used (which has no real native return type).
            if ($type === 'null' && ($typeCount === 1)) {
                $returnTypeHint = $this->defaultNullReturn;
                break; // We still need this break to prevent further execution of the default value.
            }

            // We add the question mark if there is a nullable type.
            if (in_array($type, self::NULL_TYPES, true) && ($typeCount > 1)) {
                $returnTypeHint = '?' . $returnTypeHint;
                continue; // We still need this continue to prevent further execution of the questionmark.
            }

            // We add a fixable "native" type. We do not fix custom classes (because it would have side effects to the
            // imported usage of classes.
            $returnTypeHint .= (TypeHintHelper::isSimpleTypeHint($type))
                ? TypeHintHelper::convertLongSimpleTypeHintToShort($type)
                : $type;
        }

        return $returnTypeHint;
    }
private function createReturnType(): string
    {
        $returnTypeHint = '';
        $typeCount = count($this->typesForFix);

        foreach ($this->typesForFix as $type) {
            // We add the default value if only null is used (which has no real native return type).
            if ($type === 'null' && ($typeCount === 1)) {
                $returnTypeHint = $this->defaultNullReturn;
                break; // We still need this break to prevent further execution of the default value.
            }

            // We add the question mark if there is a nullable type.
            if (in_array($type, self::NULL_TYPES, true) && ($typeCount > 1)) {
                $returnTypeHint = '?' . $returnTypeHint;
                continue; // We still need this continue to prevent further execution of the questionmark.
            }

            // We add a fixable "native" type. We do not fix custom classes (because it would have side effects to the
            // imported usage of classes.
            $returnTypeHint .= (TypeHintHelper::isSimpleTypeHint($type))
                ? TypeHintHelper::convertLongSimpleTypeHintToShort($type)
                : $type;
        }

        return $returnTypeHint;
    }
private function createReturnType ( ) : string { $ returnTypeHint = '' ; $ typeCount = count ( $ this -> typesForFix ) ; foreach ( $ this -> typesForFix as $ type ) { // We add the default value if only null is used (which has no real native return type). if ( $ type === 'null' && ( $ typeCount === 1 ) ) { $ returnTypeHint = $ this -> defaultNullReturn ; break ; // We still need this break to prevent further execution of the default value. } // We add the question mark if there is a nullable type. if ( in_array ( $ type , self :: NULL_TYPES , true ) && ( $ typeCount > 1 ) ) { $ returnTypeHint = '?' . $ returnTypeHint ; continue ; // We still need this continue to prevent further execution of the questionmark. } // We add a fixable "native" type. We do not fix custom classes (because it would have side effects to the // imported usage of classes. $ returnTypeHint .= ( TypeHintHelper :: isSimpleTypeHint ( $ type ) ) ? TypeHintHelper :: convertLongSimpleTypeHintToShort ( $ type ) : $ type ; } return $ returnTypeHint ; }
Creates the new return type for fixing or returns a null if not possible.

@return string
Creates the new return type for fixing or returns a null if not possible .