- Move 45 debug/test files from root to organized scripts/ directories - Secure public/ directory by removing debug files (security improvement) - Create structured scripts organization: • scripts/debug/ (20 files) - Framework debugging tools • scripts/test/ (18 files) - Test and validation scripts • scripts/maintenance/ (5 files) - Maintenance utilities • scripts/dev/ (2 files) - Development tools Security improvements: - Removed all debug/test files from public/ directory - Only production files remain: index.php, health.php Root directory cleanup: - Reduced from 47 to 2 PHP files in root - Only essential production files: console.php, worker.php This improves: ✅ Security (no debug code in public/) ✅ Organization (clear separation of concerns) ✅ Maintainability (easy to find and manage scripts) ✅ Professional structure (clean root directory)
72 lines
1.5 KiB
PHP
72 lines
1.5 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
use App\Framework\SyntaxHighlighter\SyntaxHighlighter;
|
|
|
|
// Test code to highlight
|
|
$phpCode = <<<'PHP'
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Example;
|
|
|
|
use App\Framework\Http\JsonResult;
|
|
|
|
#[Route(path: '/api/users', method: 'GET')]
|
|
final readonly class UserController
|
|
{
|
|
/**
|
|
* Get all users
|
|
*
|
|
* @param UserRepository $repository
|
|
* @return JsonResult<array<User>>
|
|
*/
|
|
public function getUsers(UserRepository $repository): JsonResult
|
|
{
|
|
$users = $repository->findAll();
|
|
$count = count($users);
|
|
|
|
return new JsonResult([
|
|
'users' => $users,
|
|
'count' => $count,
|
|
'message' => "Found {$count} users"
|
|
]);
|
|
}
|
|
}
|
|
PHP;
|
|
|
|
$highlighter = new SyntaxHighlighter();
|
|
|
|
// Test HTML output
|
|
echo "=== HTML Output ===\n";
|
|
$html = $highlighter->highlightWithCss($phpCode, [
|
|
'theme' => 'dark',
|
|
'lineNumbers' => true
|
|
]);
|
|
echo $html . "\n\n";
|
|
|
|
// Test console output
|
|
echo "=== Console Output ===\n";
|
|
$console = $highlighter->highlight($phpCode, 'console', [
|
|
'colorize' => true,
|
|
'lineNumbers' => true
|
|
]);
|
|
echo $console . "\n";
|
|
|
|
// Test tokenization
|
|
echo "=== Tokenization Test ===\n";
|
|
$tokens = $highlighter->tokenize($phpCode);
|
|
echo "Total tokens: " . $tokens->count() . "\n";
|
|
|
|
// Show first few tokens
|
|
$first5 = $tokens->slice(0, 5);
|
|
foreach ($first5 as $token) {
|
|
echo sprintf(
|
|
"Line %d: %s = '%s'\n",
|
|
$token->line,
|
|
$token->type->value,
|
|
trim($token->value)
|
|
);
|
|
} |