Skip to content

Commit

Permalink
Move public string 'name' into Node
Browse files Browse the repository at this point in the history
All of Component, Parameter and Property have 'name'.

Moving it into Node helps phpstan to understand that 'name' always exists.
  • Loading branch information
phil-davis committed Sep 14, 2022
1 parent ec86e75 commit 98b5190
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
11 changes: 3 additions & 8 deletions lib/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@
*/
class Component extends Node
{
/**
* Component name.
*
* This will contain a string such as VEVENT, VTODO, VCALENDAR, VCARD.
*/
public string $name;

/**
* A list of properties and/or sub-components.
*
* @var array<string, Component<int, mixed>|Property<int, mixed>>
* ToDo: maybe be more specific array<string, Component<int, mixed>|Property<int, mixed>>
*
* @var array<string, array<int, mixed>>
*/
protected array $children = [];

Expand Down
9 changes: 9 additions & 0 deletions lib/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ abstract class Node implements \IteratorAggregate, \ArrayAccess, \Countable, \Js
*/
protected ?Component $root;

/**
* Name of the item (a Component or Parameter or Property).
*
* This will contain a component name such as VEVENT, VTODO, VCALENDAR, VCARD.
* Or a parameter name (vCard 2.1 allows parameters to be encoded without a name)
* Or a property name such as DTSTART, SUMMARY, FN.
*/
public ?string $name;

/**
* Serializes the node into a mimedir format.
*/
Expand Down
5 changes: 0 additions & 5 deletions lib/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
*/
class Parameter extends Node
{
/**
* Parameter name.
*/
public string $name;

/**
* vCard 2.1 allows parameters to be encoded without a name.
*
Expand Down
7 changes: 0 additions & 7 deletions lib/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ abstract class Property extends Node
*/
public ?Component $root;

/**
* Property name.
*
* This will contain a string such as DTSTART, SUMMARY, FN.
*/
public ?string $name;

/**
* Property group.
*
Expand Down

0 comments on commit 98b5190

Please sign in to comment.