Skip to content

Commit

Permalink
Removed unused code. Fixed defaults. (#267)
Browse files Browse the repository at this point in the history
* Removed unused code.
Fixed defaults.

* Fixed defaults and config arrays merging
  • Loading branch information
ddziaduch authored and samsonasik committed Aug 9, 2017
1 parent 099c8f0 commit ea41d4b
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 25 deletions.
2 changes: 0 additions & 2 deletions src/Analysis/Debugger.php
@@ -1,8 +1,6 @@
<?php
namespace Kahlan\Analysis;

use Exception;

/**
* The `Debugger` class provides basic facilities for generating and rendering meta-data about the
* state of an application in its current context.
Expand Down
2 changes: 1 addition & 1 deletion src/Box/Box.php
Expand Up @@ -32,7 +32,7 @@ public function __construct($config = [])
'wrapper' => 'Kahlan\Box\Wrapper'
];
$config += $defaults;
$this->_classes['wrapper'] = $defaults['wrapper'];
$this->_classes['wrapper'] = $config['wrapper'];
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Code/Code.php
Expand Up @@ -59,7 +59,6 @@ public static function spin($callable, $timeout = 0, $delay = 100000)

$closure = function () use ($callable, $timeout, $delay) {
$timeout = (float) $timeout;
$result = false;
$start = microtime(true);

do {
Expand Down
3 changes: 0 additions & 3 deletions src/Jit/Interceptor.php
Expand Up @@ -435,7 +435,6 @@ public function loadFiles($files)
{
$files = (array) $files;

$success = true;
foreach ($files as $file) {
$this->loadFile($file);
}
Expand Down Expand Up @@ -586,8 +585,6 @@ public function getPrefixes()
*/
public function findPath($namespace, $forceDir = false)
{
$loader = static::originalInstance();

$paths = static::getPrefixes();
$logicalPath = trim(strtr($namespace, '\\', DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);

Expand Down
5 changes: 1 addition & 4 deletions src/Jit/Parser.php
Expand Up @@ -82,7 +82,6 @@ protected function _parser($content, $lines = false)
$blockStartLine = [];

while ($token = $this->_stream->current(true)) {
$current = $this->_states['current'];
switch ($token[0]) {
case T_OPEN_TAG:
case T_OPEN_TAG_WITH_ECHO:
Expand Down Expand Up @@ -179,7 +178,6 @@ protected function _parser($content, $lines = false)
break;
case T_FUNCTION:
$this->_functionNode();
$buffered = '';
break;
case $T_YIELD: // use T_YIELD directly when PHP 5.4 support will be removed.
$parent = $this->_states['current'];
Expand Down Expand Up @@ -506,9 +504,8 @@ protected function _functionNode()
*/
protected function _parseArgs()
{
$inString = false;
$cpt = 0;
$last = $char = $value = $name = '';
$value = $name = '';
$args = [];
$body = '';
while ($token = $this->_stream->current(true)) {
Expand Down
4 changes: 0 additions & 4 deletions src/Jit/Patcher/Monkey.php
Expand Up @@ -229,7 +229,6 @@ protected function _monkeyPatch($node, $parent, $index)
if (!preg_match_all($this->_regex, $node->body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
return;
}
$offset = 0;
foreach (array_reverse($matches) as $match) {
$len = strlen($match[0][0]);
$pos = $match[0][1];
Expand Down Expand Up @@ -283,9 +282,6 @@ protected function _monkeyPatch($node, $parent, $index)
$replace .= $match[1][0] . $match[2][0] . $variable . $match[4][0];
}
$node->body = substr_replace($node->body, $replace, $pos, $len);
$offset = $pos + strlen($replace);
} else {
$offset = $pos + $len;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Matcher/ToReceive.php
Expand Up @@ -71,7 +71,6 @@ class ToReceive
*/
public static function match($actual, $expected = null)
{
$class = get_called_class();
$args = func_get_args();
$actual = array_shift($args);
return new static($actual, $args);
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Call/Calls.php
Expand Up @@ -153,7 +153,7 @@ public static function find($message, $index = 0, $times = 0, &$args = [])
$times -= 1;
if ($times < 0) {
$success = true;
$next = static::find($messages, $i + 1, 0, $args);
static::find($messages, $i + 1, 0, $args);
static::$_index = $i + 1;
break;
} elseif ($times === 0) {
Expand Down
1 change: 0 additions & 1 deletion src/Plugin/Stub.php
Expand Up @@ -242,7 +242,6 @@ public static function find($references, $method = null, $args = null)
{
$references = (array) $references;
$stub = null;
$refs = [];
foreach ($references as $reference) {
$hash = Suite::hash($reference);
if (!isset(static::$_registered[$hash])) {
Expand Down
2 changes: 0 additions & 2 deletions src/Reporter/Coverage.php
Expand Up @@ -387,8 +387,6 @@ public function stop($summary)
$percent = number_format($stats['percent'], 2);
$this->write(str_repeat(' ', substr_count($name, '\\')));

$pos = strrpos($name, '\\');
$basename = substr($name, $pos !== false ? $pos + 1 : 0);
$this->write('Total: ');
$this->write("{$percent}% ", $this->_style($percent));
$this->write("({$stats['cloc']}/{$stats['lloc']})");
Expand Down
1 change: 0 additions & 1 deletion src/Reporter/Coverage/Collector.php
Expand Up @@ -172,7 +172,6 @@ public function start()
public function stop($mergeToParent = true)
{
$collector = end(static::$_collectors);
$collected = [];
if ($collector !== $this) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Reporter/Coverage/Driver/HHVM.php
Expand Up @@ -23,7 +23,7 @@ public function __construct($config = [])
$defaults = [
'cleanup' => true
];
$this->_config = $config;
$this->_config = $config + $defaults;

if (!defined('HHVM_VERSION')) {
throw new RuntimeException('HHVM is not loaded.');
Expand Down
2 changes: 1 addition & 1 deletion src/Reporter/Coverage/Metrics.php
Expand Up @@ -190,7 +190,7 @@ public function get($name = null)

$child = $this;
foreach ($parts as $part) {
list($name, $type) = $part;
list($name) = $part;
if (!isset($child->_children[$name])) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Scope.php
Expand Up @@ -4,7 +4,6 @@
use Closure;
use Exception;
use Kahlan\Analysis\Debugger;
use Kahlan\Plugin\Call\Message;

class Scope
{
Expand Down Expand Up @@ -449,7 +448,7 @@ protected function _parents($current = false)
* @return Closure
* @throws Exception Throw an Exception if the passed parameter is not a closure
*/
protected function _bind($closure, $name)
protected function _bind($closure)
{
if (!is_callable($closure)) {
throw new Exception("Error, invalid closure.");
Expand Down

0 comments on commit ea41d4b

Please sign in to comment.