Updated to PHP 8.3 and added cache provider requirements to the README.

This commit is contained in:
flash 2024-07-31 18:12:46 +00:00
parent e4c8ed711e
commit 3952dd96e8
21 changed files with 356 additions and 332 deletions

View file

@ -2,16 +2,29 @@
Index is a common library for my PHP projects.
It provides a number of components that I would otherwise copy between projects (and thus become out-of-sync) as well as a number of quality of life things on top of standard PHP stdlib functionality such as abstractions of arrays and strings as objects inspired by .NET's standard library.
It provides a number of components that I would otherwise copy between projects (and thus become out-of-sync) as well as a number of quality of life things on top of standard PHP stdlib functionality.
## Requirements and Dependencies
Index currently targets **PHP 8.2** with the `mbstring` extension installed.
Index currently targets **PHP 8.3** with the `mbstring` extension installed.
### `Index\Cache\Memcached`
Requires either the `memcached` or `memcache` extension, if both are installed the `memcached` based implementation will be used.
For full functionality you will want the `memcached` implementation.
The way each implementation stores data is NOT guaranteed to be compatible, please do not mix them.
### `Index\Cache\Valkey`
Requires the `redis` extension.
Valkey is the name of the Linux Foundation's fork of Redis.
### `Index\Data\MariaDB`
Requires the `mysqli` extension. `mysqlnd` is recommended as the underlying driver, but `libmysql` should work without a hitch. This driver also works for MySQL as the dependencies would suggest, but you should consider using MariaDB instead of possible.
Requires the `mysqli` extension.
`mysqlnd` is recommended as the underlying driver, but `libmysql` should work without a hitch.
This driver also works for MySQL as the dependencies would suggest, but you should consider using MariaDB instead of possible.
### `Index\Data\SQLite`

View file

@ -1 +1 @@
0.2404.102340
0.2407.311805

View file

@ -5,12 +5,12 @@
"homepage": "https://railgun.sh/index",
"license": "bsd-3-clause-clear",
"require": {
"php": ">=8.1",
"php": ">=8.3",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
"phpstan/phpstan": "^1.10"
"phpunit/phpunit": "^11.2",
"phpstan/phpstan": "^1.11"
},
"suggest": {
"ext-mysqli": "Support for the Index\\Data\\MariaDB namespace (both mysqlnd and libmysql are supported).",

503
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,15 @@
<?php
// Base32Test.php
// Created: 2021-04-28
// Updated: 2023-07-21
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Serialisation\Base32;
/**
* @covers Base32
*/
#[CoversClass(Base32::class)]
final class Base32Test extends TestCase {
public const TESTS = [
'A' => '',

View file

@ -1,16 +1,15 @@
<?php
// Base62Test.php
// Created: 2022-01-28
// Updated: 2023-07-21
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Serialisation\Base62;
/**
* @covers Base62
*/
#[CoversClass(Base62::class)]
final class Base62Test extends TestCase {
public const TESTS = [
['aaaaaa', 9311514030],

View file

@ -1,16 +1,15 @@
<?php
// BencodeTest.php
// Created: 2023-07-21
// Updated: 2023-07-21
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Serialisation\Bencode;
/**
* @covers Bencode
*/
#[CoversClass(Bencode::class)]
final class BencodeTest extends TestCase {
public const TORRENT = 'ZDg6YW5ub3VuY2U0NTpodHRwczovL3RyYWNrZXIuZmxhc2hpaS5uZXQvYW5ub3VuY2UucGhwL21lb3c3OmNvbW1lbnQyNjp0aGlzIGlzIHRoZSBjb21tZW50cyBmaWVsZDEwOmNyZWF0ZWQgYnkxODpxQml0dG9ycmVudCB2NC41LjQxMzpjcmVhdGlvbiBkYXRlaTE2ODk5NzM2NjRlNDppbmZvZDY6bGVuZ3RoaTM5NDg4ZTQ6bmFtZTEwOmF1dGlzbS5qcGcxMjpwaWVjZSBsZW5ndGhpMTYzODRlNjpwaWVjZXM2MDpJCQyONUjTseqtXs9g1xIC+yWtTGjuWTho+hSXmOUkSAiKnD4vs5E9QewQ1NrXvVeg2xCRHYD/HL9RNRc3OnByaXZhdGVpMWVlZQ';

View file

@ -1,16 +1,15 @@
<?php
// ByteFormatTest.php
// Created: 2023-07-05
// Updated: 2023-07-05
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\ByteFormat;
/**
* @covers ByteFormat
*/
#[CoversClass(ByteFormat::class)]
final class ByteFormatTest extends TestCase {
public function testFormat(): void {
$this->assertEquals(ByteFormat::formatDecimal(0), 'Zero Bytes');

View file

@ -1,16 +1,15 @@
<?php
// CSRFPTest.php
// Created: 2021-06-11
// Updated: 2023-07-11
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Security\CSRFP;
/**
* @covers CSRFP
*/
#[CoversClass(CSRFP::class)]
final class CSRFPTest extends TestCase {
private const SECRET_1 = 'oCtBmR7XS1dLOnGVoVi0wXwTLk7Ursn4';
private const SECRET_2 = 'v6H37MPa8NHmxVvL4AzNSxrWLVkiTfPHouyTto1LXOfOyoqSU7EaSorjdM4gXlq3';

View file

@ -1,20 +1,27 @@
<?php
// CacheToolsTest.php
// Created: 2024-04-10
// Updated: 2024-04-10
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use Index\Cache\CacheTools;
use Index\Cache\ArrayCache\{ArrayCacheBackend,ArrayCacheProvider};
use Index\Cache\Memcached\MemcachedBackend;
use Index\Cache\Valkey\ValkeyBackend;
use Index\Net\{DnsEndPoint,IPEndPoint,UnixEndPoint};
/**
* @covers CacheTools
*/
#[CoversClass(CacheTools::class)]
#[CoversClass(ArrayCacheBackend::class)]
#[CoversClass(ArrayCacheProvider::class)]
#[CoversClass(MemcachedBackend::class)]
#[CoversClass(ValkeyBackend::class)]
#[UsesClass(DnsEndPoint::class)]
#[UsesClass(IPEndPoint::class)]
#[UsesClass(UnixEndPoint::class)]
final class CacheToolsTest extends TestCase {
public function testBasicDSN(): void {
$arrayCache = CacheTools::create('array:');

View file

@ -1,24 +1,23 @@
<?php
// ColourTest.php
// Created: 2023-01-02
// Updated: 2023-09-15
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Colour\Colour;
use Index\Colour\ColourHSL;
use Index\Colour\ColourNamed;
use Index\Colour\ColourNull;
use Index\Colour\ColourRGB;
/**
* @covers Colour
* @covers ColourHSL
* @covers ColourNamed
* @covers ColourNull
* @covers ColourRGB
*/
#[CoversClass(Colour::class)]
#[CoversClass(ColourHSL::class)]
#[CoversClass(ColourNamed::class)]
#[CoversClass(ColourNull::class)]
#[CoversClass(ColourRGB::class)]
final class ColourTest extends TestCase {
public function testNone(): void {
$none = Colour::none();

View file

@ -1,20 +1,19 @@
<?php
// DateTimeTest.php
// Created: 2021-06-14
// Updated: 2022-02-27
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\DateTime;
use Index\TimeSpan;
use Index\TimeZoneInfo;
/**
* @covers DateTime
* @covers TimeSpan
* @covers TimeZoneInfo
*/
#[CoversClass(DateTime::class)]
#[CoversClass(TimeSpan::class)]
#[CoversClass(TimeZoneInfo::class)]
final class DateTimeTest extends TestCase {
public function testAttributes(): void {
$index = new DateTime('2021-06-14T21:07:14.359324 CEST');

View file

@ -1,22 +1,26 @@
<?php
// DbToolsTest.php
// Created: 2021-04-28
// Updated: 2024-04-10
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use Index\Data\DbTools;
use Index\Data\DbType;
use Index\Data\MariaDB\MariaDBBackend;
use Index\Data\NullDb\NullDbConnection;
use Index\Data\SQLite\SQLiteBackend;
use Index\IO\MemoryStream;
use Index\Net\UnixEndPoint;
/**
* @covers DbTools
*/
#[CoversClass(DbTools::class)]
#[CoversClass(DbType::class)]
#[CoversClass(NullDbConnection::class)]
#[CoversClass(MariaDBBackend::class)]
#[CoversClass(SQLiteBackend::class)]
#[UsesClass(MemoryStream::class)]
final class DbToolsTest extends TestCase {
public function testDetectType(): void {
$this->assertEquals(DbType::NULL, DbTools::detectType(null));

View file

@ -1,17 +1,18 @@
<?php
// EnvironmentTest.php
// Created: 2021-05-02
// Updated: 2023-11-09
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use Index\Environment;
use Index\Version;
/**
* @covers Environment
*/
#[CoversClass(Environment::class)]
#[UsesClass(Version::class)]
final class EnvironmentTest extends TestCase {
public function testEnvVars(): void {
$varName = 'NDX_TEST_VAR_DO_NOT_DEFINE';

View file

@ -1,17 +1,18 @@
<?php
// IPAddressRangeTest.php
// Created: 2021-04-27
// Updated: 2022-02-03
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use Index\Net\IPAddress;
use Index\Net\IPAddressRange;
/**
* @covers IPAddressRange
*/
#[CoversClass(IPAddressRange::class)]
#[UsesClass(IPAddress::class)]
final class IPAddressRangeTest extends TestCase {
public function testParsing(): void {
$v4 = IPAddressRange::parse('127.0.0.1/23');

View file

@ -1,16 +1,15 @@
<?php
// IPAddressTest.php
// Created: 2021-04-26
// Updated: 2022-02-03
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Net\IPAddress;
/**
* @covers IPAddress
*/
#[CoversClass(IPAddress::class)]
final class IPAddressTest extends TestCase {
public function testParsing(): void {
$v4 = IPAddress::parse('127.0.0.1');

View file

@ -1,21 +1,24 @@
<?php
// RouterTest.php
// Created: 2022-01-20
// Updated: 2024-04-02
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Index\Routing\Route;
use Index\Routing\Router;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\Http\Routing\{HttpGet,HttpMiddleware,HttpPost,HttpPut,HttpRouter,RouteHandler};
/**
* This test isn't super representative of the current functionality
* it mostly just does the same tests that were done against the previous implementation
*
* @covers HttpRouter
*/
#[CoversClass(HttpGet::class)]
#[CoversClass(HttpMiddleware::class)]
#[CoversClass(HttpPost::class)]
#[CoversClass(HttpPut::class)]
#[CoversClass(HttpRouter::class)]
#[CoversClass(RouteHandler::class)]
final class RouterTest extends TestCase {
public function testRouter(): void {
$router1 = new HttpRouter;

View file

@ -1,17 +1,18 @@
<?php
// VersionTest.php
// Created: 2021-04-30
// Updated: 2022-02-03
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use Index\Version;
use Index\XArray;
/**
* @covers Version
*/
#[CoversClass(Version::class)]
#[UsesClass(XArray::class)]
final class VersionTest extends TestCase {
public function testParse(): void {
$tests = [

View file

@ -1,16 +1,15 @@
<?php
// WStringTest.php
// Created: 2021-04-26
// Updated: 2024-01-04
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\WString;
/**
* @covers WString
*/
#[CoversClass(WString::class)]
final class WStringTest extends TestCase {
public function testStartsWith(): void {
$this->assertTrue(WString::startsWith('君は実にバカだな', '君は'));

View file

@ -1,16 +1,15 @@
<?php
// XArrayTest.php
// Created: 2021-04-26
// Updated: 2024-01-04
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\XArray;
/**
* @covers XArray
*/
#[CoversClass(XArray::class)]
final class XArrayTest extends TestCase {
public function testCountEmpty(): void {
$array = [];

View file

@ -1,16 +1,15 @@
<?php
// XStringTest.php
// Created: 2021-04-26
// Updated: 2024-01-04
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\XString;
/**
* @covers XString
*/
#[CoversClass(XString::class)]
final class XStringTest extends TestCase {
public function testEscape(): void {
$dirty = '<img onerror="alert(\'xss\')">';