Author: fabien
Date: 2010-02-23 12:15:06 +0100 (Tue, 23 Feb 2010)
New Revision: 28207

Modified:
   branches/2.0/src/Symfony/Components/Yaml/Inline.php
   branches/2.0/src/Symfony/Components/Yaml/Parser.php
   branches/2.0/src/Symfony/Framework/DoctrineBundle/Bundle.php
   
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php
   
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
   branches/2.0/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php
   branches/2.0/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php
   branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/pdo.xml
   
branches/2.0/tests/fixtures/Symfony/Components/Yaml/YtsSpecificationExamples.yml
   branches/2.0/tests/fixtures/Symfony/Components/Yaml/sfComments.yml
   branches/2.0/tests/unit/Symfony/Components/Yaml/DumperTest.php
   branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php
Log:
Merge branch 'master' of git://github.com/symfony/symfony

Modified: branches/2.0/src/Symfony/Components/Yaml/Inline.php
===================================================================
--- branches/2.0/src/Symfony/Components/Yaml/Inline.php 2010-02-23 11:03:51 UTC 
(rev 28206)
+++ branches/2.0/src/Symfony/Components/Yaml/Inline.php 2010-02-23 11:15:06 UTC 
(rev 28207)
@@ -80,7 +80,7 @@
         return is_infinite($value) ? str_ireplace('INF', '.Inf', 
strval($value)) : (is_string($value) ? "'$value'" : $value);
       case false !== strpos($value, "\n") || false !== strpos($value, "\r"):
         return sprintf('"%s"', str_replace(array('"', "\n", "\r"), 
array('\\"', '\n', '\r'), $value));
-      case preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \#] | \A[ - ? | < > = 
! % @ ]/x', $value):
+      case preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > 
= ! % @ ` ]/x', $value):
         return sprintf("'%s'", str_replace('\'', '\'\'', $value));
       case '' == $value:
         return "''";

Modified: branches/2.0/src/Symfony/Components/Yaml/Parser.php
===================================================================
--- branches/2.0/src/Symfony/Components/Yaml/Parser.php 2010-02-23 11:03:51 UTC 
(rev 28206)
+++ branches/2.0/src/Symfony/Components/Yaml/Parser.php 2010-02-23 11:15:06 UTC 
(rev 28207)
@@ -65,7 +65,7 @@
       }
 
       $isRef = $isInPlace = $isProcessed = false;
-      if (preg_match('#^\-(\s+(?P<value>.+?))?\s*$#', $this->currentLine, 
$values))
+      if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#', 
$this->currentLine, $values))
       {
         if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) 
*(?P<value>.*)#', $values['value'], $matches))
         {
@@ -87,13 +87,30 @@
           {
             $data[] = array($matches[1] => Inline::load($matches[2]));
           }
+          elseif (isset($values['leadspaces'])
+            && ' ' == $values['leadspaces']
+            && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ 
\'"].*?) *\:(\s+(?P<value>.+?))?\s*$#', $values['value'], $matches))
+          {
+            // this is a compact notation element, add to next block and parse
+            $c = $this->getRealCurrentLineNb();
+            $parser = new Parser($c);
+            $parser->refs =& $this->refs;
+
+            $block = $values['value'];
+            if (!$this->isNextLineIndented())
+            {
+              $block .= "\n".$this->getNextEmbedBlock();
+            }
+
+            $data[] = $parser->parse($block);
+          }
           else
           {
             $data[] = $this->parseValue($values['value']);
           }
         }
       }
-      else if (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ ].*?) 
*\:(\s+(?P<value>.+?))?\s*$#', $this->currentLine, $values))
+      else if (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ 
\'"].*?) *\:(\s+(?P<value>.+?))?\s*$#', $this->currentLine, $values))
       {
         $key = Inline::parseScalar($values['key']);
 
@@ -547,10 +564,18 @@
     }
 
     // strip YAML header
-    preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);
+    $count = 0;
+    $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value, -1, $count);
+    $this->offset += $count;
 
-    // remove ---
-    $value = preg_replace('#^\-\-\-.*?\n#s', '', $value);
+    // remove leading comments and/or ---
+    $trimmedValue = preg_replace('#^((\#.*?\n)|(\-\-\-.*?\n))*#s', '', $value, 
-1, $count);
+    if ($count == 1)
+    {
+      // items have been removed, update the offset
+      $this->offset += substr_count($value, "\n") - 
substr_count($trimmedValue, "\n");
+      $value = $trimmedValue;
+    }
 
     return $value;
   }

Modified: branches/2.0/src/Symfony/Framework/DoctrineBundle/Bundle.php
===================================================================
--- branches/2.0/src/Symfony/Framework/DoctrineBundle/Bundle.php        
2010-02-23 11:03:51 UTC (rev 28206)
+++ branches/2.0/src/Symfony/Framework/DoctrineBundle/Bundle.php        
2010-02-23 11:15:06 UTC (rev 28207)
@@ -36,7 +36,7 @@
     foreach ($container->getParameter('kernel.bundles') as $className)
     {
       $tmp = dirname(str_replace('\\', '/', $className));
-      $namespace = dirname($tmp);
+      $namespace = str_replace('/', '\\', dirname($tmp));
       $class = basename($tmp);
 
       if (isset($bundleDirs[$namespace]))
@@ -54,4 +54,4 @@
     $container->setParameter('doctrine.orm.metadata_driver_impl.dirs', 
$metadataDirs);
     $container->setParameter('doctrine.entity_dirs', $entityDirs);
   }
-}
\ No newline at end of file
+}

Modified: 
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php
===================================================================
--- 
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php
        2010-02-23 11:03:51 UTC (rev 28206)
+++ 
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php
        2010-02-23 11:15:06 UTC (rev 28207)
@@ -48,7 +48,7 @@
     foreach ($this->container->getKernelService()->getBundles() as $bundle)
     {
       $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
-      $namespace = dirname($tmp);
+      $namespace = str_replace('/', '\\', dirname($tmp));
       $class = basename($tmp);
 
       if (isset($bundleDirs[$namespace]) && is_dir($dir = 
$bundleDirs[$namespace].'/'.$class.'/Entities'))
@@ -67,4 +67,4 @@
       $this->runDoctrineCliTask('orm:generate-proxies', array('class-dir' => 
$dir));
     }
   }
-}
\ No newline at end of file
+}

Modified: 
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
===================================================================
--- 
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
       2010-02-23 11:03:51 UTC (rev 28206)
+++ 
branches/2.0/src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
       2010-02-23 11:15:06 UTC (rev 28207)
@@ -88,7 +88,7 @@
       foreach ($this->container->getKernelService()->getBundles() as $bundle)
       {
         $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
-        $namespace = dirname($tmp);
+        $namespace = str_replace('/', '\\', dirname($tmp));
         $class = basename($tmp);
 
         if (isset($bundleDirs[$namespace]) && is_dir($dir = 
$bundleDirs[$namespace].'/'.$class.'/Resources/data/fixtures/doctrine'))
@@ -154,4 +154,4 @@
 
     return $calc->getCommitOrder();
   }
-}
\ No newline at end of file
+}

Modified: 
branches/2.0/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php
===================================================================
--- 
branches/2.0/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php   
    2010-02-23 11:03:51 UTC (rev 28206)
+++ 
branches/2.0/src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php   
    2010-02-23 11:15:06 UTC (rev 28207)
@@ -56,7 +56,7 @@
     foreach ($this->container->getKernelService()->getBundles() as $bundle)
     {
       $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
-      $namespace = dirname($tmp);
+      $namespace = str_replace('/', '\\', dirname($tmp));
       $class = basename($tmp);
 
       if (isset($dirs[$namespace]) && is_dir($originDir = 
$dirs[$namespace].'/'.$class.'/Resources/public'))

Modified: 
branches/2.0/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php
===================================================================
--- branches/2.0/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php  
2010-02-23 11:03:51 UTC (rev 28206)
+++ branches/2.0/src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php  
2010-02-23 11:15:06 UTC (rev 28207)
@@ -54,7 +54,7 @@
     $dirs = $this->container->getKernelService()->getBundleDirs();
 
     $tmp = str_replace('\\', '/', $namespace);
-    $namespace = dirname($tmp);
+    $namespace = str_replace('/', '\\', dirname($tmp));
     $bundle = basename($tmp);
 
     if (!isset($dirs[$namespace]))

Modified: branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/pdo.xml
===================================================================
--- branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/pdo.xml       
2010-02-23 11:03:51 UTC (rev 28206)
+++ branches/2.0/src/Symfony/Framework/WebBundle/Resources/config/pdo.xml       
2010-02-23 11:15:06 UTC (rev 28207)
@@ -5,7 +5,7 @@
     xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services 
http://www.symfony-project.org/schema/dic/services/services-1.0.xsd";>
 
   <service id="pdo_connection" class="PDO">
-    <argument key="dns">%pdo.dsn%</argument>
+    <argument key="dsn">%pdo.dsn%</argument>
     <argument key="username">%pdo.username%</argument>
     <argument key="password">%pdo.password%</argument>
   </service>

Modified: 
branches/2.0/tests/fixtures/Symfony/Components/Yaml/YtsSpecificationExamples.yml
===================================================================
--- 
branches/2.0/tests/fixtures/Symfony/Components/Yaml/YtsSpecificationExamples.yml
    2010-02-23 11:03:51 UTC (rev 28206)
+++ 
branches/2.0/tests/fixtures/Symfony/Components/Yaml/YtsSpecificationExamples.yml
    2010-02-23 11:15:06 UTC (rev 28207)
@@ -149,7 +149,7 @@
       hr: 63,
       avg: 0.288
     }
-ruby: | 
+php: | 
   array(  
     'Mark McGwire' => 
       array( 'hr' => 65, 'avg' => 0.278 ), 
@@ -286,7 +286,6 @@
  
 --- 
 test: Sequence key shortcut 
-todo: true
 spec: 2.12
 yaml: | 
   ---
@@ -297,6 +296,21 @@
     quantity: 4
   - item    : Big Shoes
     quantity: 1
+php: | 
+  array (
+    array (
+      'item' => 'Super Hoop',
+      'quantity' => 1,
+    ),
+    array (
+      'item' => 'Basketball',
+      'quantity' => 4,
+    ),
+    array (
+      'item' => 'Big Shoes',
+      'quantity' => 1,
+    )
+  )
 perl: | 
   [  
      { item => 'Super Hoop', quantity => 1 }, 

Modified: branches/2.0/tests/fixtures/Symfony/Components/Yaml/sfComments.yml
===================================================================
--- branches/2.0/tests/fixtures/Symfony/Components/Yaml/sfComments.yml  
2010-02-23 11:03:51 UTC (rev 28206)
+++ branches/2.0/tests/fixtures/Symfony/Components/Yaml/sfComments.yml  
2010-02-23 11:15:06 UTC (rev 28207)
@@ -38,4 +38,14 @@
 yaml: | 
     foo:   '#bar' 
 php: | 
-    array('foo' => '#bar') 
\ No newline at end of file
+    array('foo' => '#bar')
+---
+test: Document starting with a comment and a separator
+brief: >
+  Commenting before document start is allowed
+yaml: |
+    # document comment
+    ---
+    foo: bar # a comment
+php: |
+    array('foo' => 'bar')

Modified: branches/2.0/tests/unit/Symfony/Components/Yaml/DumperTest.php
===================================================================
--- branches/2.0/tests/unit/Symfony/Components/Yaml/DumperTest.php      
2010-02-23 11:03:51 UTC (rev 28206)
+++ branches/2.0/tests/unit/Symfony/Components/Yaml/DumperTest.php      
2010-02-23 11:15:06 UTC (rev 28207)
@@ -16,7 +16,7 @@
 
 Yaml::setSpecVersion('1.1');
 
-$t = new LimeTest(149);
+$t = new LimeTest(150);
 
 $parser = new Parser();
 $dumper = new Dumper();

Modified: branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php
===================================================================
--- branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php      
2010-02-23 11:03:51 UTC (rev 28206)
+++ branches/2.0/tests/unit/Symfony/Components/Yaml/ParserTest.php      
2010-02-23 11:15:06 UTC (rev 28207)
@@ -16,7 +16,7 @@
 
 Yaml::setSpecVersion('1.1');
 
-$t = new LimeTest(149);
+$t = new LimeTest(150);
 
 $parser = new Parser();
 

-- 
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