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 26, 2022
1 parent 0c4b347 commit c08a536
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
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
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
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
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 c08a536

Please sign in to comment.