@@ -270,7 +270,7 @@ public function cleanupMerge()
270270 }
271271 }
272272
273- if ($ diffs [count ($ diffs ) - 1 ][1 ] == '' ) {
273+ if ($ diffs [count ($ diffs ) - 1 ][1 ] === '' ) {
274274 array_pop ($ diffs );
275275 }
276276
@@ -283,13 +283,13 @@ public function cleanupMerge()
283283 while ($ pointer < count ($ diffs ) - 1 ) {
284284 if ($ diffs [$ pointer - 1 ][0 ] == self ::EQUAL && $ diffs [$ pointer + 1 ][0 ] == self ::EQUAL ) {
285285 // This is a single edit surrounded by equalities.
286- if (mb_substr ($ diffs [$ pointer ][1 ], -mb_strlen ($ diffs [$ pointer - 1 ][1 ])) == $ diffs [$ pointer - 1 ][1 ]) {
286+ if (mb_substr ($ diffs [$ pointer ][1 ], -mb_strlen ($ diffs [$ pointer - 1 ][1 ])) === $ diffs [$ pointer - 1 ][1 ]) {
287287 // Shift the edit over the previous equality.
288288 $ diffs [$ pointer ][1 ] = $ diffs [$ pointer - 1 ][1 ] . mb_substr ($ diffs [$ pointer ][1 ], 0 , -mb_strlen ($ diffs [$ pointer - 1 ][1 ]));
289289 $ diffs [$ pointer + 1 ][1 ] = $ diffs [$ pointer - 1 ][1 ] . $ diffs [$ pointer + 1 ][1 ];
290290 array_splice ($ diffs , $ pointer - 1 , 1 );
291291 $ changes = true ;
292- } elseif (mb_substr ($ diffs [$ pointer ][1 ], 0 , mb_strlen ($ diffs [$ pointer + 1 ][1 ])) == $ diffs [$ pointer + 1 ][1 ]) {
292+ } elseif (mb_substr ($ diffs [$ pointer ][1 ], 0 , mb_strlen ($ diffs [$ pointer + 1 ][1 ])) === $ diffs [$ pointer + 1 ][1 ]) {
293293 // Shift the edit over the next equality.
294294 $ diffs [$ pointer - 1 ][1 ] = $ diffs [$ pointer - 1 ][1 ] . $ diffs [$ pointer + 1 ][1 ];
295295 $ diffs [$ pointer ][1 ] = mb_substr ($ diffs [$ pointer ][1 ], mb_strlen ($ diffs [$ pointer + 1 ][1 ])) . $ diffs [$ pointer + 1 ][1 ];
@@ -343,7 +343,7 @@ public function cleanupSemanticLossless()
343343 $ bestEdit = $ edit ;
344344 $ bestEquality2 = $ equality2 ;
345345 $ bestScore = $ this ->cleanupSemanticScore ($ equality1 , $ edit ) + $ this ->cleanupSemanticScore ($ edit , $ equality2 );
346- while ($ edit && $ equality2 && mb_substr ($ edit , 0 , 1 ) == mb_substr ($ equality2 , 0 , 1 )) {
346+ while ($ edit && $ equality2 && mb_substr ($ edit , 0 , 1 ) === mb_substr ($ equality2 , 0 , 1 )) {
347347 $ equality1 .= mb_substr ($ edit , 0 , 1 );
348348 $ edit = mb_substr ($ edit , 1 ) . mb_substr ($ equality2 , 0 , 1 );
349349 $ equality2 = mb_substr ($ equality2 , 1 );
@@ -356,16 +356,16 @@ public function cleanupSemanticLossless()
356356 $ bestEquality2 = $ equality2 ;
357357 }
358358 }
359- if ($ diffs [$ pointer - 1 ][1 ] != $ bestEquality1 ) {
359+ if ($ diffs [$ pointer - 1 ][1 ] !== $ bestEquality1 ) {
360360 // We have an improvement, save it back to the diff.
361- if ($ bestEquality1 != '' ) {
361+ if ($ bestEquality1 !== '' ) {
362362 $ diffs [$ pointer - 1 ][1 ] = $ bestEquality1 ;
363363 } else {
364364 array_splice ($ diffs , $ pointer - 1 , 1 );
365365 $ pointer -= 1 ;
366366 }
367367 $ diffs [$ pointer ][1 ] = $ bestEdit ;
368- if ($ bestEquality2 != '' ) {
368+ if ($ bestEquality2 !== '' ) {
369369 $ diffs [$ pointer + 1 ][1 ] = $ bestEquality2 ;
370370 } else {
371371 array_splice ($ diffs , $ pointer + 1 , 1 );
@@ -391,7 +391,7 @@ public function cleanupSemanticLossless()
391391 */
392392 protected function cleanupSemanticScore ($ one , $ two )
393393 {
394- if ($ one == '' || $ two == '' ) {
394+ if ($ one === '' || $ two = == '' ) {
395395 // Edges are the best.
396396 return 6 ;
397397 }
@@ -472,7 +472,7 @@ public function cleanupSemantic()
472472 }
473473 // Eliminate an equality that is smaller or equal to the edits on both sides of it.
474474 if (
475- $ lastequality != '' &&
475+ $ lastequality !== null &&
476476 mb_strlen ($ lastequality ) <= max ($ length_insertions1 , $ length_deletions1 ) &&
477477 mb_strlen ($ lastequality ) <= max ($ length_insertions2 , $ length_deletions2 )
478478 ) {
@@ -623,7 +623,7 @@ public function cleanupEfficiency() {
623623 // <ins>A</ins><del>B</del>X<del>C</del>
624624 // TODO refactor condition
625625 if (
626- $ lastequality != '' &&
626+ $ lastequality !== null &&
627627 (
628628 ($ pre_ins && $ pre_del && $ post_ins && $ post_del ) ||
629629 (
@@ -797,7 +797,7 @@ public function fromDelta($text1, $delta)
797797 $ pointer = 0 ;
798798 $ tokens = explode ("\t" , $ delta );
799799 foreach ($ tokens as $ token ) {
800- if ($ token == '' ) {
800+ if ($ token === '' ) {
801801 // Blank tokens are ok (from a trailing \t).
802802 continue ;
803803 }
@@ -824,7 +824,7 @@ public function fromDelta($text1, $delta)
824824 $ text = mb_substr ($ text1 , $ pointer , $ n );
825825 $ pointer += $ n ;
826826 $ diffs [] = array (
827- $ op == '= ' ? self ::EQUAL : self ::DELETE ,
827+ $ op === '= ' ? self ::EQUAL : self ::DELETE ,
828828 $ text ,
829829 );
830830 break ;
@@ -954,8 +954,8 @@ public function main($text1, $text2, $checklines = true, $deadline = null)
954954 }
955955
956956 // Check for equality (speedup).
957- if ($ text1 == $ text2 ) {
958- if ($ text1 != '' ) {
957+ if ($ text1 === $ text2 ) {
958+ if ($ text1 !== '' ) {
959959 $ this ->setChanges (array (
960960 array (self ::EQUAL , $ text1 ),
961961 ));
@@ -966,7 +966,7 @@ public function main($text1, $text2, $checklines = true, $deadline = null)
966966
967967 $ prevInternalEncoding = mb_internal_encoding ();
968968 $ newInternalEncoding = 'UCS-2LE ' ;
969- if ($ prevInternalEncoding != $ newInternalEncoding ) {
969+ if ($ prevInternalEncoding !== $ newInternalEncoding ) {
970970 $ errorReportingLevel = error_reporting ();
971971 error_reporting ($ errorReportingLevel & ~E_NOTICE );
972972
@@ -1011,14 +1011,14 @@ public function main($text1, $text2, $checklines = true, $deadline = null)
10111011 $ diffs = $ this ->compute ($ text1 , $ text2 , $ checklines , $ deadline );
10121012
10131013 // Restore the prefix and suffix.
1014- if ($ commonPrefix != '' ) {
1014+ if ($ commonPrefix !== '' ) {
10151015 array_unshift ($ diffs , array (self ::EQUAL , $ commonPrefix ));
10161016 }
1017- if ($ commonSuffix != '' ) {
1017+ if ($ commonSuffix !== '' ) {
10181018 array_push ($ diffs , array (self ::EQUAL , $ commonSuffix ));
10191019 }
10201020
1021- if ($ newInternalEncoding != $ prevInternalEncoding ) {
1021+ if ($ newInternalEncoding !== $ prevInternalEncoding ) {
10221022 mb_internal_encoding ($ prevInternalEncoding );
10231023 foreach ($ diffs as &$ change ) {
10241024 $ change [1 ] = iconv ($ newInternalEncoding , $ prevInternalEncoding , $ change [1 ]);
@@ -1048,14 +1048,14 @@ public function main($text1, $text2, $checklines = true, $deadline = null)
10481048 */
10491049 protected function compute ($ text1 , $ text2 , $ checklines , $ deadline )
10501050 {
1051- if ($ text1 == '' ) {
1051+ if ($ text1 === '' ) {
10521052 // Just add some text (speedup).
10531053 return array (
10541054 array (self ::INSERT , $ text2 ),
10551055 );
10561056 }
10571057
1058- if ($ text2 == '' ) {
1058+ if ($ text2 === '' ) {
10591059 // Just delete some text (speedup).
10601060 return array (
10611061 array (self ::DELETE , $ text1 ),
@@ -1248,7 +1248,7 @@ protected function bisect($text1, $text2, $deadline)
12481248 $ x1 = $ v1 [$ k1Offset - 1 ] + 1 ;
12491249 }
12501250 $ y1 = $ x1 - $ k1 ;
1251- while ($ x1 < $ text1Length && $ y1 < $ text2Length && mb_substr ($ text1 , $ x1 , 1 ) == mb_substr ($ text2 , $ y1 , 1 )) {
1251+ while ($ x1 < $ text1Length && $ y1 < $ text2Length && mb_substr ($ text1 , $ x1 , 1 ) === mb_substr ($ text2 , $ y1 , 1 )) {
12521252 $ x1 ++;
12531253 $ y1 ++;
12541254 }
@@ -1281,7 +1281,7 @@ protected function bisect($text1, $text2, $deadline)
12811281 $ x2 = $ v2 [$ k2Offset - 1 ] + 1 ;
12821282 }
12831283 $ y2 = $ x2 - $ k2 ;
1284- while ($ x2 < $ text1Length && $ y2 < $ text2Length && mb_substr ($ text1 , -$ x2 - 1 , 1 ) == mb_substr ($ text2 , -$ y2 - 1 , 1 )) {
1284+ while ($ x2 < $ text1Length && $ y2 < $ text2Length && mb_substr ($ text1 , -$ x2 - 1 , 1 ) === mb_substr ($ text2 , -$ y2 - 1 , 1 )) {
12851285 $ x2 ++;
12861286 $ y2 ++;
12871287 }
0 commit comments