allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,44 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Manual;
/**
* Interface for PHP manual loaders.
*
* Provides a unified interface for accessing PHP manual documentation
* regardless of the underlying storage format (SQLite, Phar, PHP file).
*/
interface ManualInterface
{
/**
* Get documentation for a given ID.
*
* @param string $id Documentation ID (e.g., 'strlen', 'PDO::query')
*
* @return string|array|null Formatted string (v2) or structured data (v3), or null if not found
*/
public function get(string $id);
/**
* Get the manual format version.
*
* @return int Major version number
*/
public function getVersion(): int;
/**
* Get manual metadata (version, language, build date, etc).
*
* @return array Manual metadata
*/
public function getMeta(): array;
}

View File

@@ -0,0 +1,82 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Manual;
/**
* V2 manual format loader.
*
* Loads pre-formatted manual documentation from SQLite databases.
*/
class V2Manual implements ManualInterface
{
private \PDO $db;
/**
* Constructor.
*
* @param \PDO $db SQLite database connection
*/
public function __construct(\PDO $db)
{
$this->db = $db;
}
/**
* {@inheritdoc}
*/
public function get(string $id)
{
$result = $this->db->query(\sprintf('SELECT doc FROM php_manual WHERE id = %s', $this->db->quote($id)));
if ($result !== false) {
return $result->fetchColumn(0) ?: null;
}
return null;
}
/**
* {@inheritdoc}
*/
public function getVersion(): int
{
return 2;
}
/**
* Get manual metadata (version, language, build date, etc).
*
* Reads metadata from the meta table in the SQLite database.
*
* @return array
*/
public function getMeta(): array
{
$meta = ['format' => 'sqlite'];
$result = $this->db->query('SELECT id, value FROM meta');
if ($result !== false) {
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
$key = $row['id'];
$value = $row['value'];
// Convert numeric strings to integers
if (\in_array($key, ['git_timestamp', 'built_at'], true)) {
$value = (int) $value;
}
$meta[$key] = $value;
}
}
return $meta;
}
}

106
vendor/psy/psysh/src/Manual/V3Manual.php vendored Normal file
View File

@@ -0,0 +1,106 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Manual;
use Psy\Exception\InvalidManualException;
/**
* V3 manual format loader.
*
* Loads structured manual documentation from a single pre-built PHP file.
*
* The PHP file returns an object with a get($id) method that handles the data loading internally.
*/
class V3Manual implements ManualInterface
{
/** @var object */
private $data;
/** @var array<string, object> */
private static $cache = [];
/**
* Constructor.
*
* @param string $filePath Path to the PHP manual file
*
* @throws InvalidManualException if file doesn't return a valid manual data object
*/
public function __construct(string $filePath)
{
// Avoid redefining __COMPILER_HALT_OFFSET__
// TODO: Remove cache after dropping support for PHP 8.2.
if (isset(self::$cache[$filePath])) {
$data = self::$cache[$filePath];
} else {
// Suppress output from invalid/corrupted manual files
\ob_start();
try {
/** @var mixed $data */
$data = require $filePath;
} finally {
\ob_end_clean();
}
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable $data is always set above
self::$cache[$filePath] = $data;
}
// Validate that the file returned an object with the expected interface
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable $data is always set above
if (!\is_object($data)) {
throw new InvalidManualException(\sprintf('Manual file "%s" must return an object, got %s', $filePath, \gettype($data)), $filePath);
}
$requiredMethods = ['get', 'getMeta'];
foreach ($requiredMethods as $method) {
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable $data is always set above
if (!\method_exists($data, $method)) {
throw new InvalidManualException(\sprintf('Manual data object must have a %s() method', $method), $filePath);
}
}
// Verify the manual format version is v3.x
$meta = $data->getMeta();
if (!isset($meta['version']) || !\preg_match('/^3\./', (string) $meta['version'])) {
$version = $meta['version'] ?? 'unknown';
throw new InvalidManualException(\sprintf('Manual file "%s" must be v3.x format, got version %s', $filePath, $version), $filePath);
}
$this->data = $data;
}
/**
* {@inheritdoc}
*/
public function get(string $id)
{
return $this->data->get($id);
}
/**
* {@inheritdoc}
*/
public function getVersion(): int
{
return 3;
}
/**
* Get manual metadata (version, language, build date, etc).
*
* @return array
*/
public function getMeta(): array
{
return $this->data->getMeta();
}
}