<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarai.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup</link><pubDate>Wed, 10 Sep 2025 18:08:36 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Current Revision posted to Dev Tutorials by Rafael Fernandes on 9/10/2025 6:08:36 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using&amp;nbsp;Sugar &amp;gt;= 25.1&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You must use Rector that is shipped with Sugar and located at vendor lib in your Sugar Instance folder. ex:&amp;nbsp;&lt;code&gt;&lt;span&gt;/path/to/sugar/&lt;/span&gt;&lt;span&gt;vendor/rector/rector/bin/rector&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;You might need to give +x permissions to execute rector.
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;chmod +x&amp;nbsp;&lt;span&gt;/path/to/sugar&lt;/span&gt;/vendor/rector/rector/bin/rector&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You may still&amp;nbsp;use newer Rector version for your convenience, just make sure you use composer in a different directory (see below) to avoid incompatibilities.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using Sugar &amp;lt; 25&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;You should leverage composer to install rector and its dependencies.&lt;/li&gt;
&lt;li&gt;It is important that you&amp;nbsp;&lt;strong&gt;DO NOT&lt;/strong&gt; install it in the Sugar&amp;#39;s directory, if you do you will get errors due to libraries incompatibilities, see &lt;a href="/dev-club/w/dev-tutorials/835/troubleshooting-rector"&gt;Troubleshooting Rector&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You can use the following commands to prepare rector to be used.&lt;/li&gt;
&lt;li&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;# install composer if you dont have it
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

# create a temp rector folder
mkdir /tmp/rector
cd /tmp/rector

# let composer decide which version works on your system
composer require rector/rector --dev

# or specify a specific version (if you need to)
composer require rector/rector:^1.2.3 --dev
&lt;/pre&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using rector 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;rector-0.15.20/bin/rector init&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using newer versions of Rector, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;/path/to/rector/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes

 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a &lt;code&gt;rector.php&lt;/code&gt; file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
    -&amp;gt;withPaths([
        __DIR__ . &amp;#39;/src&amp;#39;,
    ])
    // uncomment to reach your current PHP version
    // -&amp;gt;withPhpSets()
    -&amp;gt;withTypeCoverageLevel(0)
    -&amp;gt;withDeadCodeLevel(0)
    -&amp;gt;withCodeQualityLevel(0);&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/21</link><pubDate>Wed, 10 Sep 2025 18:06:28 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 21 posted to Dev Tutorials by Rafael Fernandes on 9/10/2025 6:06:28 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using&amp;nbsp;Sugar &amp;gt;= 25.1&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You must use Rector that is shipped with Sugar and located at vendor lib in your Sugar Instance folder. ex:&amp;nbsp;&lt;code&gt;&lt;span&gt;/path/to/sugar/&lt;/span&gt;&lt;span&gt;vendor/rector/rector/bin/rector&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;You might need to give +x permissions to execute rector.
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;chmod +x&amp;nbsp;&lt;span&gt;/path/to/sugar&lt;/span&gt;/vendor/rector/rector/bin/rector&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You may still download newer versions of Rector from its &lt;a href="https://github.com/rectorphp/rector/releases"&gt;release repository&lt;/a&gt;, however, you&amp;#39;d need to follow their &lt;a href="https://github.com/rectorphp/rector?tab=readme-ov-file#install"&gt;installation instructions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using Sugar &amp;lt; 25&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;You should leverage composer to install rector and its dependencies.&lt;/li&gt;
&lt;li&gt;It is important that you&amp;nbsp;&lt;strong&gt;DO NOT&lt;/strong&gt; install it in the Sugar&amp;#39;s directory, if you do you will get errors due to libraries incompatibilities, see &lt;a href="/dev-club/w/dev-tutorials/835/troubleshooting-rector"&gt;Troubleshooting Rector&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You can use the following commands to prepare rector to be used.&lt;/li&gt;
&lt;li&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;# install composer if you dont have it
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

# create a temp rector folder
mkdir /tmp/rector
cd /tmp/rector

# let composer decide which version works on your system
composer require rector/rector --dev

# or specify a specific version (if you need to)
composer require rector/rector:^1.2.3 --dev
&lt;/pre&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using rector 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;rector-0.15.20/bin/rector init&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using newer versions of Rector, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;/path/to/rector/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a &lt;code&gt;rector.php&lt;/code&gt; file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
    -&amp;gt;withPaths([
        __DIR__ . &amp;#39;/src&amp;#39;,
    ])
    // uncomment to reach your current PHP version
    // -&amp;gt;withPhpSets()
    -&amp;gt;withTypeCoverageLevel(0)
    -&amp;gt;withDeadCodeLevel(0)
    -&amp;gt;withCodeQualityLevel(0);&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/20</link><pubDate>Mon, 17 Mar 2025 12:51:24 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 20 posted to Dev Tutorials by Rafael Fernandes on 3/17/2025 12:51:24 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using&amp;nbsp;Sugar &amp;gt;= 25.1&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You must use Rector that is shipped with Sugar and located at vendor lib in your Sugar Instance folder. ex:&amp;nbsp;&lt;code&gt;&lt;span&gt;/path/to/sugar/&lt;/span&gt;&lt;span&gt;vendor/rector/rector/bin/rector&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;You might need to give +x permissions to execute rector.
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;chmod +x&amp;nbsp;&lt;span&gt;/path/to/sugar&lt;/span&gt;/vendor/rector/rector/bin/rector&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You may still download newer versions of Rector from its &lt;a href="https://github.com/rectorphp/rector/releases"&gt;release repository&lt;/a&gt;, however, you&amp;#39;d need to follow their &lt;a href="https://github.com/rectorphp/rector?tab=readme-ov-file#install"&gt;installation instructions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using Sugar &amp;lt; 25&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases/tag/0.18.1"&gt;this rector release&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.18.1&lt;/code&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;Rector team might&amp;nbsp;add or remove classes that we utilize on our scans&lt;/li&gt;
&lt;li&gt;Latest we are using is 0.18.1, later than that might not work.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using rector 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;cd /path/to/sugar &amp;amp;&amp;amp; /path/to/rector/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a &lt;code&gt;rector.php&lt;/code&gt; file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/19</link><pubDate>Thu, 13 Mar 2025 19:20:26 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 19 posted to Dev Tutorials by Rafael Fernandes on 3/13/2025 7:20:26 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using PHP &amp;gt;= 8.3&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases/tag/1.2.3"&gt;this rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-1.2.3&lt;/code&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;Rector team might&amp;nbsp;add or remove classes that we utilize on our scans&lt;/li&gt;
&lt;li&gt;Latest we are using is &lt;code&gt;1.2.3&lt;/code&gt; for PHP 8.3, later than that might not work.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;If you are using PHP &amp;lt; 8.3&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases/tag/0.18.1"&gt;this rector release&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.18.1&lt;/code&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;Rector team might&amp;nbsp;add or remove classes that we utilize on our scans&lt;/li&gt;
&lt;li&gt;Latest we are using is 0.18.1, later than that might not work.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.18.1/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/18</link><pubDate>Thu, 26 Oct 2023 17:44:41 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 18 posted to Dev Tutorials by Rafael Fernandes on 10/26/2023 5:44:41 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases/tag/0.18.1"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.18.1&lt;/code&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;Rector team might&amp;nbsp;add or remove classes that we utilize on our scans&lt;/li&gt;
&lt;li&gt;Latest we are using is 0.18.1, later than that might not work.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.18.1/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/17</link><pubDate>Thu, 31 Aug 2023 15:10:32 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 17 posted to Dev Tutorials by Rafael Fernandes on 8/31/2023 3:10:32 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.18.1/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/16</link><pubDate>Thu, 31 Aug 2023 15:10:07 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 16 posted to Dev Tutorials by Rafael Fernandes on 8/31/2023 3:10:07 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.18.24/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/15</link><pubDate>Thu, 31 Aug 2023 15:09:15 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 15 posted to Dev Tutorials by Rafael Fernandes on 8/31/2023 3:09:15 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;vendor/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/14</link><pubDate>Thu, 31 Aug 2023 15:09:00 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 14 posted to Dev Tutorials by Rafael Fernandes on 8/31/2023 3:09:00 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;If you are using 0.15.x or less, you can use init.&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;vendor/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/13</link><pubDate>Thu, 31 Aug 2023 15:08:37 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 13 posted to Dev Tutorials by Rafael Fernandes on 8/31/2023 3:08:37 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1h96266pd0"&gt;&lt;span style="font-size:inherit;"&gt;Initialize Rector config (rector.php)&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;If you are using 0.15.x or less, you can use init.&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.15.x or less, you can use the following&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;If you are using 0.16.x or higher, you can use&lt;/span&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;vendor/bin/rector

 No &amp;quot;rector.php&amp;quot; config found. Should we generate it for you? [yes]:
 &amp;gt; yes


 [OK] The config is added now. Re-run command to make Rector do the work!
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/12</link><pubDate>Tue, 11 Jul 2023 19:41:12 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 12 posted to Dev Tutorials by Rafael Fernandes on 7/11/2023 7:41:12 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/11</link><pubDate>Tue, 20 Jun 2023 12:57:22 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 11 posted to Dev Tutorials by Rafael Fernandes on 6/20/2023 12:57:22 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/10</link><pubDate>Wed, 19 Apr 2023 19:42:26 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 10 posted to Dev Tutorials by Rafael Fernandes on 4/19/2023 7:42:26 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gudgk28f0"&gt;You can move on to the Prepare Phase:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/834/prepare-rector-for-mlp-addon"&gt;Prepare Rector for MLP/Addon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/dev-club/w/dev-tutorials/837/prepare-rector-for-customizations"&gt;Prepare Rector for Customizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/9</link><pubDate>Wed, 19 Apr 2023 14:29:22 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 9 posted to Dev Tutorials by Rafael Fernandes on 4/19/2023 2:29:22 PM&lt;br /&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/8</link><pubDate>Wed, 19 Apr 2023 14:29:05 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 8 posted to Dev Tutorials by Rafael Fernandes on 4/19/2023 2:29:05 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;&lt;/h2&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/7</link><pubDate>Tue, 18 Apr 2023 19:16:19 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 7 posted to Dev Tutorials by Rafael Fernandes on 4/18/2023 7:16:19 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;Basic Setup&lt;/h2&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/6</link><pubDate>Tue, 18 Apr 2023 19:15:57 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 6 posted to Dev Tutorials by Rafael Fernandes on 4/18/2023 7:15:57 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;Basic Setup&lt;/h2&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/xxxx.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/
Removing install/BusinessProcesses/data/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/5</link><pubDate>Tue, 18 Apr 2023 15:57:58 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 5 posted to Dev Tutorials by Rafael Fernandes on 4/18/2023 3:57:58 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;Basic Setup&lt;/h2&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init

sh-3.2$ git clean -fd
Removing custom/Extension/application/Ext/Include/xxxx.php
Removing custom/Extension/application/Ext/Include/orderMapping.php
Removing custom/modules/ActivityStream/
Removing custom/modules/Forecasts/Ext/clients/
Removing custom/modules/pmse_Project/
Removing install/BusinessProcesses/data/

sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/4</link><pubDate>Tue, 18 Apr 2023 15:51:32 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 4 posted to Dev Tutorials by Rafael Fernandes on 4/18/2023 3:51:32 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;Basic Setup&lt;/h2&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You might wanna keep your initial commit hash in case you need to reset&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Reset your Repo to start over&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;You can always start over at your initial Git commit and undo all changes by Rector or yourself after that point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Take the initial commit hash from git log and reset as follows:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sh-3.2$ git log
commit 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f (HEAD -&amp;gt; main)
Author: Rafael Fernandes &amp;lt;rafael.fernandes@sugarcrm.com&amp;gt;
Date:   Mon Apr 17 10:40:56 2023 -0400

sh-3.2$ git status
On branch main
Changes not staged for commit:
  (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)
  (use &amp;quot;git restore &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)
        modified:   vCard.php

no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)

sh-3.2$ git reset --hard 0ac2bd9c175f7bff9842dcd8179fc9ec67b7002f
HEAD is now at 0ac2bd9c init


sh-3.2$ git status
On branch main
nothing to commit, working tree clean&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/3</link><pubDate>Fri, 14 Apr 2023 14:01:34 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 3 posted to Dev Tutorials by Rafael Fernandes on 4/14/2023 2:01:34 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;Basic Setup&lt;/h2&gt;
&lt;p&gt;Refactoring your code required a very basic setup to make your life easier to track what Rector does to your code (if you use its auto-fix mode).&lt;/p&gt;
&lt;p&gt;Basic setup means installing software you will need such as Rector and Git. Git will help us to keep track of changes in your Sugar instance folder after we initialize it.&lt;/p&gt;
&lt;p&gt;Keep that info in mind if you are planing to use a pre-existing instance for this work, it will add a lot of extra files to it.&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Rector Basic Setup</title><link>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup/revision/2</link><pubDate>Thu, 13 Apr 2023 15:04:25 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:050075a8-3243-4b82-89be-e8ba4c5bdd17</guid><dc:creator>Rafael Fernandes</dc:creator><comments>https://sugarclub.sugarai.com/dev-club/w/dev-tutorials/828/rector-basic-setup#comments</comments><description>Revision 2 posted to Dev Tutorials by Rafael Fernandes on 4/13/2023 3:04:25 PM&lt;br /&gt;
&lt;h2 id="mcetoc_1gtthv2b41"&gt;Basic Setup&lt;/h2&gt;
&lt;p&gt;You will need a basic setup to have Rector working with Sugar. We will create files and initialize a git repo in the Sugar instance folder to keep track of the changes.&lt;/p&gt;
&lt;p&gt;If you are using a pre-existing instance, keep that in mind, we suggest creating a new instance for this purpose.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1gtthusvo0"&gt;Step by Step&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download a build of SugarCRM. Please use the one that is compatible with your MPL.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Install the build locally or use your own Sugar instance if you have one local&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Download the &lt;a class="css-tgpl01" title="https://github.com/rectorphp/rector/releases" href="https://github.com/rectorphp/rector/releases"&gt;latest rector release&lt;/a&gt; and unzip it into the Sugar instance folder. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/rector-0.15.20&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Rector needs &lt;code&gt;phpstan&lt;/code&gt; tool to run, for that create a new file in the Sugar instance folder called &lt;code&gt;stan.neon&lt;/code&gt;. ex:&amp;nbsp;&lt;code class="code css-z5oxh7"&gt;/path/to/sugar/stan.neon&lt;/code&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;parameters:
	level: 1
	bootstrapFiles:
		- include/entryPoint.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Initialize a git repository inside the instance folder: cd /path/to/sugar &amp;amp;&amp;amp; git init. It&amp;rsquo;s just convenient to use git to track the list of files and some other things.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Create /path/to/sugar/.gitignore file to skip the unneeded changes with the following contents:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;cache
vendor
portal2
upload
upgrades
*.log
rector.php
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size:inherit;"&gt;Commit the initial repository state&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;git add . &amp;amp;&amp;amp; git commit -am &amp;#39;init&amp;#39;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Initialize rector config:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cd /path/to/sugar &amp;amp;&amp;amp; rector-0.15.20/bin/rector init
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li class="code-block  css-1si5tit"&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Agree to create a rector.php file with the dummy config. It should generate a template file similar to this:&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig-&amp;gt;paths([
        __DIR__ . &amp;#39;/Ext&amp;#39;,
        //... more subdirs here
        __DIR__ . &amp;#39;/upgrades&amp;#39;,
    ]);

    // register a single rule
    $rectorConfig-&amp;gt;rule(InlineConstructorDefaultToPropertyRector::class);

    // define sets of rules
    //    $rectorConfig-&amp;gt;sets([
    //        LevelSetList::UP_TO_PHP_74
    //    ]);
};
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>