diff options
author | fox <[email protected]> | 2022-08-17 19:38:15 +0300 |
---|---|---|
committer | fox <[email protected]> | 2022-08-17 19:38:15 +0300 |
commit | 60658be5bc35192f9b2d9aaf413454f29fe51316 (patch) | |
tree | d7f6aa1b6bf3eaa4d7a9601e46e15441bc737d9e /classes/db/migrations.php | |
parent | ec764f97e7e3e0fac20f93364c84dfa01651bf95 (diff) | |
parent | 0dbed700efa77355839a4d2cddf02f93203dc96f (diff) |
Merge pull request 'Use PHP 7.4 features' (#77) from wn/tt-rss:feature/php-7.4-stuff into master
Reviewed-on: https://dev.tt-rss.org/fox/tt-rss/pulls/77
Diffstat (limited to 'classes/db/migrations.php')
-rw-r--r-- | classes/db/migrations.php | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/classes/db/migrations.php b/classes/db/migrations.php index aecd9186c..ffce2af5f 100644 --- a/classes/db/migrations.php +++ b/classes/db/migrations.php @@ -1,33 +1,15 @@ <?php class Db_Migrations { - // TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+ - /** @var string */ - private $base_filename = "schema.sql"; - - /** @var string */ - private $base_path; - - /** @var string */ - private $migrations_path; - - /** @var string */ - private $migrations_table; - - /** @var bool */ - private $base_is_latest; - - /** @var PDO */ - private $pdo; - - /** @var int */ - private $cached_version = 0; - - /** @var int */ - private $cached_max_version = 0; - - /** @var int */ - private $max_version_override; + private string $base_filename = "schema.sql"; + private string $base_path; + private string $migrations_path; + private string $migrations_table; + private bool $base_is_latest; + private PDO $pdo; + private int $cached_version = 0; + private int $cached_max_version = 0; + private int $max_version_override; function __construct() { $this->pdo = Db::pdo(); @@ -207,14 +189,11 @@ class Db_Migrations { $filename = "{$this->base_path}/{$this->base_filename}"; if (file_exists($filename)) { - $lines = array_filter(preg_split("/[\r\n]/", file_get_contents($filename)), - function ($line) { - return strlen(trim($line)) > 0 && strpos($line, "--") !== 0; - }); - - return array_filter(explode(";", implode("", $lines)), function ($line) { - return strlen(trim($line)) > 0 && !in_array(strtolower($line), ["begin", "commit"]); - }); + $lines = array_filter(preg_split("/[\r\n]/", file_get_contents($filename)), + fn($line) => strlen(trim($line)) > 0 && strpos($line, "--") !== 0); + + return array_filter(explode(";", implode("", $lines)), + fn($line) => strlen(trim($line)) > 0 && !in_array(strtolower($line), ["begin", "commit"])); } else { user_error("Requested schema file ${filename} not found.", E_USER_ERROR); |