Quick run with Rector
This commit is contained in:
parent
36ab96bf8c
commit
325221f527
8 changed files with 93 additions and 9 deletions
|
@ -27,6 +27,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"rector/rector": "^0.15.4"
|
||||
}
|
||||
}
|
||||
|
|
58
composer.lock
generated
58
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "43edbcf416f751f14ae5ce7be4c414e8",
|
||||
"content-hash": "cc1e950196a545bb666399f2d1eab986",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dflydev/dot-access-data",
|
||||
|
@ -1828,6 +1828,62 @@
|
|||
],
|
||||
"time": "2022-12-09T07:31:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "0.15.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "1dcdf54ebf502d9f7cf9b5f89df613da1774d050"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/1dcdf54ebf502d9f7cf9b5f89df613da1774d050",
|
||||
"reference": "1dcdf54ebf502d9f7cf9b5f89df613da1774d050",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"phpstan/phpstan": "^1.9.7"
|
||||
},
|
||||
"conflict": {
|
||||
"rector/rector-doctrine": "*",
|
||||
"rector/rector-downgrade-php": "*",
|
||||
"rector/rector-php-parser": "*",
|
||||
"rector/rector-phpunit": "*",
|
||||
"rector/rector-symfony": "*"
|
||||
},
|
||||
"bin": [
|
||||
"bin/rector"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.14-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/0.15.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/tomasvotruba",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-10T11:09:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
"version": "1.0.1",
|
||||
|
|
27
rector.php
Normal file
27
rector.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
|
||||
use Rector\Php80\Rector\FunctionLike\UnionTypesRector;
|
||||
use Rector\Set\ValueObject\LevelSetList;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->paths([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests',
|
||||
]);
|
||||
$rectorConfig->skip([
|
||||
__DIR__ . '/src/Vendor',
|
||||
__DIR__ . '/src/Cache',
|
||||
UnionTypesRector::class,
|
||||
MixedTypeRector::class,
|
||||
]);
|
||||
|
||||
$rectorConfig->sets([
|
||||
SetList::PHP_80,
|
||||
]);
|
||||
};
|
|
@ -108,7 +108,7 @@ class AntCMS
|
|||
$pageContent = preg_replace('/\A--AntCMS--[^-]*--AntCMS--/sm', '', $pageContent);
|
||||
$result = ['content' => $pageContent, 'title' => $pageHeaders['title'], 'author' => $pageHeaders['author'], 'description' => $pageHeaders['description'], 'keywords' => $pageHeaders['keywords']];
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -140,7 +140,7 @@ class AntCMS
|
|||
} else {
|
||||
$template = file_get_contents(AntTools::repairFilePath($defaultTemplates . '/' . $layout . '.html.twig'));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception) {
|
||||
}
|
||||
|
||||
if (empty($template)) {
|
||||
|
|
|
@ -23,7 +23,7 @@ class AntCache
|
|||
try {
|
||||
file_put_contents($cachePath, (string)$content);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ class AntCache
|
|||
try {
|
||||
$contents = file_get_contents($cachePath);
|
||||
return $contents;
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,7 @@ class AntPluginLoader
|
|||
$files = AntTools::getFileList(antPluginPath, null, true);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (substr($file, -10) === "Plugin.php") {
|
||||
if (str_ends_with($file, "Plugin.php")) {
|
||||
include_once AntTools::repairFilePath($file);
|
||||
$className = pathinfo($file, PATHINFO_FILENAME);
|
||||
$plugins[] = new $className();
|
||||
|
|
|
@ -34,7 +34,7 @@ class AntYaml
|
|||
public static function parseYaml(string $yaml){
|
||||
try {
|
||||
return Yaml::parse($yaml);
|
||||
} catch (ParseException $exception) {
|
||||
} catch (ParseException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ class AdminPlugin extends AntPlugin
|
|||
$page = file_get_contents(antContentPath . '/' . $pagePath);
|
||||
} else {
|
||||
$pagePath = '/' . $_POST['newpage'];
|
||||
if (substr($pagePath, -3) !== ".md") {
|
||||
if (!str_ends_with($pagePath, ".md")) {
|
||||
$pagePath .= '.md';
|
||||
}
|
||||
$page = "--AntCMS--\nTitle: New Page Title\nAuthor: Author\nDescription: Description of this page.\nKeywords: Keywords\n--AntCMS--\n";
|
||||
|
|
Loading…
Reference in a new issue