88 */
99class File implements Source
1010{
11-
1211 private static $ minHyphens = null ;
1312 private $ path = null ;
1413 private $ language = null ;
@@ -48,20 +47,20 @@ public function getMinHyphens()
4847 private function loadLanguage ()
4948 {
5049 if (!$ this ->loaded ) {
51- $ this ->patterns = array () ;
50+ $ this ->patterns = [] ;
5251 $ this ->max_pattern_length = 0 ;
53- $ this ->hyphenations = array () ;
52+ $ this ->hyphenations = [] ;
5453
5554 // parser state
56- $ command = FALSE ;
57- $ braces = FALSE ;
55+ $ command = false ;
56+ $ braces = false ;
5857
5958 // parse .tex file
6059 foreach (file ("{$ this ->path }/hyph- {$ this ->language }.tex " ) as $ line ) {
6160 $ offset = 0 ;
6261 $ strlen_line = mb_strlen ($ line );
6362 while ($ offset < $ strlen_line ) {
64- $ char = $ line{ $ offset} ;
63+ $ char = $ line[ $ offset] ;
6564
6665 // %comment
6766 if ($ char === '% ' ) {
@@ -77,8 +76,8 @@ private function loadLanguage()
7776
7877 // {
7978 if ($ char === '{ ' ) {
80- $ braces = TRUE ;
81- ++ $ offset ;
79+ $ braces = true ;
80+ $ offset++ ;
8281 continue ; // next token
8382 }
8483
@@ -100,10 +99,10 @@ private function loadLanguage()
10099 $ numbers .= '0 ' ;
101100 }
102101 $ pattern .= $ char ;
103- ++ $ strlen ;
102+ $ strlen++ ;
104103 $ expect_number = true ;
105104 }
106- ++ $ offset ;
105+ $ offset++ ;
107106 }
108107 if ($ expect_number ) {
109108 $ numbers .= '0 ' ;
@@ -114,28 +113,28 @@ private function loadLanguage()
114113 $ this ->max_pattern_length = $ strlen ;
115114 }
116115 }
117- continue 2 ; // next token
116+ continue 3 ; // next token
118117
119118 case 'hyphenation ' :
120119 if (preg_match ('~^\S+~u ' , substr ($ line , $ offset ), $ m ) === 1 ) {
121120 $ hyphenation = preg_replace ('~\-~ ' , '' , $ m [0 ]);
122121 $ this ->hyphenations [$ hyphenation ] = $ m [0 ];
123122 $ offset += strlen ($ m [0 ]);
124123 }
125- continue 2 ; // next token
124+ continue 3 ; // next token
126125 }
127126 }
128127
129128 // }
130129 if ($ char === '} ' ) {
131- $ braces = FALSE ;
132- $ command = FALSE ;
133- ++ $ offset ;
130+ $ braces = false ;
131+ $ command = false ;
132+ $ offset++ ;
134133 continue ; // next token
135134 }
136135
137136 // ignorable content, skip one char
138- ++ $ offset ;
137+ $ offset++ ;
139138 }
140139 }
141140
@@ -146,19 +145,21 @@ private function loadLanguage()
146145 public function getHyphentations ()
147146 {
148147 $ this ->loadLanguage ();
148+
149149 return $ this ->hyphenations ;
150150 }
151151
152152 public function getMaxPattern ()
153153 {
154154 $ this ->loadLanguage ();
155+
155156 return $ this ->max_pattern_length ;
156157 }
157158
158159 public function getPatterns ()
159160 {
160161 $ this ->loadLanguage ();
162+
161163 return $ this ->patterns ;
162164 }
163-
164165}
0 commit comments