Skip to content

Commit

Permalink
Merge pull request #98 from MarvinKlemp/cleanup
Browse files Browse the repository at this point in the history
[WIP]Minor cleanup
  • Loading branch information
MarvinKlemp committed Jan 7, 2016
2 parents dc42106 + 2f261f4 commit 2a878df
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 78 deletions.
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 18 additions & 9 deletions src/DetectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
use SensioLabs\DeprecationDetector\TypeGuessing\SymbolTable\Visitor\SymbolTableVariableResolverVisitor;
use SensioLabs\DeprecationDetector\TypeGuessing\Symfony\ContainerReader;
use SensioLabs\DeprecationDetector\Violation\Renderer\ConsoleOutputRenderer;
use SensioLabs\DeprecationDetector\Violation\Renderer\Html\Renderer;
use SensioLabs\DeprecationDetector\Violation\Renderer\Html\RendererFactory;
use SensioLabs\DeprecationDetector\Violation\Renderer\MessageHelper\Message\ClassViolationMessage;
use SensioLabs\DeprecationDetector\Violation\Renderer\MessageHelper\Message\FunctionViolationMessage;
Expand Down Expand Up @@ -294,7 +293,13 @@ private function getViolationFilter(Configuration $configuration)
/**
* Renderer.
*/
private function getRenderer(Configuration $configuration, $output)

/**
* @param Configuration $configuration
* @param OutputInterface $output
* @return ConsoleOutputRenderer|Violation\Renderer\Html\Renderer
*/
private function getRenderer(Configuration $configuration, OutputInterface $output)
{
$messageHelper = $this->getMessageHelper();

Expand All @@ -314,20 +319,24 @@ private function getMessageHelper()
{
return new MessageHelper(
array(
new ClassViolationMessage('SensioLabs\DeprecationDetector\FileInfo\Usage\ClassUsage'),
new InterfaceViolationMessage('SensioLabs\DeprecationDetector\FileInfo\Usage\InterfaceUsage'),
new MethodViolationMessage('SensioLabs\DeprecationDetector\FileInfo\Usage\MethodUsage'),
new MethodDefinitionViolationMessage('SensioLabs\DeprecationDetector\FileInfo\MethodDefinition'),
new SuperTypeViolationMessage('SensioLabs\DeprecationDetector\FileInfo\Usage\SuperTypeUsage'),
new LanguageDeprecationMessage('SensioLabs\DeprecationDetector\FileInfo\Usage\DeprecatedLanguageUsage'),
new FunctionViolationMessage('SensioLabs\DeprecationDetector\FileInfo\Usage\FunctionUsage'),
new ClassViolationMessage(),
new InterfaceViolationMessage(),
new MethodViolationMessage(),
new MethodDefinitionViolationMessage(),
new SuperTypeViolationMessage(),
new LanguageDeprecationMessage(),
new FunctionViolationMessage(),
)
);
}

/**
* DeprecationParser.
*/

/**
* @return DeprecationParser
*/
private function getDeprecationParser()
{
return new DeprecationParser(
Expand Down
8 changes: 0 additions & 8 deletions src/Finder/ParsedPhpFileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ public function count()
return iterator_count(parent::getIterator());
}

/**
* @return bool
*/
public function hasParserErrors()
{
return !empty($this->parserErrors);
}

/**
* @return \PhpParser\Error[]
*/
Expand Down
4 changes: 2 additions & 2 deletions src/RuleSet/Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function loadRuleSet($path)

if (!$ruleSet instanceof RuleSet) {
throw new CouldNotLoadRuleSetException(sprintf(
'Ruleset "$s" is invalid, aborting.',
$path
'Ruleset "%s" is invalid, aborting.',
$path
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ public function __construct($usageName)

public function supports(UsageInterface $usage)
{
if ($usage instanceof $this->usageName) {
return true;
}

return false;
return $usage instanceof $this->usageName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\Usage\ClassUsage;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class ClassViolationMessage extends BaseViolationMessage implements ViolationMessageInterface
class ClassViolationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\Usage\ClassUsage';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\Usage\FunctionUsage;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class FunctionViolationMessage extends BaseViolationMessage implements ViolationMessageInterface
class FunctionViolationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\Usage\FunctionUsage';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\Usage\InterfaceUsage;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class InterfaceViolationMessage extends BaseViolationMessage implements ViolationMessageInterface
class InterfaceViolationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\Usage\InterfaceUsage';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\Usage\DeprecatedLanguageUsage;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class LanguageDeprecationMessage extends BaseViolationMessage implements ViolationMessageInterface
class LanguageDeprecationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\Usage\DeprecatedLanguageUsage';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\MethodDefinition;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class MethodDefinitionViolationMessage extends BaseViolationMessage implements ViolationMessageInterface
class MethodDefinitionViolationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\MethodDefinition';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\Usage\MethodUsage;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class MethodViolationMessage extends BaseViolationMessage implements ViolationMessageInterface
class MethodViolationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\Usage\MethodUsage';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use SensioLabs\DeprecationDetector\FileInfo\Usage\SuperTypeUsage;
use SensioLabs\DeprecationDetector\FileInfo\Usage\UsageInterface;

class SuperTypeViolationMessage extends BaseViolationMessage implements ViolationMessageInterface
class SuperTypeViolationMessage extends BaseViolationMessage
{
/**
* @param string $usageName
*/
public function __construct($usageName)
const USAGE_NAME = 'SensioLabs\DeprecationDetector\FileInfo\Usage\SuperTypeUsage';

public function __construct()
{
parent::__construct($usageName);
parent::__construct(self::USAGE_NAME);
}

public function message(UsageInterface $usage)
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Command/CheckCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function testCommandWithFilterMethodOption()
* @param string $rulesetPath ruleset argument
* @param array $options Further options as key => value array
*/
private function executeCommand($sourcePath, $rulesetPath, $options = array())
private function executeCommand($sourcePath, $rulesetPath, array $options = array())
{
$arguments = array_merge(
$options,
Expand Down
1 change: 0 additions & 1 deletion tests/DeprecationDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function testCheckForDeprecations()

$deprecationFinder = $this->prophesize('SensioLabs\DeprecationDetector\Finder\ParsedPhpFileFinder');
$deprecationFinder->in($sourceArg)->willReturn($deprecationFinder->reveal());
$deprecationFinder->hasParserErrors()->willReturn(false);
$deprecationFinder->count()->willReturn($fileCount);
$deprecationFinder->getParserErrors()->willReturn(array());

Expand Down
2 changes: 1 addition & 1 deletion tests/FileInfo/PhpFileInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function testHasAndGetSuperTypeUsageByClass()
{
$fileInfo = PhpFileInfo::create($this->prophesize('Symfony\Component\Finder\SplFileInfo')->reveal());
$this->assertFalse($fileInfo->hasSuperTypeUsageByClass('someClass'));
$this->assertSame(null, $fileInfo->getSuperTypeUsageByClass('someClass'));
$this->assertNull($fileInfo->getSuperTypeUsageByClass('someClass'));

$superTypeUsage = $this->prophesize('SensioLabs\DeprecationDetector\FileInfo\Usage\SuperTypeUsage');
$superTypeUsage->className()->willReturn('someClass');
Expand Down
2 changes: 1 addition & 1 deletion tests/TypeGuessing/SymbolTable/TableScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testFindSymbolReturnsNull()
{
$scope = new TableScope(TableScope::CLASS_LIKE_SCOPE);

$this->assertSame(null, $scope->findSymbol('var'));
$this->assertNull($scope->findSymbol('var'));
}

public function testSetAndFindSymbol()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

class BaseViolationMessageImplementation extends BaseViolationMessage
{
public function __construct($usageName)
{
parent::__construct($usageName);
}

public function message(UsageInterface $usage)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MethodViolationFilterTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
parent::setup();
parent::setUp();
$this->methodViolationFilter = new MethodViolationFilter($this->filterList);
}

Expand Down

0 comments on commit 2a878df

Please sign in to comment.