複数ネームスペースを可能に

This commit is contained in:
2026-02-27 03:15:17 +09:00
parent b723230818
commit a1bd29cff6
32 changed files with 95 additions and 73 deletions

View File

@@ -2,7 +2,7 @@
namespace Site\Controller;
use Site\Controller\BlogPost;
use Site\Lib\Markdown;
use Std\Lib\Markdown;
class Atom extends BlogPost {
private string $domain = 'technicalsuwako.moe';

View File

@@ -3,7 +3,7 @@ namespace Site\Controller;
use Site\Controller\BlogPost;
use Site\Controller\Mods;
use Site\Lib\Activitypub;
use Std\Lib\Activitypub;
class Fediverse extends BlogPost {
use Mods;

View File

@@ -3,10 +3,10 @@ namespace Site\Controller;
use Site\Controller\BlogPost;
use Site\Controller\Mods;
use Site\Lib\Activitypub;
use Site\Lib\Auth;
use Site\Lib\Markdown;
use Site\Lib\Template;
use Std\Lib\Activitypub;
use Std\Lib\Auth;
use Std\Lib\Markdown;
use Std\Lib\Template;
class Home extends BlogPost {
use Mods;

View File

@@ -2,8 +2,8 @@
namespace Site\Controller;
use Site\Controller\Mods;
use Site\Lib\Auth;
use Site\Lib\Template;
use Std\Lib\Auth;
use Std\Lib\Template;
class Notfound {
use Mods;

View File

@@ -2,8 +2,8 @@
namespace Site\Controller;
use Site\Controller\Mods;
use Site\Lib\Auth;
use Site\Lib\Template;
use Std\Lib\Auth;
use Std\Lib\Template;
class Page {
use Mods;

View File

@@ -2,8 +2,8 @@
namespace Site\Controller;
use Site\Controller\Mods;
use Site\Lib\Auth;
use Site\Lib\Template;
use Std\Lib\Auth;
use Std\Lib\Template;
class User {
use Mods;

View File

@@ -0,0 +1,19 @@
<?php
namespace Site\Test;
require_once __DIR__.'/../../../autoload.php';
use Site\Controller\User;
use Std\Lib\Tester;
$test = new Tester([
'colorOutput' => true,
'verboseOutput' => true
]);
$test->describe('', function($test): void {
$test->it('', function($test): void {
// TODO
});
});

View File

@@ -1,7 +1,7 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
use Site\Lib\Curl;
use Std\Lib\Curl;
/**
* ActivityPubプロトコルの実装クラス

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
class Auth {
private int $id;

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
/**
* php_curlへの依存を排除するための独自のCURL実装

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
class DiffViewer {
private $diffContent;

View File

@@ -1,11 +1,11 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
use Site\Lib\Image\ImageInterface;
use Site\Lib\Image\Gif;
use Site\Lib\Image\Jpeg;
use Site\Lib\Image\Png;
use Site\Lib\Image\Targa;
use Std\Lib\Image\ImageInterface;
use Std\Lib\Image\Gif;
use Std\Lib\Image\Jpeg;
use Std\Lib\Image\Png;
use Std\Lib\Image\Targa;
class RGB {
public int $r;

View File

@@ -1,7 +1,7 @@
<?php
namespace Site\Lib\Image;
namespace Std\Lib\Image;
use Site\Lib\Image\ImageInterface;
use Std\Lib\Image\ImageInterface;
class Gif implements ImageInterface {
public int $width = 0;

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib\Image;
namespace Std\Lib\Image;
interface ImageInterface {
public function parse(string $file): \stdClass;

View File

@@ -1,7 +1,7 @@
<?php
namespace Site\Lib\Image;
namespace Std\Lib\Image;
use Site\Lib\Image\ImageInterface;
use Std\Lib\Image\ImageInterface;
class Jpeg implements ImageInterface {
public int $width = 0;

View File

@@ -1,7 +1,7 @@
<?php
namespace Site\Lib\Image;
namespace Std\Lib\Image;
use Site\Lib\Image\ImageInterface;
use Std\Lib\Image\ImageInterface;
class Png implements ImageInterface {
public \stdClass $IHDR; // 画像ヘッダー
@@ -151,7 +151,7 @@ next_chunk:
if ($nextChunk === "\x50\x4c\x54\x45") { // PLTE
$palette = [];
for ($i = 0; $i < $length; $i += 3) {
$colors = new \Site\Lib\RGB(ord($data[$i]), ord($data[$i+1]), ord($data[$i+2]));
$colors = new \Std\Lib\RGB(ord($data[$i]), ord($data[$i+1]), ord($data[$i+2]));
$palette[] = $colors->rgb;
}
@@ -173,7 +173,7 @@ next_chunk:
$bytes = $this->IHDR->colorType === 2 ? 3 : 1;
for ($i = 0; $i < $length; $i += $bytes) {
if ($this->IHDR->colorType === 2) {
$colors = new \Site\Lib\RGB(ord($data[$i]), ord($data[$i+1]), ord($data[$i+2]));
$colors = new \Std\Lib\RGB(ord($data[$i]), ord($data[$i+1]), ord($data[$i+2]));
$vals[] = $colors->rgb;
} else {
$vals[] = ord($data[$i]);

View File

@@ -1,7 +1,7 @@
<?php
namespace Site\Lib\Image;
namespace Std\Lib\Image;
use Site\Lib\Image\ImageInterface;
use Std\Lib\Image\ImageInterface;
class Targa implements ImageInterface {
public int $id = 0;

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
class Mailer {
private $socket;

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
class Markdown {
private string $content;

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
class Route {
protected static array $routes = [];

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
class Template {
private string $tmplExt = '.maron';

View File

@@ -1,5 +1,5 @@
<?php
namespace Site\Lib;
namespace Std\Lib;
/**
* アサーション失敗用のカスタム例外

View File

@@ -1,10 +1,10 @@
<?php
namespace Site\Test;
namespace Std\Test;
require_once __DIR__.'/../../../autoload.php';
use Site\Lib\Tester;
use Site\Lib\Activitypub;
use Std\Lib\Tester;
use Std\Lib\Activitypub;
use Site\Controller\BlogPost;
if (ACTIVITYPUB_ENABLED) {

View File

@@ -1,10 +1,10 @@
<?php
namespace Site\Test;
namespace Std\Test;
require_once __DIR__.'/../../../autoload.php';
use Site\Lib\Tester;
use Site\Lib\Auth;
use Std\Lib\Tester;
use Std\Lib\Auth;
if (AUTH_ENABLED) {
$test = new Tester([
@@ -156,7 +156,7 @@ if (AUTH_ENABLED) {
});
}
// TODO: CLIからクッキーを設定出来ないから、「Site\Lib\Auth::getUserData(): Return value must be of type stdClass, null returned」って発生する・・・
// TODO: CLIからクッキーを設定出来ないから、「Lib\Auth::getUserData(): Return value must be of type stdClass, null returned」って発生する・・・
// $test->describe('ログインとログアウト', function($test): void {
// $user = "admin1234";
// $pass = "testTEST1234!#$%@[]:;";

View File

@@ -1,10 +1,10 @@
<?php
namespace Site\Test;
namespace Std\Test;
require_once __DIR__.'/../../../autoload.php';
use Site\Lib\Tester;
use Site\Lib\Curl;
use Std\Lib\Tester;
use Std\Lib\Curl;
if (CURL_ENABLED) {
$test = new Tester([

View File

@@ -1,10 +1,10 @@
<?php
namespace Site\Test;
namespace Std\Test;
require_once __DIR__.'/../../../autoload.php';
use Site\Lib\Tester;
use Site\Lib\Markdown;
use Std\Lib\Tester;
use Std\Lib\Markdown;
$test = new Tester([
'colorOutput' => true,
@@ -80,7 +80,7 @@ $test->describe('マークダウン', function($test): void {
$body = $md->parse();
$test->assertNotNull($body);
$expect = "<h1>ケロケロ</h1>";
$expect = "<h1 id=\"section-1\">ケロケロ</h1>";
$actual = trim($body);
$test->assertEquals($expect, $actual);
@@ -95,7 +95,7 @@ $test->describe('マークダウン', function($test): void {
$body = $md->parse();
$test->assertNotNull($body);
$expect = "<h2>ケロケロ</h2>";
$expect = "<h2 id=\"section-1\">ケロケロ</h2>";
$actual = trim($body);
$test->assertEquals($expect, $actual);
@@ -110,7 +110,7 @@ $test->describe('マークダウン', function($test): void {
$body = $md->parse();
$test->assertNotNull($body);
$expect = "<h3>ケロケロ</h3>";
$expect = "<h3 id=\"section-1\">ケロケロ</h3>";
$actual = trim($body);
$test->assertEquals($expect, $actual);
@@ -125,7 +125,7 @@ $test->describe('マークダウン', function($test): void {
$body = $md->parse();
$test->assertNotNull($body);
$expect = "<h4>ケロケロ</h4>";
$expect = "<h4 id=\"section-1\">ケロケロ</h4>";
$actual = trim($body);
$test->assertEquals($expect, $actual);
@@ -140,7 +140,7 @@ $test->describe('マークダウン', function($test): void {
$body = $md->parse();
$test->assertNotNull($body);
$expect = "<h5>ケロケロ</h5>";
$expect = "<h5 id=\"section-1\">ケロケロ</h5>";
$actual = trim($body);
$test->assertEquals($expect, $actual);
@@ -155,7 +155,7 @@ $test->describe('マークダウン', function($test): void {
$body = $md->parse();
$test->assertNotNull($body);
$expect = "<h6>ケロケロ</h6>";
$expect = "<h6 id=\"section-1\">ケロケロ</h6>";
$actual = trim($body);
$test->assertEquals($expect, $actual);

View File

@@ -1,10 +1,10 @@
<?php
namespace Site\Test;
namespace Std\Test;
require_once __DIR__.'/../../../autoload.php';
use Site\Lib\Tester;
use Site\Lib\Route;
use Std\Lib\Tester;
use Std\Lib\Route;
$test = new Tester([
'colorOutput' => true,
@@ -25,7 +25,7 @@ $test->describe('ルート', function($test): void {
[
'method' => 'GET',
'path' => 'about',
'class' => 'Site\Test\Webpage@about',
'class' => 'Std\Test\Webpage@about',
'params' => [],
]
];