Updated to PHP 8.3 and latest Index.
This commit is contained in:
parent
954a07b951
commit
129a46c0d9
12 changed files with 354 additions and 338 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.1.0-dev
|
||||
1.2.0
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
"type": "library",
|
||||
"homepage": "https://railgun.sh/syokuhou",
|
||||
"license": "bsd-3-clause-clear",
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": ">=8.2",
|
||||
"flashwave/index": "dev-master"
|
||||
"php": ">=8.3",
|
||||
"flashwave/index": "^0.2408.40014"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.4",
|
||||
"phpstan/phpstan": "^1.10"
|
||||
"phpunit/phpunit": "^11.2",
|
||||
"phpstan/phpstan": "^1.11"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
|
|
523
composer.lock
generated
523
composer.lock
generated
File diff suppressed because it is too large
Load diff
34
src/Syokuhou.php
Normal file
34
src/Syokuhou.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
// SyokuhouInfo.php
|
||||
// Created: 2023-10-20
|
||||
// Updated: 2023-10-20
|
||||
|
||||
namespace Syokuhou;
|
||||
|
||||
/**
|
||||
* Provides information about the Syokuhou library.
|
||||
*/
|
||||
final class Syokuhou {
|
||||
public const PATH_SOURCE = __DIR__;
|
||||
public const PATH_ROOT = self::PATH_SOURCE . DIRECTORY_SEPARATOR . '..';
|
||||
public const PATH_VERSION = self::PATH_ROOT . DIRECTORY_SEPARATOR . 'VERSION';
|
||||
|
||||
/**
|
||||
* Gets the current version of the Syokuhou library.
|
||||
*
|
||||
* Reads the VERSION file in the root of the Syokuhou directory.
|
||||
* Returns 0.0.0 if reading the file failed for any reason.
|
||||
*
|
||||
* @return string Current version string.
|
||||
*/
|
||||
public static function version(): string {
|
||||
if(!is_file(self::PATH_VERSION))
|
||||
return '0.0.0';
|
||||
|
||||
$version = file_get_contents(self::PATH_VERSION);
|
||||
if($version === false)
|
||||
return '0.0.0';
|
||||
|
||||
return trim($version);
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
// SyokuhouInfo.php
|
||||
// Created: 2023-10-20
|
||||
// Updated: 2023-10-20
|
||||
|
||||
namespace Syokuhou;
|
||||
|
||||
use UnexpectedValueException;
|
||||
use Index\Version;
|
||||
|
||||
/**
|
||||
* Retrieves library info.
|
||||
*/
|
||||
final class SyokuhouInfo {
|
||||
private static ?string $versionString = null;
|
||||
private static ?Version $version = null;
|
||||
|
||||
/**
|
||||
* Returns the current version of the library.
|
||||
*
|
||||
* @return Version
|
||||
*/
|
||||
public static function getVersion(): Version {
|
||||
if(self::$version === null)
|
||||
self::$version = Version::parse(self::getVersionString());
|
||||
|
||||
return self::$version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current version of the library as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getVersionString(): string {
|
||||
if(self::$versionString === null) {
|
||||
$body = file_get_contents(__DIR__ . '/../VERSION');
|
||||
if($body === false)
|
||||
throw new UnexpectedValueException('Was unable to read VERSION file.');
|
||||
self::$versionString = trim($body);
|
||||
}
|
||||
|
||||
return self::$versionString;
|
||||
}
|
||||
}
|
|
@ -6,14 +6,13 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* @covers \Syokuhou\DbConfigTest
|
||||
* @covers \Syokuhou\DbConfigValueInfo
|
||||
* @covers \Syokuhou\MutableConfigTrait
|
||||
* @covers \Syokuhou\GetValueInfoTrait
|
||||
* @covers \Syokuhou\GetValuesTrait
|
||||
*/
|
||||
#[CoversClass(Syokuhou\DbConfigTest::class)]
|
||||
#[CoversClass(Syokuhou\DbConfigValueInfo::class)]
|
||||
#[CoversClass(Syokuhou\MutableConfigTrait::class)]
|
||||
#[CoversClass(Syokuhou\GetValueInfoTrait::class)]
|
||||
#[CoversClass(Syokuhou\GetValuesTrait::class)]
|
||||
final class DbConfigTest extends TestCase {
|
||||
private \Index\Data\IDbConnection $dbConn;
|
||||
private \Syokuhou\DbConfig $config;
|
||||
|
|
|
@ -6,15 +6,14 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* @covers \Syokuhou\FileConfig
|
||||
* @covers \Syokuhou\FileConfigValueInfo
|
||||
* @covers \Syokuhou\ImmutableConfigTrait
|
||||
* @covers \Syokuhou\GetValueInfoTrait
|
||||
* @covers \Syokuhou\GetValuesTrait
|
||||
* @covers \Syokuhou\SharpConfig
|
||||
*/
|
||||
#[CoversClass(Syokuhou\FileConfig::class)]
|
||||
#[CoversClass(Syokuhou\FileConfigValueInfo::class)]
|
||||
#[CoversClass(Syokuhou\ImmutableConfigTrait::class)]
|
||||
#[CoversClass(Syokuhou\GetValueInfoTrait::class)]
|
||||
#[CoversClass(Syokuhou\GetValuesTrait::class)]
|
||||
#[CoversClass(Syokuhou\SharpConfig::class)]
|
||||
final class FileConfigTest extends TestCase {
|
||||
public function testImmutableRemove(): void {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* @covers \Syokuhou\NullConfig
|
||||
* @covers \Syokuhou\GetValuesTrait
|
||||
*/
|
||||
#[CoversClass(Syokuhou\NullConfig::class)]
|
||||
#[CoversClass(Syokuhou\GetValuesTrait::class)]
|
||||
final class NullConfigTest extends TestCase {
|
||||
public function testNullConfig(): void {
|
||||
$config = new \Syokuhou\NullConfig;
|
||||
|
|
|
@ -6,14 +6,12 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* @covers \Syokuhou\SyokuhouInfo
|
||||
*/
|
||||
#[CoversClass(Syokuhou\Syokuhou::class)]
|
||||
final class SyokuhouTest extends TestCase {
|
||||
public function testVersionDecode(): void {
|
||||
$expected = trim(file_get_contents(__DIR__ . '/../VERSION'));
|
||||
$this->assertEquals($expected, \Syokuhou\SyokuhouInfo::getVersionString());
|
||||
$this->assertEquals($expected, (string)\Syokuhou\SyokuhouInfo::getVersion());
|
||||
$this->assertEquals($expected, \Syokuhou\Syokuhou::version());
|
||||
}
|
||||
}
|
||||
|
|
30
tools/create-tag
Executable file
30
tools/create-tag
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
$path = (function($path) {
|
||||
if(!str_starts_with($path, '/'))
|
||||
die('Cannot be bothered to support non-UNIX style paths, sorry!' . PHP_EOL);
|
||||
|
||||
while($path !== '/') {
|
||||
$vPath = $path . DIRECTORY_SEPARATOR . 'VERSION';
|
||||
if(is_file($vPath))
|
||||
return $vPath;
|
||||
|
||||
$path = dirname($path);
|
||||
}
|
||||
})(__DIR__);
|
||||
|
||||
$version = file_get_contents($path);
|
||||
if($version === false)
|
||||
die('Failed to read VERSION file.' . PHP_EOL);
|
||||
$version = trim($version);
|
||||
|
||||
$workingDir = getcwd();
|
||||
try {
|
||||
chdir(dirname($path));
|
||||
echo shell_exec(sprintf('git tag v%s', $version));
|
||||
echo shell_exec(sprintf('git push origin v%s', $version));
|
||||
} finally {
|
||||
chdir($workingDir);
|
||||
}
|
||||
|
||||
echo $version . PHP_EOL;
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pushd .
|
||||
cd $(dirname "$0")
|
||||
|
||||
php update-headers.php
|
||||
./update-headers
|
||||
|
||||
popd
|
||||
|
|
1
tools/update-headers.php → tools/update-headers
Normal file → Executable file
1
tools/update-headers.php → tools/update-headers
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
// the point of index was so that i wouldn't have to copy things between projects
|
||||
// here i am copying things from index
|
Reference in a new issue