Skip to content

Commit 953c173

Browse files
committedNov 3, 2023
Dependency for YAML encoding/decoding changed from PECL yaml/yaml-beta extension to Symfony YAML component (#103)
1 parent c60ccf0 commit 953c173

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed
 

Diff for: ‎composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
],
2121
"require": {
2222
"php": ">=7.4.0",
23-
"garoevans/php-enum": "*"
23+
"garoevans/php-enum": "*",
24+
"symfony/yaml": "^6.3"
2425
},
2526
"require-dev": {
2627
"phpunit/phpunit": "*",

Diff for: ‎src/coders/data_coders/data_decoders/YamlDataDecoder.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Exorg\DataCoder;
1313

14+
use Symfony\Component\Yaml\Yaml;
15+
1416
/**
1517
* YamlDataDecoder.
1618
* Data decoder for YAML format.
@@ -36,7 +38,7 @@ public function decodeData($data)
3638

3739
$this->validateData($data);
3840

39-
$parsedData = \yaml_parse($data);
41+
$parsedData = Yaml::parse($data);
4042

4143
$parsingSuccessful = ($parsedData !== null);
4244

Diff for: ‎src/coders/data_coders/data_encoders/YamlDataEncoder.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Exorg\DataCoder;
1313

14+
use Symfony\Component\Yaml\Yaml;
15+
1416
/**
1517
* YamlDataEncoder.
1618
* Data encoder for YAML format.
@@ -34,7 +36,7 @@ public function encodeData($data)
3436
{
3537
$this->validateData($data);
3638

37-
$encodedData = \yaml_emit($data);
39+
$encodedData = Yaml::dump($data);
3840

3941
return $encodedData;
4042
}

Diff for: ‎tests/testing_environment/data/decoded/yaml.php

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
$result = array (
1+
$result = [
22
"firstName" => "John",
33
"lastName" => "Smith",
44
"isAlive" => true,
55
"age" => 25,
66
"height_cm" => 167.6,
7-
"address" => array (
7+
"address" => [
88
"streetAddress" => "21 2nd Street",
99
"city" => "New York",
1010
"state" => "NY",
1111
"postalCode" => "10021-3100",
12-
),
13-
"phoneNumbers" => array (
14-
array (
12+
],
13+
"phoneNumbers" => [
14+
[
1515
"type" => "home",
1616
"number" => "212 555-1234",
17-
),
18-
array (
17+
],
18+
[
1919
"type" => "office",
2020
"number" => "646 555-4567",
21-
),
22-
),
23-
"children" => array (
24-
),
21+
],
22+
],
23+
"children" => [],
2524
"spouse" => null,
26-
);
25+
];

Diff for: ‎tests/testing_environment/data/encoded/data.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
---
21
firstName: John
32
lastName: Smith
43
isAlive: true
54
age: 25
65
height_cm: 167.6
76
address:
8-
streetAddress: 21 2nd Street
9-
city: New York
10-
state: NY
11-
postalCode: 10021-3100
7+
streetAddress: '21 2nd Street'
8+
city: 'New York'
9+
state: NY
10+
postalCode: 10021-3100
1211
phoneNumbers:
13-
- type: home
14-
number: 212 555-1234
15-
- type: office
16-
number: 646 555-4567
17-
children: []
18-
spouse: ~
19-
...
12+
- { type: home, number: '212 555-1234' }
13+
- { type: office, number: '646 555-4567' }
14+
children: { }
15+
spouse: null

0 commit comments

Comments
 (0)
Please sign in to comment.