$to = trim( $v[1] );
$v = trim( $v[0] );
$u = explode( '=>', $v, 2 );
+ $vv = $this->mConverter->validateVariant( $v );
// if $to is empty (which is also used as $from in bidtable),
// strtr() could return a wrong result.
- if ( count( $u ) == 1 && $to !== '' && in_array( $v, $variants ) ) {
- $bidtable[$v] = $to;
+ if ( count( $u ) == 1 && $to !== '' && $vv ) {
+ $bidtable[$vv] = $to;
} elseif ( count( $u ) == 2 ) {
$from = trim( $u[0] );
$v = trim( $u[1] );
+ $vv = $this->mConverter->validateVariant( $v );
// if $from is empty, strtr() could return a wrong result.
- if ( array_key_exists( $v, $unidtable )
- && !is_array( $unidtable[$v] )
+ if ( array_key_exists( $vv, $unidtable )
+ && !is_array( $unidtable[$vv] )
&& $from !== ''
- && in_array( $v, $variants ) ) {
- $unidtable[$v] = [ $from => $to ];
- } elseif ( $from !== '' && in_array( $v, $variants ) ) {
- $unidtable[$v][$from] = $to;
+ && $vv ) {
+ $unidtable[$vv] = [ $from => $to ];
+ } elseif ( $from !== '' && $vv ) {
+ $unidtable[$vv][$from] = $to;
}
}
// syntax error, pass
- if ( !isset( $this->mConverter->mVariantNames[$v] ) ) {
+ if ( !isset( $this->mConverter->mVariantNames[$vv] ) ) {
$bidtable = [];
$unidtable = [];
break;
case 'N':
// process N flag: output current variant name
$ruleVar = trim( $rules );
- if ( isset( $this->mConverter->mVariantNames[$ruleVar] ) ) {
- $this->mRuleDisplay = $this->mConverter->mVariantNames[$ruleVar];
- } else {
- $this->mRuleDisplay = '';
- }
+ $this->mRuleDisplay = $this->mConverter->mVariantNames[$ruleVar] ?? '';
break;
case 'D':
// process D flag: output rules description