| 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".
Please see working POC repository here: https://github.com/ruudk/rector-carbon-bug
Not crash.
I just found an issue posted on the BetterReflection repo https://github.com/Roave/BetterReflection/issues/689
Hi,
could you share a link to this Localization trait 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
Ah yes, that's what I remember. So we basically patch that part to be removed on composer install.
Then I think it would be better to submit a PR to Carbon to get that stuff removed.
Also a way. Depends how fast you need it
Hi,
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:
any update on this?
This is the best solution so far, untill it gets fixed in carbon
https://github.com/rectorphp/rector/issues/4406#issuecomment-708506993
Is Carbon willing to apply a fix? I don't see an open issue on their side.
I didn't open an issue because I saw they were working on a new major that will prob fix this. But I'm not sure. Maybe good to open the issue anyway?
Might be a good idea to get it on their radar and see if it is something they are willing to even fix.
@u01jmg3 Go ahead :)
Same problem here.. All Laravel project have this problem
This appears to be fixed on Rector dev-master@8a64821
@HDVinnie thank you for verify. I am closing it.
Most helpful comment
Same problem here.. All Laravel project have this problem