Library/FunctionLike/ReturnType/Collection.php
public function areReturnTypesCompatible()
    {
        $numberOfReturnTypes = $this->count();

        if (0 == $numberOfReturnTypes || 1 == $numberOfReturnTypes) {
            return true;
        }

        // <Class_1> | <Class_2> | ... | <Class_n>
        $classes = $this->getObjectLikeReturnTypes();

        // <Class> | <Class_1[]> | <Class_1[]> | ... | <Class_n[]>
        $collections = $this->getTypesBySpecification(new Specification\IsCollection());
        if (\count($collections) > 0 && $this->areReturnTypesObjectCompatible()) {
            return false;
        }

        $summ =
            // array | <Class_1[]> | <Class_2[]> | ... | <Class_n[]>
            (int) $this->areReturnTypesArrayCompatible() +

            // char | uchar | int | uint | long | ulong
            (int) $this->areReturnTypesIntCompatible() +

            // bool
            (int) $this->areReturnTypesBoolCompatible() +

            // istring | string
            (int) $this->areReturnTypesStringCompatible() +

            // double
            (int) $this->areReturnTypesDoubleCompatible();

        // T1 | T2 | ... | Tn
        if ($summ > 1) {
            return false;
        }

        // <Class_1> | <T1>
        if ($this->areReturnTypesObjectCompatible() && $summ > 0) {
            return false;
        }

        // null
        $null = (int) $this->areReturnTypesNullCompatible();

        // <T1> | null
        // <Class_1> | null
        // <Class_1[]> | null
        if (1 == $null && 2 == $this->count()) {
            return true;
        }

        // T1 | T2 | ... | Tn | null
        if (1 == $null && $null + $summ != $this->count()) {
            return false;
        }

        return 1 == $summ;
    }
public function areReturnTypesCompatible()
    {
        $numberOfReturnTypes = $this->count();

        if (0 == $numberOfReturnTypes || 1 == $numberOfReturnTypes) {
            return true;
        }

        // <Class_1> | <Class_2> | ... | <Class_n>
        $classes = $this->getObjectLikeReturnTypes();

        // <Class> | <Class_1[]> | <Class_1[]> | ... | <Class_n[]>
        $collections = $this->getTypesBySpecification(new Specification\IsCollection());
        if (\count($collections) > 0 && $this->areReturnTypesObjectCompatible()) {
            return false;
        }

        $summ =
            // array | <Class_1[]> | <Class_2[]> | ... | <Class_n[]>
            (int) $this->areReturnTypesArrayCompatible() +

            // char | uchar | int | uint | long | ulong
            (int) $this->areReturnTypesIntCompatible() +

            // bool
            (int) $this->areReturnTypesBoolCompatible() +

            // istring | string
            (int) $this->areReturnTypesStringCompatible() +

            // double
            (int) $this->areReturnTypesDoubleCompatible();

        // T1 | T2 | ... | Tn
        if ($summ > 1) {
            return false;
        }

        // <Class_1> | <T1>
        if ($this->areReturnTypesObjectCompatible() && $summ > 0) {
            return false;
        }

        // null
        $null = (int) $this->areReturnTypesNullCompatible();

        // <T1> | null
        // <Class_1> | null
        // <Class_1[]> | null
        if (1 == $null && 2 == $this->count()) {
            return true;
        }

        // T1 | T2 | ... | Tn | null
        if (1 == $null && $null + $summ != $this->count()) {
            return false;
        }

        return 1 == $summ;
    }
public function areReturnTypesCompatible ( ) { $ numberOfReturnTypes = $ this -> count ( ) ; if ( 0 == $ numberOfReturnTypes || 1 == $ numberOfReturnTypes ) { return true ; } // <Class_1> | <Class_2> | ... | <Class_n> $ classes = $ this -> getObjectLikeReturnTypes ( ) ; // <Class> | <Class_1[]> | <Class_1[]> | ... | <Class_n[]> $ collections = $ this -> getTypesBySpecification ( new Specification \ IsCollection ( ) ) ; if ( \ count ( $ collections ) > 0 && $ this -> areReturnTypesObjectCompatible ( ) ) { return false ; } $ summ = // array | <Class_1[]> | <Class_2[]> | ... | <Class_n[]> ( int ) $ this -> areReturnTypesArrayCompatible ( ) + // char | uchar | int | uint | long | ulong ( int ) $ this -> areReturnTypesIntCompatible ( ) + // bool ( int ) $ this -> areReturnTypesBoolCompatible ( ) + // istring | string ( int ) $ this -> areReturnTypesStringCompatible ( ) + // double ( int ) $ this -> areReturnTypesDoubleCompatible ( ) ; // T1 | T2 | ... | Tn if ( $ summ > 1 ) { return false ; } // <Class_1> | <T1> if ( $ this -> areReturnTypesObjectCompatible ( ) && $ summ > 0 ) { return false ; } // null $ null = ( int ) $ this -> areReturnTypesNullCompatible ( ) ; // <T1> | null // <Class_1> | null // <Class_1[]> | null if ( 1 == $ null && 2 == $ this -> count ( ) ) { return true ; } // T1 | T2 | ... | Tn | null if ( 1 == $ null && $ null + $ summ != $ this -> count ( ) ) { return false ; } return 1 == $ summ ; }
Checks if the collection have compatible return types.

@return bool
Checks if the collection have compatible return types .