diff --git a/lib/Component.php b/lib/Component.php index f33b628a..c1a63258 100644 --- a/lib/Component.php +++ b/lib/Component.php @@ -212,14 +212,14 @@ public function getComponents() * string ("HOME.EMAIL"). If you want to search on a specific property that * has not been assigned a group, specify ".EMAIL". * - * @param string $name + * @param string|null $name * * @return array */ public function select($name) { $group = null; - $name = strtoupper($name); + $name = is_null($name) ? '' : strtoupper($name); if (false !== strpos($name, '.')) { list($group, $name) = explode('.', $name, 2); } @@ -238,7 +238,7 @@ public function select($name) return array_filter( $result, function ($child) use ($group) { - return $child instanceof Property && strtoupper($child->group) === $group; + return $child instanceof Property && strtoupper($child->group ?? '') === $group; } ); } @@ -249,7 +249,7 @@ function ($child) use ($group) { $result = []; foreach ($this->children as $childGroup) { foreach ($childGroup as $child) { - if ($child instanceof Property && strtoupper($child->group) === $group) { + if ($child instanceof Property && $child->group && strtoupper($child->group) === $group) { $result[] = $child; } } diff --git a/lib/Parameter.php b/lib/Parameter.php index 7e4d5574..5df6238e 100644 --- a/lib/Parameter.php +++ b/lib/Parameter.php @@ -47,12 +47,12 @@ class Parameter extends Node * * It's recommended to use the create:: factory method instead. * - * @param string $name + * @param string|null $name * @param string $value */ public function __construct(Document $root, $name, $value = null) { - $this->name = strtoupper($name); + $this->name = is_null($name) ? '' : strtoupper($name); $this->root = $root; if (is_null($name)) { $this->noName = true; diff --git a/lib/Property.php b/lib/Property.php index 50cda968..56096daf 100644 --- a/lib/Property.php +++ b/lib/Property.php @@ -30,7 +30,7 @@ abstract class Property extends Node * * This is only used in vcards * - * @var string + * @var string|null */ public $group;