[FEATURE] Add config and use composer autoloader.

We use composer already to install SabreDAV. Include config
composer.(json|lock) to install and manage more dependencies
in future.
Also provide PSR-4 autoloading for our namespaced classes, e.g.
"Zotlabs\". To regenerate autoloader maps use:
$ composer install --optimize-autoloader --no-dev

We could also remove the whole vendor/ folder from our repository, but
that would need changes in deployment and how to install hubs and needs
more discussion first.
This commit is contained in:
Klaus Weidenbach
2016-10-17 23:26:48 +02:00
parent 17091bd38c
commit 745515b11f
51 changed files with 2097 additions and 490 deletions

View File

@@ -1,11 +1,9 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7
- nightly
- hhvm
- 7.0
- 7.1
matrix:
fast_finish: true
@@ -16,10 +14,13 @@ cache:
directories:
- $HOME/.composer/cache
before_install:
- phpenv config-rm xdebug.ini; true
install:
- composer install
script:
- ./bin/phpunit --configuration tests/phpunit.xml.dist
- ./bin/sabre-cs-fixer fix . --dry-run --diff
before_script:
- phpenv config-rm xdebug.ini; true
- composer install

View File

@@ -1,7 +1,16 @@
ChangeLog
=========
1.4.2 (????-??-??)
1.5.0 (2016-10-09)
------------------
* Now requires PHP 5.5.
* Using `finally` to always roll back the context stack when serializing.
* #94: Fixed an infinite loop condition when reading some invalid XML
documents.
1.4.2 (2016-05-19)
------------------
* The `contextStack` in the Reader object is now correctly rolled back in

53
vendor/sabre/xml/composer.json vendored Normal file
View File

@@ -0,0 +1,53 @@
{
"name": "sabre/xml",
"description" : "sabre/xml is an XML library that you may not hate.",
"keywords" : [ "XML", "XMLReader", "XMLWriter", "DOM" ],
"homepage" : "https://sabre.io/xml/",
"license" : "BSD-3-Clause",
"require" : {
"php" : ">=5.5.5",
"ext-xmlwriter" : "*",
"ext-xmlreader" : "*",
"ext-dom" : "*",
"lib-libxml" : ">=2.6.20",
"sabre/uri" : ">=1.0,<3.0.0"
},
"authors" : [
{
"name" : "Evert Pot",
"email" : "me@evertpot.com",
"homepage" : "http://evertpot.com/",
"role" : "Developer"
},
{
"name": "Markus Staab",
"email": "markus.staab@redaxo.de",
"role" : "Developer"
}
],
"support" : {
"forum" : "https://groups.google.com/group/sabredav-discuss",
"source" : "https://github.com/fruux/sabre-xml"
},
"autoload" : {
"psr-4" : {
"Sabre\\Xml\\" : "lib/"
},
"files": [
"lib/Deserializer/functions.php",
"lib/Serializer/functions.php"
]
},
"autoload-dev" : {
"psr-4" : {
"Sabre\\Xml\\" : "tests/Sabre/Xml/"
}
},
"require-dev": {
"sabre/cs": "~1.0.0",
"phpunit/phpunit" : "*"
},
"config" : {
"bin-dir" : "bin/"
}
}

View File

@@ -2,9 +2,9 @@
namespace Sabre\Xml\Element;
use Sabre\Xml\Element;
use Sabre\Xml\Reader;
use Sabre\Xml\Writer;
use Sabre\Xml\Element;
/**
* The XmlFragment element allows you to extract a portion of your xml tree,

View File

@@ -59,22 +59,26 @@ class Reader extends XMLReader {
$previousEntityState = libxml_disable_entity_loader(true);
$previousSetting = libxml_use_internal_errors(true);
// Really sorry about the silence operator, seems like I have no
// choice. See:
//
// https://bugs.php.net/bug.php?id=64230
while ($this->nodeType !== self::ELEMENT && @$this->read()) {
// noop
}
$result = $this->parseCurrentElement();
try {
$errors = libxml_get_errors();
libxml_clear_errors();
libxml_use_internal_errors($previousSetting);
libxml_disable_entity_loader($previousEntityState);
// Really sorry about the silence operator, seems like I have no
// choice. See:
//
// https://bugs.php.net/bug.php?id=64230
while ($this->nodeType !== self::ELEMENT && @$this->read()) {
// noop
}
$result = $this->parseCurrentElement();
if ($errors) {
throw new LibXMLException($errors);
$errors = libxml_get_errors();
libxml_clear_errors();
if ($errors) {
throw new LibXMLException($errors);
}
} finally {
libxml_use_internal_errors($previousSetting);
libxml_disable_entity_loader($previousEntityState);
}
return $result;
@@ -138,60 +142,62 @@ class Reader extends XMLReader {
$this->elementMap = $elementMap;
}
// Really sorry about the silence operator, seems like I have no
// choice. See:
//
// https://bugs.php.net/bug.php?id=64230
if (!@$this->read()) {
try {
// Really sorry about the silence operator, seems like I have no
// choice. See:
//
// https://bugs.php.net/bug.php?id=64230
if (!@$this->read()) {
$errors = libxml_get_errors();
libxml_clear_errors();
if ($errors) {
throw new LibXMLException($errors);
}
throw new ParseException('This should never happen (famous last words)');
}
while (true) {
if (!$this->isValid()) {
$errors = libxml_get_errors();
if ($errors) {
libxml_clear_errors();
throw new LibXMLException($errors);
}
}
switch ($this->nodeType) {
case self::ELEMENT :
$elements[] = $this->parseCurrentElement();
break;
case self::TEXT :
case self::CDATA :
$text .= $this->value;
$this->read();
break;
case self::END_ELEMENT :
// Ensuring we are moving the cursor after the end element.
$this->read();
break 2;
case self::NONE :
throw new ParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.');
default :
// Advance to the next element
$this->read();
break;
}
}
} finally {
if (!is_null($elementMap)) {
$this->popContext();
}
return false;
}
while (true) {
if (!$this->isValid()) {
$errors = libxml_get_errors();
if ($errors) {
libxml_clear_errors();
if (!is_null($elementMap)) {
$this->popContext();
}
throw new LibXMLException($errors);
}
}
switch ($this->nodeType) {
case self::ELEMENT :
$elements[] = $this->parseCurrentElement();
break;
case self::TEXT :
case self::CDATA :
$text .= $this->value;
$this->read();
break;
case self::END_ELEMENT :
// Ensuring we are moving the cursor after the end element.
$this->read();
break 2;
case self::NONE :
if (!is_null($elementMap)) {
$this->popContext();
}
throw new ParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.');
default :
// Advance to the next element
$this->read();
break;
}
}
if (!is_null($elementMap)) {
$this->popContext();
}
return ($elements ? $elements : $text);
@@ -304,7 +310,7 @@ class Reader extends XMLReader {
$deserializer = $this->elementMap[$name];
if (is_subclass_of($deserializer, 'Sabre\\Xml\\XmlDeserializable')) {
return [ $deserializer, 'xmlDeserialize' ];
return [$deserializer, 'xmlDeserialize'];
}
if (is_callable($deserializer)) {

View File

@@ -14,6 +14,6 @@ class Version {
/**
* Full version number
*/
const VERSION = '1.4.1';
const VERSION = '1.5.0';
}

View File

@@ -127,7 +127,7 @@ class Writer extends XMLWriter {
if (array_key_exists($namespace, $this->namespaceMap)) {
$result = $this->startElementNS(
$this->namespaceMap[$namespace] === '' ? null : $this->namespaceMap[$namespace],
$this->namespaceMap[$namespace] === '' ? null : $this->namespaceMap[$namespace],
$localName,
null
);