]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - includes/libs/spyc.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / includes / libs / spyc.php
similarity index 83%
rename from includes/api/ApiFormatYaml_spyc.php
rename to includes/libs/spyc.php
index 30f860dd4a039c19a252d3730ec578cc5f2eccdb..bc92e869c903259118b7b87e8fe641d9292393b0 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /**
  * Spyc -- A Simple PHP YAML Class
+ *
+ * @file
  * @version 0.2.3 -- 2006-02-04
  * @author Chris Wanstrath <chris@ozmm.org>
  * @see http://spyc.sourceforge.net/
@@ -33,10 +35,10 @@ class Spyc {
         * Indent's default is 2 spaces, wordwrap's default is 40 characters.  And
         * you can turn off wordwrap by passing in 0.
         *
-        * @return string
         * @param $array Array: PHP array
         * @param $indent Integer: Pass in false to use the default, which is 2
         * @param $wordwrap Integer: Pass in 0 for no wordwrap, false for default (40)
+        * @return String
         */
        public static function YAMLDump( $array, $indent = false, $wordwrap = false ) {
                $spyc = new Spyc;
@@ -57,13 +59,12 @@ class Spyc {
         * Indent's default is 2 spaces, wordwrap's default is 40 characters.  And
         * you can turn off wordwrap by passing in 0.
         *
-        * @public
-        * @return string
         * @param $array Array: PHP array
         * @param $indent Integer: Pass in false to use the default, which is 2
         * @param $wordwrap Integer: Pass in 0 for no wordwrap, false for default (40)
+        * @return String
         */
-       function dump( $array, $indent = false, $wordwrap = false ) {
+       public function dump( $array, $indent = false, $wordwrap = false ) {
                // Dumps to some very clean YAML.  We'll have to add some more features
                // and options soon.  And better support for folding.
 
@@ -92,12 +93,16 @@ class Spyc {
 
        /**** Private Properties ****/
 
+       /**
+        * Unused variables, but just commented rather than deleting
+        * to save altering the library
        private $_haveRefs;
        private $_allNodes;
        private $_lastIndent;
        private $_lastNode;
        private $_inBlock;
        private $_isInline;
+       **/
        private $_dumpIndent;
        private $_dumpWordWrap;
 
@@ -105,10 +110,11 @@ class Spyc {
 
        /**
         * Attempts to convert a key / value array item to YAML
-        * @return string
-        * @param $key The name of the key
-        * @param $value The value of the item
-        * @param $indent The indent of the current node
+        *
+        * @param $key Mixed: the name of the key
+        * @param $value Mixed: the value of the item
+        * @param $indent Integer: the indent of the current node
+        * @return String
         */
        private function _yamlize( $key, $value, $indent ) {
                if ( is_array( $value ) ) {
@@ -128,9 +134,10 @@ class Spyc {
 
        /**
         * Attempts to convert an array to YAML
-        * @return string
-        * @param $array The array you want to convert
-        * @param $indent The indent of the current level
+        *
+        * @param $array Array: the array you want to convert
+        * @param $indent Integer: the indent of the current level
+        * @return String
         */
        private function _yamlizeArray( $array, $indent ) {
                if ( is_array( $array ) ) {
@@ -140,15 +147,16 @@ class Spyc {
                        }
                        return $string;
                } else {
-                       return false;
+                       return false;
                }
     }
 
        /**
         * Find out whether a string needs to be output as a literal rather than in plain style.
         * Added by Roan Kattouw 13-03-2008
-        * @param $value The string to check
-        * @return bool
+        *
+        * @param $value String: the string to check
+        * @return Boolean
         */
        function _needLiteral( $value ) {
                // Check whether the string contains # or : or begins with any of:
@@ -163,17 +171,18 @@ class Spyc {
 
        /**
         * Returns YAML from a key and a value
-        * @return string
-        * @param $key The name of the key
-        * @param $value The value of the item
-        * @param $indent The indent of the current node
+        *
+        * @param $key Mixed: the name of the key
+        * @param $value Mixed: the value of the item
+        * @param $indent Integer: the indent of the current node
+        * @return String
         */
        private function _dumpNode( $key, $value, $indent ) {
                // do some folding here, for blocks
                if ( $this->_needLiteral( $value ) ) {
                        $value = $this->_doLiteralBlock( $value, $indent );
                } else {
-                       $value  = $this->_doFolding( $value, $indent );
+                       $value = $this->_doFolding( $value, $indent );
                }
 
                $spaces = str_repeat( ' ', $indent );
@@ -185,9 +194,9 @@ class Spyc {
                        else
                                $string = $spaces . "-\n";
                } else {
-                        if ($key == '*') //bug 21922 - Quote asterix used as keys
+                        if ( $key == '*' ) // bug 21922 - Quote asterix used as keys
                                $key = "'*'";
-               
+
                        // It's mapped
                        if ( $value !== '' && !is_null( $value ) )
                                $string = $spaces . $key . ': ' . $value . "\n";
@@ -199,9 +208,10 @@ class Spyc {
 
        /**
         * Creates a literal block for dumping
-        * @return string
-        * @param $value
-        * @param $indent int The value of the indent
+        *
+        * @param $value String
+        * @param $indent Integer: the value of the indent
+        * @return String
         */
        private function _doLiteralBlock( $value, $indent ) {
                $exploded = explode( "\n", $value );
@@ -216,8 +226,10 @@ class Spyc {
 
        /**
         * Folds a string of text, if necessary
-        * @return string
-        * @param $value The string you wish to fold
+        *
+        * @param $value String: the string you wish to fold
+        * @param $indent Integer: the indent of the current node
+        * @return String
         */
        private function _doFolding( $value, $indent ) {
                // Don't do anything if wordwrap is set to 0