[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/util/ -> Spyc.class.php (sommaire)

Spyc -- A Simple PHP YAML Class

Author: Chris Wanstrath <chris@ozmm.org>
Copyright: Copyright 2005-2006 Chris Wanstrath
License: http://www.opensource.org/licenses/mit-license.php MIT License
Version: 0.2.3 -- 2006-02-04
Poids: 1014 lignes (27 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 2 classes

YAMLNode:: (1 méthode):
  __construct()

Spyc:: (20 méthodes):
  YAMLLoad()
  YAMLDump()
  load()
  dump()
  _yamlize()
  _yamlizeArray()
  _dumpNode()
  _doLiteralBlock()
  _doFolding()
  _getIndent()
  _parseLine()
  _toType()
  _inlineEscape()
  _buildArray()
  _linkReferences()
  _linkRef()
  _gatherChildren()
  _nodeArrayizeData()
  _makeReferences()
  _array_kmerge()


Classe: YAMLNode  - X-Ref

A node, used by Spyc for parsing YAML.

__construct()   X-Ref
The constructor assigns the node a unique ID.

return: void

Classe: Spyc  - X-Ref

The Simple PHP YAML Class.

This class can be used to read a YAML file and convert its contents
into a PHP array.  It currently supports a very limited subsection of
the YAML spec.

Usage:
<code>
$parser = new Spyc;
$array  = $parser->load($file);
</code>
YAMLLoad($input)   X-Ref
Load YAML into a PHP array statically

The load method, when supplied with a YAML stream (string or file),
will do its best to convert YAML in a file into a PHP array.  Pretty
simple.
Usage:
<code>
$array = Spyc::YAMLLoad('lucky.yml');
print_r($array);
</code>

param: string $input Path of YAML file or string containing YAML
return: array

YAMLDump($array, $indent = false, $wordwrap = false)   X-Ref
Dump YAML from PHP array statically

The dump method, when supplied with an array, will do its best
to convert the array into friendly YAML.  Pretty simple.  Feel free to
save the returned string as nothing.yml and pass it around.

Oh, and you can decide how big the indent is and what the wordwrap
for folding is.  Pretty cool -- just pass in 'false' for either if
you want to use the default.

Indent's default is 2 spaces, wordwrap's default is 40 characters.  And
you can turn off wordwrap by passing in 0.

param: array $array PHP array
param: int $indent Pass in false to use the default, which is 2
param: int $wordwrap Pass in 0 for no wordwrap, false for default (40)
return: string

load($input)   X-Ref
Load YAML into a PHP array from an instantiated object

The load method, when supplied with a YAML stream (string or file path),
will do its best to convert the YAML into a PHP array.  Pretty simple.
Usage:
<code>
$parser = new Spyc;
$array  = $parser->load('lucky.yml');
print_r($array);
</code>

param: string $input Path of YAML file or string containing YAML
return: array

dump($array, $indent = false, $wordwrap = false)   X-Ref
Dump PHP array to YAML

The dump method, when supplied with an array, will do its best
to convert the array into friendly YAML.  Pretty simple.  Feel free to
save the returned string as tasteful.yml and pass it around.

Oh, and you can decide how big the indent is and what the wordwrap
for folding is.  Pretty cool -- just pass in 'false' for either if
you want to use the default.

Indent's default is 2 spaces, wordwrap's default is 40 characters.  And
you can turn off wordwrap by passing in 0.

param: array $array PHP array
param: int $indent Pass in false to use the default, which is 2
param: int $wordwrap Pass in 0 for no wordwrap, false for default (40)
return: string

_yamlize($key, $value, $indent)   X-Ref
Attempts to convert a key / value array item to YAML

param: $key The name of the key
param: $value The value of the item
param: $indent The indent of the current node
return: string

_yamlizeArray($array, $indent)   X-Ref
Attempts to convert an array to YAML

param: $array The array you want to convert
param: $indent The indent of the current level
return: string

_dumpNode($key, $value, $indent)   X-Ref
Returns YAML from a key and a value

param: $key The name of the key
param: $value The value of the item
param: $indent The indent of the current node
return: string

_doLiteralBlock($value, $indent)   X-Ref
Creates a literal block for dumping

param: $value
param: $indent int The value of the indent
return: string

_doFolding($value, $indent)   X-Ref
Folds a string of text, if necessary

param: $value The string you wish to fold
return: string

_getIndent($line)   X-Ref
Finds and returns the indentation of a YAML line

param: string $line A line from the YAML file
return: int

_parseLine($line)   X-Ref
Parses YAML code and returns an array for a node

param: string $line A line from the YAML file
return: array

_toType($value)   X-Ref
Finds the type of the passed value, returns the value as the new type.

param: string $value
return: mixed

_inlineEscape($inline)   X-Ref
Used in inlines to check for more inlines or quoted strings

return: array

_buildArray()   X-Ref
Builds the PHP array from all the YAML nodes we've gathered

return: array

_linkReferences()   X-Ref
Traverses node-space and sets references (& and *) accordingly

return: bool

_linkRef(&$n, $key, $k = null, $v = null)   X-Ref
Pas de description

_gatherChildren($nid)   X-Ref
Finds the children of a node and aids in the building of the PHP array

param: int $nid The id of the node whose children we're gathering
return: array

_nodeArrayizeData(&$node)   X-Ref
Turns a node's data and its children's data into a PHP array

param: array $node The node which you want to arrayize
return: boolean

_makeReferences(&$z)   X-Ref
Traverses node-space and copies references to / from this object.

param: object $z A node whose references we wish to make real
return: bool

_array_kmerge($arr1, $arr2)   X-Ref
Merges arrays and maintains numeric keys.

An ever-so-slightly modified version of the array_kmerge() function posted
to php.net by mail at nospam dot iaindooley dot com on 2004-04-08.

http://us3.php.net/manual/en/function.array-merge.php#41394

param: array $arr1
param: array $arr2
return: array



Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7