function entity_type_export($file, $entities, $plan, $type)
{
    foreach ($entities[$plan] as $entity) {
        if ($entity->__metadata['type'] = $type) {
            $object = '$entities[\'' . $plan . '\'][] = ' . improved_var_export($entity, true) . ";\n\n";
            fwrite($file, $object);
        }
    }
}
/**
 * An implementation of var_export() that is compatible with instances
 * of stdClass.
 * @param mixed $variable The variable you want to export
 * @param bool $return If used and set to true, improved_var_export()
 *     will return the variable representation instead of outputting it.
 * @return mixed|null Returns the variable representation when the
 *     return parameter is used and evaluates to TRUE. Otherwise, this
 *     function will return NULL.
 */
function improved_var_export($variable, $return = false, $depth = 0)
{
    $indent = str_repeat("\t", $depth);
    if ($variable instanceof stdClass) {
        $result = '(object) ' . improved_var_export(get_object_vars($variable), true, $depth + 1);
    } else {
        if (is_array($variable)) {
            $array = array();
            foreach ($variable as $key => $value) {
                $array[] = $indent . var_export($key, true) . ' => ' . improved_var_export($value, true, $depth + 1);
            }
            $result = "array(\n" . implode(",\n", $array) . "\n" . $indent . ")";
        } else {
            $result = var_export($variable, true);
        }
    }
    if (!$return) {
        print $result;
        return null;
    } else {
        return $result;
    }
}