Anyone here using https://getrector.com to do code updates, for things like PHP8 compatibility?
I’ve known about this project, but have never used it, and just wondering if anyone has any tips when using it with Concrete specifically.
Anyone here using https://getrector.com to do code updates, for things like PHP8 compatibility?
I’ve known about this project, but have never used it, and just wondering if anyone has any tips when using it with Concrete specifically.
I used grok.com with great efficiency to do so. It’s much more efficient in coding than the current ChatGPT.
I have used various AIs. In most cases useful for general php, pretty good for JS, CSS and SQL, but they have all hallucinated wildly when asked to do something specific using a Concrete CMS interface.
I suspect there just isn’t enough Concrete specific code out there in the AI training data, and what is out there can be old 5.6 code which the AI doesn’t differentiate.
Totally agree, you have to be very specific with the request or link or paste example code to get things done.
It’s too easy to fall into a rabbithole of misunderstanding if the requests are too broad.
But things like → php8 compatibility are pretty easy with those AIs. I suspect the better the documentation grows, the better the interaction will be.
I’va actually caught ChatGPT producing Typos in the code - so it also has some human characteristics
I have a comparison engine written in php for logic in Form Reform pipelines. A few hundred lines of php.
My most successful AI use was to get copilot to create a version in JavaScript for a front end version of the comparison engine. I only needed a few minor edits to wrap it up and slot it into my script file. So for translation it was a massive success that saved me days.
At the other extreme, asking it to do something with Concrete permissions ended up with a iterating mess of invented interfaces that sounded plausible, but didn’t exist and just got worse as I went along. It wasted a lot of time and had to go back and do the usual archaeology on the core.
What I really hate right now is the new sycophant personality. It ends everything with “Given your expertise in XXX, you should have no trouble implementing YYY”.
I’m using AI for lazy things, like little functions or loops where I know it’ll be quicker to explain it to AI and then review what it spits out, instead of writing the code directly.
I’ve also seen some cool things with integration, using IDEs like PHPStorm, where if you give it permission it can directly change your code - I just haven’t really dug into using things that way though,
But Rector isn’t AI I believe, it’s more a tool to review code and automatically apply changes to handle PHP version issues. Doing a ‘dry run’ with it supposedly just shows you what issues are potentially there, on I think any side codebase. So I was just curious if anyone else had tried it specifically.
A diving friend has been using php stan and rector to update legacy Laravel coderbases. He has been touring the conferences presenting his methods.
I’ve actually got a huge Laravel app that I’ll be upgrading later this year.
(my code, but written, errr… 9 years ago!)
So I’m very interested in that, thanks John.
Dave is in Bristol, also heavily involved in the PHP SW user group.
Not being as versed in the depth of PHP as most of you, I started using Perplexity.ai to mess around building simple blocks. It used to do OK IF I reminded it to create ALL the required php files. It was amusing but not very productive really. All it is is a glorified cut 'n paste but it’s getting worse instead of better. This is a very predictable path as each model participates in an ‘arms race’ and they consume less and less accurate sources of info including their own public hallucinations that are now part of the training data. The loudest person in the room isn’t always correct and so AI models often confuse quantity with quality and give equal weight to ‘fine people on both sides’ leading to DE-generative AI as time goes on.
We have been using Rector in our theme packages, with a pretty simple config:
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\ValueObject\PhpVersion;
return RectorConfig::configure()
->withSkip([
\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrEndsWithRector::class,
\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrStartsWithRector::class,
\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class,
\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class,
])
->withPaths([
__DIR__ . '/src',
__DIR__ . '/themes',
__DIR__ . '/controller.php',
])
// uncomment to reach your current PHP version
->withPhpVersion(PhpVersion::PHP_74)
->withSets([
LevelSetList::UP_TO_PHP_74,
DowngradeLevelSetList::DOWN_TO_PHP_74,
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,
SetList::STRICT_BOOLEANS,
SetList::CODING_STYLE,
]);