diff --git a/.travis.yml b/.travis.yml index 003337d..7ccf910 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 @@ -12,5 +11,15 @@ php: matrix: fast_finish: true allow_failures: - - php: hhvm - - php: 7 + - php: 5.4 + +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 diff --git a/README.md b/README.md index 1b3a4d5..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: @@ -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 diff --git a/composer.json b/composer.json index e605c7a..1f792fe 100644 --- a/composer.json +++ b/composer.json @@ -7,22 +7,29 @@ {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"} ], + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/AJenbo/PHP-Token-Reflection" + } + ], + "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": "~2.1", + "beberlei/assert": "~2.3", + "POPSuL/php-token-reflection": "dev-develop", + "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..e1cabe9 100644 --- a/composer.lock +++ b/composer.lock @@ -1,84 +1,37 @@ { "_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", + "content-hash": "69f1d3096260391b5c482defdfa591c4", "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.3", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "160eba4d1fbe692e42b3cf8a20b92ab23e3a8759" + "reference": "8726e183ebbb0169cb6cb4832e22ebd355524563" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/160eba4d1fbe692e42b3cf8a20b92ab23e3a8759", - "reference": "160eba4d1fbe692e42b3cf8a20b92ab23e3a8759", + "url": "https://api.github.com/repos/beberlei/assert/zipball/8726e183ebbb0169cb6cb4832e22ebd355524563", + "reference": "8726e183ebbb0169cb6cb4832e22ebd355524563", "shasum": "" }, "require": { - "ext-mbstring": "*" + "ext-mbstring": "*", + "php": ">=5.3" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.1.1", + "phpunit/phpunit": "^4|^5" }, + "type": "library", "autoload": { - "psr-0": { - "Assert": "lib/" + "psr-4": { + "Assert\\": "lib/Assert" }, "files": [ "lib/Assert/functions.php" @@ -91,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.", @@ -100,36 +59,42 @@ "assertion", "validation" ], - "time": "2014-12-18 19:12:40" + "time": "2017-05-04 02:00:24" }, { "name": "nikic/php-parser", - "version": "v1.2.2", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "08f97eb4efa029e2fafb6d8c98b71731bf0cf621" + "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0" }, "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/4dd659edadffdc2143e4753df655d866dbfeedf0", + "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0", "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.2-dev" + "dev-master": "2.1-dev" } }, "autoload": { - "files": [ - "lib/bootstrap.php" - ] + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -145,7 +110,7 @@ "parser", "php" ], - "time": "2015-04-03 14:33:59" + "time": "2016-09-16 12:04:44" }, { "name": "phpspec/php-diff", @@ -174,35 +139,145 @@ "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/AJenbo/PHP-Token-Reflection.git", + "reference": "21b9a442e62be8c1ba063a89f0f785807c98c96f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/AJenbo/PHP-Token-Reflection/zipball/21b9a442e62be8c1ba063a89f0f785807c98c96f", + "reference": "21b9a442e62be8c1ba063a89f0f785807c98c96f", + "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/AJenbo/PHP-Token-Reflection/tree/develop" + }, + "time": "2017-06-04 16:08:02" + }, + { + "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.6.6", - "target-dir": "Symfony/Component/Console", + "version": "v2.8.21", "source": { "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "5b91dc4ed5eb08553f57f6df04c4730a73992667" + "url": "https://github.com/symfony/console.git", + "reference": "efa4d466b67c2fc9bf9419a981e683e1f99fa029" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/5b91dc4ed5eb08553f57f6df04c4730a73992667", - "reference": "5b91dc4ed5eb08553f57f6df04c4730a73992667", + "url": "https://api.github.com/repos/symfony/console/zipball/efa4d466b67c2fc9bf9419a981e683e1f99fa029", + "reference": "efa4d466b67c2fc9bf9419a981e683e1f99fa029", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9", + "symfony/debug": "^2.7.2|~3.0.0", + "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,81 +287,199 @@ "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": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "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" + "homepage": "https://symfony.com", + "time": "2017-05-28 14:07:33" }, { - "name": "symfony/finder", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Finder", + "name": "symfony/debug", + "version": "v3.0.9", "source": { "type": "git", - "url": "https://github.com/symfony/Finder.git", - "reference": "5dbe2e73a580618f5b4880fda93406eed25de251" + "url": "https://github.com/symfony/debug.git", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/5dbe2e73a580618f5b4880fda93406eed25de251", - "reference": "5dbe2e73a580618f5b4880fda93406eed25de251", + "url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a", "shasum": "" }, "require": { - "php": ">=5.3.3" + "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/phpunit-bridge": "~2.7" + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" - } + "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": "http://symfony.com/contributors" + "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.21", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "b058a6f0cb6ee9b6b727aae03d5a62474a308528" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/b058a6f0cb6ee9b6b727aae03d5a62474a308528", + "reference": "b058a6f0cb6ee9b6b727aae03d5a62474a308528", + "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 Finder Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2017-05-25 22:57:22" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2016-11-14 01:06:16" }, { "name": "tomphp/patch-builder", @@ -327,27 +520,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 +578,7 @@ "Behat", "Symfony2" ], - "time": "2015-01-23 22:18:15" + "time": "2015-06-01 09:37:55" }, { "name": "behat/gherkin", @@ -450,16 +643,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 +663,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 +672,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, "notification-url": "https://packagist.org/downloads/", @@ -500,20 +693,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.4", "source": { "type": "git", "url": "https://github.com/mikey179/vfsStream.git", - "reference": "4dc0d2f622412f561f5b242b19b98068bbbc883a" + "reference": "0247f57b2245e8ad2e689d7cee754b45fbabd592" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/4dc0d2f622412f561f5b242b19b98068bbbc883a", - "reference": "4dc0d2f622412f561f5b242b19b98068bbbc883a", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/0247f57b2245e8ad2e689d7cee754b45fbabd592", + "reference": "0247f57b2245e8ad2e689d7cee754b45fbabd592", "shasum": "" }, "require": { @@ -525,7 +718,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -546,26 +739,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-07-18 14:02:57" }, { "name": "phake/phake", - "version": "v2.0.2", + "version": "v2.3.2", "source": { "type": "git", "url": "https://github.com/mlively/Phake.git", - "reference": "15d688aa23e6d5db433accb75feea6c0a1cdd1f1" + "reference": "d5832f1a0dd2370e14d38bcbaeb6770e8546cff2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mlively/Phake/zipball/15d688aa23e6d5db433accb75feea6c0a1cdd1f1", - "reference": "15d688aa23e6d5db433accb75feea6c0a1cdd1f1", + "url": "https://api.github.com/repos/mlively/Phake/zipball/d5832f1a0dd2370e14d38bcbaeb6770e8546cff2", + "reference": "d5832f1a0dd2370e14d38bcbaeb6770e8546cff2", "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 +773,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0.0-dev" } }, "autoload": { @@ -602,41 +797,138 @@ "mock", "testing" ], - "time": "2015-03-21 18:05:30" + "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/" ] } @@ -648,37 +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": "1.4.0", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5" + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5", - "reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" + "php": "^5.3|^7.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.4.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -711,20 +1006,20 @@ "spy", "stub" ], - "time": "2015-03-27 19:31:25" + "time": "2017-03-02 20:05:34" }, { "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 +1027,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 +1042,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.2.x-dev" } }, "autoload": { @@ -773,20 +1068,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.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "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/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { @@ -820,20 +1115,20 @@ "filesystem", "iterator" ], - "time": "2015-04-02 05:19:05" + "time": "2016-10-03 07:40:28" }, { "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 +1137,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 +1156,40 @@ "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.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "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/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -908,20 +1205,20 @@ "keywords": [ "timer" ], - "time": "2013-08-02 07:42:54" + "time": "2017-02-26 11:10:40" }, { "name": "phpunit/php-token-stream", - "version": "1.4.1", + "version": "1.4.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "eab81d02569310739373308137284e0158424330" + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" }, "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/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "shasum": "" }, "require": { @@ -957,20 +1254,20 @@ "keywords": [ "tokenizer" ], - "time": "2015-04-08 04:46:07" + "time": "2017-02-27 10:12:30" }, { "name": "phpunit/phpunit", - "version": "4.6.4", + "version": "4.8.35", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "163232991e652e6efed2f8470326fffa61e848e2" + "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/163232991e652e6efed2f8470326fffa61e848e2", - "reference": "163232991e652e6efed2f8470326fffa61e848e2", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87", + "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87", "shasum": "" }, "require": { @@ -980,15 +1277,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/comparator": "~1.2.2", "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 +1300,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.6.x-dev" + "dev-master": "4.8.x-dev" } }, "autoload": { @@ -1029,26 +1326,27 @@ "testing", "xunit" ], - "time": "2015-04-11 05:23:21" + "time": "2017-02-06 05:18:07" }, { "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,26 +1382,26 @@ "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.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", - "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "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" @@ -1111,7 +1409,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -1148,32 +1446,32 @@ "compare", "equality" ], - "time": "2015-01-29 16:28:08" + "time": "2017-01-29 09:50:25" }, { "name": "sebastian/diff", - "version": "1.3.0", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "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.2" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1196,31 +1494,31 @@ } ], "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": "2017-05-22 07:24:03" }, { "name": "sebastian/environment", - "version": "1.2.2", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", - "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "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": { @@ -1250,20 +1548,20 @@ "environment", "hhvm" ], - "time": "2015-01-01 10:01:08" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", - "version": "1.2.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "84839970d05254c73cde183a721c7af13aede943" + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", - "reference": "84839970d05254c73cde183a721c7af13aede943", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", "shasum": "" }, "require": { @@ -1271,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": { @@ -1316,20 +1615,20 @@ "export", "exporter" ], - "time": "2015-01-27 07:23:06" + "time": "2016-06-17 09:04:28" }, { "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 +1666,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.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" }, "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/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", "shasum": "" }, "require": { @@ -1420,20 +1719,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": "2016-10-03 07:41:43" }, { "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 +1754,150 @@ ], "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.21", "source": { "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "d91be01336605db8da21b79bc771e46a7276d1bc" + "url": "https://github.com/symfony/config.git", + "reference": "0b8541d18507d10204a08384640ff6df3c739ebe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/d91be01336605db8da21b79bc771e46a7276d1bc", - "reference": "d91be01336605db8da21b79bc771e46a7276d1bc", + "url": "https://api.github.com/repos/symfony/config/zipball/0b8541d18507d10204a08384640ff6df3c739ebe", + "reference": "0b8541d18507d10204a08384640ff6df3c739ebe", "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" + "symfony/yaml": "~2.7|~3.0.0" + }, + "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": "2017-04-12 14:07:15" }, { "name": "symfony/dependency-injection", - "version": "v2.6.6", - "target-dir": "Symfony/Component/DependencyInjection", + "version": "v2.8.21", "source": { "type": "git", - "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "8e9007012226b4bd41f8afed855c452cf5edc3a6" + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "155b770e68150139779295864d6b6cb3172cd821" }, "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/155b770e68150139779295864d6b6cb3172cd821", + "reference": "155b770e68150139779295864d6b6cb3172cd821", "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.3.42|~2.7.14|~2.8.7|~3.0.7" }, "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": "2017-05-25 22:57:22" }, { "name": "symfony/event-dispatcher", - "version": "v2.6.6", - "target-dir": "Symfony/Component/EventDispatcher", + "version": "v2.8.21", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "7fc8e2b4118ff316550596357325dfd92a51f531" }, "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/7fc8e2b4118ff316550596357325dfd92a51f531", + "reference": "7fc8e2b4118ff316550596357325dfd92a51f531", "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.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 +1906,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": "2017-04-26 16:56:54" }, { "name": "symfony/filesystem", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Filesystem", + "version": "v3.0.9", "source": { "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "4983964b3693e4f13449cb3800c64a9112c301b4" + "url": "https://github.com/symfony/filesystem.git", + "reference": "b2da5009d9bacbd91d83486aa1f44c793a8c380d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/4983964b3693e4f13449cb3800c64a9112c301b4", - "reference": "4983964b3693e4f13449cb3800c64a9112c301b4", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b2da5009d9bacbd91d83486aa1f44c793a8c380d", + "reference": "b2da5009d9bacbd91d83486aa1f44c793a8c380d", "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-07-20 05:43:46" }, { "name": "symfony/process", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Process", + "version": "v2.8.21", "source": { "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552" + "url": "https://github.com/symfony/process.git", + "reference": "d54232f5682fda2f8bbebff7c81b864646867ab9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/a8bebaec1a9dc6cde53e0250e32917579b0be552", - "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552", + "url": "https://api.github.com/repos/symfony/process/zipball/d54232f5682fda2f8bbebff7c81b864646867ab9", + "reference": "d54232f5682fda2f8bbebff7c81b864646867ab9", "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": "2017-05-08 01:19:21" }, { "name": "symfony/translation", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Translation", + "version": "v2.8.21", "source": { "type": "git", - "url": "https://github.com/symfony/Translation.git", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af" + "url": "https://github.com/symfony/translation.git", + "reference": "32b7c0bffc07772cf1a902e3464ef77117fa07c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af", + "url": "https://api.github.com/repos/symfony/translation/zipball/32b7c0bffc07772cf1a902e3464ef77117fa07c7", + "reference": "32b7c0bffc07772cf1a902e3464ef77117fa07c7", "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.7.25|^2.8.18|~3.2.5", + "symfony/yaml": "~2.2|~3.0.0" }, "suggest": { "psr/log": "To use logging capability in translator", @@ -1761,101 +2068,144 @@ "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": "2017-04-12 14:07:15" }, { "name": "symfony/yaml", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Yaml", + "version": "v2.8.21", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "174f009ed36379a801109955fc5a71a49fe62dd4" + "url": "https://github.com/symfony/yaml.git", + "reference": "93ccdde79f4b079c7558da4656a3cb1c50c68e02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4", - "reference": "174f009ed36379a801109955fc5a71a49fe62dd4", + "url": "https://api.github.com/repos/symfony/yaml/zipball/93ccdde79f4b079c7558da4656a3cb1c50c68e02", + "reference": "93ccdde79f4b079c7558da4656a3cb1c50c68e02", "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": "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": { - "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 + "popsul/php-token-reflection": 20 }, "prefer-stable": false, "prefer-lowest": false, "platform": [], "platform-dev": { - "php": ">=5.4" + "php": "~5.4|~7.0" } } diff --git a/features/rename_local_variable.feature b/features/rename_local_variable.feature index 3389255..c871968 100644 --- a/features/rename_local_variable.feature +++ b/features/rename_local_variable.feature @@ -90,3 +90,125 @@ Feature: Rename Local Variable } """ + + Scenario: Rename a method argument + Given a PHP File named "src/MethodArgument.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 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 @@ create(ParserFactory::PREFER_PHP7); $collector = new PhpNameCollector(); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); try { $stmts = $parser->parse($file->getCode()); - } catch (PHPParser_Error $e) { - throw new \RuntimeException("Error parsing " . $file->getRelativePath() .": " . $e->getMessage(), 0, $e); + } catch (\PHPParser\Error $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 1edbd68..cdbd17b 100644 --- a/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php +++ b/src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserVariableScanner.php @@ -14,6 +14,10 @@ namespace QafooLabs\Refactoring\Adapters\PHPParser; +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; @@ -23,23 +27,15 @@ 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()); - $stmts = $parser->parse($file->getCode()); + $stmts = $this->parse($file); $collector = new LineRangeStatementCollector($range); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor(new NodeConnector); $traverser->addVisitor($collector); @@ -48,11 +44,11 @@ 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(); - $traverser = new PHPParser_NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor($localVariableClassifier); $traverser->traverse($selectedStatements); @@ -61,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/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..59e6ffd 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,42 +33,47 @@ 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->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); } } - private function enterVariableNode($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/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(); 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/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/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/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 93db01b..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; @@ -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/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 d21ca51..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; /** @@ -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..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; @@ -59,7 +59,6 @@ protected function configure() HELP ); - ; } protected function execute(InputInterface $input, OutputInterface $output) 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 c766693..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); @@ -45,7 +67,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,12 +78,34 @@ 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(); } + 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); @@ -83,7 +127,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) @@ -91,6 +135,21 @@ 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); + } + + public function isClassScope(File $file, LineRange $range) + { + return $this->findMatchingClass($file, $range) !== null; + } + /** * @param File $file * @return PhpClass[] @@ -116,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; @@ -127,7 +206,7 @@ private function findMatchingMethod(File $file, LineRange $range) foreach ($file->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; } @@ -137,4 +216,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/ConvertLocalToInstanceVariable.php b/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php index 5c7e925..5eac854 100644 --- a/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php +++ b/src/main/QafooLabs/Refactoring/Application/ConvertLocalToInstanceVariable.php @@ -3,16 +3,9 @@ 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; @@ -54,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)); 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..c416c42 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; @@ -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(); diff --git a/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php b/src/main/QafooLabs/Refactoring/Application/RenameLocalVariable.php index 4cd51ef..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; /** @@ -39,7 +36,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); @@ -61,7 +58,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)); 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 2af397a..c476eed 100644 --- a/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php +++ b/src/main/QafooLabs/Refactoring/Application/SingleFileRefactoring.php @@ -59,6 +59,20 @@ 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 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); @@ -75,7 +89,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 @@ -83,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/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/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/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/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..c449620 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php +++ b/src/main/QafooLabs/Refactoring/Domain/Model/MethodSignature.php @@ -43,11 +43,11 @@ 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)) { - 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..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; @@ -184,7 +183,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/Domain/Model/RefactoringException.php b/src/main/QafooLabs/Refactoring/Domain/Model/RefactoringException.php index d2319b9..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( @@ -45,4 +52,20 @@ 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() + )); + } + + 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 dab67a8..88a02ec 100644 --- a/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php +++ b/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php @@ -40,12 +40,52 @@ 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 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. * @@ -56,6 +96,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. * @@ -64,6 +114,22 @@ abstract public function isInsideMethod(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. * @@ -79,5 +145,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); + } } 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); } 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/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/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); $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); } @@ -54,11 +52,13 @@ private function range($range) private function statements($code) { - if (strpos($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 705ef6d..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 e47da60..2406754 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() @@ -33,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' 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 +60,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..74a23c5 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' + $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' + $this->refactoring->refactor(new File('foo.php', <<<'PHP' applyCommand)->apply(<<<'CODE' diff --git a/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php b/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php index 06cdca2..a1a4904 100644 --- a/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php +++ b/src/test/QafooLabs/Refactoring/Domain/Model/EditingAction/AddMethodTest.php @@ -3,13 +3,11 @@ 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 { - private $action; - private $buffer; protected function setUp() 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..8265bfc 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); + 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 243ced3..3b849c8 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); @@ -95,21 +95,20 @@ 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."); + $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); $this->assertEquals('Qafoo\ChangeTrack\Analyzer\ChangeFeed', $changed->fullyQualifiedName()); - $this->assertEQuals('Analyzer\ChangeFeed', $changed->relativeName()); + $this->assertEquals('Analyzer\ChangeFeed', $changed->relativeName()); } public function testRegression6() @@ -211,7 +210,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/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); } } 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); }