Skip to content

Commit 7f1f420

Browse files
Rename SebastianBergmann\Diff to SebastianBergmann\Diff\Differ
1 parent aeaf75b commit 7f1f420

File tree

5 files changed

+64
-55
lines changed

5 files changed

+64
-55
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ Diff implementation for PHP, factored out of PHPUnit into a stand-alone componen
44

55
## Installation
66

7-
You can use the [PEAR Installer](http://pear.php.net/manual/en/guide.users.commandline.cli.php) or [Composer](http://getcomposer.org/) to download and install this package as well as its dependencies.
8-
9-
### PEAR Installer
10-
11-
The following two commands (which you may have to run as `root`) are all that is required to install this package using the PEAR Installer:
12-
13-
pear config-set auto_discover 1
14-
pear install pear.phpunit.de/Diff
7+
You can use [Composer](http://getcomposer.org/) or the [PEAR Installer](http://pear.php.net/manual/en/guide.users.commandline.cli.php) to download and install this package as well as its dependencies.
158

169
### Composer
1710

18-
To add this package as a local, per-project dependency to your project, simply add a dependency on `sebastian/diff` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Diff 1.0:
11+
To add this package as a local, per-project dependency to your project, simply add a dependency on `sebastian/diff` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Diff:
1912

2013
{
2114
"require": {
22-
"sebastian/diff": "1.0.*"
15+
"sebastian/diff": "*"
2316
}
2417
}
2518

19+
### PEAR Installer
20+
21+
The following two commands (which you may have to run as `root`) are all that is required to install this package using the PEAR Installer:
22+
23+
pear config-set auto_discover 1
24+
pear install pear.phpunit.de/Diff
25+
2626
### Usage
2727

2828
```php
29-
use SebastianBergmann\Diff;
29+
use SebastianBergmann\Diff\Differ;
3030

31-
$diff = new Diff;
32-
print $diff->diff('foo', 'bar');
31+
$differ = new Differ;
32+
print $differ->diff('foo', 'bar');
3333
```
3434

3535
The code above yields the output below:

build/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<dir name="SebastianBergmann">
3434
<dir name="Diff">
3535
<file baseinstalldir="/" name="autoload.php" role="php"/>
36-
<file baseinstalldir="/" name="Diff.php" role="php"/>
36+
<file baseinstalldir="/" name="Differ.php" role="php"/>
3737
</dir>
3838
</dir>
3939
<file baseinstalldir="/" name="LICENSE" role="doc"/>

src/Diff.php renamed to src/Differ.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @link http://www.github.com/sebastianbergmann/diff
4343
*/
4444

45-
namespace SebastianBergmann;
45+
namespace SebastianBergmann\Diff;
4646

4747
/**
4848
* Diff implementation.
@@ -54,7 +54,7 @@
5454
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
5555
* @link http://www.github.com/sebastianbergmann/diff
5656
*/
57-
class Diff
57+
class Differ
5858
{
5959
/**
6060
* @var string
@@ -254,7 +254,7 @@ public function diffToArray($from, $to)
254254
* @param array $to
255255
* @return array
256256
*/
257-
protected function longestCommonSubsequence(array $from, array $to)
257+
private function longestCommonSubsequence(array $from, array $to)
258258
{
259259
$common = array();
260260
$matrix = array();

src/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function($class) {
77
static $classes = null;
88
if ($classes === null) {
99
$classes = array(
10-
'sebastianbergmann\\diff' => '/Diff.php'
10+
'sebastianbergmann\\diff\\differ' => '/Differ.php'
1111
);
1212
}
1313
$cn = strtolower($class);

tests/DiffTest.php renamed to tests/DifferTest.php

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
* @link http://www.github.com/sebastianbergmann/diff
4242
*/
4343

44-
namespace SebastianBergmann;
44+
namespace SebastianBergmann\Diff;
4545

46-
class DiffTest extends \PHPUnit_Framework_TestCase
46+
class DifferTest extends \PHPUnit_Framework_TestCase
4747
{
4848
const REMOVED = 2;
4949
const ADDED = 1;
@@ -53,200 +53,209 @@ class DiffTest extends \PHPUnit_Framework_TestCase
5353

5454
protected function setUp()
5555
{
56-
$this->diff = new Diff;
56+
$this->differ = new Differ;
5757
}
5858

5959
/**
60-
* @covers SebastianBergmann\Diff::diff
60+
* @covers SebastianBergmann\Diff\Differ::diff
6161
*/
6262
public function testComparisonErrorMessage()
6363
{
6464
$this->assertEquals(
6565
"--- Original\n+++ New\n@@ @@\n-a\n+b\n",
66-
$this->diff->diff('a', 'b')
66+
$this->differ->diff('a', 'b')
6767
);
6868
}
6969

7070
/**
71-
* @covers SebastianBergmann\Diff::diffToArray
71+
* @covers SebastianBergmann\Diff\Differ::diffToArray
7272
*/
7373
public function testComparisonErrorMessage_toArray()
7474
{
7575
$expected = array();
7676
$expected[] = array('a', self::REMOVED);
7777
$expected[] = array('b', self::ADDED);
7878

79-
$this->assertEquals($expected, $this->diff->diffToArray('a', 'b'));
79+
$this->assertEquals($expected, $this->differ->diffToArray('a', 'b'));
8080
}
8181

8282
/**
83-
* @covers SebastianBergmann\Diff::diff
83+
* @covers SebastianBergmann\Diff\Differ::diff
8484
*/
8585
public function testComparisonErrorStartSame()
8686
{
8787
$this->assertEquals(
8888
"--- Original\n+++ New\n@@ @@\n-ba\n+bc\n",
89-
$this->diff->diff('ba', 'bc')
89+
$this->differ->diff('ba', 'bc')
9090
);
9191
}
9292

9393
/**
94-
* @covers SebastianBergmann\Diff::diffToArray
94+
* @covers SebastianBergmann\Diff\Differ::diffToArray
9595
*/
9696
public function testComparisonErrorStartSame_toArray()
9797
{
9898
$expected = array();
9999
$expected[] = array('ba', self::REMOVED);
100100
$expected[] = array('bc', self::ADDED);
101101

102-
$this->assertEquals($expected, $this->diff->diffToArray('ba', 'bc'));
102+
$this->assertEquals($expected, $this->differ->diffToArray('ba', 'bc'));
103103
}
104104

105105
/**
106-
* @covers SebastianBergmann\Diff::diff
106+
* @covers SebastianBergmann\Diff\Differ::diff
107107
*/
108108
public function testComparisonErrorEndSame()
109109
{
110110
$this->assertEquals(
111111
"--- Original\n+++ New\n@@ @@\n-ab\n+cb\n",
112-
$this->diff->diff('ab', 'cb')
112+
$this->differ->diff('ab', 'cb')
113113
);
114114
}
115115

116116
/**
117-
* @covers SebastianBergmann\Diff::diffToArray
117+
* @covers SebastianBergmann\Diff\Differ::diffToArray
118118
*/
119119
public function testComparisonErrorEndSame_toArray()
120120
{
121121
$expected = array();
122122
$expected[] = array('ab', self::REMOVED);
123123
$expected[] = array('cb', self::ADDED);
124124

125-
$this->assertEquals($expected, $this->diff->diffToArray('ab', 'cb'));
125+
$this->assertEquals($expected, $this->differ->diffToArray('ab', 'cb'));
126126
}
127127

128128
/**
129-
* @covers SebastianBergmann\Diff::diff
129+
* @covers SebastianBergmann\Diff\Differ::diff
130130
*/
131131
public function testComparisonErrorStartAndEndSame()
132132
{
133133
$this->assertEquals(
134134
"--- Original\n+++ New\n@@ @@\n-abc\n+adc\n",
135-
$this->diff->diff('abc', 'adc')
135+
$this->differ->diff('abc', 'adc')
136136
);
137137
}
138138

139139
/**
140-
* @covers SebastianBergmann\Diff::diffToArray
140+
* @covers SebastianBergmann\Diff\Differ::diffToArray
141141
*/
142142
public function testComparisonErrorStartAndEndSame_toArray()
143143
{
144144
$expected = array();
145145
$expected[] = array('abc', self::REMOVED);
146146
$expected[] = array('adc', self::ADDED);
147147

148-
$this->assertEquals($expected, $this->diff->diffToArray('abc', 'adc'));
148+
$this->assertEquals(
149+
$expected, $this->differ->diffToArray('abc', 'adc')
150+
);
149151
}
150152

151153
/**
152-
* @covers SebastianBergmann\Diff::diff
154+
* @covers SebastianBergmann\Diff\Differ::diff
153155
*/
154156
public function testComparisonErrorStartSameComplete()
155157
{
156158
$this->assertEquals(
157159
"--- Original\n+++ New\n@@ @@\n-ab\n+abc\n",
158-
$this->diff->diff('ab', 'abc')
160+
$this->differ->diff('ab', 'abc')
159161
);
160162
}
161163

162164
/**
163-
* @covers SebastianBergmann\Diff::diffToArray
165+
* @covers SebastianBergmann\Diff\Differ::diffToArray
164166
*/
165167
public function testComparisonErrorStartSameComplete_toArray()
166168
{
167169
$expected = array();
168170
$expected[] = array('ab', self::REMOVED);
169171
$expected[] = array('abc', self::ADDED);
170172

171-
$this->assertEquals($expected, $this->diff->diffToArray('ab', 'abc'));
173+
$this->assertEquals($expected, $this->differ->diffToArray('ab', 'abc'));
172174
}
173175

174176
/**
175-
* @covers SebastianBergmann\Diff::diff
177+
* @covers SebastianBergmann\Diff\Differ::diff
176178
*/
177179
public function testComparisonErrorEndSameComplete()
178180
{
179181
$this->assertEquals(
180182
"--- Original\n+++ New\n@@ @@\n-bc\n+abc\n",
181-
$this->diff->diff('bc', 'abc')
183+
$this->differ->diff('bc', 'abc')
182184
);
183185
}
184186

185187
/**
186-
* @covers SebastianBergmann\Diff::diffToArray
188+
* @covers SebastianBergmann\Diff\Differ::diffToArray
187189
*/
188190
public function testComparisonErrorEndSameComplete_toArray()
189191
{
190192
$expected = array();
191193
$expected[] = array('bc', self::REMOVED);
192194
$expected[] = array('abc', self::ADDED);
193195

194-
$this->assertEquals($expected, $this->diff->diffToArray('bc', 'abc'));
196+
$this->assertEquals($expected, $this->differ->diffToArray('bc', 'abc'));
195197
}
196198

197199
/**
198-
* @covers SebastianBergmann\Diff::diff
200+
* @covers SebastianBergmann\Diff\Differ::diff
199201
*/
200202
public function testComparisonErrorOverlapingMatches()
201203
{
202204
$this->assertEquals(
203205
"--- Original\n+++ New\n@@ @@\n-abc\n+abbc\n",
204-
$this->diff->diff('abc', 'abbc')
206+
$this->differ->diff('abc', 'abbc')
205207
);
206208
}
207209

208210
/**
209-
* @covers SebastianBergmann\Diff::diffToArray
211+
* @covers SebastianBergmann\Diff\Differ::diffToArray
210212
*/
211213
public function testComparisonErrorOverlapingMatches_toArray()
212214
{
213215
$expected = array();
214216
$expected[] = array('abc', self::REMOVED);
215217
$expected[] = array('abbc', self::ADDED);
216218

217-
$this->assertEquals($expected, $this->diff->diffToArray('abc', 'abbc'));
219+
$this->assertEquals(
220+
$expected, $this->differ->diffToArray('abc', 'abbc')
221+
);
218222
}
219223

220224
/**
221-
* @covers SebastianBergmann\Diff::diff
225+
* @covers SebastianBergmann\Diff\Differ::diff
222226
*/
223227
public function testComparisonErrorOverlapingMatches2()
224228
{
225229
$this->assertEquals(
226230
"--- Original\n+++ New\n@@ @@\n-abcdde\n+abcde\n",
227-
$this->diff->diff('abcdde', 'abcde')
231+
$this->differ->diff('abcdde', 'abcde')
228232
);
229233
}
230234

231235
/**
232-
* @covers SebastianBergmann\Diff::diffToArray
236+
* @covers SebastianBergmann\Diff\Differ::diffToArray
233237
*/
234238
public function testComparisonErrorOverlapingMatches2_toArray()
235239
{
236240
$expected = array();
237241
$expected[] = array('abcdde', self::REMOVED);
238242
$expected[] = array('abcde', self::ADDED);
239243

240-
$this->assertEquals($expected, $this->diff->diffToArray('abcdde', 'abcde'));
244+
$this->assertEquals(
245+
$expected, $this->differ->diffToArray('abcdde', 'abcde')
246+
);
241247
}
242248

249+
/**
250+
* @covers SebastianBergmann\Diff\Differ::diff
251+
*/
243252
public function testCustomHeader()
244253
{
245-
$diff = new Diff('CUSTOM HEADER');
254+
$differ = new Differ('CUSTOM HEADER');
246255

247256
$this->assertEquals(
248257
"CUSTOM HEADER@@ @@\n-a\n+b\n",
249-
$diff->diff('a', 'b')
258+
$differ->diff('a', 'b')
250259
);
251260
}
252261
}

0 commit comments

Comments
 (0)