Always return something nice in Language::translateBlockExpiry()
[lhc/web/wiklou.git] / includes / ConfEditor.php
index c9fd207..d304e65 100644 (file)
@@ -1,4 +1,24 @@
 <?php
+/**
+ * Configuration file editor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
 
 /**
  * This is a state machine style parser with two internal stacks:
@@ -84,6 +104,10 @@ class ConfEditor {
 
        /**
         * Simple entry point for command-line testing
+        *
+        * @param $text string
+        *
+        * @return string
         */
        static function test( $text ) {
                try {
@@ -135,6 +159,8 @@ class ConfEditor {
         * insert
         *    Insert a new element at the start of the array.
         *
+        * @throws MWException
+        * @return string
         */
        public function edit( $ops ) {
                $this->parse();
@@ -306,14 +332,14 @@ class ConfEditor {
        function parseScalar( $str ) {
                if ( $str !== '' && $str[0] == '\'' )
                        // Single-quoted string
-                       // @todo Fixme: trim() call is due to mystery bug where whitespace gets
+                       // @todo FIXME: trim() call is due to mystery bug where whitespace gets
                        // appended to the token; without it we ended up reading in the
                        // extra quote on the end!
                        return strtr( substr( trim( $str ), 1, -1 ),
                                array( '\\\'' => '\'', '\\\\' => '\\' ) );
-               if ( $str !== '' && @$str[0] == '"' )
+               if ( $str !== '' && $str[0] == '"' )
                        // Double-quoted string
-                       // @todo Fixme: trim() call is due to mystery bug where whitespace gets
+                       // @todo FIXME: trim() call is due to mystery bug where whitespace gets
                        // appended to the token; without it we ended up reading in the
                        // extra quote on the end!
                        return stripcslashes( substr( trim( $str ), 1, -1 ) );
@@ -367,6 +393,9 @@ class ConfEditor {
         * Finds the source byte region which you would want to delete, if $pathName
         * was to be deleted. Includes the leading spaces and tabs, the trailing line
         * break, and any comments in between.
+        * @param $pathName
+        * @throws MWException
+        * @return array
         */
        function findDeletionRegion( $pathName ) {
                if ( !isset( $this->pathInfo[$pathName] ) ) {
@@ -424,6 +453,9 @@ class ConfEditor {
         * or semicolon.
         *
         * The end position is the past-the-end (end + 1) value as per convention.
+        * @param $pathName
+        * @throws MWException
+        * @return array
         */
        function findValueRegion( $pathName ) {
                if ( !isset( $this->pathInfo[$pathName] ) ) {
@@ -440,6 +472,7 @@ class ConfEditor {
         * Find the path name of the last element in the array.
         * If the array is empty, this will return the \@extra interstitial element.
         * If the specified path is not found or is not an array, it will return false.
+        * @return bool|int|string
         */
        function findLastArrayElement( $path ) {
                // Try for a real element
@@ -472,10 +505,11 @@ class ConfEditor {
                return $extraPath;
        }
 
-       /*
+       /**
         * Find the path name of first element in the array.
         * If the array is empty, this will return the \@extra interstitial element.
         * If the specified path is not found or is not an array, it will return false.
+        * @return bool|int|string
         */
        function findFirstArrayElement( $path ) {
                // Try for an ordinary element
@@ -500,6 +534,7 @@ class ConfEditor {
        /**
         * Get the indent string which sits after a given start position.
         * Returns false if the position is not at the start of the line.
+        * @return array
         */
        function getIndent( $pos, $key = false, $arrowPos = false ) {
                $arrowIndent = ' ';
@@ -721,6 +756,7 @@ class ConfEditor {
 
        /**
         * Create a ConfEditorToken from an element of token_get_all()
+        * @return ConfEditorToken
         */
        function newTokenObj( $internalToken ) {
                if ( is_array( $internalToken ) ) {
@@ -772,6 +808,7 @@ class ConfEditor {
        /**
         * Get the token $offset steps ahead of the current position.
         * $offset may be negative, to get tokens behind the current position.
+        * @return ConfEditorToken
         */
        function getTokenAhead( $offset ) {
                $pos = $this->pos + $offset;
@@ -817,6 +854,7 @@ class ConfEditor {
 
        /**
         * Pop a state from the state stack.
+        * @return mixed
         */
        function popState() {
                return array_pop( $this->stateStack );
@@ -825,6 +863,7 @@ class ConfEditor {
        /**
         * Returns true if the user input path is valid.
         * This exists to allow "/" and "@" to be reserved for string path keys
+        * @return bool
         */
        function validatePath( $path ) {
                return strpos( $path, '/' ) === false && substr( $path, 0, 1 ) != '@';
@@ -945,6 +984,7 @@ class ConfEditor {
 
        /**
         * Get a readable name for the given token type.
+        * @return string
         */
        function getTypeName( $type ) {
                if ( is_int( $type ) ) {
@@ -958,6 +998,7 @@ class ConfEditor {
         * Looks ahead to see if the given type is the next token type, starting
         * from the current position plus the given offset. Skips any intervening
         * whitespace.
+        * @return bool
         */
        function isAhead( $type, $offset = 0 ) {
                $ahead = $offset;