From dc4b8a62ca9ba6edea49c4c3d27732a02658b672 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 9 Oct 2019 11:14:35 +0200 Subject: [PATCH 01/83] fix Bad file descriptor (7.4) (#469) --- tests/VObject/Parser/MimeDirTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/VObject/Parser/MimeDirTest.php b/tests/VObject/Parser/MimeDirTest.php index 671c23064..309068854 100644 --- a/tests/VObject/Parser/MimeDirTest.php +++ b/tests/VObject/Parser/MimeDirTest.php @@ -16,7 +16,7 @@ class MimeDirTest extends TestCase public function testParseError() { $mimeDir = new MimeDir(); - $mimeDir->parse(fopen(__FILE__, 'a')); + $mimeDir->parse(fopen(__FILE__, 'a+')); } public function testDecodeLatin1() From 26d8ecfb77d62de4ea38c99679012dc46563f077 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 9 Oct 2019 11:15:35 +0200 Subject: [PATCH 02/83] travis: allow failure for phpstan for now (#470) --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 686982b66..4bf5e44df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,8 @@ matrix: fast_finish: true allow_failures: - php: 5.5 + - php: 7.2 + env: RUN_PHPSTAN="TRUE" install: - if [ $RUN_PHPSTAN == "TRUE" ]; then wget https://github.com/phpstan/phpstan/releases/download/0.11.8/phpstan.phar; fi From c2d75dbbc8dc0e15e0beb1f9a9c7baa5221aee44 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 9 Oct 2019 11:33:37 +0200 Subject: [PATCH 03/83] travis: add php 7.4snapshot build (#471) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4bf5e44df..4562f4440 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4snapshot env: global: From ebe974884ef45cd6b62472b5942f8839ae48b5c9 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 9 Oct 2019 11:53:23 +0200 Subject: [PATCH 04/83] reduce phpstan level back to 0, as level 1 is failing right now (#472) * reduce phpstan level back to 0, as level 1 is failing right now * travis: no longer allow failures for phpstan --- .travis.yml | 2 -- phpstan.neon | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4562f4440..64b055bf1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,6 @@ matrix: fast_finish: true allow_failures: - php: 5.5 - - php: 7.2 - env: RUN_PHPSTAN="TRUE" install: - if [ $RUN_PHPSTAN == "TRUE" ]; then wget https://github.com/phpstan/phpstan/releases/download/0.11.8/phpstan.phar; fi diff --git a/phpstan.neon b/phpstan.neon index 241663a72..e50c5be6e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,3 @@ parameters: - level: 1 + level: 0 bootstrap: %currentWorkingDirectory%/vendor/autoload.php From 2de7a4c76a20c8cc8debd9046f434e7a95614fa2 Mon Sep 17 00:00:00 2001 From: Dominik Date: Wed, 13 Nov 2019 22:36:52 +0100 Subject: [PATCH 05/83] Fixed typo in vobject CLI help (#477) --- lib/Cli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cli.php b/lib/Cli.php index 70b5e8d6e..8350719a4 100644 --- a/lib/Cli.php +++ b/lib/Cli.php @@ -289,7 +289,7 @@ protected function showHelp() $this->log($this->colorize('green', ' validate').' source_file Validates a file for correctness.'); $this->log($this->colorize('green', ' repair').' source_file [output_file] Repairs a file.'); $this->log($this->colorize('green', ' convert').' source_file [output_file] Converts a file.'); - $this->log($this->colorize('green', ' color').' source_file Colorize a file, useful for debbugging.'); + $this->log($this->colorize('green', ' color').' source_file Colorize a file, useful for debugging.'); $this->log( << Date: Wed, 18 Dec 2019 20:29:43 +0100 Subject: [PATCH 06/83] Release 4.2.1 (#479) * Release 4.2.1 * Update CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ lib/Version.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a2c935fb..3f70f37db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ ChangeLog ========= +4.2.1 (2019-12-18) +------------------ + +* #469, #451: fix compat with php 7.4 +* #443: prevent running in indefinte loop +* #449: Preventing creating a component for a root document +* #450: Fix parse with option Forgiving with trailing equal +* #459: fixed typo in VCalendar which resulting in usage of the wrong TimeZone +* #462: Broker::parseEventForOrganizer copies DTSTAMP from $eventInfo that causes broken scheduling + 4.2.0 (2019-02-19) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 257e66a79..b728f216d 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.2.0'; + const VERSION = '4.2.1'; } From 1356b64c885208f5386ce994f744d686d73b2faf Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 18 Dec 2019 20:40:38 +0100 Subject: [PATCH 07/83] Prepare next iteration (#480) --- CHANGELOG.md | 5 +++++ lib/Version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f70f37db..9e4ec65dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ChangeLog ========= +4.2.2-dev (XXXX-XX-XX) +------------------ + +* + 4.2.1 (2019-12-18) ------------------ diff --git a/lib/Version.php b/lib/Version.php index b728f216d..15d74ce1b 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.2.1'; + const VERSION = '4.2.2-dev'; } From 26673bbae7245e53e06b305473406331fdda063e Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Thu, 2 Jan 2020 14:53:39 +0100 Subject: [PATCH 08/83] Run phpstan on PHP >= 7.1 (#483) --- .travis.yml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64b055bf1..822a753e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: php -sudo: required php: - 5.5 - 5.6 @@ -7,31 +6,23 @@ php: - 7.1 - 7.2 - 7.3 - - 7.4snapshot - -env: - global: - - RUN_PHPSTAN="FALSE" + - 7.4 matrix: - include: - - name: 'PHPStan' - php: 7.2 - env: RUN_PHPSTAN="TRUE" fast_finish: true allow_failures: - php: 5.5 install: - - if [ $RUN_PHPSTAN == "TRUE" ]; then wget https://github.com/phpstan/phpstan/releases/download/0.11.8/phpstan.phar; fi + - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then wget https://github.com/phpstan/phpstan/releases/download/0.12.3/phpstan.phar; fi before_script: - composer install script: - - if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml; fi - - if [ $RUN_PHPSTAN == "TRUE" ]; then php phpstan.phar analyse -c phpstan.neon lib; fi - + - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then php phpstan.phar analyse -c phpstan.neon lib; fi + - ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml + after_success: - bash <(curl -s https://codecov.io/bash) From 7642fd7fdaac96e42fd85ff3b103a7555b84832b Mon Sep 17 00:00:00 2001 From: Renaud BOYER Date: Thu, 11 Jul 2019 12:34:52 +0200 Subject: [PATCH 09/83] Add TZ in iTip REPLY messages --- lib/ITip/Broker.php | 23 ++-- .../VObject/ITip/BrokerAttendeeReplyTest.php | 118 ++++++++++++++++++ tests/VObject/ITip/BrokerProcessReplyTest.php | 99 +++++++++++++++ tests/VObject/ITip/BrokerTester.php | 4 +- 4 files changed, 231 insertions(+), 13 deletions(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 4f37b75d0..ea27b3b3e 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -505,20 +505,21 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, $message->recipient = $attendee['href']; $message->recipientName = $attendee['name']; + // Creating the new iCalendar body. + $icalMsg = new VCalendar(); + + foreach ($calendar->select('VTIMEZONE') as $timezone) { + $icalMsg->add(clone $timezone); + } + if (!$attendee['newInstances']) { // If there are no instances the attendee is a part of, it // means the attendee was removed and we need to send him a // CANCEL. $message->method = 'CANCEL'; - // Creating the new iCalendar body. - $icalMsg = new VCalendar(); $icalMsg->METHOD = $message->method; - foreach ($calendar->select('VTIMEZONE') as $timezone) { - $icalMsg->add(clone $timezone); - } - $event = $icalMsg->add('VEVENT', [ 'UID' => $message->uid, 'SEQUENCE' => $message->sequence, @@ -545,14 +546,8 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, // The attendee gets the updated event body $message->method = 'REQUEST'; - // Creating the new iCalendar body. - $icalMsg = new VCalendar(); $icalMsg->METHOD = $message->method; - foreach ($calendar->select('VTIMEZONE') as $timezone) { - $icalMsg->add(clone $timezone); - } - // We need to find out that this change is significant. If it's // not, systems may opt to not send messages. // @@ -711,6 +706,10 @@ protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo, $icalMsg = new VCalendar(); $icalMsg->METHOD = 'REPLY'; + foreach ($calendar->select('VTIMEZONE') as $timezone) { + $icalMsg->add(clone $timezone); + } + $hasReply = false; foreach ($instances as $instance) { diff --git a/tests/VObject/ITip/BrokerAttendeeReplyTest.php b/tests/VObject/ITip/BrokerAttendeeReplyTest.php index cd0c7bb66..71008c6ae 100644 --- a/tests/VObject/ITip/BrokerAttendeeReplyTest.php +++ b/tests/VObject/ITip/BrokerAttendeeReplyTest.php @@ -68,6 +68,124 @@ public function testAccepted() $this->parse($oldMessage, $newMessage, $expected); } + public function testAcceptedWithTz() + { + $oldMessage = << 'foobar', + 'method' => 'REPLY', + 'component' => 'VEVENT', + 'sender' => 'mailto:one@example.org', + 'senderName' => 'One', + 'recipient' => 'mailto:strunk@example.org', + 'recipientName' => 'Strunk', + 'message' => <<parse($oldMessage, $newMessage, $expected); + } + public function testRecurringReply() { $oldMessage = <<process($itip, $old, $expected); } + public function testReplyWithTz() + { + $itip = <<process($itip, $old, $expected); + } + public function testReplyRequestStatus() { $itip = <<getComponents() as $mainComponent) { - break; + if ('VEVENT' === $mainComponent->name) { + break; + } } $message = new Message(); From 82d2d6a582c41a767752c35041f044e2dc878b5c Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sat, 4 Jan 2020 10:29:40 +0100 Subject: [PATCH 10/83] Added phpstan for tests folder (#485) --- .travis.yml | 2 +- composer.json | 5 ++ lib/PHPUnitAssertions.php | 3 +- tests/VObject/CliTest.php | 3 + tests/VObject/Component/VCardTest.php | 6 +- tests/VObject/FreeBusyGeneratorTest.php | 2 +- tests/VObject/JCalTest.php | 42 +++++----- tests/VObject/JCardTest.php | 36 ++++---- tests/VObject/Parser/JsonTest.php | 82 +++++++++---------- .../EventIterator/ByMonthInDailyTest.php | 2 +- .../Recur/EventIterator/BySetPosHangTest.php | 2 +- .../EventIterator/InfiniteLoopProblemTest.php | 3 + .../Recur/EventIterator/Issue48Test.php | 6 +- .../Recur/EventIterator/Issue50Test.php | 6 +- .../Recur/EventIterator/NoInstancesTest.php | 3 +- .../EventIterator/OverrideFirstEventTest.php | 2 +- .../SameDateForRecurringEventsTest.php | 3 +- tests/VObject/TimeZoneUtilTest.php | 2 +- tests/bootstrap.php | 2 - 19 files changed, 113 insertions(+), 99 deletions(-) diff --git a/.travis.yml b/.travis.yml index 822a753e0..e449565e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_script: - composer install script: - - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then php phpstan.phar analyse -c phpstan.neon lib; fi + - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then php phpstan.phar analyse -c phpstan.neon lib tests; fi - ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml after_success: diff --git a/composer.json b/composer.json index ad026879e..bd7892464 100644 --- a/composer.json +++ b/composer.json @@ -71,6 +71,11 @@ "Sabre\\VObject\\" : "lib/" } }, + "autoload-dev" : { + "psr-4" : { + "Sabre\\VObject\\" : "tests/VObject" + } + }, "bin" : [ "bin/vobject", "bin/generate_vcards" diff --git a/lib/PHPUnitAssertions.php b/lib/PHPUnitAssertions.php index d77e4b1ed..635988387 100644 --- a/lib/PHPUnitAssertions.php +++ b/lib/PHPUnitAssertions.php @@ -34,8 +34,7 @@ trait PHPUnitAssertions */ public function assertVObjectEqualsVObject($expected, $actual, $message = '') { - $self = $this; - $getObj = function ($input) use ($self) { + $getObj = function ($input) { if (is_resource($input)) { $input = stream_get_contents($input); } diff --git a/tests/VObject/CliTest.php b/tests/VObject/CliTest.php index 11c969c9d..cae424d96 100644 --- a/tests/VObject/CliTest.php +++ b/tests/VObject/CliTest.php @@ -11,6 +11,9 @@ */ class CliTest extends TestCase { + /** @var CliMock */ + private $cli; + public function setUp() { $this->cli = new CliMock(); diff --git a/tests/VObject/Component/VCardTest.php b/tests/VObject/Component/VCardTest.php index 1895ce6c5..3124fec84 100644 --- a/tests/VObject/Component/VCardTest.php +++ b/tests/VObject/Component/VCardTest.php @@ -204,7 +204,7 @@ public function testNoUIDCardDAV() VCF; $this->assertValidate( $vcard, - VCARD::PROFILE_CARDDAV, + VCard::PROFILE_CARDDAV, 3, 'vCards on CardDAV servers MUST have a UID property.' ); @@ -236,7 +236,7 @@ public function testNoUIDNoCardDAVRepair() VCF; $this->assertValidate( $vcard, - VCARD::REPAIR, + VCard::REPAIR, 1, 'Adding a UID to a vCard property is recommended.' ); @@ -253,7 +253,7 @@ public function testVCard21CardDAV() VCF; $this->assertValidate( $vcard, - VCARD::PROFILE_CARDDAV, + VCard::PROFILE_CARDDAV, 3, 'CardDAV servers are not allowed to accept vCard 2.1.' ); diff --git a/tests/VObject/FreeBusyGeneratorTest.php b/tests/VObject/FreeBusyGeneratorTest.php index 323cf632b..e2dd59409 100644 --- a/tests/VObject/FreeBusyGeneratorTest.php +++ b/tests/VObject/FreeBusyGeneratorTest.php @@ -30,7 +30,7 @@ public function testInvalidArg() $gen = new FreeBusyGenerator( new \DateTime('2012-01-01'), new \DateTime('2012-12-31'), - new \StdClass() + new \stdClass() ); } diff --git a/tests/VObject/JCalTest.php b/tests/VObject/JCalTest.php index d2de80281..9332b6413 100644 --- a/tests/VObject/JCalTest.php +++ b/tests/VObject/JCalTest.php @@ -43,19 +43,19 @@ public function testToJCal() [ [ 'version', - new \StdClass(), + new \stdClass(), 'text', '2.0', ], [ 'prodid', - new \StdClass(), + new \stdClass(), 'text', '-//Sabre//Sabre VObject '.Version::VERSION.'//EN', ], [ 'calscale', - new \StdClass(), + new \stdClass(), 'text', 'GREGORIAN', ], @@ -64,22 +64,22 @@ public function testToJCal() ['vevent', [ [ - 'uid', new \StdClass(), 'text', 'foo', + 'uid', new \stdClass(), 'text', 'foo', ], [ - 'dtstart', new \StdClass(), 'date', '2013-05-26', + 'dtstart', new \stdClass(), 'date', '2013-05-26', ], [ - 'duration', new \StdClass(), 'duration', 'P1D', + 'duration', new \stdClass(), 'duration', 'P1D', ], [ - 'categories', new \StdClass(), 'text', 'home', 'testing', + 'categories', new \stdClass(), 'text', 'home', 'testing', ], [ - 'created', new \StdClass(), 'date-time', '2013-05-26T18:10:00Z', + 'created', new \stdClass(), 'date-time', '2013-05-26T18:10:00Z', ], [ - 'attendee', new \StdClass(), 'cal-address', 'mailto:armin@example.org', + 'attendee', new \stdClass(), 'cal-address', 'mailto:armin@example.org', ], [ 'attendee', @@ -91,50 +91,50 @@ public function testToJCal() 'mailto:dominik@example.org', ], [ - 'geo', new \StdClass(), 'float', [51.96668, 7.61876], + 'geo', new \stdClass(), 'float', [51.96668, 7.61876], ], [ - 'sequence', new \StdClass(), 'integer', 5, + 'sequence', new \stdClass(), 'integer', 5, ], [ - 'freebusy', new \StdClass(), 'period', ['2013-05-26T21:02:13', 'PT1H'], ['2013-06-26T12:00:00', '2013-06-26T13:00:00'], + 'freebusy', new \stdClass(), 'period', ['2013-05-26T21:02:13', 'PT1H'], ['2013-06-26T12:00:00', '2013-06-26T13:00:00'], ], [ - 'url', new \StdClass(), 'uri', 'http://example.org/', + 'url', new \stdClass(), 'uri', 'http://example.org/', ], [ - 'tzoffsetfrom', new \StdClass(), 'utc-offset', '+05:00', + 'tzoffsetfrom', new \stdClass(), 'utc-offset', '+05:00', ], [ - 'rrule', new \StdClass(), 'recur', [ + 'rrule', new \stdClass(), 'recur', [ 'freq' => 'WEEKLY', 'byday' => ['MO', 'TU'], ], ], [ - 'x-bool', new \StdClass(), 'boolean', true, + 'x-bool', new \stdClass(), 'boolean', true, ], [ - 'x-time', new \StdClass(), 'time', '08:00:00', + 'x-time', new \stdClass(), 'time', '08:00:00', ], [ - 'attach', new \StdClass(), 'binary', base64_encode('attachment'), + 'attach', new \stdClass(), 'binary', base64_encode('attachment'), ], [ 'request-status', - new \StdClass(), + new \stdClass(), 'text', ['2.0', 'Success'], ], [ 'request-status', - new \StdClass(), + new \stdClass(), 'text', ['3.7', 'Invalid Calendar User', 'ATTENDEE:mailto:jsmith@example.org'], ], [ 'dtend', - new \StdClass(), + new \stdClass(), 'date-time', '2015-01-08T13:30:00', ], diff --git a/tests/VObject/JCardTest.php b/tests/VObject/JCardTest.php index 2100a07a9..1864f666d 100644 --- a/tests/VObject/JCardTest.php +++ b/tests/VObject/JCardTest.php @@ -48,25 +48,25 @@ public function testToJCard() [ [ 'version', - new \StdClass(), + new \stdClass(), 'text', '4.0', ], [ 'prodid', - new \StdClass(), + new \stdClass(), 'text', '-//Sabre//Sabre VObject '.Version::VERSION.'//EN', ], [ 'uid', - new \StdClass(), + new \stdClass(), 'text', 'foo', ], [ 'bday', - new \StdClass(), + new \stdClass(), 'date-and-or-time', '1985-04-07', ], @@ -80,25 +80,25 @@ public function testToJCard() ], [ 'bday', - new \StdClass(), + new \stdClass(), 'date-time', '1979-12-25T02:00:00', ], [ 'rev', - new \StdClass(), + new \stdClass(), 'timestamp', '1995-10-31T22:27:10Z', ], [ 'lang', - new \StdClass(), + new \stdClass(), 'language-tag', 'nl', ], [ 'n', - new \StdClass(), + new \stdClass(), 'text', ['Last', 'First', 'Middle', '', ''], ], @@ -120,7 +120,7 @@ public function testToJCard() ], [ 'adr', - new \StdClass(), + new \stdClass(), 'text', [ '', @@ -134,55 +134,55 @@ public function testToJCard() ], [ 'x-truncated', - new \StdClass(), + new \stdClass(), 'date', '--12-25', ], [ 'x-time-local', - new \StdClass(), + new \stdClass(), 'time', '12:30:00', ], [ 'x-time-utc', - new \StdClass(), + new \stdClass(), 'time', '12:30:00Z', ], [ 'x-time-offset', - new \StdClass(), + new \stdClass(), 'time', '12:30:00-08:00', ], [ 'x-time-reduced', - new \StdClass(), + new \stdClass(), 'time', '23', ], [ 'x-time-truncated', - new \StdClass(), + new \stdClass(), 'time', '--30', ], [ 'x-karma-points', - new \StdClass(), + new \stdClass(), 'integer', 42, ], [ 'x-grade', - new \StdClass(), + new \stdClass(), 'float', 1.3, ], [ 'tz', - new \StdClass(), + new \stdClass(), 'utc-offset', '-05:00', ], diff --git a/tests/VObject/Parser/JsonTest.php b/tests/VObject/Parser/JsonTest.php index 587f55f70..2aa0d9dab 100644 --- a/tests/VObject/Parser/JsonTest.php +++ b/tests/VObject/Parser/JsonTest.php @@ -14,25 +14,25 @@ public function testRoundTripJCard() [ [ 'version', - new \StdClass(), + new \stdClass(), 'text', '4.0', ], [ 'prodid', - new \StdClass(), + new \stdClass(), 'text', '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN', ], [ 'uid', - new \StdClass(), + new \stdClass(), 'text', 'foo', ], [ 'bday', - new \StdClass(), + new \stdClass(), 'date-and-or-time', '1985-04-07', ], @@ -46,25 +46,25 @@ public function testRoundTripJCard() ], [ 'bday', - new \StdClass(), + new \stdClass(), 'date-time', '1979-12-25T02:00:00', ], [ 'rev', - new \StdClass(), + new \stdClass(), 'timestamp', '1995-10-31T22:27:10Z', ], [ 'lang', - new \StdClass(), + new \stdClass(), 'language-tag', 'nl', ], [ 'n', - new \StdClass(), + new \stdClass(), 'text', ['Last', 'First', 'Middle', '', ''], ], @@ -86,7 +86,7 @@ public function testRoundTripJCard() ], [ 'adr', - new \StdClass(), + new \stdClass(), 'text', [ '', @@ -101,55 +101,55 @@ public function testRoundTripJCard() [ 'x-truncated', - new \StdClass(), + new \stdClass(), 'date', '--12-25', ], [ 'x-time-local', - new \StdClass(), + new \stdClass(), 'time', '12:30:00', ], [ 'x-time-utc', - new \StdClass(), + new \stdClass(), 'time', '12:30:00Z', ], [ 'x-time-offset', - new \StdClass(), + new \stdClass(), 'time', '12:30:00-08:00', ], [ 'x-time-reduced', - new \StdClass(), + new \stdClass(), 'time', '23', ], [ 'x-time-truncated', - new \StdClass(), + new \stdClass(), 'time', '--30', ], [ 'x-karma-points', - new \StdClass(), + new \stdClass(), 'integer', 42, ], [ 'x-grade', - new \StdClass(), + new \stdClass(), 'float', 1.3, ], [ 'tz', - new \StdClass(), + new \stdClass(), 'utc-offset', '-05:00', ], @@ -203,19 +203,19 @@ public function testRoundTripJCal() [ [ 'version', - new \StdClass(), + new \stdClass(), 'text', '2.0', ], [ 'prodid', - new \StdClass(), + new \stdClass(), 'text', '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN', ], [ 'calscale', - new \StdClass(), + new \stdClass(), 'text', 'GREGORIAN', ], @@ -224,25 +224,25 @@ public function testRoundTripJCal() ['vevent', [ [ - 'uid', new \StdClass(), 'text', 'foo', + 'uid', new \stdClass(), 'text', 'foo', ], [ - 'dtstart', new \StdClass(), 'date', '2013-05-26', + 'dtstart', new \stdClass(), 'date', '2013-05-26', ], [ - 'duration', new \StdClass(), 'duration', 'P1D', + 'duration', new \stdClass(), 'duration', 'P1D', ], [ - 'categories', new \StdClass(), 'text', 'home', 'testing', + 'categories', new \stdClass(), 'text', 'home', 'testing', ], [ - 'created', new \StdClass(), 'date-time', '2013-05-26T18:10:00Z', + 'created', new \stdClass(), 'date-time', '2013-05-26T18:10:00Z', ], [ - 'attach', new \StdClass(), 'binary', base64_encode('attachment'), + 'attach', new \stdClass(), 'binary', base64_encode('attachment'), ], [ - 'attendee', new \StdClass(), 'cal-address', 'mailto:armin@example.org', + 'attendee', new \stdClass(), 'cal-address', 'mailto:armin@example.org', ], [ 'attendee', @@ -254,41 +254,41 @@ public function testRoundTripJCal() 'mailto:dominik@example.org', ], [ - 'geo', new \StdClass(), 'float', [51.96668, 7.61876], + 'geo', new \stdClass(), 'float', [51.96668, 7.61876], ], [ - 'sequence', new \StdClass(), 'integer', 5, + 'sequence', new \stdClass(), 'integer', 5, ], [ - 'freebusy', new \StdClass(), 'period', ['2013-05-26T21:02:13', 'PT1H'], ['2013-06-26T12:00:00', '2013-06-26T13:00:00'], + 'freebusy', new \stdClass(), 'period', ['2013-05-26T21:02:13', 'PT1H'], ['2013-06-26T12:00:00', '2013-06-26T13:00:00'], ], [ - 'url', new \StdClass(), 'uri', 'http://example.org/', + 'url', new \stdClass(), 'uri', 'http://example.org/', ], [ - 'tzoffsetfrom', new \StdClass(), 'utc-offset', '+05:00', + 'tzoffsetfrom', new \stdClass(), 'utc-offset', '+05:00', ], [ - 'rrule', new \StdClass(), 'recur', [ + 'rrule', new \stdClass(), 'recur', [ 'freq' => 'WEEKLY', 'byday' => ['MO', 'TU'], ], ], [ - 'x-bool', new \StdClass(), 'boolean', true, + 'x-bool', new \stdClass(), 'boolean', true, ], [ - 'x-time', new \StdClass(), 'time', '08:00:00', + 'x-time', new \stdClass(), 'time', '08:00:00', ], [ 'request-status', - new \StdClass(), + new \stdClass(), 'text', ['2.0', 'Success'], ], [ 'request-status', - new \StdClass(), + new \stdClass(), 'text', ['3.7', 'Invalid Calendar User', 'ATTENDEE:mailto:jsmith@example.org'], ], @@ -297,7 +297,7 @@ public function testRoundTripJCal() ['valarm', [ [ - 'action', new \StdClass(), 'text', 'DISPLAY', + 'action', new \stdClass(), 'text', 'DISPLAY', ], ], [], @@ -358,7 +358,7 @@ public function testParseStreamArg() 'vcard', [ [ - 'FN', new \StdClass(), 'text', 'foo', + 'FN', new \stdClass(), 'text', 'foo', ], ], ]; @@ -381,7 +381,7 @@ public function testParseInvalidData() 'vlist', [ [ - 'FN', new \StdClass(), 'text', 'foo', + 'FN', new \stdClass(), 'text', 'foo', ], ], ]; diff --git a/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php b/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php index 40f09364f..71858c36f 100644 --- a/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php +++ b/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php @@ -1,6 +1,6 @@ vcal = new VCalendar(); diff --git a/tests/VObject/Recur/EventIterator/Issue48Test.php b/tests/VObject/Recur/EventIterator/Issue48Test.php index fe4b06755..f08f0ccce 100644 --- a/tests/VObject/Recur/EventIterator/Issue48Test.php +++ b/tests/VObject/Recur/EventIterator/Issue48Test.php @@ -1,10 +1,12 @@ assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); - $it = new Recur\EventIterator($vcal, 'foo'); + $it = new EventIterator($vcal, 'foo'); $result = iterator_to_array($it); diff --git a/tests/VObject/Recur/EventIterator/Issue50Test.php b/tests/VObject/Recur/EventIterator/Issue50Test.php index df9c15519..faa04e829 100644 --- a/tests/VObject/Recur/EventIterator/Issue50Test.php +++ b/tests/VObject/Recur/EventIterator/Issue50Test.php @@ -1,10 +1,12 @@ assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); - $it = new Recur\EventIterator($vcal, '1aef0b27-3d92-4581-829a-11999dd36724'); + $it = new EventIterator($vcal, '1aef0b27-3d92-4581-829a-11999dd36724'); $result = []; foreach ($it as $instance) { diff --git a/tests/VObject/Recur/EventIterator/NoInstancesTest.php b/tests/VObject/Recur/EventIterator/NoInstancesTest.php index b3e5a11fa..24810db14 100644 --- a/tests/VObject/Recur/EventIterator/NoInstancesTest.php +++ b/tests/VObject/Recur/EventIterator/NoInstancesTest.php @@ -1,9 +1,10 @@ addPsr4('Sabre\\VObject\\', __DIR__.'/VObject'); - if (!defined('SABRE_TEMPDIR')) { define('SABRE_TEMPDIR', __DIR__.'/temp/'); } From 17e6eea2e3726fee370e64cecf638f250448bbe3 Mon Sep 17 00:00:00 2001 From: Christian Kraus Date: Mon, 6 Jan 2020 08:48:20 +0100 Subject: [PATCH 11/83] Add PHONE-NUMBER value type (used for TEL in vCard 3.0) (#486) Signed-off-by: Christian Kraus --- lib/Component/VCard.php | 1 + lib/Property/VCard/PhoneNumber.php | 30 +++++++++++++++++++ lib/VCardConverter.php | 3 ++ .../Property/VCard/PhoneNumberTest.php | 19 ++++++++++++ tests/VObject/VCardConverterTest.php | 30 +++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 lib/Property/VCard/PhoneNumber.php create mode 100644 tests/VObject/Property/VCard/PhoneNumberTest.php diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php index 860e45ffa..4d7e861a2 100644 --- a/lib/Component/VCard.php +++ b/lib/Component/VCard.php @@ -57,6 +57,7 @@ class VCard extends VObject\Document 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', 'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', + 'PHONE-NUMBER' => 'Sabre\\VObject\\Property\\VCard\\PhoneNumber', // vCard 3.0 only 'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', 'TEXT' => 'Sabre\\VObject\\Property\\Text', 'TIME' => 'Sabre\\VObject\\Property\\Time', diff --git a/lib/Property/VCard/PhoneNumber.php b/lib/Property/VCard/PhoneNumber.php new file mode 100644 index 000000000..b714ffd03 --- /dev/null +++ b/lib/Property/VCard/PhoneNumber.php @@ -0,0 +1,30 @@ + + */ +class PhoneNumber extends Property\Text +{ + protected $structuredValues = []; + + /** + * Returns the type of value. + * + * This corresponds to the VALUE= parameter. Every property also has a + * 'default' valueType. + * + * @return string + */ + public function getValueType() + { + return 'PHONE-NUMBER'; + } +} diff --git a/lib/VCardConverter.php b/lib/VCardConverter.php index 156b83b4e..bc80abee9 100644 --- a/lib/VCardConverter.php +++ b/lib/VCardConverter.php @@ -83,6 +83,9 @@ protected function convertProperty(Component\VCard $input, Component\VCard $outp if (!$valueType) { $valueType = $property->getValueType(); } + if (Document::VCARD30 !== $targetVersion && 'PHONE-NUMBER' === $valueType) { + $valueType = null; + } $newProperty = $output->createProperty( $property->name, $property->getParts(), diff --git a/tests/VObject/Property/VCard/PhoneNumberTest.php b/tests/VObject/Property/VCard/PhoneNumberTest.php new file mode 100644 index 000000000..4a54d3333 --- /dev/null +++ b/tests/VObject/Property/VCard/PhoneNumberTest.php @@ -0,0 +1,19 @@ +assertInstanceOf('Sabre\VObject\Property\VCard\PhoneNumber', $vCard->TEL); + $this->assertEquals('PHONE-NUMBER', $vCard->TEL->getValueType()); + $this->assertEquals($input, $vCard->serialize()); + } +} diff --git a/tests/VObject/VCardConverterTest.php b/tests/VObject/VCardConverterTest.php index a5be3cc8c..72c3ac64a 100644 --- a/tests/VObject/VCardConverterTest.php +++ b/tests/VObject/VCardConverterTest.php @@ -518,4 +518,34 @@ public function testNoLabel() $this->assertEquals($expected, str_replace("\r", '', $vcard)); } + + public function testPhoneNumberValueTypeGetsRemoved() + { + $input = <<convert(Document::VCARD40); + + $this->assertVObjectEqualsVObject( + $output, + $vcard + ); + } } From 346bd88bdc857b4d2b680e290921d8af23aa605a Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 14 Jan 2020 15:40:47 +0545 Subject: [PATCH 12/83] use latest phpstan 0.12.5 in CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e449565e3..a36b67c47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - php: 5.5 install: - - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then wget https://github.com/phpstan/phpstan/releases/download/0.12.3/phpstan.phar; fi + - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then wget https://github.com/phpstan/phpstan/releases/download/0.12.5/phpstan.phar; fi before_script: - composer install From c14af2a7fb87cb42abf11c43f84912344af5f8a7 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 14 Jan 2020 15:41:42 +0545 Subject: [PATCH 13/83] Add PHPstorm .idea to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f08b31359..f723749ef 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ bin/hoa # Development stuff testdata/ .php_cs.cache +.idea # OS X .DS_Store From 0fec2b0c475f9318353b4a9c50441470397f6da4 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 14 Jan 2020 15:42:20 +0545 Subject: [PATCH 14/83] Fix various typos --- lib/Cli.php | 4 ++-- lib/Component.php | 2 +- lib/Component/VEvent.php | 2 +- lib/PHPUnitAssertions.php | 2 +- lib/Parser/MimeDir.php | 4 ++-- lib/Parser/XML/Element/KeyValue.php | 2 +- lib/Property/Boolean.php | 2 +- lib/Property/IntegerValue.php | 2 +- lib/Property/Text.php | 2 +- lib/Property/Uri.php | 2 +- lib/Recur/NoInstancesException.php | 2 +- lib/Recur/RRuleIterator.php | 6 +++--- lib/Settings.php | 2 +- lib/TimeZoneUtil.php | 2 +- lib/VCardConverter.php | 2 +- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/Cli.php b/lib/Cli.php index 8350719a4..be795e9e2 100644 --- a/lib/Cli.php +++ b/lib/Cli.php @@ -29,7 +29,7 @@ class Cli protected $showHelp = false; /** - * Wether to spit out 'mimedir' or 'json' format. + * Whether to spit out 'mimedir' or 'json' format. * * @var string */ @@ -516,7 +516,7 @@ protected function serializeComponent(Component $vObj) * * A higher score means the item will be lower in the list. * To avoid score collisions, each "score category" has a reasonable - * space to accomodate elements. The $key is added to the $score to + * space to accommodate elements. The $key is added to the $score to * preserve the original relative order of elements. * * @param int $key diff --git a/lib/Component.php b/lib/Component.php index a33b7d577..d4d8506d8 100644 --- a/lib/Component.php +++ b/lib/Component.php @@ -276,7 +276,7 @@ public function serialize() * * A higher score means the item will be lower in the list. * To avoid score collisions, each "score category" has a reasonable - * space to accomodate elements. The $key is added to the $score to + * space to accommodate elements. The $key is added to the $score to * preserve the original relative order of elements. * * @param int $key diff --git a/lib/Component/VEvent.php b/lib/Component/VEvent.php index 09f37033c..4a53a7561 100644 --- a/lib/Component/VEvent.php +++ b/lib/Component/VEvent.php @@ -36,7 +36,7 @@ public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) try { $it = new EventIterator($this, null, $start->getTimezone()); } catch (NoInstancesException $e) { - // If we've catched this exception, there are no instances + // If we've caught this exception, there are no instances // for the event that fall into the specified time-range. return false; } diff --git a/lib/PHPUnitAssertions.php b/lib/PHPUnitAssertions.php index 635988387..45c0a21c6 100644 --- a/lib/PHPUnitAssertions.php +++ b/lib/PHPUnitAssertions.php @@ -15,7 +15,7 @@ trait PHPUnitAssertions { /** - * This method tests wether two vcards or icalendar objects are + * This method tests whether two vcards or icalendar objects are * semantically identical. * * It supports objects being supplied as strings, streams or diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index 26a7101e5..ea5ac0326 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -124,7 +124,7 @@ public function setInput($input) $this->startLine = 0; if (is_string($input)) { - // Convering to a stream. + // Converting to a stream. $stream = fopen('php://temp', 'r+'); fwrite($stream, $input); rewind($stream); @@ -480,7 +480,7 @@ protected function readProperty($line) * vCard 3.0 says: * * (rfc2425) Backslashes, newlines (\n or \N) and comma's must be * escaped, all time time. - * * Comma's are used for delimeters in multiple values + * * Comma's are used for delimiters in multiple values * * (rfc2426) Adds to to this that the semi-colon MUST also be escaped, * as in some properties semi-colon is used for separators. * * Properties using semi-colons: N, ADR, GEO, ORG diff --git a/lib/Parser/XML/Element/KeyValue.php b/lib/Parser/XML/Element/KeyValue.php index e26540036..c0bbf0d9b 100644 --- a/lib/Parser/XML/Element/KeyValue.php +++ b/lib/Parser/XML/Element/KeyValue.php @@ -18,7 +18,7 @@ class KeyValue extends SabreXml\Element\KeyValue /** * The deserialize method is called during xml parsing. * - * This method is called staticly, this is because in theory this method + * This method is called statically, this is because in theory this method * may be used as a type of constructor, or factory method. * * Often you want to return an instance of the current class, but you are diff --git a/lib/Property/Boolean.php b/lib/Property/Boolean.php index 1b219bb8c..0e7bc666e 100644 --- a/lib/Property/Boolean.php +++ b/lib/Property/Boolean.php @@ -8,7 +8,7 @@ /** * Boolean property. * - * This object represents BOOLEAN values. These are always the case-insenstive + * This object represents BOOLEAN values. These are always the case-insensitive * string TRUE or FALSE. * * Automatic conversion to PHP's true and false are done. diff --git a/lib/Property/IntegerValue.php b/lib/Property/IntegerValue.php index ddd71d731..24a46fb07 100644 --- a/lib/Property/IntegerValue.php +++ b/lib/Property/IntegerValue.php @@ -9,7 +9,7 @@ * Integer property. * * This object represents INTEGER values. These are always a single integer. - * They may be preceeded by either + or -. + * They may be preceded by either + or -. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) diff --git a/lib/Property/Text.php b/lib/Property/Text.php index 23c945551..ac8aa066b 100644 --- a/lib/Property/Text.php +++ b/lib/Property/Text.php @@ -111,7 +111,7 @@ public function setQuotedPrintableValue($val) // that. // // We also don't have to unescape \\, so all we need to look for is a ; - // that's not preceeded with a \. + // that's not preceded with a \. $regex = '# (?setValue($matches); diff --git a/lib/Property/Uri.php b/lib/Property/Uri.php index 3449ba1f2..830cd3f18 100644 --- a/lib/Property/Uri.php +++ b/lib/Property/Uri.php @@ -72,7 +72,7 @@ public function setRawMimeDirValue($val) { // Normally we don't need to do any type of unescaping for these // properties, however.. we've noticed that Google Contacts - // specifically escapes the colon (:) with a blackslash. While I have + // specifically escapes the colon (:) with a backslash. While I have // no clue why they thought that was a good idea, I'm unescaping it // anyway. // diff --git a/lib/Recur/NoInstancesException.php b/lib/Recur/NoInstancesException.php index b55af567d..348c02306 100644 --- a/lib/Recur/NoInstancesException.php +++ b/lib/Recur/NoInstancesException.php @@ -7,7 +7,7 @@ /** * This exception gets thrown when a recurrence iterator produces 0 instances. * - * This may happen when every occurence in a rrule is also in EXDATE. + * This may happen when every occurrence in a rrule is also in EXDATE. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 75342a2a8..7bd4b086e 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -232,7 +232,7 @@ public function fastForward(DateTimeInterface $dt) * * This is an array of weekdays * - * This may also be preceeded by a positive or negative integer. If present, + * This may also be preceded by a positive or negative integer. If present, * this indicates the nth occurrence of a specific day within the monthly or * yearly rrule. For instance, -2TU indicates the second-last tuesday of * the month, or year. @@ -771,7 +771,7 @@ protected function parseRRule($rrule) $this->byMonth = (array) $value; foreach ($this->byMonth as $byMonth) { if (!is_numeric($byMonth) || (int) $byMonth < 1 || (int) $byMonth > 12) { - throw new InvalidDataException('BYMONTH in RRULE must have value(s) betweeen 1 and 12!'); + throw new InvalidDataException('BYMONTH in RRULE must have value(s) between 1 and 12!'); } } break; @@ -948,7 +948,7 @@ protected function getDays() { $recurrenceDays = []; foreach ($this->byDay as $byDay) { - // The day may be preceeded with a positive (+n) or + // The day may be preceded with a positive (+n) or // negative (-n) integer. However, this does not make // sense in 'weekly' so we ignore it here. $recurrenceDays[] = $this->dayMap[substr($byDay, -2)]; diff --git a/lib/Settings.php b/lib/Settings.php index afc586b0c..b0bb80a82 100644 --- a/lib/Settings.php +++ b/lib/Settings.php @@ -46,7 +46,7 @@ class Settings * specific events that recur many, many times, potentially DDOSing the * server. * - * The default (3500) allows creation of a dialy event that goes on for 10 + * The default (3500) allows creation of a daily event that goes on for 10 * years, which is hopefully long enough for most. * * Set this value to -1 to disable this control altogether. diff --git a/lib/TimeZoneUtil.php b/lib/TimeZoneUtil.php index 5b1a775c2..2c407fee6 100644 --- a/lib/TimeZoneUtil.php +++ b/lib/TimeZoneUtil.php @@ -139,7 +139,7 @@ public static function getTimeZone($tzid, Component $vcalendar = null, $failIfUn // PHP has a bug that logs PHP warnings even it shouldn't: // https://bugs.php.net/bug.php?id=67881 // - // That's why we're checking if we'll be able to successfull instantiate + // That's why we're checking if we'll be able to successfully instantiate // \DateTimeZone() before doing so. Otherwise we could simply instantiate // and catch the exception. $tzIdentifiers = \DateTimeZone::listIdentifiers(); diff --git a/lib/VCardConverter.php b/lib/VCardConverter.php index bc80abee9..5a814aa2e 100644 --- a/lib/VCardConverter.php +++ b/lib/VCardConverter.php @@ -230,7 +230,7 @@ protected function convertProperty(Component\VCard $input, Component\VCard $outp // Lastly, we need to see if there's a need for a VALUE parameter. // - // We can do that by instantating a empty property with that name, and + // We can do that by instantiating a empty property with that name, and // seeing if the default valueType is identical to the current one. $tempProperty = $output->createProperty($newProperty->name); if ($tempProperty->getValueType() !== $newProperty->getValueType()) { From 449616b2d45b95c8973975de23f34a3d14f63b4b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 14 Jan 2020 11:18:45 +0100 Subject: [PATCH 15/83] Release 4.2.2 (#490) * Release 4.2.2 * Update CHANGELOG.md --- CHANGELOG.md | 5 +++-- lib/Version.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e4ec65dd..4ddee77f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ChangeLog ========= -4.2.2-dev (XXXX-XX-XX) +4.2.2 (2020-01-14) ------------------ -* +* #465: Add TZ in iTip REPLY iTip messages +* #486: Add PHONE-NUMBER value type (used for TEL in vCard 3.0) 4.2.1 (2019-12-18) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 15d74ce1b..e040dd4d9 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.2.2-dev'; + const VERSION = '4.2.2'; } From 01ab95803b5dc129d926ffe5513718b5588b707f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 14 Jan 2020 11:19:31 +0100 Subject: [PATCH 16/83] Prepare next iteration --- lib/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Version.php b/lib/Version.php index e040dd4d9..e18fc00ea 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.2.2'; + const VERSION = '4.2.3-dev'; } From df805ce64a4192624758cf2694ff73f819b0be51 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 26 Jan 2020 12:26:31 +0545 Subject: [PATCH 17/83] Update dependencies and code style tools --- .gitignore | 4 ++-- .php_cs.dist | 2 +- .travis.yml | 9 ++------- composer.json | 7 ++++--- tests/phpunit.xml | 9 +++++---- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index f723749ef..8b677a5ad 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,9 @@ tests/temp #binaries bin/phpunit -bin/phpcs bin/php-cs-fixer -bin/sabre-cs-fixer +bin/phpstan +bin/phpstan.phar bin/hoa # Development stuff diff --git a/.php_cs.dist b/.php_cs.dist index 8d61ee259..c5c78a971 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -6,7 +6,7 @@ $config->getFinder() ->in(__DIR__); $config->setRules([ '@PSR1' => true, - '@Symfony' =>true + '@Symfony' => true ]); return $config; \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a36b67c47..40c54aeb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: php php: - - 5.5 - - 5.6 - - 7.0 - 7.1 - 7.2 - 7.3 @@ -10,17 +7,15 @@ php: matrix: fast_finish: true - allow_failures: - - php: 5.5 install: - - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then wget https://github.com/phpstan/phpstan/releases/download/0.12.5/phpstan.phar; fi + - composer require --dev phpstan/phpstan:^0.12 before_script: - composer install script: - - if [[ $TRAVIS_PHP_VERSION =~ ^7\.1|7\.2|7\.3|7\.4$ ]]; then php phpstan.phar analyse -c phpstan.neon lib tests; fi + - php ./bin/phpstan.phar analyse -c phpstan.neon lib tests - ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml after_success: diff --git a/composer.json b/composer.json index bd7892464..7e34b74b8 100644 --- a/composer.json +++ b/composer.json @@ -32,12 +32,13 @@ "homepage" : "http://sabre.io/vobject/", "license" : "BSD-3-Clause", "require" : { - "php" : ">=5.5", + "php" : "^7.1", "ext-mbstring" : "*", - "sabre/xml" : ">=1.5 <3.0" + "sabre/xml" : "^2.1" }, "require-dev" : { - "phpunit/phpunit" : "> 4.8.35, <6.0.0" + "friendsofphp/php-cs-fixer": "2.16.*", + "phpunit/phpunit" : "^7" }, "suggest" : { "hoa/bench" : "If you would like to run the benchmark scripts" diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 46dad6a3d..c9abae412 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -6,11 +6,12 @@ convertWarningsToExceptions="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTestSize="true" > - - VObject/ - + + + VObject/ + + From 4c55982419964c8aa6e8e8ffdd8c5080c2fa71a7 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 26 Jan 2020 17:11:07 +0545 Subject: [PATCH 18/83] Remove unneeded 'bootstrap' line from phpstan.neon --- phpstan.neon | 1 - 1 file changed, 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index e50c5be6e..5335bc651 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,2 @@ parameters: level: 0 - bootstrap: %currentWorkingDirectory%/vendor/autoload.php From ce46be4189055aaf48c66dc240e1eae342a88d0e Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 26 Jan 2020 12:32:22 +0545 Subject: [PATCH 19/83] Apply php-cs-fixer code style changes --- lib/Cli.php | 8 -------- lib/Component.php | 6 ++---- lib/Component/VAvailability.php | 3 --- lib/Component/VCalendar.php | 6 ++---- lib/Component/VEvent.php | 3 --- lib/Component/VFreeBusy.php | 3 --- lib/Component/VJournal.php | 3 --- lib/Component/VTodo.php | 3 --- lib/FreeBusyGenerator.php | 12 +----------- lib/ITip/Broker.php | 14 +------------- lib/Node.php | 2 -- lib/Parameter.php | 2 -- lib/Parser/Json.php | 4 ---- lib/Parser/XML.php | 18 +++++------------- lib/Property.php | 6 ------ lib/Property/Binary.php | 2 -- lib/Property/Boolean.php | 2 -- lib/Property/FloatValue.php | 2 -- lib/Property/ICalendar/DateTime.php | 5 ----- lib/Property/ICalendar/Period.php | 2 -- lib/Property/ICalendar/Recur.php | 2 -- lib/Property/IntegerValue.php | 2 -- lib/Property/Time.php | 4 ---- lib/Property/UtcOffset.php | 2 -- lib/Property/VCard/Date.php | 2 -- lib/Property/VCard/DateAndOrTime.php | 4 ---- lib/Recur/EventIterator.php | 2 -- lib/Recur/RDateIterator.php | 5 +---- lib/Recur/RRuleIterator.php | 5 +---- lib/VCardConverter.php | 20 ++++---------------- lib/Writer.php | 7 +------ 31 files changed, 18 insertions(+), 143 deletions(-) diff --git a/lib/Cli.php b/lib/Cli.php index be795e9e2..f3e419b15 100644 --- a/lib/Cli.php +++ b/lib/Cli.php @@ -312,8 +312,6 @@ protected function showHelp() /** * Validates a VObject file. * - * @param Component $vObj - * * @return int */ protected function validate(Component $vObj) @@ -354,8 +352,6 @@ protected function validate(Component $vObj) /** * Repairs a VObject file. * - * @param Component $vObj - * * @return int */ protected function repair(Component $vObj) @@ -582,8 +578,6 @@ function ($a, $b) use ($sortScore, $tmp) { /** * Colorizes a property. - * - * @param Property $property */ protected function serializeProperty(Property $property) { @@ -642,8 +636,6 @@ protected function serializeProperty(Property $property) /** * Parses the list of arguments. - * - * @param array $argv */ protected function parseArguments(array $argv) { diff --git a/lib/Component.php b/lib/Component.php index d4d8506d8..58594aec1 100644 --- a/lib/Component.php +++ b/lib/Component.php @@ -43,10 +43,8 @@ class Component extends Node * an iCalendar object, this may be something like CALSCALE:GREGORIAN. To * ensure that this does not happen, set $defaults to false. * - * @param Document $root - * @param string $name such as VCALENDAR, VEVENT - * @param array $children - * @param bool $defaults + * @param string $name such as VCALENDAR, VEVENT + * @param bool $defaults */ public function __construct(Document $root, $name, array $children = [], $defaults = true) { diff --git a/lib/Component/VAvailability.php b/lib/Component/VAvailability.php index 6f3e7f13c..04ec38dcb 100644 --- a/lib/Component/VAvailability.php +++ b/lib/Component/VAvailability.php @@ -26,9 +26,6 @@ class VAvailability extends VObject\Component * * https://tools.ietf.org/html/draft-daboo-calendar-availability-05#section-3.1 * - * @param DateTimeInterface $start - * @param DateTimeInterface $end - * * @return bool */ public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) diff --git a/lib/Component/VCalendar.php b/lib/Component/VCalendar.php index e21ae077a..54419c88a 100644 --- a/lib/Component/VCalendar.php +++ b/lib/Component/VCalendar.php @@ -276,10 +276,8 @@ public function getBaseComponent($componentName = null) * In addition, this method will cause timezone information to be stripped, * and normalized to UTC. * - * @param DateTimeInterface $start - * @param DateTimeInterface $end - * @param DateTimeZone $timeZone reference timezone for floating dates and - * times + * @param DateTimeZone $timeZone reference timezone for floating dates and + * times * * @return VCalendar */ diff --git a/lib/Component/VEvent.php b/lib/Component/VEvent.php index 4a53a7561..6ea93ed5e 100644 --- a/lib/Component/VEvent.php +++ b/lib/Component/VEvent.php @@ -25,9 +25,6 @@ class VEvent extends VObject\Component * The rules used to determine if an event falls within the specified * time-range is based on the CalDAV specification. * - * @param DateTimeInterface $start - * @param DateTimeInterface $end - * * @return bool */ public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) diff --git a/lib/Component/VFreeBusy.php b/lib/Component/VFreeBusy.php index 558a85233..fef418b53 100644 --- a/lib/Component/VFreeBusy.php +++ b/lib/Component/VFreeBusy.php @@ -21,9 +21,6 @@ class VFreeBusy extends VObject\Component * Checks based on the contained FREEBUSY information, if a timeslot is * available. * - * @param DateTimeInterface $start - * @param DateTimeInterface $end - * * @return bool */ public function isFree(DateTimeInterface $start, DatetimeInterface $end) diff --git a/lib/Component/VJournal.php b/lib/Component/VJournal.php index 9bd336776..9b7f1b873 100644 --- a/lib/Component/VJournal.php +++ b/lib/Component/VJournal.php @@ -23,9 +23,6 @@ class VJournal extends VObject\Component * The rules used to determine if an event falls within the specified * time-range is based on the CalDAV specification. * - * @param DateTimeInterface $start - * @param DateTimeInterface $end - * * @return bool */ public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) diff --git a/lib/Component/VTodo.php b/lib/Component/VTodo.php index 9de77e841..6f022ba6d 100644 --- a/lib/Component/VTodo.php +++ b/lib/Component/VTodo.php @@ -23,9 +23,6 @@ class VTodo extends VObject\Component * The rules used to determine if an event falls within the specified * time-range is based on the CalDAV specification. * - * @param DateTimeInterface $start - * @param DateTimeInterface $end - * * @return bool */ public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) diff --git a/lib/FreeBusyGenerator.php b/lib/FreeBusyGenerator.php index adb214c08..a1c24044c 100644 --- a/lib/FreeBusyGenerator.php +++ b/lib/FreeBusyGenerator.php @@ -109,8 +109,6 @@ public function __construct(DateTimeInterface $start = null, DateTimeInterface $ * for setting things like the METHOD, CALSCALE, VERSION, etc.. * * The VFREEBUSY object will be automatically added though. - * - * @param Document $vcalendar */ public function setBaseObject(Document $vcalendar) { @@ -119,8 +117,6 @@ public function setBaseObject(Document $vcalendar) /** * Sets a VAVAILABILITY document. - * - * @param Document $vcalendar */ public function setVAvailability(Document $vcalendar) { @@ -176,8 +172,6 @@ public function setTimeRange(DateTimeInterface $start = null, DateTimeInterface /** * Sets the reference timezone for floating times. - * - * @param DateTimeZone $timeZone */ public function setTimeZone(DateTimeZone $timeZone) { @@ -208,9 +202,6 @@ public function getResult() /** * This method takes a VAVAILABILITY component and figures out all the * available times. - * - * @param FreeBusyData $fbData - * @param VCalendar $vavailability */ protected function calculateAvailability(FreeBusyData $fbData, VCalendar $vavailability) { @@ -363,8 +354,7 @@ function ($a, $b) { * This method takes an array of iCalendar objects and applies its busy * times on fbData. * - * @param FreeBusyData $fbData - * @param VCalendar[] $objects + * @param VCalendar[] $objects */ protected function calculateBusy(FreeBusyData $fbData, array $objects) { diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index ea27b3b3e..c09cdf3be 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -104,7 +104,6 @@ class Broker * * If the iTip message was not supported, we will always return false. * - * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null @@ -263,8 +262,6 @@ public function parseEvent($calendar = null, $userHref, $oldCalendar = null) * This is message from an organizer, and is either a new event * invite, or an update to an existing one. * - * - * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null @@ -300,7 +297,6 @@ protected function processMessageRequest(Message $itipMessage, VCalendar $existi * attendee got removed from an event, or an event got cancelled * altogether. * - * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null @@ -326,7 +322,6 @@ protected function processMessageCancel(Message $itipMessage, VCalendar $existin * The message is a reply. This is for example an attendee telling * an organizer he accepted the invite, or declined it. * - * @param Message $itipMessage * @param VCalendar $existingObject * * @return VCalendar|null @@ -452,10 +447,6 @@ protected function processMessageReply(Message $itipMessage, VCalendar $existing * We will detect which attendees got added, which got removed and create * specific messages for these situations. * - * @param VCalendar $calendar - * @param array $eventInfo - * @param array $oldEventInfo - * * @return array */ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, array $oldEventInfo) @@ -620,10 +611,7 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, * * This function figures out if we need to send a reply to an organizer. * - * @param VCalendar $calendar - * @param array $eventInfo - * @param array $oldEventInfo - * @param string $attendee + * @param string $attendee * * @return Message[] */ diff --git a/lib/Node.php b/lib/Node.php index 154a7fac5..4c0c04f72 100644 --- a/lib/Node.php +++ b/lib/Node.php @@ -115,8 +115,6 @@ public function getIterator() * Sets the overridden iterator. * * Note that this is not actually part of the iterator interface - * - * @param ElementList $iterator */ public function setIterator(ElementList $iterator) { diff --git a/lib/Parameter.php b/lib/Parameter.php index 2c9a8e7fd..e39d320a1 100644 --- a/lib/Parameter.php +++ b/lib/Parameter.php @@ -201,8 +201,6 @@ public function getValue() /** * Sets multiple values for this parameter. - * - * @param array $value */ public function setParts(array $value) { diff --git a/lib/Parser/Json.php b/lib/Parser/Json.php index 3fd307e97..e8138b197 100644 --- a/lib/Parser/Json.php +++ b/lib/Parser/Json.php @@ -87,8 +87,6 @@ public function parse($input = null, $options = 0) /** * Parses a component. * - * @param array $jComp - * * @return \Sabre\VObject\Component */ public function parseComponent(array $jComp) @@ -124,8 +122,6 @@ function ($jComp) use ($self) { /** * Parses properties. * - * @param array $jProp - * * @return \Sabre\VObject\Property */ public function parseProperty(array $jProp) diff --git a/lib/Parser/XML.php b/lib/Parser/XML.php index 90f262d9e..8b7693edd 100644 --- a/lib/Parser/XML.php +++ b/lib/Parser/XML.php @@ -112,8 +112,6 @@ public function parse($input = null, $options = 0) /** * Parse a xCalendar component. - * - * @param Component $parentComponent */ protected function parseVCalendarComponents(Component $parentComponent) { @@ -134,8 +132,6 @@ protected function parseVCalendarComponents(Component $parentComponent) /** * Parse a xCard component. - * - * @param Component $parentComponent */ protected function parseVCardComponents(Component $parentComponent) { @@ -146,8 +142,7 @@ protected function parseVCardComponents(Component $parentComponent) /** * Parse xCalendar and xCard properties. * - * @param Component $parentComponent - * @param string $propertyNamePrefix + * @param string $propertyNamePrefix */ protected function parseProperties(Component $parentComponent, $propertyNamePrefix = '') { @@ -302,8 +297,6 @@ protected function parseProperties(Component $parentComponent, $propertyNamePref /** * Parse a component. - * - * @param Component $parentComponent */ protected function parseComponent(Component $parentComponent) { @@ -327,11 +320,10 @@ protected function parseComponent(Component $parentComponent) /** * Create a property. * - * @param Component $parentComponent - * @param string $name - * @param array $parameters - * @param string $type - * @param mixed $value + * @param string $name + * @param array $parameters + * @param string $type + * @param mixed $value */ protected function createProperty(Component $parentComponent, $name, $parameters, $type, $value) { diff --git a/lib/Property.php b/lib/Property.php index 6105cb0f0..f9cf8e38e 100644 --- a/lib/Property.php +++ b/lib/Property.php @@ -123,8 +123,6 @@ public function getValue() /** * Sets a multi-valued property. - * - * @param array $parts */ public function setParts(array $parts) { @@ -262,8 +260,6 @@ public function getJsonValue() * Sets the JSON value, as it would appear in a jCard or jCal object. * * The value must always be an array. - * - * @param array $value */ public function setJsonValue(array $value) { @@ -309,8 +305,6 @@ public function jsonSerialize() /** * Hydrate data from a XML subtree, as it would appear in a xCard or xCal * object. - * - * @param array $value */ public function setXmlValue(array $value) { diff --git a/lib/Property/Binary.php b/lib/Property/Binary.php index 830dd9028..ec6713fdd 100644 --- a/lib/Property/Binary.php +++ b/lib/Property/Binary.php @@ -100,8 +100,6 @@ public function getJsonValue() * Sets the json value, as it would appear in a jCard or jCal object. * * The value must always be an array. - * - * @param array $value */ public function setJsonValue(array $value) { diff --git a/lib/Property/Boolean.php b/lib/Property/Boolean.php index 0e7bc666e..9fb2bce35 100644 --- a/lib/Property/Boolean.php +++ b/lib/Property/Boolean.php @@ -59,8 +59,6 @@ public function getValueType() /** * Hydrate data from a XML subtree, as it would appear in a xCard or xCal * object. - * - * @param array $value */ public function setXmlValue(array $value) { diff --git a/lib/Property/FloatValue.php b/lib/Property/FloatValue.php index 208d74516..0d0346968 100644 --- a/lib/Property/FloatValue.php +++ b/lib/Property/FloatValue.php @@ -93,8 +93,6 @@ public function getJsonValue() /** * Hydrate data from a XML subtree, as it would appear in a xCard or xCal * object. - * - * @param array $value */ public function setXmlValue(array $value) { diff --git a/lib/Property/ICalendar/DateTime.php b/lib/Property/ICalendar/DateTime.php index 7eb3e0bb7..a0d1b38d4 100644 --- a/lib/Property/ICalendar/DateTime.php +++ b/lib/Property/ICalendar/DateTime.php @@ -38,8 +38,6 @@ class DateTime extends Property * Sets a multi-valued property. * * You may also specify DateTime objects here. - * - * @param array $parts */ public function setParts(array $parts) { @@ -175,7 +173,6 @@ public function getDateTimes(DateTimeZone $timeZone = null) /** * Sets the property as a DateTime object. * - * @param DateTimeInterface $dt * @param bool isFloating If set to true, timezones will be ignored */ public function setDateTime(DateTimeInterface $dt, $isFloating = false) @@ -279,8 +276,6 @@ function (DateTimeInterface $dt) use ($hasTime, $isUtc) { * Sets the json value, as it would appear in a jCard or jCal object. * * The value must always be an array. - * - * @param array $value */ public function setJsonValue(array $value) { diff --git a/lib/Property/ICalendar/Period.php b/lib/Property/ICalendar/Period.php index 17bfa5c5c..eb3752770 100644 --- a/lib/Property/ICalendar/Period.php +++ b/lib/Property/ICalendar/Period.php @@ -67,8 +67,6 @@ public function getValueType() * Sets the json value, as it would appear in a jCard or jCal object. * * The value must always be an array. - * - * @param array $value */ public function setJsonValue(array $value) { diff --git a/lib/Property/ICalendar/Recur.php b/lib/Property/ICalendar/Recur.php index baeda781e..3d632fec1 100644 --- a/lib/Property/ICalendar/Recur.php +++ b/lib/Property/ICalendar/Recur.php @@ -88,8 +88,6 @@ public function getValue() /** * Sets a multi-valued property. - * - * @param array $parts */ public function setParts(array $parts) { diff --git a/lib/Property/IntegerValue.php b/lib/Property/IntegerValue.php index 24a46fb07..6f709bfff 100644 --- a/lib/Property/IntegerValue.php +++ b/lib/Property/IntegerValue.php @@ -68,8 +68,6 @@ public function getJsonValue() /** * Hydrate data from a XML subtree, as it would appear in a xCard or xCal * object. - * - * @param array $value */ public function setXmlValue(array $value) { diff --git a/lib/Property/Time.php b/lib/Property/Time.php index 7aeafc8d0..544b5ced3 100644 --- a/lib/Property/Time.php +++ b/lib/Property/Time.php @@ -40,8 +40,6 @@ public function getValueType() * Sets the JSON value, as it would appear in a jCard or jCal object. * * The value must always be an array. - * - * @param array $value */ public function setJsonValue(array $value) { @@ -119,8 +117,6 @@ public function getJsonValue() /** * Hydrate data from a XML subtree, as it would appear in a xCard or xCal * object. - * - * @param array $value */ public function setXmlValue(array $value) { diff --git a/lib/Property/UtcOffset.php b/lib/Property/UtcOffset.php index 732239e23..248ed40ea 100644 --- a/lib/Property/UtcOffset.php +++ b/lib/Property/UtcOffset.php @@ -38,8 +38,6 @@ public function getValueType() * Sets the JSON value, as it would appear in a jCard or jCal object. * * The value must always be an array. - * - * @param array $value */ public function setJsonValue(array $value) { diff --git a/lib/Property/VCard/Date.php b/lib/Property/VCard/Date.php index a018ccbb8..fc679d572 100644 --- a/lib/Property/VCard/Date.php +++ b/lib/Property/VCard/Date.php @@ -28,8 +28,6 @@ public function getValueType() /** * Sets the property as a DateTime object. - * - * @param \DateTimeInterface $dt */ public function setDateTime(\DateTimeInterface $dt) { diff --git a/lib/Property/VCard/DateAndOrTime.php b/lib/Property/VCard/DateAndOrTime.php index b7e17492a..09918b31a 100644 --- a/lib/Property/VCard/DateAndOrTime.php +++ b/lib/Property/VCard/DateAndOrTime.php @@ -45,8 +45,6 @@ public function getValueType() * Sets a multi-valued property. * * You may also specify DateTimeInterface objects here. - * - * @param array $parts */ public function setParts(array $parts) { @@ -80,8 +78,6 @@ public function setValue($value) /** * Sets the property as a DateTime object. - * - * @param DateTimeInterface $dt */ public function setDateTime(DateTimeInterface $dt) { diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php index 135ecf00e..fd904b383 100644 --- a/lib/Recur/EventIterator.php +++ b/lib/Recur/EventIterator.php @@ -380,8 +380,6 @@ public function next() /** * Quickly jump to a date in the future. - * - * @param DateTimeInterface $dateTime */ public function fastForward(DateTimeInterface $dateTime) { diff --git a/lib/Recur/RDateIterator.php b/lib/Recur/RDateIterator.php index 013694b95..d117e152c 100644 --- a/lib/Recur/RDateIterator.php +++ b/lib/Recur/RDateIterator.php @@ -24,8 +24,7 @@ class RDateIterator implements Iterator /** * Creates the Iterator. * - * @param string|array $rrule - * @param DateTimeInterface $start + * @param string|array $rrule */ public function __construct($rrule, DateTimeInterface $start) { @@ -107,8 +106,6 @@ public function isInfinite() /** * This method allows you to quickly go to the next occurrence after the * specified date. - * - * @param DateTimeInterface $dt */ public function fastForward(DateTimeInterface $dt) { diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 7bd4b086e..dd07310e5 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -27,8 +27,7 @@ class RRuleIterator implements Iterator /** * Creates the Iterator. * - * @param string|array $rrule - * @param DateTimeInterface $start + * @param string|array $rrule */ public function __construct($rrule, DateTimeInterface $start) { @@ -132,8 +131,6 @@ public function isInfinite() /** * This method allows you to quickly go to the next occurrence after the * specified date. - * - * @param DateTimeInterface $dt */ public function fastForward(DateTimeInterface $dt) { diff --git a/lib/VCardConverter.php b/lib/VCardConverter.php index 5a814aa2e..04932fe67 100644 --- a/lib/VCardConverter.php +++ b/lib/VCardConverter.php @@ -26,8 +26,7 @@ class VCardConverter * * If input and output version are identical, a clone is returned. * - * @param Component\VCard $input - * @param int $targetVersion + * @param int $targetVersion */ public function convert(Component\VCard $input, $targetVersion) { @@ -62,10 +61,7 @@ public function convert(Component\VCard $input, $targetVersion) /** * Handles conversion of a single property. * - * @param Component\VCard $input - * @param Component\VCard $output - * @param Property $property - * @param int $targetVersion + * @param int $targetVersion */ protected function convertProperty(Component\VCard $input, Component\VCard $output, Property $property, $targetVersion) { @@ -245,8 +241,7 @@ protected function convertProperty(Component\VCard $input, Component\VCard $outp * * vCard 4.0 no longer supports BINARY properties. * - * @param Component\VCard $output - * @param Property\Uri $property the input property + * @param Property\Uri $property the input property * @param $parameters list of parameters that will eventually be added to * the new property * @@ -299,8 +294,7 @@ protected function convertBinaryToUri(Component\VCard $output, Property\Binary $ * be valid in vCard 3.0 as well, we should convert those to BINARY if * possible, to improve compatibility. * - * @param Component\VCard $output - * @param Property\Uri $property the input property + * @param Property\Uri $property the input property * * @return Property\Binary|null */ @@ -347,9 +341,6 @@ protected function convertUriToBinary(Component\VCard $output, Property\Uri $new /** * Adds parameters to a new property for vCard 4.0. - * - * @param Property $newProperty - * @param array $parameters */ protected function convertParameters40(Property $newProperty, array $parameters) { @@ -386,9 +377,6 @@ protected function convertParameters40(Property $newProperty, array $parameters) /** * Adds parameters to a new property for vCard 3.0. - * - * @param Property $newProperty - * @param array $parameters */ protected function convertParameters30(Property $newProperty, array $parameters) { diff --git a/lib/Writer.php b/lib/Writer.php index c70a6ae4d..cbd22022e 100644 --- a/lib/Writer.php +++ b/lib/Writer.php @@ -19,8 +19,6 @@ class Writer /** * Serializes a vCard or iCalendar object. * - * @param Component $component - * * @return string */ public static function write(Component $component) @@ -31,8 +29,7 @@ public static function write(Component $component) /** * Serializes a jCal or jCard object. * - * @param Component $component - * @param int $options + * @param int $options * * @return string */ @@ -44,8 +41,6 @@ public static function writeJson(Component $component, $options = 0) /** * Serializes a xCal or xCard object. * - * @param Component $component - * * @return string */ public static function writeXml(Component $component) From f154971709d40b599820d6246e816396f384157a Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 26 Jan 2020 12:34:31 +0545 Subject: [PATCH 20/83] run php-cs-fixer in CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 40c54aeb3..511119bbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ before_script: - composer install script: + - ./bin/php-cs-fixer fix lib/ --dry-run --diff - php ./bin/phpstan.phar analyse -c phpstan.neon lib tests - ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml From 5b828a9f87c30b00c51c796ad1d00191956c86ac Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 26 Jan 2020 20:21:55 +0545 Subject: [PATCH 21/83] php-cs-fixer must be at least 2.16.1 for PHP 7.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7e34b74b8..baf94db74 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "sabre/xml" : "^2.1" }, "require-dev" : { - "friendsofphp/php-cs-fixer": "2.16.*", + "friendsofphp/php-cs-fixer": "~2.16.1", "phpunit/phpunit" : "^7" }, "suggest" : { From 458bf943067ca8c7b2c42194f85e12970149d1be Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 29 Jan 2020 20:40:20 +0545 Subject: [PATCH 22/83] Use phpunit8 where possible --- .gitignore | 1 + composer.json | 2 +- .../VObject/BirthdayCalendarGeneratorTest.php | 12 ++--- tests/VObject/CliTest.php | 2 +- tests/VObject/Component/VAlarmTest.php | 5 +-- tests/VObject/Component/VCalendarTest.php | 5 +-- tests/VObject/ComponentTest.php | 26 ++++------- tests/VObject/DateTimeParserTest.php | 20 +++------ tests/VObject/FreeBusyGeneratorTest.php | 4 +- tests/VObject/ITip/BrokerNewEventTest.php | 16 ++----- tests/VObject/IssueUndefinedIndexTest.php | 4 +- tests/VObject/Parser/JsonTest.php | 5 +-- tests/VObject/Parser/MimeDirTest.php | 13 ++---- tests/VObject/Property/BinaryTest.php | 4 +- .../Property/ICalendar/DateTimeTest.php | 7 ++- .../VObject/Property/ICalendar/RecurTest.php | 4 +- tests/VObject/Property/UriTest.php | 2 +- .../Property/VCard/DateAndOrTimeTest.php | 4 +- tests/VObject/PropertyTest.php | 8 ++-- tests/VObject/ReaderTest.php | 19 +++----- .../EventIterator/InfiniteLoopProblemTest.php | 6 +-- .../Recur/EventIterator/Issue26Test.php | 5 +-- .../VObject/Recur/EventIterator/MainTest.php | 13 +++--- .../Recur/EventIterator/MaxInstancesTest.php | 5 +-- .../Recur/EventIterator/NoInstancesTest.php | 5 +-- tests/VObject/Recur/RRuleIteratorTest.php | 44 +++++-------------- tests/VObject/Splitter/ICalendarTest.php | 11 ++--- tests/VObject/Splitter/VCardTest.php | 15 +++---- tests/VObject/TimeZoneUtilTest.php | 6 +-- tests/VObject/VCardConverterTest.php | 8 +--- 30 files changed, 91 insertions(+), 190 deletions(-) diff --git a/.gitignore b/.gitignore index 8b677a5ad..e9b0ed32f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ vendor/ composer.lock tests/cov/ tests/temp +tests/.phpunit.result.cache #vim .*.swp diff --git a/composer.json b/composer.json index baf94db74..9e522f8a4 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ }, "require-dev" : { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit" : "^7" + "phpunit/phpunit" : "^7 || ^8" }, "suggest" : { "hoa/bench" : "If you would like to run the benchmark scripts" diff --git a/tests/VObject/BirthdayCalendarGeneratorTest.php b/tests/VObject/BirthdayCalendarGeneratorTest.php index 6e4f89a4c..d27362837 100644 --- a/tests/VObject/BirthdayCalendarGeneratorTest.php +++ b/tests/VObject/BirthdayCalendarGeneratorTest.php @@ -458,11 +458,9 @@ public function testVcardStringWithEmptyBirthdayProperty() ); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testParseException() { + $this->expectException(ParseException::class); $generator = new BirthdayCalendarGenerator(); $input = <<setObjects($input); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentException() { + $this->expectException(\InvalidArgumentException::class); $generator = new BirthdayCalendarGenerator(); $input = <<setObjects($input); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentExceptionForPartiallyInvalidArray() { + $this->expectException(\InvalidArgumentException::class); $generator = new BirthdayCalendarGenerator(); $input = []; diff --git a/tests/VObject/CliTest.php b/tests/VObject/CliTest.php index cae424d96..2fa0162e4 100644 --- a/tests/VObject/CliTest.php +++ b/tests/VObject/CliTest.php @@ -14,7 +14,7 @@ class CliTest extends TestCase /** @var CliMock */ private $cli; - public function setUp() + public function setUp(): void { $this->cli = new CliMock(); $this->cli->stderr = fopen('php://memory', 'r+'); diff --git a/tests/VObject/Component/VAlarmTest.php b/tests/VObject/Component/VAlarmTest.php index 1e7a55ad7..2823d16da 100644 --- a/tests/VObject/Component/VAlarmTest.php +++ b/tests/VObject/Component/VAlarmTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Sabre\VObject\InvalidDataException; use Sabre\VObject\Reader; class VAlarmTest extends TestCase @@ -126,11 +127,9 @@ public function timeRangeTestData() return $tests; } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testInTimeRangeInvalidComponent() { + $this->expectException(InvalidDataException::class); $calendar = new VCalendar(); $valarm = $calendar->createComponent('VALARM'); $valarm->TRIGGER = '-P1D'; diff --git a/tests/VObject/Component/VCalendarTest.php b/tests/VObject/Component/VCalendarTest.php index dbf2fef0a..c2f0ce978 100644 --- a/tests/VObject/Component/VCalendarTest.php +++ b/tests/VObject/Component/VCalendarTest.php @@ -5,6 +5,7 @@ use DateTimeZone; use PHPUnit\Framework\TestCase; use Sabre\VObject; +use Sabre\VObject\InvalidDataException; class VCalendarTest extends TestCase { @@ -330,11 +331,9 @@ public function expandData() return $tests; } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testBrokenEventExpand() { + $this->expectException(InvalidDataException::class); $input = 'BEGIN:VCALENDAR CALSCALE:GREGORIAN VERSION:2.0 diff --git a/tests/VObject/ComponentTest.php b/tests/VObject/ComponentTest.php index 8c0a0d7c6..b1e73c634 100644 --- a/tests/VObject/ComponentTest.php +++ b/tests/VObject/ComponentTest.php @@ -41,7 +41,7 @@ public function testMagicGet() $this->assertInstanceOf('Sabre\\VObject\\Component', $event); $this->assertEquals('VEVENT', $event->name); - $this->assertInternalType('null', $comp->vjournal); + $this->assertNull($comp->vjournal); } public function testMagicGetGroups() @@ -174,20 +174,16 @@ public function testArrayAccessExists() $this->assertTrue(isset($comp->vevent[1])); } - /** - * @expectedException \LogicException - */ public function testArrayAccessSet() { + $this->expectException(\LogicException::class); $comp = new VCalendar(); $comp['hey'] = 'hi there'; } - /** - * @expectedException \LogicException - */ public function testArrayAccessUnset() { + $this->expectException(\LogicException::class); $comp = new VCalendar(); unset($comp[0]); } @@ -250,20 +246,16 @@ public function testAddComponentTwice() $this->assertEquals('VEVENT', $comp->VEVENT->name); } - /** - * @expectedException \InvalidArgumentException - */ public function testAddArgFail() { + $this->expectException(\InvalidArgumentException::class); $comp = new VCalendar(); $comp->add($comp->createComponent('VEVENT'), 'hello'); } - /** - * @expectedException \InvalidArgumentException - */ public function testAddArgFail2() { + $this->expectException(\InvalidArgumentException::class); $comp = new VCalendar(); $comp->add([]); } @@ -293,7 +285,7 @@ public function testChildren() $comp->add($comp->createComponent('VTODO')); $r = $comp->children(); - $this->assertInternalType('array', $r); + $this->assertIsArray($r); $this->assertEquals(2, count($r)); } @@ -305,7 +297,7 @@ public function testGetComponents() $comp->add($comp->createComponent('VTODO')); $r = $comp->getComponents(); - $this->assertInternalType('array', $r); + $this->assertIsArray($r); $this->assertEquals(1, count($r)); $this->assertEquals('VTODO', $r[0]->name); } @@ -414,11 +406,9 @@ public function testRemoveByObj() $this->assertTrue(isset($comp->prop1)); } - /** - * @expectedException \InvalidArgumentException - */ public function testRemoveNotFound() { + $this->expectException(\InvalidArgumentException::class); $comp = new VCalendar([], false); $prop = $comp->createProperty('A', 'B'); $comp->remove($prop); diff --git a/tests/VObject/DateTimeParserTest.php b/tests/VObject/DateTimeParserTest.php index 44fba80c5..b20a43217 100644 --- a/tests/VObject/DateTimeParserTest.php +++ b/tests/VObject/DateTimeParserTest.php @@ -31,11 +31,9 @@ public function testParseICalendarDurationDateInterval() $this->assertEquals($expected, DateTimeParser::parseDuration('-PT3M')); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testParseICalendarDurationFail() { + $this->expectException(InvalidDataException::class); DateTimeParser::parseDuration('P1X', true); } @@ -50,19 +48,19 @@ public function testParseICalendarDateTime() /** * @depends testParseICalendarDateTime - * @expectedException \Sabre\VObject\InvalidDataException */ public function testParseICalendarDateTimeBadFormat() { + $this->expectException(InvalidDataException::class); $dateTime = DateTimeParser::parseDateTime('20100316T141405 '); } /** * @depends testParseICalendarDateTime - * @expectedException \Sabre\VObject\InvalidDataException */ public function testParseICalendarDateTimeInvalidTime() { + $this->expectException(InvalidDataException::class); $dateTime = DateTimeParser::parseDateTime('20100316T251405'); } @@ -143,19 +141,19 @@ public function testParseICalendarDateTimeGreaterThan4000() /** * @depends testParseICalendarDate - * @expectedException \Sabre\VObject\InvalidDataException */ public function testParseICalendarDateBadFormat() { + $this->expectException(InvalidDataException::class); $dateTime = DateTimeParser::parseDate('20100316T141405'); } /** * @depends testParseICalendarDate - * @expectedException \Sabre\VObject\InvalidDataException */ public function testParseICalendarDateInvalidDate() { + $this->expectException(InvalidDataException::class); $dateTime = DateTimeParser::parseDate('20101331'); } @@ -170,19 +168,15 @@ public function testVCardDate($input, $output) ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testBadVCardDate() { + $this->expectException(InvalidDataException::class); DateTimeParser::parseVCardDateTime('1985---01'); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testBadVCardTime() { + $this->expectException(InvalidDataException::class); DateTimeParser::parseVCardTime('23:12:166'); } diff --git a/tests/VObject/FreeBusyGeneratorTest.php b/tests/VObject/FreeBusyGeneratorTest.php index e2dd59409..4700a2800 100644 --- a/tests/VObject/FreeBusyGeneratorTest.php +++ b/tests/VObject/FreeBusyGeneratorTest.php @@ -22,11 +22,9 @@ public function testGeneratorBaseObject() $this->assertEquals('PUBLISH', $result->METHOD->getValue()); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArg() { + $this->expectException(\InvalidArgumentException::class); $gen = new FreeBusyGenerator( new \DateTime('2012-01-01'), new \DateTime('2012-12-31'), diff --git a/tests/VObject/ITip/BrokerNewEventTest.php b/tests/VObject/ITip/BrokerNewEventTest.php index a727427af..f5b89b0e8 100644 --- a/tests/VObject/ITip/BrokerNewEventTest.php +++ b/tests/VObject/ITip/BrokerNewEventTest.php @@ -81,11 +81,9 @@ public function testSimpleInvite() $this->parse(null, $message, $expected, 'mailto:strunk@example.org'); } - /** - * @expectedException \Sabre\VObject\ITip\ITipException - */ public function testBrokenEventUIDMisMatch() { + $this->expectException(ITipException::class); $message = <<parse(null, $message, [], 'mailto:strunk@example.org'); } - /** - * @expectedException \Sabre\VObject\ITip\ITipException - */ public function testBrokenEventOrganizerMisMatch() { + $this->expectException(ITipException::class); $message = <<parse(null, $message, [], 'mailto:strunk@example.org'); } - /** - * @expectedException \Sabre\VObject\ITip\ITipException - */ public function testMultipleUID() { + $this->expectException(ITipException::class); $message = <<parse(null, $message, [], 'mailto:strunk@example.org'); } - /** - * @expectedException \Sabre\VObject\ITip\SameOrganizerForAllComponentsException - */ public function testChangingOrganizers() { + $this->expectException(SameOrganizerForAllComponentsException::class); $message = <<expectException(ParseException::class); $input = <<assertEquals('foo', $result->FN->getValue()); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testParseInvalidData() { + $this->expectException(ParseException::class); $json = new Json(); $input = [ 'vlist', diff --git a/tests/VObject/Parser/MimeDirTest.php b/tests/VObject/Parser/MimeDirTest.php index 309068854..183c9ce4c 100644 --- a/tests/VObject/Parser/MimeDirTest.php +++ b/tests/VObject/Parser/MimeDirTest.php @@ -3,6 +3,7 @@ namespace Sabre\VObject\Parser; use PHPUnit\Framework\TestCase; +use Sabre\VObject\ParseException; /** * Note that most MimeDir related tests can actually be found in the ReaderTest @@ -10,11 +11,9 @@ */ class MimeDirTest extends TestCase { - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testParseError() { + $this->expectException(ParseException::class); $mimeDir = new MimeDir(); $mimeDir->parse(fopen(__FILE__, 'a+')); } @@ -80,20 +79,16 @@ public function testDontDecodeLatin1() $this->assertEquals("umlaut u - \xFC", $vcard->FN->getValue()); } - /** - * @expectedException \InvalidArgumentException - */ public function testDecodeUnsupportedCharset() { + $this->expectException(\InvalidArgumentException::class); $mimeDir = new MimeDir(); $mimeDir->setCharset('foobar'); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testDecodeUnsupportedInlineCharset() { + $this->expectException(ParseException::class); $vcard = <<expectException(\InvalidArgumentException::class); $vcard = new VObject\Component\VCard(['VERSION' => '3.0']); $vcard->add('PHOTO', ['a', 'b']); } diff --git a/tests/VObject/Property/ICalendar/DateTimeTest.php b/tests/VObject/Property/ICalendar/DateTimeTest.php index 33525ff33..40c6e2ef6 100644 --- a/tests/VObject/Property/ICalendar/DateTimeTest.php +++ b/tests/VObject/Property/ICalendar/DateTimeTest.php @@ -4,12 +4,13 @@ use PHPUnit\Framework\TestCase; use Sabre\VObject\Component\VCalendar; +use Sabre\VObject\InvalidDataException; class DateTimeTest extends TestCase { protected $vcal; - public function setUp() + public function setUp(): void { $this->vcal = new VCalendar(); } @@ -256,11 +257,9 @@ public function testGetDateTimeDateLOCALTZ() $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testGetDateTimeDateInvalid() { + $this->expectException(InvalidDataException::class); $elem = $this->vcal->createProperty('DTSTART', 'bla'); $dt = $elem->getDateTime(); } diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php index 818840605..3567ff1c0 100644 --- a/tests/VObject/Property/ICalendar/RecurTest.php +++ b/tests/VObject/Property/ICalendar/RecurTest.php @@ -24,11 +24,9 @@ public function testParts() $this->assertEquals(['FREQ' => 'MONTHLY'], $recur->getParts()); } - /** - * @expectedException \InvalidArgumentException - */ public function testSetValueBadVal() { + $this->expectException(\InvalidArgumentException::class); $vcal = new VCalendar(); $recur = $vcal->add('RRULE', 'FREQ=Daily'); $recur->setValue(new \Exception()); diff --git a/tests/VObject/Property/UriTest.php b/tests/VObject/Property/UriTest.php index 4ab32a736..d3d0e0f9c 100644 --- a/tests/VObject/Property/UriTest.php +++ b/tests/VObject/Property/UriTest.php @@ -21,6 +21,6 @@ public function testAlwaysEncodeUriVCalendar() END:VCALENDAR ICS; $output = Reader::read($input)->serialize(); - $this->assertContains('URL;VALUE=URI:http://example.org/', $output); + $this->assertStringContainsString('URL;VALUE=URI:http://example.org/', $output); } } diff --git a/tests/VObject/Property/VCard/DateAndOrTimeTest.php b/tests/VObject/Property/VCard/DateAndOrTimeTest.php index a59411e01..f21b408a1 100644 --- a/tests/VObject/Property/VCard/DateAndOrTimeTest.php +++ b/tests/VObject/Property/VCard/DateAndOrTimeTest.php @@ -105,11 +105,9 @@ public function testSetPartsDateTimeImmutable() $this->assertEquals('20140402T183700Z', $prop->getValue()); } - /** - * @expectedException \InvalidArgumentException - */ public function testSetPartsTooMany() { + $this->expectException(\InvalidArgumentException::class); $vcard = new VObject\Component\VCard(); $prop = $vcard->createProperty('BDAY'); diff --git a/tests/VObject/PropertyTest.php b/tests/VObject/PropertyTest.php index 1c2dc0830..adfb62e64 100644 --- a/tests/VObject/PropertyTest.php +++ b/tests/VObject/PropertyTest.php @@ -71,7 +71,7 @@ public function testParameterNotExists() $property = $cal->createProperty('propname', 'propvalue'); $property['paramname'] = 'paramvalue'; - $this->assertInternalType('null', $property['foo']); + $this->assertNull($property['foo']); } public function testParameterMultiple() @@ -308,11 +308,10 @@ public function testGetValue() /** * ElementList should reject this. - * - * @expectedException \LogicException */ public function testArrayAccessSetInt() { + $this->expectException(\LogicException::class); $calendar = new VCalendar(); $property = $calendar->createProperty('X-PROP', null); @@ -322,11 +321,10 @@ public function testArrayAccessSetInt() /** * ElementList should reject this. - * - * @expectedException \LogicException */ public function testArrayAccessUnsetInt() { + $this->expectException(\LogicException::class); $calendar = new VCalendar(); $property = $calendar->createProperty('X-PROP', null); diff --git a/tests/VObject/ReaderTest.php b/tests/VObject/ReaderTest.php index 06310e80a..f9d08c75a 100644 --- a/tests/VObject/ReaderTest.php +++ b/tests/VObject/ReaderTest.php @@ -54,21 +54,17 @@ public function testReadComponentLineFold() $this->assertEquals(0, count($result->children())); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testReadCorruptComponent() { + $this->expectException(ParseException::class); $data = "BEGIN:VCALENDAR\r\nEND:FOO"; $result = Reader::read($data); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testReadCorruptSubComponent() { + $this->expectException(ParseException::class); $data = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:FOO\r\nEND:VCALENDAR"; $result = Reader::read($data); @@ -118,11 +114,9 @@ public function testReadMappedPropertyGrouped() $this->assertEquals('20110529', $result->getValue()); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testReadBrokenLine() { + $this->expectException(ParseException::class); $data = "BEGIN:VCALENDAR\r\nPROPNAME;propValue"; $result = Reader::read($data); } @@ -369,11 +363,10 @@ public function testReadWithInvalidLine() /** * Reported as Issue 32. - * - * @expectedException \Sabre\VObject\ParseException */ public function testReadIncompleteFile() { + $this->expectException(ParseException::class); $input = <<expectException(\InvalidArgumentException::class); Reader::read(false); } diff --git a/tests/VObject/Recur/EventIterator/InfiniteLoopProblemTest.php b/tests/VObject/Recur/EventIterator/InfiniteLoopProblemTest.php index ace78de2c..5546c508d 100644 --- a/tests/VObject/Recur/EventIterator/InfiniteLoopProblemTest.php +++ b/tests/VObject/Recur/EventIterator/InfiniteLoopProblemTest.php @@ -6,6 +6,7 @@ use DateTimeZone; use PHPUnit\Framework\TestCase; use Sabre\VObject\Component\VCalendar; +use Sabre\VObject\InvalidDataException; use Sabre\VObject\Recur; class InfiniteLoopProblemTest extends TestCase @@ -13,7 +14,7 @@ class InfiniteLoopProblemTest extends TestCase /** @var VCalendar */ private $vcal; - public function setUp() + public function setUp(): void { $this->vcal = new VCalendar(); } @@ -76,11 +77,10 @@ public function testYearlyByMonthLoop() * Something, somewhere produced an ics with an interval set to 0. Because * this means we increase the current day (or week, month) by 0, this also * results in an infinite loop. - * - * @expectedException \Sabre\VObject\InvalidDataException */ public function testZeroInterval() { + $this->expectException(InvalidDataException::class); $ev = $this->vcal->createComponent('VEVENT'); $ev->UID = 'uuid'; $ev->DTSTART = '20120824T145700Z'; diff --git a/tests/VObject/Recur/EventIterator/Issue26Test.php b/tests/VObject/Recur/EventIterator/Issue26Test.php index bb4df64df..60d3aa240 100644 --- a/tests/VObject/Recur/EventIterator/Issue26Test.php +++ b/tests/VObject/Recur/EventIterator/Issue26Test.php @@ -3,16 +3,15 @@ namespace Sabre\VObject\Recur\EventIterator; use PHPUnit\Framework\TestCase; +use Sabre\VObject\InvalidDataException; use Sabre\VObject\Reader; use Sabre\VObject\Recur\EventIterator; class Issue26Test extends TestCase { - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testExpand() { + $this->expectException(InvalidDataException::class); $input = <<expectException(InvalidDataException::class); $vcal = new VCalendar(); $ev = $vcal->createComponent('VEVENT'); $ev->RRULE = 'FREQ=SMONTHLY;INTERVAL=3;UNTIL=20111025T000000Z'; @@ -47,20 +48,16 @@ public function testInvalidFreq() $it = new EventIterator($vcal, (string) $ev->UID); } - /** - * @expectedException \InvalidArgumentException - */ public function testVCalendarNoUID() { + $this->expectException(\InvalidArgumentException::class); $vcal = new VCalendar(); $it = new EventIterator($vcal); } - /** - * @expectedException \InvalidArgumentException - */ public function testVCalendarInvalidUID() { + $this->expectException(\InvalidArgumentException::class); $vcal = new VCalendar(); $it = new EventIterator($vcal, 'foo'); } @@ -1386,10 +1383,10 @@ public function testRDATE() /** * @depends testValues - * @expectedException \InvalidArgumentException */ public function testNoMasterBadUID() { + $this->expectException(\InvalidArgumentException::class); $vcal = new VCalendar(); // ev2 overrides an event, and puts it on 2pm instead. $ev2 = $vcal->createComponent('VEVENT'); diff --git a/tests/VObject/Recur/EventIterator/MaxInstancesTest.php b/tests/VObject/Recur/EventIterator/MaxInstancesTest.php index d0571ee82..6314b3b5a 100644 --- a/tests/VObject/Recur/EventIterator/MaxInstancesTest.php +++ b/tests/VObject/Recur/EventIterator/MaxInstancesTest.php @@ -5,15 +5,14 @@ use DateTime; use PHPUnit\Framework\TestCase; use Sabre\VObject\Reader; +use Sabre\VObject\Recur\MaxInstancesExceededException; use Sabre\VObject\Settings; class MaxInstancesTest extends TestCase { - /** - * @expectedException \Sabre\VObject\Recur\MaxInstancesExceededException - */ public function testExceedMaxRecurrences() { + $this->expectException(MaxInstancesExceededException::class); $input = <<expectException(NoInstancesException::class); $input = <<expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=0', '2011-04-07 00:00:00', @@ -434,11 +433,9 @@ public function testYearlyByMonthInvalidValue1() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testYearlyByMonthInvalidValue2() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=bla', '2011-04-07 00:00:00', @@ -446,11 +443,9 @@ public function testYearlyByMonthInvalidValue2() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testYearlyByMonthManyInvalidValues() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=0,bla', '2011-04-07 00:00:00', @@ -458,11 +453,9 @@ public function testYearlyByMonthManyInvalidValues() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testYearlyByMonthEmptyValue() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=', '2011-04-07 00:00:00', @@ -576,11 +569,9 @@ public function testYearlyByYearDayNegative() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testYearlyByYearDayInvalid390() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;COUNT=8;INTERVAL=4;BYYEARDAY=390', '2011-04-07 00:00:00', @@ -589,11 +580,9 @@ public function testYearlyByYearDayInvalid390() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testYearlyByYearDayInvalid0() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;COUNT=8;INTERVAL=4;BYYEARDAY=0', '2011-04-07 00:00:00', @@ -770,11 +759,9 @@ public function testMultipleValidByWeekNo() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testInvalidByWeekNo() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;BYWEEKNO=54', '2011-05-16 00:00:00', @@ -802,11 +789,10 @@ public function testYearlyByMonthLoop() * Something, somewhere produced an ics with an interval set to 0. Because * this means we increase the current day (or week, month) by 0, this also * results in an infinite loop. - * - * @expectedException \Sabre\VObject\InvalidDataException */ public function testZeroInterval() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=YEARLY;INTERVAL=0', '2012-08-24 14:57:00', @@ -815,11 +801,9 @@ public function testZeroInterval() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testInvalidFreq() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=SMONTHLY;INTERVAL=3;UNTIL=20111025T000000Z', '2011-10-07', @@ -827,11 +811,9 @@ public function testInvalidFreq() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testByDayBadOffset() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=WEEKLY;INTERVAL=1;COUNT=4;BYDAY=0MO;WKST=SA', '2014-08-01 00:00:00', @@ -911,11 +893,9 @@ public function testNeverEnding() ); } - /** - * @expectedException \Sabre\VObject\InvalidDataException - */ public function testUnsupportedPart() { + $this->expectException(InvalidDataException::class); $this->parse( 'FREQ=DAILY;BYWODAN=1', '2014-08-02 00:15:00', diff --git a/tests/VObject/Splitter/ICalendarTest.php b/tests/VObject/Splitter/ICalendarTest.php index 5addf9f6d..2788b96d6 100644 --- a/tests/VObject/Splitter/ICalendarTest.php +++ b/tests/VObject/Splitter/ICalendarTest.php @@ -4,12 +4,13 @@ use PHPUnit\Framework\TestCase; use Sabre\VObject; +use Sabre\VObject\ParseException; class ICalendarTest extends TestCase { protected $version; - public function setUp() + public function setUp(): void { $this->version = VObject\Version::VERSION; } @@ -45,11 +46,9 @@ public function testICalendarImportValidEvent() $this->assertEquals([], VObject\Reader::read($return)->validate()); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testICalendarImportWrongType() { + $this->expectException(ParseException::class); $data = <<assertNull($object = $objects->getNext()); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testICalendarImportInvalidEvent() { + $this->expectException(ParseException::class); $data = <<createStream($data); diff --git a/tests/VObject/Splitter/VCardTest.php b/tests/VObject/Splitter/VCardTest.php index a7e4ea3d2..1402b5094 100644 --- a/tests/VObject/Splitter/VCardTest.php +++ b/tests/VObject/Splitter/VCardTest.php @@ -3,6 +3,7 @@ namespace Sabre\VObject\Splitter; use PHPUnit\Framework\TestCase; +use Sabre\VObject\ParseException; class VCardTest extends TestCase { @@ -33,11 +34,9 @@ public function testVCardImportValidVCard() $this->assertEquals(1, $count); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testVCardImportWrongType() { + $this->expectException(ParseException::class); $event[] = <<assertEquals(4, $count); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testVCardImportVCardNoComponent() { + $this->expectException(ParseException::class); $data = <<expectException(\Sabre\VObject\ParseException::class); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Invalid MimeDir file. Unexpected component: "BEGIN:VCARD" in document type VCARD'); while ($object = $splitter->getNext()) { } @@ -161,11 +158,9 @@ public function testVCardImportEndOfData() $this->assertNull($objects->getNext()); } - /** - * @expectedException \Sabre\VObject\ParseException - */ public function testVCardImportCheckInvalidArgumentException() { + $this->expectException(ParseException::class); $data = <<assertEquals($ex->getName(), $tz->getName()); } - /** - * @expectedException \InvalidArgumentException - */ public function testTimezoneFail() { + $this->expectException(\InvalidArgumentException::class); $tz = TimeZoneUtil::getTimeZone('FooBar', null, true); } diff --git a/tests/VObject/VCardConverterTest.php b/tests/VObject/VCardConverterTest.php index 72c3ac64a..d7c48e045 100644 --- a/tests/VObject/VCardConverterTest.php +++ b/tests/VObject/VCardConverterTest.php @@ -294,11 +294,9 @@ public function testBDAYConversion() ); } - /** - * @expectedException \InvalidArgumentException - */ public function testUnknownSourceVCardVersion() { + $this->expectException(\InvalidArgumentException::class); $input = <<convert(Document::VCARD40); } - /** - * @expectedException \InvalidArgumentException - */ public function testUnknownTargetVCardVersion() { + $this->expectException(\InvalidArgumentException::class); $input = << Date: Tue, 7 Jan 2020 14:09:21 +0100 Subject: [PATCH 23/83] Fixed phpstan level 1 errors --- lib/Property/ICalendar/DateTime.php | 16 ++++++++-------- lib/Recur/RRuleIterator.php | 7 +++++++ phpstan.neon | 4 +++- tests/VObject/CliTest.php | 10 ++++++++-- tests/VObject/ComponentTest.php | 1 + tests/VObject/ElementListTest.php | 1 + tests/VObject/ITip/BrokerTester.php | 1 + .../Recur/EventIterator/ByMonthInDailyTest.php | 1 + .../Recur/EventIterator/BySetPosHangTest.php | 1 + tests/bootstrap.php | 8 -------- 10 files changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/Property/ICalendar/DateTime.php b/lib/Property/ICalendar/DateTime.php index a0d1b38d4..66d7a122f 100644 --- a/lib/Property/ICalendar/DateTime.php +++ b/lib/Property/ICalendar/DateTime.php @@ -338,8 +338,8 @@ public function validate($options = 0) $messages = parent::validate($options); $valueType = $this->getValueType(); $values = $this->getParts(); - try { - foreach ($values as $value) { + foreach ($values as $value) { + try { switch ($valueType) { case 'DATE': DateTimeParser::parseDate($value); @@ -348,13 +348,13 @@ public function validate($options = 0) DateTimeParser::parseDateTime($value); break; } + } catch (InvalidDataException $e) { + $messages[] = [ + 'level' => 3, + 'message' => 'The supplied value ('.$value.') is not a correct '.$valueType, + 'node' => $this, + ]; } - } catch (InvalidDataException $e) { - $messages[] = [ - 'level' => 3, - 'message' => 'The supplied value ('.$value.') is not a correct '.$valueType, - 'node' => $this, - ]; } return $messages; diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index dd07310e5..55581e9ac 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -322,14 +322,17 @@ protected function nextDaily() return; } + $recurrenceHours = []; if (!empty($this->byHour)) { $recurrenceHours = $this->getHours(); } + $recurrenceDays = []; if (!empty($this->byDay)) { $recurrenceDays = $this->getDays(); } + $recurrenceMonths = []; if (!empty($this->byMonth)) { $recurrenceMonths = $this->getMonths(); } @@ -372,10 +375,12 @@ protected function nextWeekly() return; } + $recurrenceHours = []; if ($this->byHour) { $recurrenceHours = $this->getHours(); } + $recurrenceDays = []; if ($this->byDay) { $recurrenceDays = $this->getDays(); } @@ -436,6 +441,7 @@ protected function nextMonthly() return; } + $occurrence = -1; while (true) { $occurrences = $this->getMonthlyOccurrences(); @@ -605,6 +611,7 @@ protected function nextYearly() // If we got a byDay or getMonthDay filter, we must first expand // further. if ($this->byDay || $this->byMonthDay) { + $occurrence = -1; while (true) { $occurrences = $this->getMonthlyOccurrences(); diff --git a/phpstan.neon b/phpstan.neon index 5335bc651..c705178c9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,2 +1,4 @@ parameters: - level: 0 + level: 1 + universalObjectCratesClasses: + - \Sabre\VObject\Component diff --git a/tests/VObject/CliTest.php b/tests/VObject/CliTest.php index 2fa0162e4..5736f9a01 100644 --- a/tests/VObject/CliTest.php +++ b/tests/VObject/CliTest.php @@ -14,8 +14,14 @@ class CliTest extends TestCase /** @var CliMock */ private $cli; + private $sabreTempDir = __DIR__.'/../temp/'; + public function setUp(): void { + if (!file_exists($this->sabreTempDir)) { + mkdir($this->sabreTempDir); + } + $this->cli = new CliMock(); $this->cli->stderr = fopen('php://memory', 'r+'); $this->cli->stdout = fopen('php://memory', 'r+'); @@ -269,7 +275,7 @@ public function testConvertMimeDir() public function testConvertDefaultFormats() { - $outputFile = SABRE_TEMPDIR.'bar.json'; + $outputFile = $this->sabreTempDir.'bar.json'; $this->assertEquals( 2, @@ -282,7 +288,7 @@ public function testConvertDefaultFormats() public function testConvertDefaultFormats2() { - $outputFile = SABRE_TEMPDIR.'bar.ics'; + $outputFile = $this->sabreTempDir.'bar.ics'; $this->assertEquals( 2, diff --git a/tests/VObject/ComponentTest.php b/tests/VObject/ComponentTest.php index b1e73c634..6026aaa54 100644 --- a/tests/VObject/ComponentTest.php +++ b/tests/VObject/ComponentTest.php @@ -19,6 +19,7 @@ public function testIterate() $comp->add($sub); $count = 0; + $key = null; foreach ($comp->children() as $key => $subcomponent) { ++$count; $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent); diff --git a/tests/VObject/ElementListTest.php b/tests/VObject/ElementListTest.php index 1842ca963..2046ae4ca 100644 --- a/tests/VObject/ElementListTest.php +++ b/tests/VObject/ElementListTest.php @@ -20,6 +20,7 @@ public function testIterate() $elemList = new ElementList($elems); $count = 0; + $key = null; foreach ($elemList as $key => $subcomponent) { ++$count; $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent); diff --git a/tests/VObject/ITip/BrokerTester.php b/tests/VObject/ITip/BrokerTester.php index 350e37e23..9e9956e03 100644 --- a/tests/VObject/ITip/BrokerTester.php +++ b/tests/VObject/ITip/BrokerTester.php @@ -45,6 +45,7 @@ public function process($input, $existingObject = null, $expected = false) $vcal = Reader::read($input); + $mainComponent = new \Sabre\VObject\Component\VEvent($vcal, 'VEVENT'); foreach ($vcal->getComponents() as $mainComponent) { if ('VEVENT' === $mainComponent->name) { break; diff --git a/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php b/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php index 71858c36f..3448032e8 100644 --- a/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php +++ b/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php @@ -40,6 +40,7 @@ public function testExpand() $vcal = $vcal->expand(new DateTime('2013-09-28'), new DateTime('2014-09-11')); + $dates = []; foreach ($vcal->VEVENT as $event) { $dates[] = $event->DTSTART->getValue(); } diff --git a/tests/VObject/Recur/EventIterator/BySetPosHangTest.php b/tests/VObject/Recur/EventIterator/BySetPosHangTest.php index bd00cb52a..caf6b0dc3 100644 --- a/tests/VObject/Recur/EventIterator/BySetPosHangTest.php +++ b/tests/VObject/Recur/EventIterator/BySetPosHangTest.php @@ -35,6 +35,7 @@ public function testExpand() $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2016-01-01')); + $dates = []; foreach ($vcal->VEVENT as $event) { $dates[] = $event->DTSTART->getValue(); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 590b25080..2496aa4ff 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,11 +13,3 @@ break; } } - -if (!defined('SABRE_TEMPDIR')) { - define('SABRE_TEMPDIR', __DIR__.'/temp/'); -} - -if (!file_exists(SABRE_TEMPDIR)) { - mkdir(SABRE_TEMPDIR); -} From c476d933e1ee16b1b859f1b6fe8aa2523880b3c1 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Wed, 8 Jan 2020 09:06:05 +0100 Subject: [PATCH 24/83] Make sure there is no logic change --- lib/Property/ICalendar/DateTime.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Property/ICalendar/DateTime.php b/lib/Property/ICalendar/DateTime.php index 66d7a122f..f2dbdeba3 100644 --- a/lib/Property/ICalendar/DateTime.php +++ b/lib/Property/ICalendar/DateTime.php @@ -354,6 +354,7 @@ public function validate($options = 0) 'message' => 'The supplied value ('.$value.') is not a correct '.$valueType, 'node' => $this, ]; + break; } } From 36d00ee5642ecf97a8cbe2a890c183aeaf3dfbe6 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Wed, 8 Jan 2020 09:19:35 +0100 Subject: [PATCH 25/83] Prevent setting foreach key beforehand --- tests/VObject/ComponentTest.php | 6 ++++-- tests/VObject/ElementListTest.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/VObject/ComponentTest.php b/tests/VObject/ComponentTest.php index 6026aaa54..4979592a0 100644 --- a/tests/VObject/ComponentTest.php +++ b/tests/VObject/ComponentTest.php @@ -19,13 +19,15 @@ public function testIterate() $comp->add($sub); $count = 0; - $key = null; foreach ($comp->children() as $key => $subcomponent) { ++$count; $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent); + + if (2 === $count) { + $this->assertEquals(1, $key); + } } $this->assertEquals(2, $count); - $this->assertEquals(1, $key); } public function testMagicGet() diff --git a/tests/VObject/ElementListTest.php b/tests/VObject/ElementListTest.php index 2046ae4ca..4b1ce999f 100644 --- a/tests/VObject/ElementListTest.php +++ b/tests/VObject/ElementListTest.php @@ -20,12 +20,14 @@ public function testIterate() $elemList = new ElementList($elems); $count = 0; - $key = null; foreach ($elemList as $key => $subcomponent) { ++$count; $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent); + + if (3 === $count) { + $this->assertEquals(2, $key); + } } $this->assertEquals(3, $count); - $this->assertEquals(2, $key); } } From 1af8f3f42b43e56c5ed84074e81c365e75111f66 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 31 Jan 2020 13:18:17 +0100 Subject: [PATCH 26/83] Refactored fqcn strings to ::class to allow checking with phpstan (#495) --- lib/Component/VCalendar.php | 152 +++++++++--------- lib/Component/VCard.php | 136 ++++++++-------- lib/Document.php | 4 +- lib/Parser/Json.php | 6 +- lib/Parser/XML.php | 4 +- tests/VObject/Component/AvailableTest.php | 2 +- tests/VObject/Component/VAvailabilityTest.php | 4 +- tests/VObject/ComponentTest.php | 12 +- tests/VObject/DocumentTest.php | 12 +- tests/VObject/ElementListTest.php | 2 +- tests/VObject/EmptyParameterTest.php | 2 +- tests/VObject/ICalendar/AttachParseTest.php | 3 +- tests/VObject/Issue36WorkAroundTest.php | 2 +- tests/VObject/Issue64Test.php | 2 +- tests/VObject/Issue96Test.php | 2 +- tests/VObject/Parser/QuotedPrintableTest.php | 9 +- tests/VObject/Property/FloatTest.php | 2 +- .../VObject/Property/ICalendar/RecurTest.php | 2 +- .../Property/VCard/LanguageTagTest.php | 4 +- .../Property/VCard/PhoneNumberTest.php | 2 +- tests/VObject/PropertyTest.php | 6 +- tests/VObject/ReaderTest.php | 50 +++--- .../EventIterator/ByMonthInDailyTest.php | 3 +- .../Recur/EventIterator/BySetPosHangTest.php | 3 +- .../EventIterator/ExpandFloatingTimesTest.php | 5 +- .../EventIterator/HandleRDateExpandTest.php | 3 +- .../EventIterator/IncorrectExpandTest.php | 3 +- .../Recur/EventIterator/Issue26Test.php | 3 +- .../Recur/EventIterator/Issue48Test.php | 3 +- .../Recur/EventIterator/Issue50Test.php | 3 +- .../EventIterator/MissingOverriddenTest.php | 3 +- .../Recur/EventIterator/NoInstancesTest.php | 3 +- tests/VObject/VCardConverterTest.php | 2 +- 33 files changed, 234 insertions(+), 220 deletions(-) diff --git a/lib/Component/VCalendar.php b/lib/Component/VCalendar.php index 54419c88a..40e09a1c0 100644 --- a/lib/Component/VCalendar.php +++ b/lib/Component/VCalendar.php @@ -37,15 +37,15 @@ class VCalendar extends VObject\Document * @var array */ public static $componentMap = [ - 'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar', - 'VALARM' => 'Sabre\\VObject\\Component\\VAlarm', - 'VEVENT' => 'Sabre\\VObject\\Component\\VEvent', - 'VFREEBUSY' => 'Sabre\\VObject\\Component\\VFreeBusy', - 'VAVAILABILITY' => 'Sabre\\VObject\\Component\\VAvailability', - 'AVAILABLE' => 'Sabre\\VObject\\Component\\Available', - 'VJOURNAL' => 'Sabre\\VObject\\Component\\VJournal', - 'VTIMEZONE' => 'Sabre\\VObject\\Component\\VTimeZone', - 'VTODO' => 'Sabre\\VObject\\Component\\VTodo', + 'VCALENDAR' => self::class, + 'VALARM' => VAlarm::class, + 'VEVENT' => VEvent::class, + 'VFREEBUSY' => VFreeBusy::class, + 'VAVAILABILITY' => VAvailability::class, + 'AVAILABLE' => Available::class, + 'VJOURNAL' => VJournal::class, + 'VTIMEZONE' => VTimeZone::class, + 'VTODO' => VTodo::class, ]; /** @@ -54,21 +54,21 @@ class VCalendar extends VObject\Document * @var array */ public static $valueMap = [ - 'BINARY' => 'Sabre\\VObject\\Property\\Binary', - 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', - 'CAL-ADDRESS' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', - 'DATE' => 'Sabre\\VObject\\Property\\ICalendar\\Date', - 'DATE-TIME' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', - 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', - 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', - 'PERIOD' => 'Sabre\\VObject\\Property\\ICalendar\\Period', - 'RECUR' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', - 'TEXT' => 'Sabre\\VObject\\Property\\Text', - 'TIME' => 'Sabre\\VObject\\Property\\Time', - 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. - 'URI' => 'Sabre\\VObject\\Property\\Uri', - 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', + 'BINARY' => VObject\Property\Binary::class, + 'BOOLEAN' => VObject\Property\Boolean::class, + 'CAL-ADDRESS' => VObject\Property\ICalendar\CalAddress::class, + 'DATE' => VObject\Property\ICalendar\Date::class, + 'DATE-TIME' => VObject\Property\ICalendar\DateTime::class, + 'DURATION' => VObject\Property\ICalendar\Duration::class, + 'FLOAT' => VObject\Property\FloatValue::class, + 'INTEGER' => VObject\Property\IntegerValue::class, + 'PERIOD' => VObject\Property\ICalendar\Period::class, + 'RECUR' => VObject\Property\ICalendar\Recur::class, + 'TEXT' => VObject\Property\Text::class, + 'TIME' => VObject\Property\Time::class, + 'UNKNOWN' => VObject\Property\Unknown::class, // jCard / jCal-only. + 'URI' => VObject\Property\Uri::class, + 'UTC-OFFSET' => VObject\Property\UtcOffset::class, ]; /** @@ -78,78 +78,78 @@ class VCalendar extends VObject\Document */ public static $propertyMap = [ // Calendar properties - 'CALSCALE' => 'Sabre\\VObject\\Property\\FlatText', - 'METHOD' => 'Sabre\\VObject\\Property\\FlatText', - 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', - 'VERSION' => 'Sabre\\VObject\\Property\\FlatText', + 'CALSCALE' => VObject\Property\FlatText::class, + 'METHOD' => VObject\Property\FlatText::class, + 'PRODID' => VObject\Property\FlatText::class, + 'VERSION' => VObject\Property\FlatText::class, // Component properties - 'ATTACH' => 'Sabre\\VObject\\Property\\Uri', - 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', - 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', - 'COMMENT' => 'Sabre\\VObject\\Property\\FlatText', - 'DESCRIPTION' => 'Sabre\\VObject\\Property\\FlatText', - 'GEO' => 'Sabre\\VObject\\Property\\FloatValue', - 'LOCATION' => 'Sabre\\VObject\\Property\\FlatText', - 'PERCENT-COMPLETE' => 'Sabre\\VObject\\Property\\IntegerValue', - 'PRIORITY' => 'Sabre\\VObject\\Property\\IntegerValue', - 'RESOURCES' => 'Sabre\\VObject\\Property\\Text', - 'STATUS' => 'Sabre\\VObject\\Property\\FlatText', - 'SUMMARY' => 'Sabre\\VObject\\Property\\FlatText', + 'ATTACH' => VObject\Property\Uri::class, + 'CATEGORIES' => VObject\Property\Text::class, + 'CLASS' => VObject\Property\FlatText::class, + 'COMMENT' => VObject\Property\FlatText::class, + 'DESCRIPTION' => VObject\Property\FlatText::class, + 'GEO' => VObject\Property\FloatValue::class, + 'LOCATION' => VObject\Property\FlatText::class, + 'PERCENT-COMPLETE' => VObject\Property\IntegerValue::class, + 'PRIORITY' => VObject\Property\IntegerValue::class, + 'RESOURCES' => VObject\Property\Text::class, + 'STATUS' => VObject\Property\FlatText::class, + 'SUMMARY' => VObject\Property\FlatText::class, // Date and Time Component Properties - 'COMPLETED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DTEND' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DUE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DTSTART' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', - 'FREEBUSY' => 'Sabre\\VObject\\Property\\ICalendar\\Period', - 'TRANSP' => 'Sabre\\VObject\\Property\\FlatText', + 'COMPLETED' => VObject\Property\ICalendar\DateTime::class, + 'DTEND' => VObject\Property\ICalendar\DateTime::class, + 'DUE' => VObject\Property\ICalendar\DateTime::class, + 'DTSTART' => VObject\Property\ICalendar\DateTime::class, + 'DURATION' => VObject\Property\ICalendar\Duration::class, + 'FREEBUSY' => VObject\Property\ICalendar\Period::class, + 'TRANSP' => VObject\Property\FlatText::class, // Time Zone Component Properties - 'TZID' => 'Sabre\\VObject\\Property\\FlatText', - 'TZNAME' => 'Sabre\\VObject\\Property\\FlatText', - 'TZOFFSETFROM' => 'Sabre\\VObject\\Property\\UtcOffset', - 'TZOFFSETTO' => 'Sabre\\VObject\\Property\\UtcOffset', - 'TZURL' => 'Sabre\\VObject\\Property\\Uri', + 'TZID' => VObject\Property\FlatText::class, + 'TZNAME' => VObject\Property\FlatText::class, + 'TZOFFSETFROM' => VObject\Property\UtcOffset::class, + 'TZOFFSETTO' => VObject\Property\UtcOffset::class, + 'TZURL' => VObject\Property\Uri::class, // Relationship Component Properties - 'ATTENDEE' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', - 'CONTACT' => 'Sabre\\VObject\\Property\\FlatText', - 'ORGANIZER' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress', - 'RECURRENCE-ID' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'RELATED-TO' => 'Sabre\\VObject\\Property\\FlatText', - 'URL' => 'Sabre\\VObject\\Property\\Uri', - 'UID' => 'Sabre\\VObject\\Property\\FlatText', + 'ATTENDEE' => VObject\Property\ICalendar\CalAddress::class, + 'CONTACT' => VObject\Property\FlatText::class, + 'ORGANIZER' => VObject\Property\ICalendar\CalAddress::class, + 'RECURRENCE-ID' => VObject\Property\ICalendar\DateTime::class, + 'RELATED-TO' => VObject\Property\FlatText::class, + 'URL' => VObject\Property\Uri::class, + 'UID' => VObject\Property\FlatText::class, // Recurrence Component Properties - 'EXDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'RDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'RRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', - 'EXRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', // Deprecated since rfc5545 + 'EXDATE' => VObject\Property\ICalendar\DateTime::class, + 'RDATE' => VObject\Property\ICalendar\DateTime::class, + 'RRULE' => VObject\Property\ICalendar\Recur::class, + 'EXRULE' => VObject\Property\ICalendar\Recur::class, // Deprecated since rfc5545 // Alarm Component Properties - 'ACTION' => 'Sabre\\VObject\\Property\\FlatText', - 'REPEAT' => 'Sabre\\VObject\\Property\\IntegerValue', - 'TRIGGER' => 'Sabre\\VObject\\Property\\ICalendar\\Duration', + 'ACTION' => VObject\Property\FlatText::class, + 'REPEAT' => VObject\Property\IntegerValue::class, + 'TRIGGER' => VObject\Property\ICalendar\Duration::class, // Change Management Component Properties - 'CREATED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'DTSTAMP' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'LAST-MODIFIED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'SEQUENCE' => 'Sabre\\VObject\\Property\\IntegerValue', + 'CREATED' => VObject\Property\ICalendar\DateTime::class, + 'DTSTAMP' => VObject\Property\ICalendar\DateTime::class, + 'LAST-MODIFIED' => VObject\Property\ICalendar\DateTime::class, + 'SEQUENCE' => VObject\Property\IntegerValue::class, // Request Status - 'REQUEST-STATUS' => 'Sabre\\VObject\\Property\\Text', + 'REQUEST-STATUS' => VObject\Property\Text::class, // Additions from draft-daboo-valarm-extensions-04 - 'ALARM-AGENT' => 'Sabre\\VObject\\Property\\Text', - 'ACKNOWLEDGED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime', - 'PROXIMITY' => 'Sabre\\VObject\\Property\\Text', - 'DEFAULT-ALARM' => 'Sabre\\VObject\\Property\\Boolean', + 'ALARM-AGENT' => VObject\Property\Text::class, + 'ACKNOWLEDGED' => VObject\Property\ICalendar\DateTime::class, + 'PROXIMITY' => VObject\Property\Text::class, + 'DEFAULT-ALARM' => VObject\Property\Boolean::class, // Additions from draft-daboo-calendar-availability-05 - 'BUSYTYPE' => 'Sabre\\VObject\\Property\\Text', + 'BUSYTYPE' => VObject\Property\Text::class, ]; /** diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php index 4d7e861a2..51321949f 100644 --- a/lib/Component/VCard.php +++ b/lib/Component/VCard.php @@ -39,7 +39,7 @@ class VCard extends VObject\Document * @var array */ public static $componentMap = [ - 'VCARD' => 'Sabre\\VObject\\Component\\VCard', + 'VCARD' => VCard::class, ]; /** @@ -48,23 +48,23 @@ class VCard extends VObject\Document * @var array */ public static $valueMap = [ - 'BINARY' => 'Sabre\\VObject\\Property\\Binary', - 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', - 'CONTENT-ID' => 'Sabre\\VObject\\Property\\FlatText', // vCard 2.1 only - 'DATE' => 'Sabre\\VObject\\Property\\VCard\\Date', - 'DATE-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateTime', - 'DATE-AND-OR-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', // vCard only - 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', - 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', - 'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', - 'PHONE-NUMBER' => 'Sabre\\VObject\\Property\\VCard\\PhoneNumber', // vCard 3.0 only - 'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', - 'TEXT' => 'Sabre\\VObject\\Property\\Text', - 'TIME' => 'Sabre\\VObject\\Property\\Time', - 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. - 'URI' => 'Sabre\\VObject\\Property\\Uri', - 'URL' => 'Sabre\\VObject\\Property\\Uri', // vCard 2.1 only - 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', + 'BINARY' => VObject\Property\Binary::class, + 'BOOLEAN' => VObject\Property\Boolean::class, + 'CONTENT-ID' => VObject\Property\FlatText::class, // vCard 2.1 only + 'DATE' => VObject\Property\VCard\Date::class, + 'DATE-TIME' => VObject\Property\VCard\DateTime::class, + 'DATE-AND-OR-TIME' => VObject\Property\VCard\DateAndOrTime::class, // vCard only + 'FLOAT' => VObject\Property\FloatValue::class, + 'INTEGER' => VObject\Property\IntegerValue::class, + 'LANGUAGE-TAG' => VObject\Property\VCard\LanguageTag::class, + 'PHONE-NUMBER' => VObject\Property\VCard\PhoneNumber::class, // vCard 3.0 only + 'TIMESTAMP' => VObject\Property\VCard\TimeStamp::class, + 'TEXT' => VObject\Property\Text::class, + 'TIME' => VObject\Property\Time::class, + 'UNKNOWN' => VObject\Property\Unknown::class, // jCard / jCal-only. + 'URI' => VObject\Property\Uri::class, + 'URL' => VObject\Property\Uri::class, // vCard 2.1 only + 'UTC-OFFSET' => VObject\Property\UtcOffset::class, ]; /** @@ -74,68 +74,68 @@ class VCard extends VObject\Document */ public static $propertyMap = [ // vCard 2.1 properties and up - 'N' => 'Sabre\\VObject\\Property\\Text', - 'FN' => 'Sabre\\VObject\\Property\\FlatText', - 'PHOTO' => 'Sabre\\VObject\\Property\\Binary', - 'BDAY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', - 'ADR' => 'Sabre\\VObject\\Property\\Text', - 'LABEL' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 - 'TEL' => 'Sabre\\VObject\\Property\\FlatText', - 'EMAIL' => 'Sabre\\VObject\\Property\\FlatText', - 'MAILER' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 - 'GEO' => 'Sabre\\VObject\\Property\\FlatText', - 'TITLE' => 'Sabre\\VObject\\Property\\FlatText', - 'ROLE' => 'Sabre\\VObject\\Property\\FlatText', - 'LOGO' => 'Sabre\\VObject\\Property\\Binary', + 'N' => VObject\Property\Text::class, + 'FN' => VObject\Property\FlatText::class, + 'PHOTO' => VObject\Property\Binary::class, + 'BDAY' => VObject\Property\VCard\DateAndOrTime::class, + 'ADR' => VObject\Property\Text::class, + 'LABEL' => VObject\Property\FlatText::class, // Removed in vCard 4.0 + 'TEL' => VObject\Property\FlatText::class, + 'EMAIL' => VObject\Property\FlatText::class, + 'MAILER' => VObject\Property\FlatText::class, // Removed in vCard 4.0 + 'GEO' => VObject\Property\FlatText::class, + 'TITLE' => VObject\Property\FlatText::class, + 'ROLE' => VObject\Property\FlatText::class, + 'LOGO' => VObject\Property\Binary::class, // 'AGENT' => 'Sabre\\VObject\\Property\\', // Todo: is an embedded vCard. Probably rare, so // not supported at the moment - 'ORG' => 'Sabre\\VObject\\Property\\Text', - 'NOTE' => 'Sabre\\VObject\\Property\\FlatText', - 'REV' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', - 'SOUND' => 'Sabre\\VObject\\Property\\FlatText', - 'URL' => 'Sabre\\VObject\\Property\\Uri', - 'UID' => 'Sabre\\VObject\\Property\\FlatText', - 'VERSION' => 'Sabre\\VObject\\Property\\FlatText', - 'KEY' => 'Sabre\\VObject\\Property\\FlatText', - 'TZ' => 'Sabre\\VObject\\Property\\Text', + 'ORG' => VObject\Property\Text::class, + 'NOTE' => VObject\Property\FlatText::class, + 'REV' => VObject\Property\VCard\TimeStamp::class, + 'SOUND' => VObject\Property\FlatText::class, + 'URL' => VObject\Property\Uri::class, + 'UID' => VObject\Property\FlatText::class, + 'VERSION' => VObject\Property\FlatText::class, + 'KEY' => VObject\Property\FlatText::class, + 'TZ' => VObject\Property\Text::class, // vCard 3.0 properties - 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', - 'SORT-STRING' => 'Sabre\\VObject\\Property\\FlatText', - 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', - 'NICKNAME' => 'Sabre\\VObject\\Property\\Text', - 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 + 'CATEGORIES' => VObject\Property\Text::class, + 'SORT-STRING' => VObject\Property\FlatText::class, + 'PRODID' => VObject\Property\FlatText::class, + 'NICKNAME' => VObject\Property\Text::class, + 'CLASS' => VObject\Property\FlatText::class, // Removed in vCard 4.0 // rfc2739 properties - 'FBURL' => 'Sabre\\VObject\\Property\\Uri', - 'CAPURI' => 'Sabre\\VObject\\Property\\Uri', - 'CALURI' => 'Sabre\\VObject\\Property\\Uri', - 'CALADRURI' => 'Sabre\\VObject\\Property\\Uri', + 'FBURL' => VObject\Property\Uri::class, + 'CAPURI' => VObject\Property\Uri::class, + 'CALURI' => VObject\Property\Uri::class, + 'CALADRURI' => VObject\Property\Uri::class, // rfc4770 properties - 'IMPP' => 'Sabre\\VObject\\Property\\Uri', + 'IMPP' => VObject\Property\Uri::class, // vCard 4.0 properties - 'SOURCE' => 'Sabre\\VObject\\Property\\Uri', - 'XML' => 'Sabre\\VObject\\Property\\FlatText', - 'ANNIVERSARY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', - 'CLIENTPIDMAP' => 'Sabre\\VObject\\Property\\Text', - 'LANG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', - 'GENDER' => 'Sabre\\VObject\\Property\\Text', - 'KIND' => 'Sabre\\VObject\\Property\\FlatText', - 'MEMBER' => 'Sabre\\VObject\\Property\\Uri', - 'RELATED' => 'Sabre\\VObject\\Property\\Uri', + 'SOURCE' => VObject\Property\Uri::class, + 'XML' => VObject\Property\FlatText::class, + 'ANNIVERSARY' => VObject\Property\VCard\DateAndOrTime::class, + 'CLIENTPIDMAP' => VObject\Property\Text::class, + 'LANG' => VObject\Property\VCard\LanguageTag::class, + 'GENDER' => VObject\Property\Text::class, + 'KIND' => VObject\Property\FlatText::class, + 'MEMBER' => VObject\Property\Uri::class, + 'RELATED' => VObject\Property\Uri::class, // rfc6474 properties - 'BIRTHPLACE' => 'Sabre\\VObject\\Property\\FlatText', - 'DEATHPLACE' => 'Sabre\\VObject\\Property\\FlatText', - 'DEATHDATE' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'BIRTHPLACE' => VObject\Property\FlatText::class, + 'DEATHPLACE' => VObject\Property\FlatText::class, + 'DEATHDATE' => VObject\Property\VCard\DateAndOrTime::class, // rfc6715 properties - 'EXPERTISE' => 'Sabre\\VObject\\Property\\FlatText', - 'HOBBY' => 'Sabre\\VObject\\Property\\FlatText', - 'INTEREST' => 'Sabre\\VObject\\Property\\FlatText', - 'ORG-DIRECTORY' => 'Sabre\\VObject\\Property\\FlatText', + 'EXPERTISE' => VObject\Property\FlatText::class, + 'HOBBY' => VObject\Property\FlatText::class, + 'INTEREST' => VObject\Property\FlatText::class, + 'ORG-DIRECTORY' => VObject\Property\FlatText::class, ]; /** @@ -526,8 +526,8 @@ public function getClassNameForPropertyName($propertyName) $className = parent::getClassNameForPropertyName($propertyName); // In vCard 4, BINARY no longer exists, and we need URI instead. - if ('Sabre\\VObject\\Property\\Binary' == $className && self::VCARD40 === $this->getDocumentType()) { - return 'Sabre\\VObject\\Property\\Uri'; + if (VObject\Property\Binary::class == $className && self::VCARD40 === $this->getDocumentType()) { + return VObject\Property\Uri::class; } return $className; diff --git a/lib/Document.php b/lib/Document.php index 0cb2e0978..14a77c911 100644 --- a/lib/Document.php +++ b/lib/Document.php @@ -160,7 +160,7 @@ public function create($name) public function createComponent($name, array $children = null, $defaults = true) { $name = strtoupper($name); - $class = 'Sabre\\VObject\\Component'; + $class = Component::class; if (isset(static::$componentMap[$name])) { $class = static::$componentMap[$name]; @@ -258,7 +258,7 @@ public function getClassNameForPropertyName($propertyName) if (isset(static::$propertyMap[$propertyName])) { return static::$propertyMap[$propertyName]; } else { - return 'Sabre\\VObject\\Property\\Unknown'; + return Property\Unknown::class; } } } diff --git a/lib/Parser/Json.php b/lib/Parser/Json.php index e8138b197..f33603207 100644 --- a/lib/Parser/Json.php +++ b/lib/Parser/Json.php @@ -7,6 +7,8 @@ use Sabre\VObject\Document; use Sabre\VObject\EofException; use Sabre\VObject\ParseException; +use Sabre\VObject\Property\FlatText; +use Sabre\VObject\Property\Text; /** * Json Parser. @@ -156,8 +158,8 @@ public function parseProperty(array $jProp) // represents TEXT values. We have to normalize these here. In the // future we can get rid of FlatText once we're allowed to break BC // again. - if ('Sabre\VObject\Property\FlatText' === $defaultPropertyClass) { - $defaultPropertyClass = 'Sabre\VObject\Property\Text'; + if (FlatText::class === $defaultPropertyClass) { + $defaultPropertyClass = Text::class; } // If the value type we received (e.g.: TEXT) was not the default value diff --git a/lib/Parser/XML.php b/lib/Parser/XML.php index 8b7693edd..78773173d 100644 --- a/lib/Parser/XML.php +++ b/lib/Parser/XML.php @@ -351,9 +351,9 @@ public function setInput($input) if (is_string($input)) { $reader = new SabreXml\Reader(); $reader->elementMap['{'.self::XCAL_NAMESPACE.'}period'] - = 'Sabre\VObject\Parser\XML\Element\KeyValue'; + = XML\Element\KeyValue::class; $reader->elementMap['{'.self::XCAL_NAMESPACE.'}recur'] - = 'Sabre\VObject\Parser\XML\Element\KeyValue'; + = XML\Element\KeyValue::class; $reader->xml($input); $input = $reader->parse(); } diff --git a/tests/VObject/Component/AvailableTest.php b/tests/VObject/Component/AvailableTest.php index 55292424e..bf0a6716f 100644 --- a/tests/VObject/Component/AvailableTest.php +++ b/tests/VObject/Component/AvailableTest.php @@ -22,7 +22,7 @@ public function testAvailableComponent() END:VCALENDAR VCAL; $document = Reader::read($vcal); - $this->assertInstanceOf(__NAMESPACE__.'\Available', $document->AVAILABLE); + $this->assertInstanceOf(Available::class, $document->AVAILABLE); } public function testGetEffectiveStartEnd() diff --git a/tests/VObject/Component/VAvailabilityTest.php b/tests/VObject/Component/VAvailabilityTest.php index b6b9a2b80..2fd9c0dde 100644 --- a/tests/VObject/Component/VAvailabilityTest.php +++ b/tests/VObject/Component/VAvailabilityTest.php @@ -24,7 +24,7 @@ public function testVAvailabilityComponent() VCAL; $document = Reader::read($vcal); - $this->assertInstanceOf(__NAMESPACE__.'\VAvailability', $document->VAVAILABILITY); + $this->assertInstanceOf(VAvailability::class, $document->VAVAILABILITY); } public function testGetEffectiveStartEnd() @@ -236,7 +236,7 @@ public function testAvailableSubComponent() VCAL; $document = Reader::read($vcal); - $this->assertInstanceOf(__NAMESPACE__, $document->VAVAILABILITY->AVAILABLE); + $this->assertInstanceOf(Available::class, $document->VAVAILABILITY->AVAILABLE); } public function testRFCxxxSection3_1_availableprop_required() diff --git a/tests/VObject/ComponentTest.php b/tests/VObject/ComponentTest.php index 4979592a0..f56d55531 100644 --- a/tests/VObject/ComponentTest.php +++ b/tests/VObject/ComponentTest.php @@ -21,7 +21,7 @@ public function testIterate() $count = 0; foreach ($comp->children() as $key => $subcomponent) { ++$count; - $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent); + $this->assertInstanceOf(Component::class, $subcomponent); if (2 === $count) { $this->assertEquals(1, $key); @@ -41,7 +41,7 @@ public function testMagicGet() $comp->add($sub); $event = $comp->vevent; - $this->assertInstanceOf('Sabre\\VObject\\Component', $event); + $this->assertInstanceOf(Component::class, $event); $this->assertEquals('VEVENT', $event->name); $this->assertNull($comp->vjournal); @@ -92,7 +92,7 @@ public function testMagicSetScalar() $comp = new VCalendar(); $comp->myProp = 'myValue'; - $this->assertInstanceOf('Sabre\\VObject\\Property', $comp->MYPROP); + $this->assertInstanceOf(Property::class, $comp->MYPROP); $this->assertEquals('myValue', (string) $comp->MYPROP); } @@ -103,7 +103,7 @@ public function testMagicSetScalarTwice() $comp->myProp = 'myValue'; $this->assertEquals(1, count($comp->children())); - $this->assertInstanceOf('Sabre\\VObject\\Property', $comp->MYPROP); + $this->assertInstanceOf(Property::class, $comp->MYPROP); $this->assertEquals('myValue', (string) $comp->MYPROP); } @@ -112,7 +112,7 @@ public function testMagicSetArray() $comp = new VCalendar(); $comp->ORG = ['Acme Inc', 'Section 9']; - $this->assertInstanceOf('Sabre\\VObject\\Property', $comp->ORG); + $this->assertInstanceOf(Property::class, $comp->ORG); $this->assertEquals(['Acme Inc', 'Section 9'], $comp->ORG->getParts()); } @@ -216,7 +216,7 @@ public function testAddScalarParams() $bla = $comp->children()[0]; - $this->assertInstanceOf('Sabre\\VObject\\Property', $bla); + $this->assertInstanceOf(Property::class, $bla); $this->assertEquals('MYPROP', $bla->name); $this->assertEquals('value', (string) $bla); diff --git a/tests/VObject/DocumentTest.php b/tests/VObject/DocumentTest.php index 2665406f6..f2698f65f 100644 --- a/tests/VObject/DocumentTest.php +++ b/tests/VObject/DocumentTest.php @@ -24,11 +24,11 @@ public function testCreateComponent() $event = $vcal->createComponent('VEVENT'); - $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event); + $this->assertInstanceOf(Component\VEvent::class, $event); $vcal->add($event); $prop = $vcal->createProperty('X-PROP', '1234256', ['X-PARAM' => '3']); - $this->assertInstanceOf('Sabre\VObject\Property', $prop); + $this->assertInstanceOf(Property::class, $prop); $event->add($prop); @@ -46,16 +46,16 @@ public function testCreate() $vcal = new Component\VCalendar([], false); $event = $vcal->create('VEVENT'); - $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event); + $this->assertInstanceOf(Component\VEvent::class, $event); $prop = $vcal->create('CALSCALE'); - $this->assertInstanceOf('Sabre\VObject\Property\Text', $prop); + $this->assertInstanceOf(Property\Text::class, $prop); } public function testGetClassNameForPropertyValue() { $vcal = new Component\VCalendar([], false); - $this->assertEquals('Sabre\\VObject\\Property\\Text', $vcal->getClassNameForPropertyValue('TEXT')); + $this->assertEquals(Property\Text::class, $vcal->getClassNameForPropertyValue('TEXT')); $this->assertNull($vcal->getClassNameForPropertyValue('FOO')); } @@ -64,7 +64,7 @@ public function testDestroy() $vcal = new Component\VCalendar([], false); $event = $vcal->createComponent('VEVENT'); - $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event); + $this->assertInstanceOf(Component\VEvent::class, $event); $vcal->add($event); $prop = $vcal->createProperty('X-PROP', '1234256', ['X-PARAM' => '3']); diff --git a/tests/VObject/ElementListTest.php b/tests/VObject/ElementListTest.php index 4b1ce999f..f3bb8f2bb 100644 --- a/tests/VObject/ElementListTest.php +++ b/tests/VObject/ElementListTest.php @@ -22,7 +22,7 @@ public function testIterate() $count = 0; foreach ($elemList as $key => $subcomponent) { ++$count; - $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent); + $this->assertInstanceOf(Component::class, $subcomponent); if (3 === $count) { $this->assertEquals(2, $key); diff --git a/tests/VObject/EmptyParameterTest.php b/tests/VObject/EmptyParameterTest.php index 213e69ab8..52fe878e2 100644 --- a/tests/VObject/EmptyParameterTest.php +++ b/tests/VObject/EmptyParameterTest.php @@ -20,7 +20,7 @@ public function testRead() $vcard = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard); + $this->assertInstanceOf(Component\VCard::class, $vcard); $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30); $vcard = $vcard->serialize(); diff --git a/tests/VObject/ICalendar/AttachParseTest.php b/tests/VObject/ICalendar/AttachParseTest.php index a32a2462e..e6e3d8685 100644 --- a/tests/VObject/ICalendar/AttachParseTest.php +++ b/tests/VObject/ICalendar/AttachParseTest.php @@ -3,6 +3,7 @@ namespace Sabre\VObject\ICalendar; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Property\Uri; use Sabre\VObject\Reader; class AttachParseTest extends TestCase @@ -23,7 +24,7 @@ public function testParseAttach() $vcal = Reader::read($vcal); $prop = $vcal->VEVENT->ATTACH; - $this->assertInstanceOf('Sabre\\VObject\\Property\\URI', $prop); + $this->assertInstanceOf(Uri::class, $prop); $this->assertEquals('ftp://example.com/pub/reports/r-960812.ps', $prop->getValue()); } } diff --git a/tests/VObject/Issue36WorkAroundTest.php b/tests/VObject/Issue36WorkAroundTest.php index 332aace39..1afd3d184 100644 --- a/tests/VObject/Issue36WorkAroundTest.php +++ b/tests/VObject/Issue36WorkAroundTest.php @@ -34,6 +34,6 @@ public function testWorkaround() // If this does not throw an exception, it's all good. $it = new Recur\EventIterator($obj, '1833bd44-188b-405c-9f85-1a12105318aa'); - $this->assertInstanceOf('Sabre\\VObject\\Recur\\EventIterator', $it); + $this->assertInstanceOf(Recur\EventIterator::class, $it); } } diff --git a/tests/VObject/Issue64Test.php b/tests/VObject/Issue64Test.php index 9dc2bb984..2e623baa8 100644 --- a/tests/VObject/Issue64Test.php +++ b/tests/VObject/Issue64Test.php @@ -14,6 +14,6 @@ public function testRead() $converted = Reader::read($vcard); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $converted); + $this->assertInstanceOf(Component\VCard::class, $converted); } } diff --git a/tests/VObject/Issue96Test.php b/tests/VObject/Issue96Test.php index 22d1fed2f..88803a3e0 100644 --- a/tests/VObject/Issue96Test.php +++ b/tests/VObject/Issue96Test.php @@ -18,7 +18,7 @@ public function testRead() VCF; $vcard = Reader::read($input, Reader::OPTION_FORGIVING); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard); + $this->assertInstanceOf(Component\VCard::class, $vcard); $this->assertEquals('http://www.example.org', $vcard->URL->getValue()); } } diff --git a/tests/VObject/Parser/QuotedPrintableTest.php b/tests/VObject/Parser/QuotedPrintableTest.php index 7ec16a5a5..7cadb46eb 100644 --- a/tests/VObject/Parser/QuotedPrintableTest.php +++ b/tests/VObject/Parser/QuotedPrintableTest.php @@ -3,6 +3,7 @@ namespace Sabre\VObject\Parser; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component; use Sabre\VObject\Reader; class QuotedPrintableTest extends TestCase @@ -13,7 +14,7 @@ public function testReadQuotedPrintableSimple() $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCARD', $result->name); $this->assertEquals(1, count($result->children())); $this->assertEquals('Aachen', $this->getPropertyValue($result->LABEL)); @@ -24,7 +25,7 @@ public function testReadQuotedPrintableNewlineSoft() $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aa=\r\n ch=\r\n en\r\nEND:VCARD"; $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCARD', $result->name); $this->assertEquals(1, count($result->children())); $this->assertEquals('Aachen', $this->getPropertyValue($result->LABEL)); @@ -35,7 +36,7 @@ public function testReadQuotedPrintableNewlineHard() $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aachen=0D=0A=\r\n Germany\r\nEND:VCARD"; $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCARD', $result->name); $this->assertEquals(1, count($result->children())); $this->assertEquals("Aachen\r\nGermany", $this->getPropertyValue($result->LABEL)); @@ -46,7 +47,7 @@ public function testReadQuotedPrintableCompatibilityMS() $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aachen=0D=0A=\r\nDeutschland:okay\r\nEND:VCARD"; $result = Reader::read($data, Reader::OPTION_FORGIVING); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCARD', $result->name); $this->assertEquals(1, count($result->children())); $this->assertEquals("Aachen\r\nDeutschland:okay", $this->getPropertyValue($result->LABEL)); diff --git a/tests/VObject/Property/FloatTest.php b/tests/VObject/Property/FloatTest.php index c5237c47b..0ba02470e 100644 --- a/tests/VObject/Property/FloatTest.php +++ b/tests/VObject/Property/FloatTest.php @@ -14,7 +14,7 @@ public function testMimeDir() $result = $mimeDir->parse($input); - $this->assertInstanceOf('Sabre\VObject\Property\FloatValue', $result->{'X-FLOAT'}); + $this->assertInstanceOf(FloatValue::class, $result->{'X-FLOAT'}); $this->assertEquals([ 0.234, diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php index 3567ff1c0..3902a6e13 100644 --- a/tests/VObject/Property/ICalendar/RecurTest.php +++ b/tests/VObject/Property/ICalendar/RecurTest.php @@ -16,7 +16,7 @@ public function testParts() $vcal = new VCalendar(); $recur = $vcal->add('RRULE', 'FREQ=Daily'); - $this->assertInstanceOf('Sabre\VObject\Property\ICalendar\Recur', $recur); + $this->assertInstanceOf(Recur::class, $recur); $this->assertEquals(['FREQ' => 'DAILY'], $recur->getParts()); $recur->setParts(['freq' => 'MONTHLY']); diff --git a/tests/VObject/Property/VCard/LanguageTagTest.php b/tests/VObject/Property/VCard/LanguageTagTest.php index ffb65f434..54106ffe8 100644 --- a/tests/VObject/Property/VCard/LanguageTagTest.php +++ b/tests/VObject/Property/VCard/LanguageTagTest.php @@ -14,7 +14,7 @@ public function testMimeDir() $result = $mimeDir->parse($input); - $this->assertInstanceOf('Sabre\VObject\Property\VCard\LanguageTag', $result->LANG); + $this->assertInstanceOf(LanguageTag::class, $result->LANG); $this->assertEquals('nl', $result->LANG->getValue()); @@ -31,7 +31,7 @@ public function testChangeAndSerialize() $result = $mimeDir->parse($input); - $this->assertInstanceOf('Sabre\VObject\Property\VCard\LanguageTag', $result->LANG); + $this->assertInstanceOf(LanguageTag::class, $result->LANG); // This replicates what the vcard converter does and triggered a bug in // the past. $result->LANG->setValue(['de']); diff --git a/tests/VObject/Property/VCard/PhoneNumberTest.php b/tests/VObject/Property/VCard/PhoneNumberTest.php index 4a54d3333..668bc7e4c 100644 --- a/tests/VObject/Property/VCard/PhoneNumberTest.php +++ b/tests/VObject/Property/VCard/PhoneNumberTest.php @@ -12,7 +12,7 @@ public function testParser() $input = "BEGIN:VCARD\r\nVERSION:3.0\r\nTEL;TYPE=HOME;VALUE=PHONE-NUMBER:+1234\r\nEND:VCARD\r\n"; $vCard = VObject\Reader::read($input); - $this->assertInstanceOf('Sabre\VObject\Property\VCard\PhoneNumber', $vCard->TEL); + $this->assertInstanceOf(PhoneNumber::class, $vCard->TEL); $this->assertEquals('PHONE-NUMBER', $vCard->TEL->getValueType()); $this->assertEquals($input, $vCard->serialize()); } diff --git a/tests/VObject/PropertyTest.php b/tests/VObject/PropertyTest.php index adfb62e64..1f6e07022 100644 --- a/tests/VObject/PropertyTest.php +++ b/tests/VObject/PropertyTest.php @@ -62,7 +62,7 @@ public function testParameterGet() $property = $cal->createProperty('propname', 'propvalue'); $property['paramname'] = 'paramvalue'; - $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property['paramname']); + $this->assertInstanceOf(Parameter::class, $property['paramname']); } public function testParameterNotExists() @@ -81,7 +81,7 @@ public function testParameterMultiple() $property['paramname'] = 'paramvalue'; $property->add('paramname', 'paramvalue'); - $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property['paramname']); + $this->assertInstanceOf(Parameter::class, $property['paramname']); $this->assertEquals(2, count($property['paramname']->getParts())); } @@ -92,7 +92,7 @@ public function testSetParameterAsString() $property['paramname'] = 'paramvalue'; $this->assertEquals(1, count($property->parameters())); - $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property->parameters['PARAMNAME']); + $this->assertInstanceOf(Parameter::class, $property->parameters['PARAMNAME']); $this->assertEquals('PARAMNAME', $property->parameters['PARAMNAME']->name); $this->assertEquals('paramvalue', $property->parameters['PARAMNAME']->getValue()); } diff --git a/tests/VObject/ReaderTest.php b/tests/VObject/ReaderTest.php index f9d08c75a..0992806be 100644 --- a/tests/VObject/ReaderTest.php +++ b/tests/VObject/ReaderTest.php @@ -12,7 +12,7 @@ public function testReadComponent() $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } @@ -27,7 +27,7 @@ public function testReadStream() $result = Reader::read($stream); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } @@ -38,7 +38,7 @@ public function testReadComponentUnixNewLine() $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } @@ -49,7 +49,7 @@ public function testReadComponentLineFold() $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } @@ -76,7 +76,7 @@ public function testReadProperty() $result = Reader::read($data); $result = $result->SUMMARY; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('SUMMARY', $result->name); $this->assertEquals('propValue', $result->getValue()); } @@ -87,7 +87,7 @@ public function testReadPropertyWithNewLine() $result = Reader::read($data); $result = $result->SUMMARY; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('SUMMARY', $result->name); $this->assertEquals("Line1\nLine2\nLine3\\Not the 4th line!", $result->getValue()); } @@ -98,7 +98,7 @@ public function testReadMappedProperty() $result = Reader::read($data); $result = $result->DTSTART; - $this->assertInstanceOf('Sabre\\VObject\\Property\\ICalendar\\DateTime', $result); + $this->assertInstanceOf(Property\ICalendar\DateTime::class, $result); $this->assertEquals('DTSTART', $result->name); $this->assertEquals('20110529', $result->getValue()); } @@ -109,7 +109,7 @@ public function testReadMappedPropertyGrouped() $result = Reader::read($data); $result = $result->DTSTART; - $this->assertInstanceOf('Sabre\\VObject\\Property\\ICalendar\\DateTime', $result); + $this->assertInstanceOf(Property\ICalendar\DateTime::class, $result); $this->assertEquals('DTSTART', $result->name); $this->assertEquals('20110529', $result->getValue()); } @@ -131,10 +131,10 @@ public function testReadPropertyInComponent() $result = Reader::read(implode("\r\n", $data)); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(1, count($result->children())); - $this->assertInstanceOf('Sabre\\VObject\\Property', $result->children()[0]); + $this->assertInstanceOf(Property::class, $result->children()[0]); $this->assertEquals('PROPNAME', $result->children()[0]->name); $this->assertEquals('propValue', $result->children()[0]->getValue()); } @@ -152,13 +152,13 @@ public function testReadNestedComponent() $result = Reader::read(implode("\r\n", $data)); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(1, count($result->children())); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result->children()[0]); + $this->assertInstanceOf(Component::class, $result->children()[0]); $this->assertEquals('VTIMEZONE', $result->children()[0]->name); $this->assertEquals(1, count($result->children()[0]->children())); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result->children()[0]->children()[0]); + $this->assertInstanceOf(Component::class, $result->children()[0]->children()[0]); $this->assertEquals('DAYLIGHT', $result->children()[0]->children()[0]->name); } @@ -169,7 +169,7 @@ public function testReadPropertyParameter() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -184,7 +184,7 @@ public function testReadPropertyRepeatingParameter() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -200,7 +200,7 @@ public function testReadPropertyRepeatingNamelessGuessedParameter() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -216,7 +216,7 @@ public function testReadPropertyNoName() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -232,7 +232,7 @@ public function testReadPropertyParameterExtraColon() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue:anotherrandomstring', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -247,7 +247,7 @@ public function testReadProperty2Parameters() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(2, count($result->parameters())); @@ -264,7 +264,7 @@ public function testReadPropertyParameterQuoted() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -279,7 +279,7 @@ public function testReadPropertyParameterNewLines() $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); @@ -294,7 +294,7 @@ public function testReadPropertyParameterQuotedColon() $result = Reader::read($data); $result = $result->PROPNAME; - $this->assertInstanceOf('Sabre\\VObject\\Property', $result); + $this->assertInstanceOf(Property::class, $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->getValue()); $this->assertEquals(1, count($result->parameters())); @@ -408,7 +408,7 @@ public function testReadBOM() $data = chr(0xef).chr(0xbb).chr(0xbf)."BEGIN:VCALENDAR\r\nEND:VCALENDAR"; $result = Reader::read($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } @@ -425,7 +425,7 @@ public function testReadXMLComponent() $result = Reader::readXML($data); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } @@ -446,7 +446,7 @@ public function testReadXMLStream() $result = Reader::readXML($stream); - $this->assertInstanceOf('Sabre\\VObject\\Component', $result); + $this->assertInstanceOf(Component::class, $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children())); } diff --git a/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php b/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php index 3448032e8..bd1eeb9b6 100644 --- a/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php +++ b/tests/VObject/Recur/EventIterator/ByMonthInDailyTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; class ByMonthInDailyTest extends TestCase @@ -36,7 +37,7 @@ public function testExpand() ICS; $vcal = Reader::read($ics); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand(new DateTime('2013-09-28'), new DateTime('2014-09-11')); diff --git a/tests/VObject/Recur/EventIterator/BySetPosHangTest.php b/tests/VObject/Recur/EventIterator/BySetPosHangTest.php index caf6b0dc3..555f2ffd4 100644 --- a/tests/VObject/Recur/EventIterator/BySetPosHangTest.php +++ b/tests/VObject/Recur/EventIterator/BySetPosHangTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; class BySetPosHangTest extends TestCase @@ -31,7 +32,7 @@ public function testExpand() ICS; $vcal = Reader::read($ics); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2016-01-01')); diff --git a/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php b/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php index 635b0a8c5..605e10dde 100644 --- a/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php +++ b/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php @@ -5,6 +5,7 @@ use DateTime; use DateTimeZone; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; class ExpandFloatingTimesTest extends TestCase @@ -26,7 +27,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-01-31')); $output = <<assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand( new DateTime('2015-01-01'), diff --git a/tests/VObject/Recur/EventIterator/HandleRDateExpandTest.php b/tests/VObject/Recur/EventIterator/HandleRDateExpandTest.php index 698c5fe59..548820191 100644 --- a/tests/VObject/Recur/EventIterator/HandleRDateExpandTest.php +++ b/tests/VObject/Recur/EventIterator/HandleRDateExpandTest.php @@ -6,6 +6,7 @@ use DateTimeImmutable; use DateTimeZone; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; /** @@ -36,7 +37,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-12-01')); diff --git a/tests/VObject/Recur/EventIterator/IncorrectExpandTest.php b/tests/VObject/Recur/EventIterator/IncorrectExpandTest.php index afc509972..f9fcda442 100644 --- a/tests/VObject/Recur/EventIterator/IncorrectExpandTest.php +++ b/tests/VObject/Recur/EventIterator/IncorrectExpandTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; /** @@ -34,7 +35,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand(new DateTime('2011-01-01'), new DateTime('2014-01-01')); diff --git a/tests/VObject/Recur/EventIterator/Issue26Test.php b/tests/VObject/Recur/EventIterator/Issue26Test.php index 60d3aa240..3313c3ec6 100644 --- a/tests/VObject/Recur/EventIterator/Issue26Test.php +++ b/tests/VObject/Recur/EventIterator/Issue26Test.php @@ -3,6 +3,7 @@ namespace Sabre\VObject\Recur\EventIterator; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\InvalidDataException; use Sabre\VObject\Reader; use Sabre\VObject\Recur\EventIterator; @@ -25,7 +26,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $it = new EventIterator($vcal, 'bae5d57a98'); } diff --git a/tests/VObject/Recur/EventIterator/Issue48Test.php b/tests/VObject/Recur/EventIterator/Issue48Test.php index f08f0ccce..aef592590 100644 --- a/tests/VObject/Recur/EventIterator/Issue48Test.php +++ b/tests/VObject/Recur/EventIterator/Issue48Test.php @@ -5,6 +5,7 @@ use DateTimeImmutable; use DateTimeZone; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; use Sabre\VObject\Recur\EventIterator; @@ -30,7 +31,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $it = new EventIterator($vcal, 'foo'); diff --git a/tests/VObject/Recur/EventIterator/Issue50Test.php b/tests/VObject/Recur/EventIterator/Issue50Test.php index faa04e829..5c476e6f2 100644 --- a/tests/VObject/Recur/EventIterator/Issue50Test.php +++ b/tests/VObject/Recur/EventIterator/Issue50Test.php @@ -5,6 +5,7 @@ use DateTimeImmutable; use DateTimeZone; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; use Sabre\VObject\Recur\EventIterator; @@ -104,7 +105,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $it = new EventIterator($vcal, '1aef0b27-3d92-4581-829a-11999dd36724'); diff --git a/tests/VObject/Recur/EventIterator/MissingOverriddenTest.php b/tests/VObject/Recur/EventIterator/MissingOverriddenTest.php index 5ed47238d..69af8a8a1 100644 --- a/tests/VObject/Recur/EventIterator/MissingOverriddenTest.php +++ b/tests/VObject/Recur/EventIterator/MissingOverriddenTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; class MissingOverriddenTest extends TestCase @@ -33,7 +34,7 @@ public function testExpand() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $vcal = $vcal->expand(new DateTime('2011-01-01'), new DateTime('2015-01-01')); diff --git a/tests/VObject/Recur/EventIterator/NoInstancesTest.php b/tests/VObject/Recur/EventIterator/NoInstancesTest.php index 092a63c5f..d89afd197 100644 --- a/tests/VObject/Recur/EventIterator/NoInstancesTest.php +++ b/tests/VObject/Recur/EventIterator/NoInstancesTest.php @@ -3,6 +3,7 @@ namespace Sabre\VObject\Recur\EventIterator; use PHPUnit\Framework\TestCase; +use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; use Sabre\VObject\Recur\EventIterator; use Sabre\VObject\Recur\NoInstancesException; @@ -31,7 +32,7 @@ public function testRecurrence() ICS; $vcal = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); + $this->assertInstanceOf(VCalendar::class, $vcal); $it = new EventIterator($vcal, 'foo'); } diff --git a/tests/VObject/VCardConverterTest.php b/tests/VObject/VCardConverterTest.php index d7c48e045..ae2b10bd5 100644 --- a/tests/VObject/VCardConverterTest.php +++ b/tests/VObject/VCardConverterTest.php @@ -491,7 +491,7 @@ public function testNoLabel() $vcard = Reader::read($input); - $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard); + $this->assertInstanceOf(Component\VCard::class, $vcard); $vcard = $vcard->convert(Document::VCARD40); $vcard = $vcard->serialize(); From 5b2248d965160f93053f3a24704794a13a22a1bb Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 31 Jan 2020 19:50:58 +0100 Subject: [PATCH 27/83] Release 4.3.0 (#497) * Update CHANGELOG.md * Update Version.php --- CHANGELOG.md | 7 +++++++ lib/Version.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ddee77f1..5126e04f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ ChangeLog ========= +4.3.0 (2020-01-31) +------------------ + +* Added support for PHP 7.4, dropped support for PHP 7.0 (@phil-davis) +* #487: Added phpstan coverage, updated testsuite for phpunit8 (@phil-davis, @JeroenVanOort) +* #495: refactored maps to use ::class notation (@JeroenVanOort) + 4.2.2 (2020-01-14) ------------------ diff --git a/lib/Version.php b/lib/Version.php index e18fc00ea..883d20289 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.2.3-dev'; + const VERSION = '4.3.0'; } From c0224ca9e2ee3d7326151fc3fb3095d1230708ac Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 31 Jan 2020 09:39:47 +0100 Subject: [PATCH 28/83] Added phpstan to dev dependencies --- .travis.yml | 3 --- composer.json | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 511119bbb..abe9185c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,6 @@ php: matrix: fast_finish: true -install: - - composer require --dev phpstan/phpstan:^0.12 - before_script: - composer install diff --git a/composer.json b/composer.json index 9e522f8a4..9f1195c26 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ }, "require-dev" : { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit" : "^7 || ^8" + "phpunit/phpunit" : "^7 || ^8", + "phpstan/phpstan": "^0.12" }, "suggest" : { "hoa/bench" : "If you would like to run the benchmark scripts" From 6f6b093e54585c263bb21337078d45f5307aaca8 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 31 Jan 2020 09:51:22 +0100 Subject: [PATCH 29/83] Reset bin-dir config --- .gitignore | 7 ------- .travis.yml | 8 ++++---- composer.json | 3 --- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index e9b0ed32f..f12ec08a8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,13 +8,6 @@ tests/.phpunit.result.cache #vim .*.swp -#binaries -bin/phpunit -bin/php-cs-fixer -bin/phpstan -bin/phpstan.phar -bin/hoa - # Development stuff testdata/ .php_cs.cache diff --git a/.travis.yml b/.travis.yml index abe9185c6..8914a4791 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,10 @@ before_script: - composer install script: - - ./bin/php-cs-fixer fix lib/ --dry-run --diff - - php ./bin/phpstan.phar analyse -c phpstan.neon lib tests - - ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml - + - php vendor/bin/php-cs-fixer fix lib/ --dry-run --diff + - php vendor/bin/phpstan analyse -c phpstan.neon lib tests + - php vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml + after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/composer.json b/composer.json index 9f1195c26..d611cd77b 100644 --- a/composer.json +++ b/composer.json @@ -86,8 +86,5 @@ "branch-alias" : { "dev-master" : "4.0.x-dev" } - }, - "config" : { - "bin-dir" : "bin" } } From 874f389396bfbfefd7bd8ac9c3c74d0b5978fb95 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 31 Jan 2020 09:55:18 +0100 Subject: [PATCH 30/83] Added convenient development commands --- composer.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/composer.json b/composer.json index d611cd77b..21542bb47 100644 --- a/composer.json +++ b/composer.json @@ -86,5 +86,21 @@ "branch-alias" : { "dev-master" : "4.0.x-dev" } + }, + "scripts": { + "phpstan": [ + "@php vendor/bin/phpstan analyse lib tests" + ], + "php-cs-fixer": [ + "@php vendor/bin/php-cs-fixer fix" + ], + "phpunit": [ + "@php vendor/bin/phpunit --configuration tests/phpunit.xml" + ], + "test": [ + "composer phpstan", + "composer php-cs-fixer", + "composer phpunit" + ] } } From 4b759b210f78cd001f6075d8344ccf86a3239357 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 31 Jan 2020 09:57:59 +0100 Subject: [PATCH 31/83] Cleaned up .gitignore These entries should be in the developer's global .gitignore --- .gitignore | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitignore b/.gitignore index f12ec08a8..82b7dad3f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,13 +5,5 @@ tests/cov/ tests/temp tests/.phpunit.result.cache -#vim -.*.swp - # Development stuff -testdata/ .php_cs.cache -.idea - -# OS X -.DS_Store From 79bb4f007a3ee240a83623bab3ede34b4bf8f937 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sat, 1 Feb 2020 19:28:01 +0100 Subject: [PATCH 32/83] cs-fixer: don't check only the lib folder --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8914a4791..b435459c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_script: - composer install script: - - php vendor/bin/php-cs-fixer fix lib/ --dry-run --diff + - php vendor/bin/php-cs-fixer fix --dry-run --diff - php vendor/bin/phpstan analyse -c phpstan.neon lib tests - php vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml From 5bd174f688330c6868b2a356534e44a5dd024ad8 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sat, 1 Feb 2020 19:30:25 +0100 Subject: [PATCH 33/83] Decoupled cs-fixer command from chosen tool --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 21542bb47..555b90b91 100644 --- a/composer.json +++ b/composer.json @@ -91,7 +91,7 @@ "phpstan": [ "@php vendor/bin/phpstan analyse lib tests" ], - "php-cs-fixer": [ + "cs-fixer": [ "@php vendor/bin/php-cs-fixer fix" ], "phpunit": [ @@ -99,7 +99,7 @@ ], "test": [ "composer phpstan", - "composer php-cs-fixer", + "composer cs-fixer", "composer phpunit" ] } From 6b047514d57c468accd5779793efd8cefb5343fe Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 10 Feb 2020 09:17:43 +0545 Subject: [PATCH 34/83] Standardize CI --- .travis.yml | 20 ++++++++++++++++---- composer.json | 8 ++++---- tests/phpunit.xml | 5 +---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index b435459c6..07c4824d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,28 @@ php: - 7.3 - 7.4 +env: + global: + - MEMCACHED_SERVER=127.0.0.1 + - RUN_PHPSTAN="FALSE" + matrix: + - PREFER_LOWEST="" WITH_COVERAGE="--coverage-clover=coverage.xml" + - PREFER_LOWEST="--prefer-lowest" $WITH_COVERAGE="" + matrix: + include: + - name: 'PHPStan' + php: 7.4 + env: RUN_PHPSTAN="TRUE" fast_finish: true before_script: - - composer install + - composer update $PREFER_LOWEST script: - - php vendor/bin/php-cs-fixer fix --dry-run --diff - - php vendor/bin/phpstan analyse -c phpstan.neon lib tests - - php vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml + - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi + - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi + - if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/composer.json b/composer.json index 555b90b91..4890de97b 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ }, "require-dev" : { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit" : "^7 || ^8", + "phpunit/phpunit" : "^7.5 || ^8.5", "phpstan/phpstan": "^0.12" }, "suggest" : { @@ -89,13 +89,13 @@ }, "scripts": { "phpstan": [ - "@php vendor/bin/phpstan analyse lib tests" + "phpstan analyse lib tests" ], "cs-fixer": [ - "@php vendor/bin/php-cs-fixer fix" + "php-cs-fixer fix" ], "phpunit": [ - "@php vendor/bin/phpunit --configuration tests/phpunit.xml" + "phpunit --configuration tests/phpunit.xml" ], "test": [ "composer phpstan", diff --git a/tests/phpunit.xml b/tests/phpunit.xml index c9abae412..c0588d460 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -9,16 +9,13 @@ > - VObject/ + . ../lib/ - - ../lib/Sabre/VObject/includes.php - From 07db2ee3dc4e6d669f7bd8963b26af1cbe66530a Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 10 Feb 2020 09:35:43 +0545 Subject: [PATCH 35/83] Use phpunit 9 where possible --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4890de97b..d4fa56a31 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ }, "require-dev" : { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit" : "^7.5 || ^8.5", + "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0", "phpstan/phpstan": "^0.12" }, "suggest" : { From 22067ece2cf924217cd13404ad13becd5f1e7c18 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 10 Feb 2020 09:46:39 +0545 Subject: [PATCH 36/83] Only upload coverage when it has been collected --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07c4824d0..d1feb60de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,14 +10,16 @@ env: - MEMCACHED_SERVER=127.0.0.1 - RUN_PHPSTAN="FALSE" matrix: - - PREFER_LOWEST="" WITH_COVERAGE="--coverage-clover=coverage.xml" - - PREFER_LOWEST="--prefer-lowest" $WITH_COVERAGE="" + - PREFER_LOWEST="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml" + - PREFER_LOWEST="--prefer-lowest" REPORT_COVERAGE="FALSE" WITH_COVERAGE="" matrix: include: - name: 'PHPStan' php: 7.4 - env: RUN_PHPSTAN="TRUE" + env: + - RUN_PHPSTAN="TRUE" + - REPORT_COVERAGE="FALSE" fast_finish: true before_script: @@ -29,7 +31,7 @@ script: - if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi after_success: - - bash <(curl -s https://codecov.io/bash) + - if [ $REPORT_COVERAGE == "TRUE" ]; then bash <(curl -s https://codecov.io/bash); fi cache: directories: From d29010a67bc8a5604bf69fecb82f9eb8e48601a3 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 21 Jun 2020 23:22:28 +0545 Subject: [PATCH 37/83] Replace assertRegExp with assertMatchesRegularExpression in unit test --- tests/VObject/CliTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/VObject/CliTest.php b/tests/VObject/CliTest.php index 5736f9a01..a4124b76b 100644 --- a/tests/VObject/CliTest.php +++ b/tests/VObject/CliTest.php @@ -483,7 +483,15 @@ public function testRepair() ); rewind($this->cli->stdout); - $this->assertRegExp("/^BEGIN:VCARD\r\nVERSION:2.1\r\nUID:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\r\nEND:VCARD\r\n$/", stream_get_contents($this->cli->stdout)); + $regularExpression = "/^BEGIN:VCARD\r\nVERSION:2.1\r\nUID:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\r\nEND:VCARD\r\n$/"; + $data = stream_get_contents($this->cli->stdout); + // ToDo: when we do not need to run phpunit 7 or 8, remove this 'if' block and just use + // the new assertMatchesRegularExpression that exists since phpunit 9. + if (method_exists($this, 'assertMatchesRegularExpression')) { + $this->assertMatchesRegularExpression($regularExpression, $data); + } else { + $this->assertRegExp($regularExpression, $data); + } } public function testRepairNothing() From 3f25520d13954514091418fc2080660bbc9b5b19 Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Mon, 6 Jul 2020 11:50:17 +0200 Subject: [PATCH 38/83] fix an incomplete phpdoc type annotation --- lib/Component.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Component.php b/lib/Component.php index 58594aec1..da45eb29f 100644 --- a/lib/Component.php +++ b/lib/Component.php @@ -431,7 +431,7 @@ protected function getDefaults() * * @param string $name * - * @return Property + * @return Property|null */ public function __get($name) { From b4c67374c54372b7939f6c551d65c2a1851064cf Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 13 Jul 2020 17:00:36 +0545 Subject: [PATCH 39/83] Release 4.3.1 --- CHANGELOG.md | 8 ++++++++ lib/Version.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5126e04f9..69e14154b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ ChangeLog ========= +4.3.1 (2020-07-13) +------------------ + +* #510: Fix an incomplete phpdoc type annotation (@mstilkerich) +* #505: Refactor unit test code for phpunit9 (@phil-davis) +* #500: Standardize CI (@phil-davis) +* #496: CI tooling changes (@JeroenVanOort) + 4.3.0 (2020-01-31) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 883d20289..e5ab9af38 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.0'; + const VERSION = '4.3.1'; } From cfe4963f7df48f5422386da19f0d560bb6d45cdd Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 12:46:47 +0545 Subject: [PATCH 40/83] Adjust boolean vars in .travis.yml to prepare for PHP8.0 --- .travis.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d1feb60de..3592c37af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ php: env: global: - MEMCACHED_SERVER=127.0.0.1 + - RUN_PHPCSFIXER="TRUE" + - RUN_PHPUNIT="TRUE" - RUN_PHPSTAN="FALSE" matrix: - PREFER_LOWEST="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml" @@ -18,16 +20,19 @@ matrix: - name: 'PHPStan' php: 7.4 env: + - RUN_PHPCSFIXER="FALSE" + - RUN_PHPUNIT="FALSE" - RUN_PHPSTAN="TRUE" - REPORT_COVERAGE="FALSE" fast_finish: true before_script: + - if [ $RUN_PHPCSFIXER == "FALSE" ]; then composer remove --dev friendsofphp/php-cs-fixer; fi - composer update $PREFER_LOWEST script: - - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi - - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi + - if [ $RUN_PHPCSFIXER == "TRUE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi + - if [ $RUN_PHPUNIT == "TRUE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi - if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi after_success: From a1a898a26b24a179b6ad2d543b1982cc3a6f2fb0 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 12:50:01 +0545 Subject: [PATCH 41/83] Run unit tests on PHP8 --- .travis.yml | 6 ++++++ composer.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3592c37af..0eff33ec4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,12 @@ env: matrix: include: + - name: 'PHP8' + dist: focal + php: nightly + env: + - RUN_PHPCSFIXER="FALSE" + - REPORT_COVERAGE="FALSE" - name: 'PHPStan' php: 7.4 env: diff --git a/composer.json b/composer.json index d4fa56a31..05524d254 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "homepage" : "http://sabre.io/vobject/", "license" : "BSD-3-Clause", "require" : { - "php" : "^7.1", + "php" : "^7.1 || ^8.0", "ext-mbstring" : "*", "sabre/xml" : "^2.1" }, From ad7ed41bda9516c61161be2fd1c48caeb41eafb1 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 12:59:52 +0545 Subject: [PATCH 42/83] Fixup calendar parameter to Broker parseEvent --- lib/ITip/Broker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index c09cdf3be..4e0368e13 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -162,7 +162,7 @@ public function processMessage(Message $itipMessage, VCalendar $existingObject = * * @return array */ - public function parseEvent($calendar = null, $userHref, $oldCalendar = null) + public function parseEvent($calendar, $userHref, $oldCalendar = null) { if ($oldCalendar) { if (is_string($oldCalendar)) { From 433b88a238dc9c17d046f6c524f57baa97f66107 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 16:17:38 +0545 Subject: [PATCH 43/83] Release 4.3.2 --- CHANGELOG.md | 5 +++++ lib/Version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e14154b..69be5f924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ChangeLog ========= +4.3.2 (2020-10-03) +------------------ + +* #513: Added Support for PHP 8.0 (@phil-davis) + 4.3.1 (2020-07-13) ------------------ diff --git a/lib/Version.php b/lib/Version.php index e5ab9af38..cc1ff48b0 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.1'; + const VERSION = '4.3.2'; } From 15644b920a31848bd060d18d1ddb527cb64baa93 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 8 Nov 2020 13:16:51 +0545 Subject: [PATCH 44/83] Remove Pacific-New obsolete timezone --- lib/timezonedata/php-bc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/timezonedata/php-bc.php b/lib/timezonedata/php-bc.php index 83f38f507..3116c6868 100644 --- a/lib/timezonedata/php-bc.php +++ b/lib/timezonedata/php-bc.php @@ -147,7 +147,6 @@ 'US/Michigan', 'US/Mountain', 'US/Pacific', - 'US/Pacific-New', 'US/Samoa', 'WET', ]; From 0552fa28a469870f26278def7d8bde52a58f4240 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 8 Nov 2020 13:47:54 +0545 Subject: [PATCH 45/83] Do composer remove --no-update in Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0eff33ec4..4f50e97fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ matrix: fast_finish: true before_script: - - if [ $RUN_PHPCSFIXER == "FALSE" ]; then composer remove --dev friendsofphp/php-cs-fixer; fi + - if [ $RUN_PHPCSFIXER == "FALSE" ]; then composer remove --no-update --dev friendsofphp/php-cs-fixer; fi - composer update $PREFER_LOWEST script: From 6dbc4a3d6f805734c72749ef1c46f6882c9a4d70 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 8 Nov 2020 15:11:23 +0545 Subject: [PATCH 46/83] Use min php-cs-fixer 2.16.7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 05524d254..f26c0b5ec 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "sabre/xml" : "^2.1" }, "require-dev" : { - "friendsofphp/php-cs-fixer": "~2.16.1", + "friendsofphp/php-cs-fixer": "~2.16.7", "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0", "phpstan/phpstan": "^0.12" }, From 8e34e2e6a87932e01e40aa8c51b4af9d48028463 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 9 Nov 2020 10:07:23 +0545 Subject: [PATCH 47/83] Release 4.3.3 --- CHANGELOG.md | 5 +++++ lib/Version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69be5f924..7d6b096fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ChangeLog ========= +4.3.3 (2020-11-09) +------------------ + +* #519: Remove US/Pacific-New obsolete timezone (@phil-davis) + 4.3.2 (2020-10-03) ------------------ diff --git a/lib/Version.php b/lib/Version.php index cc1ff48b0..29ba84f88 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.2'; + const VERSION = '4.3.3'; } From 362a4483264606a4b02b9da1ff0c4b4c95533f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane?= Date: Fri, 27 Nov 2020 18:34:22 +0100 Subject: [PATCH 48/83] Add .gitattributes --- .gitattributes | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..f95a950f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php_cs.dist export-ignore +/.travis.yml export-ignore +/CHANGELOG.md export-ignore +/phpstan.neon export-ignore From 4a92383d63430a46360468ab050c742ab5f9872c Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 10 Dec 2020 12:46:08 +0545 Subject: [PATCH 49/83] Explicitly select PHP 8.0 in CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f50e97fd..a1a1f66b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ matrix: include: - name: 'PHP8' dist: focal - php: nightly + php: 8.0 env: - RUN_PHPCSFIXER="FALSE" - REPORT_COVERAGE="FALSE" From 2fd911fec79f8d5c35fa149862bd710ea3a9a1a2 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 13 Dec 2020 13:21:23 +0545 Subject: [PATCH 50/83] Use latest php-cs-fixer 2.17.1 --- bin/bench_freebusygenerator.php | 2 +- bin/bench_manipulatevcard.php | 2 +- bin/generateicalendardata.php | 4 +- bin/mergeduplicates.php | 4 +- bin/rrulebench.php | 2 +- composer.json | 2 +- lib/Cli.php | 7 +- lib/FreeBusyGenerator.php | 1 - lib/Parameter.php | 6 - lib/Parser/MimeDir.php | 2 +- lib/Property/Boolean.php | 3 +- lib/Property/ICalendar/CalAddress.php | 3 +- lib/Property/IntegerValue.php | 3 +- lib/Property/VCard/LanguageTag.php | 3 +- lib/Recur/RRuleIterator.php | 1 - lib/timezonedata/windowszones.php | 2 +- tests/VObject/Component/VAvailabilityTest.php | 14 +-- tests/VObject/DateTimeParserTest.php | 40 +++---- tests/VObject/Parser/XmlTest.php | 112 +++++++++--------- 19 files changed, 98 insertions(+), 115 deletions(-) diff --git a/bin/bench_freebusygenerator.php b/bin/bench_freebusygenerator.php index 1299c14fb..963623d18 100644 --- a/bin/bench_freebusygenerator.php +++ b/bin/bench_freebusygenerator.php @@ -11,7 +11,7 @@ echo "The process will be repeated 100 times to get accurate stats\n"; echo "\n"; echo 'Usage: '.$argv[0]." inputfile.ics\n"; - die(); + exit(); } list(, $inputFile) = $argv; diff --git a/bin/bench_manipulatevcard.php b/bin/bench_manipulatevcard.php index f229091db..df6d9f23d 100644 --- a/bin/bench_manipulatevcard.php +++ b/bin/bench_manipulatevcard.php @@ -10,7 +10,7 @@ echo 'system.'; echo "\n"; echo 'Usage: '.$argv[0]." inputfile.vcf\n"; - die(); + exit(); } list(, $inputFile) = $argv; diff --git a/bin/generateicalendardata.php b/bin/generateicalendardata.php index 62b6107c5..019ed9745 100755 --- a/bin/generateicalendardata.php +++ b/bin/generateicalendardata.php @@ -18,7 +18,7 @@ HI ); - die(); + exit(); } $events = 100; @@ -77,7 +77,7 @@ if ($result) { fwrite(STDERR, "Errors!\n"); fwrite(STDERR, print_r($result, true)); - die(-1); + exit(-1); } fwrite(STDERR, "Serializing this beast\n"); diff --git a/bin/mergeduplicates.php b/bin/mergeduplicates.php index e6cde73dd..31b2c14ab 100755 --- a/bin/mergeduplicates.php +++ b/bin/mergeduplicates.php @@ -19,7 +19,7 @@ if (!class_exists('Sabre\\VObject\\Version')) { fwrite(STDERR, "Composer autoloader could not be loaded.\n"); - die(1); + exit(1); } echo 'sabre/vobject ', Version::VERSION, " duplicate contact merge tool\n"; @@ -27,7 +27,7 @@ if ($argc < 3) { echo "\n"; echo 'Usage: ', $argv[0], " input.vcf output.vcf [debug.log]\n"; - die(1); + exit(1); } $input = fopen($argv[1], 'r'); diff --git a/bin/rrulebench.php b/bin/rrulebench.php index 583da574c..69008002e 100644 --- a/bin/rrulebench.php +++ b/bin/rrulebench.php @@ -9,7 +9,7 @@ echo 'system.'; echo "\n"; echo 'Usage: '.$argv[0]." inputfile.ics startdate enddate\n"; - die(); + exit(); } list(, $inputFile, $startDate, $endDate) = $argv; diff --git a/composer.json b/composer.json index f26c0b5ec..4de13d926 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "sabre/xml" : "^2.1" }, "require-dev" : { - "friendsofphp/php-cs-fixer": "~2.16.7", + "friendsofphp/php-cs-fixer": "~2.17.1", "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0", "phpstan/phpstan": "^0.12" }, diff --git a/lib/Cli.php b/lib/Cli.php index f3e419b15..54b938764 100644 --- a/lib/Cli.php +++ b/lib/Cli.php @@ -2,8 +2,7 @@ namespace Sabre\VObject; -use - InvalidArgumentException; +use InvalidArgumentException; /** * This is the CLI interface for sabre-vobject. @@ -137,17 +136,14 @@ public function main(array $argv) // jcard/jcal documents case 'jcard': case 'jcal': - // specific document versions case 'vcard21': case 'vcard30': case 'vcard40': case 'icalendar20': - // specific formats case 'json': case 'mimedir': - // icalendar/vcad case 'icalendar': case 'vcard': @@ -183,7 +179,6 @@ public function main(array $argv) case 'vcard30': case 'vcard40': case 'icalendar20': - $this->inputFormat = 'mimedir'; break; diff --git a/lib/FreeBusyGenerator.php b/lib/FreeBusyGenerator.php index a1c24044c..63f05a151 100644 --- a/lib/FreeBusyGenerator.php +++ b/lib/FreeBusyGenerator.php @@ -362,7 +362,6 @@ protected function calculateBusy(FreeBusyData $fbData, array $objects) foreach ($object->getBaseComponents() as $component) { switch ($component->name) { case 'VEVENT': - $FBTYPE = 'BUSY'; if (isset($component->TRANSP) && ('TRANSPARENT' === strtoupper($component->TRANSP))) { break; diff --git a/lib/Parameter.php b/lib/Parameter.php index e39d320a1..de0c5bfdc 100644 --- a/lib/Parameter.php +++ b/lib/Parameter.php @@ -95,13 +95,11 @@ public static function guessParameterNameByValue($value) case 'WORK': case 'HOME': case 'PREF': - // Delivery Label Type case 'DOM': case 'INTL': case 'POSTAL': case 'PARCEL': - // Telephone types case 'VOICE': case 'FAX': @@ -113,7 +111,6 @@ public static function guessParameterNameByValue($value) case 'CAR': case 'ISDN': case 'VIDEO': - // EMAIL types (lol) case 'AOL': case 'APPLELINK': @@ -127,7 +124,6 @@ public static function guessParameterNameByValue($value) case 'PRODIGY': case 'TLX': case 'X400': - // Photo / Logo format types case 'GIF': case 'CGM': @@ -143,12 +139,10 @@ public static function guessParameterNameByValue($value) case 'MPEG2': case 'AVI': case 'QTIME': - // Sound Digital Audio Type case 'WAVE': case 'PCM': case 'AIFF': - // Key types case 'X509': case 'PGP': diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index ea5ac0326..385d340d7 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -343,7 +343,7 @@ protected function readProperty($line) ) (?=[;:,]) /xi"; - //echo $regex, "\n"; die(); + //echo $regex, "\n"; exit(); preg_match_all($regex, $line, $matches, PREG_SET_ORDER); $property = [ diff --git a/lib/Property/Boolean.php b/lib/Property/Boolean.php index 9fb2bce35..4bd6ffdfe 100644 --- a/lib/Property/Boolean.php +++ b/lib/Property/Boolean.php @@ -2,8 +2,7 @@ namespace Sabre\VObject\Property; -use - Sabre\VObject\Property; +use Sabre\VObject\Property; /** * Boolean property. diff --git a/lib/Property/ICalendar/CalAddress.php b/lib/Property/ICalendar/CalAddress.php index e89bb31f9..86be66c15 100644 --- a/lib/Property/ICalendar/CalAddress.php +++ b/lib/Property/ICalendar/CalAddress.php @@ -2,8 +2,7 @@ namespace Sabre\VObject\Property\ICalendar; -use - Sabre\VObject\Property\Text; +use Sabre\VObject\Property\Text; /** * CalAddress property. diff --git a/lib/Property/IntegerValue.php b/lib/Property/IntegerValue.php index 6f709bfff..3ae775214 100644 --- a/lib/Property/IntegerValue.php +++ b/lib/Property/IntegerValue.php @@ -2,8 +2,7 @@ namespace Sabre\VObject\Property; -use - Sabre\VObject\Property; +use Sabre\VObject\Property; /** * Integer property. diff --git a/lib/Property/VCard/LanguageTag.php b/lib/Property/VCard/LanguageTag.php index 697273989..318ea0231 100644 --- a/lib/Property/VCard/LanguageTag.php +++ b/lib/Property/VCard/LanguageTag.php @@ -2,8 +2,7 @@ namespace Sabre\VObject\Property\VCard; -use - Sabre\VObject\Property; +use Sabre\VObject\Property; /** * LanguageTag property. diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 55581e9ac..1d774152a 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -717,7 +717,6 @@ protected function parseRRule($rrule) break; case 'INTERVAL': - case 'COUNT': $val = (int) $value; if ($val < 1) { diff --git a/lib/timezonedata/windowszones.php b/lib/timezonedata/windowszones.php index af3904b12..94455e66c 100644 --- a/lib/timezonedata/windowszones.php +++ b/lib/timezonedata/windowszones.php @@ -10,7 +10,7 @@ * @license http://sabre.io/license/ Modified BSD License */ -return [ +return [ 'AUS Central Standard Time' => 'Australia/Darwin', 'AUS Eastern Standard Time' => 'Australia/Sydney', 'Afghanistan Standard Time' => 'Asia/Kabul', diff --git a/tests/VObject/Component/VAvailabilityTest.php b/tests/VObject/Component/VAvailabilityTest.php index 2fd9c0dde..edd06b02b 100644 --- a/tests/VObject/Component/VAvailabilityTest.php +++ b/tests/VObject/Component/VAvailabilityTest.php @@ -122,7 +122,7 @@ public function testIsInTimeRangeOutside() ); } - public function testRFCxxxSection3_1_availabilityprop_required() + public function testRFCxxxSection3Part1AvailabilitypropRequired() { // UID and DTSTAMP are present. $this->assertIsValid(Reader::read( @@ -177,7 +177,7 @@ public function testRFCxxxSection3_1_availabilityprop_required() )); } - public function testRFCxxxSection3_1_availabilityprop_optional_once() + public function testRFCxxxSection3Part1AvailabilitypropOptionalOnce() { $properties = [ 'BUSYTYPE:BUSY', @@ -205,7 +205,7 @@ public function testRFCxxxSection3_1_availabilityprop_optional_once() } } - public function testRFCxxxSection3_1_availabilityprop_dtend_duration() + public function testRFCxxxSection3Part1AvailabilitypropDtendDuration() { // Only DTEND. $this->assertIsValid(Reader::read($this->template([ @@ -239,7 +239,7 @@ public function testAvailableSubComponent() $this->assertInstanceOf(Available::class, $document->VAVAILABILITY->AVAILABLE); } - public function testRFCxxxSection3_1_availableprop_required() + public function testRFCxxxSection3Part1AvailablepropRequired() { // UID, DTSTAMP and DTSTART are present. $this->assertIsValid(Reader::read( @@ -331,7 +331,7 @@ public function testRFCxxxSection3_1_availableprop_required() )); } - public function testRFCxxxSection3_1_available_dtend_duration() + public function testRFCxxxSection3Part1AvailableDtendDuration() { // Only DTEND. $this->assertIsValid(Reader::read($this->templateAvailable([ @@ -350,7 +350,7 @@ public function testRFCxxxSection3_1_available_dtend_duration() ]))); } - public function testRFCxxxSection3_1_available_optional_once() + public function testRFCxxxSection3Part1AvailableOptionalOnce() { $properties = [ 'CREATED:20111005T135125Z', @@ -373,7 +373,7 @@ public function testRFCxxxSection3_1_available_optional_once() } } - public function testRFCxxxSection3_2() + public function testRFCxxxSection3Part2() { $this->assertEquals( 'BUSY', diff --git a/tests/VObject/DateTimeParserTest.php b/tests/VObject/DateTimeParserTest.php index b20a43217..ede81e321 100644 --- a/tests/VObject/DateTimeParserTest.php +++ b/tests/VObject/DateTimeParserTest.php @@ -408,7 +408,7 @@ public function vcardDates() ]; } - public function testDateAndOrTime_DateWithYearMonthDay() + public function testDateAndOrTimeDateWithYearMonthDay() { $this->assertDateAndOrTimeEqualsTo( '20150128', @@ -420,7 +420,7 @@ public function testDateAndOrTime_DateWithYearMonthDay() ); } - public function testDateAndOrTime_DateWithYearMonth() + public function testDateAndOrTimeDateWithYearMonth() { $this->assertDateAndOrTimeEqualsTo( '2015-01', @@ -431,7 +431,7 @@ public function testDateAndOrTime_DateWithYearMonth() ); } - public function testDateAndOrTime_DateWithMonth() + public function testDateAndOrTimeDateWithMonth() { $this->assertDateAndOrTimeEqualsTo( '--01', @@ -441,7 +441,7 @@ public function testDateAndOrTime_DateWithMonth() ); } - public function testDateAndOrTime_DateWithMonthDay() + public function testDateAndOrTimeDateWithMonthDay() { $this->assertDateAndOrTimeEqualsTo( '--0128', @@ -452,7 +452,7 @@ public function testDateAndOrTime_DateWithMonthDay() ); } - public function testDateAndOrTime_DateWithDay() + public function testDateAndOrTimeDateWithDay() { $this->assertDateAndOrTimeEqualsTo( '---28', @@ -462,7 +462,7 @@ public function testDateAndOrTime_DateWithDay() ); } - public function testDateAndOrTime_TimeWithHour() + public function testDateAndOrTimeTimeWithHour() { $this->assertDateAndOrTimeEqualsTo( '13', @@ -472,7 +472,7 @@ public function testDateAndOrTime_TimeWithHour() ); } - public function testDateAndOrTime_TimeWithHourMinute() + public function testDateAndOrTimeTimeWithHourMinute() { $this->assertDateAndOrTimeEqualsTo( '1353', @@ -483,7 +483,7 @@ public function testDateAndOrTime_TimeWithHourMinute() ); } - public function testDateAndOrTime_TimeWithHourSecond() + public function testDateAndOrTimeTimeWithHourSecond() { $this->assertDateAndOrTimeEqualsTo( '135301', @@ -495,7 +495,7 @@ public function testDateAndOrTime_TimeWithHourSecond() ); } - public function testDateAndOrTime_TimeWithMinute() + public function testDateAndOrTimeTimeWithMinute() { $this->assertDateAndOrTimeEqualsTo( '-53', @@ -505,7 +505,7 @@ public function testDateAndOrTime_TimeWithMinute() ); } - public function testDateAndOrTime_TimeWithMinuteSecond() + public function testDateAndOrTimeTimeWithMinuteSecond() { $this->assertDateAndOrTimeEqualsTo( '-5301', @@ -516,7 +516,7 @@ public function testDateAndOrTime_TimeWithMinuteSecond() ); } - public function testDateAndOrTime_TimeWithSecond() + public function testDateAndOrTimeTimeWithSecond() { $this->assertTrue(true); @@ -526,7 +526,7 @@ public function testDateAndOrTime_TimeWithSecond() */ } - public function testDateAndOrTime_TimeWithSecondZ() + public function testDateAndOrTimeTimeWithSecondZ() { $this->assertDateAndOrTimeEqualsTo( '--01Z', @@ -537,7 +537,7 @@ public function testDateAndOrTime_TimeWithSecondZ() ); } - public function testDateAndOrTime_TimeWithSecondTZ() + public function testDateAndOrTimeTimeWithSecondTZ() { $this->assertDateAndOrTimeEqualsTo( '--01+1234', @@ -548,7 +548,7 @@ public function testDateAndOrTime_TimeWithSecondTZ() ); } - public function testDateAndOrTime_DateTimeWithYearMonthDayHour() + public function testDateAndOrTimeDateTimeWithYearMonthDayHour() { $this->assertDateAndOrTimeEqualsTo( '20150128T13', @@ -561,7 +561,7 @@ public function testDateAndOrTime_DateTimeWithYearMonthDayHour() ); } - public function testDateAndOrTime_DateTimeWithMonthDayHour() + public function testDateAndOrTimeDateTimeWithMonthDayHour() { $this->assertDateAndOrTimeEqualsTo( '--0128T13', @@ -573,7 +573,7 @@ public function testDateAndOrTime_DateTimeWithMonthDayHour() ); } - public function testDateAndOrTime_DateTimeWithDayHour() + public function testDateAndOrTimeDateTimeWithDayHour() { $this->assertDateAndOrTimeEqualsTo( '---28T13', @@ -584,7 +584,7 @@ public function testDateAndOrTime_DateTimeWithDayHour() ); } - public function testDateAndOrTime_DateTimeWithDayHourMinute() + public function testDateAndOrTimeDateTimeWithDayHourMinute() { $this->assertDateAndOrTimeEqualsTo( '---28T1353', @@ -596,7 +596,7 @@ public function testDateAndOrTime_DateTimeWithDayHourMinute() ); } - public function testDateAndOrTime_DateTimeWithDayHourMinuteSecond() + public function testDateAndOrTimeDateTimeWithDayHourMinuteSecond() { $this->assertDateAndOrTimeEqualsTo( '---28T135301', @@ -609,7 +609,7 @@ public function testDateAndOrTime_DateTimeWithDayHourMinuteSecond() ); } - public function testDateAndOrTime_DateTimeWithDayHourZ() + public function testDateAndOrTimeDateTimeWithDayHourZ() { $this->assertDateAndOrTimeEqualsTo( '---28T13Z', @@ -621,7 +621,7 @@ public function testDateAndOrTime_DateTimeWithDayHourZ() ); } - public function testDateAndOrTime_DateTimeWithDayHourTZ() + public function testDateAndOrTimeDateTimeWithDayHourTZ() { $this->assertDateAndOrTimeEqualsTo( '---28T13+1234', diff --git a/tests/VObject/Parser/XmlTest.php b/tests/VObject/Parser/XmlTest.php index e520185ba..46ee30ce2 100644 --- a/tests/VObject/Parser/XmlTest.php +++ b/tests/VObject/Parser/XmlTest.php @@ -262,7 +262,7 @@ public function testRFC6321Example2() /** * iCalendar Stream. */ - public function testRFC6321Section3_2() + public function testRFC6321Section3Part2() { $this->assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( @@ -466,7 +466,7 @@ public function testRFC6321Section3_4_1_3() /** * Values, Binary. */ - public function testRFC6321Section3_6_1() + public function testRFC6321Section3Part6Part1() { $this->assertXMLEqualsToMimeDir( <<assertXMLEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( << with a positive and a non-negative numbers. - $this->testRFC6321Section3_4_1_2(); + $this->testRFC6321Section3Part4Part1Part2(); } /** * Values, Integer. */ - public function testRFC6321Section3_6_8() + public function testRFC6321Section3Part6Part8() { $this->assertXMLEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( @@ -1259,7 +1259,7 @@ public function testRFC6351Section5Group() /** * Extensibility. */ - public function testRFC6351Section5_1_NoNamespace() + public function testRFC6351Section5Part1NoNamespace() { $this->assertXMLEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( <<assertXMLReflexivelyEqualsToMimeDir( << Date: Sun, 13 Dec 2020 17:43:53 +0545 Subject: [PATCH 51/83] Update windowszones timezone data to 2020-12-13 --- bin/fetch_windows_zones.php | 5 ++--- lib/timezonedata/windowszones.php | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/fetch_windows_zones.php b/bin/fetch_windows_zones.php index 9c4e51abd..2361dc309 100755 --- a/bin/fetch_windows_zones.php +++ b/bin/fetch_windows_zones.php @@ -1,13 +1,12 @@ #!/usr/bin/env php 'Pacific/Kiritimati', 'Lord Howe Standard Time' => 'Australia/Lord_Howe', 'Magadan Standard Time' => 'Asia/Magadan', + 'Magallanes Standard Time' => 'America/Punta_Arenas', 'Marquesas Standard Time' => 'Pacific/Marquesas', 'Mauritius Standard Time' => 'Indian/Mauritius', 'Middle East Standard Time' => 'Asia/Beirut', @@ -91,11 +92,13 @@ 'North Asia East Standard Time' => 'Asia/Irkutsk', 'North Asia Standard Time' => 'Asia/Krasnoyarsk', 'North Korea Standard Time' => 'Asia/Pyongyang', + 'Omsk Standard Time' => 'Asia/Omsk', 'Pacific SA Standard Time' => 'America/Santiago', 'Pacific Standard Time' => 'America/Los_Angeles', 'Pacific Standard Time (Mexico)' => 'America/Tijuana', 'Pakistan Standard Time' => 'Asia/Karachi', 'Paraguay Standard Time' => 'America/Asuncion', + 'Qyzylorda Standard Time' => 'Asia/Qyzylorda', 'Romance Standard Time' => 'Europe/Paris', 'Russia Time Zone 10' => 'Asia/Srednekolymsk', 'Russia Time Zone 11' => 'Asia/Kamchatka', @@ -108,9 +111,12 @@ 'Saint Pierre Standard Time' => 'America/Miquelon', 'Sakhalin Standard Time' => 'Asia/Sakhalin', 'Samoa Standard Time' => 'Pacific/Apia', + 'Sao Tome Standard Time' => 'Africa/Sao_Tome', + 'Saratov Standard Time' => 'Europe/Saratov', 'Singapore Standard Time' => 'Asia/Singapore', 'South Africa Standard Time' => 'Africa/Johannesburg', 'Sri Lanka Standard Time' => 'Asia/Colombo', + 'Sudan Standard Time' => 'Africa/Khartoum', 'Syria Standard Time' => 'Asia/Damascus', 'Taipei Standard Time' => 'Asia/Taipei', 'Tasmania Standard Time' => 'Australia/Hobart', @@ -125,6 +131,7 @@ 'US Mountain Standard Time' => 'America/Phoenix', 'UTC' => 'Etc/GMT', 'UTC+12' => 'Etc/GMT-12', + 'UTC+13' => 'Etc/GMT-13', 'UTC-02' => 'Etc/GMT+2', 'UTC-08' => 'Etc/GMT+8', 'UTC-09' => 'Etc/GMT+9', @@ -132,6 +139,7 @@ 'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar', 'Venezuela Standard Time' => 'America/Caracas', 'Vladivostok Standard Time' => 'Asia/Vladivostok', + 'Volgograd Standard Time' => 'Europe/Volgograd', 'W. Australia Standard Time' => 'Australia/Perth', 'W. Central Africa Standard Time' => 'Africa/Lagos', 'W. Europe Standard Time' => 'Europe/Berlin', @@ -140,4 +148,5 @@ 'West Bank Standard Time' => 'Asia/Hebron', 'West Pacific Standard Time' => 'Pacific/Port_Moresby', 'Yakutsk Standard Time' => 'Asia/Yakutsk', + 'Yukon Standard Time' => 'America/Whitehorse', ]; From 96d330d0c61c6221120271ee8d008b4292ef7105 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 13 Dec 2020 18:11:33 +0545 Subject: [PATCH 52/83] Fix typos --- CHANGELOG.md | 10 +++++----- lib/Cli.php | 2 +- lib/Component/VCalendar.php | 2 +- lib/Component/VCard.php | 2 +- lib/FreeBusyData.php | 8 ++++---- lib/FreeBusyGenerator.php | 2 +- lib/Parameter.php | 2 +- lib/Property/ICalendar/DateTime.php | 2 +- lib/Recur/EventIterator.php | 2 +- tests/VObject/Component/VCardTest.php | 4 ++-- tests/VObject/EmptyValueIssueTest.php | 4 ++-- tests/VObject/ITip/BrokerAttendeeReplyTest.php | 2 +- tests/VObject/ITip/BrokerProcessReplyTest.php | 2 +- tests/VObject/ReaderTest.php | 2 +- tests/VObject/Recur/EventIterator/MainTest.php | 12 ++++++------ tests/VObject/Recur/RRuleIteratorTest.php | 4 ++-- tests/VObject/TimeZoneUtilTest.php | 4 ++-- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6b096fd..28697b5b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ ChangeLog ------------------ * #469, #451: fix compat with php 7.4 -* #443: prevent running in indefinte loop +* #443: prevent running in indefinite loop * #449: Preventing creating a component for a root document * #450: Fix parse with option Forgiving with trailing equal * #459: fixed typo in VCalendar which resulting in usage of the wrong TimeZone @@ -125,7 +125,7 @@ ChangeLog * #306: iTip REPLYs to the first instance of a recurring event was not handled correctly. * Slightly better error message during validation of `N` and `ADR` properties. -* #312: Correctly extracing timezone in the iTip broker, even when we don't +* #312: Correctly extracting timezone in the iTip broker, even when we don't have a master event. (@vkomrakov-sugar). * When validating a component's property that must appear once and which could automatically be repaired, make sure we report the change as 'repaired'. @@ -447,7 +447,7 @@ ChangeLog * #114: VTIMEZONE is retained when generating new REQUEST objects. * #114: Support for 'MAILTO:' style email addresses (in uppercase) in the iTip broker. This improves evolution support. -* #115: Using REQUEST-STATUS from REPLY messages and now propegating that into +* #115: Using REQUEST-STATUS from REPLY messages and now propagating that into SCHEDULE-STATUS. @@ -684,7 +684,7 @@ ChangeLog 3.0.0-alpha2 (2013-05-22) ------------------------- -* Fixed: vCard URL properties were referencing a non-existant class. +* Fixed: vCard URL properties were referencing a non-existent class. 3.0.0-alpha1 (2013-05-21) @@ -842,7 +842,7 @@ ChangeLog properties such as N, ADR, ORG and CATEGORIES. * Added: Splitter classes, that can split up large objects (such as exports) into individual objects (thanks @DominikTo and @armin-hackmann). -* Added: VFREEBUSY component, which allows easily checking wether timeslots are +* Added: VFREEBUSY component, which allows easily checking whether timeslots are available. * Added: The Reader class now has a 'FORGIVING' option, which allows it to parse properties with incorrect characters in the name (at this time, it just allows diff --git a/lib/Cli.php b/lib/Cli.php index 54b938764..4984ac9b2 100644 --- a/lib/Cli.php +++ b/lib/Cli.php @@ -206,7 +206,7 @@ public function main(array $argv) } if (!in_array($positional[0], ['validate', 'repair', 'convert', 'color'])) { - throw new InvalidArgumentException('Uknown command: '.$positional[0]); + throw new InvalidArgumentException('Unknown command: '.$positional[0]); } } catch (InvalidArgumentException $e) { $this->showHelp(); diff --git a/lib/Component/VCalendar.php b/lib/Component/VCalendar.php index 40e09a1c0..4db318135 100644 --- a/lib/Component/VCalendar.php +++ b/lib/Component/VCalendar.php @@ -309,7 +309,7 @@ public function expand(DateTimeInterface $start, DateTimeInterface $end, DateTim foreach ($this->children() as $child) { if ($child instanceof Property && 'PRODID' !== $child->name) { - // We explictly want to ignore PRODID, because we want to + // We explicitly want to ignore PRODID, because we want to // overwrite it with our own. $newChildren[] = clone $child; } elseif ($child instanceof Component && 'VTIMEZONE' !== $child->name) { diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php index 51321949f..2430df621 100644 --- a/lib/Component/VCard.php +++ b/lib/Component/VCard.php @@ -373,7 +373,7 @@ public function getValidationRules() /** * Returns a preferred field. * - * VCards can indicate wether a field such as ADR, TEL or EMAIL is + * VCards can indicate whether a field such as ADR, TEL or EMAIL is * preferred by specifying TYPE=PREF (vcard 2.1, 3) or PREF=x (vcard 4, x * being a number between 1 and 100). * diff --git a/lib/FreeBusyData.php b/lib/FreeBusyData.php index d05dfc799..4d9f441ce 100644 --- a/lib/FreeBusyData.php +++ b/lib/FreeBusyData.php @@ -84,7 +84,7 @@ public function add($start, $end, $type) 'type' => $type, ]; - $preceedingItem = $this->data[$insertStartIndex - 1]; + $precedingItem = $this->data[$insertStartIndex - 1]; if ($this->data[$insertStartIndex - 1]['start'] === $start) { // The old item starts at the exact same point as the new item. --$insertStartIndex; @@ -122,11 +122,11 @@ public function add($start, $end, $type) // between. if (-1 === $itemsToDelete) { $itemsToDelete = 0; - if ($newItem['end'] < $preceedingItem['end']) { + if ($newItem['end'] < $precedingItem['end']) { $newItems[] = [ 'start' => $newItem['end'] + 1, - 'end' => $preceedingItem['end'], - 'type' => $preceedingItem['type'], + 'end' => $precedingItem['end'], + 'type' => $precedingItem['type'], ]; } } diff --git a/lib/FreeBusyGenerator.php b/lib/FreeBusyGenerator.php index 63f05a151..81b8126d5 100644 --- a/lib/FreeBusyGenerator.php +++ b/lib/FreeBusyGenerator.php @@ -126,7 +126,7 @@ public function setVAvailability(Document $vcalendar) /** * Sets the input objects. * - * You must either specify a valendar object as a string, or as the parse + * You must either specify a vcalendar object as a string, or as the parse * Component. * It's also possible to specify multiple objects as an array. * diff --git a/lib/Parameter.php b/lib/Parameter.php index de0c5bfdc..72f2ecbcb 100644 --- a/lib/Parameter.php +++ b/lib/Parameter.php @@ -293,7 +293,7 @@ function ($out, $item) { // https://tools.ietf.org/html/rfc6868 // // But we've found that iCal (7.0, shipped with OSX 10.9) - // severaly trips on + characters not being quoted, so we + // severely trips on + characters not being quoted, so we // added + as well. if (!preg_match('#(?: [\n":;\^,\+] )#x', $item)) { return $out.$item; diff --git a/lib/Property/ICalendar/DateTime.php b/lib/Property/ICalendar/DateTime.php index f2dbdeba3..d635e17ae 100644 --- a/lib/Property/ICalendar/DateTime.php +++ b/lib/Property/ICalendar/DateTime.php @@ -184,7 +184,7 @@ public function setDateTime(DateTimeInterface $dt, $isFloating = false) * Sets the property as multiple date-time objects. * * The first value will be used as a reference for the timezones, and all - * the otehr values will be adjusted for that timezone + * the other values will be adjusted for that timezone * * @param DateTimeInterface[] $dt * @param bool isFloating If set to true, timezones will be ignored diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php index fd904b383..e42ca1360 100644 --- a/lib/Recur/EventIterator.php +++ b/lib/Recur/EventIterator.php @@ -83,7 +83,7 @@ class EventIterator implements \Iterator * 2. You can pass an array of VEVENTs (all UIDS should match). * 3. You can pass a single VEVENT component. * - * Only the second method is recomended. The other 1 and 3 will be removed + * Only the second method is recommended. The other 1 and 3 will be removed * at some point in the future. * * The $uid parameter is only required for the first method. diff --git a/tests/VObject/Component/VCardTest.php b/tests/VObject/Component/VCardTest.php index 3124fec84..d8e6110b6 100644 --- a/tests/VObject/Component/VCardTest.php +++ b/tests/VObject/Component/VCardTest.php @@ -135,8 +135,8 @@ public function testGetByType() $vcard = VObject\Reader::read($vcard); $this->assertEquals('1@example.org', $vcard->getByType('EMAIL', 'home')->getValue()); $this->assertEquals('2@example.org', $vcard->getByType('EMAIL', 'work')->getValue()); - $this->assertNull($vcard->getByType('EMAIL', 'non-existant')); - $this->assertNull($vcard->getByType('ADR', 'non-existant')); + $this->assertNull($vcard->getByType('EMAIL', 'non-existent')); + $this->assertNull($vcard->getByType('ADR', 'non-existent')); } public function testPreferredNoPref() diff --git a/tests/VObject/EmptyValueIssueTest.php b/tests/VObject/EmptyValueIssueTest.php index 91a4d84f6..0798d9c4a 100644 --- a/tests/VObject/EmptyValueIssueTest.php +++ b/tests/VObject/EmptyValueIssueTest.php @@ -17,7 +17,7 @@ public function testDecodeValue() BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT -DESCRIPTION:This is a descpription\\nwith a linebreak and a \\; \\, and : +DESCRIPTION:This is a description\\nwith a linebreak and a \\; \\, and : END:VEVENT END:VCALENDAR ICS; @@ -25,6 +25,6 @@ public function testDecodeValue() $vobj = Reader::read($input); // Before this bug was fixed, getValue() would return nothing. - $this->assertEquals("This is a descpription\nwith a linebreak and a ; , and :", $vobj->VEVENT->DESCRIPTION->getValue()); + $this->assertEquals("This is a description\nwith a linebreak and a ; , and :", $vobj->VEVENT->DESCRIPTION->getValue()); } } diff --git a/tests/VObject/ITip/BrokerAttendeeReplyTest.php b/tests/VObject/ITip/BrokerAttendeeReplyTest.php index 71008c6ae..284075adf 100644 --- a/tests/VObject/ITip/BrokerAttendeeReplyTest.php +++ b/tests/VObject/ITip/BrokerAttendeeReplyTest.php @@ -907,7 +907,7 @@ public function testDeclinedCancelledEvent() * Except in this case, there was already an overridden event, and the * overridden event was marked as cancelled by the attendee. * - * For any other attendence status, the new status would have been + * For any other attendance status, the new status would have been * declined, but for this, no message should we sent. */ public function testDontCreateReplyWhenEventWasDeclined() diff --git a/tests/VObject/ITip/BrokerProcessReplyTest.php b/tests/VObject/ITip/BrokerProcessReplyTest.php index 1cb685096..bbfd6c419 100644 --- a/tests/VObject/ITip/BrokerProcessReplyTest.php +++ b/tests/VObject/ITip/BrokerProcessReplyTest.php @@ -373,7 +373,7 @@ public function testReplyNewExceptionTz() $result = $this->process($itip, $old, $expected); } - public function testReplyPartyCrashCreateExcepton() + public function testReplyPartyCrashCreateException() { // IN this test there's a recurring event that has an exception. The // exception is missing the attendee. diff --git a/tests/VObject/ReaderTest.php b/tests/VObject/ReaderTest.php index 0992806be..6f2cbb77d 100644 --- a/tests/VObject/ReaderTest.php +++ b/tests/VObject/ReaderTest.php @@ -336,7 +336,7 @@ public function testReadWithInvalidLine() $data = [ 'BEGIN:VCALENDAR', 'DESCRIPTION:propValue', - "Yes, we've actually seen a file with non-idented property values on multiple lines", + "Yes, we've actually seen a file with non-indented property values on multiple lines", 'END:VCALENDAR', ]; diff --git a/tests/VObject/Recur/EventIterator/MainTest.php b/tests/VObject/Recur/EventIterator/MainTest.php index 1a019a57d..cf317f3ea 100644 --- a/tests/VObject/Recur/EventIterator/MainTest.php +++ b/tests/VObject/Recur/EventIterator/MainTest.php @@ -1172,7 +1172,7 @@ public function testComplexExclusions() /** * @depends testValues */ - public function testOverridenEvent() + public function testOverriddenEvent() { $vcal = new VCalendar(); @@ -1243,7 +1243,7 @@ public function testOverridenEvent() /** * @depends testValues */ - public function testOverridenEvent2() + public function testOverriddenEvent2() { $vcal = new VCalendar(); @@ -1291,7 +1291,7 @@ public function testOverridenEvent2() /** * @depends testValues */ - public function testOverridenEventNoValuesExpected() + public function testOverriddenEventNoValuesExpected() { $vcal = new VCalendar(); $ev1 = $vcal->createComponent('VEVENT'); @@ -1318,12 +1318,12 @@ public function testOverridenEventNoValuesExpected() $summaries = []; // The reported problem was specifically related to the VCALENDAR - // expansion. In this parcitular case, we had to forward to the 28th of + // expansion. In this particular case, we had to forward to the 28th of // january. $it->fastForward(new DateTimeImmutable('2012-01-28 23:00:00')); - // We stop the loop when it hits the 6th of februari. Normally this - // iterator would hit 24, 25 (overriden from 31) and 7 feb but because + // We stop the loop when it hits the 6th of February. Normally this + // iterator would hit 24, 25 (overridden from 31) and 7 feb but because // we 'filter' from the 28th till the 6th, we should get 0 results. while ($it->valid() && $it->getDTStart() < new DateTimeImmutable('2012-02-06 23:00:00')) { $dates[] = $it->getDTStart(); diff --git a/tests/VObject/Recur/RRuleIteratorTest.php b/tests/VObject/Recur/RRuleIteratorTest.php index 0b3e6b8de..8a38ad616 100644 --- a/tests/VObject/Recur/RRuleIteratorTest.php +++ b/tests/VObject/Recur/RRuleIteratorTest.php @@ -265,7 +265,7 @@ public function testMonthly() ); } - public function testMonlthyEndOfMonth() + public function testMonthlyEndOfMonth() { $this->parse( 'FREQ=MONTHLY;INTERVAL=2;COUNT=12', @@ -628,7 +628,7 @@ public function testFifthTuesdayProblem() * This bug came from a Fruux customer. This would result in a never-ending * request. */ - public function testFastFowardTooFar() + public function testFastForwardTooFar() { $this->parse( 'FREQ=WEEKLY;BYDAY=MO;UNTIL=20090704T205959Z;INTERVAL=1', diff --git a/tests/VObject/TimeZoneUtilTest.php b/tests/VObject/TimeZoneUtilTest.php index 619abc19a..580ac9fef 100644 --- a/tests/VObject/TimeZoneUtilTest.php +++ b/tests/VObject/TimeZoneUtilTest.php @@ -8,7 +8,7 @@ class TimeZoneUtilTest extends TestCase { public function setUp(): void { - // clearning the tz cache + // clearing the tz cache TimeZoneUtil::$map = null; } @@ -82,7 +82,7 @@ public function testExchangeMap() $this->assertEquals($ex->getName(), $tz->getName()); } - public function testWetherMicrosoftIsStillInsane() + public function testWhetherMicrosoftIsStillInsane() { $vobj = << Date: Tue, 2 Feb 2021 19:02:41 +0100 Subject: [PATCH 53/83] Reassign modified date in yearly rrule --- lib/Recur/RRuleIterator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 1d774152a..981260606 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -536,7 +536,7 @@ protected function nextYearly() foreach ($this->byWeekNo as $byWeekNo) { foreach ($dayOffsets as $dayOffset) { $date = clone $this->currentDate; - $date->setISODate($currentYear, $byWeekNo, $dayOffset); + $date = $date->setISODate($currentYear, $byWeekNo, $dayOffset); if ($date > $this->currentDate) { $checkDates[] = $date; From ea97e1384d1e4ad0de0ff3320eb157cf0698e982 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Wed, 3 Feb 2021 08:55:25 +0100 Subject: [PATCH 54/83] Add test --- tests/VObject/Recur/RRuleIteratorTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/VObject/Recur/RRuleIteratorTest.php b/tests/VObject/Recur/RRuleIteratorTest.php index 8a38ad616..067991f73 100644 --- a/tests/VObject/Recur/RRuleIteratorTest.php +++ b/tests/VObject/Recur/RRuleIteratorTest.php @@ -591,6 +591,19 @@ public function testYearlyByYearDayInvalid0() ); } + public function testYearlyByDayByWeekNo() + { + $this->parse( + 'FREQ=YEARLY;COUNT=3;BYDAY=MO;BYWEEKNO=13,15,50', + '2021-01-01 00:00:00', + [ + '2021-01-01 00:00:00', + '2021-03-29 00:00:00', + '2021-04-12 00:00:00', + ] + ); + } + public function testFastForward() { // The idea is that we're fast-forwarding too far in the future, so From 67c6ee371abba8cd4222958200e7cb9057b07582 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Wed, 3 Feb 2021 08:59:18 +0100 Subject: [PATCH 55/83] Code style --- tests/VObject/Recur/RRuleIteratorTest.php | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/VObject/Recur/RRuleIteratorTest.php b/tests/VObject/Recur/RRuleIteratorTest.php index 067991f73..ddee980b5 100644 --- a/tests/VObject/Recur/RRuleIteratorTest.php +++ b/tests/VObject/Recur/RRuleIteratorTest.php @@ -591,18 +591,18 @@ public function testYearlyByYearDayInvalid0() ); } - public function testYearlyByDayByWeekNo() - { - $this->parse( - 'FREQ=YEARLY;COUNT=3;BYDAY=MO;BYWEEKNO=13,15,50', - '2021-01-01 00:00:00', - [ - '2021-01-01 00:00:00', - '2021-03-29 00:00:00', - '2021-04-12 00:00:00', - ] - ); - } + public function testYearlyByDayByWeekNo() + { + $this->parse( + 'FREQ=YEARLY;COUNT=3;BYDAY=MO;BYWEEKNO=13,15,50', + '2021-01-01 00:00:00', + [ + '2021-01-01 00:00:00', + '2021-03-29 00:00:00', + '2021-04-12 00:00:00', + ] + ); + } public function testFastForward() { From 7e48c3269ac938bdaaad9288a9174da2d6c3a270 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Wed, 3 Feb 2021 14:28:17 +0100 Subject: [PATCH 56/83] Add test for calendar expand --- tests/VObject/Component/VCalendarTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/VObject/Component/VCalendarTest.php b/tests/VObject/Component/VCalendarTest.php index c2f0ce978..ccc8a8eeb 100644 --- a/tests/VObject/Component/VCalendarTest.php +++ b/tests/VObject/Component/VCalendarTest.php @@ -350,6 +350,26 @@ public function testBrokenEventExpand() ); } + public function testEventExpandYearly() + { + $input = 'BEGIN:VCALENDAR +BEGIN:VEVENT +UID:1a093f1012086078fdd3d9df5ff4d7d0 +DTSTART;TZID=UTC:20210203T130000 +DTEND;TZID=UTC:20210203T140000 +RRULE:FREQ=YEARLY;COUNT=7;WKST=MO;BYDAY=MO;BYWEEKNO=13,15,50 +END:VEVENT +END:VCALENDAR +'; + $vcal = VObject\Reader::read($input); + $events = $vcal->expand( + new \DateTime('2021-01-01'), + new \DateTime('2023-01-01') + ); + + $this->assertCount(7, $events->VEVENT); + } + public function testGetDocumentType() { $vcard = new VCalendar(); From b571095958614b6bfbee9bd17a7b337204c031d0 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 3 Feb 2021 21:51:08 +0545 Subject: [PATCH 57/83] adjust unit test settings for time limits Some tests were testing a bug that caused an infinite loop. Annotate those tests with large, small annotations. Turn on enforceTimeLimit, failOnWarning and failOnRisky so that the annotations are enforced when unit tests are run. Add phpunit/php-invoker to the composer require-dev becaause this is required to make the enforceTimeLimit setting effective. --- composer.json | 1 + tests/VObject/Component/VCalendarTest.php | 7 +++++++ tests/VObject/Recur/RRuleIteratorTest.php | 7 +++++++ tests/phpunit.xml | 3 +++ 4 files changed, 18 insertions(+) diff --git a/composer.json b/composer.json index 4de13d926..b745b1fa6 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,7 @@ "require-dev" : { "friendsofphp/php-cs-fixer": "~2.17.1", "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0", + "phpunit/php-invoker" : "^2.0 || ^3.1", "phpstan/phpstan": "^0.12" }, "suggest" : { diff --git a/tests/VObject/Component/VCalendarTest.php b/tests/VObject/Component/VCalendarTest.php index ccc8a8eeb..d34e12d2b 100644 --- a/tests/VObject/Component/VCalendarTest.php +++ b/tests/VObject/Component/VCalendarTest.php @@ -350,6 +350,13 @@ public function testBrokenEventExpand() ); } + /** + * This test used to induce an infinite loop. + * The "medium" annotation means that phpunit will fail the + * test if it takes longer than a default of 10 seconds. + * + * @medium + */ public function testEventExpandYearly() { $input = 'BEGIN:VCALENDAR diff --git a/tests/VObject/Recur/RRuleIteratorTest.php b/tests/VObject/Recur/RRuleIteratorTest.php index ddee980b5..f778afb4b 100644 --- a/tests/VObject/Recur/RRuleIteratorTest.php +++ b/tests/VObject/Recur/RRuleIteratorTest.php @@ -892,6 +892,13 @@ public function testMinusFifthThursday() ); } + /** + * This test can take some seconds to complete. + * The "large" annotation means phpunit will let it run for + * up to 60 seconds by default. + * + * @large + */ public function testNeverEnding() { $this->parse( diff --git a/tests/phpunit.xml b/tests/phpunit.xml index c0588d460..d40187d2a 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -6,6 +6,9 @@ convertWarningsToExceptions="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" + failOnRisky="true" + failOnWarning="true" + enforceTimeLimit="true" > From 3ee2401e107e46bb305d6e26604413dfb2872151 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 4 Feb 2021 14:30:56 +0545 Subject: [PATCH 58/83] Release 4.3.4 --- CHANGELOG.md | 6 ++++++ lib/Version.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28697b5b2..607d07a2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ChangeLog ========= +4.3.4 (2021-02-04) +------------------ + +* #529: Reassign modified date in yearly rrule (@laoneo) +* #525: Add .gitattributes to reduce package size (@fezfez) + 4.3.3 (2020-11-09) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 29ba84f88..83c82a573 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.3'; + const VERSION = '4.3.4'; } From e8b5ea4b1492ff304cbef497c93e1b3ea0b7ee27 Mon Sep 17 00:00:00 2001 From: Jair Cueva Junior Date: Wed, 10 Feb 2021 16:12:39 -0300 Subject: [PATCH 59/83] Make use of until parameter in nextMonthly function --- lib/Recur/RRuleIterator.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 981260606..2ba2d8369 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -466,7 +466,15 @@ protected function nextMonthly() // This goes to 0 because we need to start counting at the // beginning. - $currentDayOfMonth = 0; + $currentDayOfMonth = 0; + + // For some reason the "until" parameter was not being taken into + // account, that's why the workaround of the 10000 year bug was + // needed at all. + // Let's stop it before the "until" parameter date arrives. + if ($this->currentDate->getTimestamp() >= $this->until->getTimestamp()){ + return; + } // To prevent running this forever (better: until we hit the max date of DateTimeImmutable) we simply // stop at 9999-12-31. Looks like the year 10000 problem is not solved in php .... @@ -475,7 +483,7 @@ protected function nextMonthly() return; } - } + } $this->currentDate = $this->currentDate->setDate( (int) $this->currentDate->format('Y'), From 6c263cea300918245e12d6a2a420b893a0492c42 Mon Sep 17 00:00:00 2001 From: Jair Cueva Junior Date: Wed, 10 Feb 2021 16:27:06 -0300 Subject: [PATCH 60/83] CS FIX --- lib/Recur/RRuleIterator.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 2ba2d8369..abc0e0a80 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -466,13 +466,12 @@ protected function nextMonthly() // This goes to 0 because we need to start counting at the // beginning. - $currentDayOfMonth = 0; + $currentDayOfMonth = 0; - // For some reason the "until" parameter was not being taken into - // account, that's why the workaround of the 10000 year bug was - // needed at all. - // Let's stop it before the "until" parameter date arrives. - if ($this->currentDate->getTimestamp() >= $this->until->getTimestamp()){ + // For some reason the "until" parameter was not being used here, + // that's why the workaround of the 10000 year bug was needed at all + // let's stop it before the "until" parameter date + if ($this->currentDate->getTimestamp() >= $this->until->getTimestamp()) { return; } @@ -483,7 +482,7 @@ protected function nextMonthly() return; } - } + } $this->currentDate = $this->currentDate->setDate( (int) $this->currentDate->format('Y'), @@ -884,7 +883,7 @@ protected function getMonthlyOccurrences() foreach ($this->byMonthDay as $monthDay) { // Removing values that are out of range for this month if ($monthDay > $startDate->format('t') || - $monthDay < 0 - $startDate->format('t')) { + $monthDay < 0 - $startDate->format('t')) { continue; } if ($monthDay > 0) { @@ -978,3 +977,4 @@ protected function getMonths() return $recurrenceMonths; } } + From 1f2e2e5495172149939ca2ce054c71673c07cbae Mon Sep 17 00:00:00 2001 From: Jair Cueva Junior Date: Wed, 10 Feb 2021 16:35:10 -0300 Subject: [PATCH 61/83] CS FIX --- lib/Recur/RRuleIterator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index abc0e0a80..9c2aecabe 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -977,4 +977,3 @@ protected function getMonths() return $recurrenceMonths; } } - From 6d3f4ee783ac51f76019f622841e75d808639c01 Mon Sep 17 00:00:00 2001 From: Jair Cueva Junior Date: Wed, 10 Feb 2021 17:18:10 -0300 Subject: [PATCH 62/83] Fix breaking tests --- lib/Recur/RRuleIterator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php index 9c2aecabe..0511f0ade 100644 --- a/lib/Recur/RRuleIterator.php +++ b/lib/Recur/RRuleIterator.php @@ -471,7 +471,7 @@ protected function nextMonthly() // For some reason the "until" parameter was not being used here, // that's why the workaround of the 10000 year bug was needed at all // let's stop it before the "until" parameter date - if ($this->currentDate->getTimestamp() >= $this->until->getTimestamp()) { + if ($this->until && $this->currentDate->getTimestamp() >= $this->until->getTimestamp()) { return; } From 1bed299d6ac62ac64175eefd8a5ff6b2a64098e9 Mon Sep 17 00:00:00 2001 From: Jair Cueva Junior Date: Thu, 11 Feb 2021 11:43:59 -0300 Subject: [PATCH 63/83] create testMonthlyByDayUntil --- tests/VObject/Recur/RRuleIteratorTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/VObject/Recur/RRuleIteratorTest.php b/tests/VObject/Recur/RRuleIteratorTest.php index f778afb4b..caf921833 100644 --- a/tests/VObject/Recur/RRuleIteratorTest.php +++ b/tests/VObject/Recur/RRuleIteratorTest.php @@ -332,6 +332,22 @@ public function testMonthlyByDay() ); } + public function testMonthlyByDayUntil() + { + $this->parse( + 'FREQ=MONTHLY;INTERVAL=1;BYDAY=WE;WKST=WE;UNTIL=20210317T000000Z', + '2021-02-10 00:00:00', + [ + '2021-02-10 00:00:00', + '2021-02-17 00:00:00', + '2021-02-24 00:00:00', + '2021-03-03 00:00:00', + '2021-03-10 00:00:00', + '2021-03-17 00:00:00', + ] + ); + } + public function testMonthlyByDayByMonthDay() { $this->parse( From 1bbae6556e9c10fc4bc916d5081f8cc1caba5a84 Mon Sep 17 00:00:00 2001 From: Jair Cueva Junior Date: Thu, 11 Feb 2021 11:49:17 -0300 Subject: [PATCH 64/83] create testMonthlyByDayUntilWithImpossibleNextOccurrence --- tests/VObject/Recur/RRuleIteratorTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/VObject/Recur/RRuleIteratorTest.php b/tests/VObject/Recur/RRuleIteratorTest.php index caf921833..cc40a6f6f 100644 --- a/tests/VObject/Recur/RRuleIteratorTest.php +++ b/tests/VObject/Recur/RRuleIteratorTest.php @@ -348,6 +348,17 @@ public function testMonthlyByDayUntil() ); } + public function testMonthlyByDayUntilWithImpossibleNextOccurrence() + { + $this->parse( + 'FREQ=MONTHLY;INTERVAL=1;BYDAY=2WE;BYMONTHDAY=2;WKST=WE;UNTIL=20210317T000000Z', + '2021-02-10 00:00:00', + [ + '2021-02-10 00:00:00', + ] + ); + } + public function testMonthlyByDayByMonthDay() { $this->parse( From 9708bd9a6ff12f1006fc8e1ce3a00b99cf6160fa Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Sat, 14 Nov 2020 10:00:28 +0100 Subject: [PATCH 65/83] Fix setting properties with group assignment --- lib/Component.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Component.php b/lib/Component.php index da45eb29f..07f6a627f 100644 --- a/lib/Component.php +++ b/lib/Component.php @@ -160,9 +160,9 @@ public function remove($item) return; } } - } - throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component'); + throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component'); + } } /** From 930b748faae459de0ce2fb05c2d54438d23cf981 Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Tue, 17 Nov 2020 13:23:14 +0100 Subject: [PATCH 66/83] Unit test for adding properties with group for a VCard --- tests/VObject/ComponentTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/VObject/ComponentTest.php b/tests/VObject/ComponentTest.php index f56d55531..ae7420dad 100644 --- a/tests/VObject/ComponentTest.php +++ b/tests/VObject/ComponentTest.php @@ -72,6 +72,23 @@ public function testMagicGetGroups() $this->assertEquals(null, $email3[0]->group); } + public function testAddGroupProperties() + { + $comp = new VCard([ + 'VERSION' => '3.0', + 'item2.X-ABLabel' => "item2-Foo", + ]); + + $comp->{'ITEM1.X-ABLabel'} = "ITEM1-Foo"; + + foreach (['item2', 'ITEM1'] as $group) { + $prop = $comp->{"$group.X-ABLabel"}; + $this->assertInstanceOf(Property::class, $prop); + $this->assertSame("$group-Foo", (string) $prop); + $this->assertSame($group, $prop->group); + } + } + public function testMagicIsset() { $comp = new VCalendar(); From 31c9187e466e67b413e3fbe03b55a9134d88ca79 Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Tue, 17 Nov 2020 13:26:02 +0100 Subject: [PATCH 67/83] Adapt style --- tests/VObject/ComponentTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/VObject/ComponentTest.php b/tests/VObject/ComponentTest.php index ae7420dad..cf3e196dc 100644 --- a/tests/VObject/ComponentTest.php +++ b/tests/VObject/ComponentTest.php @@ -76,10 +76,10 @@ public function testAddGroupProperties() { $comp = new VCard([ 'VERSION' => '3.0', - 'item2.X-ABLabel' => "item2-Foo", + 'item2.X-ABLabel' => 'item2-Foo', ]); - $comp->{'ITEM1.X-ABLabel'} = "ITEM1-Foo"; + $comp->{'ITEM1.X-ABLabel'} = 'ITEM1-Foo'; foreach (['item2', 'ITEM1'] as $group) { $prop = $comp->{"$group.X-ABLabel"}; From 6439b62db5862807c9ef618e19cb4209f109dcba Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 12 Feb 2021 11:12:49 +0545 Subject: [PATCH 68/83] Release 4.3.5 --- CHANGELOG.md | 6 ++++++ lib/Version.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 607d07a2e..7605110f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ChangeLog ========= +4.3.5 (2021-02-12) +------------------ + +* #523: Fix setting properties with group assignment (@mstilkerich) +* #532: Make use of until parameter in nextMonthly function (@jaircuevajunior) + 4.3.4 (2021-02-04) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 83c82a573..63452400f 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.4'; + const VERSION = '4.3.5'; } From 502bc802854f411a230ad89d2cc85a7fa3705845 Mon Sep 17 00:00:00 2001 From: Parajuli Kiran Date: Fri, 8 Oct 2021 11:10:08 +0545 Subject: [PATCH 69/83] tests: migrate from Travis to gh-actions --- .github/ci.yml | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/ci.yml diff --git a/.github/ci.yml b/.github/ci.yml new file mode 100644 index 000000000..6195adc9d --- /dev/null +++ b/.github/ci.yml @@ -0,0 +1,65 @@ +name: continuous-integration + +on: + push: + branches: + - master + - release/* + pull_request: + +jobs: + unit-testing: + name: PHPUnit (PHP${{ matrix.php-versions }}) + runs-on: ubuntu-latest + + strategy: + fail-faset: false + matrix: + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1'] + coverage: ['pcov'] + code-analysis: ['no'] + include: + - php-versions: '7.1' + coverage: 'none' + code-analysis: 'yes' + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, dom, fileinfo, mysql, redis, opcache + coverage: ${{ matrix.coverage }} + tools: composer + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Code Analysis(PHP CS-Fixer) + if: matrix.code-analysis == 'yes' + run: composer cs-fixer + + - name: Code Analysis(PHPStan) + if: matrix.code-analysis == 'yes' + run: composer phpstan + + - name: Test with PHPUnit + run: composer phpunit --coverage-clover clover.xml + + - name: Code Coverage + uses: codecov/codecov-actions@v2 + if: matrix.coverage != 'none' \ No newline at end of file From 6a32c6cb398550e64a4ad38dad8f7eab4a53c683 Mon Sep 17 00:00:00 2001 From: Parajuli Kiran Date: Fri, 8 Oct 2021 11:24:20 +0545 Subject: [PATCH 70/83] Removed travis config --- .github/{ => workflows}/ci.yml | 50 ++++++++++++++++------------------ .travis.yml | 49 --------------------------------- lib/Cli.php | 2 -- 3 files changed, 24 insertions(+), 77 deletions(-) rename .github/{ => workflows}/ci.yml (62%) delete mode 100644 .travis.yml diff --git a/.github/ci.yml b/.github/workflows/ci.yml similarity index 62% rename from .github/ci.yml rename to .github/workflows/ci.yml index 6195adc9d..db8706bf9 100644 --- a/.github/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,16 @@ name: continuous-integration - on: push: branches: - master - release/* - pull_request: - + pull_request: jobs: unit-testing: - name: PHPUnit (PHP${{ matrix.php-versions }}) + name: PHPUnit (PHP ${{ matrix.php-versions }}) runs-on: ubuntu-latest - strategy: - fail-faset: false + fail-fast: false matrix: php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1'] coverage: ['pcov'] @@ -22,44 +19,45 @@ jobs: - php-versions: '7.1' coverage: 'none' code-analysis: 'yes' - steps: - name: Checkout uses: actions/checkout@v2 - - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 + + - name: Setup PHP, with Composer and Extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql, redis, opcache coverage: ${{ matrix.coverage }} tools: composer - - - name: Get composer cache directory + + - name: Get Composer Cache Directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies + + - name: Cache Composer Dependencies uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - - name: Install composer dependencies + + - name: Install Composer Dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Code Analysis(PHP CS-Fixer) + + - name: Code Analysis (PHP CS-Fixer) if: matrix.code-analysis == 'yes' - run: composer cs-fixer - - - name: Code Analysis(PHPStan) + run: php vendor/bin/php-cs-fixer fix --dry-run --diff + + - name: Code Analysis (PHPStan) if: matrix.code-analysis == 'yes' run: composer phpstan - + - name: Test with PHPUnit - run: composer phpunit --coverage-clover clover.xml - + run: composer phpunit + - name: Code Coverage - uses: codecov/codecov-actions@v2 - if: matrix.coverage != 'none' \ No newline at end of file + uses: codecov/codecov-action@v2 + if: matrix.coverage != 'none' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a1a1f66b5..000000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: php -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - global: - - MEMCACHED_SERVER=127.0.0.1 - - RUN_PHPCSFIXER="TRUE" - - RUN_PHPUNIT="TRUE" - - RUN_PHPSTAN="FALSE" - matrix: - - PREFER_LOWEST="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml" - - PREFER_LOWEST="--prefer-lowest" REPORT_COVERAGE="FALSE" WITH_COVERAGE="" - -matrix: - include: - - name: 'PHP8' - dist: focal - php: 8.0 - env: - - RUN_PHPCSFIXER="FALSE" - - REPORT_COVERAGE="FALSE" - - name: 'PHPStan' - php: 7.4 - env: - - RUN_PHPCSFIXER="FALSE" - - RUN_PHPUNIT="FALSE" - - RUN_PHPSTAN="TRUE" - - REPORT_COVERAGE="FALSE" - fast_finish: true - -before_script: - - if [ $RUN_PHPCSFIXER == "FALSE" ]; then composer remove --no-update --dev friendsofphp/php-cs-fixer; fi - - composer update $PREFER_LOWEST - -script: - - if [ $RUN_PHPCSFIXER == "TRUE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi - - if [ $RUN_PHPUNIT == "TRUE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi - - if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi - -after_success: - - if [ $REPORT_COVERAGE == "TRUE" ]; then bash <(curl -s https://codecov.io/bash); fi - -cache: - directories: - - $HOME/.composer/cache diff --git a/lib/Cli.php b/lib/Cli.php index 4984ac9b2..816e2cb31 100644 --- a/lib/Cli.php +++ b/lib/Cli.php @@ -453,8 +453,6 @@ protected function convert($vObj) * Colorizes a file. * * @param Component $vObj - * - * @return int */ protected function color($vObj) { From a7798a383c77304e33b3aaee82b44aeba5faefb1 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 8 Oct 2021 13:16:58 +0545 Subject: [PATCH 71/83] Minor edit to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5030cf276..659e3fa83 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ sabre/vobject The VObject library allows you to easily parse and manipulate [iCalendar](https://tools.ietf.org/html/rfc5545) and [vCard](https://tools.ietf.org/html/rfc6350) objects using PHP. -The goal of the VObject library is to create a very complete library, with an easy to use API. +The goal of the VObject library is to create a very complete library, with an easy-to-use API. Installation From 94e63e75323d0730088554a3efaef3514c99fd75 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 8 Oct 2021 13:25:59 +0545 Subject: [PATCH 72/83] Run phpunit with coverage in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db8706bf9..076b66694 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: run: composer phpstan - name: Test with PHPUnit - run: composer phpunit + run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml - name: Code Coverage uses: codecov/codecov-action@v2 From bb3bfeb6b621bd08ea64993e04a0a267d15ecb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 6 Oct 2021 15:25:01 +0200 Subject: [PATCH 73/83] Fix deprecated usages and return types on PHP 8.1 --- lib/Component.php | 1 + lib/Component/VCard.php | 1 + lib/ElementList.php | 2 ++ lib/Node.php | 7 +++++++ lib/Parameter.php | 2 ++ lib/Parser/MimeDir.php | 2 +- lib/Property.php | 5 +++++ lib/Property/ICalendar/DateTime.php | 1 + 8 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Component.php b/lib/Component.php index 07f6a627f..f33b628a7 100644 --- a/lib/Component.php +++ b/lib/Component.php @@ -339,6 +339,7 @@ function ($a, $b) use ($sortScore, $tmp) { * * @return array */ + #[\ReturnTypeWillChange] public function jsonSerialize() { $components = []; diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php index 2430df621..eac789842 100644 --- a/lib/Component/VCard.php +++ b/lib/Component/VCard.php @@ -445,6 +445,7 @@ protected function getDefaults() * * @return array */ + #[\ReturnTypeWillChange] public function jsonSerialize() { // A vcard does not have sub-components, so we're overriding this diff --git a/lib/ElementList.php b/lib/ElementList.php index 56058cbd5..860512649 100644 --- a/lib/ElementList.php +++ b/lib/ElementList.php @@ -25,6 +25,7 @@ class ElementList extends ArrayIterator * @param int $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('You can not add new objects to an ElementList'); @@ -37,6 +38,7 @@ public function offsetSet($offset, $value) * * @param int $offset */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new LogicException('You can not remove objects from an ElementList'); diff --git a/lib/Node.php b/lib/Node.php index 4c0c04f72..2041b2ac7 100644 --- a/lib/Node.php +++ b/lib/Node.php @@ -73,6 +73,7 @@ abstract public function serialize(); * * @return array */ + #[\ReturnTypeWillChange] abstract public function jsonSerialize(); /** @@ -102,6 +103,7 @@ public function destroy() * * @return ElementList */ + #[\ReturnTypeWillChange] public function getIterator() { if (!is_null($this->iterator)) { @@ -157,6 +159,7 @@ public function validate($options = 0) * * @return int */ + #[\ReturnTypeWillChange] public function count() { $it = $this->getIterator(); @@ -177,6 +180,7 @@ public function count() * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { $iterator = $this->getIterator(); @@ -193,6 +197,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { $iterator = $this->getIterator(); @@ -208,6 +213,7 @@ public function offsetGet($offset) * @param int $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $iterator = $this->getIterator(); @@ -228,6 +234,7 @@ public function offsetSet($offset, $value) * * @param int $offset */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $iterator = $this->getIterator(); diff --git a/lib/Parameter.php b/lib/Parameter.php index 72f2ecbcb..7e4d55743 100644 --- a/lib/Parameter.php +++ b/lib/Parameter.php @@ -321,6 +321,7 @@ function ($out, $item) { * * @return array */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->value; @@ -354,6 +355,7 @@ public function __toString() * * @return ElementList */ + #[\ReturnTypeWillChange] public function getIterator() { if (!is_null($this->iterator)) { diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index 385d340d7..f6ffc37b6 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -439,7 +439,7 @@ protected function readProperty($line) $propObj->add(null, $namelessParameter); } - if ('QUOTED-PRINTABLE' === strtoupper($propObj['ENCODING'])) { + if (isset($propObj['ENCODING']) && 'QUOTED-PRINTABLE' === strtoupper($propObj['ENCODING'])) { $propObj->setQuotedPrintableValue($this->extractQuotedPrintableValue()); } else { $charset = $this->charset; diff --git a/lib/Property.php b/lib/Property.php index f9cf8e38e..6219c9b67 100644 --- a/lib/Property.php +++ b/lib/Property.php @@ -276,6 +276,7 @@ public function setJsonValue(array $value) * * @return array */ + #[\ReturnTypeWillChange] public function jsonSerialize() { $parameters = []; @@ -387,6 +388,7 @@ public function __toString() * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($name) { if (is_int($name)) { @@ -413,6 +415,7 @@ public function offsetExists($name) * * @return Node */ + #[\ReturnTypeWillChange] public function offsetGet($name) { if (is_int($name)) { @@ -433,6 +436,7 @@ public function offsetGet($name) * @param string $name * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { if (is_int($name)) { @@ -453,6 +457,7 @@ public function offsetSet($name, $value) * * @param string $name */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { if (is_int($name)) { diff --git a/lib/Property/ICalendar/DateTime.php b/lib/Property/ICalendar/DateTime.php index d635e17ae..ca71633b9 100644 --- a/lib/Property/ICalendar/DateTime.php +++ b/lib/Property/ICalendar/DateTime.php @@ -300,6 +300,7 @@ function ($item) { * @param string $name * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { parent::offsetSet($name, $value); From a9dc7a96f3cf5a5727e4263a6d312d27c0ebe790 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 3 Nov 2021 13:12:48 +0545 Subject: [PATCH 74/83] sync ci.yml to match other repos --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 076b66694..3a019fe77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Setup PHP, with Composer and Extensions + - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} @@ -31,11 +31,11 @@ jobs: coverage: ${{ matrix.coverage }} tools: composer - - name: Get Composer Cache Directory + - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache Composer Dependencies + - name: Cache composer dependencies uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} @@ -44,7 +44,7 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - name: Install Composer Dependencies + - name: Install composer dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Code Analysis (PHP CS-Fixer) @@ -55,7 +55,7 @@ jobs: if: matrix.code-analysis == 'yes' run: composer phpstan - - name: Test with PHPUnit + - name: Test with phpunit run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml - name: Code Coverage From 8de260f324ff1b928e647160b15041f51ed8a7ea Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 4 Nov 2021 12:05:13 +0545 Subject: [PATCH 75/83] Changes that should have happened for 4.3.6 --- CHANGELOG.md | 5 +++++ lib/Version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7605110f4..f6f087b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ChangeLog ========= +4.3.6 (2021-11-04) +------------------ + +* #544 Fix deprecated usages and return types on PHP 8.1 (@cedric-anne) + 4.3.5 (2021-02-12) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 63452400f..d338adeaf 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.5'; + const VERSION = '4.3.6'; } From a3b1d590fd3629d6cf05d3fce83cbd4ee3d16db0 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 4 Nov 2021 12:51:40 +0545 Subject: [PATCH 76/83] changelog and VERSION bump for 4.3.7 --- CHANGELOG.md | 5 +++++ lib/Version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f087b4a..b7b735539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ChangeLog ========= +4.3.7 (2021-11-04) +------------------ + +* #551 version bump that was missed in 4.3.6 (@phil-davis) + 4.3.6 (2021-11-04) ------------------ diff --git a/lib/Version.php b/lib/Version.php index d338adeaf..3b9cc5e23 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.6'; + const VERSION = '4.3.7'; } From bfe37ff5bf2e754e57f43a8f10ab15c6703ac5ef Mon Sep 17 00:00:00 2001 From: Holger Floerke Date: Wed, 4 Aug 2021 12:05:53 +0200 Subject: [PATCH 77/83] EventIterator returns wrong endTime (#534) --- lib/Recur/EventIterator.php | 8 ++- .../EventIterator/OverrideDurationTest.php | 52 +++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/VObject/Recur/EventIterator/OverrideDurationTest.php diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php index e42ca1360..310bebe41 100644 --- a/lib/Recur/EventIterator.php +++ b/lib/Recur/EventIterator.php @@ -229,9 +229,13 @@ public function getDtEnd() if (!$this->valid()) { return; } - $end = clone $this->currentDate; + if ($this->currentOverriddenEvent && $this->currentOverriddenEvent->DTEND) { + return $this->currentOverriddenEvent->DTEND->getDateTime($this->timeZone); + } else { + $end = clone $this->currentDate; - return $end->modify('+'.$this->eventDuration.' seconds'); + return $end->modify('+'.$this->eventDuration.' seconds'); + } } /** diff --git a/tests/VObject/Recur/EventIterator/OverrideDurationTest.php b/tests/VObject/Recur/EventIterator/OverrideDurationTest.php new file mode 100644 index 000000000..f25ef13d9 --- /dev/null +++ b/tests/VObject/Recur/EventIterator/OverrideDurationTest.php @@ -0,0 +1,52 @@ +getComponents()); + + $this->assertEquals($eventIterator->current()->format('Y-m-d H:i:s'), '2021-05-17 09:00:00', 'recur event start time'); + $this->assertEquals($eventIterator->getDtEnd()->format('Y-m-d H:i:s'), '2021-05-17 10:00:00', 'recur event end time'); + + $eventIterator->next(); + $this->assertEquals($eventIterator->current()->format('Y-m-d H:i:s'), '2021-05-18 09:00:00', 'recur event start time'); + $this->assertEquals($eventIterator->getDtEnd()->format('Y-m-d H:i:s'), '2021-05-18 10:00:00', 'recur event end time'); + + $eventIterator->next(); + $this->assertEquals($eventIterator->current()->format('Y-m-d H:i:s'), '2021-05-19 09:00:00', 'overridden event start time'); + $this->assertEquals($eventIterator->getDtEnd()->format('Y-m-d H:i:s'), '2021-05-19 12:00:00', 'overridden event end time'); + + $eventIterator->next(); + $this->assertEquals($eventIterator->current()->format('Y-m-d H:i:s'), '2021-05-20 09:00:00', 'recur event start time'); + $this->assertEquals($eventIterator->getDtEnd()->format('Y-m-d H:i:s'), '2021-05-20 10:00:00', 'recur event end time'); + } +} From 5f81c0f189dd45639405d3c5d001e73a000258a5 Mon Sep 17 00:00:00 2001 From: Holger Floerke Date: Fri, 10 Sep 2021 08:02:20 +0200 Subject: [PATCH 78/83] Reordering of the attendees should not be a signitifcant change (sabre-io#540) --- lib/ITip/Broker.php | 6 ++- .../ITip/BrokerSignificantChangesTest.php | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 4e0368e13..1c599b997 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -547,9 +547,13 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, // properties changed in the event, or simply if there's a // difference in instances that the attendee is invited to. + $oldAttendeeInstances = array_keys($attendee['oldInstances']); + $newAttendeeInstances = array_keys($attendee['newInstances']); + $message->significantChange = 'REQUEST' === $attendee['forceSend'] || - array_keys($attendee['oldInstances']) != array_keys($attendee['newInstances']) || + count($oldAttendeeInstances) != count($newAttendeeInstances) || + count(array_diff($oldAttendeeInstances, $newAttendeeInstances)) > 0 || $oldEventInfo['significantChangeHash'] !== $eventInfo['significantChangeHash']; foreach ($attendee['newInstances'] as $instanceId => $instanceInfo) { diff --git a/tests/VObject/ITip/BrokerSignificantChangesTest.php b/tests/VObject/ITip/BrokerSignificantChangesTest.php index a225cb98c..ef4865127 100644 --- a/tests/VObject/ITip/BrokerSignificantChangesTest.php +++ b/tests/VObject/ITip/BrokerSignificantChangesTest.php @@ -105,4 +105,46 @@ public function testSignificantChangesRRuleOrderNoChange() $this->parse($old, $new, $expected, 'mailto:martin@fruux.com'); } + + /** + * Check significant changes detection (no change). + * Reordering of the attendees should not be a signitifcant change (#540) + * https://github.com/sabre-io/vobject/issues/540. + */ + public function testSignificantChangesAttendeesOrderNoChange() + { + $old = << false]; + $expected[] = ['significantChange' => false]; + + $this->parse($old, $new, $expected, 'mailto:martin@fruux.com'); + } } From 8ee715a520c573b7d9d4151eed0d4de5cfd2f69a Mon Sep 17 00:00:00 2001 From: Holger Floerke Date: Fri, 10 Sep 2021 13:33:24 +0200 Subject: [PATCH 79/83] Reordering of vevent should not be a significant change (#542) --- lib/ITip/Broker.php | 18 +++-- .../ITip/BrokerSignificantChangesTest.php | 68 ++++++++++++++++++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 1c599b997..b66a59f54 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -820,7 +820,10 @@ protected function parseEventInfo(VCalendar $calendar = null) $instances = []; $exdate = []; + $significantChangeEventProperties = []; + foreach ($calendar->VEVENT as $vevent) { + $eventSignificantChangeHash = ''; $rrule = []; if (is_null($uid)) { @@ -934,19 +937,26 @@ protected function parseEventInfo(VCalendar $calendar = null) if (isset($vevent->$prop)) { $propertyValues = $vevent->select($prop); - $significantChangeHash .= $prop.':'; + $eventSignificantChangeHash .= $prop.':'; if ('EXDATE' === $prop) { - $significantChangeHash .= implode(',', $exdate).';'; + $eventSignificantChangeHash .= implode(',', $exdate).';'; } elseif ('RRULE' === $prop) { - $significantChangeHash .= implode(',', $rrule).';'; + $eventSignificantChangeHash .= implode(',', $rrule).';'; } else { foreach ($propertyValues as $val) { - $significantChangeHash .= $val->getValue().';'; + $eventSignificantChangeHash .= $val->getValue().';'; } } } } + $significantChangeEventProperties[] = $eventSignificantChangeHash; + } + + asort($significantChangeEventProperties); + + foreach ($significantChangeEventProperties as $eventSignificantChangeHash) { + $significantChangeHash .= $eventSignificantChangeHash; } $significantChangeHash = md5($significantChangeHash); diff --git a/tests/VObject/ITip/BrokerSignificantChangesTest.php b/tests/VObject/ITip/BrokerSignificantChangesTest.php index ef4865127..a20d55025 100644 --- a/tests/VObject/ITip/BrokerSignificantChangesTest.php +++ b/tests/VObject/ITip/BrokerSignificantChangesTest.php @@ -108,7 +108,7 @@ public function testSignificantChangesRRuleOrderNoChange() /** * Check significant changes detection (no change). - * Reordering of the attendees should not be a signitifcant change (#540) + * Reordering of the attendees should not be a significant change (#540) * https://github.com/sabre-io/vobject/issues/540. */ public function testSignificantChangesAttendeesOrderNoChange() @@ -147,4 +147,70 @@ public function testSignificantChangesAttendeesOrderNoChange() $this->parse($old, $new, $expected, 'mailto:martin@fruux.com'); } + + /** + * Check significant changes detection (no change). + * Reordering of vevent in a recurring event with exceptions should + * not be a significant change + * https://github.com/sabre-io/vobject/issues/542. + */ + public function testSignificantChangesVeventOrderNoChange() + { + $vevent1 = << false]]; + + $this->parse($old, $new, $expected, 'mailto:martin@fruux.com'); + } } From 7cb4ddd934c815f0404ffcc5e7fddf8c4c20d34b Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 14 Nov 2021 20:19:16 +0545 Subject: [PATCH 80/83] Prepare release 4.3.8 --- CHANGELOG.md | 7 +++++++ lib/Version.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b735539..6621decbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ ChangeLog ========= +4.3.8 (2021-11-14) +------------------ + +* #538 fix EventIterator returns wrong end endTime (@floerke) +* #541 Reordering of the attendees is not a significant change (@floerke) +* #543 Reordering of vevent is not a significant change (@floerke) + 4.3.7 (2021-11-04) ------------------ diff --git a/lib/Version.php b/lib/Version.php index 3b9cc5e23..fce863ecb 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.7'; + const VERSION = '4.3.8'; } From 87c8def18d7f9a7d88ceff67e63a2ed006e082cc Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Fri, 29 Oct 2021 11:50:30 +0200 Subject: [PATCH 81/83] Allow easier extension of the timezone guessing This will ease customization of timezone-guessing as it is now gets easier to extend that process with own implementations (as long as they implement the appropriate interface) This is espechially necessary when wanting to actually guess a timezone via the rules defined in the VTIMEZONE-entry (which is currently not done) --- lib/TimeZoneUtil.php | 261 +++++++++--------- lib/TimezoneGuesser/FindFromOffset.php | 31 +++ .../FindFromTimezoneIdentifier.php | 71 +++++ lib/TimezoneGuesser/FindFromTimezoneMap.php | 78 ++++++ lib/TimezoneGuesser/GuessFromLicEntry.php | 33 +++ lib/TimezoneGuesser/GuessFromMsTzId.php | 119 ++++++++ lib/TimezoneGuesser/TimezoneFinder.php | 10 + lib/TimezoneGuesser/TimezoneGuesser.php | 11 + tests/VObject/TimeZoneUtilTest.php | 14 +- 9 files changed, 496 insertions(+), 132 deletions(-) create mode 100644 lib/TimezoneGuesser/FindFromOffset.php create mode 100644 lib/TimezoneGuesser/FindFromTimezoneIdentifier.php create mode 100644 lib/TimezoneGuesser/FindFromTimezoneMap.php create mode 100644 lib/TimezoneGuesser/GuessFromLicEntry.php create mode 100644 lib/TimezoneGuesser/GuessFromMsTzId.php create mode 100644 lib/TimezoneGuesser/TimezoneFinder.php create mode 100644 lib/TimezoneGuesser/TimezoneGuesser.php diff --git a/lib/TimeZoneUtil.php b/lib/TimeZoneUtil.php index 2c407fee6..6422c0930 100644 --- a/lib/TimeZoneUtil.php +++ b/lib/TimeZoneUtil.php @@ -2,6 +2,16 @@ namespace Sabre\VObject; +use DateTimeZone; +use InvalidArgumentException; +use Sabre\VObject\TimezoneGuesser\FindFromOffset; +use Sabre\VObject\TimezoneGuesser\FindFromTimezoneIdentifier; +use Sabre\VObject\TimezoneGuesser\FindFromTimezoneMap; +use Sabre\VObject\TimezoneGuesser\GuessFromLicEntry; +use Sabre\VObject\TimezoneGuesser\GuessFromMsTzId; +use Sabre\VObject\TimezoneGuesser\TimezoneFinder; +use Sabre\VObject\TimezoneGuesser\TimezoneGuesser; + /** * Time zone name translation. * @@ -14,17 +24,136 @@ */ class TimeZoneUtil { + /** @var self */ + private static $instance = null; + + /** @var TimezoneGuesser[] */ + private $timezoneGuessers = []; + + /** @var TimezoneFinder[] */ + private $timezoneFinders = []; + + private function __construct() + { + $this->addGuesser('lic', new GuessFromLicEntry()); + $this->addGuesser('msTzId', new GuessFromMsTzId()); + $this->addFinder('tzid', new FindFromTimezoneIdentifier()); + $this->addFinder('tzmap', new FindFromTimezoneMap()); + $this->addFinder('offset', new FindFromOffset()); + } + + private static function getInstance(): self + { + if (null === self::$instance) { + self::$instance = new self(); + } + + return self::$instance; + } + + private function addGuesser(string $key, TimezoneGuesser $guesser): void + { + $this->timezoneGuessers[$key] = $guesser; + } + + private function addFinder(string $key, TimezoneFinder $finder): void + { + $this->timezoneFinders[$key] = $finder; + } + + /** + * This method will try to find out the correct timezone for an iCalendar + * date-time value. + * + * You must pass the contents of the TZID parameter, as well as the full + * calendar. + * + * If the lookup fails, this method will return the default PHP timezone + * (as configured using date_default_timezone_set, or the date.timezone ini + * setting). + * + * Alternatively, if $failIfUncertain is set to true, it will throw an + * exception if we cannot accurately determine the timezone. + */ + private function findTimeZone(string $tzid, Component $vcalendar = null, bool $failIfUncertain = false): DateTimeZone + { + foreach ($this->timezoneFinders as $timezoneFinder) { + $timezone = $timezoneFinder->find($tzid, $failIfUncertain); + if (!$timezone instanceof DateTimeZone) { + continue; + } + + return $timezone; + } + + if ($vcalendar) { + // If that didn't work, we will scan VTIMEZONE objects + foreach ($vcalendar->select('VTIMEZONE') as $vtimezone) { + if ((string) $vtimezone->TZID === $tzid) { + foreach ($this->timezoneGuessers as $timezoneGuesser) { + $timezone = $timezoneGuesser->guess($vtimezone, $failIfUncertain); + if (!$timezone instanceof DateTimeZone) { + continue; + } + + return $timezone; + } + } + } + } + + if ($failIfUncertain) { + throw new InvalidArgumentException('We were unable to determine the correct PHP timezone for tzid: '.$tzid); + } + + // If we got all the way here, we default to whatever has been set as the PHP default timezone. + return new DateTimeZone(date_default_timezone_get()); + } + + public static function addTimezoneGuesser(string $key, TimezoneGuesser $guesser): void + { + self::getInstance()->addGuesser($key, $guesser); + } + + public static function addTimezoneFinder(string $key, TimezoneFinder $finder): void + { + self::getInstance()->addFinder($key, $finder); + } + + /** + * @param string $tzid + * @param false $failIfUncertain + * + * @return DateTimeZone + */ + public static function getTimeZone($tzid, Component $vcalendar = null, $failIfUncertain = false) + { + return self::getInstance()->findTimeZone($tzid, $vcalendar, $failIfUncertain); + } + + public static function clean(): void + { + self::$instance = null; + } + + // Keeping things for backwards compatibility + /** + * @var array|null + * + * @deprecated + */ public static $map = null; /** * List of microsoft exchange timezone ids. * * Source: http://msdn.microsoft.com/en-us/library/aa563018(loband).aspx + * + * @deprecated */ public static $microsoftExchangeMap = [ 0 => 'UTC', 31 => 'Africa/Casablanca', - // Insanely, id #2 is used for both Europe/Lisbon, and Europe/Sarajevo. // I'm not even kidding.. We handle this special case in the // getTimeZone method. @@ -103,135 +232,11 @@ class TimeZoneUtil 39 => 'Pacific/Kwajalein', ]; - /** - * This method will try to find out the correct timezone for an iCalendar - * date-time value. - * - * You must pass the contents of the TZID parameter, as well as the full - * calendar. - * - * If the lookup fails, this method will return the default PHP timezone - * (as configured using date_default_timezone_set, or the date.timezone ini - * setting). - * - * Alternatively, if $failIfUncertain is set to true, it will throw an - * exception if we cannot accurately determine the timezone. - * - * @param string $tzid - * @param Sabre\VObject\Component $vcalendar - * - * @return \DateTimeZone - */ - public static function getTimeZone($tzid, Component $vcalendar = null, $failIfUncertain = false) - { - // First we will just see if the tzid is a support timezone identifier. - // - // The only exception is if the timezone starts with (. This is to - // handle cases where certain microsoft products generate timezone - // identifiers that for instance look like: - // - // (GMT+01.00) Sarajevo/Warsaw/Zagreb - // - // Since PHP 5.5.10, the first bit will be used as the timezone and - // this method will return just GMT+01:00. This is wrong, because it - // doesn't take DST into account. - if ('(' !== $tzid[0]) { - // PHP has a bug that logs PHP warnings even it shouldn't: - // https://bugs.php.net/bug.php?id=67881 - // - // That's why we're checking if we'll be able to successfully instantiate - // \DateTimeZone() before doing so. Otherwise we could simply instantiate - // and catch the exception. - $tzIdentifiers = \DateTimeZone::listIdentifiers(); - - try { - if ( - (in_array($tzid, $tzIdentifiers)) || - (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) || - (in_array($tzid, self::getIdentifiersBC())) - ) { - return new \DateTimeZone($tzid); - } - } catch (\Exception $e) { - } - } - - self::loadTzMaps(); - - // Next, we check if the tzid is somewhere in our tzid map. - if (isset(self::$map[$tzid])) { - return new \DateTimeZone(self::$map[$tzid]); - } - - // Some Microsoft products prefix the offset first, so let's strip that off - // and see if it is our tzid map. We don't want to check for this first just - // in case there are overrides in our tzid map. - if (preg_match('/^\((UTC|GMT)(\+|\-)[\d]{2}\:[\d]{2}\) (.*)/', $tzid, $matches)) { - $tzidAlternate = $matches[3]; - if (isset(self::$map[$tzidAlternate])) { - return new \DateTimeZone(self::$map[$tzidAlternate]); - } - } - - // Maybe the author was hyper-lazy and just included an offset. We - // support it, but we aren't happy about it. - if (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) { - // Note that the path in the source will never be taken from PHP 5.5.10 - // onwards. PHP 5.5.10 supports the "GMT+0100" style of format, so it - // already gets returned early in this function. Once we drop support - // for versions under PHP 5.5.10, this bit can be taken out of the - // source. - // @codeCoverageIgnoreStart - return new \DateTimeZone('Etc/GMT'.$matches[1].ltrim(substr($matches[2], 0, 2), '0')); - // @codeCoverageIgnoreEnd - } - - if ($vcalendar) { - // If that didn't work, we will scan VTIMEZONE objects - foreach ($vcalendar->select('VTIMEZONE') as $vtimezone) { - if ((string) $vtimezone->TZID === $tzid) { - // Some clients add 'X-LIC-LOCATION' with the olson name. - if (isset($vtimezone->{'X-LIC-LOCATION'})) { - $lic = (string) $vtimezone->{'X-LIC-LOCATION'}; - - // Libical generators may specify strings like - // "SystemV/EST5EDT". For those we must remove the - // SystemV part. - if ('SystemV/' === substr($lic, 0, 8)) { - $lic = substr($lic, 8); - } - - return self::getTimeZone($lic, null, $failIfUncertain); - } - // Microsoft may add a magic number, which we also have an - // answer for. - if (isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) { - $cdoId = (int) $vtimezone->{'X-MICROSOFT-CDO-TZID'}->getValue(); - - // 2 can mean both Europe/Lisbon and Europe/Sarajevo. - if (2 === $cdoId && false !== strpos((string) $vtimezone->TZID, 'Sarajevo')) { - return new \DateTimeZone('Europe/Sarajevo'); - } - - if (isset(self::$microsoftExchangeMap[$cdoId])) { - return new \DateTimeZone(self::$microsoftExchangeMap[$cdoId]); - } - } - } - } - } - - if ($failIfUncertain) { - throw new \InvalidArgumentException('We were unable to determine the correct PHP timezone for tzid: '.$tzid); - } - - // If we got all the way here, we default to UTC. - return new \DateTimeZone(date_default_timezone_get()); - } - /** * This method will load in all the tz mapping information, if it's not yet * done. + * + * @deprecated */ public static function loadTzMaps() { @@ -257,6 +262,8 @@ public static function loadTzMaps() * (See timezonedata/php-bc.php and timezonedata php-workaround.php) * * @return array + * + * @deprecated */ public static function getIdentifiersBC() { diff --git a/lib/TimezoneGuesser/FindFromOffset.php b/lib/TimezoneGuesser/FindFromOffset.php new file mode 100644 index 000000000..990ac9692 --- /dev/null +++ b/lib/TimezoneGuesser/FindFromOffset.php @@ -0,0 +1,31 @@ +getIdentifiersBC())) + ) { + return new DateTimeZone($tzid); + } + } catch (Exception $e) { + } + + return null; + } + + /** + * This method returns an array of timezone identifiers, that are supported + * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers(). + * + * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because: + * - It's not supported by some PHP versions as well as HHVM. + * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions. + * (See timezonedata/php-bc.php and timezonedata php-workaround.php) + * + * @return array + */ + private function getIdentifiersBC() + { + return include __DIR__.'/../timezonedata/php-bc.php'; + } +} diff --git a/lib/TimezoneGuesser/FindFromTimezoneMap.php b/lib/TimezoneGuesser/FindFromTimezoneMap.php new file mode 100644 index 000000000..b52ba6a19 --- /dev/null +++ b/lib/TimezoneGuesser/FindFromTimezoneMap.php @@ -0,0 +1,78 @@ +hasTzInMap($tzid)) { + return new DateTimeZone($this->getTzFromMap($tzid)); + } + + // Some Microsoft products prefix the offset first, so let's strip that off + // and see if it is our tzid map. We don't want to check for this first just + // in case there are overrides in our tzid map. + foreach ($this->patterns as $pattern) { + if (!preg_match($pattern, $tzid, $matches)) { + continue; + } + $tzidAlternate = $matches[3]; + if ($this->hasTzInMap($tzidAlternate)) { + return new DateTimeZone($this->getTzFromMap($tzidAlternate)); + } + } + + return null; + } + + /** + * This method returns an array of timezone identifiers, that are supported + * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers(). + * + * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because: + * - It's not supported by some PHP versions as well as HHVM. + * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions. + * (See timezonedata/php-bc.php and timezonedata php-workaround.php) + * + * @return array + */ + private function getTzMaps() + { + if ([] === $this->map) { + $this->map = array_merge( + include __DIR__.'/../timezonedata/windowszones.php', + include __DIR__.'/../timezonedata/lotuszones.php', + include __DIR__.'/../timezonedata/exchangezones.php', + include __DIR__.'/../timezonedata/php-workaround.php' + ); + } + + return $this->map; + } + + private function getTzFromMap(string $tzid): string + { + return $this->getTzMaps()[$tzid]; + } + + private function hasTzInMap(string $tzid): bool + { + return isset($this->getTzMaps()[$tzid]); + } +} diff --git a/lib/TimezoneGuesser/GuessFromLicEntry.php b/lib/TimezoneGuesser/GuessFromLicEntry.php new file mode 100644 index 000000000..f340a3962 --- /dev/null +++ b/lib/TimezoneGuesser/GuessFromLicEntry.php @@ -0,0 +1,33 @@ +{'X-LIC-LOCATION'})) { + return null; + } + + $lic = (string) $vtimezone->{'X-LIC-LOCATION'}; + + // Libical generators may specify strings like + // "SystemV/EST5EDT". For those we must remove the + // SystemV part. + if ('SystemV/' === substr($lic, 0, 8)) { + $lic = substr($lic, 8); + } + + return TimeZoneUtil::getTimeZone($lic, null, $failIfUncertain); + } +} diff --git a/lib/TimezoneGuesser/GuessFromMsTzId.php b/lib/TimezoneGuesser/GuessFromMsTzId.php new file mode 100644 index 000000000..b11ce1832 --- /dev/null +++ b/lib/TimezoneGuesser/GuessFromMsTzId.php @@ -0,0 +1,119 @@ + 'UTC', + 31 => 'Africa/Casablanca', + + // Insanely, id #2 is used for both Europe/Lisbon, and Europe/Sarajevo. + // I'm not even kidding.. We handle this special case in the + // getTimeZone method. + 2 => 'Europe/Lisbon', + 1 => 'Europe/London', + 4 => 'Europe/Berlin', + 6 => 'Europe/Prague', + 3 => 'Europe/Paris', + 69 => 'Africa/Luanda', // This was a best guess + 7 => 'Europe/Athens', + 5 => 'Europe/Bucharest', + 49 => 'Africa/Cairo', + 50 => 'Africa/Harare', + 59 => 'Europe/Helsinki', + 27 => 'Asia/Jerusalem', + 26 => 'Asia/Baghdad', + 74 => 'Asia/Kuwait', + 51 => 'Europe/Moscow', + 56 => 'Africa/Nairobi', + 25 => 'Asia/Tehran', + 24 => 'Asia/Muscat', // Best guess + 54 => 'Asia/Baku', + 48 => 'Asia/Kabul', + 58 => 'Asia/Yekaterinburg', + 47 => 'Asia/Karachi', + 23 => 'Asia/Calcutta', + 62 => 'Asia/Kathmandu', + 46 => 'Asia/Almaty', + 71 => 'Asia/Dhaka', + 66 => 'Asia/Colombo', + 61 => 'Asia/Rangoon', + 22 => 'Asia/Bangkok', + 64 => 'Asia/Krasnoyarsk', + 45 => 'Asia/Shanghai', + 63 => 'Asia/Irkutsk', + 21 => 'Asia/Singapore', + 73 => 'Australia/Perth', + 75 => 'Asia/Taipei', + 20 => 'Asia/Tokyo', + 72 => 'Asia/Seoul', + 70 => 'Asia/Yakutsk', + 19 => 'Australia/Adelaide', + 44 => 'Australia/Darwin', + 18 => 'Australia/Brisbane', + 76 => 'Australia/Sydney', + 43 => 'Pacific/Guam', + 42 => 'Australia/Hobart', + 68 => 'Asia/Vladivostok', + 41 => 'Asia/Magadan', + 17 => 'Pacific/Auckland', + 40 => 'Pacific/Fiji', + 67 => 'Pacific/Tongatapu', + 29 => 'Atlantic/Azores', + 53 => 'Atlantic/Cape_Verde', + 30 => 'America/Noronha', + 8 => 'America/Sao_Paulo', // Best guess + 32 => 'America/Argentina/Buenos_Aires', + 60 => 'America/Godthab', + 28 => 'America/St_Johns', + 9 => 'America/Halifax', + 33 => 'America/Caracas', + 65 => 'America/Santiago', + 35 => 'America/Bogota', + 10 => 'America/New_York', + 34 => 'America/Indiana/Indianapolis', + 55 => 'America/Guatemala', + 11 => 'America/Chicago', + 37 => 'America/Mexico_City', + 36 => 'America/Edmonton', + 38 => 'America/Phoenix', + 12 => 'America/Denver', // Best guess + 13 => 'America/Los_Angeles', // Best guess + 14 => 'America/Anchorage', + 15 => 'Pacific/Honolulu', + 16 => 'Pacific/Midway', + 39 => 'Pacific/Kwajalein', + ]; + + public function guess(VTimeZone $vtimezone, bool $throwIfUnsure = false): ?DateTimeZone + { + // Microsoft may add a magic number, which we also have an + // answer for. + if (!isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) { + return null; + } + $cdoId = (int) $vtimezone->{'X-MICROSOFT-CDO-TZID'}->getValue(); + + // 2 can mean both Europe/Lisbon and Europe/Sarajevo. + if (2 === $cdoId && false !== strpos((string) $vtimezone->TZID, 'Sarajevo')) { + return new DateTimeZone('Europe/Sarajevo'); + } + + if (isset(self::$microsoftExchangeMap[$cdoId])) { + return new DateTimeZone(self::$microsoftExchangeMap[$cdoId]); + } + + return null; + } +} diff --git a/lib/TimezoneGuesser/TimezoneFinder.php b/lib/TimezoneGuesser/TimezoneFinder.php new file mode 100644 index 000000000..5aa880a1c --- /dev/null +++ b/lib/TimezoneGuesser/TimezoneFinder.php @@ -0,0 +1,10 @@ + Date: Mon, 15 Nov 2021 16:16:23 +0545 Subject: [PATCH 82/83] testEmptyTimeZone --- tests/VObject/TimeZoneUtilTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/VObject/TimeZoneUtilTest.php b/tests/VObject/TimeZoneUtilTest.php index 494a2e1ae..4df91572c 100644 --- a/tests/VObject/TimeZoneUtilTest.php +++ b/tests/VObject/TimeZoneUtilTest.php @@ -151,6 +151,13 @@ public function testUnknownExchangeId() $this->assertEquals($ex->getName(), $tz->getName()); } + public function testEmptyTimeZone() + { + $tz = TimeZoneUtil::getTimeZone(''); + $ex = new \DateTimeZone('UTC'); + $this->assertEquals($ex->getName(), $tz->getName()); + } + public function testWindowsTimeZone() { $tz = TimeZoneUtil::getTimeZone('Eastern Standard Time'); From 962b5eea95dae8aab7f0af3c84de85443103e25f Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 15 Nov 2021 22:02:23 +0545 Subject: [PATCH 83/83] Changelog for 4.4.0 --- CHANGELOG.md | 15 ++++++++++----- lib/Version.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6621decbf..3461d0c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,27 @@ ChangeLog ========= +4.4.0 (2021-11-15) +------------------ + + #548: Allow easier extension of the timezone guessing (@heiglandreas) + 4.3.8 (2021-11-14) ------------------ -* #538 fix EventIterator returns wrong end endTime (@floerke) -* #541 Reordering of the attendees is not a significant change (@floerke) -* #543 Reordering of vevent is not a significant change (@floerke) +* #538: fix EventIterator returns wrong end endTime (@floerke) +* #541: Reordering of the attendees is not a significant change (@floerke) +* #543: Reordering of vevent is not a significant change (@floerke) 4.3.7 (2021-11-04) ------------------ -* #551 version bump that was missed in 4.3.6 (@phil-davis) +* #551: version bump that was missed in 4.3.6 (@phil-davis) 4.3.6 (2021-11-04) ------------------ -* #544 Fix deprecated usages and return types on PHP 8.1 (@cedric-anne) +* #544: Fix deprecated usages and return types on PHP 8.1 (@cedric-anne) 4.3.5 (2021-02-12) ------------------ diff --git a/lib/Version.php b/lib/Version.php index fce863ecb..e8e73360b 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -14,5 +14,5 @@ class Version /** * Full version number. */ - const VERSION = '4.3.8'; + const VERSION = '4.4.0'; }