From 1c0b15cf7d148fbf3df4f5f5d7a9d73f353b0d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 21:01:27 +0200 Subject: [PATCH 01/29] Add support for renaming local variables inside functions --- .../TokenReflection/StaticCodeAnalysis.php | 52 +++++++++++++++++ .../Application/RenameLocalVariable.php | 2 +- .../Application/SingleFileRefactoring.php | 13 ++++- .../Domain/Model/RefactoringException.php | 8 +++ .../Domain/Services/CodeAnalysis.php | 56 +++++++++++++++++++ 5 files changed, 129 insertions(+), 2 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php b/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php index c766693..0484d5b 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php +++ b/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php @@ -62,6 +62,28 @@ public function getMethodStartLine(File $file, LineRange $range) return $method->getStartLine(); } + public function getFunctionEndLine(File $file, LineRange $range) + { + $function = $this->findMatchingFunction($file, $range); + + if ($function === null) { + throw new \InvalidArgumentException("Could not find function end line."); + } + + return $function->getEndLine(); + } + + public function getFunctionStartLine(File $file, LineRange $range) + { + $function = $this->findMatchingFunction($file, $range); + + if ($function === null) { + throw new \InvalidArgumentException("Could not find function start line."); + } + + return $function->getStartLine(); + } + public function getLineOfLastPropertyDefinedInScope(File $file, $lastLine) { $this->broker = new Broker(new Memory); @@ -91,6 +113,16 @@ public function isInsideMethod(File $file, LineRange $range) return $this->findMatchingMethod($file, $range) !== null; } + public function isInsideFunction(File $file, LineRange $range) + { + return $this->findMatchingFunction($file, $range) !== null; + } + + public function isLocalScope(File $file, LineRange $range) + { + return $this->isInsideMethod($file, $range) || $this->isInsideFunction($file, $range); + } + /** * @param File $file * @return PhpClass[] @@ -137,4 +169,24 @@ private function findMatchingMethod(File $file, LineRange $range) return $foundMethod; } + + private function findMatchingFunction(File $file, LineRange $range) + { + $foundFunction = null; + + $this->broker = new Broker(new Memory); + $file = $this->broker->processString($file->getCode(), $file->getRelativePath(), true); + $lastLine = $range->getEnd(); + + foreach ($file->getNamespaces() as $namespace) { + foreach ($namespace->getFunctions() as $function) { + if ($function->getStartLine() < $lastLine && $lastLine < $function->getEndLine()) { + $foundFunction = $function; + break; + } + } + } + + return $foundFunction; + } } diff --git a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php index 4cd51ef..2e5aa15 100644 --- a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php +++ b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php @@ -39,7 +39,7 @@ public function refactor(File $file, $line, Variable $oldName, Variable $newName $this->newName = $newName; $this->oldName = $oldName; - $this->assertIsInsideMethod(); + $this->assertIsLocalScope(); $this->assertVariableIsLocal($this->oldName); $this->assertVariableIsLocal($this->newName); diff --git a/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php b/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php index 2af397a..01af684 100644 --- a/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php +++ b/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php @@ -59,6 +59,13 @@ protected function assertIsInsideMethod() } } + protected function assertIsLocalScope() + { + if ( ! $this->codeAnalysis->isLocalScope($this->file, LineRange::fromSingleLine($this->line)) ) { + throw RefactoringException::rangeIsNotLocalScope(LineRange::fromSingleLine($this->line)); + } + } + protected function startEditingSession() { $buffer = $this->editor->openBuffer($this->file); @@ -75,7 +82,11 @@ protected function completeEditingSession() protected function getDefinedVariables() { - $selectedMethodLineRange = $this->codeAnalysis->findMethodRange($this->file, LineRange::fromSingleLine($this->line)); + if ($this->codeAnalysis->isInsideFunction($this->file, LineRange::fromSingleLine($this->line))) { + $selectedMethodLineRange = $this->codeAnalysis->findFunctionRange($this->file, LineRange::fromSingleLine($this->line)); + } else { + $selectedMethodLineRange = $this->codeAnalysis->findMethodRange($this->file, LineRange::fromSingleLine($this->line)); + } $definedVariables = $this->variableScanner->scanForVariables( $this->file, $selectedMethodLineRange diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php b/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php index d2319b9..0d96c5a 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php @@ -45,4 +45,12 @@ static public function rangeIsNotInsideMethod(LineRange $range) $range->getStart(), $range->getEnd() )); } + + static public function rangeIsNotLocalScope(LineRange $range) + { + return new self(sprintf( + 'The range %d-%d is not inside a method or a function.', + $range->getStart(), $range->getEnd() + )); + } } diff --git a/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php b/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php index dab67a8..830d19b 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php +++ b/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php @@ -40,12 +40,42 @@ abstract public function getMethodStartLine(File $file, LineRange $range); */ abstract public function getMethodEndLine(File $file, LineRange $range); + /** + * Get the function start line + * + * @param File $file + * @param LineRange $range + * + * @return int + */ + abstract public function getFunctionStartLine(File $file, LineRange $range); + + /** + * Get the function end line + * + * @param File $file + * @param LineRange $range + * + * @return int + */ + abstract public function getFunctionEndLine(File $file, LineRange $range); + /** * @param File $file * @param int $line */ abstract public function getLineOfLastPropertyDefinedInScope(File $file, $line); + /** + * Check if the line range is inside a local scope. A local scope being a method or a function. + * + * @param File $file + * @param LineRange $range + * + * @return bool + */ + abstract public function isLocalScope(File $file, LineRange $range); + /** * Check if the line range is inside exactly one class method. * @@ -56,6 +86,16 @@ abstract public function getLineOfLastPropertyDefinedInScope(File $file, $line); */ abstract public function isInsideMethod(File $file, LineRange $range); + /** + * Check if the line range is inside a function. + * + * @param File $file + * @param LineRange $range + * + * @return bool + */ + abstract public function isInsideFunction(File $file, LineRange $range); + /** * Find all classes in the file. * @@ -79,5 +119,21 @@ public function findMethodRange(File $file, LineRange $range) return LineRange::fromLines($methodStartLine, $methodEndLine); } + + /** + * From a range within a method, find the start and end range of that method. + * + * @param File $file + * @param LineRange $range + * + * @return LineRange + */ + public function findFunctionRange(File $file, LineRange $range) + { + $methodStartLine = $this->getFunctionStartLine($file, $range); + $methodEndLine = $this->getFunctionEndLine($file, $range); + + return LineRange::fromLines($methodStartLine, $methodEndLine); + } } From 2aaabe13e79f66c1fb4c9bd60446a5015fa881c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 21:05:06 +0200 Subject: [PATCH 02/29] Add a test for the local variable renaming inside functions --- features/rename_local_variable.feature | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/features/rename_local_variable.feature b/features/rename_local_variable.feature index 3389255..a416d81 100644 --- a/features/rename_local_variable.feature +++ b/features/rename_local_variable.feature @@ -90,3 +90,45 @@ Feature: Rename Local Variable } """ + + Scenario: Rename Variable In functions + Given a PHP File named "src/Foo.php" with: + """ + Date: Sat, 14 May 2016 21:06:09 +0200 Subject: [PATCH 03/29] Fix undeclared variable usage --- .../QafooLabs/Refactoring/Application/RenameLocalVariable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php index 2e5aa15..a8dbb90 100644 --- a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php +++ b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php @@ -61,7 +61,7 @@ private function renameLocalVariable() $definedVariables = $this->getDefinedVariables(); if ( ! $definedVariables->contains($this->oldName)) { - throw RefactoringException::variableNotInRange($this->oldName, $selectedMethodLineRange); + throw RefactoringException::variableNotInRange($this->oldName, LineRange::fromSingleLine($this->line)); } $this->session->addEdit(new RenameVariable($definedVariables, $this->oldName, $this->newName)); From 9306801baf4bad123c393d117aac6cbf6a19848d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 21:25:08 +0200 Subject: [PATCH 04/29] Allow to rename function and method arguments --- features/rename_local_variable.feature | 80 +++++++++++++++++++ .../TokenReflection/StaticCodeAnalysis.php | 4 +- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/features/rename_local_variable.feature b/features/rename_local_variable.feature index a416d81..c871968 100644 --- a/features/rename_local_variable.feature +++ b/features/rename_local_variable.feature @@ -91,6 +91,46 @@ Feature: Rename Local Variable """ + Scenario: Rename a method argument + Given a PHP File named "src/MethodArgument.php" with: + """ + getNamespaces() as $namespace) { foreach ($namespace->getClasses() as $class) { foreach ($class->getMethods() as $method) { - if ($method->getStartLine() < $lastLine && $lastLine < $method->getEndLine()) { + if ($method->getStartLine() <= $lastLine && $lastLine <= $method->getEndLine()) { $foundMethod = $method; break; } @@ -180,7 +180,7 @@ private function findMatchingFunction(File $file, LineRange $range) foreach ($file->getNamespaces() as $namespace) { foreach ($namespace->getFunctions() as $function) { - if ($function->getStartLine() < $lastLine && $lastLine < $function->getEndLine()) { + if ($function->getStartLine() <= $lastLine && $lastLine <= $function->getEndLine()) { $foundFunction = $function; break; } From b595ed0eb470322b13d1b286ced37def243e406e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 22:32:23 +0200 Subject: [PATCH 05/29] Update vendors --- composer.json | 22 +- composer.lock | 719 +++++++++++++++++++++++++++----------------------- 2 files changed, 402 insertions(+), 339 deletions(-) diff --git a/composer.json b/composer.json index e605c7a..8613ad2 100644 --- a/composer.json +++ b/composer.json @@ -8,21 +8,21 @@ ], "require": { - "nikic/php-parser": "@stable", - "beberlei/assert": "@stable", - "andrewsville/php-token-reflection": "@stable", - "symfony/finder": "~2.4@stable", - "symfony/console": "~2.4@stable", + "nikic/php-parser": "~1.2", + "beberlei/assert": "~2.3", + "andrewsville/php-token-reflection": "~1.4", + "symfony/finder": "~2.4", + "symfony/console": "~2.4", "tomphp/patch-builder": "~0.1" }, "require-dev": { - "php": ">=5.4", - "behat/behat": "~2.5@stable", - "mikey179/vfsStream": "@stable", - "phake/phake": "@stable", - "symfony/process": "@stable", - "phpunit/phpunit": "~4.6@stable" + "php": "~5.4|~7.0", + "behat/behat": "~2.5", + "mikey179/vfsStream": "~1.5", + "phake/phake": "~2.0", + "symfony/process": "~2.6", + "phpunit/phpunit": "~4.6" }, "autoload": { diff --git a/composer.lock b/composer.lock index 6bc4cf4..e82f550 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,11 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ec675be63f343e2656ad4fba790a9a74", + "hash": "5e96394b45d5549b2d6b87e40c918686", + "content-hash": "56c659a3dcb56e7c0596f0ad3468ff56", "packages": [ { "name": "andrewsville/php-token-reflection", @@ -55,20 +56,24 @@ }, { "name": "beberlei/assert", - "version": "v2.3", + "version": "v2.5", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "160eba4d1fbe692e42b3cf8a20b92ab23e3a8759" + "reference": "91e2690c4ecc8a4e3e2d333430069f6a0c694a7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/160eba4d1fbe692e42b3cf8a20b92ab23e3a8759", - "reference": "160eba4d1fbe692e42b3cf8a20b92ab23e3a8759", + "url": "https://api.github.com/repos/beberlei/assert/zipball/91e2690c4ecc8a4e3e2d333430069f6a0c694a7a", + "reference": "91e2690c4ecc8a4e3e2d333430069f6a0c694a7a", "shasum": "" }, "require": { - "ext-mbstring": "*" + "ext-mbstring": "*", + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "@stable" }, "type": "library", "extra": { @@ -100,20 +105,20 @@ "assertion", "validation" ], - "time": "2014-12-18 19:12:40" + "time": "2016-03-22 14:34:51" }, { "name": "nikic/php-parser", - "version": "v1.2.2", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "08f97eb4efa029e2fafb6d8c98b71731bf0cf621" + "reference": "f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/08f97eb4efa029e2fafb6d8c98b71731bf0cf621", - "reference": "08f97eb4efa029e2fafb6d8c98b71731bf0cf621", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51", + "reference": "f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51", "shasum": "" }, "require": { @@ -123,7 +128,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -145,7 +150,7 @@ "parser", "php" ], - "time": "2015-04-03 14:33:59" + "time": "2015-09-19 14:15:08" }, { "name": "phpspec/php-diff", @@ -182,27 +187,26 @@ }, { "name": "symfony/console", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Console", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "5b91dc4ed5eb08553f57f6df04c4730a73992667" + "url": "https://github.com/symfony/console.git", + "reference": "48221d3de4dc22d2cd57c97e8b9361821da86609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/5b91dc4ed5eb08553f57f6df04c4730a73992667", - "reference": "5b91dc4ed5eb08553f57f6df04c4730a73992667", + "url": "https://api.github.com/repos/symfony/console/zipball/48221d3de4dc22d2cd57c97e8b9361821da86609", + "reference": "48221d3de4dc22d2cd57c97e8b9361821da86609", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9", + "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" + "symfony/event-dispatcher": "~2.1|~3.0.0", + "symfony/process": "~2.1|~3.0.0" }, "suggest": { "psr/log": "For using the console logger", @@ -212,63 +216,117 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Console\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2016-04-26 12:00:47" + }, + { + "name": "symfony/finder", + "version": "v2.8.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "ca24cf2cd4e3826f571e0067e535758e73807aa1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/ca24cf2cd4e3826f571e0067e535758e73807aa1", + "reference": "ca24cf2cd4e3826f571e0067e535758e73807aa1", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Console Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2016-03-10 10:53:53" }, { - "name": "symfony/finder", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Finder", + "name": "symfony/polyfill-mbstring", + "version": "v1.1.1", "source": { "type": "git", - "url": "https://github.com/symfony/Finder.git", - "reference": "5dbe2e73a580618f5b4880fda93406eed25de251" + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "1289d16209491b584839022f29257ad859b8532d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/5dbe2e73a580618f5b4880fda93406eed25de251", - "reference": "5dbe2e73a580618f5b4880fda93406eed25de251", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", + "reference": "1289d16209491b584839022f29257ad859b8532d", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "suggest": { + "ext-mbstring": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.1-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" - } + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -276,17 +334,24 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Finder Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2016-01-20 09:13:37" }, { "name": "tomphp/patch-builder", @@ -327,27 +392,27 @@ "packages-dev": [ { "name": "behat/behat", - "version": "v2.5.4", + "version": "v2.5.5", "source": { "type": "git", "url": "https://github.com/Behat/Behat.git", - "reference": "ba257dd19d47b6e196c4e43995a2d2db4dd95991" + "reference": "c1e48826b84669c97a1efa78459aedfdcdcf2120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Behat/zipball/ba257dd19d47b6e196c4e43995a2d2db4dd95991", - "reference": "ba257dd19d47b6e196c4e43995a2d2db4dd95991", + "url": "https://api.github.com/repos/Behat/Behat/zipball/c1e48826b84669c97a1efa78459aedfdcdcf2120", + "reference": "c1e48826b84669c97a1efa78459aedfdcdcf2120", "shasum": "" }, "require": { "behat/gherkin": "~2.3.0", "php": ">=5.3.1", - "symfony/config": "~2.0", + "symfony/config": "~2.3", "symfony/console": "~2.0", "symfony/dependency-injection": "~2.0", "symfony/event-dispatcher": "~2.0", "symfony/finder": "~2.0", - "symfony/translation": "~2.0", + "symfony/translation": "~2.3", "symfony/yaml": "~2.0" }, "require-dev": { @@ -385,7 +450,7 @@ "Behat", "Symfony2" ], - "time": "2015-01-23 22:18:15" + "time": "2015-06-01 09:37:55" }, { "name": "behat/gherkin", @@ -450,16 +515,16 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { @@ -470,7 +535,7 @@ "ext-pdo": "*", "ext-phar": "*", "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { @@ -479,8 +544,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, "notification-url": "https://packagist.org/downloads/", @@ -500,20 +565,20 @@ "constructor", "instantiate" ], - "time": "2014-10-13 12:58:55" + "time": "2015-06-14 21:17:01" }, { "name": "mikey179/vfsStream", - "version": "v1.5.0", + "version": "v1.6.3", "source": { "type": "git", "url": "https://github.com/mikey179/vfsStream.git", - "reference": "4dc0d2f622412f561f5b242b19b98068bbbc883a" + "reference": "c19925cd0390d3c436a0203ae859afa460d0474b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/4dc0d2f622412f561f5b242b19b98068bbbc883a", - "reference": "4dc0d2f622412f561f5b242b19b98068bbbc883a", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/c19925cd0390d3c436a0203ae859afa460d0474b", + "reference": "c19925cd0390d3c436a0203ae859afa460d0474b", "shasum": "" }, "require": { @@ -525,7 +590,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -546,26 +611,28 @@ ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2015-03-29 11:19:49" + "time": "2016-04-09 09:42:01" }, { "name": "phake/phake", - "version": "v2.0.2", + "version": "v2.3.0", "source": { "type": "git", "url": "https://github.com/mlively/Phake.git", - "reference": "15d688aa23e6d5db433accb75feea6c0a1cdd1f1" + "reference": "2202d361d34f2712dcc257afdedc6c30060dc9bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mlively/Phake/zipball/15d688aa23e6d5db433accb75feea6c0a1cdd1f1", - "reference": "15d688aa23e6d5db433accb75feea6c0a1cdd1f1", + "url": "https://api.github.com/repos/mlively/Phake/zipball/2202d361d34f2712dcc257afdedc6c30060dc9bd", + "reference": "2202d361d34f2712dcc257afdedc6c30060dc9bd", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "sebastian/comparator": "~1.1" }, "require-dev": { + "codeclimate/php-test-reporter": "dev-master", "doctrine/common": "2.3.*", "ext-soap": "*", "hamcrest/hamcrest-php": "1.1.*", @@ -578,7 +645,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0.0-dev" } }, "autoload": { @@ -602,7 +669,7 @@ "mock", "testing" ], - "time": "2015-03-21 18:05:30" + "time": "2016-03-04 18:49:33" }, { "name": "phpdocumentor/reflection-docblock", @@ -655,22 +722,24 @@ }, { "name": "phpspec/prophecy", - "version": "1.4.0", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5" + "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5", - "reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972", + "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" + "sebastian/comparator": "~1.1", + "sebastian/recursion-context": "~1.0" }, "require-dev": { "phpspec/phpspec": "~2.0" @@ -678,7 +747,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "1.5.x-dev" } }, "autoload": { @@ -711,20 +780,20 @@ "spy", "stub" ], - "time": "2015-03-27 19:31:25" + "time": "2016-02-15 07:46:21" }, { "name": "phpunit/php-code-coverage", - "version": "2.0.16", + "version": "2.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c" + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c", - "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", "shasum": "" }, "require": { @@ -732,7 +801,7 @@ "phpunit/php-file-iterator": "~1.3", "phpunit/php-text-template": "~1.2", "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "~1.0", + "sebastian/environment": "^1.3.2", "sebastian/version": "~1.0" }, "require-dev": { @@ -747,7 +816,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.2.x-dev" } }, "autoload": { @@ -773,20 +842,20 @@ "testing", "xunit" ], - "time": "2015-04-11 04:35:00" + "time": "2015-10-06 15:47:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", "shasum": "" }, "require": { @@ -820,20 +889,20 @@ "filesystem", "iterator" ], - "time": "2015-04-02 05:19:05" + "time": "2015-06-21 13:08:43" }, { "name": "phpunit/php-text-template", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { @@ -842,20 +911,17 @@ "type": "library", "autoload": { "classmap": [ - "Text/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -864,35 +930,35 @@ "keywords": [ "template" ], - "time": "2014-01-30 17:20:04" + "time": "2015-06-21 13:50:34" }, { "name": "phpunit/php-timer", - "version": "1.0.5", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4|~5" + }, "type": "library", "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -908,20 +974,20 @@ "keywords": [ "timer" ], - "time": "2013-08-02 07:42:54" + "time": "2016-05-12 18:03:57" }, { "name": "phpunit/php-token-stream", - "version": "1.4.1", + "version": "1.4.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "eab81d02569310739373308137284e0158424330" + "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", - "reference": "eab81d02569310739373308137284e0158424330", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", + "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", "shasum": "" }, "require": { @@ -957,20 +1023,20 @@ "keywords": [ "tokenizer" ], - "time": "2015-04-08 04:46:07" + "time": "2015-09-15 10:49:45" }, { "name": "phpunit/phpunit", - "version": "4.6.4", + "version": "4.8.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "163232991e652e6efed2f8470326fffa61e848e2" + "reference": "a1066c562c52900a142a0e2bbf0582994671385e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/163232991e652e6efed2f8470326fffa61e848e2", - "reference": "163232991e652e6efed2f8470326fffa61e848e2", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e", + "reference": "a1066c562c52900a142a0e2bbf0582994671385e", "shasum": "" }, "require": { @@ -980,15 +1046,15 @@ "ext-reflection": "*", "ext-spl": "*", "php": ">=5.3.3", - "phpspec/prophecy": "~1.3,>=1.3.1", - "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpspec/prophecy": "^1.3.1", + "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0", + "phpunit/php-timer": ">=1.0.6", "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.1", "sebastian/diff": "~1.2", - "sebastian/environment": "~1.2", + "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", "sebastian/global-state": "~1.0", "sebastian/version": "~1.0", @@ -1003,7 +1069,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.6.x-dev" + "dev-master": "4.8.x-dev" } }, "autoload": { @@ -1029,26 +1095,27 @@ "testing", "xunit" ], - "time": "2015-04-11 05:23:21" + "time": "2016-03-14 06:16:08" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.1", + "version": "2.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "74ffb87f527f24616f72460e54b595f508dccb5c" + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", - "reference": "74ffb87f527f24616f72460e54b595f508dccb5c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", "shasum": "" }, "require": { - "doctrine/instantiator": "~1.0,>=1.0.2", + "doctrine/instantiator": "^1.0.2", "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2" + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" }, "require-dev": { "phpunit/phpunit": "~4.4" @@ -1084,20 +1151,20 @@ "mock", "xunit" ], - "time": "2015-04-02 05:36:41" + "time": "2015-10-02 06:51:40" }, { "name": "sebastian/comparator", - "version": "1.1.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", - "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", "shasum": "" }, "require": { @@ -1111,7 +1178,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -1148,32 +1215,32 @@ "compare", "equality" ], - "time": "2015-01-29 16:28:08" + "time": "2015-07-26 15:48:44" }, { "name": "sebastian/diff", - "version": "1.3.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "~4.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1196,24 +1263,24 @@ } ], "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", + "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ "diff" ], - "time": "2015-02-22 15:13:53" + "time": "2015-12-08 07:14:41" }, { "name": "sebastian/environment", - "version": "1.2.2", + "version": "1.3.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + "reference": "2292b116f43c272ff4328083096114f84ea46a56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", - "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/2292b116f43c272ff4328083096114f84ea46a56", + "reference": "2292b116f43c272ff4328083096114f84ea46a56", "shasum": "" }, "require": { @@ -1250,20 +1317,20 @@ "environment", "hhvm" ], - "time": "2015-01-01 10:01:08" + "time": "2016-05-04 07:59:13" }, { "name": "sebastian/exporter", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "84839970d05254c73cde183a721c7af13aede943" + "reference": "7ae5513327cb536431847bcc0c10edba2701064e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", - "reference": "84839970d05254c73cde183a721c7af13aede943", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", + "reference": "7ae5513327cb536431847bcc0c10edba2701064e", "shasum": "" }, "require": { @@ -1316,20 +1383,20 @@ "export", "exporter" ], - "time": "2015-01-27 07:23:06" + "time": "2015-06-21 07:55:53" }, { "name": "sebastian/global-state", - "version": "1.0.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", - "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", "shasum": "" }, "require": { @@ -1367,20 +1434,20 @@ "keywords": [ "global state" ], - "time": "2014-10-06 09:23:50" + "time": "2015-10-12 03:26:01" }, { "name": "sebastian/recursion-context", - "version": "1.0.0", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + "reference": "913401df809e99e4f47b27cdd781f4a258d58791" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", - "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", + "reference": "913401df809e99e4f47b27cdd781f4a258d58791", "shasum": "" }, "require": { @@ -1420,20 +1487,20 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-01-24 09:48:32" + "time": "2015-11-11 19:50:13" }, { "name": "sebastian/version", - "version": "1.0.5", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", - "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", "shasum": "" }, "type": "library", @@ -1455,145 +1522,147 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-02-24 06:35:25" + "time": "2015-06-21 13:59:46" }, { "name": "symfony/config", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Config", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "d91be01336605db8da21b79bc771e46a7276d1bc" + "url": "https://github.com/symfony/config.git", + "reference": "edbbcf33cffa2a85104fc80de8dc052cc51596bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/d91be01336605db8da21b79bc771e46a7276d1bc", - "reference": "d91be01336605db8da21b79bc771e46a7276d1bc", + "url": "https://api.github.com/repos/symfony/config/zipball/edbbcf33cffa2a85104fc80de8dc052cc51596bb", + "reference": "edbbcf33cffa2a85104fc80de8dc052cc51596bb", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/filesystem": "~2.3" + "php": ">=5.3.9", + "symfony/filesystem": "~2.3|~3.0.0" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Config\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Config Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2016-04-20 18:52:26" }, { "name": "symfony/dependency-injection", - "version": "v2.6.6", - "target-dir": "Symfony/Component/DependencyInjection", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "8e9007012226b4bd41f8afed855c452cf5edc3a6" + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "bd04588c087651ceffdc45d40dc4de05af9c7c52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/8e9007012226b4bd41f8afed855c452cf5edc3a6", - "reference": "8e9007012226b4bd41f8afed855c452cf5edc3a6", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/bd04588c087651ceffdc45d40dc4de05af9c7c52", + "reference": "bd04588c087651ceffdc45d40dc4de05af9c7c52", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "conflict": { "symfony/expression-language": "<2.6" }, "require-dev": { - "symfony/config": "~2.2", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/yaml": "~2.1" + "symfony/config": "~2.2|~3.0.0", + "symfony/expression-language": "~2.6|~3.0.0", + "symfony/yaml": "~2.1|~3.0.0" }, "suggest": { "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\DependencyInjection\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony DependencyInjection Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2016-05-09 18:12:35" }, { "name": "symfony/event-dispatcher", - "version": "v2.6.6", - "target-dir": "Symfony/Component/EventDispatcher", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "a158f13992a3147d466af7a23b564ac719a4ddd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a158f13992a3147d466af7a23b564ac719a4ddd8", + "reference": "a158f13992a3147d466af7a23b564ac719a4ddd8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/stopwatch": "~2.3" + "symfony/config": "~2.0,>=2.0.5|~3.0.0", + "symfony/dependency-injection": "~2.6|~3.0.0", + "symfony/expression-language": "~2.6|~3.0.0", + "symfony/stopwatch": "~2.3|~3.0.0" }, "suggest": { "symfony/dependency-injection": "", @@ -1602,156 +1671,159 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2015-03-13 17:37:22" + "homepage": "https://symfony.com", + "time": "2016-05-03 18:59:18" }, { "name": "symfony/filesystem", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Filesystem", + "version": "v3.0.6", "source": { "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "4983964b3693e4f13449cb3800c64a9112c301b4" + "url": "https://github.com/symfony/filesystem.git", + "reference": "74fec3511b62cb934b64bce1d96f06fffa4beafd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/4983964b3693e4f13449cb3800c64a9112c301b4", - "reference": "4983964b3693e4f13449cb3800c64a9112c301b4", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/74fec3511b62cb934b64bce1d96f06fffa4beafd", + "reference": "74fec3511b62cb934b64bce1d96f06fffa4beafd", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "php": ">=5.5.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Filesystem\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Filesystem Component", - "homepage": "http://symfony.com", - "time": "2015-03-22 16:55:57" + "homepage": "https://symfony.com", + "time": "2016-04-12 18:09:53" }, { "name": "symfony/process", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Process", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552" + "url": "https://github.com/symfony/process.git", + "reference": "1276bd9be89be039748cf753a2137f4ef149cd74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/a8bebaec1a9dc6cde53e0250e32917579b0be552", - "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552", + "url": "https://api.github.com/repos/symfony/process/zipball/1276bd9be89be039748cf753a2137f4ef149cd74", + "reference": "1276bd9be89be039748cf753a2137f4ef149cd74", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Process\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Process Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2016-04-14 15:22:22" }, { "name": "symfony/translation", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Translation", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/Translation.git", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af" + "url": "https://github.com/symfony/translation.git", + "reference": "d60b8e076d22953aabebeebda53bf334438e7aca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af", + "url": "https://api.github.com/repos/symfony/translation/zipball/d60b8e076d22953aabebeebda53bf334438e7aca", + "reference": "d60b8e076d22953aabebeebda53bf334438e7aca", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/config": "<2.7" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.3,>=2.3.12", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/yaml": "~2.2" + "symfony/config": "~2.8", + "symfony/intl": "~2.4|~3.0.0", + "symfony/yaml": "~2.2|~3.0.0" }, "suggest": { "psr/log": "To use logging capability in translator", @@ -1761,101 +1833,92 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Translation\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Translation Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2016-03-25 01:40:30" }, { "name": "symfony/yaml", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Yaml", + "version": "v2.8.6", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "174f009ed36379a801109955fc5a71a49fe62dd4" + "url": "https://github.com/symfony/yaml.git", + "reference": "e4fbcc65f90909c999ac3b4dfa699ee6563a9940" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4", - "reference": "174f009ed36379a801109955fc5a71a49fe62dd4", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e4fbcc65f90909c999ac3b4dfa699ee6563a9940", + "reference": "e4fbcc65f90909c999ac3b4dfa699ee6563a9940", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2016-03-29 19:00:15" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "nikic/php-parser": 0, - "beberlei/assert": 0, - "andrewsville/php-token-reflection": 0, - "symfony/finder": 0, - "symfony/console": 0, - "behat/behat": 0, - "mikey179/vfsstream": 0, - "phake/phake": 0, - "symfony/process": 0, - "phpunit/phpunit": 0 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], "platform-dev": { - "php": ">=5.4" + "php": "~5.4|~7.0" } } From 867b96e67317914fc06fe49704f814d10a3aee1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:15:26 +0200 Subject: [PATCH 06/29] Use nikic/PHP-Parser ~2.0 --- composer.json | 2 +- composer.lock | 30 +++++++++++-------- .../PHPParser/ParserPhpNameScanner.php | 16 ++++------ .../PHPParser/ParserVariableScanner.php | 16 ++++------ .../Visitor/LineRangeStatementCollector.php | 9 +++--- .../Visitor/LocalVariableClassifier.php | 28 ++++++++--------- .../PHPParser/Visitor/NodeConnector.php | 12 ++++---- .../PHPParser/Visitor/PhpNameCollector.php | 26 +++++++--------- 8 files changed, 63 insertions(+), 76 deletions(-) diff --git a/composer.json b/composer.json index 8613ad2..52bcc2c 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ ], "require": { - "nikic/php-parser": "~1.2", + "nikic/php-parser": "~2.1", "beberlei/assert": "~2.3", "andrewsville/php-token-reflection": "~1.4", "symfony/finder": "~2.4", diff --git a/composer.lock b/composer.lock index e82f550..30257ec 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": "5e96394b45d5549b2d6b87e40c918686", - "content-hash": "56c659a3dcb56e7c0596f0ad3468ff56", + "hash": "65e64a201ab092fabc9d1d854154d30f", + "content-hash": "e3d9aa5afaf15f0d99d52dc2d228fbf1", "packages": [ { "name": "andrewsville/php-token-reflection", @@ -109,32 +109,38 @@ }, { "name": "nikic/php-parser", - "version": "v1.4.1", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51" + "reference": "47b254ea51f1d6d5dc04b9b299e88346bf2369e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51", - "reference": "f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/47b254ea51f1d6d5dc04b9b299e88346bf2369e3", + "reference": "47b254ea51f1d6d5dc04b9b299e88346bf2369e3", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3" + "php": ">=5.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" }, + "bin": [ + "bin/php-parse" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.1-dev" } }, "autoload": { - "files": [ - "lib/bootstrap.php" - ] + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -150,7 +156,7 @@ "parser", "php" ], - "time": "2015-09-19 14:15:08" + "time": "2016-04-19 13:41:41" }, { "name": "phpspec/php-diff", diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScanner.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScanner.php index 2b2bba1..52487cc 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScanner.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScanner.php @@ -2,30 +2,26 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser; +use PhpParser\NodeTraverser; +use PhpParser\ParserFactory; use QafooLabs\Refactoring\Adapters\PHPParser\Visitor\PhpNameCollector; use QafooLabs\Refactoring\Domain\Services\PhpNameScanner; use QafooLabs\Refactoring\Domain\Model\File; -use QafooLabs\Refactoring\Domain\Model\LineRange; -use QafooLabs\Refactoring\Domain\Model\UseStatement; use QafooLabs\Refactoring\Domain\Model\PhpName; use QafooLabs\Refactoring\Domain\Model\PhpNameOccurance; -use PHPParser_Parser; -use PHPParser_Lexer; -use PHPParser_NodeTraverser; -use PHPParser_Error; - class ParserPhpNameScanner implements PhpNameScanner { public function findNames(File $file) { - $parser = new PHPParser_Parser(new PHPParser_Lexer()); + $parserFactory = new ParserFactory(); + $parser = $parserFactory->create(ParserFactory::PREFER_PHP7); $collector = new PhpNameCollector(); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); try { $stmts = $parser->parse($file->getCode()); - } catch (PHPParser_Error $e) { + } catch (\PHPParser\Error $e) { throw new \RuntimeException("Error parsing " . $file->getRelativePath() .": " . $e->getMessage(), 0, $e); } diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php index 1edbd68..ff51fd5 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php @@ -14,6 +14,8 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser; +use PhpParser\NodeTraverser; +use PhpParser\ParserFactory; use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Model\DefinedVariables; @@ -23,23 +25,17 @@ use QafooLabs\Refactoring\Adapters\PHPParser\Visitor\LocalVariableClassifier; use QafooLabs\Refactoring\Adapters\PHPParser\Visitor\NodeConnector; -use PHPParser_Parser; -use PHPParser_Lexer; -use PHPParser_Node; -use PHPParser_Node_Stmt; -use PHPParser_Node_Expr_FuncCall; -use PHPParser_NodeTraverser; - class ParserVariableScanner implements VariableScanner { public function scanForVariables(File $file, LineRange $range) { - $parser = new PHPParser_Parser(new PHPParser_Lexer()); + $parserFactory = new ParserFactory(); + $parser = $parserFactory->create(ParserFactory::PREFER_PHP7); $stmts = $parser->parse($file->getCode()); $collector = new LineRangeStatementCollector($range); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor(new NodeConnector); $traverser->addVisitor($collector); @@ -52,7 +48,7 @@ public function scanForVariables(File $file, LineRange $range) } $localVariableClassifier = new LocalVariableClassifier(); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor($localVariableClassifier); $traverser->traverse($selectedStatements); diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollector.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollector.php index 0e4f0b8..6120220 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollector.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollector.php @@ -14,15 +14,14 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser\Visitor; +use PhpParser\Node; +use PhpParser\NodeVisitorAbstract; use QafooLabs\Refactoring\Domain\Model\LineRange; -use PHPParser_Node; -use PHPParser_Node_Stmt; -use PHPParser_Node_Expr_FuncCall; /** * Given a line range, collect the AST slice that is inside that range. */ -class LineRangeStatementCollector extends \PHPParser_NodeVisitorAbstract +class LineRangeStatementCollector extends NodeVisitorAbstract { /** * @var LineRange @@ -36,7 +35,7 @@ public function __construct(LineRange $lineRange) $this->statements = new \SplObjectStorage(); } - public function enterNode(PHPParser_Node $node) + public function enterNode(Node $node) { if ( ! $this->lineRange->isInRange($node->getLine())) { return; diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php index e198014..3cf3b0c 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php @@ -14,19 +14,15 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser\Visitor; -use PHPParser_Node; -use PHPParser_NodeVisitorAbstract; -use PHPParser_Node_Expr_Variable; -use PHPParser_Node_Expr_Assign; -use PHPParser_Node_Expr_ArrayDimFetch; -use PHPParser_Node_Param; +use PhpParser\Node; +use PhpParser\NodeVisitorAbstract; use SplObjectStorage; /** * Classify local variables into assignments and usages, * permanent and temporary variables. */ -class LocalVariableClassifier extends PHPParser_NodeVisitorAbstract +class LocalVariableClassifier extends NodeVisitorAbstract { private $localVariables = array(); private $assignments = array(); @@ -37,32 +33,32 @@ public function __construct() $this->seenAssignmentVariables = new SplObjectStorage(); } - public function enterNode(PHPParser_Node $node) + public function enterNode(Node $node) { - if ($node instanceof PHPParser_Node_Expr_Variable) { + if ($node instanceof Node\Expr\Variable) { $this->enterVariableNode($node); } - if ($node instanceof PHPParser_Node_Expr_Assign) { + if ($node instanceof Node\Expr\Assign) { $this->enterAssignment($node); } - if ($node instanceof PHPParser_Node_Param) { + if ($node instanceof Node\Param) { $this->enterParam($node); } } - private function enterParam($node) + private function enterParam(Node\Param $node) { $this->assignments[$node->name][] = $node->getLine(); } - private function enterAssignment($node) + private function enterAssignment(Node\Expr\Assign $node) { - if ($node->var instanceof PHPParser_Node_Expr_Variable) { + if ($node->var instanceof Node\Expr\Variable) { $this->assignments[$node->var->name][] = $node->getLine(); $this->seenAssignmentVariables->attach($node->var); - } else if ($node->var instanceof PHPParser_Node_Expr_ArrayDimFetch) { + } else if ($node instanceof Node\Expr\ArrayDimFetch) { // $foo[] = "baz" is both a read and a write access to $foo $this->localVariables[$node->var->var->name][] = $node->getLine(); $this->assignments[$node->var->var->name][] = $node->getLine(); @@ -70,7 +66,7 @@ private function enterAssignment($node) } } - private function enterVariableNode($node) + private function enterVariableNode(Node\Expr\Variable $node) { if ($node->name === "this" || $this->seenAssignmentVariables->contains($node)) { return; diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/NodeConnector.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/NodeConnector.php index 6eb323c..6ce56be 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/NodeConnector.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/NodeConnector.php @@ -13,21 +13,21 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser\Visitor; -use PHPParser_NodeVisitorAbstract; -use PHPParser_Node; +use PhpParser\Node; +use PhpParser\NodeVisitorAbstract; /** * Connects the nodes. * * @author Johannes M. Schmitt */ -class NodeConnector extends PHPParser_NodeVisitorAbstract +class NodeConnector extends NodeVisitorAbstract { - public function enterNode(PHPParser_Node $node) + public function enterNode(Node $node) { $subNodes = array(); foreach ($node as $subNode) { - if ($subNode instanceof PHPParser_Node) { + if ($subNode instanceof Node) { $subNodes[] = $subNode; continue; } else if (!is_array($subNode)) { @@ -38,7 +38,7 @@ public function enterNode(PHPParser_Node $node) } for ($i=0,$c=count($subNodes); $i<$c; $i++) { - if (!$subNodes[$i] instanceof PHPParser_Node) { + if (!$subNodes[$i] instanceof Node) { continue; } diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PhpNameCollector.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PhpNameCollector.php index db5d3d9..8760cb5 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PhpNameCollector.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PhpNameCollector.php @@ -13,19 +13,13 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser\Visitor; -use PHPParser_Node; -use PHPParser_Node_Name; -use PHPParser_Node_Stmt_Namespace; -use PHPParser_Node_Stmt_Use; -use PHPParser_Node_Stmt_Class; -use PHPParser_Node_Stmt_UseUse; -use PHPParser_Node_Expr_New; -use PHPParser_Node_Expr_StaticCall; +use PhpParser\Node; +use PhpParser\NodeVisitorAbstract; /** * Visitor for PHP Parser collecting PHP Names from an AST. */ -class PhpNameCollector extends \PHPParser_NodeVisitorAbstract +class PhpNameCollector extends NodeVisitorAbstract { /** * @var array @@ -40,11 +34,11 @@ class PhpNameCollector extends \PHPParser_NodeVisitorAbstract */ private $currentNamespace; - public function enterNode(PHPParser_Node $node) + public function enterNode(Node $node) { - if ($node instanceof PHPParser_Node_Stmt_Use) { + if ($node instanceof Node\Stmt\Use_) { foreach ($node->uses as $use) { - if ($use instanceof PHPParser_Node_Stmt_UseUse) { + if ($use instanceof Node\Stmt\UseUse) { $name = implode('\\', $use->name->parts); $this->useStatements[$use->alias] = $name; @@ -59,7 +53,7 @@ public function enterNode(PHPParser_Node $node) } - if ($node instanceof PHPParser_Node_Expr_New && $node->class instanceof PHPParser_Node_Name) { + if ($node instanceof Node\Expr\New_ && $node->class instanceof Node\Name) { $usedAlias = implode('\\', $node->class->parts); $this->nameDeclarations[] = array( @@ -70,7 +64,7 @@ public function enterNode(PHPParser_Node $node) ); } - if ($node instanceof PHPParser_Node_Expr_StaticCall && $node->class instanceof PHPParser_Node_Name) { + if ($node instanceof Node\Expr\StaticCall && $node->class instanceof Node\Name) { $usedAlias = implode('\\', $node->class->parts); $this->nameDeclarations[] = array( @@ -81,7 +75,7 @@ public function enterNode(PHPParser_Node $node) ); } - if ($node instanceof PHPParser_Node_Stmt_Class) { + if ($node instanceof Node\Stmt\Class_) { $className = $node->name; $this->nameDeclarations[] = array( @@ -114,7 +108,7 @@ public function enterNode(PHPParser_Node $node) } } - if ($node instanceof PHPParser_Node_Stmt_Namespace) { + if ($node instanceof Node\Stmt\Namespace_) { $this->currentNamespace = implode('\\', $node->name->parts); $this->useStatements = array(); From 3f4e7a88015ef712d2e13d6325e480457a649055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:16:08 +0200 Subject: [PATCH 07/29] Fix case in method call --- src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php index 243ced3..84af2f0 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php @@ -109,7 +109,7 @@ public function testRegression5() $changed = $name->change($from, $to); $this->assertEquals('Qafoo\ChangeTrack\Analyzer\ChangeFeed', $changed->fullyQualifiedName()); - $this->assertEQuals('Analyzer\ChangeFeed', $changed->relativeName()); + $this->assertEquals('Analyzer\ChangeFeed', $changed->relativeName()); } public function testRegression6() From ffb48679f91f88a53716e02bb70dd84b432ea55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:16:49 +0200 Subject: [PATCH 08/29] Prefer single quotes when possible --- src/bin/compile | 2 +- src/bin/refactor | 2 +- .../PHPParser/ParserPhpNameScanner.php | 2 +- .../PHPParser/ParserVariableScanner.php | 2 +- .../Visitor/LocalVariableClassifier.php | 2 +- .../TokenReflection/StaticCodeAnalysis.php | 10 +++++----- .../Refactoring/Domain/Model/Directory.php | 2 +- .../Refactoring/Domain/Model/File.php | 8 ++++---- .../Refactoring/Domain/Model/LineRange.php | 2 +- .../Domain/Model/MethodSignature.php | 2 +- .../Refactoring/Domain/Model/PhpName.php | 2 +- .../Refactoring/Domain/Model/PhpNameChange.php | 2 +- .../Refactoring/Utils/ValueObject.php | 4 ++-- .../PHPParser/ParserPhpNameScannerTest.php | 6 +++--- .../LineRangeStatementCollectorTest.php | 4 ++-- .../Visitor/LocalVariableClassifierTest.php | 18 +++++++++--------- .../Application/RenameLocalVariableTest.php | 6 +++--- .../Application/Service/ExtractMethodTest.php | 8 ++++---- .../Refactoring/Domain/Model/LineRangeTest.php | 2 +- .../Domain/Model/MethodSignatureTest.php | 8 ++++---- .../Refactoring/Domain/Model/PhpNameTest.php | 16 ++++++++-------- .../Utils/CallbackFilterIteratorTest.php | 2 +- 22 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/bin/compile b/src/bin/compile index 68b0dcd..bc3c8ec 100755 --- a/src/bin/compile +++ b/src/bin/compile @@ -2,7 +2,7 @@ parse($file->getCode()); } catch (\PHPParser\Error $e) { - throw new \RuntimeException("Error parsing " . $file->getRelativePath() .": " . $e->getMessage(), 0, $e); + throw new \RuntimeException('Error parsing ' . $file->getRelativePath() . ': ' . $e->getMessage(), 0, $e); } $traverser->addVisitor($collector); diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php index ff51fd5..e8adfea 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php @@ -44,7 +44,7 @@ public function scanForVariables(File $file, LineRange $range) $selectedStatements = $collector->getStatements(); if ( ! $selectedStatements) { - throw new \RuntimeException("No statements found in line range."); + throw new \RuntimeException('No statements found in line range.'); } $localVariableClassifier = new LocalVariableClassifier(); diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php index 3cf3b0c..7e4ec88 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php @@ -68,7 +68,7 @@ private function enterAssignment(Node\Expr\Assign $node) private function enterVariableNode(Node\Expr\Variable $node) { - if ($node->name === "this" || $this->seenAssignmentVariables->contains($node)) { + if ($node->name === 'this' || $this->seenAssignmentVariables->contains($node)) { return; } diff --git a/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php b/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php index cf771a3..d73294d 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php +++ b/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php @@ -45,7 +45,7 @@ public function getMethodEndLine(File $file, LineRange $range) $method = $this->findMatchingMethod($file, $range); if ($method === null) { - throw new \InvalidArgumentException("Could not find method end line."); + throw new \InvalidArgumentException('Could not find method end line.'); } return $method->getEndLine(); @@ -56,7 +56,7 @@ public function getMethodStartLine(File $file, LineRange $range) $method = $this->findMatchingMethod($file, $range); if ($method === null) { - throw new \InvalidArgumentException("Could not find method start line."); + throw new \InvalidArgumentException('Could not find method start line.'); } return $method->getStartLine(); @@ -67,7 +67,7 @@ public function getFunctionEndLine(File $file, LineRange $range) $function = $this->findMatchingFunction($file, $range); if ($function === null) { - throw new \InvalidArgumentException("Could not find function end line."); + throw new \InvalidArgumentException('Could not find function end line.'); } return $function->getEndLine(); @@ -78,7 +78,7 @@ public function getFunctionStartLine(File $file, LineRange $range) $function = $this->findMatchingFunction($file, $range); if ($function === null) { - throw new \InvalidArgumentException("Could not find function start line."); + throw new \InvalidArgumentException('Could not find function start line.'); } return $function->getStartLine(); @@ -105,7 +105,7 @@ public function getLineOfLastPropertyDefinedInScope(File $file, $lastLine) } } - throw new \InvalidArgumentException("Could not find method start line."); + throw new \InvalidArgumentException('Could not find method start line.'); } public function isInsideMethod(File $file, LineRange $range) diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/Directory.php b/src/main/QafooLabs/Refactoring/Domain/Model/Directory.php index 4b4ceb4..f6d3527 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/Directory.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/Directory.php @@ -64,7 +64,7 @@ public function findAllPhpFilesRecursivly() RecursiveIteratorIterator::LEAVES_ONLY ), function (SplFileInfo $file) { - return substr($file->getFilename(), -4) === ".php"; + return substr($file->getFilename(), -4) === '.php'; } ), function ($file) use ($workingDirectory) { diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/File.php b/src/main/QafooLabs/Refactoring/Domain/Model/File.php index 40fc0a8..af021ad 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/File.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/File.php @@ -30,12 +30,12 @@ class File public static function createFromPath($path, $workingDirectory) { if ( ! file_exists($path) || ! is_file($path)) { - throw new \InvalidArgumentException("Not a valid file: " . $path); + throw new \InvalidArgumentException('Not a valid file: ' . $path); } $code = file_get_contents($path); $workingDirectory = rtrim($workingDirectory, '/\\'); - $relativePath = ltrim(str_replace($workingDirectory, "", $path), "/\\"); + $relativePath = ltrim(str_replace($workingDirectory, '', $path), "/\\"); // converted mixed, wrapped, absolute paths on windows if (DIRECTORY_SEPARATOR === '\\' && strpos($relativePath, '://') !== FALSE) { @@ -92,7 +92,7 @@ public function extractPsr0ClassName() private function parseFileForPsr0ClassShortName() { - return str_replace(".php", "", $this->getBaseName()); + return str_replace('.php', '', $this->getBaseName()); } private function parseFileForPsr0NamespaceName() @@ -119,7 +119,7 @@ private function parseFileForPsr0NamespaceName() array_pop($namespace); - return str_replace(".php", "", implode("\\", $namespace)); + return str_replace('.php', '', implode("\\", $namespace)); } private function startsWithLowerCase($string) diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/LineRange.php b/src/main/QafooLabs/Refactoring/Domain/Model/LineRange.php index 84ce74a..0de7ccd 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/LineRange.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/LineRange.php @@ -51,7 +51,7 @@ static public function fromLines($start, $end) */ static public function fromString($range) { - list($start, $end) = explode("-", $range); + list($start, $end) = explode('-', $range); return self::fromLines($start, $end); } diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php b/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php index caf90a3..7f76eef 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php @@ -47,7 +47,7 @@ private function change($flags) } if ( ! in_array(($flags & $visibility), $allowedVisibilities)) { - throw new \InvalidArgumentException("Mix of visibilities is not allowed."); + throw new \InvalidArgumentException('Mix of visibilities is not allowed.'); } return $flags; diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php b/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php index a7889f4..f9c2854 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php @@ -184,7 +184,7 @@ public function __toString() public function hashCode() { - return "1373136332" . $this->fullyQualifiedName . $this->relativeName; + return '1373136332' . $this->fullyQualifiedName . $this->relativeName; } public function fullyQualified() diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/PhpNameChange.php b/src/main/QafooLabs/Refactoring/Domain/Model/PhpNameChange.php index 3544242..fbe70f8 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/PhpNameChange.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/PhpNameChange.php @@ -38,6 +38,6 @@ public function change(PhpName $name) public function hashCode() { - return "1373136290" . $this->fromName->hashCode() . $this->toName->hashCode(); + return '1373136290' . $this->fromName->hashCode() . $this->toName->hashCode(); } } diff --git a/src/main/QafooLabs/Refactoring/Utils/ValueObject.php b/src/main/QafooLabs/Refactoring/Utils/ValueObject.php index 5ac0375..ae71e7b 100644 --- a/src/main/QafooLabs/Refactoring/Utils/ValueObject.php +++ b/src/main/QafooLabs/Refactoring/Utils/ValueObject.php @@ -23,13 +23,13 @@ abstract class ValueObject { final public function __set($name, $value) { - throw new \BadmethodCallException("Cannot set values on a value object."); + throw new \BadmethodCallException('Cannot set values on a value object.'); } public function __get($name) { if ( ! isset($this->$name)) { - throw new \RuntimeException(sprintf("Variable %s does not exist on %s.", $name, get_class($this))); + throw new \RuntimeException(sprintf('Variable %s does not exist on %s.', $name, get_class($this))); } return $this->$name; diff --git a/src/test/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScannerTest.php b/src/test/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScannerTest.php index 40a127b..9d2e83d 100644 --- a/src/test/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScannerTest.php +++ b/src/test/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScannerTest.php @@ -31,7 +31,7 @@ public function testFindNames() public function testRegressionFindNamesDetectsFQCNCorrectly() { - $file = new File("Fqcn.php", <<<'PHP' + $file = new File('Fqcn.php', <<<'PHP' statements('$this->foo(bar(baz()));'); - $collector = new LineRangeStatementCollector($this->range("2-2")); + $collector = new LineRangeStatementCollector($this->range('2-2')); $this->traverse($stmts, $collector); @@ -54,7 +54,7 @@ private function range($range) private function statements($code) { - if (strpos($code, "enterNode($variable); @@ -24,8 +24,8 @@ public function givenAssignment_WhenClassification_ThenAssignmentFound() { $classifier = new LocalVariableClassifier(); $assign = new \PHPParser_Node_Expr_Assign( - new \PHPParser_Node_Expr_Variable("foo"), - new \PHPParser_Node_Expr_Variable("bar") + new \PHPParser_Node_Expr_Variable('foo'), + new \PHPParser_Node_Expr_Variable('bar') ); $classifier->enterNode($assign); @@ -40,8 +40,8 @@ public function givenAssignmentAndReadOfSameVariable_WhenClassification_ThenFind { $classifier = new LocalVariableClassifier(); $assign = new \PHPParser_Node_Expr_Assign( - new \PHPParser_Node_Expr_Variable("foo"), - new \PHPParser_Node_Expr_Variable("foo") + new \PHPParser_Node_Expr_Variable('foo'), + new \PHPParser_Node_Expr_Variable('foo') ); $traverser = new \PHPParser_NodeTraverser; @@ -58,7 +58,7 @@ public function givenAssignmentAndReadOfSameVariable_WhenClassification_ThenFind public function givenThisVariable_WhenClassification_ThenNoLocalVariables() { $classifier = new LocalVariableClassifier(); - $variable = new \PHPParser_Node_Expr_Variable("this"); + $variable = new \PHPParser_Node_Expr_Variable('this'); $classifier->enterNode($variable); @@ -71,7 +71,7 @@ public function givenThisVariable_WhenClassification_ThenNoLocalVariables() public function givenParam_WhenClassification_FindAsAssignment() { $classifier = new LocalVariableClassifier(); - $variable = new \PHPParser_Node_Param("foo"); + $variable = new \PHPParser_Node_Param('foo'); $classifier->enterNode($variable); @@ -88,9 +88,9 @@ public function givenArrayDimFetchASsignment_WhenClassification_FindAsAssignment $assign = new \PHPParser_Node_Expr_Assign( new \PHPParser_Node_Expr_ArrayDimFetch( - new \PHPParser_Node_Expr_Variable("foo") + new \PHPParser_Node_Expr_Variable('foo') ), - new \PHPParser_Node_Expr_Variable("bar") + new \PHPParser_Node_Expr_Variable('bar') ); $classifier->enterNode($assign); diff --git a/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php b/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php index e47da60..ccab2d5 100644 --- a/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php +++ b/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php @@ -33,7 +33,7 @@ public function testRenameLocalVariable() \Phake::when($this->editor)->openBuffer(\Phake::anyParameters())->thenReturn($buffer); \Phake::when($this->codeAnalysis)->findMethodRange(\Phake::anyParameters())->thenReturn(LineRange::fromSingleLine(1)); - $patch = $this->refactoring->refactor(new File("foo.php", <<<'PHP' + $patch = $this->refactoring->refactor(new File('foo.php', <<<'PHP' setExpectedException('QafooLabs\Refactoring\Domain\Model\RefactoringException', 'Given variable "$this->foo" is required to be local to the current method.'); $this->refactoring->refactor( - new File("foo.php", ''), 6, + new File('foo.php', ''), 6, new Variable('$this->foo'), new Variable('$foo') ); @@ -64,7 +64,7 @@ public function testRenameIntoNonLocalVariable_ThrowsException() $this->setExpectedException('QafooLabs\Refactoring\Domain\Model\RefactoringException', 'Given variable "$this->foo" is required to be local to the current method.'); $this->refactoring->refactor( - new File("foo.php", ''), 6, + new File('foo.php', ''), 6, new Variable('$foo'), new Variable('$this->foo') ); diff --git a/src/test/QafooLabs/Refactoring/Application/Service/ExtractMethodTest.php b/src/test/QafooLabs/Refactoring/Application/Service/ExtractMethodTest.php index 982616a..608abea 100644 --- a/src/test/QafooLabs/Refactoring/Application/Service/ExtractMethodTest.php +++ b/src/test/QafooLabs/Refactoring/Application/Service/ExtractMethodTest.php @@ -28,7 +28,7 @@ public function setUp() */ public function testRefactorSimpleMethod() { - $patch = $this->refactoring->refactor(new File("foo.php", <<<'PHP' + $patch = $this->refactoring->refactor(new File('foo.php', <<<'PHP' applyCommand)->apply(<<<'CODE' @@ -69,7 +69,7 @@ public function testVariableUsedBeforeAndAfterExtractedSlice() { $this->markTestIncomplete('Failing over some invisible whitespace issue?'); - $patch = $this->refactoring->refactor(new File("foo.php", <<<'PHP' + $patch = $this->refactoring->refactor(new File('foo.php', <<<'PHP' applyCommand)->apply(<<<'CODE' diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/LineRangeTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/LineRangeTest.php index cb20c99..0e218b2 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/LineRangeTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/LineRangeTest.php @@ -17,7 +17,7 @@ public function testCreateFromSingleLine() public function testCreateFromString() { - $range = LineRange::fromString("1-4"); + $range = LineRange::fromString('1-4'); $this->assertEquals(1, $range->getStart()); $this->assertEquals(4, $range->getEnd()); diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/MethodSignatureTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/MethodSignatureTest.php index 76ebe36..17a9a74 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/MethodSignatureTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/MethodSignatureTest.php @@ -9,7 +9,7 @@ class MethodSignatureTest extends \PHPUnit_Framework_TestCase */ public function whenCreateMethodSignatureWithDefaults_ThenIsPrivateAndNotStatic() { - $method = new MethodSignature("foo"); + $method = new MethodSignature('foo'); $this->assertTrue($method->isPrivate()); $this->assertFalse($method->isStatic()); @@ -20,9 +20,9 @@ public function whenCreateMethodSignatureWithDefaults_ThenIsPrivateAndNotStatic( */ public function whenCreateMethodSignatureWithInvalidVisibility_ThenThrowException() { - $this->setExpectedException("InvalidArgumentException"); + $this->setExpectedException('InvalidArgumentException'); - $method = new MethodSignature("foo", MethodSignature::IS_PRIVATE | MethodSignature::IS_PUBLIC); + $method = new MethodSignature('foo', MethodSignature::IS_PRIVATE | MethodSignature::IS_PUBLIC); } /** @@ -30,7 +30,7 @@ public function whenCreateMethodSignatureWithInvalidVisibility_ThenThrowExceptio */ public function whenCreateMethodSignatureWithStaticOnly_ThenAssumePrivateVisibility() { - $method = new MethodSignature("foo", MethodSignature::IS_STATIC); + $method = new MethodSignature('foo', MethodSignature::IS_STATIC); $this->assertTrue($method->isPrivate()); $this->assertTrue($method->isStatic()); diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php index 84af2f0..8be40dd 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php @@ -17,14 +17,14 @@ class PhpNameTest extends \PHPUnit_Framework_TestCase { public function testIsAffectedByChangesToItself() { - $name = new PhpName("Foo\Bar\Baz", "Baz"); + $name = new PhpName("Foo\Bar\Baz", 'Baz'); $this->assertTrue($name->isAffectedByChangesTo($name)); } public function testIsNotAffectedByChangesToNonRelativePart() { - $name = new PhpName("Foo\Bar\Baz", "Baz"); + $name = new PhpName("Foo\Bar\Baz", 'Baz'); $changing = new PhpName("Foo\Bar", "Foo\Bar"); $this->assertFalse($name->isAffectedByChangesTo($changing)); @@ -53,7 +53,7 @@ public function testRelativeChanges() public function testRegression() { $name = new PhpName("Bar\Bar", "Bar\Bar"); - $changing = new PhpName("Bar", "Bar"); + $changing = new PhpName('Bar', 'Bar'); $this->assertTrue($name->isAffectedByChangesTo($changing)); } @@ -61,8 +61,8 @@ public function testRegression() public function testRegression2() { $name = new PhpName("Foo\\Foo", "Foo\\Foo"); - $from = new PhpName("Foo\\Foo", "Foo"); - $to = new PhpName("Foo\\Bar", "Bar"); + $from = new PhpName("Foo\\Foo", 'Foo'); + $to = new PhpName("Foo\\Bar", 'Bar'); $changed = $name->change($from, $to); @@ -97,14 +97,14 @@ public function testRegression4() $from = new PhpName('Foo\\Foo', 'Foo'); $to = new PhpName('Foo\\Bar', 'Bar'); - $this->assertFalse($name->isAffectedByChangesTo($from), "Namespace should not be affected by changes to Class in namespace."); + $this->assertFalse($name->isAffectedByChangesTo($from), 'Namespace should not be affected by changes to Class in namespace.'); } public function testRegression5() { $from = new PhpName("Qafoo\ChangeTrack\ChangeFeed", "Qafoo\ChangeTrack\ChangeFeed"); $to = new PhpName("Qafoo\ChangeTrack\Analyzer\ChangeFeed", "Qafoo\ChangeTrack\Analyzer\ChangeFeed"); - $name = new PhpName("Qafoo\ChangeTrack\ChangeFeed", "ChangeFeed"); + $name = new PhpName("Qafoo\ChangeTrack\ChangeFeed", 'ChangeFeed'); $changed = $name->change($from, $to); @@ -211,7 +211,7 @@ public static function provideIsFullyQualified() public function testGetShortNameReturnsLastPartForFQCN() { $name = new PhpName('Foo\\Bar', "Foo\\Bar", null, null); - $short = new PhpName("Foo", "Foo", null, null); + $short = new PhpName('Foo', 'Foo', null, null); $this->assertEquals('Bar', $name->shortName()); $this->assertEquals('Foo', $short->shortName()); diff --git a/src/test/QafooLabs/Refactoring/Utils/CallbackFilterIteratorTest.php b/src/test/QafooLabs/Refactoring/Utils/CallbackFilterIteratorTest.php index 901fa76..46eeb21 100644 --- a/src/test/QafooLabs/Refactoring/Utils/CallbackFilterIteratorTest.php +++ b/src/test/QafooLabs/Refactoring/Utils/CallbackFilterIteratorTest.php @@ -20,7 +20,7 @@ class CallbackFilterIteratorTest extends \PHPUnit_Framework_TestCase public function testFilterEmptyElements() { $values = new CallbackFilterIterator( - new ArrayIterator(array(1, null, false, "", 2)), + new ArrayIterator(array(1, null, false, '', 2)), function ($value) { return !empty($value); } From d318e46af20201bb3813362e66a72de29317c08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:17:31 +0200 Subject: [PATCH 09/29] Remove useless semicolons --- .../Adapters/Symfony/Commands/ExtractMethodCommand.php | 1 - .../Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php | 1 - .../Adapters/Symfony/Commands/RenameLocalVariableCommand.php | 1 - 3 files changed, 3 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php index 93db01b..ae25e0b 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php @@ -67,7 +67,6 @@ function and generates the argument list and return statement accordingly. Will extract lines 10-16 from file.php into a new method called newMethodName. HELP ); - ; } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php index d21ca51..b38964c 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php @@ -67,7 +67,6 @@ protected function configure() Will optimize the use statements in file.php. HELP ); - ; } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php index f69d1f6..c908e52 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php @@ -59,7 +59,6 @@ protected function configure() HELP ); - ; } protected function execute(InputInterface $input, OutputInterface $output) From 1a1f91ee872ef4897889bbc6e331f5de0dffb65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:18:35 +0200 Subject: [PATCH 10/29] Use short syntax for bits operation --- src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php b/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php index 7f76eef..c449620 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php @@ -43,7 +43,7 @@ private function change($flags) $allowedVisibilities = array(self::IS_PRIVATE, self::IS_PROTECTED, self::IS_PUBLIC); if (($flags & $visibility) === 0) { - $flags = $flags | self::IS_PRIVATE; + $flags |= self::IS_PRIVATE; } if ( ! in_array(($flags & $visibility), $allowedVisibilities)) { From ceee74aff1c0f190bdc5d6c3d980f479a9b9d8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:19:20 +0200 Subject: [PATCH 11/29] Use assertCount in tests when possible --- src/test/QafooLabs/Collections/SetTest.php | 6 +++--- .../Domain/Model/PhpNames/NoImportedUsagesFilterTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/QafooLabs/Collections/SetTest.php b/src/test/QafooLabs/Collections/SetTest.php index 2b2a215..f9adf95 100644 --- a/src/test/QafooLabs/Collections/SetTest.php +++ b/src/test/QafooLabs/Collections/SetTest.php @@ -15,7 +15,7 @@ public function whenAddingItemMultipleTimes_ThenOnlyAddItOnce() $set->add($item); $set->add($item); - $this->assertEquals(1, count($set)); + $this->assertCount(1, $set); } /** @@ -31,7 +31,7 @@ public function whenAddingMultipleItems_ThenCountThemUniquely() $set->add($item1); $set->add($item2); - $this->assertEquals(2, count($set)); + $this->assertCount(2, $set); } /** @@ -48,7 +48,7 @@ public function whenAddingHashableObjectMultipleTimes_ThenOnlyAddItOnce() $set->add($item2); $set->add($item2); - $this->assertEquals(2, count($set)); + $this->assertCount(2, $set); } /** diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNames/NoImportedUsagesFilterTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNames/NoImportedUsagesFilterTest.php index 2abe2af..f0a9fc7 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNames/NoImportedUsagesFilterTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNames/NoImportedUsagesFilterTest.php @@ -21,6 +21,6 @@ public function it_filters_imported_php_name_usages() new PhpNameOccurance(new PhpName('Foo\Bar', 'Bar', PhpName::TYPE_USAGE), $file, 12), )); - $this->assertEquals(1, count($names)); + $this->assertCount(1, $names); } } From d89aef888105c919a8e81e12dc5ee2db9b295c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:38:33 +0200 Subject: [PATCH 12/29] Update tests --- .../Visitor/LocalVariableClassifier.php | 2 +- .../LineRangeStatementCollectorTest.php | 16 +++++----- .../Visitor/LocalVariableClassifierTest.php | 31 ++++++++++--------- .../Application/RenameLocalVariableTest.php | 6 +--- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php index 7e4ec88..e75ea2a 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php @@ -58,7 +58,7 @@ private function enterAssignment(Node\Expr\Assign $node) if ($node->var instanceof Node\Expr\Variable) { $this->assignments[$node->var->name][] = $node->getLine(); $this->seenAssignmentVariables->attach($node->var); - } else if ($node instanceof Node\Expr\ArrayDimFetch) { + } else if ($node->var instanceof Node\Expr\ArrayDimFetch) { // $foo[] = "baz" is both a read and a write access to $foo $this->localVariables[$node->var->var->name][] = $node->getLine(); $this->assignments[$node->var->var->name][] = $node->getLine(); diff --git a/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollectorTest.php b/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollectorTest.php index f0a4fd6..11cb4ae 100644 --- a/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollectorTest.php +++ b/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LineRangeStatementCollectorTest.php @@ -2,12 +2,10 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser\Visitor; -use PHPParser_Parser; -use PHPParser_Lexer; -use PHPParser_NodeTraverser; +use PhpParser\NodeTraverser; +use PhpParser\ParserFactory; use QafooLabs\Refactoring\Domain\Model\LineRange; -use QafooLabs\Refactoring\Adapters\PHPParser\Visitor\NodeConnector; class LineRangeStatementCollectorTest extends \PHPUnit_Framework_TestCase { @@ -25,14 +23,14 @@ public function givenNestedStatements_WhenCollecting_ThenOnlyCollectTopLevel() $collectedStatements = $collector->getStatements(); $this->assertCount(1, $collectedStatements); - $this->assertInstanceOf('PHPParser_Node_Expr_MethodCall', $collectedStatements[0]); + $this->assertInstanceOf('PHPParser\Node\Expr\MethodCall', $collectedStatements[0]); } private function traverse($stmts, $visitor) { $this->connect($stmts); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor(new NodeConnector); $traverser->addVisitor($visitor); $traverser->traverse($stmts); @@ -42,7 +40,7 @@ private function traverse($stmts, $visitor) private function connect($stmts) { - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor(new NodeConnector); return $traverser->traverse($stmts); } @@ -58,7 +56,9 @@ private function statements($code) $code = "create(ParserFactory::PREFER_PHP7); + return $parser->parse($code); } diff --git a/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifierTest.php b/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifierTest.php index 2cb9391..8abeb30 100644 --- a/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifierTest.php +++ b/src/test/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifierTest.php @@ -2,6 +2,9 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser\Visitor; +use PhpParser\Node\Expr; +use PhpParser\NodeTraverser; + class LocalVariableClassifierTest extends \PHPUnit_Framework_TestCase { /** @@ -10,7 +13,7 @@ class LocalVariableClassifierTest extends \PHPUnit_Framework_TestCase public function givenVariable_WhenClassification_ThenLocalVariableFound() { $classifier = new LocalVariableClassifier(); - $variable = new \PHPParser_Node_Expr_Variable('foo'); + $variable = new Expr\Variable('foo'); $classifier->enterNode($variable); @@ -23,9 +26,9 @@ public function givenVariable_WhenClassification_ThenLocalVariableFound() public function givenAssignment_WhenClassification_ThenAssignmentFound() { $classifier = new LocalVariableClassifier(); - $assign = new \PHPParser_Node_Expr_Assign( - new \PHPParser_Node_Expr_Variable('foo'), - new \PHPParser_Node_Expr_Variable('bar') + $assign = new Expr\Assign( + new Expr\Variable('foo'), + new Expr\Variable('bar') ); $classifier->enterNode($assign); @@ -39,12 +42,12 @@ public function givenAssignment_WhenClassification_ThenAssignmentFound() public function givenAssignmentAndReadOfSameVariable_WhenClassification_ThenFindBoth() { $classifier = new LocalVariableClassifier(); - $assign = new \PHPParser_Node_Expr_Assign( - new \PHPParser_Node_Expr_Variable('foo'), - new \PHPParser_Node_Expr_Variable('foo') + $assign = new Expr\Assign( + new Expr\Variable('foo'), + new Expr\Variable('foo') ); - $traverser = new \PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor($classifier); $traverser->traverse(array($assign)); @@ -58,7 +61,7 @@ public function givenAssignmentAndReadOfSameVariable_WhenClassification_ThenFind public function givenThisVariable_WhenClassification_ThenNoLocalVariables() { $classifier = new LocalVariableClassifier(); - $variable = new \PHPParser_Node_Expr_Variable('this'); + $variable = new Expr\Variable('this'); $classifier->enterNode($variable); @@ -71,7 +74,7 @@ public function givenThisVariable_WhenClassification_ThenNoLocalVariables() public function givenParam_WhenClassification_FindAsAssignment() { $classifier = new LocalVariableClassifier(); - $variable = new \PHPParser_Node_Param('foo'); + $variable = new \PhpParser\Node\Param('foo'); $classifier->enterNode($variable); @@ -86,11 +89,11 @@ public function givenArrayDimFetchASsignment_WhenClassification_FindAsAssignment { $classifier = new LocalVariableClassifier(); - $assign = new \PHPParser_Node_Expr_Assign( - new \PHPParser_Node_Expr_ArrayDimFetch( - new \PHPParser_Node_Expr_Variable('foo') + $assign = new Expr\Assign( + new Expr\ArrayDimFetch( + new Expr\Variable('foo') ), - new \PHPParser_Node_Expr_Variable('bar') + new Expr\Variable('bar') ); $classifier->enterNode($assign); diff --git a/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php b/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php index ccab2d5..f1aa6bf 100644 --- a/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php +++ b/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php @@ -7,10 +7,6 @@ use QafooLabs\Refactoring\Domain\Model\Variable; use QafooLabs\Refactoring\Domain\Model\DefinedVariables; -use QafooLabs\Refactoring\Adapters\PHPParser\ParserVariableScanner; -use QafooLabs\Refactoring\Adapters\TokenReflection\StaticCodeAnalysis; -use QafooLabs\Refactoring\Adapters\Patches\PatchEditor; - class RenameLocalVariableTest extends \PHPUnit_Framework_TestCase { public function setUp() @@ -20,7 +16,7 @@ public function setUp() $this->editor = \Phake::mock('QafooLabs\Refactoring\Domain\Services\Editor'); $this->refactoring = new RenameLocalVariable($this->scanner, $this->codeAnalysis, $this->editor); - \Phake::when($this->codeAnalysis)->isInsideMethod(\Phake::anyParameters())->thenReturn(true); + \Phake::when($this->codeAnalysis)->isLocalScope(\Phake::anyParameters())->thenReturn(true); } public function testRenameLocalVariable() From 33d81cf2ab5d75d13a82a80c337d340cee8bb372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:40:02 +0200 Subject: [PATCH 13/29] Remove unused variables --- src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php | 1 - .../Refactoring/Application/RenameLocalVariableTest.php | 2 +- .../Refactoring/Application/Service/ExtractMethodTest.php | 4 ++-- .../Refactoring/Domain/Model/MethodSignatureTest.php | 2 +- src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php b/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php index f9c2854..1aab86d 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php @@ -87,7 +87,6 @@ private function overlaps(PhpName $other) private function shareNamespace(PhpName $other) { - $otherName = array(); $otherParts = $this->stringToParts($other->fullyQualifiedName); return strpos($this->fullyQualifiedName, $otherParts[0]) !== false; diff --git a/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php b/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php index f1aa6bf..2406754 100644 --- a/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php +++ b/src/test/QafooLabs/Refactoring/Application/RenameLocalVariableTest.php @@ -29,7 +29,7 @@ public function testRenameLocalVariable() \Phake::when($this->editor)->openBuffer(\Phake::anyParameters())->thenReturn($buffer); \Phake::when($this->codeAnalysis)->findMethodRange(\Phake::anyParameters())->thenReturn(LineRange::fromSingleLine(1)); - $patch = $this->refactoring->refactor(new File('foo.php', <<<'PHP' + $this->refactoring->refactor(new File('foo.php', <<<'PHP' refactoring->refactor(new File('foo.php', <<<'PHP' + $this->refactoring->refactor(new File('foo.php', <<<'PHP' markTestIncomplete('Failing over some invisible whitespace issue?'); - $patch = $this->refactoring->refactor(new File('foo.php', <<<'PHP' + $this->refactoring->refactor(new File('foo.php', <<<'PHP' setExpectedException('InvalidArgumentException'); - $method = new MethodSignature('foo', MethodSignature::IS_PRIVATE | MethodSignature::IS_PUBLIC); + new MethodSignature('foo', MethodSignature::IS_PRIVATE | MethodSignature::IS_PUBLIC); } /** diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php index 8be40dd..3b849c8 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/PhpNameTest.php @@ -95,7 +95,6 @@ public function testRegression4() { $name = new PhpName('Foo', 'Foo'); $from = new PhpName('Foo\\Foo', 'Foo'); - $to = new PhpName('Foo\\Bar', 'Bar'); $this->assertFalse($name->isAffectedByChangesTo($from), 'Namespace should not be affected by changes to Class in namespace.'); } From 8d94437bf57d68427034798a506efc5d93741d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:42:41 +0200 Subject: [PATCH 14/29] Remove unused imports --- .../Refactoring/Adapters/PatchBuilder/PatchBuffer.php | 2 +- .../Refactoring/Adapters/PatchBuilder/PatchEditor.php | 2 +- .../Commands/ConvertLocalToInstanceVariableCommand.php | 2 +- .../Adapters/Symfony/Commands/ExtractMethodCommand.php | 2 +- .../Adapters/Symfony/Commands/FixClassNamesCommand.php | 2 +- .../Adapters/Symfony/Commands/OptimizeUseCommand.php | 6 +++--- .../Symfony/Commands/RenameLocalVariableCommand.php | 2 +- .../Application/ConvertLocalToInstanceVariable.php | 8 -------- .../QafooLabs/Refactoring/Application/ExtractMethod.php | 6 ++---- .../QafooLabs/Refactoring/Application/FixClassNames.php | 2 +- .../QafooLabs/Refactoring/Application/OptimizeUse.php | 2 +- .../Refactoring/Application/RenameLocalVariable.php | 7 ++----- .../Refactoring/Domain/Model/EditingAction/AddMethod.php | 2 +- .../Domain/Model/EditingAction/AddMethodTest.php | 2 +- 14 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuffer.php b/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuffer.php index 447d729..9decf2c 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuffer.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuffer.php @@ -15,7 +15,7 @@ use QafooLabs\Refactoring\Domain\Model\EditorBuffer; use QafooLabs\Refactoring\Domain\Model\LineRange; -use QafooLabs\Refactoring\Adapters\PatchBuilder\PatchBuilder; + class PatchBuffer implements EditorBuffer { diff --git a/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php b/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php index 3189679..52717d9 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php @@ -16,7 +16,7 @@ use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Services\Editor; -use QafooLabs\Refactoring\Adapters\PatchBuilder\PatchBuilder; + /** * Editor creates patches for all changes. diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ConvertLocalToInstanceVariableCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ConvertLocalToInstanceVariableCommand.php index 2f070b7..65f736c 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ConvertLocalToInstanceVariableCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ConvertLocalToInstanceVariableCommand.php @@ -14,7 +14,7 @@ namespace QafooLabs\Refactoring\Adapters\Symfony\Commands; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php index ae25e0b..0638015 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/ExtractMethodCommand.php @@ -14,7 +14,7 @@ namespace QafooLabs\Refactoring\Adapters\Symfony\Commands; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/FixClassNamesCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/FixClassNamesCommand.php index d5786a2..9c23606 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/FixClassNamesCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/FixClassNamesCommand.php @@ -14,7 +14,7 @@ namespace QafooLabs\Refactoring\Adapters\Symfony\Commands; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php index b38964c..e989f3c 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/OptimizeUseCommand.php @@ -14,19 +14,19 @@ namespace QafooLabs\Refactoring\Adapters\Symfony\Commands; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; use QafooLabs\Refactoring\Application\OptimizeUse; -use QafooLabs\Refactoring\Adapters\PHPParser\ParserVariableScanner; + use QafooLabs\Refactoring\Adapters\PHPParser\ParserPhpNameScanner; use QafooLabs\Refactoring\Adapters\TokenReflection\StaticCodeAnalysis; use QafooLabs\Refactoring\Adapters\PatchBuilder\PatchEditor; use QafooLabs\Refactoring\Adapters\Symfony\OutputPatchCommand; -use QafooLabs\Refactoring\Domain\Model\LineRange; + use QafooLabs\Refactoring\Domain\Model\File; /** diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php index c908e52..dd44929 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenameLocalVariableCommand.php @@ -15,7 +15,7 @@ namespace QafooLabs\Refactoring\Adapters\Symfony\Commands; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; diff --git a/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php b/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php index 5c7e925..9227b46 100644 --- a/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php +++ b/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php @@ -3,16 +3,8 @@ namespace QafooLabs\Refactoring\Application; use QafooLabs\Refactoring\Domain\Model\File; -use QafooLabs\Refactoring\Domain\Model\DefinedVariables; -use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\Variable; - use QafooLabs\Refactoring\Domain\Model\RefactoringException; -use QafooLabs\Refactoring\Domain\Model\EditingSession; - -use QafooLabs\Refactoring\Domain\Services\VariableScanner; -use QafooLabs\Refactoring\Domain\Services\CodeAnalysis; -use QafooLabs\Refactoring\Domain\Services\Editor; use QafooLabs\Refactoring\Domain\Model\EditingAction\AddProperty; use QafooLabs\Refactoring\Domain\Model\EditingAction\LocalVariableToInstance; diff --git a/src/main/QafooLabs/Refactoring/Application/ExtractMethod.php b/src/main/QafooLabs/Refactoring/Application/ExtractMethod.php index 121138b..09d515d 100644 --- a/src/main/QafooLabs/Refactoring/Application/ExtractMethod.php +++ b/src/main/QafooLabs/Refactoring/Application/ExtractMethod.php @@ -5,12 +5,10 @@ use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Model\MethodSignature; -use QafooLabs\Refactoring\Domain\Model\EditingSession; + use QafooLabs\Refactoring\Domain\Model\RefactoringException; -use QafooLabs\Refactoring\Domain\Services\VariableScanner; -use QafooLabs\Refactoring\Domain\Services\CodeAnalysis; -use QafooLabs\Refactoring\Domain\Services\Editor; + use QafooLabs\Refactoring\Domain\Model\LineCollection; use QafooLabs\Refactoring\Domain\Model\EditingAction\AddMethod; use QafooLabs\Refactoring\Domain\Model\EditingAction\ReplaceWithMethodCall; diff --git a/src/main/QafooLabs/Refactoring/Application/FixClassNames.php b/src/main/QafooLabs/Refactoring/Application/FixClassNames.php index b2b092c..0b10aa3 100644 --- a/src/main/QafooLabs/Refactoring/Application/FixClassNames.php +++ b/src/main/QafooLabs/Refactoring/Application/FixClassNames.php @@ -15,7 +15,7 @@ use QafooLabs\Collections\Set; use QafooLabs\Refactoring\Domain\Model\Directory; -use QafooLabs\Refactoring\Domain\Model\File; + use QafooLabs\Refactoring\Domain\Model\PhpName; use QafooLabs\Refactoring\Domain\Model\PhpNameChange; use QafooLabs\Refactoring\Domain\Model\PhpNames\NoImportedUsagesFilter; diff --git a/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php b/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php index ce9d8de..fe29623 100644 --- a/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php +++ b/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php @@ -13,7 +13,7 @@ namespace QafooLabs\Refactoring\Application; -use QafooLabs\Refactoring\Domain\Model\Directory; + use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Model\PhpClassName; use QafooLabs\Refactoring\Domain\Model\PhpName; diff --git a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php index a8dbb90..c2b8a51 100644 --- a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php +++ b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php @@ -4,14 +4,11 @@ use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Model\Variable; -use QafooLabs\Refactoring\Domain\Model\DefinedVariables; + use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\RefactoringException; -use QafooLabs\Refactoring\Domain\Model\EditingSession; -use QafooLabs\Refactoring\Domain\Services\VariableScanner; -use QafooLabs\Refactoring\Domain\Services\CodeAnalysis; -use QafooLabs\Refactoring\Domain\Services\Editor; + use QafooLabs\Refactoring\Domain\Model\EditingAction\RenameVariable; /** diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethod.php b/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethod.php index e1f9631..31b6b02 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethod.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethod.php @@ -6,7 +6,7 @@ use QafooLabs\Refactoring\Domain\Model\EditorBuffer; use QafooLabs\Refactoring\Domain\Model\IndentationDetector; use QafooLabs\Refactoring\Domain\Model\IndentingLineCollection; -use QafooLabs\Refactoring\Domain\Model\Line; + use QafooLabs\Refactoring\Domain\Model\LineCollection; use QafooLabs\Refactoring\Domain\Model\MethodSignature; use QafooLabs\Refactoring\Utils\ToStringIterator; diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php index 06cdca2..5152d89 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php @@ -3,7 +3,7 @@ namespace QafooLabs\Refactoring\Domain\Model\EditingAction; use QafooLabs\Refactoring\Domain\Model\MethodSignature; -use QafooLabs\Refactoring\Domain\Model\Line; + use QafooLabs\Refactoring\Domain\Model\LineCollection; class AddMethodTest extends \PHPUnit_Framework_TestCase From 522a9537a59333ec43df97e42164acf959923642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:43:01 +0200 Subject: [PATCH 15/29] Remove unused attribute --- .../Refactoring/Domain/Model/EditingAction/AddMethodTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php index 5152d89..a1a4904 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php @@ -8,8 +8,6 @@ class AddMethodTest extends \PHPUnit_Framework_TestCase { - private $action; - private $buffer; protected function setUp() From c41c0b116fe3d12d97e523ac7c5fa2e2c0316c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:44:20 +0200 Subject: [PATCH 16/29] Fix undeclared variable usage --- .../Refactoring/Application/ConvertLocalToInstanceVariable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php b/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php index 9227b46..5eac854 100644 --- a/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php +++ b/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php @@ -3,6 +3,7 @@ namespace QafooLabs\Refactoring\Application; use QafooLabs\Refactoring\Domain\Model\File; +use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\Variable; use QafooLabs\Refactoring\Domain\Model\RefactoringException; use QafooLabs\Refactoring\Domain\Model\EditingAction\AddProperty; @@ -46,7 +47,7 @@ private function convertVariablesToInstanceVariables() $definedVariables = $this->getDefinedVariables(); if ( ! $definedVariables->contains($this->convertVariable)) { - throw RefactoringException::variableNotInRange($this->convertVariable, $selectedMethodLineRange); + throw RefactoringException::variableNotInRange($this->convertVariable, LineRange::fromSingleLine($this->line)); } $this->session->addEdit(new LocalVariableToInstance($definedVariables, $this->convertVariable)); From 67cab17fc8cade30b296f267e10bc1449ac9dcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:47:58 +0200 Subject: [PATCH 17/29] Update travis-ci config --- .travis.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 003337d..11adc79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php -before_script: - - composer self-update - - composer install --dev --prefer-dist -script: php vendor/bin/phpunit; php vendor/bin/behat --format progress + +sudo: false + php: - 5.4 - 5.5 @@ -14,3 +13,14 @@ matrix: allow_failures: - php: hhvm - php: 7 + +before_install: + - phpenv config-rm xdebug.ini || true + - composer self-update + +install: + - composer install --optimize-autoloader --no-interaction --ignore-platform-reqs + +script: + - php vendor/bin/phpunit + - php vendor/bin/behat --format progress From 7e070667ee5e702aff39d912f655b6fd4ae70d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:49:40 +0200 Subject: [PATCH 18/29] PHP 7.0 should not be allowed to fail --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 11adc79..661da0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ matrix: fast_finish: true allow_failures: - php: hhvm - - php: 7 before_install: - phpenv config-rm xdebug.ini || true From eca98ae66cbf1a29bc0f0e7fbe2640dc9035d661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:50:29 +0200 Subject: [PATCH 19/29] Also test against HHVM --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 661da0f..cfb7486 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 5.5 - 5.6 - 7.0 + - hhvm matrix: fast_finish: true From 56963322a9d4ec81912577fd86f1c6dbfc8b13d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 14 May 2016 23:52:30 +0200 Subject: [PATCH 20/29] Disallow failures for HHVM --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cfb7486..f777d98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,6 @@ php: matrix: fast_finish: true - allow_failures: - - php: hhvm before_install: - phpenv config-rm xdebug.ini || true From acc316f68405f287f31e6a735d870e946ee4b811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 15 May 2016 17:03:20 +0200 Subject: [PATCH 21/29] Add rename property command --- .../PHPParser/ParserVariableScanner.php | 42 +++++++++- .../PHPParser/Visitor/PropertiesCollector.php | 57 ++++++++++++++ .../Adapters/Symfony/CliApplication.php | 1 + .../Commands/RenamePropertyCommand.php | 77 +++++++++++++++++++ .../TokenReflection/StaticCodeAnalysis.php | 47 +++++++++++ .../Application/RenameProperty.php | 54 +++++++++++++ .../Application/SingleFileRefactoring.php | 16 ++++ .../Domain/Model/DefinedProperties.php | 72 +++++++++++++++++ .../Model/EditingAction/RenameProperty.php | 69 +++++++++++++++++ .../Domain/Model/RefactoringException.php | 15 ++++ .../Domain/Services/CodeAnalysis.php | 26 +++++++ .../Domain/Services/VariableScanner.php | 8 ++ 12 files changed, 481 insertions(+), 3 deletions(-) create mode 100644 src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PropertiesCollector.php create mode 100644 src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenamePropertyCommand.php create mode 100644 src/main/QafooLabs/Refactoring/Application/RenameProperty.php create mode 100644 src/main/QafooLabs/Refactoring/Domain/Model/DefinedProperties.php create mode 100644 src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/RenameProperty.php diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php index e8adfea..cdbd17b 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php @@ -16,6 +16,8 @@ use PhpParser\NodeTraverser; use PhpParser\ParserFactory; +use QafooLabs\Refactoring\Adapters\PHPParser\Visitor\PropertiesCollector; +use QafooLabs\Refactoring\Domain\Model\DefinedProperties; use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Model\DefinedVariables; @@ -29,9 +31,7 @@ class ParserVariableScanner implements VariableScanner { public function scanForVariables(File $file, LineRange $range) { - $parserFactory = new ParserFactory(); - $parser = $parserFactory->create(ParserFactory::PREFER_PHP7); - $stmts = $parser->parse($file->getCode()); + $stmts = $this->parse($file); $collector = new LineRangeStatementCollector($range); @@ -57,4 +57,40 @@ public function scanForVariables(File $file, LineRange $range) return new DefinedVariables($localVariables, $assignments); } + + public function scanForProperties(File $file, LineRange $range) + { + $stmts = $this->parse($file); + + $collector = new LineRangeStatementCollector($range); + + $traverser = new NodeTraverser(); + $traverser->addVisitor($collector); + + $traverser->traverse($stmts); + + $selectedStatements = $collector->getStatements(); + + if ( ! $selectedStatements) { + throw new \RuntimeException('No statements found in line range.'); + } + + $propertiesCollector = new PropertiesCollector(); + $traverser = new NodeTraverser(); + $traverser->addVisitor($propertiesCollector); + $traverser->traverse($selectedStatements); + + $definitions = $propertiesCollector->getDeclarations(); + $usages = $propertiesCollector->getUsages(); + + return new DefinedProperties($definitions, $usages); + } + + private function parse(File $file) + { + $parserFactory = new ParserFactory(); + $parser = $parserFactory->create(ParserFactory::PREFER_PHP7); + + return $parser->parse($file->getCode()); + } } diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PropertiesCollector.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PropertiesCollector.php new file mode 100644 index 0000000..6ec4321 --- /dev/null +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/PropertiesCollector.php @@ -0,0 +1,57 @@ +seenPropertyUsages = new SplObjectStorage(); + } + + public function enterNode(Node $node) + { + if ($node instanceof Node\Stmt\Property) { + $this->declarations[$node->props[0]->name] = $node->getLine(); + } + + if ($node instanceof Node\Expr\PropertyFetch && !$this->seenPropertyUsages->contains($node)) { + $this->usages[$node->name][] = $node->getLine(); + $this->seenPropertyUsages->attach($node); + } + } + + public function getDeclarations() + { + return $this->declarations; + } + + public function getUsages() + { + return $this->usages; + } +} diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/CliApplication.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/CliApplication.php index 99bdcc6..913d50c 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/Symfony/CliApplication.php +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/CliApplication.php @@ -40,6 +40,7 @@ protected function getDefaultCommands() $commands = parent::getDefaultCommands(); $commands[] = new Commands\ExtractMethodCommand(); $commands[] = new Commands\RenameLocalVariableCommand(); + $commands[] = new Commands\RenamePropertyCommand(); $commands[] = new Commands\ConvertLocalToInstanceVariableCommand(); $commands[] = new Commands\FixClassNamesCommand(); $commands[] = new Commands\OptimizeUseCommand(); diff --git a/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenamePropertyCommand.php b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenamePropertyCommand.php new file mode 100644 index 0000000..dc11f65 --- /dev/null +++ b/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/RenamePropertyCommand.php @@ -0,0 +1,77 @@ +setName('rename-property') + ->setDescription('Rename a class property.') + ->addArgument('file', InputArgument::REQUIRED, 'File that contains the class') + ->addArgument('line', InputArgument::REQUIRED, 'Line where the property is defined or used.') + ->addArgument('name', InputArgument::REQUIRED, 'Current name of the property without the "$this->"') + ->addArgument('new-name', InputArgument::REQUIRED, 'New name of the property') + ->setHelp(<<Operations: + +1. Renames a property by giving it a new name inside the class. + +Pre-Conditions: + +1. Check that new property name does not exist (NOT YET CHECKED). + +Usage: + + php refactor.phar rename-property file.php 17 hello newHello + +Renames \$hello in line 17 of file.php into \$newHello. + +HELP + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $file = Model\File::createFromPath($input->getArgument('file'), getcwd()); + $line = (int)$input->getArgument('line'); + $name = new Model\Variable($input->getArgument('name')); + $newName = new Model\Variable($input->getArgument('new-name')); + + $scanner = new ParserVariableScanner(); + $codeAnalysis = new StaticCodeAnalysis(); + $editor = new PatchEditor(new OutputPatchCommand($output)); + + $renameLocalVariable = new RenameProperty($scanner, $codeAnalysis, $editor); + $renameLocalVariable->refactor($file, $line, $name, $newName); + } +} diff --git a/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php b/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php index d73294d..539e1b9 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php +++ b/src/main/QafooLabs/Refactoring/Adapters/TokenReflection/StaticCodeAnalysis.php @@ -33,6 +33,28 @@ public function __construct() // caching in memory gives us error for now :( } + public function getClassStartLine(File $file, LineRange $range) + { + $class = $this->findMatchingClass($file, $range); + + if ($class === null) { + throw new \InvalidArgumentException('Could not find class start line.'); + } + + return $class->getStartLine(); + } + + public function getClassEndLine(File $file, LineRange $range) + { + $class = $this->findMatchingClass($file, $range); + + if ($class === null) { + throw new \InvalidArgumentException('Could not find class end line.'); + } + + return $class->getEndLine(); + } + public function isMethodStatic(File $file, LineRange $range) { $method = $this->findMatchingMethod($file, $range); @@ -123,6 +145,11 @@ public function isLocalScope(File $file, LineRange $range) return $this->isInsideMethod($file, $range) || $this->isInsideFunction($file, $range); } + public function isClassScope(File $file, LineRange $range) + { + return $this->findMatchingClass($file, $range) !== null; + } + /** * @param File $file * @return PhpClass[] @@ -148,6 +175,26 @@ public function findClasses(File $file) return $classes; } + private function findMatchingClass(File $file, LineRange $range) + { + $foundClass = null; + + $this->broker = new Broker(new Memory); + $file = $this->broker->processString($file->getCode(), $file->getRelativePath(), true); + $lastLine = $range->getEnd(); + + foreach ($file->getNamespaces() as $namespace) { + foreach ($namespace->getClasses() as $class) { + if ($class->getStartLine() <= $lastLine && $lastLine <= $class->getEndLine()) { + $foundClass = $class; + break; + } + } + } + + return $foundClass; + } + private function findMatchingMethod(File $file, LineRange $range) { $foundMethod = null; diff --git a/src/main/QafooLabs/Refactoring/Application/RenameProperty.php b/src/main/QafooLabs/Refactoring/Application/RenameProperty.php new file mode 100644 index 0000000..b9afc8a --- /dev/null +++ b/src/main/QafooLabs/Refactoring/Application/RenameProperty.php @@ -0,0 +1,54 @@ +file = $file; + $this->line = $line; + $this->newName = $newName; + $this->oldName = $oldName; + + $this->assertIsClassScope(); + + $this->startEditingSession(); + $this->renameProperty(); + $this->completeEditingSession(); + } + + private function renameProperty() + { + $definedProperties = $this->getDefinedProperties(); + + if ( ! $definedProperties->contains($this->oldName)) { + throw RefactoringException::propertyNotInRange($this->oldName, LineRange::fromSingleLine($this->line)); + } + + $this->session->addEdit(new EditingAction\RenameProperty($definedProperties, $this->oldName, $this->newName)); + } +} diff --git a/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php b/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php index 01af684..c476eed 100644 --- a/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php +++ b/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php @@ -66,6 +66,13 @@ protected function assertIsLocalScope() } } + protected function assertIsClassScope() + { + if ( ! $this->codeAnalysis->isClassScope($this->file, LineRange::fromSingleLine($this->line)) ) { + throw RefactoringException::rangeIsNotClassScope(LineRange::fromSingleLine($this->line)); + } + } + protected function startEditingSession() { $buffer = $this->editor->openBuffer($this->file); @@ -94,4 +101,13 @@ protected function getDefinedVariables() return $definedVariables; } + + protected function getDefinedProperties() + { + $selectedClassLineRange = $this->codeAnalysis->findClassRange($this->file, LineRange::fromSingleLine($this->line)); + + return $this->variableScanner->scanForProperties( + $this->file, $selectedClassLineRange + ); + } } diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/DefinedProperties.php b/src/main/QafooLabs/Refactoring/Domain/Model/DefinedProperties.php new file mode 100644 index 0000000..76ac726 --- /dev/null +++ b/src/main/QafooLabs/Refactoring/Domain/Model/DefinedProperties.php @@ -0,0 +1,72 @@ +declarations = $declarations; + $this->usages = $usages; + } + + public function declaration($property) + { + if (!isset($this->declarations[$property])) { + return 0; + } + + return $this->declarations[$property]; + } + + public function usages($property) + { + if (!isset($this->usages[$property])) { + return array(); + } + + return array_unique($this->usages[$property]); + } + + /** + * Does list contain the given variable? + * + * @return bool + */ + public function contains(Variable $variable) + { + return ( + isset($this->declarations[$variable->getName()]) || + isset($this->usages[$variable->getName()]) + ); + } +} diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/RenameProperty.php b/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/RenameProperty.php new file mode 100644 index 0000000..8f5c4c1 --- /dev/null +++ b/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/RenameProperty.php @@ -0,0 +1,69 @@ +definedProperties = $definedProperties; + $this->oldName = $oldName; + $this->newName = $newName; + } + + public function performEdit(EditorBuffer $buffer) + { + if ($line = $this->getLinePropertyIsDeclaredOn()) { + $buffer->replaceString( + $line, + $this->oldName->getToken(), + $this->newName->getToken() + ); + } + + foreach ($this->getLinesPropertyIsUsedOn() as $line) { + $buffer->replaceString( + $line, + $this->oldName->convertToInstance()->getToken(), + $this->newName->convertToInstance()->getToken() + ); + } + } + + /** + * @return int[] + */ + private function getLinesPropertyIsUsedOn() + { + return $this->definedProperties->usages($this->oldName->getName()); + } + + /** + * @return int + */ + private function getLinePropertyIsDeclaredOn() + { + return $this->definedProperties->declaration($this->oldName->getName()); + } +} + diff --git a/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php b/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php index 0d96c5a..dcfaf9c 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php @@ -30,6 +30,13 @@ static public function variableNotInRange(Variable $variable, LineRange $range) )); } + static public function propertyNotInRange(Variable $variable, LineRange $range) + { + return new self(sprintf('Could not find property "%s" in line range %d-%d.', + $variable->getToken(), $range->getStart(), $range->getEnd() + )); + } + static public function variableNotLocal(Variable $variable) { return new self(sprintf( @@ -53,4 +60,12 @@ static public function rangeIsNotLocalScope(LineRange $range) $range->getStart(), $range->getEnd() )); } + + static public function rangeIsNotClassScope(LineRange $range) + { + return new self(sprintf( + 'The range %d-%d is not inside a class.', + $range->getStart(), $range->getEnd() + )); + } } diff --git a/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php b/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php index 830d19b..88a02ec 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php +++ b/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php @@ -76,6 +76,16 @@ abstract public function getLineOfLastPropertyDefinedInScope(File $file, $line); */ abstract public function isLocalScope(File $file, LineRange $range); + /** + * Check if the line range is inside a class scope. + * + * @param File $file + * @param LineRange $range + * + * @return bool + */ + abstract public function isClassScope(File $file, LineRange $range); + /** * Check if the line range is inside exactly one class method. * @@ -104,6 +114,22 @@ abstract public function isInsideFunction(File $file, LineRange $range); */ abstract public function findClasses(File $file); + /** + * From a range within a class, find the start and end range of that class. + * + * @param File $file + * @param LineRange $range + * + * @return LineRange + */ + public function findClassRange(File $file, LineRange $range) + { + $classStartLine = $this->getClassStartLine($file, $range); + $classEndLine = $this->getClassEndLine($file, $range); + + return LineRange::fromLines($classStartLine, $classEndLine); + } + /** * From a range within a method, find the start and end range of that method. * diff --git a/src/main/QafooLabs/Refactoring/Domain/Services/VariableScanner.php b/src/main/QafooLabs/Refactoring/Domain/Services/VariableScanner.php index 80d04f8..e88a486 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Services/VariableScanner.php +++ b/src/main/QafooLabs/Refactoring/Domain/Services/VariableScanner.php @@ -2,6 +2,7 @@ namespace QafooLabs\Refactoring\Domain\Services; +use QafooLabs\Refactoring\Domain\Model\DefinedProperties; use QafooLabs\Refactoring\Domain\Model\LineRange; use QafooLabs\Refactoring\Domain\Model\File; use QafooLabs\Refactoring\Domain\Model\DefinedVariables; @@ -14,4 +15,11 @@ interface VariableScanner * @return DefinedVariables */ public function scanForVariables(File $file, LineRange $range); + + /** + * Scan a line range within a file for properties. + * + * @return DefinedProperties + */ + public function scanForProperties(File $file, LineRange $range); } From ae172a7b55b4b1dd25d70e20c1e3543d979df95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 15 May 2016 17:07:52 +0200 Subject: [PATCH 22/29] Add a few behat tests --- features/rename_property.feature | 151 +++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 features/rename_property.feature diff --git a/features/rename_property.feature b/features/rename_property.feature new file mode 100644 index 0000000..0f0fa5a --- /dev/null +++ b/features/rename_property.feature @@ -0,0 +1,151 @@ +Feature: Rename Property + To keep my code base clean + As a developer + I want to rename properties + + Scenario: Rename Property using its declaration + Given a PHP File named "src/Foo.php" with: + """ + number; + } + } + """ + When I use refactoring "rename-property" with: + | arg | value | + | file | src/Foo.php | + | line | 4 | + | name | number | + | new-name | magic | + Then the PHP File "src/Foo.php" should be refactored: + """ + --- a/vfs://project/src/Foo.php + +++ b/vfs://project/src/Foo.php + @@ -1,7 +1,7 @@ + number; + + return $var * $this->magic; + } + } + """ + + Scenario: Rename Property using a line where it's used. + Given a PHP File named "src/Foo.php" with: + """ + number; + } + } + """ + When I use refactoring "rename-property" with: + | arg | value | + | file | src/Foo.php | + | line | 14 | + | name | number | + | new-name | magic | + Then the PHP File "src/Foo.php" should be refactored: + """ + --- a/vfs://project/src/Foo.php + +++ b/vfs://project/src/Foo.php + @@ -1,7 +1,7 @@ + number; + + return $var * $this->magic; + } + } + """ + + Scenario: Rename Property using any line inside the class. + Given a PHP File named "src/Foo.php" with: + """ + number; + } + } + """ + When I use refactoring "rename-property" with: + | arg | value | + | file | src/Foo.php | + | line | 7 | + | name | number | + | new-name | magic | + Then the PHP File "src/Foo.php" should be refactored: + """ + --- a/vfs://project/src/Foo.php + +++ b/vfs://project/src/Foo.php + @@ -1,7 +1,7 @@ + number; + + return $var * $this->magic; + } + } + """ \ No newline at end of file From 286a0f1981bb6897a28893f22cf5e2396632cd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Mon, 16 May 2016 14:15:47 +0200 Subject: [PATCH 23/29] Talk about the "Rename Class Property" refactor --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 1b3a4d5..72d76cd 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ Rename a local variable from one to another name: php refactor.phar rename-local-variable +### Rename Class Property + +Rename a class property from one to another name: + + php refactor.phar rename-property + ### Convert Local to Instance Variable Converts a local variable into an instance variable, creates the property and renames From e750c69d78913599b9fb38c5fed15ab708422971 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 4 Jun 2017 16:25:11 +0200 Subject: [PATCH 24/29] Switch to POPSuL fork of php-token-reflection This solves most issues with processing php7 files, plus a host of exotic php5 features. --- composer.json | 9 +- composer.lock | 707 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 502 insertions(+), 214 deletions(-) diff --git a/composer.json b/composer.json index 52bcc2c..3e91d1c 100644 --- a/composer.json +++ b/composer.json @@ -7,10 +7,17 @@ {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"} ], + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/POPSuL/PHP-Token-Reflection" + } + ], + "require": { "nikic/php-parser": "~2.1", "beberlei/assert": "~2.3", - "andrewsville/php-token-reflection": "~1.4", + "POPSuL/php-token-reflection": "dev-develop", "symfony/finder": "~2.4", "symfony/console": "~2.4", "tomphp/patch-builder": "~0.1" diff --git a/composer.lock b/composer.lock index 30257ec..7a25c14 100644 --- a/composer.lock +++ b/composer.lock @@ -4,68 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "65e64a201ab092fabc9d1d854154d30f", - "content-hash": "e3d9aa5afaf15f0d99d52dc2d228fbf1", + "content-hash": "fd3b1ea574a4236057c35fa9b536d672", "packages": [ - { - "name": "andrewsville/php-token-reflection", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/Andrewsville/PHP-Token-Reflection.git", - "reference": "e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Andrewsville/PHP-Token-Reflection/zipball/e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee", - "reference": "e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "TokenReflection": "./" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3" - ], - "authors": [ - { - "name": "Ondřej Nešpor", - "homepage": "https://github.com/andrewsville" - }, - { - "name": "Jaroslav Hanslík", - "homepage": "https://github.com/kukulich" - } - ], - "description": "Library emulating the PHP internal reflection using just the tokenized source code.", - "homepage": "http://andrewsville.github.com/PHP-Token-Reflection/", - "keywords": [ - "library", - "reflection", - "tokenizer" - ], - "time": "2014-08-06 16:37:08" - }, { "name": "beberlei/assert", - "version": "v2.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "91e2690c4ecc8a4e3e2d333430069f6a0c694a7a" + "reference": "8726e183ebbb0169cb6cb4832e22ebd355524563" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/91e2690c4ecc8a4e3e2d333430069f6a0c694a7a", - "reference": "91e2690c4ecc8a4e3e2d333430069f6a0c694a7a", + "url": "https://api.github.com/repos/beberlei/assert/zipball/8726e183ebbb0169cb6cb4832e22ebd355524563", + "reference": "8726e183ebbb0169cb6cb4832e22ebd355524563", "shasum": "" }, "require": { @@ -73,17 +25,13 @@ "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": "@stable" + "friendsofphp/php-cs-fixer": "^2.1.1", + "phpunit/phpunit": "^4|^5" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, "autoload": { - "psr-0": { - "Assert": "lib/" + "psr-4": { + "Assert\\": "lib/Assert" }, "files": [ "lib/Assert/functions.php" @@ -96,7 +44,13 @@ "authors": [ { "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" + "email": "kontakt@beberlei.de", + "role": "Lead Developer" + }, + { + "name": "Richard Quadling", + "email": "rquadling@gmail.com", + "role": "Collaborator" } ], "description": "Thin assertion library for input validation in business models.", @@ -105,20 +59,20 @@ "assertion", "validation" ], - "time": "2016-03-22 14:34:51" + "time": "2017-05-04 02:00:24" }, { "name": "nikic/php-parser", - "version": "v2.1.0", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "47b254ea51f1d6d5dc04b9b299e88346bf2369e3" + "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/47b254ea51f1d6d5dc04b9b299e88346bf2369e3", - "reference": "47b254ea51f1d6d5dc04b9b299e88346bf2369e3", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4dd659edadffdc2143e4753df655d866dbfeedf0", + "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0", "shasum": "" }, "require": { @@ -156,7 +110,7 @@ "parser", "php" ], - "time": "2016-04-19 13:41:41" + "time": "2016-09-16 12:04:44" }, { "name": "phpspec/php-diff", @@ -185,28 +139,139 @@ "authors": [ { "name": "Chris Boulton", - "homepage": "http://github.com/chrisboulton" + "homepage": "http://github.com/chrisboulton", + "role": "Original developer" } ], "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", "time": "2013-11-01 13:02:21" }, + { + "name": "popsul/php-token-reflection", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/POPSuL/PHP-Token-Reflection.git", + "reference": "8883ecd6f63a2ac8e97a3f7ef4529484a8e57ddf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/POPSuL/PHP-Token-Reflection/zipball/8883ecd6f63a2ac8e97a3f7ef4529484a8e57ddf", + "reference": "8883ecd6f63a2ac8e97a3f7ef4529484a8e57ddf", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.0" + }, + "replace": { + "andrewsville/php-token-reflection": "*" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-0": { + "TokenReflection": "./" + } + }, + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Ondřej Nešpor", + "homepage": "https://github.com/Andrewsville" + }, + { + "name": "Jaroslav Hanslík", + "homepage": "https://github.com/kukulich" + }, + { + "name": "Boris Momčilović", + "homepage": "https://github.com/kornrunner" + }, + { + "name": "Viktor Suprun", + "homepage": "https://github.com/POPSuL" + } + ], + "description": "Library emulating the PHP internal reflection using just the tokenized source code.", + "keywords": [ + "library", + "reflection", + "tokenizer" + ], + "support": { + "source": "https://github.com/POPSuL/PHP-Token-Reflection/tree/develop" + }, + "time": "2016-09-29 14:10:38" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10 12:19:37" + }, { "name": "symfony/console", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "48221d3de4dc22d2cd57c97e8b9361821da86609" + "reference": "efa4d466b67c2fc9bf9419a981e683e1f99fa029" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/48221d3de4dc22d2cd57c97e8b9361821da86609", - "reference": "48221d3de4dc22d2cd57c97e8b9361821da86609", + "url": "https://api.github.com/repos/symfony/console/zipball/efa4d466b67c2fc9bf9419a981e683e1f99fa029", + "reference": "efa4d466b67c2fc9bf9419a981e683e1f99fa029", "shasum": "" }, "require": { "php": ">=5.3.9", + "symfony/debug": "^2.7.2|~3.0.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -249,20 +314,77 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-04-26 12:00:47" + "time": "2017-05-28 14:07:33" + }, + { + "name": "symfony/debug", + "version": "v3.0.9", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2016-07-30 07:22:48" }, { "name": "symfony/finder", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ca24cf2cd4e3826f571e0067e535758e73807aa1" + "reference": "b058a6f0cb6ee9b6b727aae03d5a62474a308528" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ca24cf2cd4e3826f571e0067e535758e73807aa1", - "reference": "ca24cf2cd4e3826f571e0067e535758e73807aa1", + "url": "https://api.github.com/repos/symfony/finder/zipball/b058a6f0cb6ee9b6b727aae03d5a62474a308528", + "reference": "b058a6f0cb6ee9b6b727aae03d5a62474a308528", "shasum": "" }, "require": { @@ -298,20 +420,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-03-10 10:53:53" + "time": "2017-05-25 22:57:22" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.1.1", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "1289d16209491b584839022f29257ad859b8532d" + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", - "reference": "1289d16209491b584839022f29257ad859b8532d", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { @@ -323,7 +445,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -357,7 +479,7 @@ "portable", "shim" ], - "time": "2016-01-20 09:13:37" + "time": "2016-11-14 01:06:16" }, { "name": "tomphp/patch-builder", @@ -575,16 +697,16 @@ }, { "name": "mikey179/vfsStream", - "version": "v1.6.3", + "version": "v1.6.4", "source": { "type": "git", "url": "https://github.com/mikey179/vfsStream.git", - "reference": "c19925cd0390d3c436a0203ae859afa460d0474b" + "reference": "0247f57b2245e8ad2e689d7cee754b45fbabd592" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/c19925cd0390d3c436a0203ae859afa460d0474b", - "reference": "c19925cd0390d3c436a0203ae859afa460d0474b", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/0247f57b2245e8ad2e689d7cee754b45fbabd592", + "reference": "0247f57b2245e8ad2e689d7cee754b45fbabd592", "shasum": "" }, "require": { @@ -617,20 +739,20 @@ ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2016-04-09 09:42:01" + "time": "2016-07-18 14:02:57" }, { "name": "phake/phake", - "version": "v2.3.0", + "version": "v2.3.2", "source": { "type": "git", "url": "https://github.com/mlively/Phake.git", - "reference": "2202d361d34f2712dcc257afdedc6c30060dc9bd" + "reference": "d5832f1a0dd2370e14d38bcbaeb6770e8546cff2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mlively/Phake/zipball/2202d361d34f2712dcc257afdedc6c30060dc9bd", - "reference": "2202d361d34f2712dcc257afdedc6c30060dc9bd", + "url": "https://api.github.com/repos/mlively/Phake/zipball/d5832f1a0dd2370e14d38bcbaeb6770e8546cff2", + "reference": "d5832f1a0dd2370e14d38bcbaeb6770e8546cff2", "shasum": "" }, "require": { @@ -675,41 +797,138 @@ "mock", "testing" ], - "time": "2016-03-04 18:49:33" + "time": "2017-03-20 05:16:34" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2015-12-27 11:43:31" }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/type-resolver": "^0.2.0", + "webmozart/assert": "^1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2016-09-30 07:12:33" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "psr-0": { - "phpDocumentor": [ + "psr-4": { + "phpDocumentor\\Reflection\\": [ "src/" ] } @@ -721,39 +940,40 @@ "authors": [ { "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" + "email": "me@mikevanriel.com" } ], - "time": "2015-02-03 12:10:50" + "time": "2016-11-25 06:54:22" }, { "name": "phpspec/prophecy", - "version": "v1.6.0", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972" + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972", - "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1", - "sebastian/recursion-context": "~1.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "~2.0" + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8 || ^5.6.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -786,7 +1006,7 @@ "spy", "stub" ], - "time": "2016-02-15 07:46:21" + "time": "2017-03-02 20:05:34" }, { "name": "phpunit/php-code-coverage", @@ -852,16 +1072,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { @@ -895,7 +1115,7 @@ "filesystem", "iterator" ], - "time": "2015-06-21 13:08:43" + "time": "2016-10-03 07:40:28" }, { "name": "phpunit/php-text-template", @@ -940,25 +1160,30 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.8", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4|~5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -980,20 +1205,20 @@ "keywords": [ "timer" ], - "time": "2016-05-12 18:03:57" + "time": "2017-02-26 11:10:40" }, { "name": "phpunit/php-token-stream", - "version": "1.4.8", + "version": "1.4.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "shasum": "" }, "require": { @@ -1029,20 +1254,20 @@ "keywords": [ "tokenizer" ], - "time": "2015-09-15 10:49:45" + "time": "2017-02-27 10:12:30" }, { "name": "phpunit/phpunit", - "version": "4.8.24", + "version": "4.8.35", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1066c562c52900a142a0e2bbf0582994671385e" + "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e", - "reference": "a1066c562c52900a142a0e2bbf0582994671385e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87", + "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87", "shasum": "" }, "require": { @@ -1056,9 +1281,9 @@ "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", + "phpunit/php-timer": "^1.0.6", "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", + "sebastian/comparator": "~1.2.2", "sebastian/diff": "~1.2", "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", @@ -1101,7 +1326,7 @@ "testing", "xunit" ], - "time": "2016-03-14 06:16:08" + "time": "2017-02-06 05:18:07" }, { "name": "phpunit/phpunit-mock-objects", @@ -1161,22 +1386,22 @@ }, { "name": "sebastian/comparator", - "version": "1.2.0", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "shasum": "" }, "require": { "php": ">=5.3.3", "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" + "sebastian/exporter": "~1.2 || ~2.0" }, "require-dev": { "phpunit/phpunit": "~4.4" @@ -1221,27 +1446,27 @@ "compare", "equality" ], - "time": "2015-07-26 15:48:44" + "time": "2017-01-29 09:50:25" }, { "name": "sebastian/diff", - "version": "1.4.1", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", "extra": { @@ -1273,27 +1498,27 @@ "keywords": [ "diff" ], - "time": "2015-12-08 07:14:41" + "time": "2017-05-22 07:24:03" }, { "name": "sebastian/environment", - "version": "1.3.6", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "2292b116f43c272ff4328083096114f84ea46a56" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/2292b116f43c272ff4328083096114f84ea46a56", - "reference": "2292b116f43c272ff4328083096114f84ea46a56", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^4.8 || ^5.0" }, "type": "library", "extra": { @@ -1323,20 +1548,20 @@ "environment", "hhvm" ], - "time": "2016-05-04 07:59:13" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e" + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", "shasum": "" }, "require": { @@ -1344,12 +1569,13 @@ "sebastian/recursion-context": "~1.0" }, "require-dev": { + "ext-mbstring": "*", "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -1389,7 +1615,7 @@ "export", "exporter" ], - "time": "2015-06-21 07:55:53" + "time": "2016-06-17 09:04:28" }, { "name": "sebastian/global-state", @@ -1444,16 +1670,16 @@ }, { "name": "sebastian/recursion-context", - "version": "1.0.2", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", "shasum": "" }, "require": { @@ -1493,7 +1719,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" + "time": "2016-10-03 07:41:43" }, { "name": "sebastian/version", @@ -1532,22 +1758,25 @@ }, { "name": "symfony/config", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "edbbcf33cffa2a85104fc80de8dc052cc51596bb" + "reference": "0b8541d18507d10204a08384640ff6df3c739ebe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/edbbcf33cffa2a85104fc80de8dc052cc51596bb", - "reference": "edbbcf33cffa2a85104fc80de8dc052cc51596bb", + "url": "https://api.github.com/repos/symfony/config/zipball/0b8541d18507d10204a08384640ff6df3c739ebe", + "reference": "0b8541d18507d10204a08384640ff6df3c739ebe", "shasum": "" }, "require": { "php": ">=5.3.9", "symfony/filesystem": "~2.3|~3.0.0" }, + "require-dev": { + "symfony/yaml": "~2.7|~3.0.0" + }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" }, @@ -1581,20 +1810,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-04-20 18:52:26" + "time": "2017-04-12 14:07:15" }, { "name": "symfony/dependency-injection", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "bd04588c087651ceffdc45d40dc4de05af9c7c52" + "reference": "155b770e68150139779295864d6b6cb3172cd821" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/bd04588c087651ceffdc45d40dc4de05af9c7c52", - "reference": "bd04588c087651ceffdc45d40dc4de05af9c7c52", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/155b770e68150139779295864d6b6cb3172cd821", + "reference": "155b770e68150139779295864d6b6cb3172cd821", "shasum": "" }, "require": { @@ -1606,7 +1835,7 @@ "require-dev": { "symfony/config": "~2.2|~3.0.0", "symfony/expression-language": "~2.6|~3.0.0", - "symfony/yaml": "~2.1|~3.0.0" + "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7|~3.0.7" }, "suggest": { "symfony/config": "", @@ -1644,20 +1873,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-05-09 18:12:35" + "time": "2017-05-25 22:57:22" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a158f13992a3147d466af7a23b564ac719a4ddd8" + "reference": "7fc8e2b4118ff316550596357325dfd92a51f531" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a158f13992a3147d466af7a23b564ac719a4ddd8", - "reference": "a158f13992a3147d466af7a23b564ac719a4ddd8", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7fc8e2b4118ff316550596357325dfd92a51f531", + "reference": "7fc8e2b4118ff316550596357325dfd92a51f531", "shasum": "" }, "require": { @@ -1665,7 +1894,7 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5|~3.0.0", + "symfony/config": "^2.0.5|~3.0.0", "symfony/dependency-injection": "~2.6|~3.0.0", "symfony/expression-language": "~2.6|~3.0.0", "symfony/stopwatch": "~2.3|~3.0.0" @@ -1704,20 +1933,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-05-03 18:59:18" + "time": "2017-04-26 16:56:54" }, { "name": "symfony/filesystem", - "version": "v3.0.6", + "version": "v3.0.9", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "74fec3511b62cb934b64bce1d96f06fffa4beafd" + "reference": "b2da5009d9bacbd91d83486aa1f44c793a8c380d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/74fec3511b62cb934b64bce1d96f06fffa4beafd", - "reference": "74fec3511b62cb934b64bce1d96f06fffa4beafd", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b2da5009d9bacbd91d83486aa1f44c793a8c380d", + "reference": "b2da5009d9bacbd91d83486aa1f44c793a8c380d", "shasum": "" }, "require": { @@ -1753,20 +1982,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-04-12 18:09:53" + "time": "2016-07-20 05:43:46" }, { "name": "symfony/process", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "1276bd9be89be039748cf753a2137f4ef149cd74" + "reference": "d54232f5682fda2f8bbebff7c81b864646867ab9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/1276bd9be89be039748cf753a2137f4ef149cd74", - "reference": "1276bd9be89be039748cf753a2137f4ef149cd74", + "url": "https://api.github.com/repos/symfony/process/zipball/d54232f5682fda2f8bbebff7c81b864646867ab9", + "reference": "d54232f5682fda2f8bbebff7c81b864646867ab9", "shasum": "" }, "require": { @@ -1802,20 +2031,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-04-14 15:22:22" + "time": "2017-05-08 01:19:21" }, { "name": "symfony/translation", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "d60b8e076d22953aabebeebda53bf334438e7aca" + "reference": "32b7c0bffc07772cf1a902e3464ef77117fa07c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/d60b8e076d22953aabebeebda53bf334438e7aca", - "reference": "d60b8e076d22953aabebeebda53bf334438e7aca", + "url": "https://api.github.com/repos/symfony/translation/zipball/32b7c0bffc07772cf1a902e3464ef77117fa07c7", + "reference": "32b7c0bffc07772cf1a902e3464ef77117fa07c7", "shasum": "" }, "require": { @@ -1828,7 +2057,7 @@ "require-dev": { "psr/log": "~1.0", "symfony/config": "~2.8", - "symfony/intl": "~2.4|~3.0.0", + "symfony/intl": "~2.7.25|^2.8.18|~3.2.5", "symfony/yaml": "~2.2|~3.0.0" }, "suggest": { @@ -1866,20 +2095,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-03-25 01:40:30" + "time": "2017-04-12 14:07:15" }, { "name": "symfony/yaml", - "version": "v2.8.6", + "version": "v2.8.21", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "e4fbcc65f90909c999ac3b4dfa699ee6563a9940" + "reference": "93ccdde79f4b079c7558da4656a3cb1c50c68e02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e4fbcc65f90909c999ac3b4dfa699ee6563a9940", - "reference": "e4fbcc65f90909c999ac3b4dfa699ee6563a9940", + "url": "https://api.github.com/repos/symfony/yaml/zipball/93ccdde79f4b079c7558da4656a3cb1c50c68e02", + "reference": "93ccdde79f4b079c7558da4656a3cb1c50c68e02", "shasum": "" }, "require": { @@ -1915,12 +2144,64 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-03-29 19:00:15" + "time": "2017-05-01 14:31:55" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23 20:04:58" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "popsul/php-token-reflection": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], From 8d49db4abfaddc9cc0595054d69abc231ad0a098 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 4 Jun 2017 16:26:42 +0200 Subject: [PATCH 25/29] Don't throw a fit when file doesn't contain a class --- .../Refactoring/Application/OptimizeUse.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php b/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php index fe29623..c416c42 100644 --- a/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php +++ b/src/main/QafooLabs/Refactoring/Application/OptimizeUse.php @@ -33,15 +33,19 @@ public function __construct($codeAnalysis, $editor, $phpNameScanner) public function refactor(File $file) { + $appendNewLine = false; $classes = $this->codeAnalysis->findClasses($file); - $occurances = $this->phpNameScanner->findNames($file); - $class = $classes[0]; + $lastUseStatementLine = 2; + if ($classes) { + $class = $classes[0]; - $appendNewLine = 0 === $class->namespaceDeclarationLine(); - $lastUseStatementLine = $class->namespaceDeclarationLine() + 2; + $appendNewLine = 0 === $class->namespaceDeclarationLine(); + $lastUseStatementLine = $class->namespaceDeclarationLine() + 2; + } $usedNames = array(); $fqcns = array(); + $occurances = $this->phpNameScanner->findNames($file); foreach ($occurances as $occurance) { $name = $occurance->name(); From ff01104763020d35789c9e996767cf4384376bbf Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 5 Jun 2017 01:16:24 +0200 Subject: [PATCH 26/29] Switch to my branch of PHP-Token-Reflection This fixes refactoring files where keywords are used in special context: MyClass::class --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 3e91d1c..1f792fe 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "repositories": [ { "type": "vcs", - "url": "https://github.com/POPSuL/PHP-Token-Reflection" + "url": "https://github.com/AJenbo/PHP-Token-Reflection" } ], diff --git a/composer.lock b/composer.lock index 7a25c14..e1cabe9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "fd3b1ea574a4236057c35fa9b536d672", + "content-hash": "69f1d3096260391b5c482defdfa591c4", "packages": [ { "name": "beberlei/assert", @@ -151,13 +151,13 @@ "version": "dev-develop", "source": { "type": "git", - "url": "https://github.com/POPSuL/PHP-Token-Reflection.git", - "reference": "8883ecd6f63a2ac8e97a3f7ef4529484a8e57ddf" + "url": "https://github.com/AJenbo/PHP-Token-Reflection.git", + "reference": "21b9a442e62be8c1ba063a89f0f785807c98c96f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/POPSuL/PHP-Token-Reflection/zipball/8883ecd6f63a2ac8e97a3f7ef4529484a8e57ddf", - "reference": "8883ecd6f63a2ac8e97a3f7ef4529484a8e57ddf", + "url": "https://api.github.com/repos/AJenbo/PHP-Token-Reflection/zipball/21b9a442e62be8c1ba063a89f0f785807c98c96f", + "reference": "21b9a442e62be8c1ba063a89f0f785807c98c96f", "shasum": "" }, "require": { @@ -204,9 +204,9 @@ "tokenizer" ], "support": { - "source": "https://github.com/POPSuL/PHP-Token-Reflection/tree/develop" + "source": "https://github.com/AJenbo/PHP-Token-Reflection/tree/develop" }, - "time": "2016-09-29 14:10:38" + "time": "2017-06-04 16:08:02" }, { "name": "psr/log", From bdc51b3f01c8b69cb147704fc6ac4471363dd632 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 2 Jul 2017 16:43:08 +0200 Subject: [PATCH 27/29] Hanvle nested array keys --- .../PHPParser/Visitor/LocalVariableClassifier.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php index e75ea2a..59e6ffd 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor/LocalVariableClassifier.php @@ -59,10 +59,15 @@ private function enterAssignment(Node\Expr\Assign $node) $this->assignments[$node->var->name][] = $node->getLine(); $this->seenAssignmentVariables->attach($node->var); } else if ($node->var instanceof Node\Expr\ArrayDimFetch) { + // unfold $array[$var][$var] + $var = $node->var->var; + while (!isset($var->name)) { + $var = $var->var; + } // $foo[] = "baz" is both a read and a write access to $foo - $this->localVariables[$node->var->var->name][] = $node->getLine(); - $this->assignments[$node->var->var->name][] = $node->getLine(); - $this->seenAssignmentVariables->attach($node->var->var); + $this->localVariables[$var->name][] = $node->getLine(); + $this->assignments[$var->name][] = $node->getLine(); + $this->seenAssignmentVariables->attach($var); } } From 8c868342801b3999f230e06d0107460cf6287fbc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 4 Jul 2017 14:36:13 +0200 Subject: [PATCH 28/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72d76cd..8ac0c22 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Based on data from these sources the Refactoring Browser consists of two distinc ## Install & Basic Usage -[Download PHAR](https://github.com/QafooLabs/php-refactoring-browser/releases) +[Download PHAR](https://github.com/AJenbo/php-refactoring-browser/releases) The refactoring browser is used with: From 774b51e57cf91c237be505c913dd0e7b1ba2ad75 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 4 Jul 2017 15:04:56 +0200 Subject: [PATCH 29/29] Require php 5.5 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f777d98..7ccf910 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,11 @@ php: - 5.5 - 5.6 - 7.0 - - hhvm matrix: fast_finish: true + allow_failures: + - php: 5.4 before_install: - phpenv config-rm xdebug.ini || true