cakephp/cakephp — pull request #1276 by aymericderbois (2013-05-07 22:29:09+00:00)
Title: Fix bug in Xml::_toArray Method

Hi !
===

Problem :
=======

Method : Xml::_toArray();

Example :
```php
debug(Xml::toArray(Xml::build('0')));
```

Output is :
```
array(
'tag' => array(
'@type' => 'myType'
)
)
```

That must be :
```
array(
'tag' => array(
'@type' => 'myType',
'@' => 0
)
)
```

Why ?
=====

When a tag has an attribute, Xml::_toArray() test if the value isn't empty, but the string `0` is considered as empty !
```php
$asString = trim((string)$xml);
if (empty($data)) {
$data = $asString;
} elseif (!empty($asString)) {
$data['@'] = $asString;
}
```

Solution :
==========

Check if the string is equals to the string `0`.
```php
$asString = trim((string)$xml);
if (empty($data)) {
$data = $asString;
} elseif (!empty($asString) || $asString === '0') {
$data['@'] = $asString;
}
```