Skip to content

Commit 380b3a1

Browse files
committed
Implement Arrayable interface
1 parent 9bd5368 commit 380b3a1

File tree

5 files changed

+37
-31
lines changed

5 files changed

+37
-31
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
## [Unreleased](https://github.com/inspirum/xml-php/compare/v2.0.0...master)
1010

1111

12+
## [v2.1.0 (2022-07-04)](https://github.com/inspirum/xml-php/compare/v2.0.0...v2.1.0)
13+
### Added
14+
- Implement `\Arrayable` interface
15+
16+
1217
## [v2.0.0 (2022-05-21)](https://github.com/inspirum/xml-php/compare/v1.0.1...v2.0.0)
1318
### Changed
1419
- Support only **PHP 8.1+**
@@ -25,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2530
- Factories for [XML builder](./src/Builder/Document.php) and [XML Reader](./src/Reader/Reader.php)
2631
- Publicly available [`Formatter::nodeToArray`](./src/Formatter/Formatter.php) method
2732

33+
2834
## [v1.0.1 (2020-01-18)](https://github.com/inspirum/xml-php/compare/v1.0.0...v1.0.1)
2935
### Fixed
3036
- Support "_" in elements name

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"name": "inspirum/xml",
3-
"description": "",
3+
"description": "Simple XML writer and memory efficient XML reader with powerful xml-to-array cast",
44
"keywords": [
55
"inspirum",
66
"xml",
77
"xml-reader",
8+
"xml-parser",
89
"xml-writer",
9-
"xml-parser"
10+
"xml-builder",
11+
"xml-to-array"
1012
],
1113
"homepage": "https://github.com/inspirum/xml-php",
1214
"license": "MIT",
@@ -22,19 +24,22 @@
2224
"php": ">=8.1",
2325
"ext-dom": "*",
2426
"ext-json": "*",
25-
"ext-xmlreader": "*"
27+
"ext-xmlreader": "*",
28+
"inspirum/arrayable": "^1.0"
2629
},
2730
"require-dev": {
28-
"inspirum/coding-standard": "^1.0",
29-
"phpstan/phpstan": "^1.6",
31+
"inspirum/coding-standard": "^1.1",
32+
"phpstan/phpstan": "^1.8",
3033
"phpunit/phpunit": "^9.5",
31-
"squizlabs/php_codesniffer": "^3.6"
34+
"squizlabs/php_codesniffer": "^3.7"
3235
},
3336
"autoload": {
3437
"psr-4": {
3538
"Inspirum\\XML\\": "src"
3639
}
3740
},
41+
"minimum-stability": "dev",
42+
"prefer-stable": true,
3843
"autoload-dev": {
3944
"psr-4": {
4045
"Inspirum\\XML\\Tests\\": "tests"

phpunit.xml.dist

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" convertDeprecationsToExceptions="false">
33
<php>
4-
<ini name="display_errors" value="1" />
5-
<ini name="error_reporting" value="-1" />
4+
<ini name="display_errors" value="1"/>
5+
<ini name="error_reporting" value="-1"/>
66
</php>
77
<testsuites>
88
<testsuite name="Unit">
@@ -13,9 +13,6 @@
1313
<include>
1414
<directory suffix=".php">src</directory>
1515
</include>
16-
<exclude>
17-
<directory suffix="Interface.php">src</directory>
18-
</exclude>
1916
<report>
2017
<clover outputFile="var/phpunit/logs/clover.xml"/>
2118
<text outputFile="var/phpunit/coverage/coverage.txt"/>

src/Builder/BaseNode.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,19 @@ public function toArray(?Config $config = null): array
258258
}
259259

260260
/**
261-
* @inheritDoc
261+
* Convert to array
262+
*
263+
* @return array<int|string,mixed>
264+
*/
265+
public function __toArray(): array
266+
{
267+
return $this->toArray();
268+
}
269+
270+
/**
271+
* Convert to array
272+
*
273+
* @return array<int|string,mixed>
262274
*/
263275
public function jsonSerialize(): array
264276
{

src/Builder/Node.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
use DOMDocument;
88
use DOMNode;
9+
use Inspirum\Arrayable\Arrayable;
910
use Inspirum\XML\Formatter\Config;
1011
use JsonSerializable;
1112
use Stringable;
1213

13-
interface Node extends Stringable, JsonSerializable
14+
/**
15+
* @extends \Inspirum\Arrayable\Arrayable<int|string,mixed>
16+
*/
17+
interface Node extends Arrayable, Stringable, JsonSerializable
1418
{
1519
/**
1620
* Add element to XML node
@@ -74,28 +78,10 @@ public function getNode(): ?DOMNode;
7478
*/
7579
public function toString(bool $formatOutput = false): string;
7680

77-
/**
78-
* Convert to string
79-
*
80-
* @see toString()
81-
*
82-
* @return string
83-
*/
84-
public function __toString(): string;
85-
8681
/**
8782
* Convert to array
8883
*
8984
* @return array<int|string,mixed>
9085
*/
9186
public function toArray(?Config $config = null): array;
92-
93-
/**
94-
* Convert to array
95-
*
96-
* @see toArray()
97-
*
98-
* @return array<int|string,mixed>
99-
*/
100-
public function jsonSerialize(): array;
10187
}

0 commit comments

Comments
 (0)