Library/ClassMethod.php
public function hasChildReturnStatementType($statement)
    {
        if (!isset($statement['statements']) || !\is_array($statement['statements'])) {
            return false;
        }

        if ('if' == $statement['type']) {
            $ret = false;

            $statements = $statement['statements'];
            foreach ($statements as $item) {
                $type = isset($item['type']) ? $item['type'] : null;
                if ('return' == $type || 'throw' == $type) {
                    $ret = true;
                } else {
                    $ret = $this->hasChildReturnStatementType($item);
                }
            }

            if (!$ret || !isset($statement['else_statements'])) {
                return false;
            }

            $statements = $statement['else_statements'];
            foreach ($statements as $item) {
                $type = isset($item['type']) ? $item['type'] : null;
                if ('return' == $type || 'throw' == $type) {
                    return true;
                } else {
                    return $this->hasChildReturnStatementType($item);
                }
            }
        } else {
            $statements = $statement['statements'];
            foreach ($statements as $item) {
                $type = isset($item['type']) ? $item['type'] : null;
                if ('return' == $type || 'throw' == $type) {
                    return true;
                } else {
                    return $this->hasChildReturnStatementType($item);
                }
            }
        }

        return false;
    }
public function hasChildReturnStatementType($statement)
    {
        if (!isset($statement['statements']) || !\is_array($statement['statements'])) {
            return false;
        }

        if ('if' == $statement['type']) {
            $ret = false;

            $statements = $statement['statements'];
            foreach ($statements as $item) {
                $type = isset($item['type']) ? $item['type'] : null;
                if ('return' == $type || 'throw' == $type) {
                    $ret = true;
                } else {
                    $ret = $this->hasChildReturnStatementType($item);
                }
            }

            if (!$ret || !isset($statement['else_statements'])) {
                return false;
            }

            $statements = $statement['else_statements'];
            foreach ($statements as $item) {
                $type = isset($item['type']) ? $item['type'] : null;
                if ('return' == $type || 'throw' == $type) {
                    return true;
                } else {
                    return $this->hasChildReturnStatementType($item);
                }
            }
        } else {
            $statements = $statement['statements'];
            foreach ($statements as $item) {
                $type = isset($item['type']) ? $item['type'] : null;
                if ('return' == $type || 'throw' == $type) {
                    return true;
                } else {
                    return $this->hasChildReturnStatementType($item);
                }
            }
        }

        return false;
    }
public function hasChildReturnStatementType ( $ statement ) { if ( ! isset ( $ statement [ 'statements' ] ) || ! \ is_array ( $ statement [ 'statements' ] ) ) { return false ; } if ( 'if' == $ statement [ 'type' ] ) { $ ret = false ; $ statements = $ statement [ 'statements' ] ; foreach ( $ statements as $ item ) { $ type = isset ( $ item [ 'type' ] ) ? $ item [ 'type' ] : null ; if ( 'return' == $ type || 'throw' == $ type ) { $ ret = true ; } else { $ ret = $ this -> hasChildReturnStatementType ( $ item ) ; } } if ( ! $ ret || ! isset ( $ statement [ 'else_statements' ] ) ) { return false ; } $ statements = $ statement [ 'else_statements' ] ; foreach ( $ statements as $ item ) { $ type = isset ( $ item [ 'type' ] ) ? $ item [ 'type' ] : null ; if ( 'return' == $ type || 'throw' == $ type ) { return true ; } else { return $ this -> hasChildReturnStatementType ( $ item ) ; } } } else { $ statements = $ statement [ 'statements' ] ; foreach ( $ statements as $ item ) { $ type = isset ( $ item [ 'type' ] ) ? $ item [ 'type' ] : null ; if ( 'return' == $ type || 'throw' == $ type ) { return true ; } else { return $ this -> hasChildReturnStatementType ( $ item ) ; } } } return false ; }
Simple method to check if one of the paths are returning the right expected type.

@param array $statement

@return bool
Simple method to check if one of the paths are returning the right expected type .