Skip to content

Commit 5b9bff2

Browse files
committed
Deprecate special case tags public api calls
Removed all the code, and added a deprecation tag. Note: Small chance that anyone ever used this config parameter, since its pretty much undocumented, and did not really seem to serve any meaningful purpose.
1 parent 4f077a0 commit 5b9bff2

File tree

3 files changed

+13
-78
lines changed

3 files changed

+13
-78
lines changed

README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ $config
148148

149149
// List of characters to consider part of a single word when in the middle of text.
150150
->setSpecialCaseChars(array('.', ',', '(', ')', '\''))
151-
152-
// List of tags to treat as special case tags.
153-
->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'))
154-
151+
155152
// List of tags (and their replacement strings) to be diffed in isolation.
156153
->setIsolatedDiffTags(array(
157154
'ol' => '[[REPLACE_ORDERED_LIST]]',

lib/Caxy/HtmlDiff/AbstractDiff.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ abstract class AbstractDiff
9494
* @param string $oldText
9595
* @param string $newText
9696
* @param string $encoding
97-
* @param null|array $specialCaseTags
97+
* @param null|array $specialCaseTags (this does nothing, it is just here to keep the interface compatible)
9898
* @param null|bool $groupDiffs
9999
*/
100100
public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null)
@@ -103,10 +103,6 @@ public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCas
103103

104104
$this->setConfig(HtmlDiffConfig::create()->setEncoding($encoding));
105105

106-
if ($specialCaseTags !== null) {
107-
$this->config->setSpecialCaseTags($specialCaseTags);
108-
}
109-
110106
if ($groupDiffs !== null) {
111107
$this->config->setGroupDiffs($groupDiffs);
112108
}
@@ -313,7 +309,7 @@ public function removeSpecialCaseTag($tag)
313309
*/
314310
public function getSpecialCaseTags()
315311
{
316-
return $this->config->getSpecialCaseTags();
312+
return null;
317313
}
318314

319315
/**

lib/Caxy/HtmlDiff/HtmlDiffConfig.php

+10-68
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
*/
88
class HtmlDiffConfig
99
{
10-
/**
11-
* @var array
12-
*/
13-
protected $specialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p');
14-
1510
/**
1611
* @var string[]
1712
*/
@@ -61,14 +56,6 @@ class HtmlDiffConfig
6156
* @var int
6257
*/
6358
protected $matchThreshold = 80;
64-
/**
65-
* @var array
66-
*/
67-
protected $specialCaseOpeningTags = array();
68-
/**
69-
* @var array
70-
*/
71-
protected $specialCaseClosingTags = array();
7259

7360
/**
7461
* @var bool
@@ -103,7 +90,6 @@ public static function create()
10390
*/
10491
public function __construct()
10592
{
106-
$this->setSpecialCaseTags($this->specialCaseTags);
10793
}
10894

10995
/**
@@ -166,77 +152,49 @@ public function removeSpecialCaseChar($char)
166152
}
167153

168154
/**
155+
* @deprecated This feature never properly worked, and is removed in version 0.1.14
156+
*
169157
* @param array $tags
170158
*
171159
* @return $this
172160
*/
173161
public function setSpecialCaseTags(array $tags = array())
174162
{
175-
$this->specialCaseTags = $tags;
176-
$this->specialCaseOpeningTags = array();
177-
$this->specialCaseClosingTags = array();
178-
179-
foreach ($this->specialCaseTags as $tag) {
180-
$this->addSpecialCaseTag($tag);
181-
}
182-
183163
return $this;
184164
}
185165

186166
/**
167+
* @deprecated This feature never properly worked, and is removed in version 0.1.14
168+
*
187169
* @param string $tag
188170
*
189171
* @return $this
190172
*/
191173
public function addSpecialCaseTag($tag)
192174
{
193-
if (!in_array($tag, $this->specialCaseTags)) {
194-
$this->specialCaseTags[] = $tag;
195-
}
196-
197-
$opening = $this->getOpeningTag($tag);
198-
$closing = $this->getClosingTag($tag);
199-
200-
if (!in_array($opening, $this->specialCaseOpeningTags)) {
201-
$this->specialCaseOpeningTags[] = $opening;
202-
}
203-
if (!in_array($closing, $this->specialCaseClosingTags)) {
204-
$this->specialCaseClosingTags[] = $closing;
205-
}
206-
207175
return $this;
208176
}
209177

210178
/**
179+
* @deprecated This feature never properly worked, and is removed in version 0.1.14
180+
*
211181
* @param string $tag
212182
*
213183
* @return $this
214184
*/
215185
public function removeSpecialCaseTag($tag)
216186
{
217-
if (($key = array_search($tag, $this->specialCaseTags)) !== false) {
218-
unset($this->specialCaseTags[$key]);
219-
220-
$opening = $this->getOpeningTag($tag);
221-
$closing = $this->getClosingTag($tag);
222-
223-
if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) {
224-
unset($this->specialCaseOpeningTags[$key]);
225-
}
226-
if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) {
227-
unset($this->specialCaseClosingTags[$key]);
228-
}
229-
}
230-
231187
return $this;
232188
}
233189

234190
/**
235-
* @return array|null
191+
* @deprecated This feature never properly worked, and is removed in version 0.1.14
192+
*
193+
* @return null
236194
*/
237195
public function getSpecialCaseTags()
238196
{
239-
return $this->specialCaseTags;
197+
return null;
240198
}
241199

242200
/**
@@ -411,22 +369,6 @@ public function getIsolatedDiffTagPlaceholder($tag)
411369
return $this->isIsolatedDiffTag($tag) ? $this->isolatedDiffTags[$tag] : null;
412370
}
413371

414-
/**
415-
* @return array
416-
*/
417-
public function getSpecialCaseOpeningTags()
418-
{
419-
return $this->specialCaseOpeningTags;
420-
}
421-
422-
/**
423-
* @return array
424-
*/
425-
public function getSpecialCaseClosingTags()
426-
{
427-
return $this->specialCaseClosingTags;
428-
}
429-
430372
/**
431373
* @return bool
432374
*/

0 commit comments

Comments
 (0)