更新
This commit is contained in:
12
vendor/alibabacloud/tea-xml/.gitignore
vendored
Normal file
12
vendor/alibabacloud/tea-xml/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
composer.lock
|
||||
|
||||
.idea
|
||||
.DS_Store
|
||||
|
||||
cache/
|
||||
*.cache
|
||||
65
vendor/alibabacloud/tea-xml/.php_cs.dist
vendored
Normal file
65
vendor/alibabacloud/tea-xml/.php_cs.dist
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*
|
||||
* This document has been generated with
|
||||
* https://mlocati.github.io/php-cs-fixer-configurator/#version:2.15|configurator
|
||||
* you can change this configuration by importing this file.
|
||||
*/
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setIndent(' ')
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'@PhpCsFixer' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'array_indentation' => true,
|
||||
'combine_consecutive_unsets' => true,
|
||||
'method_separation' => true,
|
||||
'single_quote' => true,
|
||||
'declare_equal_normalize' => true,
|
||||
'function_typehint_space' => true,
|
||||
'hash_to_slash_comment' => true,
|
||||
'include' => true,
|
||||
'lowercase_cast' => true,
|
||||
'no_multiline_whitespace_before_semicolons' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'no_spaces_around_offset' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'single_class_element_per_statement' => true,
|
||||
'space_after_semicolon' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
'no_extra_consecutive_blank_lines' => [
|
||||
'curly_brace_block',
|
||||
'extra',
|
||||
'parenthesis_brace_block',
|
||||
'square_brace_block',
|
||||
'throw',
|
||||
'use',
|
||||
],
|
||||
'binary_operator_spaces' => [
|
||||
'align_double_arrow' => true,
|
||||
'align_equals' => true,
|
||||
],
|
||||
'braces' => [
|
||||
'allow_single_line_closure' => true,
|
||||
],
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->exclude('tests')
|
||||
->in(__DIR__)
|
||||
);
|
||||
31
vendor/alibabacloud/tea-xml/README-CN.md
vendored
Normal file
31
vendor/alibabacloud/tea-xml/README-CN.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
English | [简体中文](README-CN.md)
|
||||
|
||||

|
||||
|
||||
## Alibaba Cloud Tea XML Library for PHP
|
||||
|
||||
## Installation
|
||||
|
||||
### Composer
|
||||
|
||||
```bash
|
||||
composer require alibabacloud/tea-xml
|
||||
```
|
||||
|
||||
## Issues
|
||||
|
||||
[Opening an Issue](https://github.com/aliyun/tea-xml/issues/new), Issues not conforming to the guidelines may be closed immediately.
|
||||
|
||||
## Changelog
|
||||
|
||||
Detailed changes for each release are documented in the [release notes](./ChangeLog.txt).
|
||||
|
||||
## References
|
||||
|
||||
* [Latest Release](https://github.com/aliyun/tea-xml)
|
||||
|
||||
## License
|
||||
|
||||
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
31
vendor/alibabacloud/tea-xml/README.md
vendored
Normal file
31
vendor/alibabacloud/tea-xml/README.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
[English](README.md) | 简体中文
|
||||
|
||||

|
||||
|
||||
## Alibaba Cloud Tea XML Library for PHP
|
||||
|
||||
## 安装
|
||||
|
||||
### Composer
|
||||
|
||||
```bash
|
||||
composer require alibabacloud/tea-xml
|
||||
```
|
||||
|
||||
## 问题
|
||||
|
||||
[提交 Issue](https://github.com/aliyun/tea-xml/issues/new),不符合指南的问题可能会立即关闭。
|
||||
|
||||
## 发行说明
|
||||
|
||||
每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。
|
||||
|
||||
## 相关
|
||||
|
||||
* [最新源码](https://github.com/aliyun/tea-xml)
|
||||
|
||||
## 许可证
|
||||
|
||||
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
44
vendor/alibabacloud/tea-xml/composer.json
vendored
Normal file
44
vendor/alibabacloud/tea-xml/composer.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "alibabacloud/tea-xml",
|
||||
"description": "Alibaba Cloud Tea XML Library for PHP",
|
||||
"type": "library",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alibaba Cloud SDK",
|
||||
"email": "sdk-team@alibabacloud.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*",
|
||||
"symfony/var-dumper": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AlibabaCloud\\Tea\\XML\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"AlibabaCloud\\Tea\\XML\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"fixer": "php-cs-fixer fix ./",
|
||||
"test": [
|
||||
"@clearCache",
|
||||
"phpunit --colors=always"
|
||||
],
|
||||
"clearCache": "rm -rf cache/*"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
32
vendor/alibabacloud/tea-xml/phpunit.xml
vendored
Normal file
32
vendor/alibabacloud/tea-xml/phpunit.xml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false"
|
||||
convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"
|
||||
testSuiteLoaderFile="phpunit/src/Runner/StandardTestSuiteLoader.php">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="All">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>integration</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-html" target="cache/coverage" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="cache/coverage.clover"/>
|
||||
</logging>
|
||||
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
151
vendor/alibabacloud/tea-xml/src/ArrayToXml.php
vendored
Normal file
151
vendor/alibabacloud/tea-xml/src/ArrayToXml.php
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Tea\XML;
|
||||
|
||||
use XmlWriter;
|
||||
|
||||
/**
|
||||
* Based on: http://stackoverflow.com/questions/99350/passing-php-associative-arrays-to-and-from-xml.
|
||||
*/
|
||||
class ArrayToXml
|
||||
{
|
||||
private $version;
|
||||
private $encoding;
|
||||
|
||||
/**
|
||||
* Construct ArrayToXML object with selected version and encoding
|
||||
* for available values check XmlWriter docs http://www.php.net/manual/en/function.xmlwriter-start-document.php.
|
||||
*
|
||||
* @param string $xmlVersion XML Version, default 1.0
|
||||
* @param string $xmlEncoding XML Encoding, default UTF-8
|
||||
*/
|
||||
public function __construct($xmlVersion = '1.0', $xmlEncoding = 'utf-8')
|
||||
{
|
||||
$this->version = $xmlVersion;
|
||||
$this->encoding = $xmlEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an XML Data Set.
|
||||
*
|
||||
* @param array $data Associative Array containing values to be parsed into an XML Data Set(s)
|
||||
* @param string $startElement Root Opening Tag, default data
|
||||
*
|
||||
* @return string XML String containing values
|
||||
* @return mixed Boolean false on failure, string XML result on success
|
||||
*/
|
||||
public function buildXML($data, $startElement = 'data')
|
||||
{
|
||||
if (!\is_array($data)) {
|
||||
$err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__;
|
||||
trigger_error($err);
|
||||
|
||||
return false; //return false error occurred
|
||||
}
|
||||
$xml = new XmlWriter();
|
||||
$xml->openMemory();
|
||||
$xml->startDocument($this->version, $this->encoding);
|
||||
$xml->startElement($startElement);
|
||||
$data = $this->writeAttr($xml, $data);
|
||||
$this->writeEl($xml, $data);
|
||||
$xml->endElement(); //write end element
|
||||
//returns the XML results
|
||||
return $xml->outputMemory(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write keys in $data prefixed with @ as XML attributes, if $data is an array.
|
||||
* When an @ prefixed key is found, a '%' key is expected to indicate the element itself,
|
||||
* and '#' prefixed key indicates CDATA content.
|
||||
*
|
||||
* @param XMLWriter $xml object
|
||||
* @param array $data with attributes filtered out
|
||||
*
|
||||
* @return array $data | $nonAttributes
|
||||
*/
|
||||
protected function writeAttr(XMLWriter $xml, $data)
|
||||
{
|
||||
if (\is_array($data)) {
|
||||
$nonAttributes = [];
|
||||
foreach ($data as $key => $val) {
|
||||
//handle an attribute with elements
|
||||
if ('@' == $key[0]) {
|
||||
$xml->writeAttribute(substr($key, 1), $val);
|
||||
} elseif ('%' == $key[0]) {
|
||||
if (\is_array($val)) {
|
||||
$nonAttributes = $val;
|
||||
} else {
|
||||
$xml->text($val);
|
||||
}
|
||||
} elseif ('#' == $key[0]) {
|
||||
if (\is_array($val)) {
|
||||
$nonAttributes = $val;
|
||||
} else {
|
||||
$xml->startElement(substr($key, 1));
|
||||
$xml->writeCData($val);
|
||||
$xml->endElement();
|
||||
}
|
||||
} elseif ('!' == $key[0]) {
|
||||
if (\is_array($val)) {
|
||||
$nonAttributes = $val;
|
||||
} else {
|
||||
$xml->writeCData($val);
|
||||
}
|
||||
} //ignore normal elements
|
||||
else {
|
||||
$nonAttributes[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $nonAttributes;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write XML as per Associative Array.
|
||||
*
|
||||
* @param XMLWriter $xml object
|
||||
* @param array $data Associative Data Array
|
||||
*/
|
||||
protected function writeEl(XMLWriter $xml, $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if (\is_array($value) && !$this->isAssoc($value)) { //numeric array
|
||||
foreach ($value as $itemValue) {
|
||||
if (\is_array($itemValue)) {
|
||||
$xml->startElement($key);
|
||||
$itemValue = $this->writeAttr($xml, $itemValue);
|
||||
$this->writeEl($xml, $itemValue);
|
||||
$xml->endElement();
|
||||
} else {
|
||||
$itemValue = $this->writeAttr($xml, $itemValue);
|
||||
$xml->writeElement($key, "{$itemValue}");
|
||||
}
|
||||
}
|
||||
} elseif (\is_array($value)) { //associative array
|
||||
$xml->startElement($key);
|
||||
$value = $this->writeAttr($xml, $value);
|
||||
$this->writeEl($xml, $value);
|
||||
$xml->endElement();
|
||||
} else { //scalar
|
||||
$value = $this->writeAttr($xml, $value);
|
||||
$xml->writeElement($key, "{$value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if array is associative with string based keys
|
||||
* FROM: http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential/4254008#4254008.
|
||||
*
|
||||
* @param array $array Array to check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return (bool) \count(array_filter(array_keys($array), 'is_string'));
|
||||
}
|
||||
}
|
||||
59
vendor/alibabacloud/tea-xml/src/XML.php
vendored
Normal file
59
vendor/alibabacloud/tea-xml/src/XML.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Tea\XML;
|
||||
|
||||
class XML
|
||||
{
|
||||
public static function parseXml($xmlStr, $response)
|
||||
{
|
||||
$res = self::parse($xmlStr);
|
||||
if ($response === null) {
|
||||
return $res;
|
||||
} else {
|
||||
if (\is_string($response)) {
|
||||
$response = new $response();
|
||||
}
|
||||
$prop = get_object_vars($response);
|
||||
$target = [];
|
||||
|
||||
foreach ($res as $k => $v) {
|
||||
if (isset($prop[$k])) {
|
||||
$target[$k] = $v;
|
||||
}
|
||||
}
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
|
||||
public static function toXML($array)
|
||||
{
|
||||
$arrayToXml = new ArrayToXml();
|
||||
if (\is_object($array)) {
|
||||
$tmp = explode('\\', \get_class($array));
|
||||
$rootName = $tmp[\count($tmp) - 1];
|
||||
$data = json_decode(json_encode($array), true);
|
||||
} else {
|
||||
$tmp = $array;
|
||||
reset($tmp);
|
||||
$rootName = key($tmp);
|
||||
$data = $array[$rootName];
|
||||
}
|
||||
ksort($data);
|
||||
|
||||
return $arrayToXml->buildXML($data, $rootName);
|
||||
}
|
||||
|
||||
private static function parse($xml)
|
||||
{
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader(true);
|
||||
}
|
||||
|
||||
return json_decode(
|
||||
json_encode(
|
||||
simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
59
vendor/alibabacloud/tea-xml/tests/XMLTest.php
vendored
Normal file
59
vendor/alibabacloud/tea-xml/tests/XMLTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Tea\XML\Tests;
|
||||
|
||||
use AlibabaCloud\Tea\XML\XML;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class RpcUtilsTest extends TestCase
|
||||
{
|
||||
private $xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" .
|
||||
"<tests>\n" .
|
||||
" <name>test</name>\n" .
|
||||
" <value>1</value>\n" .
|
||||
"</tests>\n";
|
||||
|
||||
public function testParseXml()
|
||||
{
|
||||
$res = XML::parseXml($this->xmlStr, new tests());
|
||||
$name = $res['name'];
|
||||
$value = $res['value'];
|
||||
$this->assertEquals('test', $name);
|
||||
$this->assertEquals(1, $value);
|
||||
|
||||
$res = XML::parseXml($this->xmlStr, null);
|
||||
$name = $res['name'];
|
||||
$value = $res['value'];
|
||||
$this->assertEquals('test', $name);
|
||||
$this->assertEquals(1, $value);
|
||||
}
|
||||
|
||||
public function testArrayToXML()
|
||||
{
|
||||
$data = [
|
||||
'tests' => [
|
||||
'name' => 'test',
|
||||
'value' => 1,
|
||||
],
|
||||
];
|
||||
$this->assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tests><name>test</name><value>1</value></tests>", XML::toXML($data));
|
||||
}
|
||||
|
||||
public function testObjectToXML()
|
||||
{
|
||||
$obj = new tests();
|
||||
$obj->name = 'test';
|
||||
$obj->value = 1;
|
||||
$this->assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tests><name>test</name><value>1</value></tests>", XML::toXML($obj));
|
||||
}
|
||||
}
|
||||
|
||||
class tests
|
||||
{
|
||||
public $name = '';
|
||||
public $value = 0;
|
||||
}
|
||||
3
vendor/alibabacloud/tea-xml/tests/bootstrap.php
vendored
Normal file
3
vendor/alibabacloud/tea-xml/tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
Reference in New Issue
Block a user