aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/xml/lib/Service.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/xml/lib/Service.php')
-rw-r--r--vendor/sabre/xml/lib/Service.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/vendor/sabre/xml/lib/Service.php b/vendor/sabre/xml/lib/Service.php
index a8e34d254..6e522630e 100644
--- a/vendor/sabre/xml/lib/Service.php
+++ b/vendor/sabre/xml/lib/Service.php
@@ -105,16 +105,23 @@ class Service
*
* @param string|resource $input
*
- * @throws ParseException
- *
* @return array|object|string
+ *
+ * @throws ParseException
*/
- public function parse($input, string $contextUri = null, string &$rootElementName = null)
+ public function parse($input, ?string $contextUri = null, ?string &$rootElementName = null)
{
- if (is_resource($input)) {
+ if (!is_string($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
- $input = (string) stream_get_contents($input);
+ if (is_resource($input)) {
+ $input = (string) stream_get_contents($input);
+ } else {
+ // Input is not a string and not a resource.
+ // Therefore, it has to be a closed resource.
+ // Effectively empty input has been passed in.
+ $input = '';
+ }
}
// If input is empty, then it's safe to throw an exception
@@ -149,16 +156,23 @@ class Service
* @param string|string[] $rootElementName
* @param string|resource $input
*
- * @throws ParseException
- *
* @return array|object|string
+ *
+ * @throws ParseException
*/
- public function expect($rootElementName, $input, string $contextUri = null)
+ public function expect($rootElementName, $input, ?string $contextUri = null)
{
- if (is_resource($input)) {
+ if (!is_string($input)) {
// Unfortunately the XMLReader doesn't support streams. When it
// does, we can optimize this.
- $input = (string) stream_get_contents($input);
+ if (is_resource($input)) {
+ $input = (string) stream_get_contents($input);
+ } else {
+ // Input is not a string and not a resource.
+ // Therefore, it has to be a closed resource.
+ // Effectively empty input has been passed in.
+ $input = '';
+ }
}
// If input is empty, then it's safe to throw an exception
@@ -204,7 +218,7 @@ class Service
*
* @return string
*/
- public function write(string $rootElementName, $value, string $contextUri = null)
+ public function write(string $rootElementName, $value, ?string $contextUri = null)
{
$w = $this->getWriter();
$w->openMemory();
@@ -266,7 +280,7 @@ class Service
*
* @throws \InvalidArgumentException
*/
- public function writeValueObject($object, string $contextUri = null)
+ public function writeValueObject($object, ?string $contextUri = null)
{
if (!isset($this->valueObjectMap[get_class($object)])) {
throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.');