PHP code example of wernerkrauss / silverstripe-rector
1. Go to this page and download the library: Download wernerkrauss/silverstripe-rector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wernerkrauss / silverstripe-rector example snippets
declare(strict_types=1);
use Netwerkstatt\SilverstripeRector\Rector\Injector\UseCreateRector;
use Netwerkstatt\SilverstripeRector\Rector\Misc\AddConfigPropertiesRector
use Netwerkstatt\SilverstripeRector\Set\SilverstripeSetList;
use Netwerkstatt\SilverstripeRector\Set\SilverstripeLevelSetList;
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->paths([
__DIR__ . '/app/_config.php',
__DIR__ . '/app/src',
]);
$rectorConfig->autoloadPaths([
//composer autoload is already loaded
]);
//add needed files from modules, that don't support composer autoload yet
$rectorConfig->bootstrapFiles([
__DIR__ . '/vendor/path/to/code/Foobar.php'
]);
// // register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
// // define sets of rules
$rectorConfig->sets([
//rector lists
LevelSetList::UP_TO_PHP_74,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
//silverstripe rector
SilverstripeSetList::CODE_STYLE,
SilverstripeLevelSetList::UP_TO_SS_4_13
]);
//add @config properites to configurations for phpstan
//configure your own configs
$rectorConfig->ruleWithConfiguration(
AddConfigPropertiesRector::class,
[
MyClass::class => [
'my_config',
'another_config'
]
]
);
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.