Initial commit: queue workspace

Made-with: Cursor
This commit is contained in:
apple
2026-03-21 02:55:24 +08:00
commit 78de918c37
12388 changed files with 1840126 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
#!/usr/bin/env php
<?php
/**
* User: sy-records
* Email: lufei@php.net
* Usage: php bin/format
*/
function scan_dir(string $dir, callable $filter = null): array
{
$files = array_filter(scandir($dir), function (string $file) {
return $file[0] !== '.';
});
array_walk($files, function (&$file) use ($dir) {
$file = "{$dir}/{$file}";
});
return array_values($filter ? array_filter($files, $filter) : $files);
}
function fix_tests_in_this_dir(string $dir, string $root = '')
{
$files = scan_dir($dir);
foreach ($files as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
$requirement_level = (function () use ($root, $file) {
for ($l = 0; $l < 8; $l++) {
$file = dirname($file);
if ($file === $root) {
return $l;
}
}
return -1;
})();
if ($requirement_level < 0) {
echo("Failed to get requirement level of file {$file}");
}
$content = file_get_contents($file);
$changed = false;
// empty lines
$_content = trim($content) . "\n";
if ($content !== $_content) {
echo "Format empty lines in {$file}", PHP_EOL;
$content = $_content;
$changed = true;
}
if ($changed) {
file_put_contents($file, $content);
}
} elseif (is_dir($file)) {
fix_tests_in_this_dir($file, $root);
}
}
}
$root = realpath(dirname(__DIR__));
$dirs = ['src', 'tests', 'sample'];
foreach ($dirs as $dir) {
fix_tests_in_this_dir($root . '/' . $dir, $root);
}
echo 'Format done', PHP_EOL;

View File

@@ -0,0 +1,85 @@
#!/usr/bin/env php
<?php
/**
* User: sy-records
* Email: lufei@php.net
* Usage: php bin/release or php bin/release version
*/
require_once 'vendor/autoload.php';
use Qcloud\Cos\Client;
use Qcloud\Cos\Service;
use GuzzleHttp\Command\Guzzle\Description;
$class = new ReflectionClass(Client::class);
$oldDocComment = $class->getDocComment();
$clientFile = $class->getFileName();
$clientFileContent = file_get_contents($class->getFileName());
$des = new Description(Service::getService());
$operations = array_keys($des->getOperations());
$docComment = "/**\n";
$token = genToken();
foreach ($operations as $key => $operation) {
$type = $arg = $methodDesc = '';
$model = $des->getOperation($operation)->getResponseModel();
if ($des->hasModel($model)) {
$type = $des->getModel($model)->getType();
if (!empty($des->getOperation($operation)->getParams())) {
$arg = '(array $args)';
}
$methodDesc = '';
if (isset($token['method'][$operation])) {
$line = $token['method'][$operation];
if (isset($token['comment'][$line])) {
$methodDesc = $token['comment'][$line];
} elseif (isset($token['comment'][$line - 1])) {
$methodDesc = $token['comment'][$line - 1];
}
}
}
$docComment .= " * @method {$type} {$operation}{$arg} {$methodDesc}\n";
}
$docComment .= " * @see \Qcloud\Cos\Service::getService()\n";
$docComment .= ' */';
$data = str_replace($oldDocComment, $docComment, $clientFileContent);
$status = file_put_contents($clientFile, $data);
if ($status) {
echo 'Regenerate docComment successfully.', PHP_EOL;
}
if (isset($argv[1])) {
$version = $argv[1];
$versionContent = str_replace(Client::VERSION, $version, $data);
$status = file_put_contents($clientFile, $versionContent);
if ($status) {
echo 'Update version successfully.', PHP_EOL;
}
}
function genToken()
{
$result = [];
$token = token_get_all(file_get_contents(dirname(__DIR__) . '/src/Service.php'));
foreach ($token as $value) {
if (!is_array($value) || !in_array($value[0], [T_COMMENT, T_CONSTANT_ENCAPSED_STRING])) {
continue;
}
switch ($value[0]) {
case T_COMMENT:
$result['comment'][$value[2]] = trim(ltrim($value[1], '//'));
break;
case T_CONSTANT_ENCAPSED_STRING:
$key = trim($value[1], "'");
if(!isset($result['method'][$key])) {
$result['method'][$key] = $value[2];
}
break;
}
}
return $result;
}