Skip to content

Commit

Permalink
Merge pull request #605 from phil-davis/fix-ci-20230120
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
phil-davis committed Jan 20, 2023
2 parents 7b17e07 + 3bef1cf commit 041ceaf
Show file tree
Hide file tree
Showing 60 changed files with 591 additions and 701 deletions.
8 changes: 3 additions & 5 deletions lib/BirthdayCalendarGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sabre\VObject;

use DateTime;
use InvalidArgumentException;
use Sabre\VObject\Component\VCalendar;

/**
Expand Down Expand Up @@ -65,14 +63,14 @@ public function setObjects($objects): void
if (is_string($object)) {
$vObj = Reader::read($object);
if (!$vObj instanceof Component\VCard) {
throw new InvalidArgumentException('String could not be parsed as \\Sabre\\VObject\\Component\\VCard by setObjects');
throw new \InvalidArgumentException('String could not be parsed as \\Sabre\\VObject\\Component\\VCard by setObjects');
}

$this->objects[] = $vObj;
} elseif ($object instanceof Component\VCard) {
$this->objects[] = $object;
} else {
throw new InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component\\VCard arguments to setObjects');
throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component\\VCard arguments to setObjects');
}
}
}
Expand Down Expand Up @@ -138,7 +136,7 @@ public function getResult(): VCalendar
// Create event.
$event = $calendar->add('VEVENT', [
'SUMMARY' => sprintf($this->format, $object->FN->getValue()),
'DTSTART' => new DateTime($object->BDAY->getValue()),
'DTSTART' => new \DateTime($object->BDAY->getValue()),
'RRULE' => 'FREQ=YEARLY',
'TRANSP' => 'TRANSPARENT',
]);
Expand Down
20 changes: 9 additions & 11 deletions lib/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sabre\VObject;

use Exception;
use InvalidArgumentException;
use Sabre\VObject\Parser\Json;
use Sabre\VObject\Parser\MimeDir;
use Sabre\VObject\Parser\Parser;
Expand Down Expand Up @@ -131,7 +129,7 @@ public function main(array $argv): int
break;

default:
throw new InvalidArgumentException('Unknown format: '.$value);
throw new \InvalidArgumentException('Unknown format: '.$value);
}
break;
case 'pretty':
Expand Down Expand Up @@ -161,11 +159,11 @@ public function main(array $argv): int
break;

default:
throw new InvalidArgumentException('Unknown format: '.$value);
throw new \InvalidArgumentException('Unknown format: '.$value);
}
break;
default:
throw new InvalidArgumentException('Unknown option: '.$name);
throw new \InvalidArgumentException('Unknown option: '.$name);
}
}

Expand All @@ -176,17 +174,17 @@ public function main(array $argv): int
}

if (1 === count($positional)) {
throw new InvalidArgumentException('Inputfile is a required argument');
throw new \InvalidArgumentException('Inputfile is a required argument');
}

if (count($positional) > 3) {
throw new InvalidArgumentException('Too many arguments');
throw new \InvalidArgumentException('Too many arguments');
}

if (!in_array($positional[0], ['validate', 'repair', 'convert', 'color'])) {
throw new InvalidArgumentException('Unknown command: '.$positional[0]);
throw new \InvalidArgumentException('Unknown command: '.$positional[0]);
}
} catch (InvalidArgumentException $e) {
} catch (\InvalidArgumentException $e) {
$this->showHelp();
$this->log('Error: '.$e->getMessage(), 'red');

Expand Down Expand Up @@ -228,7 +226,7 @@ public function main(array $argv): int
}
} catch (EofException $e) {
// end of file
} catch (Exception $e) {
} catch (\Exception $e) {
$this->log('Error: '.$e->getMessage(), 'red');

return 2;
Expand Down Expand Up @@ -398,7 +396,7 @@ protected function convert(Component $vObj): int
}

if ($forceInput && $vObj->name !== $forceInput) {
throw new Exception('You cannot convert a '.strtolower($vObj->name).' to '.$this->format);
throw new \Exception('You cannot convert a '.strtolower($vObj->name).' to '.$this->format);
}
if ($convertVersion) {
$vObj = $vObj->convert($convertVersion);
Expand Down
10 changes: 4 additions & 6 deletions lib/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Sabre\VObject;

use InvalidArgumentException;
use ReturnTypeWillChange;
use RuntimeException;
use Sabre\VObject;
use Sabre\Xml;

Expand Down Expand Up @@ -107,14 +105,14 @@ public function add(): Node

if ($arguments[0] instanceof Node) {
if (isset($arguments[1])) {
throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject Node');
throw new \InvalidArgumentException('The second argument must not be specified, when passing a VObject Node');
}
$arguments[0]->parent = $this;
$newNode = $arguments[0];
} elseif (is_string($arguments[0])) {
$newNode = call_user_func_array([$this->root, 'create'], $arguments);
} else {
throw new InvalidArgumentException('The first argument must either be a \\Sabre\\VObject\\Node or a string');
throw new \InvalidArgumentException('The first argument must either be a \\Sabre\\VObject\\Node or a string');
}

/** @var Component|Property|Parameter $newNode */
Expand Down Expand Up @@ -163,7 +161,7 @@ public function remove($item): void
}
}

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');
}
}

Expand Down Expand Up @@ -420,7 +418,7 @@ protected function getDefaults(): array
public function __get(string $name): ?Node
{
if ('children' === $name) {
throw new RuntimeException('Starting sabre/vobject 4.0 the children property is now protected. You should use the children() method instead');
throw new \RuntimeException('Starting sabre/vobject 4.0 the children property is now protected. You should use the children() method instead');
}

$matches = $this->select($name);
Expand Down
9 changes: 3 additions & 6 deletions lib/Component/VAlarm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace Sabre\VObject\Component;

use DatePeriod;
use DateTimeImmutable;
use DateTimeInterface;
use Sabre\VObject;
use Sabre\VObject\InvalidDataException;

Expand Down Expand Up @@ -32,7 +29,7 @@ class VAlarm extends VObject\Component
*
* @throws InvalidDataException
*/
public function getEffectiveTriggerTime(): DateTimeImmutable
public function getEffectiveTriggerTime(): \DateTimeImmutable
{
$trigger = $this->TRIGGER;
if (!isset($trigger['VALUE']) || ($trigger['VALUE'] && 'DURATION' === strtoupper($trigger['VALUE']))) {
Expand Down Expand Up @@ -85,7 +82,7 @@ public function getEffectiveTriggerTime(): DateTimeImmutable
*
* @throws InvalidDataException
*/
public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end): bool
public function isInTimeRange(\DateTimeInterface $start, \DateTimeInterface $end): bool
{
$effectiveTrigger = $this->getEffectiveTriggerTime();

Expand All @@ -96,7 +93,7 @@ public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end):
$repeat = 1;
}

$period = new DatePeriod($effectiveTrigger, $duration, (int) $repeat);
$period = new \DatePeriod($effectiveTrigger, $duration, (int) $repeat);

foreach ($period as $occurrence) {
if ($start <= $occurrence && $end > $occurrence) {
Expand Down
3 changes: 1 addition & 2 deletions lib/Component/VAvailability.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sabre\VObject\Component;

use DateTimeInterface;
use Sabre\VObject;

/**
Expand Down Expand Up @@ -32,7 +31,7 @@ class VAvailability extends VObject\Component
*
* @throws VObject\InvalidDataException
*/
public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end): bool
public function isInTimeRange(\DateTimeInterface $start, \DateTimeInterface $end): bool
{
list($effectiveStart, $effectiveEnd) = $this->getEffectiveStartEnd();

Expand Down
12 changes: 5 additions & 7 deletions lib/Component/VCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sabre\VObject\Component;

use DateTimeInterface;
use DateTimeZone;
use Sabre\VObject;
use Sabre\VObject\Component;
use Sabre\VObject\InvalidDataException;
Expand Down Expand Up @@ -271,19 +269,19 @@ public function getBaseComponent(?string $componentName = null): ?Component
* In addition, this method will cause timezone information to be stripped,
* and normalized to UTC.
*
* @param DateTimeZone|null $timeZone reference timezone for floating dates and
* times
* @param \DateTimeZone|null $timeZone reference timezone for floating dates and
* times
*
* @throws InvalidDataException
* @throws VObject\Recur\MaxInstancesExceededException
*/
public function expand(DateTimeInterface $start, DateTimeInterface $end, ?DateTimeZone $timeZone = null): VCalendar
public function expand(\DateTimeInterface $start, \DateTimeInterface $end, ?\DateTimeZone $timeZone = null): VCalendar
{
$newChildren = [];
$recurringEvents = [];

if (!$timeZone) {
$timeZone = new DateTimeZone('UTC');
$timeZone = new \DateTimeZone('UTC');
}

$stripTimezones = function (Component $component) use ($timeZone, &$stripTimezones): Component {
Expand All @@ -293,7 +291,7 @@ public function expand(DateTimeInterface $start, DateTimeInterface $end, ?DateTi
// We only need to update the first timezone, because
// setDateTimes will match all other timezones to the
// first.
$dt[0] = $dt[0]->setTimeZone(new DateTimeZone('UTC'));
$dt[0] = $dt[0]->setTimeZone(new \DateTimeZone('UTC'));
$componentChild->setDateTimes($dt);
} elseif ($componentChild instanceof Component) {
$stripTimezones($componentChild);
Expand Down
3 changes: 1 addition & 2 deletions lib/Component/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sabre\VObject\Component;

use ArrayAccess;
use Sabre\VObject;
use Sabre\Xml;

Expand Down Expand Up @@ -397,7 +396,7 @@ public function preferred(string $propertyName): ?VObject\Property
* This function will return null if the property does not exist. If there are
* multiple properties with the same TYPE value, only one will be returned.
*
* @return ArrayAccess|array|null
* @return \ArrayAccess|array|null
*/
public function getByType(string $propertyName, string $type)
{
Expand Down
3 changes: 1 addition & 2 deletions lib/Component/VEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sabre\VObject\Component;

use DateTimeInterface;
use Sabre\VObject;
use Sabre\VObject\Recur\EventIterator;
use Sabre\VObject\Recur\NoInstancesException;
Expand Down Expand Up @@ -40,7 +39,7 @@ class VEvent extends VObject\Component
* @throws VObject\InvalidDataException
* @throws VObject\Recur\MaxInstancesExceededException
*/
public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end): bool
public function isInTimeRange(\DateTimeInterface $start, \DateTimeInterface $end): bool
{
if ($this->RRULE) {
try {
Expand Down
6 changes: 2 additions & 4 deletions lib/Component/VFreeBusy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sabre\VObject\Component;

use DateInterval;
use DateTimeInterface;
use Sabre\VObject;

/**
Expand All @@ -26,7 +24,7 @@ class VFreeBusy extends VObject\Component
*
* @throws VObject\InvalidDataException
*/
public function isFree(DateTimeInterface $start, DatetimeInterface $end): bool
public function isFree(\DateTimeInterface $start, \DatetimeInterface $end): bool
{
foreach ($this->select('FREEBUSY') as $freebusy) {
// We are only interested in FBTYPE=BUSY (the default),
Expand All @@ -47,7 +45,7 @@ public function isFree(DateTimeInterface $start, DatetimeInterface $end): bool

$busyStart = VObject\DateTimeParser::parse($busyStart);
$busyEnd = VObject\DateTimeParser::parse($busyEnd);
if ($busyEnd instanceof DateInterval) {
if ($busyEnd instanceof \DateInterval) {
$busyEnd = $busyStart->add($busyEnd);
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Component/VJournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sabre\VObject\Component;

use DateTimeInterface;
use Sabre\VObject;

/**
Expand All @@ -27,7 +26,7 @@ class VJournal extends VObject\Component
*
* @throws VObject\InvalidDataException
*/
public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end): bool
public function isInTimeRange(\DateTimeInterface $start, \DateTimeInterface $end): bool
{
$dtstart = isset($this->DTSTART) ? $this->DTSTART->getDateTime() : null;
if ($dtstart) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Component/VTimeZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class VTimeZone extends VObject\Component
* If we can't accurately determine the timezone, this method will return
* UTC.
*/
public function getTimeZone(): DateTimeZone
public function getTimeZone(): \DateTimeZone
{
return VObject\TimeZoneUtil::getTimeZone((string) $this->TZID, $this->root);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Component/VTodo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sabre\VObject\Component;

use DateTimeInterface;
use Sabre\VObject;

/**
Expand Down Expand Up @@ -38,7 +37,7 @@ class VTodo extends VObject\Component
*
* @throws VObject\InvalidDataException
*/
public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end): bool
public function isInTimeRange(\DateTimeInterface $start, \DateTimeInterface $end): bool
{
$dtstart = isset($this->DTSTART) ? $this->DTSTART->getDateTime() : null;
$duration = isset($this->DURATION) ? VObject\DateTimeParser::parseDuration($this->DURATION) : null;
Expand Down
Loading

0 comments on commit 041ceaf

Please sign in to comment.