-
-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rector prefixed 0.8.56: Class 'Rector\Core\Console\Style\SymfonyStyleFactory' not found #4736
Comments
I've seen @michaljusiega comment in #4606 but I feel like this is a separate issue not related to PHPStan. I came across that comment by luck and feel that a separate ticket will be easier to find and track for others so they know when it's fixed. |
No, is not related to PHPStan issue. |
duplicates #4725 |
It doesn't duplicates #4725 as I have it installed as a normal Composer dependency, not a global one. |
Sorry „duplicates“ was the wrong wording. It seems to be the same error though :) |
Hello, Did there is any workaround to use rector to upgrade a symfony 2.8 project ? |
@TomasVotruba could you help us with this issue? |
A suggested workaround : use the previous version 0.8.52 wich is based on a phar. If you current environment contains version 0.8.56, first of all remove it : Then install the previous version : Note : the command init does not work in this version. You will have to copy the rector.php.dist by hand in your main directory. |
Resolved by #4559 |
Still seeing this problem on 0.9.5 |
We'll need a reproducible repository to verify |
@TomasVotruba , I have the same error, also if I use Bamarni composer bin plugin. But my repo is public: https://github.com/Aerendir/component-array-writer It is only one class, so is perfect for debugging... I'm trying to solve the issue, but I have no idea where to start... Maybe you can having more experience with the issue that seems already happened... To reproduce
|
Ok, the first problem seems to be in /**
* In case Rector is installed as vendor dependency,
* this autoloads the project vendor/autoload.php, including Rector
*/
public function autoloadProjectAutoloaderFile(): void
{
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../../autoload.php');
+ $this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../../../../vendor/autoload.php');
} As I'm using Bamarni Bin Composer plugin, the hard coded path is not correct as Rector is actually installed in For this reason we need to go some levels up in the tree. Adding the change proposed, the error changes to: PHP Fatal error: Uncaught TypeError: Symplify\PackageBuilder\Reflection\PrivatesCaller::callPrivateMethod(): Argument #3 ($arguments) must be of type array, Symfony\Component\Console\Input\ArgvInput given, called in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/src/Console/Style/SymfonyStyleFactory.php on line 32 and defined in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php:20
Stack trace:
#0 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/src/Console/Style/SymfonyStyleFactory.php(32): Symplify\PackageBuilder\Reflection\PrivatesCaller->callPrivateMethod(Object(Symfony\Component\Console\Application), 'configureIO', Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector.php(39): Rector\Core\Console\Style\SymfonyStyleFactory->create()
#2 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector(4): require_once('/Users/Aerendir...')
#3 {main}
thrown in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php on line 20
Fatal error: Uncaught TypeError: Symplify\PackageBuilder\Reflection\PrivatesCaller::callPrivateMethod(): Argument #3 ($arguments) must be of type array, Symfony\Component\Console\Input\ArgvInput given, called in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/src/Console/Style/SymfonyStyleFactory.php on line 32 and defined in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php:20
Stack trace:
#0 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/src/Console/Style/SymfonyStyleFactory.php(32): Symplify\PackageBuilder\Reflection\PrivatesCaller->callPrivateMethod(Object(Symfony\Component\Console\Application), 'configureIO', Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector.php(39): Rector\Core\Console\Style\SymfonyStyleFactory->create()
#2 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector(4): require_once('/Users/Aerendir...')
#3 {main}
thrown in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php on line 20 |
it seems the mentioned fix is the same as the one I suggested in #4726 |
@staabm , similar, not the same: your attempt was to support global install; mine supports installation through Bamarni Composer Bin, that is anyway at project level... |
@TomasVotruba , the problem seems to be in Symplify. I changed this: /**
* @param object|string $object
* @param mixed[] $arguments
*/
- public function callPrivateMethod($object, string $methodName, array $arguments)
+ public function callPrivateMethod($object, string $methodName, $arguments)
{
$this->ensureIsNotNull($object, __METHOD__);
if (is_string($object)) {
$reflectionClass = new ReflectionClass($object);
$object = $reflectionClass->newInstanceWithoutConstructor();
}
$methodReflection = $this->createAccessibleMethodReflection($object, $methodName);
+ if ($arguments instanceof ArgvInput) {
+ $arguments = $arguments->getArguments();
+ }
return $methodReflection->invokeArgs($object, $arguments);
} But now I have other errors: Aerendir@Archimede component-array-writer % vendor/bin/rector process --dry-run
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Symfony\Component\Console\Application::configureIO(), 0 passed and exactly 2 expected in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symfony/console/Application.php:880
Stack trace:
#0 [internal function]: Symfony\Component\Console\Application->configureIO()
#1 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php(36): ReflectionMethod->invokeArgs(Object(Symfony\Component\Console\Application), Array)
#2 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/src/Console/Style/SymfonyStyleFactory.php(32): Symplify\PackageBuilder\Reflection\PrivatesCaller->callPrivateMethod(Object(Symfony\Component\Console\Application), 'configureIO', Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector.php(39): Rector\Core\Console\Style\SymfonyStyleFactory->create()
#4 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector(4): require_once('/Users/Aerendir...')
#5 {main}
thrown in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symfony/console/Application.php on line 880
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Symfony\Component\Console\Application::configureIO(), 0 passed and exactly 2 expected in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symfony/console/Application.php:880
Stack trace:
#0 [internal function]: Symfony\Component\Console\Application->configureIO()
#1 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php(36): ReflectionMethod->invokeArgs(Object(Symfony\Component\Console\Application), Array)
#2 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/src/Console/Style/SymfonyStyleFactory.php(32): Symplify\PackageBuilder\Reflection\PrivatesCaller->callPrivateMethod(Object(Symfony\Component\Console\Application), 'configureIO', Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector.php(39): Rector\Core\Console\Style\SymfonyStyleFactory->create()
#4 /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/rector/rector/bin/rector(4): require_once('/Users/Aerendir...')
#5 {main}
thrown in /Users/Aerendir/Documents/JooServer/Lab/Components/component-array-writer/vendor-bin/phpstan/vendor/symfony/console/Application.php on line 880 The problem seems to be deeper than what it appeared at a first sight. |
Neither barmani or global installation is supported. If paths will be resolved, the different Now prefixed version is way to go here. |
Ok, so Phive to the rescue! |
Also if this makes really complex to stay up to date as Dependabot doesn't support Phive I think 🤔 |
Phive is packaged phar, that's what we droppped in 0.9 - Why? See https://getrector.org/blog/2020/12/28/rector-09-released#debuggable-rector-prefixed This is prefixed Rector now: https://github.com/rectorphp/rector-prefixed We go for the future of downgraded and prefixed version. Thank's to that Rector will be able to run on PHP 5.6 in composer and without Docker. |
rectorphp/rector-src@ed7426f [Logging] Add RectorOutput logging service (#4736)
Bug Report
While trying to run a Rector with
vendor/bin/rector
there's an error happening:Minimal PHP Code Causing Issue
Expected Behaviour
Rector running properly.
The text was updated successfully, but these errors were encountered: