9
9
*
10
10
* PHP version 7.1 or greater
11
11
*
12
- * Copyright (c) 2009 Chris Boulton <[email protected] >
13
- *
14
- * All rights reserved.
15
- *
16
- * Redistribution and use in source and binary forms, with or without
17
- * modification, are permitted provided that the following conditions are met:
18
- *
19
- * - Redistributions of source code must retain the above copyright notice,
20
- * this list of conditions and the following disclaimer.
21
- * - Redistributions in binary form must reproduce the above copyright notice,
22
- * this list of conditions and the following disclaimer in the documentation
23
- * and/or other materials provided with the distribution.
24
- * - Neither the name of the Chris Boulton nor the names of its contributors
25
- * may be used to endorse or promote products derived from this software
26
- * without specific prior written permission.
27
- *
28
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
- * POSSIBILITY OF SUCH DAMAGE.
39
- *
40
12
* @package jblond\Diff\Renderer\Html
41
13
* @author Chris Boulton <[email protected] >
42
14
* @copyright (c) 2009 Chris Boulton
43
15
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
44
- * @version 1.10
16
+ * @version 1.11
45
17
* @link https://github.com/JBlond/php-diff
46
18
*/
47
19
class HtmlArray extends RendererAbstract
@@ -112,11 +84,11 @@ public function renderHtml($changes, $object)
112
84
*/
113
85
public function render ()
114
86
{
115
- // As we'll be modifying a & b to include our change markers,
87
+ // As we'll be modifying old & new to include our change markers,
116
88
// we need to get the contents and store them here. That way
117
89
// we're not going to destroy the original data
118
- $ a = $ this ->diff ->getOld ();
119
- $ b = $ this ->diff ->getNew ();
90
+ $ old = $ this ->diff ->getOld ();
91
+ $ new = $ this ->diff ->getNew ();
120
92
121
93
$ changes = array ();
122
94
$ opCodes = $ this ->diff ->getGroupedOpcodes ();
@@ -129,8 +101,8 @@ public function render()
129
101
130
102
if ($ tag == 'replace ' && $ i2 - $ i1 == $ j2 - $ j1 ) {
131
103
for ($ i = 0 ; $ i < ($ i2 - $ i1 ); ++$ i ) {
132
- $ fromLine = $ a [$ i1 + $ i ];
133
- $ toLine = $ b [$ j1 + $ i ];
104
+ $ fromLine = $ old [$ i1 + $ i ];
105
+ $ toLine = $ new [$ j1 + $ i ];
134
106
135
107
list ($ start , $ end ) = $ this ->getChangeExtent ($ fromLine , $ toLine );
136
108
if ($ start != 0 || $ end != 0 ) {
@@ -145,8 +117,8 @@ public function render()
145
117
"\0" . mb_substr ($ toLine , $ start , $ realEnd - $ start ) . "\1" .
146
118
mb_substr ($ toLine , $ realEnd );
147
119
148
- $ a [$ i1 + $ i ] = $ fromLine ;
149
- $ b [$ j1 + $ i ] = $ toLine ;
120
+ $ old [$ i1 + $ i ] = $ fromLine ;
121
+ $ new [$ j1 + $ i ] = $ toLine ;
150
122
}
151
123
}
152
124
}
@@ -159,20 +131,20 @@ public function render()
159
131
$ lastTag = $ tag ;
160
132
161
133
if ($ tag == 'equal ' ) {
162
- $ lines = array_slice ($ a , $ i1 , ($ i2 - $ i1 ));
134
+ $ lines = array_slice ($ old , $ i1 , ($ i2 - $ i1 ));
163
135
$ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ this ->formatLines ($ lines );
164
- $ lines = array_slice ($ b , $ j1 , ($ j2 - $ j1 ));
136
+ $ lines = array_slice ($ new , $ j1 , ($ j2 - $ j1 ));
165
137
$ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ this ->formatLines ($ lines );
166
138
} else {
167
139
if ($ tag == 'replace ' || $ tag == 'delete ' ) {
168
- $ lines = array_slice ($ a , $ i1 , ($ i2 - $ i1 ));
140
+ $ lines = array_slice ($ old , $ i1 , ($ i2 - $ i1 ));
169
141
$ lines = $ this ->formatLines ($ lines );
170
142
$ lines = str_replace (array ("\0" , "\1" ), array ('<del> ' , '</del> ' ), $ lines );
171
143
$ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ lines ;
172
144
}
173
145
174
146
if ($ tag == 'replace ' || $ tag == 'insert ' ) {
175
- $ lines = array_slice ($ b , $ j1 , ($ j2 - $ j1 ));
147
+ $ lines = array_slice ($ new , $ j1 , ($ j2 - $ j1 ));
176
148
$ lines = $ this ->formatLines ($ lines );
177
149
$ lines = str_replace (array ("\0" , "\1" ), array ('<ins> ' , '</ins> ' ), $ lines );
178
150
$ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ lines ;
0 commit comments