diff --git a/composer.json b/composer.json index 8ae9f914a..32564bbee 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "phpstan/extension-installer": "^1.4", "phpunit/phpunit": "^11.5", "phpunit/php-invoker" : "^5.0", - "rector/rector": "^2.4" + "rector/rector": "^2.6" }, "suggest" : { "hoa/bench" : "If you would like to run the benchmark scripts" diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php index 7c5ca739c..bbb852cc2 100644 --- a/lib/Component/VCard.php +++ b/lib/Component/VCard.php @@ -481,9 +481,7 @@ public function xmlSerialize(Xml\Writer $writer): void foreach ($this->children() as $property) { $group = $property->group; - if (!isset($propertiesByGroup[$group])) { - $propertiesByGroup[$group] = []; - } + $propertiesByGroup[$group] ??= []; $propertiesByGroup[$group][] = $property; } diff --git a/lib/DateTimeParser.php b/lib/DateTimeParser.php index 9469cacea..9b0c55b2e 100644 --- a/lib/DateTimeParser.php +++ b/lib/DateTimeParser.php @@ -63,9 +63,7 @@ public static function parseDate(string $date, ?\DateTimeZone $tz = null): \Date throw new InvalidDataException('The supplied iCalendar date value is incorrect: '.$date); } - if (is_null($tz)) { - $tz = new \DateTimeZone('UTC'); - } + $tz ??= new \DateTimeZone('UTC'); try { $date = new \DateTimeImmutable($matches[1].'-'.$matches[2].'-'.$matches[3], $tz); diff --git a/lib/Document.php b/lib/Document.php index 7cdb65d4f..8319b49be 100644 --- a/lib/Document.php +++ b/lib/Document.php @@ -146,9 +146,7 @@ public function createComponent(string $name, ?array $children = null, bool $def if (isset(static::$componentMap[$name])) { $class = static::$componentMap[$name]; } - if (is_null($children)) { - $children = []; - } + $children ??= []; return new $class($this, $name, $children, $defaults); } @@ -200,13 +198,9 @@ public function createProperty(string $name, $value = null, ?array $parameters = // we do not attempt to interpret or parse the datass value as specified in // https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.20 // So when we so far did not get a class-name, we use the default for the property - if (is_null($class)) { - $class = $this->getClassNameForPropertyName($name); - } + $class ??= $this->getClassNameForPropertyName($name); - if (is_null($parameters)) { - $parameters = []; - } + $parameters ??= []; return new $class($this, $name, $value, $parameters, $group, $lineIndex, $lineString); } diff --git a/lib/FreeBusyGenerator.php b/lib/FreeBusyGenerator.php index 3bcc842e3..9eec5c8d7 100644 --- a/lib/FreeBusyGenerator.php +++ b/lib/FreeBusyGenerator.php @@ -79,9 +79,7 @@ public function __construct(?\DateTimeInterface $start = null, ?\DateTimeInterfa if ($objects) { $this->setObjects($objects); } - if (is_null($timeZone)) { - $timeZone = new \DateTimeZone('UTC'); - } + $timeZone ??= new \DateTimeZone('UTC'); $this->setTimeZone($timeZone); } diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 42862cd8b..19de8b16b 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -609,9 +609,7 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo, // We're adding PARTSTAT=NEEDS-ACTION to ensure that // iOS shows an "Inbox Item" - if (!isset($currentEventAttendee['PARTSTAT'])) { - $currentEventAttendee['PARTSTAT'] = 'NEEDS-ACTION'; - } + $currentEventAttendee['PARTSTAT'] ??= 'NEEDS-ACTION'; } } diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index 47fa972ce..1263ced8e 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -418,9 +418,7 @@ protected function readProperty(string $line) } if (isset($match['paramName'])) { $lastParam = strtoupper($match['paramName']); - if (!isset($property['parameters'][$lastParam])) { - $property['parameters'][$lastParam] = null; - } + $property['parameters'][$lastParam] ??= null; $lastToken = self::TOKEN_PARAMNAME; continue; } @@ -440,9 +438,7 @@ protected function readProperty(string $line) // @codeCoverageIgnoreEnd } - if (\is_null($property['value'])) { - $property['value'] = ''; - } + $property['value'] ??= ''; if (!isset($property['name']) || 0 === strlen($property['name'])) { if ($this->options & self::OPTION_IGNORE_INVALID_LINES) { return false; diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php index d0317e14b..5db409350 100644 --- a/lib/Recur/EventIterator.php +++ b/lib/Recur/EventIterator.php @@ -91,9 +91,7 @@ class EventIterator implements \Iterator */ public function __construct($input, ?string $uid = null, ?\DateTimeZone $timeZone = null) { - if (is_null($timeZone)) { - $timeZone = new \DateTimeZone('UTC'); - } + $timeZone ??= new \DateTimeZone('UTC'); $this->timeZone = $timeZone; if (is_array($input)) { diff --git a/lib/TimeZoneUtil.php b/lib/TimeZoneUtil.php index 2cd458578..19333e86a 100644 --- a/lib/TimeZoneUtil.php +++ b/lib/TimeZoneUtil.php @@ -41,9 +41,7 @@ private function __construct() private static function getInstance(): self { - if (null === self::$instance) { - self::$instance = new self(); - } + self::$instance ??= new self(); return self::$instance; }