Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 30e103d

Browse files
committedNov 1, 2013
Merge pull request phpspec#2 from samdark/5.5-and-cleanup
5.5 and cleanup
2 parents 8d82ac4 + 71cd475 commit 30e103d

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed
 

‎lib/Diff.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Diff
8080
*
8181
* @param array $a Array containing the lines of the first string to compare.
8282
* @param array $b Array containing the lines for the second string to compare.
83+
* @param array $options
8384
*/
8485
public function __construct($a, $b, $options=array())
8586
{
@@ -92,7 +93,7 @@ public function __construct($a, $b, $options=array())
9293
/**
9394
* Render a diff using the supplied rendering class and return it.
9495
*
95-
* @param object $renderer An instance of the rendering object to use for generating the diff.
96+
* @param Diff_Renderer_Abstract $renderer An instance of the rendering object to use for generating the diff.
9697
* @return mixed The generated diff. Exact return value depends on the rendered.
9798
*/
9899
public function render(Diff_Renderer_Abstract $renderer)

‎lib/Diff/Renderer/Html/Array.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,20 @@ private function formatLines($lines)
177177
$lines = array_map(array($this, 'ExpandTabs'), $lines);
178178
$lines = array_map(array($this, 'HtmlSafe'), $lines);
179179
foreach($lines as &$line) {
180-
$line = preg_replace('# ( +)|^ #e', "\$this->fixSpaces('\\1')", $line);
180+
$line = preg_replace_callback('# ( +)|^ #', __CLASS__."::fixSpaces", $line);
181181
}
182182
return $lines;
183183
}
184184

185185
/**
186186
* Replace a string containing spaces with a HTML representation using  .
187187
*
188-
* @param string $spaces The string of spaces.
188+
* @param string $matches Regex matches array.
189189
* @return string The HTML representation of the string.
190190
*/
191-
function fixSpaces($spaces='')
191+
public static function fixSpaces($matches)
192192
{
193+
$spaces = isset($matches[1]) ? $matches[1] : '';
193194
$count = strlen($spaces);
194195
if($count == 0) {
195196
return '';

‎lib/Diff/SequenceMatcher.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Diff_SequenceMatcher
8383
* @param string|array $a A string or array containing the lines to compare against.
8484
* @param string|array $b A string or array containing the lines to compare.
8585
* @param string|array $junkCallback Either an array or string that references a callback function (if there is one) to determine 'junk' characters.
86+
* @param array $options
8687
*/
8788
public function __construct($a, $b, $junkCallback=null, $options)
8889
{
@@ -93,6 +94,11 @@ public function __construct($a, $b, $junkCallback=null, $options)
9394
$this->setSequences($a, $b);
9495
}
9596

97+
/**
98+
* Set new options
99+
*
100+
* @param array $options
101+
*/
96102
public function setOptions($options)
97103
{
98104
$this->options = array_merge($this->defaultOptions, $options);
@@ -206,8 +212,8 @@ private function chainB()
206212
/**
207213
* Checks if a particular character is in the junk dictionary
208214
* for the list of junk characters.
209-
*
210-
* @return boolean $b True if the character is considered junk. False if not.
215+
* @param $b
216+
* @return boolean True if the character is considered junk. False if not.
211217
*/
212218
private function isBJunk($b)
213219
{
@@ -631,7 +637,7 @@ private function quickRatio()
631637
{
632638
if($this->fullBCount === null) {
633639
$this->fullBCount = array();
634-
$bLength = count ($b);
640+
$bLength = count ($this->b);
635641
for($i = 0; $i < $bLength; ++$i) {
636642
$char = $this->b[$i];
637643
$this->fullBCount[$char] = $this->arrayGetDefault($this->fullBCount, $char, 0) + 1;
@@ -729,7 +735,7 @@ private function tupleSort($a, $b)
729735
}
730736
}
731737

732-
if(count($a) == $count($b)) {
738+
if(count($a) == count($b)) {
733739
return 0;
734740
}
735741
else if(count($a) < count($b)) {

0 commit comments

Comments
 (0)
Please sign in to comment.