rector: Could not process file due to BetterReflection\ReflectionClass "Carbon\Traits\Localization" could not be found in the located source (with POC)
Bug Report
| Subject | Details |
|---|---|
| Rector version | Rector 0.8.23 |
| Installed as | rector/rector-prefixed |
Somehow Rector trips when using Carbon together with AUTO_IMPORT_NAMES.
$ vendor/bin/rector process src --dry-run
Rector 0.8.23
Config file: rector.php
4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1 file with changes
===================
1) src/Entity.php
---------- begin diff ----------
--- Original
+++ New
@@ -4,13 +4,11 @@
namespace MyNamespace;
-use Carbon\Carbon;
-
+use Carbon;
class Entity
{
private Carbon $createdAt;
-
- public function __construct()
+ public function __construct()
{
$this->createdAt = Carbon::now();
}
----------- end diff -----------
[ERROR] Could not process "src/Entity.php" file, due to:
"_HumbugBox2e5f015a1738\Roave\BetterReflection\Reflection\ReflectionClass "Carbon\Traits\Localization" could
not be found in the located source".
Minimal PHP Code Causing Issue
Please see working POC repository here: https://github.com/ruudk/rector-carbon-bug
Expected Behaviour
Not crash.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 16 (14 by maintainers)
Same problem here… All Laravel project have this problem
Hi,
could you share a link to this
Localizationtrait on Github?I think we had same problem in one project and in the end we patches this, as there is some hack with
*_exists()that is skipped by static reflection@HDVinnie thank you for verify. I am closing it.
This appears to be fixed on
Rector dev-master@8a64821Hi,
have stacked with this issue too in our projects and have fixed it in a bit another way.
So, my steps to fix it was: