diff --git a/composer.lock b/composer.lock index 41f98eb..f94decc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ac82fae1f7095370dc4c7299aa637a30", - "content-hash": "3faf23edaf51060bfe1830506104ec83", + "hash": "6a7dba6ba1b24d45b8d19186eae195f5", + "content-hash": "3ecce85585b049d679a3b982fa3b3242", "packages": [ { "name": "nikic/php-parser", diff --git a/src/DetectorFactory.php b/src/DetectorFactory.php index 62926a8..0eb8e11 100644 --- a/src/DetectorFactory.php +++ b/src/DetectorFactory.php @@ -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; @@ -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(); @@ -314,13 +319,13 @@ 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(), ) ); } @@ -328,6 +333,10 @@ private function getMessageHelper() /** * DeprecationParser. */ + + /** + * @return DeprecationParser + */ private function getDeprecationParser() { return new DeprecationParser( diff --git a/src/Finder/ParsedPhpFileFinder.php b/src/Finder/ParsedPhpFileFinder.php index 6930dfa..73fd6cf 100644 --- a/src/Finder/ParsedPhpFileFinder.php +++ b/src/Finder/ParsedPhpFileFinder.php @@ -78,14 +78,6 @@ public function count() return iterator_count(parent::getIterator()); } - /** - * @return bool - */ - public function hasParserErrors() - { - return !empty($this->parserErrors); - } - /** * @return \PhpParser\Error[] */ diff --git a/src/RuleSet/Loader/FileLoader.php b/src/RuleSet/Loader/FileLoader.php index 6003c9a..cd2c824 100644 --- a/src/RuleSet/Loader/FileLoader.php +++ b/src/RuleSet/Loader/FileLoader.php @@ -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 ) ); } diff --git a/src/Violation/Renderer/MessageHelper/Message/BaseViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/BaseViolationMessage.php index 0408fd1..2533578 100644 --- a/src/Violation/Renderer/MessageHelper/Message/BaseViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/BaseViolationMessage.php @@ -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; } } diff --git a/src/Violation/Renderer/MessageHelper/Message/ClassViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/ClassViolationMessage.php index 2129bd7..4b318de 100644 --- a/src/Violation/Renderer/MessageHelper/Message/ClassViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/ClassViolationMessage.php @@ -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) diff --git a/src/Violation/Renderer/MessageHelper/Message/FunctionViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/FunctionViolationMessage.php index d86a262..811547a 100644 --- a/src/Violation/Renderer/MessageHelper/Message/FunctionViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/FunctionViolationMessage.php @@ -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) diff --git a/src/Violation/Renderer/MessageHelper/Message/InterfaceViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/InterfaceViolationMessage.php index 7383960..57b1143 100644 --- a/src/Violation/Renderer/MessageHelper/Message/InterfaceViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/InterfaceViolationMessage.php @@ -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) diff --git a/src/Violation/Renderer/MessageHelper/Message/LanguageDeprecationMessage.php b/src/Violation/Renderer/MessageHelper/Message/LanguageDeprecationMessage.php index 89895fc..d5aeb85 100644 --- a/src/Violation/Renderer/MessageHelper/Message/LanguageDeprecationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/LanguageDeprecationMessage.php @@ -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) diff --git a/src/Violation/Renderer/MessageHelper/Message/MethodDefinitionViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/MethodDefinitionViolationMessage.php index ac270a0..1dadfc3 100644 --- a/src/Violation/Renderer/MessageHelper/Message/MethodDefinitionViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/MethodDefinitionViolationMessage.php @@ -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) diff --git a/src/Violation/Renderer/MessageHelper/Message/MethodViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/MethodViolationMessage.php index 1946184..070637c 100644 --- a/src/Violation/Renderer/MessageHelper/Message/MethodViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/MethodViolationMessage.php @@ -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) diff --git a/src/Violation/Renderer/MessageHelper/Message/SuperTypeViolationMessage.php b/src/Violation/Renderer/MessageHelper/Message/SuperTypeViolationMessage.php index d622f6c..489fcde 100644 --- a/src/Violation/Renderer/MessageHelper/Message/SuperTypeViolationMessage.php +++ b/src/Violation/Renderer/MessageHelper/Message/SuperTypeViolationMessage.php @@ -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) diff --git a/tests/Console/Command/CheckCommandTest.php b/tests/Console/Command/CheckCommandTest.php index b3935de..cd9acba 100644 --- a/tests/Console/Command/CheckCommandTest.php +++ b/tests/Console/Command/CheckCommandTest.php @@ -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, diff --git a/tests/DeprecationDetectorTest.php b/tests/DeprecationDetectorTest.php index 87d8b72..fbd9c3d 100644 --- a/tests/DeprecationDetectorTest.php +++ b/tests/DeprecationDetectorTest.php @@ -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()); diff --git a/tests/FileInfo/PhpFileInfoTest.php b/tests/FileInfo/PhpFileInfoTest.php index 8016003..df8a611 100644 --- a/tests/FileInfo/PhpFileInfoTest.php +++ b/tests/FileInfo/PhpFileInfoTest.php @@ -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'); diff --git a/tests/TypeGuessing/SymbolTable/TableScopeTest.php b/tests/TypeGuessing/SymbolTable/TableScopeTest.php index 135317b..a94b383 100644 --- a/tests/TypeGuessing/SymbolTable/TableScopeTest.php +++ b/tests/TypeGuessing/SymbolTable/TableScopeTest.php @@ -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() diff --git a/tests/Violation/Renderer/MessageHelper/Message/BaseViolationMessageImplementation.php b/tests/Violation/Renderer/MessageHelper/Message/BaseViolationMessageImplementation.php index 0e0ce5d..53649a3 100644 --- a/tests/Violation/Renderer/MessageHelper/Message/BaseViolationMessageImplementation.php +++ b/tests/Violation/Renderer/MessageHelper/Message/BaseViolationMessageImplementation.php @@ -7,11 +7,6 @@ class BaseViolationMessageImplementation extends BaseViolationMessage { - public function __construct($usageName) - { - parent::__construct($usageName); - } - public function message(UsageInterface $usage) { } diff --git a/tests/Violation/ViolationFilter/MethodViolationFilterTest.php b/tests/Violation/ViolationFilter/MethodViolationFilterTest.php index 86e6e6b..9bfcc4d 100644 --- a/tests/Violation/ViolationFilter/MethodViolationFilterTest.php +++ b/tests/Violation/ViolationFilter/MethodViolationFilterTest.php @@ -15,7 +15,7 @@ class MethodViolationFilterTest extends \PHPUnit_Framework_TestCase public function setUp() { - parent::setup(); + parent::setUp(); $this->methodViolationFilter = new MethodViolationFilter($this->filterList); }