diff --git a/src/Neon/Encoder.php b/src/Neon/Encoder.php index 30d0d927..3698f969 100644 --- a/src/Neon/Encoder.php +++ b/src/Neon/Encoder.php @@ -28,6 +28,9 @@ public function encode($var, $options = NULL) return $var->format('Y-m-d H:i:s O'); } elseif ($var instanceof Entity) { + if ($var->value === Neon::CHAIN) { + return implode('', array_map(array($this, 'encode'), $var->attributes)); + } return $this->encode($var->value) . '(' . (is_array($var->attributes) ? substr($this->encode($var->attributes), 1, -1) : '') . ')'; } diff --git a/tests/Neon/Encoder.phpt b/tests/Neon/Encoder.phpt index ed9aad30..5c3a9dab 100644 --- a/tests/Neon/Encoder.phpt +++ b/tests/Neon/Encoder.phpt @@ -82,3 +82,12 @@ Assert::same( "foo: 1\nbar:\n\tx:\n\t\t- 1\n\t\t- 2\n\n\ty:\n\t\t- 3\n\t\t- 4\n\nbaz: null\n", Neon::encode(array('foo' => 1, 'bar' => array('x' => array(1, 2), 'y' => array(3, 4)), 'baz' => NULL), Neon::BLOCK) ); + +Assert::same( + 'ent(1)inner(2, 3)', + Neon::encode(Neon::decode('ent(1)inner(2, 3)')) +); +Assert::same( + 'foo(1, 2)::bar(3)', + Neon::encode(Neon::decode('foo(1,2)::bar(3)')) +);