Skip to content

Commit

Permalink
server: Move constants to a separate file
Browse files Browse the repository at this point in the history
This will allow us to share them with tests and also make PHPStan aware of them.
  • Loading branch information
jtojnar committed Apr 27, 2021
1 parent b223ef5 commit 7f4eae0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parameters:
bootstrapFiles:
- src/constants.php

ignoreErrors:
- '(Call to an undefined static method F3::([sg]et|error|reroute)\(\))'
9 changes: 1 addition & 8 deletions src/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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/');
Expand Down
10 changes: 10 additions & 0 deletions src/constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

const BASEDIR = __DIR__ . '/..';

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';
4 changes: 2 additions & 2 deletions utils/bump-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (newVersion.search(/^\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?$/) === -1) {
const sources = [
'package.json',
'README.md',
'src/common.php',
'src/constants.php',
'docs/config.toml'
];

Expand All @@ -33,7 +33,7 @@ const replacements = [
to: "# selfoss " + newVersion
},

// rule for src/common.php
// rule for src/constants.php
{
from: /SELFOSS_VERSION = '\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?'/,
to: "SELFOSS_VERSION = '" + newVersion + "'"
Expand Down

0 comments on commit 7f4eae0

Please sign in to comment.