Author: fabien
Date: 2010-02-11 20:30:06 +0100 (Thu, 11 Feb 2010)
New Revision: 27919

Added:
   branches/2.0/src/Symfony/Components/Yaml/Exception.php
   branches/2.0/src/Symfony/Components/Yaml/ParserException.php
Modified:
   branches/2.0/src/Symfony/Components/Yaml/Inline.php
   branches/2.0/src/Symfony/Components/Yaml/Parser.php
   branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php
Log:
Merge branch 'master' of git://github.com/symfony/symfony

Added: branches/2.0/src/Symfony/Components/Yaml/Exception.php
===================================================================
--- branches/2.0/src/Symfony/Components/Yaml/Exception.php                      
        (rev 0)
+++ branches/2.0/src/Symfony/Components/Yaml/Exception.php      2010-02-11 
19:30:06 UTC (rev 27919)
@@ -0,0 +1,23 @@
+<?php
+
+namespace Symfony\Components\Yaml;
+
+/*
+ * This file is part of the symfony package.
+ *
+ * (c) Fabien Potencier <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Exception class used by all exceptions thrown by the component.
+ *
+ * @package    symfony
+ * @subpackage yaml
+ * @author     Fabien Potencier <[email protected]>
+ */
+class Exception extends \Exception
+{
+}

Modified: branches/2.0/src/Symfony/Components/Yaml/Inline.php
===================================================================
--- branches/2.0/src/Symfony/Components/Yaml/Inline.php 2010-02-11 19:16:59 UTC 
(rev 27918)
+++ branches/2.0/src/Symfony/Components/Yaml/Inline.php 2010-02-11 19:30:06 UTC 
(rev 27919)
@@ -63,7 +63,7 @@
     switch (true)
     {
       case is_resource($value):
-        throw new \InvalidArgumentException('Unable to dump PHP resources in a 
YAML file.');
+        throw new Exception('Unable to dump PHP resources in a YAML file.');
       case is_object($value):
         return '!!php/object:'.serialize($value);
       case is_array($value):
@@ -171,7 +171,7 @@
       }
       else
       {
-        throw new \InvalidArgumentException(sprintf('Malformed inline YAML 
string (%s).', $scalar));
+        throw new ParserException(sprintf('Malformed inline YAML string 
(%s).', $scalar));
       }
 
       $output = $evaluate ? self::evaluateScalar($output) : $output;
@@ -192,7 +192,7 @@
   {
     if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/A', substr($scalar, $i), 
$match))
     {
-      throw new \InvalidArgumentException(sprintf('Malformed inline YAML 
string (%s).', substr($scalar, $i)));
+      throw new ParserException(sprintf('Malformed inline YAML string (%s).', 
substr($scalar, $i)));
     }
 
     $output = substr($match[0], 1, strlen($match[0]) - 2);
@@ -270,7 +270,7 @@
       ++$i;
     }
 
-    throw new \InvalidArgumentException(sprintf('Malformed inline YAML string 
%s', $sequence));
+    throw new ParserException(sprintf('Malformed inline YAML string %s', 
$sequence));
   }
 
   /**
@@ -337,7 +337,7 @@
       }
     }
 
-    throw new \InvalidArgumentException(sprintf('Malformed inline YAML string 
%s', $mapping));
+    throw new ParserException(sprintf('Malformed inline YAML string %s', 
$mapping));
   }
 
   /**

Modified: branches/2.0/src/Symfony/Components/Yaml/Parser.php
===================================================================
--- branches/2.0/src/Symfony/Components/Yaml/Parser.php 2010-02-11 19:16:59 UTC 
(rev 27918)
+++ branches/2.0/src/Symfony/Components/Yaml/Parser.php 2010-02-11 19:30:06 UTC 
(rev 27919)
@@ -63,7 +63,7 @@
       // tab?
       if (preg_match('#^\t+#', $this->currentLine))
       {
-        throw new \InvalidArgumentException(sprintf('A YAML file cannot 
contain tabs as indentation at line %d (%s).', $this->getRealCurrentLineNb() + 
1, $this->currentLine));
+        throw new ParserException(sprintf('A YAML file cannot contain tabs as 
indentation at line %d (%s).', $this->getRealCurrentLineNb() + 1, 
$this->currentLine));
       }
 
       $isRef = $isInPlace = $isProcessed = false;
@@ -106,7 +106,7 @@
             $isInPlace = substr($values['value'], 1);
             if (!array_key_exists($isInPlace, $this->refs))
             {
-              throw new \InvalidArgumentException(sprintf('Reference "%s" does 
not exist at line %s (%s).', $isInPlace, $this->getRealCurrentLineNb() + 1, 
$this->currentLine));
+              throw new ParserException(sprintf('Reference "%s" does not exist 
at line %s (%s).', $isInPlace, $this->getRealCurrentLineNb() + 1, 
$this->currentLine));
             }
           }
           else
@@ -127,7 +127,7 @@
             $merged = array();
             if (!is_array($parsed))
             {
-              throw new \InvalidArgumentException(sprintf("YAML merge keys 
used with a scalar value instead of an array at line %s (%s)", 
$this->getRealCurrentLineNb() + 1, $this->currentLine));
+              throw new ParserException(sprintf("YAML merge keys used with a 
scalar value instead of an array at line %s (%s)", 
$this->getRealCurrentLineNb() + 1, $this->currentLine));
             }
             else if (isset($parsed[0]))
             {
@@ -136,7 +136,7 @@
               {
                 if (!is_array($parsedItem))
                 {
-                  throw new \InvalidArgumentException(sprintf("Merge items 
must be arrays at line %s (%s).", $this->getRealCurrentLineNb() + 1, 
$parsedItem));
+                  throw new ParserException(sprintf("Merge items must be 
arrays at line %s (%s).", $this->getRealCurrentLineNb() + 1, $parsedItem));
                 }
                 $merged = array_merge($parsedItem, $merged);
               }
@@ -233,7 +233,7 @@
             $error = 'Unable to parse line';
         }
 
-        throw new \InvalidArgumentException(sprintf('%s %d (%s).', $error, 
$this->getRealCurrentLineNb() + 1, $this->currentLine));
+        throw new ParserException(sprintf('%s %d (%s).', $error, 
$this->getRealCurrentLineNb() + 1, $this->currentLine));
       }
 
       if ($isRef)
@@ -278,7 +278,7 @@
 
     if (!$this->isCurrentLineEmpty() && 0 == $newIndent)
     {
-      throw new \InvalidArgumentException(sprintf('Indentation problem at line 
%d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
+      throw new ParserException(sprintf('Indentation problem at line %d (%s)', 
$this->getRealCurrentLineNb() + 1, $this->currentLine));
     }
 
     $data = array(substr($this->currentLine, $newIndent));
@@ -314,7 +314,7 @@
       }
       else
       {
-        throw new \InvalidArgumentException(sprintf('Indentation problem at 
line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
+        throw new ParserException(sprintf('Indentation problem at line %d 
(%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
       }
     }
 
@@ -366,7 +366,7 @@
 
       if (!array_key_exists($value, $this->refs))
       {
-        throw new \InvalidArgumentException(sprintf('Reference "%s" does not 
exist (%s).', $value, $this->currentLine));
+        throw new ParserException(sprintf('Reference "%s" does not exist 
(%s).', $value, $this->currentLine));
       }
       return $this->refs[$value];
     }

Added: branches/2.0/src/Symfony/Components/Yaml/ParserException.php
===================================================================
--- branches/2.0/src/Symfony/Components/Yaml/ParserException.php                
                (rev 0)
+++ branches/2.0/src/Symfony/Components/Yaml/ParserException.php        
2010-02-11 19:30:06 UTC (rev 27919)
@@ -0,0 +1,23 @@
+<?php
+
+namespace Symfony\Components\Yaml;
+
+/*
+ * This file is part of the symfony package.
+ *
+ * (c) Fabien Potencier <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Exception class used by all exceptions thrown by the component.
+ *
+ * @package    symfony
+ * @subpackage yaml
+ * @author     Fabien Potencier <[email protected]>
+ */
+class ParserException extends Exception
+{
+}

Modified: branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php
===================================================================
--- branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php      
2010-02-11 19:16:59 UTC (rev 27918)
+++ branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php      
2010-02-11 19:30:06 UTC (rev 27919)
@@ -12,6 +12,7 @@
 
 use Symfony\Components\Yaml\Yaml;
 use Symfony\Components\Yaml\Parser;
+use Symfony\Components\Yaml\ParserException;
 
 Yaml::setSpecVersion('1.1');
 
@@ -64,7 +65,7 @@
     $content = $parser->parse($yaml);
     $t->fail('YAML files must not contain tabs');
   }
-  catch (InvalidArgumentException $e)
+  catch (ParserException $e)
   {
     $t->pass('YAML files must not contain tabs');
   }

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to