protected function outputNotNull($value): string
    {
        if (!is_array($value)) {
            throw TypeConversionException::unexpectedValue($this, 'output', 'array', $value);
        }
        if (0 === count($value)) {
            return '{}';
        }

        $requiredSizes = $this->calculateRequiredSizes($value);
        // this can only happen if $_item->dimensions() > 0, i.e. it should be an array iself
        if (count($requiredSizes) < 1) {
            throw TypeConversionException::unexpectedValue(
                $this,
                'output',
                "array with at least {$this->itemConverter->dimensions()} dimension(s)",
                reset($value)
            );
        }
        return $this->buildArrayLiteral($value, $requiredSizes);
    }
protected function outputNotNull($value): string
    {
        if (!is_array($value)) {
            throw TypeConversionException::unexpectedValue($this, 'output', 'array', $value);
        }
        if (0 === count($value)) {
            return '{}';
        }

        $requiredSizes = $this->calculateRequiredSizes($value);
        // this can only happen if $_item->dimensions() > 0, i.e. it should be an array iself
        if (count($requiredSizes) < 1) {
            throw TypeConversionException::unexpectedValue(
                $this,
                'output',
                "array with at least {$this->itemConverter->dimensions()} dimension(s)",
                reset($value)
            );
        }
        return $this->buildArrayLiteral($value, $requiredSizes);
    }
protected function outputNotNull ( $ value ) : string { if ( ! is_array ( $ value ) ) { throw TypeConversionException :: unexpectedValue ( $ this , 'output' , 'array' , $ value ) ; } if ( 0 === count ( $ value ) ) { return '{}' ; } $ requiredSizes = $ this -> calculateRequiredSizes ( $ value ) ; // this can only happen if $_item->dimensions() > 0, i.e. it should be an array iself if ( count ( $ requiredSizes ) < 1 ) { throw TypeConversionException :: unexpectedValue ( $ this , 'output' , "array with at least {$this->itemConverter->dimensions()} dimension(s)" , reset ( $ value ) ) ; } return $ this -> buildArrayLiteral ( $ value , $ requiredSizes ) ; }
Builds a Postgres array literal from given PHP array variable

Postgres enforces neither a number of dimensions of an array nor a number
of values in each dimension. However it does require that multidimensional
arrays have matching sizes for each dimension. This means that e.g.
ARRAY[['foo', 'bar'], ['baz', 'quux']] is a valid array while
ARRAY[['foo', 'bar'], ['baz']] is invalid.

This method calculates the sizes to match based on first elements of the given
array and then checks that all other subarrays match these sizes.

@param array $value
@return string
@throws TypeConversionException
Builds a Postgres array literal from given PHP array variable