Skip to content

Commit f05f4a3

Browse files
committedOct 11, 2019
Tidy files
Signed-off-by: Jack Cherng <[email protected]>
1 parent 6b8ad6f commit f05f4a3

File tree

7 files changed

+145
-148
lines changed

7 files changed

+145
-148
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ which can be used to get the content of the `example/diff-table.css`.
3939
This package is available on `Packagist` by the name of [jfcherng/php-diff](https://packagist.org/packages/jfcherng/php-diff).
4040

4141
```bash
42-
$ composer require jfcherng/php-diff
42+
composer require jfcherng/php-diff
4343
```
4444

4545

‎UPGRADING/UPGRADING_v5.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
To get previous behavior, set the renderer option `outputTagAsString` to `true`.
2121

2222
- The `tag` (sometimes called `op`) in `Diff::getGroupedOpcodes()`'s results are now in `int` form.
23-
The corresponding meaning could be found in
23+
The corresponding meaning could be found in
2424
[jfcherng/php-sequence-matcher](https://github.com/jfcherng/php-sequence-matcher/blob/3.0.0/src/SequenceMatcher.php#L16-L26).

‎UPGRADING/UPGRADING_v6.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ there is no breaking change for you so you do not have to do anything.
3838
- Remove the deprecated `AbstractRenderer::getIdenticalResult()` and
3939
add `RendererInterface::getResultForIdenticals()`. The returned value will be
4040
directly used before actually starting to calculate diff if we find that the
41-
two strings are the same. `AbstractRenderer::getResultForIdenticals()`
41+
two strings are the same. `AbstractRenderer::getResultForIdenticals()`
4242
returns an empty string by default.
4343

4444
- Now a `Renderer` should implement `protected function renderWoker(Differ $differ): string`
45-
rather than the previous `public function render(): string`. Note that
46-
`$this->diff` no longer works in `Renderer`s as it is now injected as a
45+
rather than the previous `public function render(): string`. Note that
46+
`$this->diff` no longer works in `Renderer`s as it is now injected as a
4747
parameter to `Renderer::renderWoker()`.

‎example/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
To run the example on your local machine, you can follow steps below.
22

3-
1. `$ php -S localhost:12388` where `12388` is an arbitrary unused port.
3+
1. Execute `php -S localhost:12388` where `12388` is an arbitrary unused port.
44
1. Visit `http://localhost:12388/demo.php` with your web browser.

‎example/demo.php

+123-123
Original file line numberDiff line numberDiff line change
@@ -15,191 +15,191 @@
1515
<body>
1616
<?php
1717

18-
// include two sample files for comparison
19-
$oldFilePath = __DIR__ . '/old_file.txt';
20-
$newFilePath = __DIR__ . '/new_file.txt';
21-
$oldFile = \file_get_contents($oldFilePath);
22-
$newFile = \file_get_contents($newFilePath);
23-
24-
// options for Diff class
25-
$diffOptions = [
26-
// show how many neighbor lines
27-
'context' => 1,
28-
// ignore case difference
29-
'ignoreCase' => false,
30-
// ignore whitespace difference
31-
'ignoreWhitespace' => false,
32-
];
33-
34-
// options for renderer class
35-
$rendererOptions = [
36-
// how detailed the rendered HTML is? (line, word, char)
37-
'detailLevel' => 'line',
38-
// renderer language: eng, cht, chs, jpn, ...
39-
// or an array which has the same keys with a language file
40-
'language' => 'eng',
41-
// show a separator between different diff hunks in HTML renderers
42-
'separateBlock' => true,
43-
// the frontend HTML could use CSS "white-space: pre;" to visualize consecutive whitespaces
44-
// but if you want to visualize them in the backend with "&nbsp;", you can set this to true
45-
'spacesToNbsp' => false,
46-
// HTML renderer tab width (negative = do not convert into spaces)
47-
'tabSize' => 4,
48-
// internally, ops (tags) are all int type but this is not good for human reading.
49-
// set this to "true" to convert them into string form before outputting.
50-
'outputTagAsString' => false,
51-
// extra HTML classes added to the DOM of the diff container
52-
'wrapperClasses' => ['diff-wrapper'],
53-
];
18+
// include two sample files for comparison
19+
$oldFilePath = __DIR__ . '/old_file.txt';
20+
$newFilePath = __DIR__ . '/new_file.txt';
21+
$oldFile = \file_get_contents($oldFilePath);
22+
$newFile = \file_get_contents($newFilePath);
23+
24+
// options for Diff class
25+
$diffOptions = [
26+
// show how many neighbor lines
27+
'context' => 1,
28+
// ignore case difference
29+
'ignoreCase' => false,
30+
// ignore whitespace difference
31+
'ignoreWhitespace' => false,
32+
];
33+
34+
// options for renderer class
35+
$rendererOptions = [
36+
// how detailed the rendered HTML is? (line, word, char)
37+
'detailLevel' => 'line',
38+
// renderer language: eng, cht, chs, jpn, ...
39+
// or an array which has the same keys with a language file
40+
'language' => 'eng',
41+
// show a separator between different diff hunks in HTML renderers
42+
'separateBlock' => true,
43+
// the frontend HTML could use CSS "white-space: pre;" to visualize consecutive whitespaces
44+
// but if you want to visualize them in the backend with "&nbsp;", you can set this to true
45+
'spacesToNbsp' => false,
46+
// HTML renderer tab width (negative = do not convert into spaces)
47+
'tabSize' => 4,
48+
// internally, ops (tags) are all int type but this is not good for human reading.
49+
// set this to "true" to convert them into string form before outputting.
50+
'outputTagAsString' => false,
51+
// extra HTML classes added to the DOM of the diff container
52+
'wrapperClasses' => ['diff-wrapper'],
53+
];
5454

5555
?>
5656

5757
<h1>None-level Diff</h1>
5858
<?php
5959

60-
// demo the no-inline-detail diff
61-
$result = DiffHelper::calculate(
62-
$oldFile,
63-
$newFile,
64-
'Inline',
65-
$diffOptions,
66-
['detailLevel' => 'none'] + $rendererOptions
67-
);
60+
// demo the no-inline-detail diff
61+
$result = DiffHelper::calculate(
62+
$oldFile,
63+
$newFile,
64+
'Inline',
65+
$diffOptions,
66+
['detailLevel' => 'none'] + $rendererOptions
67+
);
6868

69-
echo $result;
69+
echo $result;
7070

7171
?>
7272

7373
<h1>Line-level Diff (Default)</h1>
7474
<?php
7575

76-
// demo the word-level diff
77-
$result = DiffHelper::calculate(
78-
$oldFile,
79-
$newFile,
80-
'Inline',
81-
$diffOptions,
82-
['detailLevel' => 'line'] + $rendererOptions
83-
);
76+
// demo the word-level diff
77+
$result = DiffHelper::calculate(
78+
$oldFile,
79+
$newFile,
80+
'Inline',
81+
$diffOptions,
82+
['detailLevel' => 'line'] + $rendererOptions
83+
);
8484

85-
echo $result;
85+
echo $result;
8686

8787
?>
8888

8989
<h1>Word-level Diff</h1>
9090
<?php
9191

92-
// demo the word-level diff
93-
$result = DiffHelper::calculate(
94-
$oldFile,
95-
$newFile,
96-
'Inline',
97-
$diffOptions,
98-
['detailLevel' => 'word'] + $rendererOptions
99-
);
92+
// demo the word-level diff
93+
$result = DiffHelper::calculate(
94+
$oldFile,
95+
$newFile,
96+
'Inline',
97+
$diffOptions,
98+
['detailLevel' => 'word'] + $rendererOptions
99+
);
100100

101-
echo $result;
101+
echo $result;
102102

103103
?>
104104

105105
<h1>Character-level Diff</h1>
106106
<?php
107107

108-
// demo the character-level diff
109-
$result = DiffHelper::calculate(
110-
$oldFile,
111-
$newFile,
112-
'Inline',
113-
$diffOptions,
114-
['detailLevel' => 'char'] + $rendererOptions
115-
);
108+
// demo the character-level diff
109+
$result = DiffHelper::calculate(
110+
$oldFile,
111+
$newFile,
112+
'Inline',
113+
$diffOptions,
114+
['detailLevel' => 'char'] + $rendererOptions
115+
);
116116

117-
echo $result;
117+
echo $result;
118118

119119
?>
120120

121121
<h1>Side by Side Diff</h1>
122122
<?php
123123

124-
// generate a side by side diff
125-
$result = DiffHelper::calculateFiles(
126-
$oldFilePath,
127-
$newFilePath,
128-
'SideBySide',
129-
$diffOptions,
130-
$rendererOptions
131-
);
124+
// generate a side by side diff
125+
$result = DiffHelper::calculateFiles(
126+
$oldFilePath,
127+
$newFilePath,
128+
'SideBySide',
129+
$diffOptions,
130+
$rendererOptions
131+
);
132132

133-
echo $result;
133+
echo $result;
134134

135135
?>
136136

137137
<h1>Inline Diff</h1>
138138
<?php
139139

140-
// generate an inline diff
141-
$result = DiffHelper::calculateFiles(
142-
$oldFilePath,
143-
$newFilePath,
144-
'Inline',
145-
$diffOptions,
146-
$rendererOptions
147-
);
140+
// generate an inline diff
141+
$result = DiffHelper::calculateFiles(
142+
$oldFilePath,
143+
$newFilePath,
144+
'Inline',
145+
$diffOptions,
146+
$rendererOptions
147+
);
148148

149-
echo $result;
149+
echo $result;
150150

151151
?>
152152

153153
<h1>Unified Diff</h1>
154154
<pre><?php
155155

156-
// generate a unified diff
157-
$result = DiffHelper::calculateFiles(
158-
$oldFilePath,
159-
$newFilePath,
160-
'Unified',
161-
$diffOptions,
162-
$rendererOptions
163-
);
156+
// generate a unified diff
157+
$result = DiffHelper::calculateFiles(
158+
$oldFilePath,
159+
$newFilePath,
160+
'Unified',
161+
$diffOptions,
162+
$rendererOptions
163+
);
164164

165-
echo \htmlspecialchars($result);
165+
echo \htmlspecialchars($result);
166166

167167
?></pre>
168168

169169
<h1>Context Diff</h1>
170170
<pre><?php
171171

172-
// generate a context diff
173-
$result = DiffHelper::calculateFiles(
174-
$oldFilePath,
175-
$newFilePath,
176-
'Context',
177-
$diffOptions,
178-
$rendererOptions
179-
);
172+
// generate a context diff
173+
$result = DiffHelper::calculateFiles(
174+
$oldFilePath,
175+
$newFilePath,
176+
'Context',
177+
$diffOptions,
178+
$rendererOptions
179+
);
180180

181-
echo \htmlspecialchars($result);
181+
echo \htmlspecialchars($result);
182182

183183
?></pre>
184184

185185
<h1>JSON Diff</h1>
186186
<pre><?php
187187

188-
// generate a JSON diff
189-
$result = DiffHelper::calculateFiles(
190-
$oldFilePath,
191-
$newFilePath,
192-
'Json',
193-
$diffOptions,
194-
['outputTagAsString' => true] + $rendererOptions
195-
);
196-
197-
$beautified = \json_encode(
198-
\json_decode($result, true),
199-
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT
200-
);
201-
202-
echo $beautified;
188+
// generate a JSON diff
189+
$result = DiffHelper::calculateFiles(
190+
$oldFilePath,
191+
$newFilePath,
192+
'Json',
193+
$diffOptions,
194+
['outputTagAsString' => true] + $rendererOptions
195+
);
196+
197+
$beautified = \json_encode(
198+
\json_decode($result, true),
199+
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT
200+
);
201+
202+
echo $beautified;
203203

204204
?></pre>
205205
</body>

‎phpcs.xml

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<ruleset name="php-diff">
3-
<description>php-diff</description>
4-
2+
<ruleset name="my-rules">
3+
<description>my-rules</description>
54
<!-- <arg name="report" value="summary" /> -->
65
<!-- <arg name="colors" /> -->
76
<arg value="sp" />
8-
9-
<file>./src/</file>
10-
11-
<exclude-pattern>*/tests/*</exclude-pattern>
12-
7+
<file>example/</file>
8+
<file>src/</file>
9+
<file>tests/</file>
1310
<rule ref="PSR1" />
1411
<rule ref="PSR12" />
1512
</ruleset>

‎phpunit.xml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<phpunit
3-
backupGlobals="true"
4-
backupStaticAttributes="false"
5-
bootstrap="./tests/bootstrap.php"
6-
defaultTestSuite="All"
7-
colors="true"
8-
verbose="false">
9-
<testsuites>
10-
<testsuite name="All">
11-
<directory suffix="Test.php">tests/</directory>
12-
</testsuite>
13-
</testsuites>
3+
backupGlobals="true"
4+
backupStaticAttributes="false"
5+
bootstrap="./tests/bootstrap.php"
6+
defaultTestSuite="All"
7+
colors="true"
8+
verbose="false">
9+
<testsuites>
10+
<testsuite name="All">
11+
<directory suffix="Test.php">tests/</directory>
12+
</testsuite>
13+
</testsuites>
1414
</phpunit>

0 commit comments

Comments
 (0)
Please sign in to comment.