$error .= "* $ucdallURL\n";
}
- $this->error( $error );
- exit( 1 );
+ $this->fatalError( $error );
}
$debugOutFileName = $this->getOption( 'debug-output' );
if ( $debugOutFileName ) {
$this->debugOutFile = fopen( $debugOutFileName, 'w' );
if ( !$this->debugOutFile ) {
- $this->error( "Unable to open debug output file for writing" );
- exit( 1 );
+ $this->fatalError( "Unable to open debug output file for writing" );
}
}
$this->loadUcd();
function loadUcd() {
$uxr = new UcdXmlReader( "{$this->dataDir}/ucd.all.grouped.xml" );
- $uxr->readChars( array( $this, 'charCallback' ) );
+ $uxr->readChars( [ $this, 'charCallback' ] );
}
function charCallback( $data ) {
function generateFirstChars() {
$file = fopen( "{$this->dataDir}/allkeys.txt", 'r' );
if ( !$file ) {
- $this->error( "Unable to open allkeys.txt" );
- exit( 1 );
+ $this->fatalError( "Unable to open allkeys.txt" );
}
global $IP;
$outFile = fopen( "$IP/serialized/first-letters-root.ser", 'w' );
if ( !$outFile ) {
- $this->error( "Unable to open output file first-letters-root.ser" );
- exit( 1 );
+ $this->fatalError( "Unable to open output file first-letters-root.ser" );
}
- $goodTertiaryChars = array();
+ $goodTertiaryChars = [];
// For each character with an entry in allkeys.txt, overwrite the implicit
// entry in $this->weights that came from the UCD.
fclose( $file );
// Identify groups of characters with the same primary weight
- $this->groups = array();
+ $this->groups = [];
asort( $this->weights, SORT_STRING );
$prevWeight = reset( $this->weights );
- $group = array();
+ $group = [];
foreach ( $this->weights as $cp => $weight ) {
if ( $weight !== $prevWeight ) {
$this->groups[$prevWeight] = $group;
if ( isset( $this->groups[$weight] ) ) {
$group = $this->groups[$weight];
} else {
- $group = array();
+ $group = [];
}
}
$group[] = $cp;
ksort( $this->groups, SORT_STRING );
// Identify the header character in each group
- $headerChars = array();
+ $headerChars = [];
$prevChar = "\000";
$tertiaryCollator = new Collator( 'root' );
$primaryCollator = new Collator( 'root' );
$primaryCollator->setStrength( Collator::PRIMARY );
$numOutOfOrder = 0;
foreach ( $this->groups as $weight => $group ) {
- $uncomposedChars = array();
- $goodChars = array();
+ $uncomposedChars = [];
+ $goodChars = [];
foreach ( $group as $cp ) {
if ( isset( $goodTertiaryChars[$cp] ) ) {
$goodChars[] = $cp;
$headerChars[] = $char;
if ( $primaryCollator->compare( $char, $prevChar ) <= 0 ) {
$numOutOfOrder++;
- /*
- printf( "Out of order: U+%05X > U+%05X\n",
- utf8ToCodepoint( $prevChar ),
- utf8ToCodepoint( $char ) );
- */
}
$prevChar = $char;
public $callback;
public $groupAttrs;
public $xml;
- public $blocks = array();
+ public $blocks = [];
public $currentBlock;
function __construct( $fileName ) {
}
} elseif ( $xml->nodeType === XMLReader::END_ELEMENT ) {
if ( $xml->name === 'group' ) {
- $this->groupAttrs = array();
+ $this->groupAttrs = [];
}
}
}
* @return array
*/
protected function readAttributes() {
- $attrs = array();
+ $attrs = [];
while ( $this->xml->moveToNextAttribute() ) {
$attrs[$this->xml->name] = $this->xml->value;
}
for ( $cp = $first; $cp <= $last; $cp++ ) {
$hexCp = sprintf( "%04X", $cp );
- foreach ( array( 'na', 'na1' ) as $nameProp ) {
+ foreach ( [ 'na', 'na1' ] as $nameProp ) {
if ( isset( $attrs[$nameProp] ) ) {
$attrs[$nameProp] = str_replace( '#', $hexCp, $attrs[$nameProp] );
}
$attrs = $this->readAttributes();
$first = hexdec( $attrs['first-cp'] );
$last = hexdec( $attrs['last-cp'] );
- $this->blocks[$attrs['name']] = array( $first, $last );
+ $this->blocks[$attrs['name']] = [ $first, $last ];
}
}
}
}
}
-$maintClass = 'GenerateCollationData';
+$maintClass = GenerateCollationData::class;
require_once RUN_MAINTENANCE_IF_MAIN;