dev/UpdateCharData.php
Unexpected tabs found. Open
Open
$filepathOut = __DIR__ . '/../src/Debug/Dump/charData.php';
- Exclude checks
Unexpected tabs found. Open
Open
protected $charData = array();
- Exclude checks
Unexpected tabs found. Open
Open
public static function update()
- Exclude checks
Unexpected tabs found. Open
Open
public static $filepathSrc = 'https://www.unicode.org/Public/security/latest/confusables.txt';
- Exclude checks
Unexpected tabs found. Open
Open
\file_put_contents($filepathOut, $php);
- Exclude checks
Unexpected tabs found. Open
Open
/** @var string */
- Exclude checks
Unexpected tabs found. Open
Open
{
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
/**
- Exclude checks
Unexpected tabs found. Open
Open
/**
- Exclude checks
Unexpected tabs found. Open
Open
$php = '<?php // phpcs:ignore SlevomatCodingStandard.Files.FileLength' . "\n\n"
- Exclude checks
Unexpected tabs found. Open
Open
. 'return ' . self::varExportPretty(self::build()) . ";\n";
- Exclude checks
Unexpected tabs found. Open
Open
public static function build()
- Exclude checks
Unexpected tabs found. Open
Open
$rowsNew = require __DIR__ . '/charData.php';
- Exclude checks
Unexpected tabs found. Open
Open
unset($row['charA']);
- Exclude checks
Unexpected tabs found. Open
Open
);
- Exclude checks
Unexpected tabs found. Open
Open
{
- Exclude checks
Unexpected tabs found. Open
Open
$php = \str_replace('\'\' . "\0" . \'\'', '"\x00"', $php);
- Exclude checks
Unexpected tabs found. Open
Open
// not interested in ascii chars that are confusable with other ascii chars
- Exclude checks
Unexpected tabs found. Open
Open
'similarTo' => $row['charB'],
- Exclude checks
Unexpected tabs found. Open
Open
protected static function parseRow($row)
- Exclude checks
Unexpected tabs found. Open
Open
return \preg_replace('/^(00)+/', '', $codePoint);
- Exclude checks
Unexpected tabs found. Open
Open
$parts = \array_merge($parts, $matches);
- Exclude checks
Unexpected tabs found. Open
Open
$codePoint = \hexdec($hex);
- Exclude checks
Unexpected tabs found. Open
Open
'charB' => \implode('', \array_map(static function ($hex) {
- Exclude checks
Unexpected tabs found. Open
Open
$codePoint = \hexdec($hex);
- Exclude checks
Unexpected tabs found. Open
Open
return \mb_chr($codePoint, 'UTF-8');
- Exclude checks
Unexpected tabs found. Open
Open
$php = \preg_replace_callback('/^(\s*)/m', static function ($matches) {
- Exclude checks
Unexpected tabs found. Open
Open
'charADesc' => $parts['charADesc'],
- Exclude checks
Unexpected tabs found. Open
Open
/**
- Exclude checks
Unexpected tabs found. Open
Open
return \strcmp($rowA['charA'], $rowB['charA']);
- Exclude checks
Unexpected tabs found. Open
Open
$rows = \file(self::$filepathSrc);
- Exclude checks
Unexpected tabs found. Open
Open
$isEmptyOrComment = \strlen(\trim($row)) === 0 || $row[0] === '#';
- Exclude checks
Unexpected tabs found. Open
Open
// only interested in chars that are confusable with an ascii char
- Exclude checks
Unexpected tabs found. Open
Open
$isCharAAscii = \strlen($row['charA']) === 1 && \ord($row['charA']) < 0x80;
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
return $rowsNew;
- Exclude checks
Unexpected tabs found. Open
Open
continue;
- Exclude checks
Unexpected tabs found. Open
Open
$rowsNew[$key] = array(
- Exclude checks
Unexpected tabs found. Open
Open
'charA' => \implode('', \array_map(static function ($hex) {
- Exclude checks
Unexpected tabs found. Open
Open
return \mb_chr($codePoint, 'UTF-8');
- Exclude checks
Unexpected tabs found. Open
Open
'isXid' => empty($parts['notXid']),
- Exclude checks
Unexpected tabs found. Open
Open
{
- Exclude checks
Unexpected tabs found. Open
Open
$rows = self::getParsedRows();
- Exclude checks
Unexpected tabs found. Open
Open
\ksort($rowsNew);
- Exclude checks
Unexpected tabs found. Open
Open
});
- Exclude checks
Unexpected tabs found. Open
Open
$parts = \array_map('trim', $parts);
- Exclude checks
Unexpected tabs found. Open
Open
return \preg_replace('/^(00)+/', '', $codePoint);
- Exclude checks
Unexpected tabs found. Open
Open
return \str_repeat($matches[1], 2);
- Exclude checks
Unexpected tabs found. Open
Open
});
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
'desc' => $row['charADesc'],
- Exclude checks
Unexpected tabs found. Open
Open
$php = \preg_replace('/=> \n\s+array/', '=> array', $php);
- Exclude checks
Unexpected tabs found. Open
Open
}, \explode(' ', $parts['charACodePoint'])));
- Exclude checks
Unexpected tabs found. Open
Open
protected static function varExportPretty($val)
- Exclude checks
Unexpected tabs found. Open
Open
foreach ($rows as $row) {
- Exclude checks
Unexpected tabs found. Open
Open
/**
- Exclude checks
Unexpected tabs found. Open
Open
return $isEmptyOrComment === false;
- Exclude checks
Unexpected tabs found. Open
Open
return \array_map(static function ($row) {
- Exclude checks
Unexpected tabs found. Open
Open
$php = \var_export($val, true);
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
$key = $row['charA'];
- Exclude checks
Unexpected tabs found. Open
Open
return self::parseRow($row);
- Exclude checks
Unexpected tabs found. Open
Open
$parts['charBCodePoint'] = \implode(' ', \array_map(static function ($codePoint) {
- Exclude checks
Unexpected tabs found. Open
Open
}, \explode(' ', $parts['charACodePoint']))),
- Exclude checks
Unexpected tabs found. Open
Open
$php = \str_replace('array (', 'array(', $php);
- Exclude checks
Unexpected tabs found. Open
Open
return $isCharAAscii === false && $isCharBAscii;
- Exclude checks
Unexpected tabs found. Open
Open
'codePoint' => $row['charACodePoint'],
- Exclude checks
Unexpected tabs found. Open
Open
}, $rows);
- Exclude checks
Unexpected tabs found. Open
Open
$parts['charACodePoint'] = \implode(' ', \array_map(static function ($codePoint) {
- Exclude checks
Unexpected tabs found. Open
Open
$isCharBAscii = \strlen($row['charB']) === 1 && \ord($row['charB']) < 0x80;
- Exclude checks
Unexpected tabs found. Open
Open
// rekey
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
/**
- Exclude checks
Unexpected tabs found. Open
Open
{
- Exclude checks
Unexpected tabs found. Open
Open
'charACodePoint' => $parts['charACodePoint'],
- Exclude checks
Unexpected tabs found. Open
Open
\usort($rows, static function ($rowA, $rowB) {
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
private static function getParsedRows()
- Exclude checks
Unexpected tabs found. Open
Open
$rows = \array_filter($rows, static function ($row) {
- Exclude checks
Unexpected tabs found. Open
Open
$parts = \array_combine(['charACodePoint', 'charBCodePoint', 'comment'], $parts);
- Exclude checks
Unexpected tabs found. Open
Open
$rows = \array_filter($rows, static function ($row) {
- Exclude checks
Unexpected tabs found. Open
Open
\preg_match('/^(?P<category>\w+)\t#(?P<notXid>\*?)\s*(?P<example>\(.*?\))\s*(?P<charADesc>.*?) → (?P<charBDesc>.*?)(\s+#.*)?$/u', $parts['comment'], $matches);
- Exclude checks
Unexpected tabs found. Open
Open
return array(
- Exclude checks
Unexpected tabs found. Open
Open
$parts = \explode('; ', $row, 3);
- Exclude checks
Unexpected tabs found. Open
Open
}, \explode(' ', $parts['charBCodePoint']))),
- Exclude checks
Unexpected tabs found. Open
Open
);
- Exclude checks
Unexpected tabs found. Open
Open
// remove leading 00 pairs
- Exclude checks
Unexpected tabs found. Open
Open
}
- Exclude checks
Unexpected tabs found. Open
Open
{
- Exclude checks
Unexpected tabs found. Open
Open
}, $php);
- Exclude checks
Unexpected tabs found. Open
Open
});
- Exclude checks
Unexpected tabs found. Open
Open
if (isset($rowsNew[$key])) {
- Exclude checks
Unexpected tabs found. Open
Open
// remove leading 00 pairs
- Exclude checks
Unexpected tabs found. Open
Open
}, \explode(' ', $parts['charBCodePoint'])));
- Exclude checks
Unexpected tabs found. Open
Open
return $php;
- Exclude checks