-
-
Notifications
You must be signed in to change notification settings - Fork 699
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
[Parallel]: Class was not found while trying to analyse it #6903
[Parallel]: Class was not found while trying to analyse it #6903
Comments
yup I saw this over Christma several times - but not seen it since. Saw it in GitHub Actions too. It was inconsistent and did not occur on every run for me. |
Thanks for reporting. This might take some work to investigate. Could you create simple reproducible repository, so we can run it and track the bug in the future? The more narrow |
I was able to replicate immediately
edit rector - add
Also note in the file, is this the root cause? |
Without parallel, it works, so the issue is on the parallel process. |
If I strip that one file down to the following (note public property)
Then its fine, but change the property back to private and then it breaks consistently.
Even if I change the class name, public property works, private property causes issues. Hope that helps. |
The issue seems happen on |
It seems the issue goes to which in parallel, class may not found by |
Apply We still need to find a solution when |
I created PR to CodeIgniter4 repo for apply |
@TomasVotruba I created e2e tests for it at rectorphp/rector-src#1613 |
I think I'm having the same issue. I see this is closed but not sure if it has been released? I created a tiny repo to demonstrate the issue: https://github.com/MGatner/rector-error I kept the whole Rector file I use in "real" repos. If you run [ERROR] Could not process "src/MyException.php" file, due to:
"System error: "PHPStan\BetterReflection\Reflection\ReflectionClass "CodeIgniter\Exceptions\ExceptionInterface"
could not be found in the located source"
Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On
line: 26 Let me know if you would like this as a separate issue. |
@MGatner how about add |
@samsonasik I can try but it isn't an issue with locating classes generally - I added another class in the repo which works just fine. If you remove MyException.php then UPDATE: That caused an error until I removed the file from |
I can confirm that disabling |
@MGatner I can't reproduce it, it probably already resolved in latest PHPStan 1.4.0, could you try composer update and re-run with composer update
vendor/bin/rector process -vvv --clear-cache |
@samsonasik Still not resolved. I did have an outdated version of PHPStan: composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Upgrading phpstan/phpstan (1.3.3 => 1.4.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Upgrading phpstan/phpstan (1.3.3 => 1.4.0): Extracting archive
Package webmozart/path-util is abandoned, you should avoid using it. Use symfony/filesystem instead. Rector itself seems to be up-to-date: {
"name": "rector/rector",
"version": "0.12.12",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "efcc6f135a76bfd031c31fc182ce7a6fd02b3ce5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/efcc6f135a76bfd031c31fc182ce7a6fd02b3ce5",
"reference": "efcc6f135a76bfd031c31fc182ce7a6fd02b3ce5",
"shasum": ""
}, rector -V
Rector e33afe6434a9707374815bb977cff09b6e57c199 But when I clear cache and run I still have the class discovery error: $ rector process -vvv --clear-cache
[parsing] src/MyException.php
[parsing] src/MyOtherClass.php
[refactoring] src/MyOtherClass.php
[applying] Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector
[applying] Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector
[applying] Rector\Renaming\Rector\Name\RenameClassRector
[applying] Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector
[applying] Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParamInRequiredAutowireRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector
[applying] Rector\Php70\Rector\ClassMethod\Php4ConstructorRector
[applying] Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector
[applying] Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector
[applying] Rector\Renaming\Rector\MethodCall\RenameMethodRector
[applying] Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector
[applying] Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector
[applying] Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector
[applying] Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector
[applying] Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector
[applying] Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector
[applying] Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector
[applying] Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector
[applying] Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector
[applying] Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector
[applying] Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector
[applying] Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertNotOperatorRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertInstanceOfComparisonRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector
[applying] Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector
[applying] Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsRector
[applying] Rector\PHPUnit\Rector\MethodCall\SpecificAssertInternalTypeRector
[applying] Rector\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector
[applying] Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector
[applying] Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector
[applying] Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector
[post rectors] src/MyOtherClass.php
[post rector] Rector\PostRector\Rector\NodeToReplacePostRector
[post rector] Rector\PostRector\Rector\NodeAddingPostRector
[post rector] Rector\PostRector\Rector\PropertyAddingPostRector
[post rector] Ssch\TYPO3Rector\Rector\PostRector\FullQualifiedNamePostRector
[post rector] Rector\PostRector\Rector\NodeRemovingPostRector
[post rector] Rector\PostRector\Rector\ClassRenamingPostRector
[post rector] Rector\PostRector\Rector\NameImportingPostRector
[post rector] Rector\PostRector\Rector\UseAddingPostRector
[print] src/MyOtherClass.php
[ERROR] Could not process "src/MyException.php" file, due to:
"System error: "PHPStan\BetterReflection\Reflection\ReflectionClass "CodeIgniter\Exceptions\ExceptionInterface"
could not be found in the located source"
Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On
line: 26 Here's my PHP environment: PHP 7.4.10 (cli) (built: Sep 9 2020 06:36:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies |
After compose update today Im getting all kinds of class not found errors with and without Parallel.. |
@PhilETaylor Can you clone this repo, run the following, and share the result? https://github.com/MGatner/rector-error composer update
rector process -vv
php -v
|
|
How about these? which rector
rector -V
./vendor/bin/rector process -vv |
Haha, you & I on the same page 🤗 |
Composer jsons globally in rector-error |
Does your local version fail with verbosity? Mine actually just passed - global still fails despite being the same version: ubuntu:/opt/rector-error$ ./vendor/bin/rector -V
Rector e33afe6434a9707374815bb977cff09b6e57c199
ubuntu:/opt/rector-error$ rector -V
Rector e33afe6434a9707374815bb977cff09b6e57c199 |
Okay this is weird. My Rector and PHPStan versions are identical (same hash reference even) in local and global, but local succeeds while global fails. Something very fishy... ubuntu:/opt/rector-error$ ~/.config/composer/vendor/bin/rector process -vv --clear-cache
[parsing] src/MyException.php
[parsing] src/MyOtherClass.php
[refactoring] src/MyOtherClass.php
[post rectors] src/MyOtherClass.php
[post rector] Rector\PostRector\Rector\NodeToReplacePostRector
[post rector] Rector\PostRector\Rector\NodeAddingPostRector
[post rector] Rector\PostRector\Rector\PropertyAddingPostRector
[post rector] Ssch\TYPO3Rector\Rector\PostRector\FullQualifiedNamePostRector
[post rector] Rector\PostRector\Rector\NodeRemovingPostRector
[post rector] Rector\PostRector\Rector\ClassRenamingPostRector
[post rector] Rector\PostRector\Rector\NameImportingPostRector
[post rector] Rector\PostRector\Rector\UseAddingPostRector
[print] src/MyOtherClass.php
[ERROR] Could not process "src/MyException.php" file, due to:
"System error: "PHPStan\BetterReflection\Reflection\ReflectionClass "CodeIgniter\Exceptions\ExceptionInterface"
could not be found in the located source"
Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On
line: 26
ubuntu:/opt/rector-error$ ./vendor/bin/rector process -vv --clear-cache
[parsing] src/MyException.php
[refactoring] src/MyException.php
[post rectors] src/MyException.php
[post rector] Rector\PostRector\Rector\NodeToReplacePostRector
[post rector] Rector\PostRector\Rector\NodeAddingPostRector
[post rector] Rector\PostRector\Rector\PropertyAddingPostRector
[post rector] Ssch\TYPO3Rector\Rector\PostRector\FullQualifiedNamePostRector
[post rector] Rector\PostRector\Rector\NodeRemovingPostRector
[post rector] Rector\PostRector\Rector\ClassRenamingPostRector
[post rector] Rector\PostRector\Rector\NameImportingPostRector
[post rector] Rector\PostRector\Rector\UseAddingPostRector
[print] src/MyException.php
[parsing] src/MyOtherClass.php
[printing skipped due error] src/MyOtherClass.php
[OK] Rector is done!
|
Yeah we're finding the same thing. There is some issue using a global version of Rector even though the versions may not differ. |
@samsonasik Mentioned this to me on Slack, it must be the underlying issue - though I'm not actually sure of how to implement the fix:
|
but then |
Hmm good discovery! This still seems like a bug to me, that identical versions of the binary have differing behavior using the same config file just based on local/global. We'll see what the maintainers say, but in the meantime I will try adding the |
I agree, there is certainly a bug to be resolved, as it should work exactly the same regardless of where its invoked from. Glad I could help this far, but the ultimate fix is beyond me, Im not that close to the code of rector sorry. |
Please test PR rectorphp/rector-src#1683 |
Bug Report
Minimal PHP Code Causing Issue
When enable parallel option, it can got error:
Step to reproduce:
rector.php
, add option parall:tests
directory:Expected Behaviour
It should show
[OK] Rector is done!
without diff and error:vendor/bin/rector process tests 257/257 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% [OK] Rector is done!
The text was updated successfully, but these errors were encountered: