From 7f4eae0abe9e675b1513018ca945c3c0b5f99f5a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 27 Apr 2021 04:02:32 +0200 Subject: [PATCH] server: Move constants to a separate file This will allow us to share them with tests and also make PHPStan aware of them. --- composer.json | 2 +- phpstan.neon | 3 +++ src/common.php | 9 +-------- src/constants.php | 10 ++++++++++ utils/bump-version.js | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/constants.php diff --git a/composer.json b/composer.json index 72f6e333bd..e800216e8b 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,6 @@ "cs": "php-cs-fixer fix --verbose --dry-run --diff", "fix": "php-cs-fixer fix --verbose --diff", "lint": "parallel-lint src tests", - "test": "phpunit --bootstrap vendor/autoload.php tests" + "test": "phpunit --bootstrap tests/bootstrap.php tests" } } diff --git a/phpstan.neon b/phpstan.neon index b4a7ac2f52..96caa623da 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,6 @@ parameters: + bootstrapFiles: + - src/constants.php + ignoreErrors: - '(Call to an undefined static method F3::([sg]et|error|reroute)\(\))' diff --git a/src/common.php b/src/common.php index 637de03463..79922f15ec 100644 --- a/src/common.php +++ b/src/common.php @@ -8,7 +8,7 @@ use Monolog\Handler\StreamHandler; use Monolog\Logger; -define('BASEDIR', __DIR__ . '/..'); +require __DIR__ . '/constants.php'; $autoloader = @include BASEDIR . '/vendor/autoload.php'; // we will show custom error if ($autoloader === false) { @@ -31,13 +31,6 @@ // but we have not set an error handler yet because it needs a Logger instantiated by Dice. error_reporting(E_ALL & ~E_DEPRECATED); -const SELFOSS_VERSION = '2.19-SNAPSHOT'; - -// independent of selfoss version -// needs to be bumped each time public API is changed (follows semver) -// keep in sync with docs/api-description.json -const SELFOSS_API_VERSION = '4.0.0'; - $f3->set('AUTOLOAD', false); $f3->set('BASEDIR', BASEDIR); $f3->set('LOCALES', BASEDIR . '/assets/locale/'); diff --git a/src/constants.php b/src/constants.php new file mode 100644 index 0000000000..0e069a2294 --- /dev/null +++ b/src/constants.php @@ -0,0 +1,10 @@ +