Skip to content

Commit

Permalink
Deprecate special case tags public api calls
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SavageTiger committed Jan 19, 2022
1 parent 4f077a0 commit 5b9bff2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 78 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ $config

// List of characters to consider part of a single word when in the middle of text.
->setSpecialCaseChars(array('.', ',', '(', ')', '\''))

// List of tags to treat as special case tags.
->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'))


// List of tags (and their replacement strings) to be diffed in isolation.
->setIsolatedDiffTags(array(
'ol' => '[[REPLACE_ORDERED_LIST]]',
Expand Down
8 changes: 2 additions & 6 deletions lib/Caxy/HtmlDiff/AbstractDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ abstract class AbstractDiff
* @param string $oldText
* @param string $newText
* @param string $encoding
* @param null|array $specialCaseTags
* @param null|array $specialCaseTags (this does nothing, it is just here to keep the interface compatible)
* @param null|bool $groupDiffs
*/
public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null)
Expand All @@ -103,10 +103,6 @@ public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCas

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

if ($specialCaseTags !== null) {
$this->config->setSpecialCaseTags($specialCaseTags);
}

if ($groupDiffs !== null) {
$this->config->setGroupDiffs($groupDiffs);
}
Expand Down Expand Up @@ -313,7 +309,7 @@ public function removeSpecialCaseTag($tag)
*/
public function getSpecialCaseTags()
{
return $this->config->getSpecialCaseTags();
return null;
}

/**
Expand Down
78 changes: 10 additions & 68 deletions lib/Caxy/HtmlDiff/HtmlDiffConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
*/
class HtmlDiffConfig
{
/**
* @var array
*/
protected $specialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p');

/**
* @var string[]
*/
Expand Down Expand Up @@ -61,14 +56,6 @@ class HtmlDiffConfig
* @var int
*/
protected $matchThreshold = 80;
/**
* @var array
*/
protected $specialCaseOpeningTags = array();
/**
* @var array
*/
protected $specialCaseClosingTags = array();

/**
* @var bool
Expand Down Expand Up @@ -103,7 +90,6 @@ public static function create()
*/
public function __construct()
{
$this->setSpecialCaseTags($this->specialCaseTags);
}

/**
Expand Down Expand Up @@ -166,77 +152,49 @@ public function removeSpecialCaseChar($char)
}

/**
* @deprecated This feature never properly worked, and is removed in version 0.1.14
*
* @param array $tags
*
* @return $this
*/
public function setSpecialCaseTags(array $tags = array())
{
$this->specialCaseTags = $tags;
$this->specialCaseOpeningTags = array();
$this->specialCaseClosingTags = array();

foreach ($this->specialCaseTags as $tag) {
$this->addSpecialCaseTag($tag);
}

return $this;
}

/**
* @deprecated This feature never properly worked, and is removed in version 0.1.14
*
* @param string $tag
*
* @return $this
*/
public function addSpecialCaseTag($tag)
{
if (!in_array($tag, $this->specialCaseTags)) {
$this->specialCaseTags[] = $tag;
}

$opening = $this->getOpeningTag($tag);
$closing = $this->getClosingTag($tag);

if (!in_array($opening, $this->specialCaseOpeningTags)) {
$this->specialCaseOpeningTags[] = $opening;
}
if (!in_array($closing, $this->specialCaseClosingTags)) {
$this->specialCaseClosingTags[] = $closing;
}

return $this;
}

/**
* @deprecated This feature never properly worked, and is removed in version 0.1.14
*
* @param string $tag
*
* @return $this
*/
public function removeSpecialCaseTag($tag)
{
if (($key = array_search($tag, $this->specialCaseTags)) !== false) {
unset($this->specialCaseTags[$key]);

$opening = $this->getOpeningTag($tag);
$closing = $this->getClosingTag($tag);

if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) {
unset($this->specialCaseOpeningTags[$key]);
}
if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) {
unset($this->specialCaseClosingTags[$key]);
}
}

return $this;
}

/**
* @return array|null
* @deprecated This feature never properly worked, and is removed in version 0.1.14
*
* @return null
*/
public function getSpecialCaseTags()
{
return $this->specialCaseTags;
return null;
}

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

/**
* @return array
*/
public function getSpecialCaseOpeningTags()
{
return $this->specialCaseOpeningTags;
}

/**
* @return array
*/
public function getSpecialCaseClosingTags()
{
return $this->specialCaseClosingTags;
}

/**
* @return bool
*/
Expand Down

0 comments on commit 5b9bff2

Please sign in to comment.