Skip to content

tabs vs space #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 4
indent_style = space
38 changes: 19 additions & 19 deletions lib/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
class Autoloader
{

/**
* Autoloader constructor.
*/
public function __construct()
{
spl_autoload_register(array($this, '__autoload'));
}
/**
* Autoloader constructor.
*/
public function __construct()
{
spl_autoload_register(array($this, '__autoload'));
}

/**
* @param string $class
*/
private function __autoload($class)
{
$class = str_replace('\\', '/', $class); // revert path for old PHP on Linux
$dir = str_replace('\\', '/', __DIR__);
if (file_exists($dir . '/' . $class . '.php')) {
/** @noinspection PhpIncludeInspection */
require_once $dir . '/' . $class . '.php';
}
}
/**
* @param string $class
*/
private function __autoload($class)
{
$class = str_replace('\\', '/', $class); // revert path for old PHP on Linux
$dir = str_replace('\\', '/', __DIR__);
if (file_exists($dir . '/' . $class . '.php')) {
/** @noinspection PhpIncludeInspection */
require_once $dir . '/' . $class . '.php';
}
}
}
262 changes: 131 additions & 131 deletions lib/jblond/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,135 +49,135 @@
*/
class Diff
{
/**
* @var array The "old" sequence to use as the basis for the comparison.
*/
private $a = null;

/**
* @var array The "new" sequence to generate the changes for.
*/
private $b = null;

/**
* @var array Array containing the generated op codes for the differences between the two items.
*/
private $groupedCodes = null;

/**
* @var array Associative array of the default options available for the diff class and their default value.
*/
private $defaultOptions = array(
'context' => 3,
'ignoreNewLines' => false,
'ignoreWhitespace' => false,
'ignoreCase' => false,
'labelDifferences'=>'Differences'
);

/**
* @var array Array of the options that have been applied for generating the diff.
*/
public $options = array();

/**
* The constructor.
*
* @param array $a Array containing the lines of the first string to compare.
* @param array $b Array containing the lines for the second string to compare.
* @param array $options Array for the options
*/
public function __construct($a, $b, $options = array())
{
$this->a = $a;
$this->b = $b;

if (is_array($options)) {
$this->options = array_merge($this->defaultOptions, $options);
} else {
$this->options = $this->defaultOptions;
}
}


/**
* Render a diff using the supplied rendering class and return it.
*
* @param object $renderer object $renderer An instance of the rendering object to use for generating the diff.
* @return mixed The generated diff. Exact return value depends on the rendered.
*/
public function render($renderer)
{
$renderer->diff = $this;
return $renderer->render();
}

/**
* Get a range of lines from $start to $end from the first comparison string
* and return them as an array. If no values are supplied, the entire string
* is returned. It's also possible to specify just one line to return only
* that line.
*
* @param int $start The starting number.
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
* @return array Array of all of the lines between the specified range.
*/
public function getA($start = 0, $end = null) : array
{
if ($start == 0 && $end === null) {
return $this->a;
}

if ($end === null) {
$length = 1;
} else {
$length = $end - $start;
}

return array_slice($this->a, $start, $length);
}

/**
* Get a range of lines from $start to $end from the second comparison string
* and return them as an array. If no values are supplied, the entire string
* is returned. It's also possible to specify just one line to return only
* that line.
*
* @param int $start The starting number.
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
* @return array Array of all of the lines between the specified range.
*/
public function getB($start = 0, $end = null) : array
{
if ($start == 0 && $end === null) {
return $this->b;
}

if ($end === null) {
$length = 1;
} else {
$length = $end - $start;
}

return array_slice($this->b, $start, $length);
}

/**
* Generate a list of the compiled and grouped op codes for the differences between the
* two strings. Generally called by the renderer, this class instantiates the sequence
* matcher and performs the actual diff generation and return an array of the op codes
* for it. Once generated, the results are cached in the diff class instance.
*
* @return array Array of the grouped op codes for the generated diff.
*/
public function getGroupedOpcodes() : array
{
if (!is_null($this->groupedCodes)) {
return $this->groupedCodes;
}

$sequenceMatcher = new SequenceMatcher($this->a, $this->b, $this->options, null);
$this->groupedCodes = $sequenceMatcher->getGroupedOpcodes($this->options['context']);
return $this->groupedCodes;
}
/**
* @var array The "old" sequence to use as the basis for the comparison.
*/
private $a = null;

/**
* @var array The "new" sequence to generate the changes for.
*/
private $b = null;

/**
* @var array Array containing the generated op codes for the differences between the two items.
*/
private $groupedCodes = null;

/**
* @var array Associative array of the default options available for the diff class and their default value.
*/
private $defaultOptions = array(
'context' => 3,
'ignoreNewLines' => false,
'ignoreWhitespace' => false,
'ignoreCase' => false,
'labelDifferences'=>'Differences'
);

/**
* @var array Array of the options that have been applied for generating the diff.
*/
public $options = array();

/**
* The constructor.
*
* @param array $a Array containing the lines of the first string to compare.
* @param array $b Array containing the lines for the second string to compare.
* @param array $options Array for the options
*/
public function __construct($a, $b, $options = array())
{
$this->a = $a;
$this->b = $b;

if (is_array($options)) {
$this->options = array_merge($this->defaultOptions, $options);
} else {
$this->options = $this->defaultOptions;
}
}


/**
* Render a diff using the supplied rendering class and return it.
*
* @param object $renderer object $renderer An instance of the rendering object to use for generating the diff.
* @return mixed The generated diff. Exact return value depends on the rendered.
*/
public function render($renderer)
{
$renderer->diff = $this;
return $renderer->render();
}

/**
* Get a range of lines from $start to $end from the first comparison string
* and return them as an array. If no values are supplied, the entire string
* is returned. It's also possible to specify just one line to return only
* that line.
*
* @param int $start The starting number.
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
* @return array Array of all of the lines between the specified range.
*/
public function getA($start = 0, $end = null) : array
{
if ($start == 0 && $end === null) {
return $this->a;
}

if ($end === null) {
$length = 1;
} else {
$length = $end - $start;
}

return array_slice($this->a, $start, $length);
}

/**
* Get a range of lines from $start to $end from the second comparison string
* and return them as an array. If no values are supplied, the entire string
* is returned. It's also possible to specify just one line to return only
* that line.
*
* @param int $start The starting number.
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
* @return array Array of all of the lines between the specified range.
*/
public function getB($start = 0, $end = null) : array
{
if ($start == 0 && $end === null) {
return $this->b;
}

if ($end === null) {
$length = 1;
} else {
$length = $end - $start;
}

return array_slice($this->b, $start, $length);
}

/**
* Generate a list of the compiled and grouped op codes for the differences between the
* two strings. Generally called by the renderer, this class instantiates the sequence
* matcher and performs the actual diff generation and return an array of the op codes
* for it. Once generated, the results are cached in the diff class instance.
*
* @return array Array of the grouped op codes for the generated diff.
*/
public function getGroupedOpcodes() : array
{
if (!is_null($this->groupedCodes)) {
return $this->groupedCodes;
}

$sequenceMatcher = new SequenceMatcher($this->a, $this->b, $this->options, null);
$this->groupedCodes = $sequenceMatcher->getGroupedOpcodes($this->options['context']);
return $this->groupedCodes;
}
}
Loading