Skip to content

Commit

Permalink
Document update grammar in the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JBlond committed Aug 24, 2021
1 parent 02cf114 commit 3f44195
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions lib/jblond/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Diff
* The values can be of type string or array.
* If the type is string, it's split into array elements by line-end characters.
*
* Options for comparison can be set by using the third parameter. The format of this value is expected to be a
* Options for comparison can be set by using the third parameter. The format of this value is expected to be an
* associative array where each key-value pair represents an option and its value (E.g. ['context' => 3], ...).
* When a keyName matches the name of a default option, that option's value will be overridden by the key's value.
* Any other keyName (and it's value) can be added as an option, but will not be used if not implemented.
Expand All @@ -110,7 +110,7 @@ public function __construct($version1, $version2, array $options = [])
}

/**
* Get the type of a variable.
* Get the kind of variable.
*
* The return value depend on the type of variable:
* 0 If the type is 'array'
Expand Down Expand Up @@ -200,11 +200,11 @@ public function render(object $renderer)
* @param int|null $end The last element of the range to get.
* If not supplied, only the element at start will be returned.
*
* @return array Array containing all of the elements of the specified range.
* @return array Array containing all the elements of the specified range.
* @throws OutOfRangeException When the value of start or end are invalid to define a range.
*
*/
public function getArrayRange(array $array, int $start = 0, $end = null): array
public function getArrayRange(array $array, int $start = 0, ?int $end = null): array
{
if ($start < 0 || $end < 0 || $end < $start) {
throw new OutOfRangeException('Start parameter must be lower than End parameter while both are positive!');
Expand Down Expand Up @@ -274,7 +274,7 @@ public function getGroupedOpCodes(): array
*
* @return float Similarity ratio.
*/
public function getSimilarity($method = Similarity::CALC_DEFAULT): float
public function getSimilarity(int $method = Similarity::CALC_DEFAULT): float
{
if ($this->similarity !== null) {
return $this->similarity;
Expand Down
2 changes: 1 addition & 1 deletion lib/jblond/Diff/Renderer/Html/Merged.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Merged extends MainRenderer implements SubRendererInterface
/**
* @var array Associative array containing the default options available for this renderer and their default
* value.
* - format Format of the texts.
* - format The Format of the texts.
* - insertMarkers Markers for inserted text.
* - deleteMarkers Markers for removed text.
* - title1 Title of the 1st version of text.
Expand Down
2 changes: 1 addition & 1 deletion lib/jblond/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SideBySide extends MainRenderer implements SubRendererInterface
/**
* @var array Associative array containing the default options available for this renderer and their default
* value.
* - format Format of the texts.
* - format The Format of the texts.
* - insertMarkers Markers for inserted text.
* - deleteMarkers Markers for removed text.
* - title1 Title of the 1st version of text.
Expand Down
2 changes: 1 addition & 1 deletion lib/jblond/Diff/Renderer/Html/Unified.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Unified extends MainRenderer implements SubRendererInterface
/**
* @var array Associative array containing the default options available for this renderer and their default
* value.
* - format Format of the texts.
* - format The Format of the texts.
* - insertMarkers Markers for inserted text.
* - deleteMarkers Markers for removed text.
* - title1 Title of the 1st version of text.
Expand Down
6 changes: 3 additions & 3 deletions lib/jblond/Diff/Renderer/MainRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function renderSequences(): array
foreach ($group as $code) {
[$tag, $startOld, $endOld, $startNew, $endNew] = $code;
/**
* $code is an array describing a op-code which includes:
* $code is an array describing an op-code which includes:
* 0 - The type of tag (as described below) for the op code.
* 1 - The beginning line in the first sequence.
* 2 - The end line in the first sequence.
Expand Down Expand Up @@ -351,7 +351,7 @@ private function getOuterChange(string $oldString, string $newString): array
$limit = min(mb_strlen($oldString), mb_strlen($newString));

// Find the position of the first character which is different between old and new.
// Starts at the begin of the strings.
// Starts at the beginning of the strings.
// Stops at the end of the shortest string.
while ($start < $limit && mb_substr($oldString, $start, 1) == mb_substr($newString, $start, 1)) {
++$start;
Expand All @@ -375,7 +375,7 @@ private function getOuterChange(string $oldString, string $newString): array

/**
* Helper function that will fill the changes-array for the renderer with default values.
* Every time a operation changes (specified by $tag) , a new element will be appended to this array.
* Every time an operation changes (specified by $tag) , a new element will be appended to this array.
*
* The index of the last element of the array is always returned.
*
Expand Down
6 changes: 3 additions & 3 deletions lib/jblond/Diff/Renderer/Text/UnifiedCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ private function output(): string
}

/**
* @param $string
* @param string $color
* @param string $string
* @param string $color
*
* @return string
*/
private function colorizeString($string, $color = ''): string
private function colorizeString(string $string, string $color = ''): string
{
if ($this->options['cliColor']) {
return $this->colors->getColoredString($string, $color);
Expand Down
10 changes: 5 additions & 5 deletions lib/jblond/Diff/SequenceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SequenceMatcher

/**
* The constructor. With the sequences being passed, they'll be set for the
* sequence matcher and it will perform a basic cleanup & calculate junk
* sequence matcher, and it will perform a basic cleanup & calculate junk
* elements.
*
* @param string|array $old A string or array containing the lines to compare against.
Expand Down Expand Up @@ -215,7 +215,7 @@ private function chainB()
* content of the different files but can still provide context as to where the
* changes are.
*
* @return array Nested array of all of the grouped op codes.
* @return array Nested array of all the grouped op codes.
*/
public function getGroupedOpCodes(): array
{
Expand Down Expand Up @@ -295,7 +295,7 @@ public function getGroupedOpCodes(): array
}

/**
* Return a list of all of the op codes for the differences between the
* Return a list of all the op codes for the differences between the
* two strings.
*
* The nested array returned contains an array describing the op code
Expand Down Expand Up @@ -366,7 +366,7 @@ public function getOpCodes(): array
}

/**
* Return a nested set of arrays for all of the matching sub-sequences
* Return a nested set of arrays for all the matching sub-sequences
* in the strings $a and $b.
*
* Each block contains the lower constraint of the block in $a, the lower
Expand Down Expand Up @@ -479,7 +479,7 @@ function ($aArray, $bArray) {
* lower and upper constraints for each sequence. (for the first sequence,
* $alo - $ahi and for the second sequence, $blo - $bhi)
*
* Essentially, of all of the maximal matching blocks, return the one that
* Essentially, of all the maximal matching blocks, return the one that
* starts earliest in $a, and all of those maximal matching blocks that
* start earliest in $a, return the one that starts earliest in $b.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Diff/SequenceMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testGetGroupedOpCodesIgnoreWhitespaceTrue()
{
// Test with ignoreWhitespace enabled. Both sequences are considered to be the same.
// Note: The sequenceMatcher evaluates the string character by character. Option ignoreWhitespace will ignore
// if the difference if the character is a tab in one sequence and a space in the other.
// if the difference is the character or is a tab in one sequence and a space in the other.
$sequenceMatcher = new SequenceMatcher(
"\t54321ABXDE12345 ",
" 54321ABXDE12345\t",
Expand Down

0 comments on commit 3f44195

Please sign in to comment.