commit vendor

This commit is contained in:
2025-11-11 14:49:30 +01:00
parent f33121a308
commit 6d03080c00
2436 changed files with 483781 additions and 0 deletions

12
vendor/sabre/vobject/bin/bench.php vendored Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env php
<?php
include __DIR__.'/../vendor/autoload.php';
$data = stream_get_contents(STDIN);
$start = microtime(true);
$lol = Sabre\VObject\Reader::read($data);
echo 'time: '.(microtime(true) - $start)."\n";

View File

@ -0,0 +1,53 @@
<?php
include __DIR__.'/../vendor/autoload.php';
if ($argc < 2) {
echo 'sabre/vobject ', Sabre\VObject\Version::VERSION, " freebusy benchmark\n";
echo "\n";
echo "This script can be used to measure the speed of generating a\n";
echo "free-busy report based on a calendar.\n";
echo "\n";
echo "The process will be repeated 100 times to get accurate stats\n";
echo "\n";
echo 'Usage: '.$argv[0]." inputfile.ics\n";
die();
}
list(, $inputFile) = $argv;
$bench = new Hoa\Bench\Bench();
$bench->parse->start();
$vcal = Sabre\VObject\Reader::read(fopen($inputFile, 'r'));
$bench->parse->stop();
$repeat = 100;
$start = new \DateTime('2000-01-01');
$end = new \DateTime('2020-01-01');
$timeZone = new \DateTimeZone('America/Toronto');
$bench->fb->start();
for ($i = 0; $i < $repeat; ++$i) {
$fb = new Sabre\VObject\FreeBusyGenerator($start, $end, $vcal, $timeZone);
$results = $fb->getResult();
}
$bench->fb->stop();
echo $bench,"\n";
function formatMemory($input)
{
if (strlen($input) > 6) {
return round($input / (1024 * 1024)).'M';
} elseif (strlen($input) > 3) {
return round($input / 1024).'K';
}
}
unset($input, $splitter);
echo 'peak memory usage: '.formatMemory(memory_get_peak_usage()), "\n";
echo 'current memory usage: '.formatMemory(memory_get_usage()), "\n";

View File

@ -0,0 +1,64 @@
<?php
include __DIR__.'/../vendor/autoload.php';
if ($argc < 2) {
echo 'sabre/vobject ', Sabre\VObject\Version::VERSION, " manipulation benchmark\n";
echo "\n";
echo "This script can be used to measure the speed of opening a large amount of\n";
echo "vcards, making a few alterations and serializing them again.\n";
echo 'system.';
echo "\n";
echo 'Usage: '.$argv[0]." inputfile.vcf\n";
die();
}
list(, $inputFile) = $argv;
$input = file_get_contents($inputFile);
$splitter = new Sabre\VObject\Splitter\VCard($input);
$bench = new Hoa\Bench\Bench();
while (true) {
$bench->parse->start();
$vcard = $splitter->getNext();
$bench->parse->pause();
if (!$vcard) {
break;
}
$bench->manipulate->start();
$vcard->{'X-FOO'} = 'Random new value!';
$emails = [];
if (isset($vcard->EMAIL)) {
foreach ($vcard->EMAIL as $email) {
$emails[] = (string) $email;
}
}
$bench->manipulate->pause();
$bench->serialize->start();
$vcard2 = $vcard->serialize();
$bench->serialize->pause();
$vcard->destroy();
}
echo $bench,"\n";
function formatMemory($input)
{
if (strlen($input) > 6) {
return round($input / (1024 * 1024)).'M';
} elseif (strlen($input) > 3) {
return round($input / 1024).'K';
}
}
unset($input, $splitter);
echo 'peak memory usage: '.formatMemory(memory_get_peak_usage()), "\n";
echo 'current memory usage: '.formatMemory(memory_get_usage()), "\n";

View File

@ -0,0 +1,49 @@
#!/usr/bin/env php
<?php
$windowsZonesUrl = 'http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml';
$outputFile = __DIR__.'/../lib/timezonedata/windowszones.php';
echo 'Fetching timezone map from: '.$windowsZonesUrl, "\n";
$data = file_get_contents($windowsZonesUrl);
$xml = simplexml_load_string($data);
$map = [];
foreach ($xml->xpath('//mapZone') as $mapZone) {
$from = (string) $mapZone['other'];
$to = (string) $mapZone['type'];
list($to) = explode(' ', $to, 2);
if (!isset($map[$from])) {
$map[$from] = $to;
}
}
ksort($map);
echo "Writing to: $outputFile\n";
$f = fopen($outputFile, 'w');
fwrite($f, "<?php\n\n");
fwrite($f, "/**\n");
fwrite($f, " * Automatically generated timezone file\n");
fwrite($f, " *\n");
fwrite($f, ' * Last update: '.date(DATE_W3C)."\n");
fwrite($f, ' * Source: '.$windowsZonesUrl."\n");
fwrite($f, " *\n");
fwrite($f, " * @copyright Copyright (C) fruux GmbH (https://fruux.com/).\n");
fwrite($f, " * @license http://sabre.io/license/ Modified BSD License\n");
fwrite($f, " */\n");
fwrite($f, "\n");
fwrite($f, 'return ');
fwrite($f, var_export($map, true).';');
fclose($f);
echo "Formatting\n";
exec(__DIR__.'/sabre-cs-fixer fix '.escapeshellarg($outputFile));
echo "Done\n";

241
vendor/sabre/vobject/bin/generate_vcards vendored Normal file
View File

@ -0,0 +1,241 @@
#!/usr/bin/env php
<?php
namespace Sabre\VObject;
// This sucks.. we have to try to find the composer autoloader. But chances
// are, we can't find it this way. So we'll do our bestest
$paths = [
__DIR__ . '/../vendor/autoload.php', // In case vobject is cloned directly
__DIR__ . '/../../../autoload.php', // In case vobject is a composer dependency.
];
foreach($paths as $path) {
if (file_exists($path)) {
include $path;
break;
}
}
if (!class_exists('Sabre\\VObject\\Version')) {
fwrite(STDERR, "Composer autoloader could not be properly loaded.\n");
die(1);
}
if ($argc < 2) {
$version = Version::VERSION;
$help = <<<HI
sabre/vobject $version
Usage:
generate_vcards [count]
Options:
count The number of random vcards to generate
Examples:
generate_vcards 1000 > testdata.vcf
HI;
fwrite(STDERR, $help);
exit(2);
}
$count = (int)$argv[1];
if ($count < 1) {
fwrite(STDERR, "Count must be at least 1\n");
exit(2);
}
fwrite(STDERR, "sabre/vobject " . Version::VERSION . "\n");
fwrite(STDERR, "Generating " . $count . " vcards in vCard 4.0 format\n");
/**
* The following list is just some random data we compiled from various
* sources online.
*
* Very little thought went into compiling this list, and certainly nothing
* political or ethical.
*
* We would _love_ more additions to this to add more variation to this list.
*
* Send us PR's and don't be shy adding your own first and last name for fun.
*/
$sets = array(
"nl" => array(
"country" => "Netherlands",
"boys" => array(
"Anno",
"Bram",
"Daan",
"Evert",
"Finn",
"Jayden",
"Jens",
"Jesse",
"Levi",
"Lucas",
"Luuk",
"Milan",
"René",
"Sem",
"Sibrand",
"Willem",
),
"girls" => array(
"Celia",
"Emma",
"Fenna",
"Geke",
"Inge",
"Julia",
"Lisa",
"Lotte",
"Mila",
"Sara",
"Sophie",
"Tess",
"Zoë",
),
"last" => array(
"Bakker",
"Bos",
"De Boer",
"De Groot",
"De Jong",
"De Vries",
"Jansen",
"Janssen",
"Meyer",
"Mulder",
"Peters",
"Smit",
"Van Dijk",
"Van den Berg",
"Visser",
"Vos",
),
),
"us" => array(
"country" => "United States",
"boys" => array(
"Aiden",
"Alexander",
"Charles",
"David",
"Ethan",
"Jacob",
"James",
"Jayden",
"John",
"Joseph",
"Liam",
"Mason",
"Michael",
"Noah",
"Richard",
"Robert",
"Thomas",
"William",
),
"girls" => array(
"Ava",
"Barbara",
"Chloe",
"Dorothy",
"Elizabeth",
"Emily",
"Emma",
"Isabella",
"Jennifer",
"Lily",
"Linda",
"Margaret",
"Maria",
"Mary",
"Mia",
"Olivia",
"Patricia",
"Roxy",
"Sophia",
"Susan",
"Zoe",
),
"last" => array(
"Smith",
"Johnson",
"Williams",
"Jones",
"Brown",
"Davis",
"Miller",
"Wilson",
"Moore",
"Taylor",
"Anderson",
"Thomas",
"Jackson",
"White",
"Harris",
"Martin",
"Thompson",
"Garcia",
"Martinez",
"Robinson",
),
),
);
$current = 0;
$r = function($arr) {
return $arr[mt_rand(0,count($arr)-1)];
};
$bdayStart = strtotime('-85 years');
$bdayEnd = strtotime('-20 years');
while($current < $count) {
$current++;
fwrite(STDERR, "\033[100D$current/$count");
$country = array_rand($sets);
$gender = mt_rand(0,1)?'girls':'boys';
$vcard = new Component\VCard(array(
'VERSION' => '4.0',
'FN' => $r($sets[$country][$gender]) . ' ' . $r($sets[$country]['last']),
'UID' => UUIDUtil::getUUID(),
));
$bdayRatio = mt_rand(0,9);
if($bdayRatio < 2) {
// 20% has a birthday property with a full date
$dt = new \DateTime('@' . mt_rand($bdayStart, $bdayEnd));
$vcard->add('BDAY', $dt->format('Ymd'));
} elseif ($bdayRatio < 3) {
// 10% we only know the month and date of
$dt = new \DateTime('@' . mt_rand($bdayStart, $bdayEnd));
$vcard->add('BDAY', '--' . $dt->format('md'));
}
if ($result = $vcard->validate()) {
ob_start();
echo "\nWe produced an invalid vcard somehow!\n";
foreach($result as $message) {
echo " " . $message['message'] . "\n";
}
fwrite(STDERR, ob_get_clean());
}
echo $vcard->serialize();
}
fwrite(STDERR,"\nDone.\n");

View File

@ -0,0 +1,87 @@
#!/usr/bin/env php
<?php
use Sabre\VObject;
if ($argc < 2) {
$cmd = $argv[0];
fwrite(STDERR, <<<HI
Fruux test data generator
This script generates a lot of test data. This is used for profiling and stuff.
Currently it just generates events in a single calendar.
The iCalendar output goes to stdout. Other messages to stderr.
{$cmd} [events]
HI
);
die();
}
$events = 100;
if (isset($argv[1])) {
$events = (int) $argv[1];
}
include __DIR__.'/../vendor/autoload.php';
fwrite(STDERR, 'Generating '.$events." events\n");
$currentDate = new DateTime('-'.round($events / 2).' days');
$calendar = new VObject\Component\VCalendar();
$ii = 0;
while ($ii < $events) {
++$ii;
$event = $calendar->add('VEVENT');
$event->DTSTART = 'bla';
$event->SUMMARY = 'Event #'.$ii;
$event->UID = md5(microtime(true));
$doctorRandom = mt_rand(1, 1000);
switch ($doctorRandom) {
// All-day event
case 1:
$event->DTEND = 'bla';
$dtStart = clone $currentDate;
$dtEnd = clone $currentDate;
$dtEnd->modify('+'.mt_rand(1, 3).' days');
$event->DTSTART->setDateTime($dtStart);
$event->DTSTART['VALUE'] = 'DATE';
$event->DTEND->setDateTime($dtEnd);
break;
case 2:
$event->RRULE = 'FREQ=DAILY;COUNT='.mt_rand(1, 10);
// no break intentional
default:
$dtStart = clone $currentDate;
$dtStart->setTime(mt_rand(1, 23), mt_rand(0, 59), mt_rand(0, 59));
$event->DTSTART->setDateTime($dtStart);
$event->DURATION = 'PT'.mt_rand(1, 3).'H';
break;
}
$currentDate->modify('+ '.mt_rand(0, 3).' days');
}
fwrite(STDERR, "Validating\n");
$result = $calendar->validate();
if ($result) {
fwrite(STDERR, "Errors!\n");
fwrite(STDERR, print_r($result, true));
die(-1);
}
fwrite(STDERR, "Serializing this beast\n");
echo $calendar->serialize();
fwrite(STDERR, "done.\n");

View File

@ -0,0 +1,160 @@
#!/usr/bin/env php
<?php
namespace Sabre\VObject;
// This sucks.. we have to try to find the composer autoloader. But chances
// are, we can't find it this way. So we'll do our bestest
$paths = [
__DIR__.'/../vendor/autoload.php', // In case vobject is cloned directly
__DIR__.'/../../../autoload.php', // In case vobject is a composer dependency.
];
foreach ($paths as $path) {
if (file_exists($path)) {
include $path;
break;
}
}
if (!class_exists('Sabre\\VObject\\Version')) {
fwrite(STDERR, "Composer autoloader could not be loaded.\n");
die(1);
}
echo 'sabre/vobject ', Version::VERSION, " duplicate contact merge tool\n";
if ($argc < 3) {
echo "\n";
echo 'Usage: ', $argv[0], " input.vcf output.vcf [debug.log]\n";
die(1);
}
$input = fopen($argv[1], 'r');
$output = fopen($argv[2], 'w');
$debug = isset($argv[3]) ? fopen($argv[3], 'w') : null;
$splitter = new Splitter\VCard($input);
// The following properties are ignored. If they appear in some vcards
// but not in others, we don't consider them for the sake of finding
// differences.
$ignoredProperties = [
'PRODID',
'VERSION',
'REV',
'UID',
'X-ABLABEL',
];
$collectedNames = [];
$stats = [
'Total vcards' => 0,
'No FN property' => 0,
'Ignored duplicates' => 0,
'Merged values' => 0,
'Error' => 0,
'Unique cards' => 0,
'Total written' => 0,
];
function writeStats()
{
global $stats;
foreach ($stats as $name => $value) {
echo str_pad($name, 23, ' ', STR_PAD_RIGHT), str_pad($value, 6, ' ', STR_PAD_LEFT), "\n";
}
// Moving cursor back a few lines.
echo "\033[".count($stats).'A';
}
function write($vcard)
{
global $stats, $output;
++$stats['Total written'];
fwrite($output, $vcard->serialize()."\n");
}
while ($vcard = $splitter->getNext()) {
++$stats['Total vcards'];
writeStats();
$fn = isset($vcard->FN) ? (string) $vcard->FN : null;
if (empty($fn)) {
// Immediately write this vcard, we don't compare it.
++$stats['No FN property'];
++$stats['Unique cards'];
write($vcard);
$vcard->destroy();
continue;
}
if (!isset($collectedNames[$fn])) {
$collectedNames[$fn] = $vcard;
++$stats['Unique cards'];
continue;
} else {
// Starting comparison for all properties. We only check if properties
// in the current vcard exactly appear in the earlier vcard as well.
foreach ($vcard->children() as $newProp) {
if (in_array($newProp->name, $ignoredProperties)) {
// We don't care about properties such as UID and REV.
continue;
}
$ok = false;
foreach ($collectedNames[$fn]->select($newProp->name) as $compareProp) {
if ($compareProp->serialize() === $newProp->serialize()) {
$ok = true;
break;
}
}
if (!$ok) {
if ('EMAIL' === $newProp->name || 'TEL' === $newProp->name) {
// We're going to make another attempt to find this
// property, this time just by value. If we find it, we
// consider it a success.
foreach ($collectedNames[$fn]->select($newProp->name) as $compareProp) {
if ($compareProp->getValue() === $newProp->getValue()) {
$ok = true;
break;
}
}
if (!$ok) {
// Merging the new value in the old vcard.
$collectedNames[$fn]->add(clone $newProp);
$ok = true;
++$stats['Merged values'];
}
}
}
if (!$ok) {
// echo $newProp->serialize() . " does not appear in earlier vcard!\n";
++$stats['Error'];
if ($debug) {
fwrite($debug, "Missing '".$newProp->name."' property in duplicate. Earlier vcard:\n".$collectedNames[$fn]->serialize()."\n\nLater:\n".$vcard->serialize()."\n\n");
}
$vcard->destroy();
continue 2;
}
}
}
$vcard->destroy();
++$stats['Ignored duplicates'];
}
foreach ($collectedNames as $vcard) {
// Overwriting any old PRODID
$vcard->PRODID = '-//Sabre//Sabre VObject '.Version::VERSION.'//EN';
write($vcard);
writeStats();
}
echo str_repeat("\n", count($stats)), "\nDone.\n";

32
vendor/sabre/vobject/bin/rrulebench.php vendored Normal file
View File

@ -0,0 +1,32 @@
<?php
include __DIR__.'/../vendor/autoload.php';
if ($argc < 4) {
echo 'sabre/vobject ', Sabre\VObject\Version::VERSION, " RRULE benchmark\n";
echo "\n";
echo "This script can be used to measure the speed of the 'recurrence expansion'\n";
echo 'system.';
echo "\n";
echo 'Usage: '.$argv[0]." inputfile.ics startdate enddate\n";
die();
}
list(, $inputFile, $startDate, $endDate) = $argv;
$bench = new Hoa\Bench\Bench();
$bench->parse->start();
echo "Parsing.\n";
$vobj = Sabre\VObject\Reader::read(fopen($inputFile, 'r'));
$bench->parse->stop();
echo "Expanding.\n";
$bench->expand->start();
$vobj->expand(new DateTime($startDate), new DateTime($endDate));
$bench->expand->stop();
echo $bench,"\n";

27
vendor/sabre/vobject/bin/vobject vendored Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env php
<?php
namespace Sabre\VObject;
// This sucks.. we have to try to find the composer autoloader. But chances
// are, we can't find it this way. So we'll do our bestest
$paths = [
__DIR__ . '/../vendor/autoload.php', // In case vobject is cloned directly
__DIR__ . '/../../../autoload.php', // In case vobject is a composer dependency.
];
foreach($paths as $path) {
if (file_exists($path)) {
include $path;
break;
}
}
if (!class_exists('Sabre\\VObject\\Version')) {
fwrite(STDERR, "Composer autoloader could not be loaded.\n");
die(1);
}
$cli = new Cli();
exit($cli->main($argv));