Repository: nelmio/alice (php)

Issue:
Loader doesn't preserve double backslashes
It seems that loader doesn't preserve double backslashes.

```yaml
prop: |
    \\ these two backslashes become one in object
```

Pull request description:
Fixed issue with double backslash preserving.
Closes #167.

Patch:
diff --git a/src/Nelmio/Alice/Instances/Processor/Methods/UnescapeAt.php b/src/Nelmio/Alice/Instances/Processor/Methods/UnescapeAt.php
index 766d1775..09da1f17 100644
--- a/src/Nelmio/Alice/Instances/Processor/Methods/UnescapeAt.php
+++ b/src/Nelmio/Alice/Instances/Processor/Methods/UnescapeAt.php
@@ -30,6 +30,6 @@ class UnescapeAt implements MethodInterface
     {
         $value = $processable->getValue();
 
-        return preg_replace('{\\\\([@\\\\])}', '$1', $value);
+        return str_replace('\\@', '@', $value);
     }
 }


Test patch:
diff --git a/tests/Nelmio/Alice/Fixtures/LoaderTest.php b/tests/Nelmio/Alice/Fixtures/LoaderTest.php
index 271c5520..58f5a48d 100644
--- a/tests/Nelmio/Alice/Fixtures/LoaderTest.php
+++ b/tests/Nelmio/Alice/Fixtures/LoaderTest.php
@@ -1362,7 +1362,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
         ]);
 
         $this->assertInstanceOf(self::USER, $res['user']);
-        $this->assertSame('@foo \\@foo \\@foo \\foo', $res['user']->username);
+        $this->assertSame('@foo \\@foo \\\\@foo \\foo', $res['user']->username);
     }
 
     public function testAddProcessor()
@@ -1468,6 +1468,13 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
         $this->assertInstanceOf(self::USER, $user1);
         $this->assertEquals('user_alice', $user1->username);
     }
+
+    public function testBackslashes()
+    {
+        $loader = new Loader();
+        $res = $loader->load(__DIR__ . '/../support/fixtures/backslashes.yml');
+        $this->assertEquals('\\\\', $res['user0']->username);
+    }
 }
 
 class FakerProvider
diff --git a/tests/Nelmio/Alice/support/fixtures/backslashes.yml b/tests/Nelmio/Alice/support/fixtures/backslashes.yml
new file mode 100644
index 00000000..64a63fd5
--- /dev/null
+++ b/tests/Nelmio/Alice/support/fixtures/backslashes.yml
@@ -0,0 +1,4 @@
+Nelmio\Alice\support\models\User:
+    user0:
+        username: |-
+            \\