From 28ca1b87e4ad6b212684f31b6e5f015d5fd1c482 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Fri, 6 Jan 2023 18:25:28 -0800 Subject: [PATCH] Add PHPStan --- .github/phpstan.yml | 20 ++++++++++ composer.json | 3 ++ composer.lock | 78 +++++++++++++++++++++++++++++++++----- phpstan.neon | 7 ++++ src/AntCMS/AntCMS.php | 2 +- src/AntCMS/AntMarkdown.php | 1 - src/index.php | 2 +- 7 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 .github/phpstan.yml create mode 100644 phpstan.neon diff --git a/.github/phpstan.yml b/.github/phpstan.yml new file mode 100644 index 0000000..1b01b6c --- /dev/null +++ b/.github/phpstan.yml @@ -0,0 +1,20 @@ +name: PHPStan + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: php-actions/composer@v6 + - uses: php-actions/phpstan@v3 + with: + configuration: phpstan.neon + memory_limit: 256M + diff --git a/composer.json b/composer.json index c8e2227..faa793a 100644 --- a/composer.json +++ b/composer.json @@ -16,5 +16,8 @@ ], "config": { "vendor-dir": "src/Vendor" + }, + "require-dev": { + "phpstan/phpstan": "^1.9" } } diff --git a/composer.lock b/composer.lock index bf2599b..0610ad5 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "9fa90e5bf5828bb52c3654d04fd7383d", + "content-hash": "067bc4256a432b52ef1ab88b7708353e", "packages": [ { "name": "michelf/php-markdown", @@ -146,20 +146,20 @@ }, { "name": "symfony/yaml", - "version": "v6.2.2", + "version": "v6.0.17", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3" + "reference": "76c08913ea1c50541503a4563b2172710189fa29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3", - "reference": "6ed8243aa5f2cb5a57009f826b5e7fb3c4200cf3", + "url": "https://api.github.com/repos/symfony/yaml/zipball/76c08913ea1c50541503a4563b2172710189fa29", + "reference": "76c08913ea1c50541503a4563b2172710189fa29", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.0.2", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -200,7 +200,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.2.2" + "source": "https://github.com/symfony/yaml/tree/v6.0.17" }, "funding": [ { @@ -216,10 +216,70 @@ "type": "tidelift" } ], - "time": "2022-12-14T16:11:27+00:00" + "time": "2022-12-14T15:52:41+00:00" + } + ], + "packages-dev": [ + { + "name": "phpstan/phpstan", + "version": "1.9.7", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "0501435cd342eac7664bd62155b1ef907fc60b6f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0501435cd342eac7664bd62155b1ef907fc60b6f", + "reference": "0501435cd342eac7664bd62155b1ef907fc60b6f", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.9.7" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-01-04T21:59:57+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2298851 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,7 @@ +parameters: + level: 5 + paths: + - src + excludePaths: + analyse: + - src/Vendor diff --git a/src/AntCMS/AntCMS.php b/src/AntCMS/AntCMS.php index 0fbfb92..51c2a35 100644 --- a/src/AntCMS/AntCMS.php +++ b/src/AntCMS/AntCMS.php @@ -120,7 +120,7 @@ class AntCMS $pageHeaders['author'] = trim($matches[1] ?? 'AntCMS'); preg_match('/Description: (.*)/', $header, $matches); - $pageHeaders['description'] = trim($matches[1]) ?? 'AntCMS'; + $pageHeaders['description'] = trim($matches[1] ?? 'AntCMS'); preg_match('/Keywords: (.*)/', $header, $matches); $pageHeaders['keywords'] = trim($matches[1] ?? $AntKeywords->generateKeywords($pageContent)); diff --git a/src/AntCMS/AntMarkdown.php b/src/AntCMS/AntMarkdown.php index 19ca983..c40cb72 100644 --- a/src/AntCMS/AntMarkdown.php +++ b/src/AntCMS/AntMarkdown.php @@ -42,7 +42,6 @@ class AntMarkdown ':flushed:' => '😳', ':frowning:' => '😦', ':anguished:' => '😧', - ':fearful:' => '😨', ':weary:' => '😩', ':exploding_head:' => '🤯', ':grimacing:' => '😬', diff --git a/src/index.php b/src/index.php index 46e7441..0780ec4 100644 --- a/src/index.php +++ b/src/index.php @@ -1,7 +1,7 @@