Skip to content

Commit

Permalink
Refactored fqcn strings to ::class to allow checking with phpstan (sa…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVanOort authored and bcaller committed Jul 27, 2020
1 parent 0722b48 commit 5de8d25
Show file tree
Hide file tree
Showing 33 changed files with 234 additions and 220 deletions.
152 changes: 76 additions & 76 deletions lib/Component/VCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class VCalendar extends VObject\Document
* @var array
*/
public static $componentMap = [
'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar',
'VALARM' => 'Sabre\\VObject\\Component\\VAlarm',
'VEVENT' => 'Sabre\\VObject\\Component\\VEvent',
'VFREEBUSY' => 'Sabre\\VObject\\Component\\VFreeBusy',
'VAVAILABILITY' => 'Sabre\\VObject\\Component\\VAvailability',
'AVAILABLE' => 'Sabre\\VObject\\Component\\Available',
'VJOURNAL' => 'Sabre\\VObject\\Component\\VJournal',
'VTIMEZONE' => 'Sabre\\VObject\\Component\\VTimeZone',
'VTODO' => 'Sabre\\VObject\\Component\\VTodo',
'VCALENDAR' => self::class,
'VALARM' => VAlarm::class,
'VEVENT' => VEvent::class,
'VFREEBUSY' => VFreeBusy::class,
'VAVAILABILITY' => VAvailability::class,
'AVAILABLE' => Available::class,
'VJOURNAL' => VJournal::class,
'VTIMEZONE' => VTimeZone::class,
'VTODO' => VTodo::class,
];

/**
Expand All @@ -54,21 +54,21 @@ class VCalendar extends VObject\Document
* @var array
*/
public static $valueMap = [
'BINARY' => 'Sabre\\VObject\\Property\\Binary',
'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean',
'CAL-ADDRESS' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress',
'DATE' => 'Sabre\\VObject\\Property\\ICalendar\\Date',
'DATE-TIME' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration',
'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue',
'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue',
'PERIOD' => 'Sabre\\VObject\\Property\\ICalendar\\Period',
'RECUR' => 'Sabre\\VObject\\Property\\ICalendar\\Recur',
'TEXT' => 'Sabre\\VObject\\Property\\Text',
'TIME' => 'Sabre\\VObject\\Property\\Time',
'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only.
'URI' => 'Sabre\\VObject\\Property\\Uri',
'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset',
'BINARY' => VObject\Property\Binary::class,
'BOOLEAN' => VObject\Property\Boolean::class,
'CAL-ADDRESS' => VObject\Property\ICalendar\CalAddress::class,
'DATE' => VObject\Property\ICalendar\Date::class,
'DATE-TIME' => VObject\Property\ICalendar\DateTime::class,
'DURATION' => VObject\Property\ICalendar\Duration::class,
'FLOAT' => VObject\Property\FloatValue::class,
'INTEGER' => VObject\Property\IntegerValue::class,
'PERIOD' => VObject\Property\ICalendar\Period::class,
'RECUR' => VObject\Property\ICalendar\Recur::class,
'TEXT' => VObject\Property\Text::class,
'TIME' => VObject\Property\Time::class,
'UNKNOWN' => VObject\Property\Unknown::class, // jCard / jCal-only.
'URI' => VObject\Property\Uri::class,
'UTC-OFFSET' => VObject\Property\UtcOffset::class,
];

/**
Expand All @@ -78,78 +78,78 @@ class VCalendar extends VObject\Document
*/
public static $propertyMap = [
// Calendar properties
'CALSCALE' => 'Sabre\\VObject\\Property\\FlatText',
'METHOD' => 'Sabre\\VObject\\Property\\FlatText',
'PRODID' => 'Sabre\\VObject\\Property\\FlatText',
'VERSION' => 'Sabre\\VObject\\Property\\FlatText',
'CALSCALE' => VObject\Property\FlatText::class,
'METHOD' => VObject\Property\FlatText::class,
'PRODID' => VObject\Property\FlatText::class,
'VERSION' => VObject\Property\FlatText::class,

// Component properties
'ATTACH' => 'Sabre\\VObject\\Property\\Uri',
'CATEGORIES' => 'Sabre\\VObject\\Property\\Text',
'CLASS' => 'Sabre\\VObject\\Property\\FlatText',
'COMMENT' => 'Sabre\\VObject\\Property\\FlatText',
'DESCRIPTION' => 'Sabre\\VObject\\Property\\FlatText',
'GEO' => 'Sabre\\VObject\\Property\\FloatValue',
'LOCATION' => 'Sabre\\VObject\\Property\\FlatText',
'PERCENT-COMPLETE' => 'Sabre\\VObject\\Property\\IntegerValue',
'PRIORITY' => 'Sabre\\VObject\\Property\\IntegerValue',
'RESOURCES' => 'Sabre\\VObject\\Property\\Text',
'STATUS' => 'Sabre\\VObject\\Property\\FlatText',
'SUMMARY' => 'Sabre\\VObject\\Property\\FlatText',
'ATTACH' => VObject\Property\Uri::class,
'CATEGORIES' => VObject\Property\Text::class,
'CLASS' => VObject\Property\FlatText::class,
'COMMENT' => VObject\Property\FlatText::class,
'DESCRIPTION' => VObject\Property\FlatText::class,
'GEO' => VObject\Property\FloatValue::class,
'LOCATION' => VObject\Property\FlatText::class,
'PERCENT-COMPLETE' => VObject\Property\IntegerValue::class,
'PRIORITY' => VObject\Property\IntegerValue::class,
'RESOURCES' => VObject\Property\Text::class,
'STATUS' => VObject\Property\FlatText::class,
'SUMMARY' => VObject\Property\FlatText::class,

// Date and Time Component Properties
'COMPLETED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'DTEND' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'DUE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'DTSTART' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'DURATION' => 'Sabre\\VObject\\Property\\ICalendar\\Duration',
'FREEBUSY' => 'Sabre\\VObject\\Property\\ICalendar\\Period',
'TRANSP' => 'Sabre\\VObject\\Property\\FlatText',
'COMPLETED' => VObject\Property\ICalendar\DateTime::class,
'DTEND' => VObject\Property\ICalendar\DateTime::class,
'DUE' => VObject\Property\ICalendar\DateTime::class,
'DTSTART' => VObject\Property\ICalendar\DateTime::class,
'DURATION' => VObject\Property\ICalendar\Duration::class,
'FREEBUSY' => VObject\Property\ICalendar\Period::class,
'TRANSP' => VObject\Property\FlatText::class,

// Time Zone Component Properties
'TZID' => 'Sabre\\VObject\\Property\\FlatText',
'TZNAME' => 'Sabre\\VObject\\Property\\FlatText',
'TZOFFSETFROM' => 'Sabre\\VObject\\Property\\UtcOffset',
'TZOFFSETTO' => 'Sabre\\VObject\\Property\\UtcOffset',
'TZURL' => 'Sabre\\VObject\\Property\\Uri',
'TZID' => VObject\Property\FlatText::class,
'TZNAME' => VObject\Property\FlatText::class,
'TZOFFSETFROM' => VObject\Property\UtcOffset::class,
'TZOFFSETTO' => VObject\Property\UtcOffset::class,
'TZURL' => VObject\Property\Uri::class,

// Relationship Component Properties
'ATTENDEE' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress',
'CONTACT' => 'Sabre\\VObject\\Property\\FlatText',
'ORGANIZER' => 'Sabre\\VObject\\Property\\ICalendar\\CalAddress',
'RECURRENCE-ID' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'RELATED-TO' => 'Sabre\\VObject\\Property\\FlatText',
'URL' => 'Sabre\\VObject\\Property\\Uri',
'UID' => 'Sabre\\VObject\\Property\\FlatText',
'ATTENDEE' => VObject\Property\ICalendar\CalAddress::class,
'CONTACT' => VObject\Property\FlatText::class,
'ORGANIZER' => VObject\Property\ICalendar\CalAddress::class,
'RECURRENCE-ID' => VObject\Property\ICalendar\DateTime::class,
'RELATED-TO' => VObject\Property\FlatText::class,
'URL' => VObject\Property\Uri::class,
'UID' => VObject\Property\FlatText::class,

// Recurrence Component Properties
'EXDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'RDATE' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'RRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur',
'EXRULE' => 'Sabre\\VObject\\Property\\ICalendar\\Recur', // Deprecated since rfc5545
'EXDATE' => VObject\Property\ICalendar\DateTime::class,
'RDATE' => VObject\Property\ICalendar\DateTime::class,
'RRULE' => VObject\Property\ICalendar\Recur::class,
'EXRULE' => VObject\Property\ICalendar\Recur::class, // Deprecated since rfc5545

// Alarm Component Properties
'ACTION' => 'Sabre\\VObject\\Property\\FlatText',
'REPEAT' => 'Sabre\\VObject\\Property\\IntegerValue',
'TRIGGER' => 'Sabre\\VObject\\Property\\ICalendar\\Duration',
'ACTION' => VObject\Property\FlatText::class,
'REPEAT' => VObject\Property\IntegerValue::class,
'TRIGGER' => VObject\Property\ICalendar\Duration::class,

// Change Management Component Properties
'CREATED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'DTSTAMP' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'LAST-MODIFIED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'SEQUENCE' => 'Sabre\\VObject\\Property\\IntegerValue',
'CREATED' => VObject\Property\ICalendar\DateTime::class,
'DTSTAMP' => VObject\Property\ICalendar\DateTime::class,
'LAST-MODIFIED' => VObject\Property\ICalendar\DateTime::class,
'SEQUENCE' => VObject\Property\IntegerValue::class,

// Request Status
'REQUEST-STATUS' => 'Sabre\\VObject\\Property\\Text',
'REQUEST-STATUS' => VObject\Property\Text::class,

// Additions from draft-daboo-valarm-extensions-04
'ALARM-AGENT' => 'Sabre\\VObject\\Property\\Text',
'ACKNOWLEDGED' => 'Sabre\\VObject\\Property\\ICalendar\\DateTime',
'PROXIMITY' => 'Sabre\\VObject\\Property\\Text',
'DEFAULT-ALARM' => 'Sabre\\VObject\\Property\\Boolean',
'ALARM-AGENT' => VObject\Property\Text::class,
'ACKNOWLEDGED' => VObject\Property\ICalendar\DateTime::class,
'PROXIMITY' => VObject\Property\Text::class,
'DEFAULT-ALARM' => VObject\Property\Boolean::class,

// Additions from draft-daboo-calendar-availability-05
'BUSYTYPE' => 'Sabre\\VObject\\Property\\Text',
'BUSYTYPE' => VObject\Property\Text::class,
];

/**
Expand Down
136 changes: 68 additions & 68 deletions lib/Component/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class VCard extends VObject\Document
* @var array
*/
public static $componentMap = [
'VCARD' => 'Sabre\\VObject\\Component\\VCard',
'VCARD' => VCard::class,
];

/**
Expand All @@ -48,23 +48,23 @@ class VCard extends VObject\Document
* @var array
*/
public static $valueMap = [
'BINARY' => 'Sabre\\VObject\\Property\\Binary',
'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean',
'CONTENT-ID' => 'Sabre\\VObject\\Property\\FlatText', // vCard 2.1 only
'DATE' => 'Sabre\\VObject\\Property\\VCard\\Date',
'DATE-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateTime',
'DATE-AND-OR-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', // vCard only
'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue',
'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue',
'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag',
'PHONE-NUMBER' => 'Sabre\\VObject\\Property\\VCard\\PhoneNumber', // vCard 3.0 only
'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp',
'TEXT' => 'Sabre\\VObject\\Property\\Text',
'TIME' => 'Sabre\\VObject\\Property\\Time',
'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only.
'URI' => 'Sabre\\VObject\\Property\\Uri',
'URL' => 'Sabre\\VObject\\Property\\Uri', // vCard 2.1 only
'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset',
'BINARY' => VObject\Property\Binary::class,
'BOOLEAN' => VObject\Property\Boolean::class,
'CONTENT-ID' => VObject\Property\FlatText::class, // vCard 2.1 only
'DATE' => VObject\Property\VCard\Date::class,
'DATE-TIME' => VObject\Property\VCard\DateTime::class,
'DATE-AND-OR-TIME' => VObject\Property\VCard\DateAndOrTime::class, // vCard only
'FLOAT' => VObject\Property\FloatValue::class,
'INTEGER' => VObject\Property\IntegerValue::class,
'LANGUAGE-TAG' => VObject\Property\VCard\LanguageTag::class,
'PHONE-NUMBER' => VObject\Property\VCard\PhoneNumber::class, // vCard 3.0 only
'TIMESTAMP' => VObject\Property\VCard\TimeStamp::class,
'TEXT' => VObject\Property\Text::class,
'TIME' => VObject\Property\Time::class,
'UNKNOWN' => VObject\Property\Unknown::class, // jCard / jCal-only.
'URI' => VObject\Property\Uri::class,
'URL' => VObject\Property\Uri::class, // vCard 2.1 only
'UTC-OFFSET' => VObject\Property\UtcOffset::class,
];

/**
Expand All @@ -74,68 +74,68 @@ class VCard extends VObject\Document
*/
public static $propertyMap = [
// vCard 2.1 properties and up
'N' => 'Sabre\\VObject\\Property\\Text',
'FN' => 'Sabre\\VObject\\Property\\FlatText',
'PHOTO' => 'Sabre\\VObject\\Property\\Binary',
'BDAY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
'ADR' => 'Sabre\\VObject\\Property\\Text',
'LABEL' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0
'TEL' => 'Sabre\\VObject\\Property\\FlatText',
'EMAIL' => 'Sabre\\VObject\\Property\\FlatText',
'MAILER' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0
'GEO' => 'Sabre\\VObject\\Property\\FlatText',
'TITLE' => 'Sabre\\VObject\\Property\\FlatText',
'ROLE' => 'Sabre\\VObject\\Property\\FlatText',
'LOGO' => 'Sabre\\VObject\\Property\\Binary',
'N' => VObject\Property\Text::class,
'FN' => VObject\Property\FlatText::class,
'PHOTO' => VObject\Property\Binary::class,
'BDAY' => VObject\Property\VCard\DateAndOrTime::class,
'ADR' => VObject\Property\Text::class,
'LABEL' => VObject\Property\FlatText::class, // Removed in vCard 4.0
'TEL' => VObject\Property\FlatText::class,
'EMAIL' => VObject\Property\FlatText::class,
'MAILER' => VObject\Property\FlatText::class, // Removed in vCard 4.0
'GEO' => VObject\Property\FlatText::class,
'TITLE' => VObject\Property\FlatText::class,
'ROLE' => VObject\Property\FlatText::class,
'LOGO' => VObject\Property\Binary::class,
// 'AGENT' => 'Sabre\\VObject\\Property\\', // Todo: is an embedded vCard. Probably rare, so
// not supported at the moment
'ORG' => 'Sabre\\VObject\\Property\\Text',
'NOTE' => 'Sabre\\VObject\\Property\\FlatText',
'REV' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp',
'SOUND' => 'Sabre\\VObject\\Property\\FlatText',
'URL' => 'Sabre\\VObject\\Property\\Uri',
'UID' => 'Sabre\\VObject\\Property\\FlatText',
'VERSION' => 'Sabre\\VObject\\Property\\FlatText',
'KEY' => 'Sabre\\VObject\\Property\\FlatText',
'TZ' => 'Sabre\\VObject\\Property\\Text',
'ORG' => VObject\Property\Text::class,
'NOTE' => VObject\Property\FlatText::class,
'REV' => VObject\Property\VCard\TimeStamp::class,
'SOUND' => VObject\Property\FlatText::class,
'URL' => VObject\Property\Uri::class,
'UID' => VObject\Property\FlatText::class,
'VERSION' => VObject\Property\FlatText::class,
'KEY' => VObject\Property\FlatText::class,
'TZ' => VObject\Property\Text::class,

// vCard 3.0 properties
'CATEGORIES' => 'Sabre\\VObject\\Property\\Text',
'SORT-STRING' => 'Sabre\\VObject\\Property\\FlatText',
'PRODID' => 'Sabre\\VObject\\Property\\FlatText',
'NICKNAME' => 'Sabre\\VObject\\Property\\Text',
'CLASS' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0
'CATEGORIES' => VObject\Property\Text::class,
'SORT-STRING' => VObject\Property\FlatText::class,
'PRODID' => VObject\Property\FlatText::class,
'NICKNAME' => VObject\Property\Text::class,
'CLASS' => VObject\Property\FlatText::class, // Removed in vCard 4.0

// rfc2739 properties
'FBURL' => 'Sabre\\VObject\\Property\\Uri',
'CAPURI' => 'Sabre\\VObject\\Property\\Uri',
'CALURI' => 'Sabre\\VObject\\Property\\Uri',
'CALADRURI' => 'Sabre\\VObject\\Property\\Uri',
'FBURL' => VObject\Property\Uri::class,
'CAPURI' => VObject\Property\Uri::class,
'CALURI' => VObject\Property\Uri::class,
'CALADRURI' => VObject\Property\Uri::class,

// rfc4770 properties
'IMPP' => 'Sabre\\VObject\\Property\\Uri',
'IMPP' => VObject\Property\Uri::class,

// vCard 4.0 properties
'SOURCE' => 'Sabre\\VObject\\Property\\Uri',
'XML' => 'Sabre\\VObject\\Property\\FlatText',
'ANNIVERSARY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
'CLIENTPIDMAP' => 'Sabre\\VObject\\Property\\Text',
'LANG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag',
'GENDER' => 'Sabre\\VObject\\Property\\Text',
'KIND' => 'Sabre\\VObject\\Property\\FlatText',
'MEMBER' => 'Sabre\\VObject\\Property\\Uri',
'RELATED' => 'Sabre\\VObject\\Property\\Uri',
'SOURCE' => VObject\Property\Uri::class,
'XML' => VObject\Property\FlatText::class,
'ANNIVERSARY' => VObject\Property\VCard\DateAndOrTime::class,
'CLIENTPIDMAP' => VObject\Property\Text::class,
'LANG' => VObject\Property\VCard\LanguageTag::class,
'GENDER' => VObject\Property\Text::class,
'KIND' => VObject\Property\FlatText::class,
'MEMBER' => VObject\Property\Uri::class,
'RELATED' => VObject\Property\Uri::class,

// rfc6474 properties
'BIRTHPLACE' => 'Sabre\\VObject\\Property\\FlatText',
'DEATHPLACE' => 'Sabre\\VObject\\Property\\FlatText',
'DEATHDATE' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
'BIRTHPLACE' => VObject\Property\FlatText::class,
'DEATHPLACE' => VObject\Property\FlatText::class,
'DEATHDATE' => VObject\Property\VCard\DateAndOrTime::class,

// rfc6715 properties
'EXPERTISE' => 'Sabre\\VObject\\Property\\FlatText',
'HOBBY' => 'Sabre\\VObject\\Property\\FlatText',
'INTEREST' => 'Sabre\\VObject\\Property\\FlatText',
'ORG-DIRECTORY' => 'Sabre\\VObject\\Property\\FlatText',
'EXPERTISE' => VObject\Property\FlatText::class,
'HOBBY' => VObject\Property\FlatText::class,
'INTEREST' => VObject\Property\FlatText::class,
'ORG-DIRECTORY' => VObject\Property\FlatText::class,
];

/**
Expand Down Expand Up @@ -526,8 +526,8 @@ public function getClassNameForPropertyName($propertyName)
$className = parent::getClassNameForPropertyName($propertyName);

// In vCard 4, BINARY no longer exists, and we need URI instead.
if ('Sabre\\VObject\\Property\\Binary' == $className && self::VCARD40 === $this->getDocumentType()) {
return 'Sabre\\VObject\\Property\\Uri';
if (VObject\Property\Binary::class == $className && self::VCARD40 === $this->getDocumentType()) {
return VObject\Property\Uri::class;
}

return $className;
Expand Down
4 changes: 2 additions & 2 deletions lib/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function create($name)
public function createComponent($name, array $children = null, $defaults = true)
{
$name = strtoupper($name);
$class = 'Sabre\\VObject\\Component';
$class = Component::class;

if (isset(static::$componentMap[$name])) {
$class = static::$componentMap[$name];
Expand Down Expand Up @@ -258,7 +258,7 @@ public function getClassNameForPropertyName($propertyName)
if (isset(static::$propertyMap[$propertyName])) {
return static::$propertyMap[$propertyName];
} else {
return 'Sabre\\VObject\\Property\\Unknown';
return Property\Unknown::class;
}
}
}
Loading

0 comments on commit 5de8d25

Please sign in to comment.