@TomasVotruba As suggested to you, I'm opening this issue to track this. I'll use Phalcon Framework as an example. Steps to reproduce:
I forked and checkout the 4.0.x branch.
I installed Rector globally, with #207, and I ran:
rector process tests/ --level phpunit60
Only the tests/_ci/phpunit.php file got changed:
- PHPUnit_TextUI_Command::main();
+ PHPUnit\TextUI\Command::main();
There are many file_exists, is_* (not merged wet here #199), that didn't got affected. I tried to reproduce a PR I did a while ago there #13192.
I recall I had many troubles with compser global at @apigen, let's narrow allowed installitions to composer create-project * and composer require to not waste time with that.
Could you retry with that?
Also, have you run composer update * on phalcon? It's vendor deps might be needed.
I tried. Here as the steps:
I forked and checkout the 4.0.x branch.
I installed cphalcon dependencies with composer install.
I ran:
composer require --dev rector/rector @dev nikic/php-parser '4.0.x-dev'
And got some errors:
Problem 1
- rector/rector dev-master requires symplify/easy-coding-standard ^3.0 -> satisfiable by symplify/easy-coding-standard[v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6].
- rector/rector dev-rector-phpunit-simpler requires symplify/easy-coding-standard ^3.0 -> satisfiable by symplify/easy-coding-standard[v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6].
- symplify/easy-coding-standard v3.0.6 requires squizlabs/php_codesniffer ^3.2 -> satisfiable by squizlabs/php_codesniffer[3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- symplify/easy-coding-standard v3.0.5 requires squizlabs/php_codesniffer ^3.2 -> satisfiable by squizlabs/php_codesniffer[3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- symplify/easy-coding-standard v3.0.4 requires squizlabs/php_codesniffer ^3.2 -> satisfiable by squizlabs/php_codesniffer[3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- symplify/easy-coding-standard v3.0.3 requires squizlabs/php_codesniffer ^3.2 -> satisfiable by squizlabs/php_codesniffer[3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- symplify/easy-coding-standard v3.0.2 requires squizlabs/php_codesniffer ^3.2 -> satisfiable by squizlabs/php_codesniffer[3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- symplify/easy-coding-standard v3.0.1 requires squizlabs/php_codesniffer ^3.1 -> satisfiable by squizlabs/php_codesniffer[3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- symplify/easy-coding-standard v3.0.0 requires squizlabs/php_codesniffer ^3.1 -> satisfiable by squizlabs/php_codesniffer[3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for rector/rector @dev -> satisfiable by rector/rector[dev-master, dev-rector-phpunit-simpler, v0.1.0].
- Conclusion: remove symfony/console v4.0.2
- Conclusion: don't install symfony/console v4.0.2
- rector/rector v0.1.0 requires symfony/console ^3.3 -> satisfiable by symfony/console[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2].
- Can only install one of: symfony/console[v3.3.0, v4.0.2].
- Can only install one of: symfony/console[v3.3.1, v4.0.2].
- Can only install one of: symfony/console[v3.3.10, v4.0.2].
- Can only install one of: symfony/console[v3.3.11, v4.0.2].
- Can only install one of: symfony/console[v3.3.12, v4.0.2].
- Can only install one of: symfony/console[v3.3.13, v4.0.2].
- Can only install one of: symfony/console[v3.3.14, v4.0.2].
- Can only install one of: symfony/console[v3.3.2, v4.0.2].
- Can only install one of: symfony/console[v3.3.3, v4.0.2].
- Can only install one of: symfony/console[v3.3.4, v4.0.2].
- Can only install one of: symfony/console[v3.3.5, v4.0.2].
- Can only install one of: symfony/console[v3.3.6, v4.0.2].
- Can only install one of: symfony/console[v3.3.7, v4.0.2].
- Can only install one of: symfony/console[v3.3.8, v4.0.2].
- Can only install one of: symfony/console[v3.3.9, v4.0.2].
- Can only install one of: symfony/console[v3.4.0, v4.0.2].
- Can only install one of: symfony/console[v3.4.1, v4.0.2].
- Can only install one of: symfony/console[v3.4.2, v4.0.2].
- Installation request for symfony/console (locked at v4.0.2) -> satisfiable by symfony/console[v4.0.2].
Didn't try with composer create-project * yet.
Try dev-master instead of @dev.
I'm looks like it takes all branches, not just master
If that don't help, this looks like the case for composer create-project *, when dependencies are in conflict. That's the best case for most projects.
Just install once and runy as muc as you need :)
Ok, gonna tried in a bit and I update you, thanks!
@TomasVotruba Failed again. I've ran:
composer create-project rector/rector:@dev rector-run
inside my /var/www folder, and when I run
/var/www/rector-run/bin/rector process tests --level phpunit60
inside my cphalcon project and I get this error:
PHP Warning: require(/var/www/rector-run/vendor/composer/../symfony/polyfill-intl-icu/bootstrap.php): failed to open stream: No such file or directory in /var/www/rector-run/vendor/composer/autoload_real.php on line 66
PHP Fatal error: require(): Failed opening required '/var/www/rector-run/vendor/composer/../symfony/polyfill-intl-icu/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/rector-run/vendor/composer/autoload_real.php on line 66
I'm going to try with another framework/package an let you know :cry:
@TomasVotruba Another one: Laravel Framework. Steps to reproduce:
I forked and checkout the 5.5 branch.
I installed Rector with composer required (it worked), and I ran:
vendor/bin/rector process tests --level phpunit-specific-method
And nothing got changed. There are many is_dir, is_* that didn't get affected.
I guess our problem isn't related to the install process, but with refactoring :sob:
When I ran:
vendor/bin/rector process tests --level phpunit-specific-method
Nothing has changed. But, if I specify a subfolder:
vendor/bin/rector process tests/Filesystem --level phpunit-specific-method
The tests/Filesystem/FilesystemTest.php gets all is_dir changed :tada:
Another example:
vendor/bin/rector process tests/Database --level phpunit-specific-method
The tests/Database/DatabaseConnectionTest.php gets all is_numeric changed as well :pray:
I'm searching how we can fix it :santa:
After short Christmass break I'm back :+1: I'll try to simulate your scenario and try it out
I tried:
git clone [email protected]:TomasVotruba/framework.git
cd framework
git checkout master
composer install
composer require --dev rector/rector @dev nikic/php-parser '4.0.x-dev'
composer show rector/rector
> source : [git] https://github.com/rectorphp/rector.git bb01b218cc83de2c7833668cb08e21cc590e9428
vendor/bin/rector process tests --level phpunit-specific-method
With error on invalid DocBlock:
"\Illuminate\Contracts\Session\Session." is not a valid Fqsen
I'll look on this error. But I could not simulate success pass with missed items like you describe.
This Is my output, so you can compare with yours:
5 Loaded Rectors
================
- Rector\Rector\Contrib\PHPUnit\SpecificMethod\AssertCompareToSpecificMethodRector
- Rector\Rector\Contrib\PHPUnit\SpecificMethod\AssertSameBoolNullToSpecificMethodRector
- Rector\Rector\Contrib\PHPUnit\SpecificMethod\AssertTrueFalseInternalTypeToSpecificMethodRector
- Rector\Rector\Contrib\PHPUnit\SpecificMethod\AssertTrueFalseToSpecificMethodRector
- Rector\Rector\Contrib\PHPUnit\SpecificMethod\AssertTrueIssetToObjectHasAttributeRector
Processing files
================
In Fqsen.php line 48:
[InvalidArgumentException]
"\Illuminate\Contracts\Session\Session." is not a valid Fqsen.
Exception trace:
phpDocumentor\Reflection\Fqsen->__construct() at /var/www/framework/vendor/phpdocumentor/type-resolver/src/FqsenResolver.php:29
phpDocumentor\Reflection\FqsenResolver->resolve() at /var/www/framework/vendor/phpdocumentor/type-resolver/src/TypeResolver.php:264
phpDocumentor\Reflection\TypeResolver->resolveTypedObject() at /var/www/framework/vendor/phpdocumentor/type-resolver/src/TypeResolver.php:116
phpDocumentor\Reflection\TypeResolver->resolve() at /var/www/framework/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Return_.php:52
phpDocumentor\Reflection\DocBlock\Tags\Return_::create() at n/a:n/a
call_user_func_array() at /var/www/framework/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php:201
phpDocumentor\Reflection\DocBlock\StandardTagFactory->createTag() at /var/www/framework/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php:122
phpDocumentor\Reflection\DocBlock\StandardTagFactory->create() at /var/www/framework/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php:231
phpDocumentor\Reflection\DocBlockFactory->parseTagBlock() at /var/www/framework/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php:96
phpDocumentor\Reflection\DocBlockFactory->create() at /var/www/framework/vendor/rector/better-reflection/src/TypesFinder/FindReturnType.php:54
Rector\BetterReflection\TypesFinder\FindReturnType->__invoke() at /var/www/framework/vendor/rector/better-reflection/src/Reflection/ReflectionFunctionAbstract.php:435
Rector\BetterReflection\Reflection\ReflectionFunctionAbstract->getDocBlockReturnTypes() at /var/www/framework/vendor/rector/rector/packages/BetterReflection/src/Reflector/MethodReflector.php:55
Rector\BetterReflection\Reflector\MethodReflector->getMethodReturnTypes() at /var/www/framework/vendor/rector/rector/packages/NodeTypeResolver/src/PerNodeTypeResolver/MethodCallTypeResolver.php:111
Rector\NodeTypeResolver\PerNodeTypeResolver\MethodCallTypeResolver->resolveMethodReflectionReturnTypes() at /var/www/framework/vendor/rector/rector/packages/NodeTypeResolver/src/PerNodeTypeResolver/MethodCallTypeResolver.php:69
Rector\NodeTypeResolver\PerNodeTypeResolver\MethodCallTypeResolver->resolve() at /var/www/framework/vendor/rector/rector/packages/NodeTypeResolver/src/NodeTypeResolver.php:36
Rector\NodeTypeResolver\NodeTypeResolver->resolve() at /var/www/framework/vendor/rector/rector/packages/NodeTypeResolver/src/NodeVisitor/TypeNodeVisitor.php:52
Rector\NodeTypeResolver\NodeVisitor\TypeNodeVisitor->enterNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:115
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:133
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:133
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:133
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:197
PhpParser\NodeTraverser->traverseArray() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:108
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:197
PhpParser\NodeTraverser->traverseArray() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:108
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:197
PhpParser\NodeTraverser->traverseArray() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:108
PhpParser\NodeTraverser->traverseNode() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:197
PhpParser\NodeTraverser->traverseArray() at /var/www/framework/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:85
PhpParser\NodeTraverser->traverse() at /var/www/framework/vendor/rector/rector/src/NodeTraverser/StandaloneTraverseNodeTraverser.php:49
Rector\NodeTraverser\StandaloneTraverseNodeTraverser->traverse() at /var/www/framework/vendor/rector/rector/packages/NodeTraverserQueue/src/NodeTraverserQueue.php:74
Rector\NodeTraverserQueue\NodeTraverserQueue->processFileInfo() at /var/www/framework/vendor/rector/rector/src/Application/FileProcessor.php:49
Rector\Application\FileProcessor->processFile() at /var/www/framework/vendor/rector/rector/src/Console/Command/ProcessCommand.php:153
Rector\Console\Command\ProcessCommand->processFiles() at /var/www/framework/vendor/rector/rector/src/Console/Command/ProcessCommand.php:116
Rector\Console\Command\ProcessCommand->execute() at /var/www/framework/vendor/symfony/console/Command/Command.php:252
Symfony\Component\Console\Command\Command->run() at /var/www/framework/vendor/symfony/console/Application.php:855
Symfony\Component\Console\Application->doRunCommand() at /var/www/framework/vendor/symfony/console/Application.php:233
Symfony\Component\Console\Application->doRun() at /var/www/framework/vendor/symfony/console/Application.php:143
Symfony\Component\Console\Application->run() at /var/www/framework/vendor/rector/rector/bin/rector.php:37
require_once() at /var/www/framework/vendor/rector/rector/bin/rector:4
process [--dry-run] [--] <source> (<source>)...
I used you tip to install: dev-master, not @dev
Did it help to install the most recent version? That is the goal.
This Is my output, so you can compare with yours:
Awesome! Always check and show the exception error message. That's usually the most important information to find the responsible part
So it isn't working because of subfolder, but because of this Exception Error? :sweat_smile:
Until the exception get resolved, it probably won't work.
If you get different exception, please create new issue to make it clear
@TomasVotruba I opened a PR in laravel/framework to fix it. Was a missed typo.
- * @return \Illuminate\Contracts\Session\Session.
+ * @return \Illuminate\Contracts\Session\Session
The PR on laravel/framework was merged. I'm going to rebase my fork and try again. I update if anything crashes.
Thanks for the PR to Laravel!
I've added support to skip there mallformed annotations, instead of crashing on exception. There are many cases with invalid annotation, but that should not stop Rector from it's work. E.g. here the annotation is completely unrelated to PHPUnit rectors.
I open an issue in Symplify. I face it using it with Laravel, Doctrine, etc.
One more bug discovered:
In ProcessCommand.php line 172:
[Rector\Exception\Command\FileProcessingException]
Processing of "tests//Database/DatabaseEloquentBuilderTest.php" file failed.
In AssertCompareToSpecificMethodRector.php line 89:
[Error]
Call to undefined method PhpParser\Node\Expr\ArrayDimFetch::toString()
@TomasVotruba I'll try to fix it.
Closing as there are so many various issues far from the original one.
The install one is covered in #258