[Pkg-owncloud-commits] [php-sabre-vobject] 24/46: Lots of small cleanups.
David Prévot
taffit at moszumanska.debian.org
Thu Dec 10 02:12:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 24b48ff8f9bba4ad4560ff6e8a7aafe4537feeda
Author: Evert Pot <me at evertpot.com>
Date: Wed Nov 25 22:17:46 2015 -0500
Lots of small cleanups.
Thanks @jakobsack!
Closes #263.
---
CHANGELOG.md | 3 +++
lib/Component/VAlarm.php | 2 +-
lib/Component/VCalendar.php | 3 ++-
lib/Component/VCard.php | 9 +++++++++
lib/Parameter.php | 2 +-
lib/Parser/MimeDir.php | 8 ++------
lib/Property.php | 2 +-
tests/VObject/PropertyTest.php | 2 +-
tests/VObject/ReaderTest.php | 4 ++--
9 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6cb7468..b4763d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,9 @@ ChangeLog
because there was something wrong with input data.
* #227: Always add `VALUE=URI` to `PHOTO` properties.
* #235: Always add `VALUE=URI` to `URL` properties.
+* It's now possible to override which class is used instead of
+ `Component\VCalendar` or `Component\VCard` during parsing.
+* #263: Lots of small cleanups. (@jakobsack)
4.0.0-alpha2 (2015-09-04)
diff --git a/lib/Component/VAlarm.php b/lib/Component/VAlarm.php
index 954735c..4494c36 100644
--- a/lib/Component/VAlarm.php
+++ b/lib/Component/VAlarm.php
@@ -90,7 +90,7 @@ class VAlarm extends VObject\Component {
if (isset($this->DURATION)) {
$duration = VObject\DateTimeParser::parseDuration($this->DURATION);
- $repeat = (string)$this->repeat;
+ $repeat = (string)$this->REPEAT;
if (!$repeat) {
$repeat = 1;
}
diff --git a/lib/Component/VCalendar.php b/lib/Component/VCalendar.php
index 476b8d9..513ab73 100644
--- a/lib/Component/VCalendar.php
+++ b/lib/Component/VCalendar.php
@@ -37,6 +37,7 @@ class VCalendar extends VObject\Document {
* @var array
*/
static $componentMap = [
+ 'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar',
'VALARM' => 'Sabre\\VObject\\Component\\VAlarm',
'VEVENT' => 'Sabre\\VObject\\Component\\VEvent',
'VFREEBUSY' => 'Sabre\\VObject\\Component\\VFreeBusy',
@@ -509,7 +510,7 @@ class VCalendar extends VObject\Document {
'node' => $this,
];
}
- if (count(array_unique($componentTypes)) === 0) {
+ if (count($componentTypes) === 0) {
$warnings[] = [
'level' => 3,
'message' => 'A calendar object on a CalDAV server must have at least 1 component (VTODO, VEVENT, VJOURNAL).',
diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php
index 1b651f3..5905e47 100644
--- a/lib/Component/VCard.php
+++ b/lib/Component/VCard.php
@@ -34,6 +34,15 @@ class VCard extends VObject\Document {
private $version = null;
/**
+ * This is a list of components, and which classes they should map to.
+ *
+ * @var array
+ */
+ static $componentMap = [
+ 'VCARD' => 'Sabre\\VObject\\Component\\VCard',
+ ];
+
+ /**
* List of value-types, and which classes they map to.
*
* @var array
diff --git a/lib/Parameter.php b/lib/Parameter.php
index 4f526bc..a5d43b4 100644
--- a/lib/Parameter.php
+++ b/lib/Parameter.php
@@ -137,7 +137,7 @@ class Parameter extends Node {
case 'DIB' :
case 'PICT' :
case 'TIFF' :
- case 'PDF ':
+ case 'PDF':
case 'PS' :
case 'JPEG' :
case 'MPEG' :
diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php
index a98a0f0..ceb96bd 100644
--- a/lib/Parser/MimeDir.php
+++ b/lib/Parser/MimeDir.php
@@ -113,14 +113,10 @@ class MimeDir extends Parser {
switch (strtoupper($line)) {
case 'BEGIN:VCALENDAR' :
- $class = isset(VCalendar::$componentMap['VCALENDAR'])
- ? VCalendar::$componentMap[$name]
- : 'Sabre\\VObject\\Component\\VCalendar';
+ $class = VCalendar::$componentMap['VCALENDAR'];
break;
case 'BEGIN:VCARD' :
- $class = isset(VCard::$componentMap['VCARD'])
- ? VCard::$componentMap['VCARD']
- : 'Sabre\\VObject\\Component\\VCard';
+ $class = VCard::$componentMap['VCARD'];
break;
default :
throw new ParseException('This parser only supports VCARD and VCALENDAR files');
diff --git a/lib/Property.php b/lib/Property.php
index cb57f8e..c0b614d 100644
--- a/lib/Property.php
+++ b/lib/Property.php
@@ -120,7 +120,7 @@ abstract class Property extends Node {
} elseif (count($this->value) === 1) {
return $this->value[0];
} else {
- return $this->getRawMimeDirValue($this->value);
+ return $this->getRawMimeDirValue();
}
} else {
return $this->value;
diff --git a/tests/VObject/PropertyTest.php b/tests/VObject/PropertyTest.php
index 10425ba..69b29fb 100644
--- a/tests/VObject/PropertyTest.php
+++ b/tests/VObject/PropertyTest.php
@@ -287,7 +287,7 @@ class PropertyTest extends \PHPUnit_Framework_TestCase {
$result = $property->validate(Property::REPAIR);
$this->assertEquals('Property contained a control character (0x7f)', $result[0]['message']);
- $this->assertEquals("chars[7F()5E(^)5C(\\\\)3B(\\;)3A(:)2C(\\,)22(\")20( )1F()1E()1D()1C()1B()1A()19()18()17()16()15()14()13()12()11()10()0F()0E()0D()0C()0B()0A(\\n)09( )08()07()06()05()04()03()02()01()00()]end", $property->getRawMimeDirValue());
+ $this->assertEquals("chars[7F()5E(^)5C(\\\\)3B(\\;)3A(:)2C(\\,)22(\")20( )1F()1E()1D()1C()1B()1A()19()18()17()16()15()14()13()12()11()10()0F()0E()0D()0C()0B()0A(\\n)09(\t)08()07()06()05()04()03()02()01()00()]end", $property->getRawMimeDirValue());
}
diff --git a/tests/VObject/ReaderTest.php b/tests/VObject/ReaderTest.php
index a053a71..7c3217b 100644
--- a/tests/VObject/ReaderTest.php
+++ b/tests/VObject/ReaderTest.php
@@ -302,7 +302,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase {
$data = "BEGIN:VCALENDAR\r\nPROPNAME;PARAMNAME=paramvalue1^nvalue2^^nvalue3:propValue\r\nEND:VCALENDAR";
$result = Reader::read($data);
- $result = $result->propname;
+ $result = $result->PROPNAME;
$this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
@@ -318,7 +318,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase {
$data = "BEGIN:VCALENDAR\r\nPROPNAME;PARAMNAME=\"param:value\":propValue\r\nEND:VCALENDAR";
$result = Reader::read($data);
- $result = $result->propname;
+ $result = $result->PROPNAME;
$this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list