Composer Workspace global packages

This commit is contained in:
Clemens Schwaighofer
2023-08-02 14:52:33 +09:00
parent c383a7b7b7
commit 1fc144e178
239 changed files with 5659 additions and 2712 deletions

View File

@@ -2,6 +2,21 @@
All notable changes to `array-to-xml` will be documented in this file
## 3.1.6 - 2023-05-11
### What's Changed
- V3 - Code smell ('incorrect' method call) by @ExeQue in https://github.com/spatie/array-to-xml/pull/208
- Bump dependabot/fetch-metadata from 1.3.5 to 1.3.6 by @dependabot in https://github.com/spatie/array-to-xml/pull/210
- Bump dependabot/fetch-metadata from 1.3.6 to 1.4.0 by @dependabot in https://github.com/spatie/array-to-xml/pull/214
- Add addXmlDeclaration parameter by @silnex in https://github.com/spatie/array-to-xml/pull/216
### New Contributors
- @silnex made their first contribution in https://github.com/spatie/array-to-xml/pull/216
**Full Changelog**: https://github.com/spatie/array-to-xml/compare/3.1.5...3.1.6
## 3.1.5 - 2022-12-24
### What's Changed

View File

@@ -239,6 +239,58 @@ This will result in:
</helloyouluckypeople>
```
### Using Closure values
The package can use Closure values:
```php
$users = [
[
'name' => 'one',
'age' => 10,
],
[
'name' => 'two',
'age' => 12,
],
];
$array = [
'users' => function () use ($users) {
$new_users = [];
foreach ($users as $user) {
$new_users[] = array_merge(
$user,
[
'double_age' => $user['age'] * 2,
]
);
}
return $new_users;
},
];
ArrayToXml::convert($array)
```
This will result in:
```xml
<?xml version="1.0"?>
<root>
<users>
<name>one</name>
<age>10</age>
<double_age>20</double_age>
</users>
<users>
<name>two</name>
<age>12</age>
<double_age>24</double_age>
</users>
</root>
```
### Handling numeric keys
The package can also can handle numeric keys:

View File

@@ -2,6 +2,7 @@
namespace Spatie\ArrayToXml;
use Closure;
use DOMDocument;
use DOMElement;
use DOMException;
@@ -143,6 +144,10 @@ class ArrayToXml
protected function convertElement(DOMElement $element, mixed $value): void
{
if ($value instanceof Closure) {
$value = $value();
}
$sequential = $this->isArrayAllKeySequential($value);
if (! is_array($value)) {