Commit 4e732c87 authored by Matthias Sommerfeld's avatar Matthias Sommerfeld

Fix issues with instantiation of the class and staticness of NamePrepData

parent 21366f25
......@@ -54,18 +54,18 @@ namespace Mso\IdnaConvert;
class IdnaConvert {
const Version = '1.0.1';
const SubVersion = 'dev';
const Version = '1.0.2';
const SubVersion = 'main';
// Internal settings, do not touch!
const PunycodePrefix = 'xn--';
protected $encoding = 'utf8'; // Default input charset is UTF-8
protected $strictMode = false; // Behave strict or not
protected $idnVersion = 2008; // Can be either 2003 (old) or 2008 (default)
protected $idnVersion = '2008'; // Can be either 2003 (old) or 2008 (default)
protected $NamePrepData;
protected $UnicodeTranscoder;
protected $NamePrepData = null;
protected $UnicodeTranscoder = null;
/**
* the constructor
......@@ -92,9 +92,7 @@ class IdnaConvert {
}
}
if (is_null($this->NamePrepData)) {
$this->setIdnVersion($this->idnVersion);
}
$this->setIdnVersion($this->idnVersion);
}
public function getClassVersion()
......@@ -156,7 +154,7 @@ class IdnaConvert {
public function setIdnVersion($idnVersion)
{
if (in_array($idnVersion, ['2003', '2008'])) {
if ($idnVersion != $this->idnVersion) {
if (is_null($this->NamePrepData) || $idnVersion != $this->idnVersion) {
$this->NamePrepData = null; // Ought to destroy the object's reference
// Re-instantiate with different data set
$this->NamePrepData = ($idnVersion == 2003)
......
......@@ -4,17 +4,17 @@ namespace Mso\IdnaConvert;
class NamePrepData implements NamePrepDataInterface
{
public static $mapToNothing = [
public $mapToNothing = [
0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B, 0x200C,
0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07,
0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF
];
public static $generalProhibited = [
public $generalProhibited = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 47, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 127, 0x3002
];
public static $prohibit = [
public $prohibit = [
0xA0, 0x340, 0x341, 0x6DD, 0x70F, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003,
0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x200E, 0x200F,
0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D, 0x202E, 0x202F, 0x205F, 0x206A, 0x206B, 0x206C,
......@@ -23,12 +23,12 @@ class NamePrepData implements NamePrepDataInterface
0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF,
0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xE0001, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF
];
public static $prohibitRanges = [
public $prohibitRanges = [
[0x80, 0x9F], [0x2060, 0x206F], [0x1D173, 0x1D17A],
[0xE000, 0xF8FF], [0xF0000, 0xFFFFD], [0x100000, 0x10FFFD],
[0xFDD0, 0xFDEF], [0xD800, 0xDFFF], [0x2FF0, 0x2FFB], [0xE0020, 0xE007F]
];
public static $replaceMaps = [
public $replaceMaps = [
0x41 => [0x61], 0x42 => [0x62], 0x43 => [0x63],
0x44 => [0x64], 0x45 => [0x65], 0x46 => [0x66],
0x47 => [0x67], 0x48 => [0x68], 0x49 => [0x69],
......@@ -1847,7 +1847,7 @@ class NamePrepData implements NamePrepDataInterface
0x2FA19 => [0x9F05], 0x2FA1A => [0x9F0F], 0x2FA1B => [0x9F16],
0x2FA1C => [0x9F3B], 0x2FA1D => [0x2A600]
];
public static $normalizeCombiningClasses = [
public $normalizeCombiningClasses = [
0x334 => 1, 0x335 => 1, 0x336 => 1, 0x337 => 1,
0x338 => 1, 0x93C => 7, 0x9BC => 7, 0xA3C => 7, 0xABC => 7,
0xB3C => 7, 0xCBC => 7, 0x1037 => 7, 0x3099 => 8, 0x309A => 8,
......
......@@ -4,7 +4,7 @@ namespace Mso\IdnaConvert;
class NamePrepData2003 extends NamePrepData implements NamePrepDataInterface
{
public static $replaceMaps = [
public $replaceMaps = [
0x41 => [0x61], 0x42 => [0x62], 0x43 => [0x63],
0x44 => [0x64], 0x45 => [0x65], 0x46 => [0x66], 0x47 => [0x67],
0x48 => [0x68], 0x49 => [0x69], 0x4A => [0x6A], 0x4B => [0x6B],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment