private function serializeReturn(array $return)
    {
        $serializable = [];

        foreach ($return as $key => $value) {
            // No need to return magic variables
            if (Context::isSpecialVariableName($key)) {
                continue;
            }

            // Resources and Closures don't error, but they don't serialize well either.
            if (\is_resource($value) || $value instanceof \Closure) {
                continue;
            }

            try {
                @\serialize($value);
                $serializable[$key] = $value;
            } catch (\Throwable $e) {
                // we'll just ignore this one...
            } catch (\Exception $e) {
                // and this one too...
                // @todo remove this once we don't support PHP 5.x anymore :)
            }
        }

        return @\serialize($serializable);
    }
private function serializeReturn(array $return)
    {
        $serializable = [];

        foreach ($return as $key => $value) {
            // No need to return magic variables
            if (Context::isSpecialVariableName($key)) {
                continue;
            }

            // Resources and Closures don't error, but they don't serialize well either.
            if (\is_resource($value) || $value instanceof \Closure) {
                continue;
            }

            try {
                @\serialize($value);
                $serializable[$key] = $value;
            } catch (\Throwable $e) {
                // we'll just ignore this one...
            } catch (\Exception $e) {
                // and this one too...
                // @todo remove this once we don't support PHP 5.x anymore :)
            }
        }

        return @\serialize($serializable);
    }
private function serializeReturn ( array $ return ) { $ serializable = [ ] ; foreach ( $ return as $ key => $ value ) { // No need to return magic variables if ( Context :: isSpecialVariableName ( $ key ) ) { continue ; } // Resources and Closures don't error, but they don't serialize well either. if ( \ is_resource ( $ value ) || $ value instanceof \ Closure ) { continue ; } try { @ \ serialize ( $ value ) ; $ serializable [ $ key ] = $ value ; } catch ( \ Throwable $ e ) { // we'll just ignore this one... } catch ( \ Exception $ e ) { // and this one too... // @todo remove this once we don't support PHP 5.x anymore :) } } return @ \ serialize ( $ serializable ) ; }
Serialize all serializable return values.

A naïve serialization will run into issues if there is a Closure or
SimpleXMLElement (among other things) in scope when exiting the execution
loop. We'll just ignore these unserializable classes, and serialize what
we can.

@param array $return

@return string
Serialize all serializable return values .