Skip to content

Commit 98b5190

Browse files
committed
Move public string 'name' into Node
All of Component, Parameter and Property have 'name'. Moving it into Node helps phpstan to understand that 'name' always exists.
1 parent ec86e75 commit 98b5190

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

lib/Component.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@
2222
*/
2323
class Component extends Node
2424
{
25-
/**
26-
* Component name.
27-
*
28-
* This will contain a string such as VEVENT, VTODO, VCALENDAR, VCARD.
29-
*/
30-
public string $name;
31-
3225
/**
3326
* A list of properties and/or sub-components.
3427
*
35-
* @var array<string, Component<int, mixed>|Property<int, mixed>>
28+
* ToDo: maybe be more specific array<string, Component<int, mixed>|Property<int, mixed>>
29+
*
30+
* @var array<string, array<int, mixed>>
3631
*/
3732
protected array $children = [];
3833

lib/Node.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ abstract class Node implements \IteratorAggregate, \ArrayAccess, \Countable, \Js
5454
*/
5555
protected ?Component $root;
5656

57+
/**
58+
* Name of the item (a Component or Parameter or Property).
59+
*
60+
* This will contain a component name such as VEVENT, VTODO, VCALENDAR, VCARD.
61+
* Or a parameter name (vCard 2.1 allows parameters to be encoded without a name)
62+
* Or a property name such as DTSTART, SUMMARY, FN.
63+
*/
64+
public ?string $name;
65+
5766
/**
5867
* Serializes the node into a mimedir format.
5968
*/

lib/Parameter.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
*/
1919
class Parameter extends Node
2020
{
21-
/**
22-
* Parameter name.
23-
*/
24-
public string $name;
25-
2621
/**
2722
* vCard 2.1 allows parameters to be encoded without a name.
2823
*

lib/Property.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ abstract class Property extends Node
2525
*/
2626
public ?Component $root;
2727

28-
/**
29-
* Property name.
30-
*
31-
* This will contain a string such as DTSTART, SUMMARY, FN.
32-
*/
33-
public ?string $name;
34-
3528
/**
3629
* Property group.
3730
*

0 commit comments

Comments
 (0)