Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 deprecated support for null values in its APIs #561

Merged
merged 10 commits into from
Aug 17, 2022
2 changes: 1 addition & 1 deletion lib/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ protected function convert($vObj)
*/
protected function color($vObj)
{
fwrite($this->stdout, $this->serializeComponent($vObj));
$this->serializeComponent($vObj);
phil-davis marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
16 changes: 11 additions & 5 deletions lib/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Component extends Node
/**
* A list of properties and/or sub-components.
*
* @var array
* @var array<string, Component|Property>
*/
protected $children = [];

Expand All @@ -43,12 +43,12 @@ 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 string $name such as VCALENDAR, VEVENT
* @param bool $defaults
* @param string|null $name such as VCALENDAR, VEVENT
* @param bool $defaults
*/
public function __construct(Document $root, $name, array $children = [], $defaults = true)
{
$this->name = strtoupper($name);
$this->name = isset($name) ? strtoupper($name) : '';
$this->root = $root;

if ($defaults) {
Expand Down Expand Up @@ -238,7 +238,13 @@ public function select($name)
return array_filter(
$result,
function ($child) use ($group) {
return $child instanceof Property && strtoupper($child->group) === $group;
if ($child instanceof Property) {
$cgroup = isset($child->group) ? strtoupper($child->group) : '';

return $cgroup === $group;
}

return false;
phil-davis marked this conversation as resolved.
Show resolved Hide resolved
}
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ class Parameter extends Node
*/
public function __construct(Document $root, $name, $value = null)
{
$this->name = strtoupper($name);
$this->root = $root;
if (is_null($name)) {
$this->noName = true;
$this->name = static::guessParameterNameByValue($value);
} else {
$this->name = strtoupper($name);
}

// If guessParameterNameByValue() returns an empty string
Expand Down
2 changes: 1 addition & 1 deletion lib/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class Property extends Node
*
* This is only used in vcards
*
* @var string
* @var string|null
*/
public $group;

Expand Down
22 changes: 12 additions & 10 deletions lib/Property/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,18 @@ public function getRawMimeDirValue()
}

foreach ($item as &$subItem) {
$subItem = strtr(
$subItem,
[
'\\' => '\\\\',
';' => '\;',
',' => '\,',
"\n" => '\n',
"\r" => '',
]
);
if (!is_null($subItem)) {
$subItem = strtr(
$subItem,
[
'\\' => '\\\\',
';' => '\;',
',' => '\,',
"\n" => '\n',
"\r" => '',
]
);
}
}
$item = implode(',', $item);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
failOnWarning="true"
enforceTimeLimit="true"
>
<php>
<ini name="error_reporting" value="E_ALL"/>
</php>
<testsuites>
<testsuite name="Sabre\VObject">
<directory>.</directory>
Expand Down