public static function restorePrototypeCode($prototypeName, $abstractSyntaxTree, $indentation = '')
    {
        $result = '';

        if (array_key_exists('__prototypeObjectName', $abstractSyntaxTree)) {
            $result .= sprintf(
                'prototype(%s) < prototype(%s) {',
                $prototypeName,
                $abstractSyntaxTree['__prototypeObjectName']
            ) . chr(10);
        } else {
            $result .= sprintf('prototype(%s) {', $prototypeName) . chr(10);
        }

        // handle __meta context
        if (array_key_exists('__meta', $abstractSyntaxTree)) {
            foreach (array_keys($abstractSyntaxTree['__meta']) as $key) {
                if (in_array($key, self::$TOP_META_KEYS, true) === false) {
                    continue;
                }
                $result .= self::restoreValueCode('@' . $key, $abstractSyntaxTree['__meta'][$key], $indentation . self::INDENTATION);
            }
        }

        // handle __prototypes
        if (array_key_exists('__prototypes', $abstractSyntaxTree)) {
            foreach (array_keys($abstractSyntaxTree['__prototypes']) as $key) {
                $result .= self::restorePrototypeCode($key, $abstractSyntaxTree['__prototypes'][$key], $indentation . self::INDENTATION);
            }
        }

        // add properties
        foreach (array_keys($abstractSyntaxTree) as $key) {
            if (in_array($key, self::$RESERVED_KEYS, true)) {
                continue;
            }
            $result .=  self::restoreValueCode($key, $abstractSyntaxTree[$key], $indentation . self::INDENTATION);
        }


        // handle remaining __meta keys
        if (array_key_exists('__meta', $abstractSyntaxTree)) {
            foreach (array_keys($abstractSyntaxTree['__meta']) as $key) {
                if (in_array($key, self::$TOP_META_KEYS, true) === true) {
                    continue;
                }
                $result .= self::restoreValueCode('@' . $key, $abstractSyntaxTree['__meta'][$key], $indentation . self::INDENTATION);
            }
        }

        $result .= $indentation . '}' . chr(10);
        return $result;
    }
public static function restorePrototypeCode($prototypeName, $abstractSyntaxTree, $indentation = '')
    {
        $result = '';

        if (array_key_exists('__prototypeObjectName', $abstractSyntaxTree)) {
            $result .= sprintf(
                'prototype(%s) < prototype(%s) {',
                $prototypeName,
                $abstractSyntaxTree['__prototypeObjectName']
            ) . chr(10);
        } else {
            $result .= sprintf('prototype(%s) {', $prototypeName) . chr(10);
        }

        // handle __meta context
        if (array_key_exists('__meta', $abstractSyntaxTree)) {
            foreach (array_keys($abstractSyntaxTree['__meta']) as $key) {
                if (in_array($key, self::$TOP_META_KEYS, true) === false) {
                    continue;
                }
                $result .= self::restoreValueCode('@' . $key, $abstractSyntaxTree['__meta'][$key], $indentation . self::INDENTATION);
            }
        }

        // handle __prototypes
        if (array_key_exists('__prototypes', $abstractSyntaxTree)) {
            foreach (array_keys($abstractSyntaxTree['__prototypes']) as $key) {
                $result .= self::restorePrototypeCode($key, $abstractSyntaxTree['__prototypes'][$key], $indentation . self::INDENTATION);
            }
        }

        // add properties
        foreach (array_keys($abstractSyntaxTree) as $key) {
            if (in_array($key, self::$RESERVED_KEYS, true)) {
                continue;
            }
            $result .=  self::restoreValueCode($key, $abstractSyntaxTree[$key], $indentation . self::INDENTATION);
        }


        // handle remaining __meta keys
        if (array_key_exists('__meta', $abstractSyntaxTree)) {
            foreach (array_keys($abstractSyntaxTree['__meta']) as $key) {
                if (in_array($key, self::$TOP_META_KEYS, true) === true) {
                    continue;
                }
                $result .= self::restoreValueCode('@' . $key, $abstractSyntaxTree['__meta'][$key], $indentation . self::INDENTATION);
            }
        }

        $result .= $indentation . '}' . chr(10);
        return $result;
    }
public static function restorePrototypeCode ( $ prototypeName , $ abstractSyntaxTree , $ indentation = '' ) { $ result = '' ; if ( array_key_exists ( '__prototypeObjectName' , $ abstractSyntaxTree ) ) { $ result .= sprintf ( 'prototype(%s) < prototype(%s) {' , $ prototypeName , $ abstractSyntaxTree [ '__prototypeObjectName' ] ) . chr ( 10 ) ; } else { $ result .= sprintf ( 'prototype(%s) {' , $ prototypeName ) . chr ( 10 ) ; } // handle __meta context if ( array_key_exists ( '__meta' , $ abstractSyntaxTree ) ) { foreach ( array_keys ( $ abstractSyntaxTree [ '__meta' ] ) as $ key ) { if ( in_array ( $ key , self :: $ TOP_META_KEYS , true ) === false ) { continue ; } $ result .= self :: restoreValueCode ( '@' . $ key , $ abstractSyntaxTree [ '__meta' ] [ $ key ] , $ indentation . self :: INDENTATION ) ; } } // handle __prototypes if ( array_key_exists ( '__prototypes' , $ abstractSyntaxTree ) ) { foreach ( array_keys ( $ abstractSyntaxTree [ '__prototypes' ] ) as $ key ) { $ result .= self :: restorePrototypeCode ( $ key , $ abstractSyntaxTree [ '__prototypes' ] [ $ key ] , $ indentation . self :: INDENTATION ) ; } } // add properties foreach ( array_keys ( $ abstractSyntaxTree ) as $ key ) { if ( in_array ( $ key , self :: $ RESERVED_KEYS , true ) ) { continue ; } $ result .= self :: restoreValueCode ( $ key , $ abstractSyntaxTree [ $ key ] , $ indentation . self :: INDENTATION ) ; } // handle remaining __meta keys if ( array_key_exists ( '__meta' , $ abstractSyntaxTree ) ) { foreach ( array_keys ( $ abstractSyntaxTree [ '__meta' ] ) as $ key ) { if ( in_array ( $ key , self :: $ TOP_META_KEYS , true ) === true ) { continue ; } $ result .= self :: restoreValueCode ( '@' . $ key , $ abstractSyntaxTree [ '__meta' ] [ $ key ] , $ indentation . self :: INDENTATION ) ; } } $ result .= $ indentation . '}' . chr ( 10 ) ; return $ result ; }
Get PrototypeName and AST and restore the original Code representation

@param string $prototypeName
@param array $aspectSyntaxTree
@return string
Get PrototypeName and AST and restore the original Code representation